IMPORTANT
There is a special contract for security reasons: MetaRouterGateway.sol
.
Users should give approval on their tokens to the MetaRouterGateway
contract only, not to the MetaRouter
contract or any other contract.
During metaRoute
transactions, MetaRouter
(and only this contract) claims the user's tokens from the MetaRoutetGateway
contract and then
operates with them.
For general information about the protocol and its smart contracts, please refer to the Symbiosis documentation.
MetaRouter
defines a metaRoute
function that takes the MetaRouteTransaction
structure as an input value.
MetaRouteTransaction
has the following fields:
Name | Type | Description |
---|---|---|
firstSwapCalldata |
bytes |
Payload for the first swap on the source chain |
secondSwapCalldata |
bytes |
Payload for the second swap on the source chain |
approvedTokens |
address[] |
Tokens for approval. For the synthesize (mint) scheme, an empty array should be passed as an argument, unless the swap on the source chain is to be skipped. In this case, approvedTokens=[realTokenAddress] , where realTokenAddress is the address of the token to be synthesized on the destination chain. For the burn scheme, approvedTokens=[secondSourceTokenAddress, secondDestTokenAddress] , where secondSourceTokenAddress is the address of the source token for the second swap and secondDestTokenAddress is the address of the destination token for the second swap |
firstDexRouter |
address |
Address of the first (Uni-)DEX on the source chain |
secondDexRouter |
address |
Address of the second (Stablecoin-)DEX on the source chain |
amount |
uint256 |
Token amount to transfer |
nativeIn |
bool |
true for the native routing, otherwise false |
relayRecipient |
address |
Address of synthesis (the burn scheme) or portal (the synthesize/mint scheme) on the source chain |
otherSideCalldata |
bytes |
Payload for the call on the destination chain (metaBurnSyntheticToken for the burn scheme or metaSynthesize for the synthesize/mint scheme) |
If you use the burn scheme, then after two swaps on the first chain, the metaRoute
function calls metaBurnSyntheticToken
from
synthesis
, which takes the MetaBurnTransaction
structure as an input value.
MetaBurnTransaction
has the following fields:
Name | Type | Description |
---|---|---|
stableBridgingFee |
uint256 |
Transaction fee for bridging in stablecoins |
amount |
uint256 |
Amount of tokens to be burn |
syntCaller |
address |
Address of the owner of synthetic tokens (sTokens). It's the metarouter address, but only as an intermediary. If the transaction fails after synthetic tokens have been burned, the syntCaller address can call revertBurnRequest from Synthesis to get the synthetic tokens to this address |
finalReceiveSide |
address |
Address of the final DEX on the destination chain |
finalDexRouter |
address |
Address of the final DEX on the destination chain |
sToken |
address |
Address of the synthetic token (sToken) to be burned |
finalCalldata |
bytes |
Payload for the final call on the destination chain |
finalOffset |
uint256 |
Shift to patch the amount to calldata |
chain2address |
address |
Address on the destination chain to send the real representation of this token |
receiveSide |
address |
portal address on the destination chain |
oppositeBridge |
address |
bridgeV2 address on the destination chain |
revertableAddress |
address |
Address that can revert this operation if it gets stuck. It is usually identical to the sender's address, but can be different |
chainID |
uint256 |
Chain ID where portal is located |
clientID |
bytes32 |
Unique string that identifies the project calling the contract |
In case of MetaRouteReverseNative
you should pass bridging fee + amount
as an input value.
If you use the synthesize (mint) scheme, then after the first swap on the source chain, metaRouter
calls the metaSynthesize
function, which
takes the MetaSynthesizeTransaction
structure as an input value.
MetaSynthesizeTransaction
has the following fields:
Name | Type | Description |
---|---|---|
stableBridgingFee |
uint256 |
Transaction fee for bridging in stablecoins |
amount |
uint256 |
Token amount to be synthesized |
rtoken |
address |
Real representation of synthetic token (sToken) to be synthesized on the destination chain |
chain2address |
address |
Address on the destination chain to send the real representation of this token |
receiveSide |
address |
synthesis address on the destination chain |
oppositeBridge |
address |
bridgeV2 address on the destination chain |
syntCaller |
address |
Address of the owner of synthetic tokens (sTokens). It's the metarouter address, but only as an intermediary. If the transaction fails after synthetic tokens have been burned, the syntCaller address can call revertBurnRequest from synthesis to get the synthetic tokens to this address |
chainID |
uint256 |
Chain ID where portal is located |
swapTokens |
address[] |
Array of tokens for the first and final swaps after minting (the second and the third swaps, if we count the swap on the first chain before synthesizing); it has a zero length for no swaps, two token addresses for the first swap only, or four token addresses for two swaps |
secondDexRouter |
address |
Address of the second DEX |
secondSwapCalldata |
bytes |
Payload for the first swap on the destination chain |
finalReceiveSide |
address |
Address of the final DEX on the destination chain |
finalCalldata |
bytes |
Payload for the final call on the destination chain |
finalOffset |
uint256 |
Shift to patch the amount to calldata |
revertableAddress |
address |
Address that can revert this operation if it gets stuck. It is usually identical to the sender's address, but can be different. |
clientID |
bytes32 |
Unique string that identifies the project that calls the contract functions |
The metaSynthesize
function transmits calls of the metaMintSyntheticToken
function, which takes the MetaMintTransaction
structure as an input value.
MetaMintTransaction
has the following fields:
Name | Type | Description |
---|---|---|
stableBridgingFee |
uint256 |
Transaction fee for bridging in stablecoins |
amount |
uint256 |
Token amount to be minted |
externalID |
bytes32 |
External synthesize transaction's ID |
tokenReal |
address |
Real representation of synthetic token (sToken) to be synthesized on the destination chain |
chainID |
uint256 |
Chain ID |
to |
address |
Recipient address of synthetic tokens (sTokens) |
swapTokens |
address[] |
Array of tokens for the first and final swaps after synthesizing (the second and the third swaps, if we count the swap on the first chain before synthesizing); it has a zero length for no swaps, two token addresses for the first swap only, and four token addresses for two swaps |
secondDexRouter |
address |
address of the second DEX |
secondSwapCalldata |
uint256 |
Payload for the first swap on the destination chain |
finalReceiveSide |
address |
Address of the final DEX on the destination chain |
finalCalldata |
bytes |
Payload for the final call on the destination chain |
finalOffset |
uint256 |
Shift to patch the amount to calldata |