IOracle
Functions
portfolio
Returns oracle`s portfolio address.
curPrice
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
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
Returns price of PRT (see whitepaper), multiplied by 1e18.
baseTokenPriceCoefficient
Returns portfolio`s base token price coefficient that is used for other portfolio`s tokens` prices calculations.
curAmount
Returns current amount (in wei) of token stored in reserve with reserveAddress address.
reservesTotalSupplyBase
Returns all the portfolio`s tokens summarized amounts converted to base currency (portfolio`s base token).
reserveCount
Returns count of portfolio`s reserves (count of tokens in portfolio).
protocolFeeReceiver
Returns address of protocol fee receiver.
accumulatedProtocolFee
Returns accumulated protocol fee in LP tokens.
fee
Returns portfolio`s fee as fraction`s numerator and denominator.
curPriceForOperations
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
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
Returns all the portfolio`s tokens summarized amounts converted to base currency (portfolio`s base token).
getAccumulatedProtocolFee
Returns accumulated protocol fee in LP tokens.
getAmountIn
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
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
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
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
Returns current amount (in wei) of token stored in reserve with reserveAddress address in portfolio`s base currency (portfolio`s base token).
Last updated