Skip to main content

UniswapPCVDeposit

Functions

constructor

function constructor(
address _core,
address _pair,
address _router,
address _oracle,
address _backupOracle,
uint256 _maxBasisPointsFromPegLP
) public

Uniswap PCV Deposit constructor

Parameters

NameTypeDescription
_coreaddressFei Core for reference
_pairaddressUniswap Pair to deposit to
_routeraddressUniswap Router
_oracleaddressoracle for reference
_backupOracleaddressthe backup oracle to reference
_maxBasisPointsFromPegLPuint256the max basis points of slippage from peg allowed on LP deposit

receive

function receive() external

deposit

function deposit() external

deposit tokens into the PCV allocation

withdraw

function withdraw(
address to,
uint256 amountUnderlying
) external

withdraw tokens from the PCV allocation

has rounding errors on amount to withdraw, can differ from the input "amountUnderlying"

Parameters

NameTypeDescription
toaddressthe address to send PCV to
amountUnderlyinguint256of tokens withdrawn

setMaxBasisPointsFromPegLP

function setMaxBasisPointsFromPegLP(
uint256 _maxBasisPointsFromPegLP
) public

sets the new slippage parameter for depositing liquidity

Parameters

NameTypeDescription
_maxBasisPointsFromPegLPuint256the new distance in basis points (1/10000) from peg beyond which a liquidity provision will fail

setPair

function setPair(
address _pair
) public

set the new pair contract

also approves the router for the new pair token and underlying token

Parameters

NameTypeDescription
_pairaddressthe new pair

balance

function balance() public returns (uint256)

returns total balance of PCV in the Deposit excluding the FEI

balanceReportedIn

function balanceReportedIn() public returns (address)

display the related token of the balance reported

resistantBalanceAndFei

function resistantBalanceAndFei() public returns (uint256, uint256)

get the manipulation resistant Other(example ETH) and FEI in the Uniswap pool @return number of other token in pool @return number of FEI in pool

    Derivation rETH, rFEI = resistant (ideal) ETH and FEI reserves, P = price of ETH in FEI:
1. rETH * rFEI = k
2. rETH = k / rFEI
3. rETH = (k * rETH) / (rFEI * rETH)
4. rETH ^ 2 = k / P
5. rETH = sqrt(k / P)

and rFEI = k / rETH by 1.

Finally scale the resistant reserves by the ratio owned by the contract

liquidityOwned

function liquidityOwned() public returns (uint256)

amount of pair liquidity owned by this contract

Return Values

NameTypeDescription
[0]uint256amount of LP tokens

_removeLiquidity

function _removeLiquidity(
uint256 liquidity
) internal returns (uint256)

Parameters

NameTypeDescription
liquidityuint256

_addLiquidity

function _addLiquidity(
uint256 tokenAmount,
uint256 feiAmount
) internal

Parameters

NameTypeDescription
tokenAmountuint256
feiAmountuint256

_getMinLiquidity

function _getMinLiquidity(
uint256 amount
) internal returns (uint256)

used as slippage protection when adding liquidity to the pool

Parameters

NameTypeDescription
amountuint256

_ratioOwned

function _ratioOwned() internal returns (struct Decimal.D256)

ratio of all pair liquidity owned by this contract

_approveToken

function _approveToken(
address _token
) internal

approves a token for the router

Parameters

NameTypeDescription
_tokenaddress

_wrap

function _wrap() internal