Skip to content

Tokens received after LongTermSwap greatly varies from expected values for certain parameters #3

Description

@corddry

Increasing the length of the long term swaps causes most tests to fail. For example, setting blockInterval to 500 causes the received values to differ from the expected by as much as 30%.

I believe this to be a result of sellingRate being casted to an integer value.
uint256 sellingRate = amount / (orderExpiry - currentBlock);
In cases where amount is close to the number of blocks the order is selling over, this results in a drastic effect.
For example, selling 10,000 tokens over 5,000 blocks results in a sellingRate of 1.977, which is cast to 1, resulting in the user only receiving around half as many tokens as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions