-
Notifications
You must be signed in to change notification settings - Fork 17
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
Timelocked delegation #162
Conversation
c8231bf
to
8dabaf6
Compare
let (stake, expire_timestamp_ms) = time_lock::unpack(timelocked_stake); | ||
|
||
let staked_sui = sui_system.request_add_stake_non_entry( | ||
stake.into_coin(ctx), |
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.
It is necessary to get rid of Balance -> Coin conversion.
I suggest to move the modules out from the |
…on-in-stardust Move timelocked delegation to stardust package
7fafe1a
to
a0e4907
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.
As discussed, the Timelock
and thus also TimelockedStakedSui
should be non transferable.
crates/sui-framework/packages/stardust/sources/timelock/timelocked_staking.move
Outdated
Show resolved
Hide resolved
crates/sui-framework/packages/stardust/sources/timelock/timelocked_staking.move
Show resolved
Hide resolved
crates/sui-framework/packages/stardust/sources/timelock/timelocked_staking.move
Outdated
Show resolved
Hide resolved
crates/sui-framework/packages/stardust/sources/timelock/timelocked_staked_sui.move
Show resolved
Hide resolved
crates/sui-framework/packages/stardust/sources/timelock/timelocked_staking.move
Outdated
Show resolved
Hide resolved
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.
LGTM!
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.
looks good 👍
|
||
use sui_system::staking_pool::StakedSui; | ||
|
||
const EIncompatibleTimelockedStakedSui: u64 = 1; |
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.
const EIncompatibleTimelockedStakedSui: u64 = 1; | |
const EIncompatibleTimelockedStakedSui: u64 = 0; |
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.
fixed
use stardust::timelock::{Self, TimeLock}; | ||
use stardust::timelocked_staked_sui::{Self, TimelockedStakedSui}; | ||
|
||
const ETimeLockShouldNotBeExpired: u64 = 1; |
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.
const ETimeLockShouldNotBeExpired: u64 = 1; | |
const ETimeLockShouldNotBeExpired: u64 = 0; |
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.
fixed
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.
Fantastic PR @valeriyr!
public(package) fun pack<T: store>(locked: T, expire_timestamp_ms: u64, ctx: &mut TxContext): TimeLock<T> { | ||
// Create a timelock. | ||
TimeLock { | ||
id: object::new(ctx), | ||
locked, | ||
expire_timestamp_ms | ||
} | ||
} | ||
|
||
/// An utility function to unpack a `TimeLock`. | ||
public(package) fun unpack<T: store>(lock: TimeLock<T>): (T, u64) { | ||
// Unpack the timelock. | ||
let TimeLock { | ||
id, | ||
locked, | ||
expire_timestamp_ms | ||
} = lock; | ||
|
||
// Delete the timelock. | ||
object::delete(id); | ||
|
||
(locked, expire_timestamp_ms) | ||
} |
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.
Just wondering if we shouldn't just merge following two function bodies with the respective lock/unlock functions directly.
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.
@samuel-rufi, thank you for the question!
These functions are used internally in the request_add_stake_non_entry
and request_withdraw_stake_non_entry
ones to create/destroy a TimeLock
instance during staking, or in other words, for TimeLock <-> TimeloedStakedSui
conversion.
The lock
and unlock
functions can not be used because they check additional conditions.
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.
Awesome, thanks for the explaination @valeriyr 👌
Description of change
There are two solution proposals:
Links to any relevant issues
Closes #130
Fixes two tasks of #134
Tests
Move-level integration tests.