Skip to main content

TridentRouter

The TridentRouter contract is a contract that facilitates in the swapping of assets across Trident pools.

The full contract can be found here.

Functions

exactInputSingle

function exactInputSingle(ExactInputSingleParams calldata params) public payable returns (uint256 amountOut)

Swaps token A to token B directly; swaps are done on bento tokens.

Parameters

NameTypeDescription
paramsExactInputSingleParamsaddress of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap

Returns

NameTypeDescription
amountOutuint256amount of token B after swap

exactInput

function exactInput(ExactInputParams calldata params) public payable returns (uint256 amountOut)

Swaps token A to token B indirectly by using multiple hops.

Parameters

NameTypeDescription
paramsExactInputSingleParamsaddress of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap

Returns

NameTypeDescription
amountOutuint256amount of token B after swap

exactInputSingleWithNativeToken

function exactInputSingleWithNativeToken(ExactInputSingleParams calldata params) public payable returns (uint256 amountOut)

Swaps token A to token B directly; it is the same as exactInputSingle except it takes raw ERC-20 tokens from the users and deposits them into bento.

Parameters

NameTypeDescription
paramsExactInputSingleParamsaddress of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap

Returns

NameTypeDescription
amountOutuint256amount of token B after swap

exactInputWithNativeToken

function exactInputWithNativeToken(ExactInputParams calldata params) public payable returns (uint256 amountOut)

Swaps token a to token B indirectly by using multiple hops; it is the same as exactInput except it takes raw ERC-20 tokens from the users and deposits them into bento.

Parameters

NameTypeDescription
paramsExactInputSingleParamsaddress of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap

Returns

NameTypeDescription
amountOutuint256amount of token B after swap

complexPath

function complexPath(ComplexPathParams calldata params) public payable

Swaps multiple input tokens to multiple output tokens using multiple paths, in different percentages.

Parameters

NameTypeDescription
paramsComplexPathParamsincludes all info needed for the swap

addLiquidity

function addLiquidity(
TokenInput[] calldata tokenInput,
address pool,
uint256 minLiquidity,
bytes calldata data
) public payable returns (uint256 liquidity)

Adds liquidity to a pool.

Parameters

NameTypeDescription
tokenInputTokenInput[]token address and amount to add as liquidity
pooladdressaddress of pool to add liquidity to
minLiquidityuint256minimum output liquidity (caps slippage)
databytesdata required by pool to add liquidity

Returns

NameTypeDescription
liquidityuint256amount of liquidity added to chosen pool

burnLiquidity

function burnLiquidity(
address pool,
uint256 liquidity,
bytes calldata data,
IPool.TokenAmount[] calldata minWithdrawals
) public payable

Burns liquidity tokens to get back bento tokens.

Parameters

NameTypeDescription
pooladdressaddress of pool
liquidityuint256amount of liquidity tokens to burn
databytesdata required by pool to burn liquidity
minWithdrawalsIPool.TokenAmount[]minimum amount of bento tokens to be returned

burnLiquiditySingle

function burnLiquiditySingle(
address pool,
uint256 liquidity,
bytes calldata data,
uint256 minWithdrawal
) public payable

Burns liquidity tokens to get back bento tokens; the tokens are swapped automatically and the output is in a single token.

Parameters

NameTypeDescription
pooladdressaddress of pool
liquidityuint256amount of liquidity tokens to burn
databytesdata required by pool to burn liquidity
minWithdrawalsIPool.TokenAmount[]minimum amount of tokens to be returned

sweep

function sweep(
address token,
uint256 amount,
address recipient,
bool fromBento
) external payable

Recovers mistakenly sent tokens.

Parameters

NameTypeDescription
tokenaddressaddress of token
amountuint256amount to recover
recipientaddressaddress to return tokens to
fromBentoboolboolean to convert from bento tokens

unwrapWETH

function unwrapWETH(address recipient) external payable

Helper function to unwrap this contract's wETH into ETH.

Parameters

NameTypeDescription
recipientaddressaddress to send unwrapped ETH to

deployPool

function deployPool(address factory, bytes calldata deployData) external payable returns (address)

Wrapper function to allow pool deployment to be batched and returns the address of the deployed pool.

approveMasterContract

function approveMasterContract(
uint8 v,
bytes32 r,
bytes32 s
) external payable

Parameters

NameTypeDescription
vuint8recovery byte of the signature
rbytes32half of the ECDSA signature pair
sbytes32half of the ECDSA signature pair

Wrapper function to allow Bento set master contract approval to be batched, so that the first trade can happen in a single transaction.

harvest

function harvest(address token, uint256 maxChangeAmount) external payable

Rebalances a BentoBox token strategy and ensures there are enough tokens available to withdraw a swap amount.

Parameters

NameTypeDescription
tokenaddressaddress of token
maxChangeAmountuint256the max change amount

_depositToBentoBox

function _depositToBentoBox(
address token,
address recipient,
uint256 amount
) internal

Internal function used by others that deposits from the user's wallet into BentoBox.

Parameters

NameTypeDescription
tokenaddressaddress of token to deposit
recipientaddressaddress of recipient
amountuint256amount to deposit