IOracle

Functions

Functions

portfolio

function portfolio() external view returns (address portfolioAddress)

Returns oracle`s portfolio address.

curPrice

function curPrice(address reserveAddress) external view returns (uint256)

Returns price in base currency (multiplied by 1e18) of token that is stored in reserve with reserveAddress address (1e18 for portfolio`s base token).

calculatePRTSwap

function calculatePRTSwap(uint256 inputAmount, bool baseTokenIn)
        external
        view
        returns (
            uint256 outputAmount,
            uint256 newPRTPrice,
            uint256 newCoefficient
        )

Calculates PRT output amount, new price and base token price coefficient (for other tokens` prices calculations), used in deposit and withdrawal calculations (see whitepaper).

Parameters

Name

Type

Description

inputAmount

uint256

Amount of portfolio`s base token that takes part in swap

baseTokenIn

bool

Indicates whether portfolio`s base token is input or output token of swap

Return values

Name

Type

Description

outputAmount

uint256

Calculated amount of PRT (input or output)

newPRTPrice

uint256

New price of PRT after swap

newCoefficient

uint256

New portfolio`s base token price coefficient

PRTPrice

function PRTPrice() external view returns (uint256)

Returns price of PRT (see whitepaper), multiplied by 1e18.

baseTokenPriceCoefficient

function baseTokenPriceCoefficient() external view returns (uint256)

Returns portfolio`s base token price coefficient that is used for other portfolio`s tokens` prices calculations.

curAmount

function curAmount(address reserveAddress) external view returns (uint256)

Returns current amount (in wei) of token stored in reserve with reserveAddress address.

reservesTotalSupplyBase

function reservesTotalSupplyBase() external view returns (uint256)

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

reserveCount

function reserveCount() external view returns (uint256)

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

protocolFeeReceiver

function protocolFeeReceiver() external view returns (address)

Returns address of protocol fee receiver.

accumulatedProtocolFee

function accumulatedProtocolFee() external view returns (uint256)

Returns accumulated protocol fee in LP tokens.

fee

function fee() external view returns (uint16 _feeNumerator, uint16 _feeDenominator)

Returns portfolio`s fee as fraction`s numerator and denominator.

curPriceForOperations

function curPriceForOperations(address reserveAddress, bool isDeposit) external view returns (uint256 price)

Returns token`s price for deposit/withdrawal operation. For deposit it is the minimum of the current and average price. For withdrawal it is the maximum of the current and average price.

Parameters

Name

Type

Description

reserveAddress

address

Address of reserve that token is stored in

isDeposit

bool

Indicates whether price for deposit or withdrawal operation is needed

Return values

Name

Type

Description

price

uint256

Token`s price for deposit/withdrawal operation

getAveragePrice

function getAveragePrice(address reserveAddress) external view returns (uint256 averagePrice)

Returns average price in base currency (multiplied by 1e18) of token that is stored in reserve with reserveAddress address (1e18 for portfolio`s base token).

getPortfolioValue

function getPortfolioValue() external view returns (uint256 portfolioValue)

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

getAccumulatedProtocolFee

function getAccumulatedProtocolFee() external view returns (uint256 _accumulatedProtocolFee)

Returns accumulated protocol fee in LP tokens.

getAmountIn

function getAmountIn(
        address reserveAddress1,
        address reserveAddress2,
        uint256 amountOut
    ) external view returns (uint256 amountIn)

Returns amount in for constant product swap with given amount out.

Parameters

Name

Type

Description

reserveAddress1

address

Address of reserve that stores swap`s input token

reserveAddress2

address

Address of reserve that stores swap`s output token

amountOut

uint256

Amount of swap`s output token

Return values

Name

Type

Description

amountIn

uint256

Amount of swap`s intput token

getAmountOut

function getAmountOut(
        address reserveAddress1,
        address reserveAddress2,
        uint256 amountIn
    ) external view returns (uint256 amountOut)

Returns amount out for constant product swap with given amount in.

Parameters

Name

Type

Description

reserveAddress1

address

Address of reserve that stores swap`s input token

reserveAddress2

address

Address of reserve that stores swap`s output token

amountIn

uint256

Amount of swap`s intput token

Return values

Name

Type

Description

amountOut

uint256

Amount of swap`s output token

getExchangeAmount

function getExchangeAmount(
        address reserveAddress1,
        uint256 exactAmount,
        address reserveAddress2,
        uint256 price1,
        uint256 price2,
        bool isArbitrageSwap,
        bool isGetAmountOut
    )
        external
        view
        returns (
            uint16 portfolioFee,
            uint256 amount1,
            uint256 amount2,
            uint256 newPrice1,
            uint256 newPrice2
        )

Calculates constant product exchange amount (amount in/ amount out), portfolio fee and swap`s tokens` new prices.

Parameters

Name

Type

Description

reserveAddress1

address

Address of reserve that stores swap`s input token

exactAmount

uint256

Exact amount in/out for swap

reserveAddress2

address

Address of reserve that stores swap`s output token

price1

uint256

Swap`s input token`s price that is used for calculations (if price1 == 0 current token`s price is used)

price2

uint256

Swap`s output token`s price that is used for calculations (if price2 == 0 current token`s price is used)

isArbitrageSwap

bool

Indicates whether calculations are made for arbitrage or ordinary swap

isGetAmountOut

bool

Indicates whether swap`s amount in or out is provided

Return values

Name

Type

Description

portfolioFee

uint16

Portfolio`s fee (0.3% by default, 0% for arbitrage swaps)

amount1

uint256

Amount of swap`s input token

amount2

uint256

Amount of swap`s output token

newPrice1

uint256

New price of swap`s input token

newPrice2

uint256

New price of swap`s output token

getVirtualReserves

function getVirtualReserves(
        address reserveAddress1,
        address reserveAddress2,
        bool isArbitrageSwap
    ) external view returns (uint256 reserve1, uint256 reserve2)

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

Parameters

Name

Type

Description

reserveAddress1

address

Address of reserve that stores swap`s input token

reserveAddress2

address

Address of reserve that stores swap`s output token

isArbitrageSwap

bool

Indicates whether calculations are made for arbitrage or ordinary swap

Return values

Name

Type

Description

reserve1

uint256

Virtual reserve for swap`s input token

reserve2

uint256

Virtual reserve for swap`s output token

getReserveBaseAmount

function getReserveBaseAmount(address reserveAddress) external view returns (uint256 baseAmount)

Returns current amount (in wei) of token stored in reserve with reserveAddress address in portfolio`s base currency (portfolio`s base token).

Last updated