Inherits: Settings
Author: Anton Davydov
Simulate a reserve ratio calibration
function estimate(uint256 targetBase, uint256 targetQuote) external view returns (Estimation memory estimation);
Parameters
Name | Type | Description |
---|---|---|
targetBase |
uint256 |
The number of base parts in target ratio |
targetQuote |
uint256 |
The number of quote parts in target ratio |
Returns
Name | Type | Description |
---|---|---|
estimation |
Estimation |
Information about the simulated calibration |
Simulate a removal of liquidity from the pool
function removeLiquidityDryrun(Estimation memory estimation, EstimationContext memory context, uint256 minimumBase)
internal
pure
returns (Estimation memory, EstimationContext memory);
Parameters
Name | Type | Description |
---|---|---|
estimation |
Estimation |
Information about the simulated calibration |
context |
EstimationContext |
Intermediary state of the calibration |
minimumBase |
uint256 |
The size of base reserve after removal |
Returns
Name | Type | Description |
---|---|---|
<none> |
Estimation |
estimationNew Information about the simulated calibration |
<none> |
EstimationContext |
contextNew Intermediary state of the calibration |
Simulate a swap that changes pool ratio
function swapToRatioDryrun(
Estimation memory estimation,
EstimationContext memory context,
uint256 targetBase,
uint256 targetQuote,
uint256 feeNumerator,
uint256 feeDenominator
) internal pure returns (Estimation memory, EstimationContext memory, bool);
Parameters
Name | Type | Description |
---|---|---|
estimation |
Estimation |
Information about the simulated calibration |
context |
EstimationContext |
Intermediary state of the calibration |
targetBase |
uint256 |
The number of base parts in target ratio |
targetQuote |
uint256 |
The number of quote parts in target ratio |
feeNumerator |
uint256 |
The top of a fraction that represents swap size minus fees |
feeDenominator |
uint256 |
The bottom of a fraction that represents swap size minus fees |
Returns
Name | Type | Description |
---|---|---|
<none> |
Estimation |
estimationNew Information about the simulated calibration |
<none> |
EstimationContext |
contextNew Intermediary state of the calibration |
<none> |
bool |
Simulate provision of liquidity that reaches invariant size of base reserve
function addLiquidityDryrun(
Estimation memory estimation,
EstimationContext memory context,
uint256 reserveBaseInvariant
) internal pure returns (Estimation memory);
Parameters
Name | Type | Description |
---|---|---|
estimation |
Estimation |
Information about the simulated calibration |
context |
EstimationContext |
Intermediary state of the calibration |
reserveBaseInvariant |
uint256 |
The target size of base reserve |
Returns
Name | Type | Description |
---|---|---|
<none> |
Estimation |
estimationNew Information about the simulated calibration |
Information about the simulated calibration
struct Estimation {
bool baseToQuote;
uint256 requiredQuote;
uint256 leftoverQuote;
uint256 leftoverLiquidity;
uint256 reserveBase;
uint256 reserveQuote;
}
Intermediary state of the calibration
struct EstimationContext {
uint256 availableQuote;
uint256 availableBase;
uint256 minimumLiquidity;
uint256 totalSupply;
uint256 vaultLiquidity;
}