# How to Supply

{% hint style="danger" %}
When supplying take care to input the correct data. Make sure you are supplying to a wallet you can control on Pool Chain (Arbitrum).
{% endhint %}

You can supply any supported asset and earn interest across any chain through Replete by interacting with [RepletePool](/contracts/repletepool.md) . After supplying collateral, you are able to create borrow positions with supported assets or withdraw to a different chain.

{% hint style="warning" %}
The provided `onBehalfOf` will receive [rTokens](https://docs.aave.com/developers/tokens/atoken) on Pool Chain and requires no user interaction.
{% endhint %}

### From Any Chain

{% hint style="warning" %}
When supplying, ensure the [RepletePool](/contracts/repletepool.md) contract has enough allowance to spend funds on behalf of `msg.sender` for the amount being supplied.
{% endhint %}

To supply native token (if supported) through [RepletePool](/contracts/repletepool.md), set the `asset` parameter as `RepletePool.ETH_ADDRESS()` and set `amount` as the intended supply amount. Ensure that `msg.value` covers the bridge transfer fee too. `msg.value` should equal `amount` + `bridgeFee`.

If supplying native is not supported, the function will revert with error `Replete_UnsupportedAsset(address asset)`

#### Interface

#### Stargate v1

{% code fullWidth="true" %}

```solidity
 /**
  * @notice Supplies an `amount` of `asset` into the reserve, receiving in return overlying rTokens.
  * - E.g. User supplies 100 USDC and gets in return 100 rUSDC
  * @dev Ensure that this contract has enough allowance to spend `asset` locally
  * @param asset The local underlying asset to supply
  * @param amount The amount to be supplied in local asset decimals
  * @param onBehalfOf The address that will receive the rTokens on Pool Chain.
  *  Even if you will not transact on Pool Chain, it is recommended to set this
  *  to an address you can control.
  * @param referralCode Referral code for integrators -- can safely set to 0
  * @param stgParams Stargate v1 related bridge parameters
  */
function supply(
   address asset,
   uint256 amount,
   address onBehalfOf,
   uint16 referralCode,
   StargateSupplyParams calldata stgParams
) external payable;
```

{% endcode %}

#### Stargate v2

{% code fullWidth="true" %}

```solidity
 /**
  * @notice Supplies an `amount` of `asset` into the reserve, receiving in return overlying rTokens.
  * - E.g. User supplies 100 USDC and gets in return 100 rUSDC
  * @dev Ensure that this contract has enough allowance to spend `asset` locally
  * @param asset The local underlying asset to supply
  * @param amount The amount to be supplied in local asset decimals
  * @param onBehalfOf The address that will receive the rTokens on Pool Chain.
  *  Even if you will not transact on Pool Chain, it is recommended to set this
  *  to an address you can control.
  * @param referralCode Referral code for integrators -- can safely set to 0
  * @param stgParams Stargate v2 related bridge parameters
  */
 function supply(
     address asset,
     uint256 amount,
     address onBehalfOf,
     uint16 referralCode,
     StargateV2SupplyParams calldata stgParams
 ) external payable returns (Ticket memory);
```

{% endcode %}

#### Example

#### Stargate v1

{% code fullWidth="true" %}

```solidity
RepletePool.supply{value: bridgeFee}({
    asset: address(DAI),                           // local chain DAI address
    amount: 1337 * 1e18,                           // supply 1337 DAI
    onBehalfOf: msg.sender,                        // who is this supply for
    referralCode: 0,                               // referral code; you can safely set to 0
    stgParams: StargateSupplyParams({              // ~~ Stargate v1 related parameters ~~
        dstGasForCall: 500_000,                    // 500k gas for the destination tx
        dstNativeAmount: 0,                        // native gas airdrop in the destination tx
        dstNativeAddr: RepletePool.destAddress(),  // {BridgeReceiver} address on Pool Chain
        srcPoolId: srcPoolId,                      // source Stargate v1 pool ID
        dstPoolId: dstPoolId,                      // destination Stargate v1 pool ID
        refundAddress: payable(msg.sender),        // refund address
        minAmountLD: 1337 * 1e18                   // set max slippage amount
    })
});
```

{% endcode %}

#### Stargate v2

{% code fullWidth="true" %}

```solidity
RepletePool.supply{value: bridgeFee}({
    asset: address(DAI),                     // local chain DAI address
    amount: 1337 * 1e18,                     // supply 1337 DAI
    onBehalfOf: msg.sender,                  // who is this supply for
    referralCode: 0,                         // referral code; you can safely set to 0
    stgParams: StargateV2SupplyParams({      // ~~ Stargate v2 related parameters ~~
        router: stargateDAIPool,             // Stargate v2 DAI pool address
        extraOptions: extraOptions,          // LZv2 composed message execution options
        oftCmd: "",                          // unused for Stargate taxi transactions 
        refundAddress: payable(msg.sender),  // refund address
        minAmountLD: 1337 * 1e18             // set max slippage amount  
    })
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.replete.fi/developers/how-to-supply.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
