Open juliencharrel opened 1 year ago
1) _calculatePrice
is supposed to calculate the new price, right?
2) Why do parameters a
and b
need to be such high numbers with over 46 digits? I don't see wy that would be necessary.
3) Is the TDF token going to be a 18-decimal ERC20?
It's because we need to scale the parameters and our formula has ^2 and ^3 parameters in it. Look into the spreadsheet here https://docs.google.com/spreadsheets/d/17PEOgTeItXcquVjt1hvyfUIXu9y0ZHjsAsUpS3DhWFA/edit#gid=2075084444 and here's a screenshot of side by side formula for 1 ether of units vs 1 wei
If you want to use the other formula, you would need to do calculation with ether and then handle float numbers, that's why I scaled the cost and price functions
What is the problem with large numbers? (as long as we guarantee no overflow)
Ok sure, I understand now why the factors needed to be scaled.
But right now I actually wonder if we need to operate in wei-style decimals because it seems to be a requirement that no fractional TDF tokens can be bought.
require(amount % 1 ether == 0, "DynamicSale: (NonWholeUnit) only whole units allowed");
What do you think?
Good catch, you can remove that requirement ;)
There is an script to generate a Json file from the pricing output. We should generate this file, confirm with Tokenomics team and test that the contract outputs the same results in tests.
hey guys, I am trying to use scripts/output_pricing.ts
, but it's failing and not giving me the json I need for the test.
I believe this is because there is a Typescript error in lines 43:44:
nextUnitPrice: formatEther(await contracts.sale.calculateTotalCost(parseEther('1'))),
amountCost: formatEther(await contracts.sale.calculateTotalCost(parseEther(step.toString()))),
so calculateTotalCost
is returning a type [BigNumber, BigNumber] & { newPrice: BigNumber; totalCost: BigNumber }
which:
a) looks like a union of quite different types, is this expected?
b) is definitely not good for the formatEther
argument that expects
type BigNumberish = BigNumber | Bytes | bigint | string | number
@arturictus @juliencharrel do you guys have any idea how to fix output_pricing.ts
?
You can use the output like an object output.totalCost and the format should pick it up
@arturictus Artur, sorry, but I am lost.
output
object, that you mentioned? Is it something that exists on contracts.sale
(I don't see it there)? output_pricing.ts
and we get the json, how do I insert the data into a test, would it be something like:
// suppose json have arrays of {amount, price)
json.forEach(arrayItem => await user.calculateTotalCost(arrayItem.amount).toEq(arrayItem.price));
☝️ is this what we want to test?
// suppose json have arrays of {amount, price)
json.forEach(arrayItem => await user.calculateTotalCost(arrayItem.amount).totalCost.toEq(arrayItem.price));
notice: .totalCost.toEq(
wait, I just realized my question doesn't make sense, I compare calculateTotalCost
to itself, obviously, this is going to work:)
I am sorry for the confusion, @arturictus could we please align on the task:
fn: A -> B
? calculateTotalCost
from DynamicSale
contract?calculateTotalCost(column A) == column B
Do you know if my understanding of the task is correct?
I opened a pr with my naive implementation
assigning this task back to @arturictus as I failed again to accomplish it.
Work already started in the sale_contract branch. Start from there.
I updated the _calculatePrice function that is supposed to compute 1/ the last price after increase of supply 2/The cost of buying tokens (delta cost between a start and end supply).
You need to:
https://docs.google.com/spreadsheets/d/17PEOgTeItXcquVjt1hvyfUIXu9y0ZHjsAsUpS3DhWFA/edit#gid=2075084444