Natrium docs
  • ๐ŸงชOverview
    • ๐Ÿ“–Introducing Natrium
    • ๐Ÿ”ฎVision
  • โš™๏ธProtocol Overview
    • ๐ŸŒProtocol architecture
      • โšœ๏ธNatrium Core & Enterprise
    • ๐ŸŒŠLiquidations
    • ๐Ÿ“ˆInterest Rate Models
    • โšกOracles
    • โš–๏ธProtocol Fees
  • ๐Ÿ’ฐTokenomics
    • ๐Ÿš€Presale & Launch
    • ๐ŸงฌNTM & NaCl
  • โš’๏ธDev Docs
    • ๐Ÿ”‘Contract specs
      • Isolated Pools (Layer 1)
        • Bucket config
        • Supply underlying asset
        • Withdraw underlying asset
        • Deposit OverCollateralized asset
        • Borrow
        • Repay
        • Withdraw OverCollaterlized asset
        • Liquidate
      • Shufflers (Layer 2)
        • Contract functionalities
          • Shuffler Creation
          • Shuffler Management
          • Supply Cap Management
          • Risk Exposure Management
      • Error Library
        • Error lib
  • ๐Ÿ“šLibrary
    • Brand Assets
    • Community Links
    • Legal Disclaimer
Powered by GitBook
On this page
  1. โš’๏ธDev Docs
  2. ๐Ÿ”‘Contract specs
  3. Isolated Pools (Layer 1)

Deposit OverCollateralized asset

PreviousWithdraw underlying assetNextBorrow

Last updated 1 year ago

CtrlK

supplyCollateral is used in supplying an overcollaterized into the protocol

function supplyCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, bytes calldata data)
    external
{
    Id id = marketParams.id();
    require(market[id].lastUpdate != 0, ErrorsLib.MARKET_NOT_CREATED);
    require(assets != 0, ErrorsLib.ZERO_ASSETS);
    require(onBehalf != address(0), ErrorsLib.ZERO_ADDRESS);

    // Don't accrue interest because it's not required and it saves gas.

    position[id][onBehalf].collateral += assets.toUint128();

    emit EventsLib.SupplyCollateral(id, msg.sender, onBehalf, assets);

    if (data.length > 0) INatriumSupplyCollateralCallback(msg.sender).onNatriumSupplyCollateral(assets, data);

    IERC20(marketParams.collateralToken).safeTransferFrom(msg.sender, address(this), assets);
}