I want to calculate a supplyDelta value to be used in a rebase function for this contract https://testnet.bscscan.com/address/0xE6A61396361935231E6BC403Fc206Fa1A99E628F. But I don't know how to calculate it. Any help will be really appreciated. I had a look at this article https://www.publish0x.com/block-enthusiast-an-exploration-of-things/rebase-the-implications-of-supply-smoothing-xropreg but couldn't understand it without an example
1 Like
New Trenddddd right?
At the moment I looked at some rebase contracts, and I suggest to look at the main and only real one https://www.ampleforth.org/. You can learn a lot from their docs.
The rebase() function is usually called by an external contract, usually named Master, that is linked to a third contract, an Oracle. Thanks to the data given by the Oracle, the master do the math and call the rebase() with the """right""" input. Why so many """ ? Well because all the rebase tokens that has been launched in these days, are all made of ovverideRebase
You can see an example here:
function computeSupplyDelta(uint256 rate)
internal
view
returns (int256)
{
if (withinDeviationThreshold(rate)) {
return 0;
}
int256 targetRateSigned = targetRate.toInt256Safe();
return guh.totalSupply().toInt256Safe()
.mul(rate.toInt256Safe().sub(targetRateSigned))
.div(targetRateSigned);
}
1 Like