Inherits: Ownable
Author: Anton Davydov
Pool that is being calibrated
IPair public pair;
Token which pool reserve remains invariant
IERC20 public tokenBase;
Token which pool reserve changes
IERC20 public tokenQuote;
Version of the contract, bumped on each deployment
string public constant VERSION = "0.0.2";
The top of a fraction that represents swap size minus fees
uint256 public feeNumerator = 997;
The bottom of a fraction that represents swap size minus fees
uint256 public feeDenominator = 1000;
The top of a fraction that represents the acceptable margin of error in a calibration
when the error margin fraction is large, less swaps are performed, and precision is lower
uint256 public precisionNumerator = 1;
The bottom of a fraction that represents the acceptable margin of error in a calibration
uint256 public precisionDenominator = 1000;
The size of the base reserve after liquidity removal and before swaps
When minimum base reserve is large, swaps are more precise and more expensive
uint256 public minimumBase = 10000000;
The address of the vault that holds pair and ERC20 tokens
When vault is 0, msg.sender is considered the vault
Vault is expected to approve a large allowance to this contract
address public vault = address(0);
constructor(address _pair, address _tokenBase, address _tokenQuote);
Update the fraction that represents a net swap size
function setFee(uint256 _feeNumerator, uint256 _feeDenominator) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_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 |
Update the fraction that represents the acceptable margin of error in a calibration
function setPrecision(uint256 _precisionNumerator, uint256 _precisionDenominator) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_precisionNumerator |
uint256 |
The top of a fraction that represents the acceptable margin of error in a calibration |
_precisionDenominator |
uint256 |
The bottom of a fraction that represents the acceptable margin of error in a calibration |
Update the size of the base reserve after liquidity removal
function setMinimumBase(uint256 _minimumBase) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_minimumBase |
uint256 |
The size of the base reserve after liquidity removal |
Update the address of the vault that holds pair and ERC20 tokens
function setVault(address _vault) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_vault |
address |
The address of the vault that holds pair and ERC20 tokens |
Get the address of the vault that holds pair and ERC20 tokens
When vault is 0, msg.sender is considered the vault
function getVault() internal view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> |
address |
vault The address of the vault that holds pair and ERC20 tokens |
Retrieve pool reserves sorted such that base if first and quote is second
function getReserves() public view returns (uint256 reserveBase, uint256 reserveQuote);
Returns
Name | Type | Description |
---|---|---|
reserveBase |
uint256 |
The size of base token reserve in the pool |
reserveQuote |
uint256 |
The size of quote token reserve in the pool |
Sort token addresses
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1);
Parameters
Name | Type | Description |
---|---|---|
tokenA |
address |
The address of token A |
tokenB |
address |
The address of token B |
Returns
Name | Type | Description |
---|---|---|
token0 |
address |
The address of the first token in order |
token1 |
address |
The address of the last token in order |
Emits when the net swap fraction is updated
Call this to setup a fork with alternative fees
event SetFee(uint256 indexed feeNumerator, uint256 indexed feeDenominator);
Emits when acceptable margin of calibration error is updated
event SetPrecision(uint256 indexed precisionNumerator, uint256 indexed precisionDenominator);
Emits when the minimum size of the base reserve is updated
event SetMinimumBase(uint256 indexed minimumBase);
Emits when new vault is set
event SetVault(address indexed vault);