L1BridgeZap
L1BridgeZap
This contract is responsible for handling user Zaps into the SynapseBridge contract, through the Synapse Swap contracts. It does so It does so by combining the action of addLiquidity() to the base swap pool, and then calling either deposit() or depositAndSwap() on the bridge. This is done in hopes of automating portions of the bridge user experience to users, while keeping the SynapseBridge contract logic small.
This contract should be deployed with a base Swap.sol address and a SynapseBridge.sol address, otherwise, it will not function.
Methods
WETH_ADDRESS
Returns
_0
address payable
undefined
baseTokens
Parameters
_0
uint256
undefined
Returns
_0
contract IERC20
undefined
calculateRemoveLiquidityOneToken
Calculate the amount of underlying token available to withdraw when withdrawing via only single token
Parameters
tokenAmount
uint256
the amount of LP token to burn
tokenIndex
uint8
index of which token will be withdrawn
Returns
availableTokenAmount
uint256
calculated amount of underlying token available to withdraw
calculateTokenAmount
A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various "min" parameters on calls to fight front-running
This shouldn't be used outside frontends for user estimates.
Parameters
amounts
uint256[]
an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision.
deposit
bool
whether this is a deposit or a withdrawal
Returns
_0
uint256
token amount the user will receive
deposit
Wraps SynapseBridge deposit() function
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees*
depositAndSwap
Wraps SynapseBridge depositAndSwap() function
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees
tokenIndexFrom
uint8
the token the user wants to swap from
tokenIndexTo
uint8
the token the user wants to swap to
minDy
uint256
the min amount the user would like to receive, or revert to only minting the SynERC20 token crosschain.
deadline
uint256
latest timestamp to accept this transaction*
depositETH
Wraps SynapseBridge deposit() function to make it compatible w/ ETH -> WETH conversions
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees*
depositETHAndSwap
Wraps SynapseBridge depositAndSwap() function to make it compatible w/ ETH -> WETH conversions
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees
tokenIndexFrom
uint8
the token the user wants to swap from
tokenIndexTo
uint8
the token the user wants to swap to
minDy
uint256
the min amount the user would like to receive, or revert to only minting the SynERC20 token crosschain.
deadline
uint256
latest timestamp to accept this transaction*
redeem
Wraps SynapseBridge redeem() function
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to redeem into the bridge
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees*
redeemAndRemove
Wraps redeemAndRemove on SynapseBridge Relays to nodes that (typically) a wrapped synAsset ERC20 token has been burned and the underlying needs to be redeeemed on the native chain. This function indicates to the nodes that they should attempt to redeem the LP token for the underlying assets (E.g "swap" out of the LP token)
Parameters
to
address
address on other chain to redeem underlying assets to
chainId
uint256
which underlying chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
amount
uint256
Amount of (typically) LP token to pass to the nodes to attempt to removeLiquidity() with to redeem for the underlying assets of the LP token
liqTokenIndex
uint8
Specifies which of the underlying LP assets the nodes should attempt to redeem for
liqMinAmount
uint256
Specifies the minimum amount of the underlying asset needed for the nodes to execute the redeem/swap
liqDeadline
uint256
Specificies the deadline that the nodes are allowed to try to redeem/swap the LP token*
redeemAndSwap
Wraps redeemAndSwap on SynapseBridge.sol Relays to nodes that (typically) a wrapped synAsset ERC20 token has been burned and the underlying needs to be redeeemed on the native chain. This function indicates to the nodes that they should attempt to redeem the LP token for the underlying assets (E.g "swap" out of the LP token)
Parameters
to
address
address on other chain to redeem underlying assets to
chainId
uint256
which underlying chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees
tokenIndexFrom
uint8
the token the user wants to swap from
tokenIndexTo
uint8
the token the user wants to swap to
minDy
uint256
the min amount the user would like to receive, or revert to only minting the SynERC20 token crosschain.
deadline
uint256
latest timestamp to accept this transaction*
redeemv2
Wraps SynapseBridge redeemv2() function
Parameters
to
bytes32
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to redeem into the bridge
amount
uint256
Amount in native token decimals to transfer cross-chain pre-fees*
zapAndDeposit
Combines adding liquidity to the given Swap, and calls deposit() on the bridge using that LP token
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
liquidityAmounts
uint256[]
the amounts of each token to add, in their native precision
minToMint
uint256
the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation
deadline
uint256
latest timestamp to accept this transaction*
zapAndDepositAndSwap
Combines adding liquidity to the given Swap, and calls depositAndSwap() on the bridge using that LP token
Parameters
to
address
address on other chain to bridge assets to
chainId
uint256
which chain to bridge assets onto
token
contract IERC20
ERC20 compatible token to deposit into the bridge
liquidityAmounts
uint256[]
the amounts of each token to add, in their native precision
minToMint
uint256
the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation
liqDeadline
uint256
latest timestamp to accept this transaction
tokenIndexFrom
uint8
the token the user wants to swap from
tokenIndexTo
uint8
the token the user wants to swap to
minDy
uint256
the min amount the user would like to receive, or revert to only minting the SynERC20 token crosschain.
swapDeadline
uint256
latest timestamp to accept this transaction*
Last updated