Blueshift Docs
  • Introduction
    • What is Blueshift?
    • Blueshift token (BLUES)
    • Blueshiftโ€™s audit
    • Fees
  • Getting started
    • How do I connect wallet?
      • Configuring MetaMask
    • How to transfer ADA from Cardano to Milkomeda network?
    • How to transfer Cardano Native Tokens (CNTs) to Milkomeda network?
    • How to transfer ALGO from Algorand to Milkomeda A1 network?
    • How do I trade on Blueshift?
      • ๐ŸŽ“ Swap tutorial
    • How do I provide liquidity (get LP tokens)?
      • ๐ŸŽ“ Add liquidity tutorial
    • How do I withdraw liquidity?
      • ๐ŸŽ“ Withdraw tutorial
    • How do I use farms ?
  • Product concept
    • ๐Ÿ”ฅ Swap Cross-Chain/Local
    • Portfolios
      • Single token invest
    • Farming
    • Yield pools
      • Auto HODL BLUES Pool
    • Smart minting system
    • Referral program ๐Ÿ”ฅ
    • Cardano Wrapped Smart Contracts
  • TECHNICAL REFERENCE
    • Smart contracts overview
    • Blueshift contracts addresses
    • Interface specifications
      • IBlueshiftRouter
      • IBlueshiftArbitrageRouter
      • IOracle
      • IPortfolio
      • IMinterV3
      • IEarningV2
      • IStakingV2
      • IAutoStakingV3
  • Community
    • Telegram (Off. group)
    • Telegram (Chat)
    • Twitter
Powered by GitBook
On this page
  • Events
  • Deposit
  • Withdraw
  • Swap
  • Parameter Structs
  • Signature
  • ExternalOraclePrice
  • Functions
  • oracle
  • LPTminter
  • governanceRouter
  • reserveFactory
  • reserveCount
  • getLPTPrice
  • getPortfolioValue
  • deposit
  • withdraw
  • withdrawLast
  • getVirtualReserves
  • swap
  • arbitrageSwap
  • collectProtocolFee
  • findReserve
  • getReserve

Was this helpful?

  1. TECHNICAL REFERENCE
  2. Interface specifications

IPortfolio

Events

Deposit

Withdraw

Swap

Parameter Structs

Signature

ExternalOraclePrice

Functions

oracle

LPTminter

governanceRouter

reserveFactory

reserveCount

getLPTPrice

getPortfolioValue

deposit

withdraw

withdrawLast

getVirtualReserves

swap

arbitrageSwap

collectProtocolFee

findReserve

getReserve

Events

Deposit

event Deposit(address token, uint256 amount, uint256 liquidityOut, address to, uint256 portfolioValue)

Emits after deposit (for each token deposited).

Event parameters

Name

Type

Description

token

address

Address of deposited token

amount

uint256

Deposited amount of token

liquidityOut

uint256

Amount of LP tokens minted for depositing token

to

address

LPT`s receiver`s address

portfolioValue

uint256

Portfolio total value after depositing token (in base currency)

Withdraw

event Withdraw(address token, uint256 amount, uint256 liquidityIn, address to, uint256 portfolioValue)

Emits after withdrawal (for each token withdrawn).

Event parameters

Name

Type

Description

token

address

Address of withdrawn token

amount

uint256

Withdrawn amount of token

liquidityIn

uint256

Amount of LP tokens burned after withdrawing token

to

address

token`s receiver address

portfolioValue

uint256

Portfolio total value after withdrawing token (in base currency)

Swap

event Swap(address tokenIn, uint256 amountIn, address tokenOut, uint256 amountOut, address to, uint16 fee, uint256 portfolioValue)

Emits after swap (for each swap in chain swaps).

Event parameters

Name

Type

Description

tokenIn

address

Address of swap`s input token

amountIn

uint256

Amount of tokenIn

tokenOut

address

Address of swap`s output token

amountOut

uint256

Amount of tokenOut

to

address

tokenOut`s receiver

fee

uint16

Portfolio fee withheld from swap (in tokenIn currency)

portfolioValue

uint256

Portfolio total value after swap (in base currency)

Parameter Structs

Signature

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

Standard ECDSA signature structure.

ExternalOraclePrice

struct ExternalOraclePrice {
        address baseToken;
        uint256[] prices;
        address[] tokens;
        uint256 timestamp;
        Signature signature;
    }

Structure that holds lists of tokens and their prices got from Blueshift`s verified external price source.

Fields description

Name

Type

Description

baseToken

address

Base token of the portfolio that holds tokens

prices

uint256[]

Prices of portfolio`s tokens in a portfolio`s base currency

tokens

address[]

Tokens from one portfolio, not essentially all the tokens of the portfolio, could be a subset of all portfolio`s tokens (up to only one token)

timestamp

uint256

Indicates when the tokens` prices were signed by the external source

signature

struct

EOP.Signature

Standard ECDSA signature. Verified external source signs all other structure`s fields together and then adds a signature field

Functions

oracle

function oracle() external view returns (IOracle)

Returns portfolio`s oracle.

LPTminter

function LPTminter() external view returns (ILPTMinter)

Returns portfolio`s LPT minter (LPT minter`s address equals to LP token`s address).

governanceRouter

function governanceRouter() external view returns (IGovernanceRouter)

Returns portfolio`s governance router (equal for all the portfolios as the protocol has only one governance router).

reserveFactory

function reserveFactory() external view returns (IReserveFactory)

Returns portfolio`s reserve factory.

reserveCount

function reserveCount() external view returns (uint256)

Returns portfolio`s reserves count (count of portfolio`s tokens).

getLPTPrice

