Skip to main content

DepletedAssetUtils

Git Source

State Variables

BUFFER

uint256 public constant BUFFER = 95;

FEE

uint256 public constant FEE = 3;

Functions

computeExpectedSwapInAmount

function computeExpectedSwapInAmount(
uint256 swapAmountOut,
uint256 reserveIn,
uint256 reserveOut,
uint256 missingIn,
uint256 missingOut
) public pure returns (uint256 swapAmountIn);

computeExpectedSwapOutAmount

function computeExpectedSwapOutAmount(
uint256 swapAmountIn,
uint256 reserveIn,
uint256 reserveOut,
uint256 missingIn,
uint256 missingOut
) public pure returns (uint256 expectedSwapOut);

computeCurve

See Desmos chart functions C_X and C_y for https://www.Desmos.com/calculator/22bdlqiazt

function computeCurve(
uint256 a,
uint256 reserveA,
uint256 reserveB,
uint256 missingA,
uint256 missingB,
uint256 decimals
) public pure returns (uint256 b);

Parameters

NameTypeDescription
auint256starting value x or y
reserveAuint256reserve for start asset
reserveBuint256reserve for end asset
missingAuint256missing for start asset
missingBuint256missing for end asset
decimalsuint256decimals when a is passed in with additional precision due to fees

Returns

NameTypeDescription
buint256ending value y or x

computeAmountsForRepayLiquidity

function computeAmountsForRepayLiquidity(
uint256 liquidity,
uint256 missingX,
uint256 missingY,
uint256 reserveX,
uint256 reserveY,
uint256 activeLiquidity_
) public pure returns (uint256 amountX, uint256 amountY);

computeAmountForRepayLiquidity

function computeAmountForRepayLiquidity(
uint256 liquidity,
uint256 missing_,
uint256 reserve_,
uint256 activeLiquidity_
) private pure returns (uint256 amount_);

actualToAdjusted

See Desmos chart functions X_A or Y_A for https://www.Desmos.com/calculator/22bdlqiazt private due to modifications of equations for preserving precision.

function actualToAdjusted(uint256 actual, uint256 missing) private pure returns (uint256 adjusted);

Parameters

NameTypeDescription
actualuint256actual x or y
missinguint256missing assets associated with actual

adjustedToActual

See Desmos chart functions X_I or Y_I for https://www.Desmos.com/calculator/22bdlqiazt inverse of actualToAdjusted private due to modifications of equations for preserving precision.

function adjustedToActual(uint256 adjusted, uint256 missing) private pure returns (uint256 actual);

Parameters

NameTypeDescription
adjusteduint256adjusted value of X
missinguint256missing assets associated with adjusted

Errors

MissingOutGteReserveOut

error MissingOutGteReserveOut();

MissingGteActual

error MissingGteActual();