Token value

When transferring tokens between blockchains, the amount needs to be converted into their internal dollar value. This value depends on the pool condition and the amount being evaluated.

For the sending side (converting tokens into their value):

Where:

  • xorig is the token balance in the pool before swap (tokenBalance view function in the Pool contract)

  • xtokens is the amount of tokens you plan to swap

  • yorig is the value balance in the pool (vUsdBalance view function in the Pool contract)

  • a is a swap curve shape constant (a view function in the Pool contract, does not change)

  • d is a measure of the total liquidity in the pool (d view function in the Pool contract, does not change unless liquidity is added or removed)

  • yvalue is the resulting dollar value of the xtokens tokens

For the receiving side (converting value into tokens, the formula is very similar but reversed):

The meaning of the variables is the same as before, but for the token pool on the receiving side.

Last updated