CalculatorBase
Git Source Author: @oscarsernarosero @mpetersoCode55 @cirsteve This contract serves as the base for all the calculators.Functions
_spotPrice
This is the function to retrieve the current spot price of the x token.| Name | Type | Description |
|---|---|---|
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
| Name | Type | Description |
|---|---|---|
sPrice | uint256 | the price in YToken Decimals |
_updateParameters
This function updates the state of the math values of the pool.| Name | Type | Description |
|---|---|---|
x_old | uint256 | the previous tracker for x |
x_current | uint256 | the current tracker for x value |
_calculateAmountOfXRequiredBuyingY
This function calculates the amount of token X required for the user to purchase a specific amount of Token Y (buy y with x : out perspective).| Name | Type | Description |
|---|---|---|
_amountOfY | uint256 | desired amount of token Y |
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
| Name | Type | Description |
|---|---|---|
amountOfX | uint256 | required amount of token X |
_calculateAmountOfYRequiredBuyingX
This function calculates the amount of token Y required for the user to purchase a specific amount of Token X (buy x with y : out perspective).| Name | Type | Description |
|---|---|---|
_amountOfX | uint256 | desired amount of token X |
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
| Name | Type | Description |
|---|---|---|
amountOfY | uint256 | required amount of token Y |
_calculateAmountOfYReceivedSellingX
This function calculates the amount of token Y the user will receive when selling token X (sell x for y : in perspective).| Name | Type | Description |
|---|---|---|
_amountOfX | uint256 | amount of token X to be sold |
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
| Name | Type | Description |
|---|---|---|
amountOfY | uint256 | amount of token Y to be received |
_calculateAmountOfXReceivedSellingY
This function calculates the amount of token X the user will receive when selling token Y (sell y for x : in perspective).| Name | Type | Description |
|---|---|---|
_amountOfY | uint256 | amount of token Y to be sold |
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
| Name | Type | Description |
|---|---|---|
amountOfX | uint256 | amount of token X to be received |
_clearState
This function cleans the state of the calculator in the case of the pool closing._calculateRMax
This function returns the amount of maximum revenue available to be withdrawn by the owner.| Name | Type | Description |
|---|---|---|
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
R | uint256 | current lifitime revenue claimed |
| Name | Type | Description |
|---|---|---|
<none> | uint256 | the maximum revenue available to be withdrawn by the owner |
_validateLiquidityAdd
This function validates the liquidity addition to ensure it does not exceed the max supply of xToken.| Name | Type | Description |
|---|---|---|
x | uint256 | tracker value for the net amount of xTokens sold to the public. Bare in mind that this value is offset by initial synthetic trade |
afterBalance | uint256 | the balance of xToken after the addition |