User Functions
Breakdown of all user functions
Spoke
Spoke user actions require a costForReturnDelivery
parameter, which is the total fee a user pays the Wormhole relayer to deliver a message from a Hub to a Spoke. The fee depends on current gas prices and the relayer fee. The value for this parameter can be retrieved from Hub.getCostForReturnDelivery()
. It covers data and tokens transfer from the Hub to the Spoke (e.g. borrow, withdraw) as well as handling sending tokens back to the user in case the cross-chain transaction fails on the Hub (e.g. deposit, repay).
Spoke user actions, require also a Wormhole relayer fee to cover sending data and tokens from Spoke to Hub. This is handled internally with a Spoke.getDeliveryCostRoundtrip()
function. This additional fee is only paid if any tokens are sent from the Spoke to the Hub, so only during deposits and repays.
The surplus is refunded to the user on the Spoke chain.
Spoke.depositCollateral(...)
Initiates a deposit from a Spoke chain
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
asset
- asset address on the Spoke chainassetAmount
costForReturnDelivery
Spoke.withdrawCollateral(...)
Initiates a withdrawal to a Spoke chain
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, false)
asset
- asset address on the Spoke chainassetAmount
costForReturnDelivery
Spoke.borrow(...)
Initiates a borrow to a Spoke chain
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, false)
asset
- asset address on the Spoke chainassetAmount
costForReturnDelivery
Spoke.repay(...)
Initiates a repay from a Spoke chain
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
asset
- asset address on the Spoke chainassetAmount
costForReturnDelivery
Spoke.depositCollateralNative(...)
Initiates a Spoke native asset deposit from a Spoke chain, wrapping the native asset before bridging it.
Params
msg.value
- should be greather thanSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
- the surplus will be what a user depositscostForReturnDelivery
Spoke.repayNative(...)
Initiates a Spoke native asset repay from a Spoke chain, wrapping the native asset before bridging it.
Params
msg.value
- should be greather thanSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
- the surplus will be what a user repayscostForReturnDelivery
Spoke.withdrawCollateralNative(...)
Initiates a Spoke native asset withdrawal to a Spoke chain, wrapping the native asset before bridging it.
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
assetAmount
costForReturnDelivery
unwrap
- iftrue
, the native asset will be unwrapped before delivery to the user
Spoke.borrowNative(...)
Initiates a Spoke native asset borrow to a Spoke chain, wrapping the native asset before bridging it.
Params
msg.value
- should equal toSpoke.getDeliveryCostRoundtrip(costForReturnDelivery, true)
assetAmount
costForReturnDelivery
unwrap
- iftrue
, the native asset will be unwrapped before delivery to the user
Hub
Hub.userActions(...)
Allows users to perform actions on the vault from the Hub chain
Params
action
-Deposit
|Borrow
|Withdraw
|Repay
|DepositNative
|RepayNative
asset
- USDC or a Wormhole wrapped version of the assetamount
borrowOrWithdrawNative(...)
Allows users to borrow or withdraw the native asset
Params
action
-Action.Withdraw
|Action.Borrow
amount
unwrap
- iffalse
, the user will receive the wrapped version of the native asset. Otherwise the nave asset will be unwrapped before being sent to the user.
Liquidator functions (Hub)
Liquidation parameters
ILiquidationCalculator.LiquidationInput
vault
- the address of the vault that is being liquidated
ILiquidationCalculator.DenormalizedLiquidationAsset
For every asset to be received or repaid a liquidation asset entry must be provided
assetAddress
- the address of the repaid/received asset (USDC or a Wormhole wrapped version of the asset)repaidAmount
- the amount of the asset that is being repaid (can be zero)receivedAmount
- The amount of the asset that is being received (can be zero)depositTakeover
- A flag if the liquidator will take the deposit of the debtor instead of collateral tokens. This is useful in case the assets to be received are not currently available in the protocol (have borrowed) or if the liquidator just wants to deposit the received tokens anyway. If a liquidator chooses to takeover the deposit instead of receiving the tokens directly there's a regular deposit created for them, which earns yield.
Functions
Hub.liquidation(...)
Params
input
-ILiquidationCalculator.LiquidationInput
Last updated