How to Repay

You can repay any supported asset and close borrow positions across any chain through Replete by interacting with RepletePool.

Repaying an asset is often straight forward, where you supply the borrowed asset to repay debt positions. However, if interacting with RepletePool, there are a few things to note, for example if there are excess assets provided for the repayment:

  • The default behavior is that excess assets are supplied to the pool on behalf of onBehalfOf. Allows for the user to withdraw the asset on any chain in another transaction.

  • transferExtraAssets is an option to allow for transferring the excess supplied assets to onBehalfOf on Arbitrum instead of doing the default behavior above.

From Any Chain

To repay native token (if supported) through RepletePool, set the asset parameter as RepletePool.ETH_ADDRESS() and set amount as the intended repay 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

 /**
  * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned
  * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address
  * @param asset The local address of the borrowed underlying asset
  * @param amount The amount to repay in local asset decimals
  * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
  * @param onBehalfOf The remote address of the user to repay for on Pool Chain
  * @param transferExtraAssets Option to enable transferring the unbridged assets to `onBehalfOf`
  *  on Pool Chain instead of doing the default behavior (extra assets are supplied to `onBehalOf`).
  * @param stgParams Stargate v1 related bridge parameters
  */
 function repay(
     address asset,
     uint256 amount,
     uint8 interestRateMode,
     address onBehalfOf,
     bool transferExtraAssets,
     StargateSupplyParams calldata stgParams
 ) external payable;

Stargate v2

Example

Stargate v1

Stargate v2

Last updated

Was this helpful?