Skip to content

Commit

Permalink
Update AccountInfo with cooldown fields
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Aug 27, 2024
1 parent affcd78 commit 7c65769
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,21 @@ interface AccountInfoCommon {
accountEncryptedAmount: AccountEncryptedAmount;
accountReleaseSchedule: AccountReleaseSchedule;
accountCredentials: Record<number, AccountCredential>;
/**
* The stake on the account that is in cooldown.
* There can be multiple amounts in cooldown that expire at different times.
* This was introduced in protocol version 7, and so is not present in
* earlier protocol versions.
*/
accountCooldowns: Cooldown[];
/**
* The available (unencrypted) balance of the account (i.e. that can be transferred
* or used to pay for transactions). This is the balance minus the locked amount.
* The locked amount is the maximum of the amount in the release schedule and
* the total amount that is actively staked or in cooldown (inactive stake).
* This was introduced with protocol version 7
*/
accountAvailableBalance: CcdAmount.Type;
}

export interface AccountInfoSimple extends AccountInfoCommon {
Expand Down Expand Up @@ -1832,3 +1847,44 @@ export type BlockItem =
expiry: number;
};
};

/**
* The status of a cooldown. When stake is removed from a baker or delegator
* (from protocol version 7) it first enters the pre-pre-cooldown state.
* The next time the stake snaphot is taken (at the epoch transition before
* a payday) it enters the pre-cooldown state. At the subsequent payday, it
* enters the cooldown state. At the payday after the end of the cooldown
* period, the stake is finally released.
*/
export enum CooldownStatus {
/**
* The amount is in cooldown and will expire at the specified time, becoming available
* at the subsequent pay day.
*/
Cooldown,
/**
* The amount will enter cooldown at the next pay day. The specified end time is
* projected to be the end of the cooldown period, but the actual end time will be
* determined at the payday, and may be different if the global cooldown period
* changes.
*/
PreCooldown,
/**
* The amount will enter pre-cooldown at the next snapshot epoch (i.e. the epoch
* transition before a pay day transition). As with pre-cooldown, the specified
* end time is projected, but the actual end time will be determined later.
*/
PrePreCooldown,
}

/**
* Describes a cooldown associated with removal of stake from a baker/delegator account
*/
export type Cooldown = {
/** The time at which the cooldown will end */
timestamp: Timestamp.Type;
/** The amount that is in cooldown and set to be released at the end of the cooldown period */
amount: CcdAmount.Type;
/** The status of the cooldown */
cooldownStatus: CooldownStatus;
};

0 comments on commit 7c65769

Please sign in to comment.