Elastic Peripheral Library Contracts
AntiSnipingAttack
The motivation and explanation of the mechanism can be found here. The function containing the bulk of the logic is update()
.
Struct: Data
Field | Type | Formula Variable | Explanation |
---|---|---|---|
|
| timestamp of last action performed | |
|
| average start time of lock schedule | |
|
| average unlock time of locked fees | |
|
| locked rToken qty since last update |
initialize()
initialize()
Initializes Data values for a new position. The time variables are set to the current timestamp, while feesLocked
is set to zero.
update()
update()
Updates Data values for an existing position. Calculates the amount of claimable reinvestment tokens to be sent to the user and, in the case of liquidity removal, the amount of burnable reinvestment tokens as well.
Formula
if , otherwise and updated through calcFeeProportions()
If adding liquidity, update
If removing liquidity,
-=
Input
Field | Type | Formula Variable | Explanation |
---|---|---|---|
| N.A. | stored data values for an existing position | |
|
| current position liquidity | |
|
| quantity change to be applied | |
|
| current block timestamp | |
|
| N.A. | true = add liquidity, false = remove liquidity |
|
| fees accrued since last action | |
|
| maximum time duration for which LP fees are proportionally burnt upon LP removals |
Output
Field | Type | Formula Variable | Explanation |
---|---|---|---|
|
| claimable reinvestment token amount | |
|
| reinvestment token amount to burn |
calcFeeProportions()
calcFeeProportions()
Calculates the proportion of locked fees and claimable fees given the fee amounts and claimable fee basis points.
Formula
Input
Field | Type | Formula Variable | Explanation |
---|---|---|---|
|
| currently locked fees | |
|
| fees since last action | |
|
| proportion of claimable / unlocked | |
|
| proportion of claimable |
Output
Field | Type | Formula Variable | Explanation |
---|---|---|---|
|
| new fee amount to be locked | |
|
| claimable fees to be sent to user |
BytesLib
Solidity Bytes Arrays Utils @author Gonçalo Sá goncalo.sa@consensys.net
Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. The library lets you slice and type cast bytes arrays both in memory and storage.
LiquidityMath
Contract to calculate the expected amount of liquidity given the amounts of tokens.
getLiquidityFromQty0()
getLiquidityFromQty0()
Get liquidity from qty0 of the first token given the price range.
getLiquidityFromQty1()
getLiquidityFromQty1()
Get liquidity from qty1 of the second token given the price range.
getLiquidityFromQties()
getLiquidityFromQties()
Get liquidity given the price range and amounts of 2 tokens
PathHelper
Functions for manipulating path data for multihop swaps
Variables
hasMultiplePools()
hasMultiplePools()
Return true if the path contains 2 or more pools, false otherwise
numPools()
numPools()
Returns the number of pools in the path.
decodeFirstPool()
decodeFirstPool()
Return the first pool's data from the path, including tokenA, tokenB and fee.
getFirstPool()
getFirstPool()
Return the segment corresponding to the first pool in the path.
skipToken()
skipToken()
Skip a token + fee from the buffer and returns the remainder.
PoolAddress
Provides a function for deriving a pool address from the factory, tokens, and swap fee
computeAddress()
computeAddress()
Deterministically computes the pool address from the given data.
PoolTicksCounter
countInitializedTicksCrossed()
countInitializedTicksCrossed()
Count the number of initialized ticks have been crossed given the previous/current nearest initialized ticks to the current tick.
TokenHelper
A helper contract to transfer token/ETH.
transferToken()
transferToken()
Transfer an amount of ERC20 token from the sender to the receiver.
transferEth()
transferEth()
Transfer an amount of ETH to the receiver.
Last updated