-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(aux-ts): sdk support for stake pools #296
Conversation
59834b2
to
fa9e087
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Leina. I have a few questions re: the create
function usage and added some minor comments. Can you help me with these when you have a chance?
let pool = table::borrow_mut(&mut pools.pools, pool_id); | ||
assert!(pool.authority == sender_addr, E_TEST_FAILURE); | ||
assert!(pool.start_time == start_time, E_TEST_FAILURE); | ||
assert!(pool.end_time == end_time, E_TEST_FAILURE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so sure how this test was passingwith seemingly stale input parameters for create function line 1605. Maybe I'm missing something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good catch. I think it's because in the tests, the timestamp starts as 0
, so there's no difference between end_time
and duration_us
. I'll fast forward time a bit in the setup to avoid that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I added the fix and rebased, but if you check out this commit: 0f2761d65443b06ea73f409969f2d1fd82b29586
you should see these tests failing due to that bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Leina! I cannot replicate the test failures : (
misung@penguin:~/aux-exchange/aptos/api/aux-ts$ git checkout 0f2761d65443b06ea73f409969f2d1fd82b29586 fatal: reference is not a tree: 0f2761d65443b06ea73f409969f2d1fd82b29586
I was able to check out another commit f854bb8 instead, but I'm not so sure how to run these tests in stake.move
instead of stake.spec.ts
:
misung@penguin:~ /aux-exchange/aptos/api/aux-ts$ git checkout f854bb8
HEAD is now at f854bb8 fast forward start time in stake tests
misung@penguin:~/aux-exchange/aptos/api/aux-ts$ APTOS_NETWORK="local" yarn test --g "Stake"
Stake Pool tests
✔ fundAccount (1113ms)
✔ createStakePoolClient
✔ mintAux (2482ms)
✔ mintOther (1073ms)
✔ createStakePool (1069ms)
✔ deposit (1153ms)
Sleeping for 2 seconds
✔ claim (3057ms)
✔ modifyPool (1065ms)
✔ modifyAuthority (3305ms)
✔ endRewardEarly (2191ms)
✔ withdraw (1128ms)
✔ deleteEmptyPool (1075ms)
12 passing (19s)
e3d4a87
to
e47aa70
Compare
stake pools sdk
feat(aux): add end_reward_early function to stake.move
Apply suggestions from code review Co-authored-by: Misung Son <misungs@gmail.com>
64d550a
to
ba2a4e4
Compare
Thanks for reviewing, @misungson. I believe I applied / fixed all of your suggestions, but let me know if I missed anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making the changes, Leina!
They all look good to me. I'm failing to replicate the intermediate test results (details mentioned in the other comment), but that would be due to my user error.
let pool = table::borrow_mut(&mut pools.pools, pool_id); | ||
assert!(pool.authority == sender_addr, E_TEST_FAILURE); | ||
assert!(pool.start_time == start_time, E_TEST_FAILURE); | ||
assert!(pool.end_time == end_time, E_TEST_FAILURE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Leina! I cannot replicate the test failures : (
misung@penguin:~/aux-exchange/aptos/api/aux-ts$ git checkout 0f2761d65443b06ea73f409969f2d1fd82b29586 fatal: reference is not a tree: 0f2761d65443b06ea73f409969f2d1fd82b29586
I was able to check out another commit f854bb8 instead, but I'm not so sure how to run these tests in stake.move
instead of stake.spec.ts
:
misung@penguin:~ /aux-exchange/aptos/api/aux-ts$ git checkout f854bb8
HEAD is now at f854bb8 fast forward start time in stake tests
misung@penguin:~/aux-exchange/aptos/api/aux-ts$ APTOS_NETWORK="local" yarn test --g "Stake"
Stake Pool tests
✔ fundAccount (1113ms)
✔ createStakePoolClient
✔ mintAux (2482ms)
✔ mintOther (1073ms)
✔ createStakePool (1069ms)
✔ deposit (1153ms)
Sleeping for 2 seconds
✔ claim (3057ms)
✔ modifyPool (1065ms)
✔ modifyAuthority (3305ms)
✔ endRewardEarly (2191ms)
✔ withdraw (1128ms)
✔ deleteEmptyPool (1075ms)
12 passing (19s)
* feat(aux): simple staking contract, modeled after sushiswap masterchef * chore(aux): reward_debt -> last_acc_reward_per_share * chore(aux): abort only contract feat(aux-ts): sdk support for stake pools (#296) * add timestamps to stake pool events stake pools sdk * chore(aux-ts): stake pool tests feat(aux): add end_reward_early function to stake.move * fast forward start time in stake tests * update all tests to use duration instead of end_time in pool creation * replace endTimeUs with durationUs * Co-authored-by: Misung Son <misungs@gmail.com> Apply suggestions from code review feat(aux-ts): stake sdk localnet example (#303) * Initial commit of stake sdk localnet example. * add examples section to CONTRIBUTING.md * Added start:localnet-stake-example to package.json. * Changed the example to staker allocating between two pools (seems more relevant to me) instead of staking in one pool above threshold. * fix(localnet-stake-allocator.ts): set up other staking account * Switched to a brute-force method to find optimal staker positions. * Minor change in comments. * A little generalization using M in computing x1Optimal. Co-authored-by: Leina McDermott <leina05@gmail.com>
* feat(aux): simple staking contract, modeled after sushiswap masterchef * chore(aux): reward_debt -> last_acc_reward_per_share * chore(aux): abort only contract feat(aux-ts): sdk support for stake pools (#296) * add timestamps to stake pool events stake pools sdk * chore(aux-ts): stake pool tests feat(aux): add end_reward_early function to stake.move * fast forward start time in stake tests * update all tests to use duration instead of end_time in pool creation * replace endTimeUs with durationUs * Co-authored-by: Misung Son <misungs@gmail.com> Apply suggestions from code review feat(aux-ts): stake sdk localnet example (#303) * Initial commit of stake sdk localnet example. * add examples section to CONTRIBUTING.md * Added start:localnet-stake-example to package.json. * Changed the example to staker allocating between two pools (seems more relevant to me) instead of staking in one pool above threshold. * fix(localnet-stake-allocator.ts): set up other staking account * Switched to a brute-force method to find optimal staker positions. * Minor change in comments. * A little generalization using M in computing x1Optimal. Co-authored-by: Leina McDermott <leina05@gmail.com>
* feat(aux): simple staking contract, modeled after sushiswap masterchef * chore(aux): reward_debt -> last_acc_reward_per_share * chore(aux): abort only contract feat(aux-ts): sdk support for stake pools (#296) * add timestamps to stake pool events stake pools sdk * chore(aux-ts): stake pool tests feat(aux): add end_reward_early function to stake.move * fast forward start time in stake tests * update all tests to use duration instead of end_time in pool creation * replace endTimeUs with durationUs Apply suggestions from code review feat(aux-ts): stake sdk localnet example (#303) * Initial commit of stake sdk localnet example. * add examples section to CONTRIBUTING.md * Added start:localnet-stake-example to package.json. * Changed the example to staker allocating between two pools (seems more relevant to me) instead of staking in one pool above threshold. * fix(localnet-stake-allocator.ts): set up other staking account * Switched to a brute-force method to find optimal staker positions. * Minor change in comments. * A little generalization using M in computing x1Optimal. Co-authored-by: Misung Son <misungs@gmail.com> Co-authored-by: Leina McDermott <leina05@gmail.com>
* feat(aux): simple yield farming contract (masterchef) (#260) * feat(aux): simple staking contract, modeled after sushiswap masterchef * chore(aux): reward_debt -> last_acc_reward_per_share feat(aux-ts): sdk support for stake pools (#296) * add timestamps to stake pool events stake pools sdk * chore(aux-ts): stake pool tests feat(aux): add end_reward_early function to stake.move * fast forward start time in stake tests * update all tests to use duration instead of end_time in pool creation * replace endTimeUs with durationUs Apply suggestions from code review feat(aux-ts): stake sdk localnet example (#303) * Initial commit of stake sdk localnet example. * add examples section to CONTRIBUTING.md * Added start:localnet-stake-example to package.json. * Changed the example to staker allocating between two pools (seems more relevant to me) instead of staking in one pool above threshold. * fix(localnet-stake-allocator.ts): set up other staking account * Switched to a brute-force method to find optimal staker positions. * Minor change in comments. * A little generalization using M in computing x1Optimal. Co-authored-by: Misung Son <misungs@gmail.com> Co-authored-by: Leina McDermott <leina05@gmail.com> * fix(aux): remove support for duplicate stake pool type creation * feat(aux): add wrapped st coin to support stake coin rehypothecation * chore(aux): add st coin balance checks to tests and add test for double dip * fix(aux): stash initialized coin caps when deleting pool to allow to reuse for new pools Co-authored-by: Misung Son <misungs@gmail.com>
No description provided.