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

lockup_contract: some view methods crashing or giving incorrect values #192

Open
telezhnaya opened this issue Dec 16, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@telezhnaya
Copy link
Contributor

https://github.com/near/core-contracts/blob/master/lockup/src/getters.rs#L118

    /// Get the amount of tokens that are already vested or released, but still locked due to lockup.
    /// Takes raw vesting schedule, in case the internal vesting schedule is private.
    pub fn get_locked_vested_amount(&self, vesting_schedule: VestingSchedule) -> WrappedBalance {
        (self.get_locked_amount().0 - self.get_unvested_amount(vesting_schedule).0).into()
    }

If lockup starts earlier than vesting, we crash because we have a negative result after subtracting

@telezhnaya telezhnaya added the bug Something isn't working label Dec 16, 2021
@frol
Copy link
Contributor

frol commented Dec 16, 2021

Well, nice finding, but ...

If lockup starts earlier than vesting, we crash because we have a negative result after subtracting

There is never a case where the lockup is earlier than vesting just according to common sense.

@frol frol closed this as completed Dec 16, 2021
@telezhnaya telezhnaya reopened this Dec 17, 2021
@telezhnaya
Copy link
Contributor Author

telezhnaya commented Dec 17, 2021

I am sorry, I misinformed you above, there's nothing about termination. I deleted my wrong statements above not to misinform anyone else. The bug exists, though.

Also found incorrect get_owners_balance
https://github.com/near/core-contracts/blob/master/lockup/src/getters.rs#L163
It says

It includes vested and extra tokens that may have been deposited to this account, but excludes locked tokens.

In fact, there's nothing about vesting logic inside.

And get_liquid_owners_balance
https://github.com/near/core-contracts/blob/master/lockup/src/getters.rs#L176
Same error, no check whether tokens were vested or not

@telezhnaya telezhnaya changed the title lockup_contract: crashing on method get_locked_vested_amount lockup_contract: some view methods crashing or giving incorrect values Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants