What we need here:
Expressed in DAI
Price can be obtained with the following formula:
ppm * balanceOf(pool, collateral) / (computedSupply * reserveRatio)
ppm
: inmarketMaker
contractbalanceOf(poolAdress, collateralAddress)
: adresses available from the background script, call available on thecontroller
contract- price can be exprimed with any collateral, just use the
collateral
address you need computedSupply
: for each collateral, you need to calculate a supply responding to the following formula:
computedSupply = bondedToken.totalSupply + bondedToken.tokensToBeMinted + virtualSupply (of current collateral)
reserveRatio
: on the collateral token you want to express the price
It can also be obtained with the following call on the marketMaker
contract: getStaticPrice
.
Expressed in DAI
Market cap can be obtained with the following formula:
marketCap = price * (totalSupply + tokensToBeMinted)
totalSupply
andtokensToBeMinted
are related to thebondedToken
Expressed in DAI
Sum of the DAI buy and sell orders amounts.
totalSupply
of the bonded token, minus the tokenToBeMinted
totalSupply
andtokensToBeMinted
are related to thebondedToken
Expressed in DAI
balanceOf(pool, dai)
of the collateral token, minus thetokensToBeClaimed
, call available on thecontroller
contract
Expressed in DAI/month
Can be found on the tap
object, and converted in DAI/month
Orders get their prices and informations about the collateral from the background script. By default, an order is considered as 'pending'
The state of each orders depends on 2 things:
- if the order can be found on the list of claimed orders, then the order is 'returned' (no need to check if the order is over)
- if the the current batch ID is greater than the batchId of the order, then the batch is 'over'
This calculation means you need to call the marketMakerContract.getCurrentBatchId()
on a regular basis on the frontend.
Recalculate the state of the orders when one of the following occurs:
- new currentBatchId
- new order
- new claim
On the "My orders" tab, filter the orders by the connected user (accessible via the useConnectedAccount()
hook of aragon.js
)
TODO: This could be optimized, we don't need to recalculate state of already returned orders.
TODO:: This should be refactored when this PR aragon/aragon.js#361 gets merged and published in a new version of aragon.js
There's 2 tapped token, but we only care about the DAI.
Expressed in DAI/month
Can be found on the tap
object, and converted in DAI/month
Expressed in DAI
Can be found on the tap
object
(TODO: Why displaying ANT collateralization ratio ?)
In percents
ratio = reserveRatio / ppm
ppm
: inmarketMaker
contractreserveRatio
: in the current collateral token
totalSupply
of the bonded token, minus the tokenToBeMinted
totalSupply
andtokensToBeMinted
are related to thebondedToken
name
and symbol
of the bonded token
name
andsymbol
are related to thebondedToken
Place a new buy or sell order with the following calls: openBuyOrder
and openSellOrder
passing the following arguments:
address
: the address of the collateral usedamount
: amount of collateral or token
To calculate the conversion between the collateral and the bonded token, we use calculatePurchaseReturn
or calculateSaleReturn
calls on the BancorFormula
contract with the following arguments:
supply
:totalSupply
of the bonded token +tokensToBeMinted
of the bonded token +virtualSupply
of the current collateralbalance
:balanceOf(pool, collateral)
the balance of the given collateral in thepool
weight
: TODO: ????amount
: amount of buy or sell
Update monthly allocation and floor according to the following rules:
- no more than one increase per month. Check last update with
timestamp
on the tapped token - no restrictions on decrease
- an increase should fit within the
maximumTapIncreasePct
- no particular rules on the
floor
(TODO: what about preventing floor increase over reserve balance ?)
Just a call to claimBuyOrder
or claimSellOrder
on the controller
passing the batchId
and collateral
address to be claimed.
Just a call to withdraw
on the controller
passing the collateral
address to withdraw.
TODO: TBD
Passing the list of batches
where the startingPrice is calculated with the following formula on the background script:
startPrice = (balance * ppm) / (supply * reserveRatio)
All values coming from the event, except ppm
which can be found on the background script state.
(TODO: Should we continue to calculate it on the background script ?)