IBlueshiftRouter

Parameter Structs
Functions

Parameter Structs

Signature

struct Signature {
Β Β Β Β Β Β Β Β uint8 v;
Β Β Β Β Β Β Β Β bytes32 r;
Β Β Β Β Β Β Β Β bytes32 s;
Β Β Β Β }

Standard ECDSA signature structure.

PermitStruct

struct PermitStruct {
        address owner;
        address spender;
        uint256 value;
        uint256 deadline;
        Signature signature;
    }

Structure that holds all the data for token spend permit operation.

Fields description

Name

Type

Description

owner

address

Token's owner

spender

address

Token's spender

value

uint256

Amount of tokens that owner approves to be spent by spender

deadline

uint256

Timestamp indicates when the signature expires

signature

struct

PS.Signature

Standard ECDSA signature. Signer (owner) signs all other structure's fields together and then adds a signature field

Functions

WETH

function WETH() external view returns (address)

Returns current network's wrapped native token`s address.

swapExactTokensForTokensWithPortfolios

function swapExactTokensForTokensWithPortfolios(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external returns (uint256[] memory amounts)

Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of the path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). Properly works with fee-on-transfer tokens.

Parameters

Name

Type

Description

amountIn

uint256

Amount of swap's input token

amountOutMin

uint256

Minimal amount of swap's output token. If less tokens are received by swap transaction is reverted

path

address[]

Tokens' addresses to perform swap through

to

address

Output token's receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

A destination chain identifier for cross-chain swaps. Must be 0 for local swaps.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[amounts.length - 1] is the output token amount out.

amounts.length == path.length - 1

swapTokensForExactTokensWithPortfolios

