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

New Staking Curve #113

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

scobi7
Copy link
Collaborator

@scobi7 scobi7 commented Jul 15, 2024

New Staking Curve that implements linear decay. Allows for you to create a lock that sets the staking amount and time you will lock it for (create_lock(amount, lock_time). Basically queries when you do so and keeps track of locked amount and lock creation time. Then if you call get_balance_of, it applies linear decay formula which to calculate your current amount at this time stamp.

IMPORTANT:

by changing the functions like set_staking_curve, it affected almost all other test files that used these functions like test_treasury.

Not sure what we must do about this, since both curves are different.

@scobi7 scobi7 requested a review from tensojka July 15, 2024 07:50
@scobi7 scobi7 closed this Jul 15, 2024
@scobi7 scobi7 deleted the scobi7-staking branch July 15, 2024 07:54
@scobi7 scobi7 restored the scobi7-staking branch July 22, 2024 15:59
@scobi7 scobi7 reopened this Jul 22, 2024
@scobi7 scobi7 closed this Jul 23, 2024
@scobi7 scobi7 deleted the scobi7-staking branch July 23, 2024 08:49
@scobi7 scobi7 restored the scobi7-staking branch July 23, 2024 08:51
@scobi7 scobi7 reopened this Jul 23, 2024
Copy link
Contributor

@tensojka tensojka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing code that gets total_supply and balance_of the voting token – this is now finally possible to be implemented.

How will tokens locked the old way be handled?

src/staking.cairo Outdated Show resolved Hide resolved
src/staking.cairo Outdated Show resolved Hide resolved
scobi7 added a commit to scobi7/konoha that referenced this pull request Jul 25, 2024
Copy link
Contributor

@tensojka tensojka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update voting_token.cairo to use these functions from staking.cairo, we need total_supply to work correctly.

The tests test only staking itself, but not that it works correctly with proposals/upgrades (doesn't mess with quorum, etc)

src/staking.cairo Outdated Show resolved Hide resolved
let unlock_date = current_time + lock_duration;
assert(unlock_date > current_time, 'can only lock in the future(CL)');

//maybe a max time assertion?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely, also set MAX_TIME to 2 yrs

}
);
}
fn withdraw(ref self: ComponentState<TContractState>, caller: ContractAddress) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you burn the locked token anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if caller is withdrawing their staked tokens, shouldn't it be transferred back to them and not burned?

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

Successfully merging this pull request may close these issues.

2 participants