You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
function WETH_ADDRESS() externalviewreturns (address payable)
Returns
Name
Type
Description
_0
address payable
undefined
baseTokens
function baseTokens(uint256) externalviewreturns (contractIERC20)
Parameters
Name
Type
Description
_0
uint256
undefined
Returns
Name
Type
Description
_0
contract IERC20
undefined
calculateRemoveLiquidityOneToken
function calculateRemoveLiquidityOneToken(uint256tokenAmount, uint8tokenIndex) externalviewreturns (uint256availableTokenAmount)
Calculate the amount of underlying token available to withdraw when withdrawing via only single token
Parameters
Name
Type
Description
tokenAmount
uint256
the amount of LP token to burn
tokenIndex
uint8
index of which token will be withdrawn
Returns
Name
Type
Description
availableTokenAmount
uint256
calculated amount of underlying token available to withdraw
calculateTokenAmount
function calculateTokenAmount(uint256[] amounts, booldeposit) externalviewreturns (uint256)
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
Name
Type
Description
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
Name
Type
Description
_0
uint256
token amount the user will receive
deposit
function deposit(addressto, uint256chainId, contractIERC20token, uint256amount) externalnonpayable
Wraps SynapseBridge deposit() function
Parameters
Name
Type
Description
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
function depositAndSwap(addressto, uint256chainId, contractIERC20token, uint256amount, uint8tokenIndexFrom, uint8tokenIndexTo, uint256minDy, uint256deadline) externalnonpayable
Wraps SynapseBridge depositAndSwap() function
Parameters
Name
Type
Description
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
function depositETH(addressto, uint256chainId, uint256amount) externalpayable
Wraps SynapseBridge deposit() function to make it compatible w/ ETH -> WETH conversions
Parameters
Name
Type
Description
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
function depositETHAndSwap(addressto, uint256chainId, uint256amount, uint8tokenIndexFrom, uint8tokenIndexTo, uint256minDy, uint256deadline) externalpayable
Wraps SynapseBridge depositAndSwap() function to make it compatible w/ ETH -> WETH conversions
Parameters
Name
Type
Description
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
function redeem(addressto, uint256chainId, contractIERC20token, uint256amount) externalnonpayable
Wraps SynapseBridge redeem() function
Parameters
Name
Type
Description
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
function redeemAndRemove(addressto, uint256chainId, contractIERC20token, uint256amount, uint8liqTokenIndex, uint256liqMinAmount, uint256liqDeadline) externalnonpayable
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
Name
Type
Description
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
function redeemAndSwap(addressto, uint256chainId, contractIERC20token, uint256amount, uint8tokenIndexFrom, uint8tokenIndexTo, uint256minDy, uint256deadline) externalnonpayable
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
Name
Type
Description
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
function redeemv2(bytes32to, uint256chainId, contractIERC20token, uint256amount) externalnonpayable
Wraps SynapseBridge redeemv2() function
Parameters
Name
Type
Description
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
function zapAndDeposit(addressto, uint256chainId, contractIERC20token, uint256[] liquidityAmounts, uint256minToMint, uint256deadline) externalnonpayable
Combines adding liquidity to the given Swap, and calls deposit() on the bridge using that LP token
Parameters
Name
Type
Description
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