function swapTokensForExactTokensWithPortfolios(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external returns (uint256[] memory amounts)

Receive an exact amount of output tokens for as few input tokens as possible, along the route determined by the path. The first element of the path is the input token, the last is the output token, and any intermediate elements represent intermediate tokens to trade through (if, for example, a direct pair does not exist).

Parameters

Name

Type

Description

amountOut

uint256

Amount of swap`s output token

amountInMax

uint256

Maximal amount of swap`s input token. If more tokens are required by swap transaction is reverted

path

address[]

Tokens` addresses to perform swap through

to

address

Output token`s receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

Must be 0.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[0] is the input token amount in.

amounts.length == path.length - 1

swapExactETHForTokensWithPortfolios

function swapExactETHForTokensWithPortfolios(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external payable returns (uint256[] memory amounts)

Swaps an exact amount of ETH for as many output tokens as possible, along the route determined by the path. The first element of the path must be WETH (wrapped native token), the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). Properly works with fee-on-transfer tokens.

Parameters

Name

Type

Description

amountOutMin

uint256

Minimal amount of swap`s output token. If less tokens are received by swap transaction is reverted

path

address[]

Tokens` addresses to perform swap through. path[0] must be WETH address, otherwise transaction is reverted

to

address

Output token`s receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

A destination chain identifier for cross-chain swaps. Must be 0 for local swaps.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[amounts.length - 1] is the output token amount out.

amounts.length == path.length - 1

swapTokensForExactETHWithPortfolios

function swapTokensForExactETHWithPortfolios(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external returns (uint256[] memory amounts)

Receive an exact amount of ETH for as few input tokens as possible, along the route determined by the path. The first element of the path is the input token, the last must be WETH (wrapped native token), and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).

Parameters

Name

Type

Description

amountOut

uint256

Amount of ETH received through swap

amountInMax

uint256

Maximal amount of swap`s input token. If more tokens are required by swap transaction is reverted

path

address[]

Tokens` addresses to perform swap through. path[path.length - 1] must be WETH address, otherwise transaction is reverted

to

address

ETH`s receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

Must be 0.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[0] is the input token amount in.

amounts.length == path.length - 1

swapExactTokensForETHWithPortfolios

function swapExactTokensForETHWithPortfolios(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external returns (uint256[] memory amounts)

Swaps an exact amount of tokens for as much ETH as possible, along the route determined by the path. The first element of the path is the input token, the last must be WETH, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). Properly works with fee-on-transfer tokens.

Parameters

Name

Type

Description

amountIn

uint256

Amount of swap`s input token

amountOutMin

uint256

Minimal amount of ETH received by swap. If less tokens are received by swap transaction is reverted

path

address[]

Tokens` addresses to perform swap through. path[path.length - 1] must be WETH address, otherwise transaction is reverted

to

address

ETH`s receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

A destination chain identifier for cross-chain swaps. Must be 0 for local swaps.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[amounts.length - 1] is the ETH amount out.

amounts.length == path.length - 1

swapETHForExactTokensWithPortfolios

function swapETHForExactTokensWithPortfolios(
        uint256 amountOut,
        address[] calldata path,
        address to,
        uint256 deadline,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external payable returns (uint256[] memory amounts)

Receive an exact amount of tokens for as little ETH as possible, along the route determined by the path. The first element of the path must be WETH, the last is the output token and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). If the required amount of ETH for swap exceeds msg.value transaction is reverted.

Parameters

Name

Type

Description

amountOut

uint256

Amount of swap`s output token

path

address[]

Tokens` addresses to perform swap through. path[0] must be WETH address, otherwise transaction is reverted

to

address

Output token`s receiver address

deadline

uint256

Timestamp indicates when the swap becomes irrelevant

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

Must be 0.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[0] is the ETH amount in.

amounts.length == path.length - 1

getAmountsOutWithPortfolios

function getAmountsOutWithPortfolios(
        uint256 amountIn,
        address[] calldata path,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external view returns (uint256[] memory amounts, uint16[] memory fees)

Returns swap`s output token`s amount out with given amount in and token`s path to swap through.

Parameters

Name

Type

Description

amountIn

uint256

Amount of swap`s input token

path

address[]

Tokens` addresses to perform swap through.

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

A destination chain identifier for cross-chain swaps. Must be 0 for local swaps.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[amounts.length - 1] is the output token amount out.

amounts.length == path.length - 1

fees

uint16[]

Amounts of fees withheld from all swaps.

fees.length == path.length - 1

getAmountsInWithPortfolios

function getAmountsInWithPortfolios(
        uint256 amountOut,
        address[] calldata path,
        address[] calldata portfolios,
        uint256 destinationChainId
    ) external view returns (uint256[] memory amounts, uint16[] memory fees)

Returns swap`s input token`s amount in with given amount out and token`s path to swap through.

Parameters

Name

Type

Description

amountOut

uint256

Amount of swap`s output token

path

address[]

Tokens` addresses to perform swap through.

portfolios

address[]

Addresses of portfolios that should perform chain swaps (swap path[i] token on path[i+1] token through portfolios[i] portfolio)

destinationChainId

uint256

Must be 0.

Return values

Name

Type

Description

amounts

uint256[]

Amounts out of all the tokens during swap. amounts[i] of path[i+1] token is the input amount for path[i+1] -> path[i+2] swap. amounts[0] is the input token amount in.

amounts.length == path.length - 1

fees

uint16[]

Amounts of fees withheld from all swaps.

fees.length == path.length - 1

addLiquidityToPortfolio

function addLiquidityToPortfolio(
        address[] calldata tokens,
        uint256[] calldata amountsIn,
        uint256 minAmountOut,
        address to,
        uint256 deadline,
        address portfolio,
        uint256 destinationChainId
    ) external payable returns (uint256 liquidity)

Performs deposit of tokens to specified portfolio.

Parameters

Name

Type

Description

tokens

address[]

Array of tokens` addresses to deposit

amountsIn

uint256[]

Amounts of tokens to deposit

minAmountOut

uint256

Minimal amount of LP tokens output. If less tokens are received during the deposit the transaction is reverted

to

address

Address of LP tokens receiver

deadline

uint256

Timestamp indicates when the deposit becomes irrelevant

portfolio

address

Address of the portfolio to deposit tokens to

destinationChainId

uint256

A destination chain identifier for cross-chain operations. Must be 0 for local operations.

Return values

Name

Type

Description

liquidity

uint256

Amount of LP tokens received after the deposit

removeLiquidityFromPortfolio (single token)

function removeLiquidityFromPortfolio(
        address token,
        uint256 liquidity,
        uint256 minAmountOut,
        address to,
        uint256 deadline,
        address portfolio,
        uint256 destinationChainId
    ) external returns (uint256 amountOut)

Performs single token`s withdrawal operation from specified portfolio.

Parameters

Name

Type

Description

token

address

Address of token to withdraw

liquidity

uint256

Amount of LP tokens to spend on withdrawal

minAmountOut

uint256

Minimal amount of token to receive during withdrawal. If less tokens are received the transaction is reverted

to

address

Address of token`s receiver

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

destinationChainId

uint256

A destination chain identifier for cross-chain operations. Must be 0 for local operations.

Return values

Name

Type

Description

amountOut

uint256

Amount of token received after withdrawal

removeLiquidityFromPortfolio (multiple tokens)

function removeLiquidityFromPortfolio(
        address[] calldata tokens,
        uint256[] calldata LPTamounts,
        uint256[] calldata minAmountsOut,
        address to,
        uint256 deadline,
        address portfolio,
        uint256 destinationChainId
    ) external returns (uint256[] memory amountsOut)

Performs multiple tokens` withdrawal operation from specified portfolio.

Parameters

Name

Type

Description

tokens

address[]

Addresses of tokens to withdraw

LPTamounts

uint256[]

Amount of LP tokens to spend on withdrawal of each token

minAmountsOut

uint256[]

Minimal amount of tokens to receive during withdrawal. If less tokens are received the transaction is reverted

to

address

Address of tokens` receiver

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

destinationChainId

uint256

A destination chain identifier for cross-chain operations. Must be 0 for local operations.

Return values

Name

Type

Description

amountsOut

uint256[]

Amount of tokens received after withdrawal

removeLiquidityFromPortfolio (last liquidity)

function removeLiquidityFromPortfolio(
        uint256 liquidity,
        address to,
        uint256 deadline,
        address portfolio
    ) external returns (uint256[] memory amountsOut)

Withdraws last liquidity from portfolio in all the portfolio tokens left if liquidity is the all remaining supply of LP tokens.

Parameters

Name

Type

Description

liquidity

uint256

Amount of LP tokens to spend on withdrawal

to

address

Address of tokens` receiver

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

Return values

Name

Type

Description

amountsOut

uint256[]

Amounts of tokens received after withdrawal

removeLiquidityWithPermitFromPortfolio (single token)

function removeLiquidityWithPermitFromPortfolio(
        address token,
        uint256 minAmountOut,
        address to,
        uint256 deadline,
        address portfolio,
        PS.PermitStruct calldata permitStruct
    ) external returns (uint256 amountOut)

Performs single token`s withdrawal operation from specified portfolio, using permit instead of additional approval transaction.

Parameters

Name

Type

Description

token

address

Address of token to withdraw

minAmountOut

uint256

Minimal amount of token to receive during withdrawal. If less tokens are received the transaction is reverted

to

address

Address of token`s receiver

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

permitStruct

struct

PS.PermitStruct

Permit struct with signature to be verified by LPT minter and transfer tokens without approval

Return values

Name

Type

Description

amountOut

uint256

Amount of token received after withdrawal

removeLiquidityWithPermitFromPortfolio (multiple tokens)

function removeLiquidityWithPermitFromPortfolio(
        address[] calldata tokens,
        uint256[] calldata LPTamounts,
        uint256[] calldata minAmountsOut,
        address to,
        uint256 deadline,
        address portfolio,
        PS.PermitStruct calldata permitStruct
    ) external returns (uint256[] memory amountsOut)

Performs multiple tokens` withdrawal operation from specified portfolio, using permit instead of additional approval transaction.

Parameters

Name

Type

Description

tokens

address[]

Addresses of tokens to withdraw

LPTamounts

uint256[]

Amount of LP tokens to spend on withdrawal of each token

minAmountsOut

uint256[]

Minimal amount of tokens to receive during withdrawal. If less tokens are received the transaction is reverted

to

address

Address of tokens` receiver

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

permitStruct

struct

PS.PermitStruct

Permit struct with signature to be verified by LPT minter and transfer tokens without approval

Return values

Name

Type

Description

amountsOut

uint256[]

Amounts of tokens received after withdrawal

removeLiquidityWithPermitFromPortfolio (last liquidity)

function removeLiquidityWithPermitFromPortfolio(
        uint256 liquidity,
        address to,
        uint256 deadline,
        address portfolio,
        PS.PermitStruct calldata permitStruct
    ) external returns (uint256[] memory amountsOut)

Withdraws last liquidity from portfolio in all the portfolio tokens left if liquidity is the all remaining supply of LP tokens, using permit instead of additional approval transaction.

Parameters

Name

Type

Description

liquidity

uint256

Amount of LP tokens to spend on withdrawal

to

address

Address of tokens` receive

deadline

uint256

Timestamp indicates when the withdrawal becomes irrelevant

portfolio

address

Address of the portfolio to withdraw tokens from

permitStruct

struct

PS.PermitStruct

Permit struct with signature to be verified by LPT minter and transfer tokens without approval

Return values

Name

Type

Description

amountsOut

uint256[]

Amounts of tokens received after withdrawal

Last updated