Skip to content

Commit

Permalink
feat(contracts): add event params & explicit cmp/uncmp names
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubpark committed Aug 22, 2024
1 parent 4f959a0 commit dfa478b
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 80 deletions.
49 changes: 26 additions & 23 deletions contracts/src/interfaces/IIPTokenStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ interface IIPTokenStaking {
}

/// @notice Emitted when a new validator is created.
/// @param validatorPubkey 33 bytes compressed secp256k1 public key.
/// @param validatorUncmpPubkey 65 bytes uncompressed secp256k1 public key.
/// @param validatorCmpPubkey 33 bytes compressed secp256k1 public key.
/// @param moniker The moniker of the validator.
/// @param stakeAmount Token staked to the validator as self-delegation.
/// @param commissionRate The commission rate of the validator.
/// @param maxCommissionRate The maximum commission rate of the validator.
/// @param maxCommissionChangeRate The maximum commission change rate of the validator.
event CreateValidator(
bytes validatorPubkey,
bytes validatorUncmpPubkey,
bytes validatorCmpPubkey,
string moniker,
uint256 stakeAmount,
uint32 commissionRate,
Expand All @@ -45,28 +47,29 @@ interface IIPTokenStaking {
);

/// @notice Emitted when the withdrawal address is set/changed.
/// @param depositorPubkey Depositor's 33 bytes compressed secp256k1 public key.
/// @param delegatorPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param executionAddress Left-padded 32 bytes of the EVM address to receive stake and reward withdrawals.
event SetWithdrawalAddress(bytes depositorPubkey, bytes32 executionAddress);
event SetWithdrawalAddress(bytes delegatorPubkey, bytes32 executionAddress);

/// @notice Emitted when a user deposits token into the contract.
/// @param depositorPubkey Depositor's 33 bytes compressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param delegatorUncmpPubkey Delegator's 65 bytes uncompressed secp256k1 public key.
/// @param delegatorCmpPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param amount Token deposited.
event Deposit(bytes depositorPubkey, bytes validatorPubkey, uint256 amount);
event Deposit(bytes delegatorUncmpPubkey, bytes delegatorCmpPubkey, bytes validatorCmpPubkey, uint256 amount);

/// @notice Emitted when a user triggers redelegation of token from source validator to destination validator.
/// @param depositorPubkey Depositor's 33 bytes compressed secp256k1 public key.
/// @param delegatorPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param validatorSrcPubkey Source validator's 33 bytes compressed secp256k1 public key.
/// @param validatorDstPubkey Destination validator's 33 bytes compressed secp256k1 public key.
/// @param amount Token redelegated.
event Redelegate(bytes depositorPubkey, bytes validatorSrcPubkey, bytes validatorDstPubkey, uint256 amount);
event Redelegate(bytes delegatorPubkey, bytes validatorSrcPubkey, bytes validatorDstPubkey, uint256 amount);

/// @notice Emitted when a user withdraws her stake and starts the unbonding period.
/// @param depositorPubkey Depositor's 33 bytes compressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param delegatorPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param amount Token deposited.
event Withdraw(bytes depositorPubkey, bytes validatorPubkey, uint256 amount);
event Withdraw(bytes delegatorPubkey, bytes validatorCmpPubkey, uint256 amount);

/// @notice Emitted when the minimum stake amount is set.
/// @param minStakeAmount The new minimum stake amount.
Expand Down Expand Up @@ -127,23 +130,23 @@ interface IIPTokenStaking {

/// @notice Entry point for creating a new validator with self delegation on behalf of the validator.
/// @dev There's no minimum amount required to stake when creating a new validator.
/// @param validatorPubkey 33 bytes compressed secp256k1 public key.
function createValidatorOnBehalf(bytes calldata validatorPubkey) external payable;
/// @param validatorUncmpPubkey 65 bytes uncompressed secp256k1 public key.
function createValidatorOnBehalf(bytes calldata validatorUncmpPubkey) external payable;

/// @notice Entry point for staking IP token to stake to the given validator. The consensus chain is notified of
/// the deposit and manages the stake accounting and validator onboarding. Payer must be the delegator.
/// @dev When staking, consider it as BURNING. Unstaking (withdrawal) will trigger native minting.
/// @param delegatorUncmpPubkey Delegator's 65 bytes uncompressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
function stake(bytes calldata delegatorUncmpPubkey, bytes calldata validatorPubkey) external payable;
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
function stake(bytes calldata delegatorUncmpPubkey, bytes calldata validatorCmpPubkey) external payable;

/// @notice Entry point for staking IP token to stake to the given validator. The consensus chain is notified of
/// the stake and manages the stake accounting and validator onboarding. Payer can stake on behalf of another user,
/// who will be the beneficiary of the stake.
/// @dev When staking, consider it as BURNING. Unstaking (withdrawal) will trigger native minting.
/// @param delegatorPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
function stakeOnBehalf(bytes calldata delegatorPubkey, bytes calldata validatorPubkey) external payable;
/// @param delegatorUncmpPubkey Delegator's 65 bytes uncompressed secp256k1 public key.
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
function stakeOnBehalf(bytes calldata delegatorUncmpPubkey, bytes calldata validatorCmpPubkey) external payable;

// TODO: Redelegation also requires unbonding period to be executed. Should we separate storage for this for el?
/// @notice Entry point for redelegating the staked token.
Expand All @@ -159,18 +162,18 @@ interface IIPTokenStaking {
/// @notice Entry point for unstaking the previously staked token.
/// @dev Unstake (withdrawal) will trigger native minting, so token in this contract is considered as burned.
/// @param delegatorUncmpPubkey Delegator's 65 bytes uncompressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param amount Token amount to unstake.
function unstake(bytes calldata delegatorUncmpPubkey, bytes calldata validatorPubkey, uint256 amount) external;
function unstake(bytes calldata delegatorUncmpPubkey, bytes calldata validatorCmpPubkey, uint256 amount) external;

/// @notice Entry point for unstaking the previously staked token on behalf of the delegator.
/// @dev Must be an approved operator for the delegator.
/// @param delegatorCmpPubkey Delegator's 33 bytes compressed secp256k1 public key.
/// @param validatorPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param validatorCmpPubkey Validator's 33 bytes compressed secp256k1 public key.
/// @param amount Token amount to unstake.
function unstakeOnBehalf(
bytes calldata delegatorCmpPubkey,
bytes calldata validatorPubkey,
bytes calldata validatorCmpPubkey,
uint256 amount
) external;
}
Loading

0 comments on commit dfa478b

Please sign in to comment.