StargateAdapter
StargateAdapter
is a contract that vaults use to interact and bridge assets between chains through Stargate.
Write functions
sendTokens
function sendTokens(
address _vault,
uint32 _dstEid,
address _token,
uint _amountLD,
bytes32 _intentionId
)
MAAT vault call this function to send tokens to vault on other chain. Only callable by the vault or admin.
Params
_vault
address
Address of the destination vault
_dstEid
uint32
LayerZero endpoint ID for the destination chains.
_token
address
Address of the token to be sent
_amountLD
uint
Amount of tokens to be sent
_intentionId
bytes32
Intention id
function sendTokensToReceiver( uint32 _dstEid, address _token, uint _amountLD, address _receiver )
If a user creates a withdrawal request on one chain but wants to receive the tokens on another chain, they can specify the dstEid. The vault will send the tokens to the user through the StargateAdapter by calling this function. Only callable by the vault or admin.
Params
_dstEid
uint32
LayerZero endpoint ID for the destination chains.
_token
address
Address of the token to be sent
_amountLD
uint
Amount of tokens to be sent
lzCompose
function lzCompose(...)
Function to call by LayerZero.
depositOnSrcChain
function depositOnSrcChain(
address _vault,
uint _amount,
bytes32 _intentionId
)
Deposit tokens to vault on the source chain. This is necessary if the bridge fails and the tokens remain in the StargateAdapter. Only callable by the vault or admin.
Params
_vault
address
Address of the vault
_amount
uint
Amount of tokens to be sent
_intentionId
bytes32
Intention id
withdraw
function withdraw(address to, uint amount)
Withdraw native from the StargateAdapter. Only callable by the admin.
Params
to
address
Address of the receiver
amount
uint
Amount of native to be withdrawn
sweep
function sweep(address to, address token, uint amount)
Withdraw any token from the StargateAdapter. Only callable by the admin.
Params
to
address
Address of the receiver
token
address
Address of the token to be withdrawn
amount
uint
Amount of token to be withdrawn
setDstAdapter
function setDstAdapter(
uint32 _dstEid,
address _dstAdapterAddress
)
Set the destination StargateAdapter address for a given destination chain. The StargateAdapter can only send tokens to the configured StargateAdapter on the other chain. Only callable by the admin.
Params
_dstEid
uint32
LayerZero endpoint ID for the destination chains.
_dstAdapterAddress
address
Address of the destination StargateAdapter
setStargate
function setStargate(address _stargate)
Set the Stargate address. Only callable by the admin.
Params
_stargate
address
Address of the Stargate
setLzExtraOptions
function setLzExtraOptions(
uint32 _dstEid,
uint _extraOptions
)
Set the LayerZero extra options for a given destination chain. Only callable by the admin.
Params
_dstEid
uint32
LayerZero endpoint ID for the destination chains.
_extraOptions
uint
Extra options for LayerZero
Read functions
isDstAdapterExists
function isDstAdapterExists(uint32 dstEid)
Check if the destination StargateAdapter exists for a given destination chain.
Params
dstEid
uint32
LayerZero endpoint ID for the destination chains.
Returns
bool
True if the destination StargateAdapter exists, false otherwise
getDstAdapter
function getDstAdapter(uint32 dstEid)
Get the destination StargateAdapter address for a given destination chain.
Params
dstEid
uint32
LayerZero endpoint ID for the destination chains.
Returns
address
Address of the destination StargateAdapter
getStargateByToken
function getStargateByToken(address token)
Get the Stargate address for a given token.
Params
token
address
Address of the token
Returns
address
Address of the Stargate
Last updated