function getLPTPrice() external view returns (uint256 lpTokenPrice)

Returns portfolio`s LP token price in base currency.

getPortfolioValue

function getPortfolioValue() external view returns (uint256 portfolioValue)

Returns all the portfolio`s tokens summarized amounts converted to base currency (portfolio`s base token).

deposit

function deposit(
        address[] calldata tokens,
        address LPreceiver,
        uint256 minAmountOut
    ) external returns (uint256[] memory exactAmountsIn, uint256 liquidityOut)

Performs tokens` deposit to portfolio.

Parameters

Name

Type

Description

tokens

address

Addresses of tokens to deposit

LPreceiver

address

LP token`s receiver address

minAmountOut

uint256

Minimal amount of LP token to receive. If less is minted the transaction is reverted

Return values

Name

Type

Description

exactAmountsIn

uint256[]

Amounts of tokens deposited (to support fee-on-transfer tokens).

exactAmountsIn.length == tokens.length

liquidityOut

uint256

Amount of LP tokens minted after deposit

withdraw

function withdraw(
        address[] calldata tokens,
        uint256[] calldata LPTamounts,
        address to,
        address WETH,
        uint256[] calldata minAmountOut
    ) external returns (uint256[] memory amounts, uint256 WETHamount)

Performs tokens` withdrawal from portfolio.

Parameters

Name

Type

Description

tokens

address[]

Addresses of tokens to withdraw

LPTamounts

uint256[]

Amounts of LP tokens to spend for each token withdrawal.

LPTamounts.length == tokens.length

to

address

Tokens` receiver address

WETH

address

Address of current network`s wrapped native token

minAmountOut

uint256[]

Minimal amounts of tokens to be withdrawn. If less tokens are withdrawn the transaction reverts.

minAmountsOut.length == tokens.length

Return values

Name

Type

Description

amounts

uint256[]

Amounts of tokens withdrawn.

amounts.length == tokens.length

WETHamount

uint256

Amount of current network`s wrapped native token withdrawn

withdrawLast

function withdrawLast(
        uint256 liquidity,
        address to,
        address WETH
    ) external returns (uint256[] memory amounts, uint256 WETHamount)

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

LP token amount to be burnt during withdrawal

to

address

Withdrawn tokens` receiver address

WETH

address

Address of current network`s wrapped native token

Return values

Name

Type

Description

amounts

uint256[]

Amounts of tokens withdrawn

WETHamount

uint256

Amount of current network`s wrapped native token withdrawn

getVirtualReserves

function getVirtualReserves(address from, address to) external view returns (uint256 reserveFrom, uint256 reserveTo)

Parameters

Name

Type

Description

from

address

Address of swap`s input token

to

address

Address of swap`s output token

Return values

Name

Type

Description

reserveFrom

uint256

Virtual reserve for swap of swap`s input token

reserveTo

uint256

Virtual reserve for swap of swap`s output token

swap

function swap(
        address tokenIn,
        address tokenOut,
        address to
    ) external returns (uint256 exactAmountIn, uint256 amountOut)

Performs tokens` swap.

Parameters

Name

Type

Description

tokenIn

address

Address of swap`s input token

tokenOut

address

Address of swap`s output token

to

address

Swap`s output token`s receiver

Return values

Name

Type

Description

exactAmountIn

uint256

Amount of swap`s input token swapped (to support fee-on-transfer tokens)

amountOut

uint256

Amount of swap`s output token got after swap

arbitrageSwap

function arbitrageSwap(
        address tokenIn,
        address tokenOut,
        address to,
        EOP.ExternalOraclePrice calldata externalOraclePrice
    ) external returns (uint256 exactAmountIn, uint256 amountOut)

Performs tokens` arbitrage swap (fee isn`t withheld from arbitrage swaps).

Parameters

Name

Type

Description

tokenIn

address

Address of swap`s input token

tokenOut

address

Address of swap`s output token

to

address

Swap`s output token`s receiver

externalOraclePrice

struct

EOP.

External

OraclePrice

Struct with signature to be verified by portfolio to use data in order to check if arbitrage swap condition is met

Return values

Name

Type

Description

exactAmountIn

uint256

Amount of swap`s input token swapped (to support fee-on-transfer tokens)

amountOut

uint256

Amount of swap`s output token got after swap

collectProtocolFee

function collectProtocolFee() external returns (uint256 liquidity)

Mints protocol fee in LP tokens to a specified protocolFeeReceiver address. Returns the amount of LP tokens minted.

findReserve

function findReserve(address token) external view returns (bool isMainReserve, address reserveAddress)

Returns the address of reserve that holds specified token.

Parameters

Name

Type

Description

address

token

Token to find reserve address for

Return values

Name

Type

Description

isMainReserve

bool

Indicates whether token is the portfolio`s base token

reserveAddress

address

Address of the reserve that holds token. If there is no specified token in portfolio zero address (0x000โ€ฆ) is returned

getReserve

function getReserve(uint256 index) external view returns (bool isMainReserve, address reserveAddress)

Returns portfolio`s reserve address with specified index (from 0 to portfolio.reserveCount() - 1). If index is greater or equal to portfolio.reserveCount() then the transaction is reverted.

Parameters

Name

Type

Description

index

uint256

Number of reserve (from 0 to portfolio.reserveCount() - 1)

Return values

Name

Type

Description

isMainReserve

bool

Indicates whether token is the portfolio`s base token

reserveAddress

address

Address of the reserve with number index.

PreviousIOracleNextIMinterV3

Last updated 2 years ago

Was this helpful?

Returns virtual reserves (virtual tokens` amounts) for swap (see ).

whitepaper