Let's suppose I need to get X amount of SomeToken, and I have AnotherToken
It would be nice to have a function that calculates the following:
How many of AnotherToken should I spend to obtain X amount of SomeToken.
A simple example, explaining why it can be needed and getRate is not enough sometimes.
Let's try to use the current getRate function to calculate how many BNT tokens one should spend to get 10 ETH:
In this example, ethTokenAmount is quite close to initial (for now it is 9.944, ~0.56% deviation), but as initialAmount grows, the difference becomes greater too.
with initialAmount set to "1000" resulting ethTokenAmount is "859.966" which is 14% deviation, and that is a lot.
Though I understand that it might be hard to get an exact value, but I guess it's OK to specify a precision.
Let's suppose I need to get X amount of SomeToken, and I have AnotherToken
It would be nice to have a function that calculates the following: How many of AnotherToken should I spend to obtain X amount of SomeToken.
A simple example, explaining why it can be needed and
getRate
is not enough sometimes. Let's try to use the currentgetRate
function to calculate how many BNT tokens one should spend to get 10 ETH:In this example,
ethTokenAmount
is quite close to initial (for now it is 9.944, ~0.56% deviation), but asinitialAmount
grows, the difference becomes greater too.with
initialAmount
set to "1000" resultingethTokenAmount
is "859.966" which is 14% deviation, and that is a lot.Though I understand that it might be hard to get an exact value, but I guess it's OK to specify a precision.