diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 3658f41e..d023a004 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1037,6 +1037,21 @@ interface AccountInfoCommon { accountEncryptedAmount: AccountEncryptedAmount; accountReleaseSchedule: AccountReleaseSchedule; accountCredentials: Record; + /** + * 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 { @@ -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; +};