Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unusual require statement in BondDepository #8

Open
rlkelly opened this issue Dec 28, 2021 · 1 comment
Open

Unusual require statement in BondDepository #8

rlkelly opened this issue Dec 28, 2021 · 1 comment

Comments

@rlkelly
Copy link

rlkelly commented Dec 28, 2021

https://github.com/Wonderland-Money/contracts/blob/main/BondDepository.sol#L701

It says:

        uint profit = value.sub( payout ).sub( fee );
        ...
        treasury.deposit( _amount, address(principle), profit );
        ...
        require(balanceBefore.add(profit) == Time.balanceOf(address(this)), "Not enough Time to cover profit");

This means that it assumes that the balance has been increased by the profit. But this calls treasury.deposit( _amount, address(principle), profit ); which runs:

        uint value = valueOf(_token, _amount);
        // mint Time needed and store amount of rewards for distribution
        send_ = value.sub( _profit );
        ...
        Time.mint( msg.sender, send_ );

So I believe this only works if profit is half the value of the amount. I'm curious why this assertion is in the code.

@loic001
Copy link

loic001 commented Feb 21, 2022

very strange indeed... It would make more sense to test if there are enough tokens to cover the payout. Why cover the profit?

require(balanceBefore.add(payout) == Time.balanceOf(address(this)), "Not enough Time to cover payout"); would be better no ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants