import * as _solana_web3_js from '@solana/web3.js'; import { PublicKey, Keypair, TransactionInstruction, Connection, Transaction, AddressLookupTableAccount, Commitment, MemcmpFilter } from '@solana/web3.js'; import BN from 'bn.js'; import { IdlTypes, IdlAccounts, Program } from '@coral-xyz/anchor'; declare function deriveTokenVault(staking: PublicKey, programId: PublicKey): PublicKey; declare function deriveStakingAuthority(programId: PublicKey): PublicKey; declare function deriveEscrow(staking: PublicKey, owner: PublicKey, programId: PublicKey): PublicKey; declare function deriveEventAuthority(programId: PublicKey): PublicKey; /** * Program IDL in camelCase format in order to be used in JS/TS. * * Note that this is only a type helper and is not the actual IDL. The original * IDL can be found at `target/idl/referral.json`. */ type Referral$1 = { "address": "refnrNncADccJPZEB5hHuiFVb3trY5LH39ykwMD59Ht"; "metadata": { "name": "referral"; "version": "0.1.0"; "spec": "0.1.0"; "description": "Created with Anchor"; }; "instructions": [ { "name": "cancelUnstake"; "discriminator": [ 64, 65, 53, 227, 125, 153, 3, 167 ]; "accounts": [ { "name": "unstake"; "writable": true; }, { "name": "escrow"; "writable": true; "relations": [ "unstake" ]; }, { "name": "staking"; "writable": true; "relations": [ "unstake" ]; }, { "name": "owner"; "signer": true; "relations": [ "unstake" ]; }, { "name": "rentReceiver"; "writable": true; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": []; }, { "name": "claimPenaltyFee"; "discriminator": [ 61, 213, 181, 228, 50, 115, 39, 74 ]; "accounts": [ { "name": "staking"; "writable": true; }, { "name": "tokenVault"; "writable": true; "relations": [ "staking" ]; }, { "name": "tokenMint"; "relations": [ "staking" ]; }, { "name": "feeReceiverTokenAccount"; "writable": true; "pda": { "seeds": [ { "kind": "account"; "path": "staking"; }, { "kind": "account"; "path": "tokenProgram"; }, { "kind": "account"; "path": "tokenMint"; } ]; "program": { "kind": "const"; "value": [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ]; }; }; }, { "name": "tokenProgram"; "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { "name": "stakingAuthority"; "address": "4bpqRsxyEmegayUrEN28FCqZwiCBSQhFkB7R4BxyTuGy"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "claimPenaltyFeeParams"; }; }; } ]; }, { "name": "closeEscrow"; "discriminator": [ 139, 171, 94, 146, 191, 91, 144, 50 ]; "accounts": [ { "name": "escrow"; "writable": true; }, { "name": "staking"; "writable": true; "relations": [ "escrow" ]; }, { "name": "owner"; "signer": true; "relations": [ "escrow" ]; }, { "name": "rentReceiver"; "writable": true; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "skipCloseIfNonEmpty"; "type": "bool"; } ]; }, { "name": "immediateUnstake"; "discriminator": [ 125, 55, 141, 200, 252, 133, 78, 54 ]; "accounts": [ { "name": "escrow"; "writable": true; }, { "name": "staking"; "writable": true; "relations": [ "escrow" ]; }, { "name": "tokenVault"; "writable": true; "relations": [ "staking" ]; }, { "name": "tokenMint"; "relations": [ "staking" ]; }, { "name": "ownerTokenVault"; "writable": true; }, { "name": "owner"; "signer": true; "relations": [ "escrow" ]; }, { "name": "stakingAuthority"; "address": "4bpqRsxyEmegayUrEN28FCqZwiCBSQhFkB7R4BxyTuGy"; }, { "name": "tokenProgram"; "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "immediateUnstakeParams"; }; }; } ]; }, { "name": "initializeEscrow"; "discriminator": [ 243, 160, 77, 153, 11, 92, 48, 209 ]; "accounts": [ { "name": "staking"; "writable": true; }, { "name": "escrow"; "writable": true; "pda": { "seeds": [ { "kind": "const"; "value": [ 101, 115, 99, 114, 111, 119 ]; }, { "kind": "account"; "path": "staking"; }, { "kind": "account"; "path": "owner"; } ]; }; }, { "name": "owner"; }, { "name": "payer"; "writable": true; "signer": true; }, { "name": "systemProgram"; "address": "11111111111111111111111111111111"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": []; }, { "name": "initializeStaking"; "discriminator": [ 184, 41, 251, 154, 146, 145, 197, 77 ]; "accounts": [ { "name": "staking"; "writable": true; "signer": true; }, { "name": "tokenVault"; "writable": true; "pda": { "seeds": [ { "kind": "const"; "value": [ 115, 116, 97, 107, 105, 110, 103, 95, 118, 97, 117, 108, 116 ]; }, { "kind": "account"; "path": "staking"; } ]; }; }, { "name": "tokenMint"; }, { "name": "stakingAuthority"; "address": "4bpqRsxyEmegayUrEN28FCqZwiCBSQhFkB7R4BxyTuGy"; }, { "name": "owner"; }, { "name": "stakingPenaltyFeeReceiver"; }, { "name": "payer"; "writable": true; "signer": true; }, { "name": "tokenProgram"; "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { "name": "systemProgram"; "address": "11111111111111111111111111111111"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "initializeStakingParams"; }; }; } ]; }, { "name": "stake"; "discriminator": [ 206, 176, 202, 18, 200, 209, 179, 108 ]; "accounts": [ { "name": "staking"; "writable": true; "relations": [ "escrow" ]; }, { "name": "escrow"; "writable": true; }, { "name": "tokenVault"; "writable": true; "relations": [ "staking" ]; }, { "name": "tokenMint"; "relations": [ "staking" ]; }, { "name": "ownerTokenVault"; "writable": true; }, { "name": "owner"; "signer": true; "relations": [ "escrow" ]; }, { "name": "tokenProgram"; "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "stakeParams"; }; }; } ]; }, { "name": "transferOwner"; "discriminator": [ 245, 25, 221, 175, 106, 229, 225, 45 ]; "accounts": [ { "name": "staking"; "writable": true; }, { "name": "owner"; "signer": true; }, { "name": "newOwner"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": []; }, { "name": "unstake"; "discriminator": [ 90, 95, 107, 42, 205, 124, 50, 225 ]; "accounts": [ { "name": "unstake"; "writable": true; "signer": true; }, { "name": "escrow"; "writable": true; }, { "name": "staking"; "writable": true; "relations": [ "escrow" ]; }, { "name": "owner"; "signer": true; "relations": [ "escrow" ]; }, { "name": "payer"; "writable": true; "signer": true; }, { "name": "systemProgram"; "address": "11111111111111111111111111111111"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "unstakeParams"; }; }; } ]; }, { "name": "updateConfig"; "discriminator": [ 29, 158, 252, 191, 10, 83, 219, 99 ]; "accounts": [ { "name": "staking"; "writable": true; }, { "name": "owner"; "signer": true; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": [ { "name": "params"; "type": { "defined": { "name": "updateConfigParams"; }; }; } ]; }, { "name": "updatePenaltyFeeReceiver"; "discriminator": [ 77, 197, 74, 123, 114, 173, 124, 117 ]; "accounts": [ { "name": "staking"; "writable": true; }, { "name": "owner"; "signer": true; }, { "name": "newFeeReceiver"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": []; }, { "name": "withdraw"; "discriminator": [ 183, 18, 70, 156, 148, 109, 161, 34 ]; "accounts": [ { "name": "unstake"; "writable": true; }, { "name": "escrow"; "writable": true; "relations": [ "unstake" ]; }, { "name": "staking"; "writable": true; "relations": [ "unstake" ]; }, { "name": "tokenVault"; "writable": true; "relations": [ "staking" ]; }, { "name": "tokenMint"; "relations": [ "staking" ]; }, { "name": "ownerTokenVault"; "writable": true; }, { "name": "owner"; "signer": true; "relations": [ "unstake" ]; }, { "name": "rentReceiver"; "writable": true; }, { "name": "stakingAuthority"; "address": "4bpqRsxyEmegayUrEN28FCqZwiCBSQhFkB7R4BxyTuGy"; }, { "name": "tokenProgram"; "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; }, { "name": "eventAuthority"; }, { "name": "program"; } ]; "args": []; } ]; "accounts": [ { "name": "escrow"; "discriminator": [ 31, 213, 123, 187, 186, 22, 218, 155 ]; }, { "name": "staking"; "discriminator": [ 242, 134, 183, 223, 18, 13, 184, 23 ]; }, { "name": "unstake"; "discriminator": [ 154, 148, 131, 67, 52, 244, 244, 19 ]; } ]; "events": [ { "name": "cancelUnstakeEvt"; "discriminator": [ 230, 63, 92, 158, 107, 126, 230, 39 ]; }, { "name": "claimPenaltyFeeEvt"; "discriminator": [ 228, 41, 121, 236, 21, 69, 166, 71 ]; }, { "name": "closeEscrowEvt"; "discriminator": [ 206, 208, 89, 181, 183, 64, 108, 210 ]; }, { "name": "immediateUnstakeEvt"; "discriminator": [ 36, 24, 202, 62, 47, 51, 54, 201 ]; }, { "name": "initializeEscrowEvt"; "discriminator": [ 50, 157, 215, 42, 247, 238, 231, 43 ]; }, { "name": "initializeStakingEvt"; "discriminator": [ 133, 42, 50, 158, 52, 137, 101, 142 ]; }, { "name": "stakeEvt"; "discriminator": [ 53, 123, 172, 217, 133, 170, 68, 67 ]; }, { "name": "transferOwnerEvt"; "discriminator": [ 197, 207, 122, 118, 106, 171, 112, 89 ]; }, { "name": "unstakeEvt"; "discriminator": [ 168, 60, 214, 132, 109, 88, 1, 165 ]; }, { "name": "updateConfigEvt"; "discriminator": [ 39, 182, 200, 158, 81, 7, 69, 254 ]; }, { "name": "updatePenaltyFeeReceiverEvt"; "discriminator": [ 37, 29, 255, 198, 43, 220, 10, 94 ]; }, { "name": "withdrawEvt"; "discriminator": [ 6, 132, 68, 72, 106, 106, 131, 225 ]; } ]; "errors": [ { "code": 6000; "name": "invalidInputParams"; "msg": "Invalid input parameters"; }, { "code": 6001; "name": "mathOverflow"; "msg": "Math overflow"; }, { "code": 6002; "name": "unsupportedTokenMint"; "msg": "Unsupported token mint"; }, { "code": 6003; "name": "belowMinimumStakeAmount"; "msg": "Below minimum stake amount"; }, { "code": 6004; "name": "unstakeNotReady"; "msg": "Unstake not ready for withdrawal"; }, { "code": 6005; "name": "cannotCloseNonEmptyEscrow"; "msg": "Cannot close non-empty escrow"; }, { "code": 6006; "name": "unauthorized"; "msg": "unauthorized"; }, { "code": 6007; "name": "invalidFeeReceiver"; "msg": "Invalid fee receiver"; }, { "code": 6008; "name": "nothingToUnstake"; "msg": "Nothing to unstake"; }, { "code": 6009; "name": "unstakeDisabled"; "msg": "Unstake is disabled. Use immediate unstake instead."; }, { "code": 6010; "name": "slippageExceeded"; "msg": "Slippage exceeded"; }, { "code": 6011; "name": "invalidNewOwner"; "msg": "Invalid new owner"; }, { "code": 6012; "name": "invalidOwner"; "msg": "Invalid owner"; }, { "code": 6013; "name": "invalidTokenAccount"; "msg": "Invalid token account"; } ]; "types": [ { "name": "cancelUnstakeEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "unstake"; "docs": [ "The unstake account created for this unstake" ]; "type": "pubkey"; }, { "name": "rentReceiver"; "docs": [ "The account that receives the lamports from closing the unstake account" ]; "type": "pubkey"; }, { "name": "escrowAmountLatest"; "docs": [ "Latest escrow amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "stakingAmountLatest"; "docs": [ "Latest staking amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "cancelledAmount"; "docs": [ "The amount successfully cancelled from the unstake account" ]; "type": "u64"; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; } ]; }; }, { "name": "claimPenaltyFeeEvt"; "type": { "kind": "struct"; "fields": [ { "name": "staking"; "docs": [ "The staking account" ]; "type": "pubkey"; }, { "name": "feeReceiver"; "docs": [ "The token account that receives the claimed penalty fee" ]; "type": "pubkey"; }, { "name": "claimedFeeAmount"; "docs": [ "The amount of penalty fee claimed" ]; "type": "u64"; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; }, { "name": "stakingPenaltyFeeLatest"; "docs": [ "Latest staking penalty fee after the claim" ]; "type": "u64"; } ]; }; }, { "name": "claimPenaltyFeeParams"; "type": { "kind": "struct"; "fields": [ { "name": "maxAmount"; "docs": [ "The maximum amount of penalty fee to claim. Pass in u64::MAX to claim all available penalty fee." ]; "type": "u64"; }, { "name": "padding0"; "docs": [ "Padding for future use." ]; "type": { "array": [ "u64", 8 ]; }; } ]; }; }, { "name": "closeEscrowEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "rentReceiver"; "docs": [ "The account that receives the lamports from closing the escrow account" ]; "type": "pubkey"; }, { "name": "totalEscrow"; "docs": [ "Total number of escrow accounts after closing this escrow" ]; "type": "u64"; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; } ]; }; }, { "name": "configFields"; "type": { "kind": "enum"; "variants": [ { "name": "unstakeCooldownSeconds"; "fields": [ "u64" ]; }, { "name": "minStakingAmount"; "fields": [ "u64" ]; }, { "name": "immediateUnstakePenaltyFeeRateBps"; "fields": [ "u16" ]; } ]; }; }, { "name": "escrow"; "serialization": "bytemuck"; "repr": { "kind": "c"; }; "type": { "kind": "struct"; "fields": [ { "name": "staking"; "docs": [ "Staking account this escrow belongs to" ]; "type": "pubkey"; }, { "name": "owner"; "docs": [ "Owner of the escrow" ]; "type": "pubkey"; }, { "name": "stakedAmount"; "docs": [ "Amount of tokens staked in this escrow" ]; "type": "u64"; }, { "name": "partialUnstakedAmount"; "docs": [ "Amount of tokens that have been unstaked but not yet withdrawn" ]; "type": "u64"; }, { "name": "padding0"; "docs": [ "Padding reserved for future use" ]; "type": { "array": [ "u64", 24 ]; }; } ]; }; }, { "name": "immediateUnstakeEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "escrowAmountLatest"; "docs": [ "Latest escrow amount after the immediate unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "stakingAmountLatest"; "docs": [ "Latest staking amount after the immediate unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "penaltyFeeBps"; "docs": [ "Penalty fee bps" ]; "type": "u16"; }, { "name": "penaltyFeeAmount"; "docs": [ "Penalty fee amount for the immediate unstake" ]; "type": "u64"; }, { "name": "stakingPenaltyFeeLatest"; "docs": [ "Latest staking penalty fee after the immediate unstake" ]; "type": "u64"; }, { "name": "penaltyFeeExcludedUnstakeAmount"; "docs": [ "Unstake amount user received" ]; "type": "u64"; }, { "name": "receiver"; "docs": [ "The token account that receives the unstake token" ]; "type": "pubkey"; }, { "name": "params"; "docs": [ "Immediate unstake params" ]; "type": { "defined": { "name": "immediateUnstakeParams"; }; }; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; }, { "name": "actualUnstakeAmount"; "docs": [ "The actual total amount unstaked from escrow before penalty split" ]; "type": "u64"; } ]; }; }, { "name": "immediateUnstakeParams"; "type": { "kind": "struct"; "fields": [ { "name": "maxAmount"; "docs": [ "The maximum amount of tokens to unstake. User can pass in u64::MAX to unstake the full amount." ]; "type": "u64"; }, { "name": "maxImmediateUnstakePenaltyBps"; "docs": [ "Slippage protection against penalty fee bps changes. Eg: Update penalty fee bps sandwich." ]; "type": "u16"; }, { "name": "padding0"; "type": { "array": [ "u64", 5 ]; }; } ]; }; }, { "name": "initializeEscrowEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "payer"; "docs": [ "The payer who pays for the account rental" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "The escrow account" ]; "type": "pubkey"; }, { "name": "totalEscrow"; "docs": [ "Total number of escrow accounts" ]; "type": "u64"; } ]; }; }, { "name": "initializeStakingEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the staking" ]; "type": "pubkey"; }, { "name": "tokenMint"; "docs": [ "The mint of the staking token" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account" ]; "type": "pubkey"; }, { "name": "payer"; "docs": [ "The payer who pays for the account rental" ]; "type": "pubkey"; }, { "name": "tokenProgram"; "docs": [ "Token program used for staking" ]; "type": "pubkey"; }, { "name": "params"; "docs": [ "Parameters for initializing the staking" ]; "type": { "defined": { "name": "initializeStakingParams"; }; }; } ]; }; }, { "name": "initializeStakingParams"; "type": { "kind": "struct"; "fields": [ { "name": "unstakeCooldownSeconds"; "docs": [ "The amount of seconds that a user has to wait after unstaking before they can withdraw their tokens" ]; "type": "u64"; }, { "name": "minStakingAmount"; "docs": [ "The minimum amount of tokens that a user has to stake" ]; "type": "u64"; }, { "name": "immediateUnstakePenaltyBps"; "docs": [ "The penalty in basis points (bps) for immediately withdraw upon unstaking" ]; "type": "u16"; }, { "name": "padding"; "type": { "array": [ "u64", 10 ]; }; } ]; }; }, { "name": "stakeEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "payer"; "docs": [ "Payer who pay for stake amount" ]; "type": "pubkey"; }, { "name": "escrowAmountLatest"; "docs": [ "Latest escrow amount after the stake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "stakingAmountLatest"; "docs": [ "Latest staking amount after the stake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "params"; "docs": [ "Stake params" ]; "type": { "defined": { "name": "stakeParams"; }; }; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; } ]; }; }, { "name": "stakeParams"; "type": { "kind": "struct"; "fields": [ { "name": "amount"; "docs": [ "The amount of tokens to stake" ]; "type": "u64"; }, { "name": "padding"; "type": { "array": [ "u64", 5 ]; }; } ]; }; }, { "name": "staking"; "serialization": "bytemuck"; "repr": { "kind": "c"; }; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the staking" ]; "type": "pubkey"; }, { "name": "tokenVault"; "docs": [ "The token vault that holds the staked tokens" ]; "type": "pubkey"; }, { "name": "tokenMint"; "docs": [ "The mint of the staked tokens" ]; "type": "pubkey"; }, { "name": "stakedAmount"; "docs": [ "The amount of tokens that the user has staked" ]; "type": "u64"; }, { "name": "partialUnstakedAmount"; "docs": [ "The amount of tokens that the user has unstaked but not yet withdrawn" ]; "type": "u64"; }, { "name": "penaltyFeeAmount"; "docs": [ "The penalty fee amount for immediate unstaking that has been accumulated but not yet claimed" ]; "type": "u64"; }, { "name": "config"; "docs": [ "Staking configuration" ]; "type": { "defined": { "name": "stakingConfig"; }; }; }, { "name": "metrics"; "docs": [ "Staking metrics" ]; "type": { "defined": { "name": "stakingMetrics"; }; }; }, { "name": "padding0"; "type": { "array": [ "u64", 24 ]; }; }, { "name": "padding1"; "type": { "array": [ "u64", 24 ]; }; } ]; }; }, { "name": "stakingAmountLatest"; "type": { "kind": "struct"; "fields": [ { "name": "stakedAmount"; "docs": [ "New staked amount after the change" ]; "type": "u64"; }, { "name": "partialUnstakedAmount"; "docs": [ "New partial unstaked amount after the change" ]; "type": "u64"; } ]; }; }, { "name": "stakingConfig"; "serialization": "bytemuck"; "repr": { "kind": "c"; }; "type": { "kind": "struct"; "fields": [ { "name": "unstakeCooldownSeconds"; "docs": [ "The amount of seconds that a user has to wait after unstaking before they can withdraw their tokens" ]; "type": "u64"; }, { "name": "minStakingAmount"; "docs": [ "The minimum amount of tokens that a user has to stake" ]; "type": "u64"; }, { "name": "immediateUnstakePenaltyBps"; "docs": [ "The penalty in basis points (bps) for immediately withdraw upon unstaking" ]; "type": "u16"; }, { "name": "padding0"; "type": { "array": [ "u8", 6 ]; }; }, { "name": "feeReceiver"; "docs": [ "The account that receives the staking penalty fees" ]; "type": "pubkey"; }, { "name": "padding1"; "type": { "array": [ "u64", 24 ]; }; } ]; }; }, { "name": "stakingConfigEvt"; "docs": [ "Borsh-serializable mirror of `StakingConfig` for use in events.", "`#[zero_copy]` on `StakingConfig` provides bytemuck-based AnchorSerialize/Deserialize,", "which is incompatible with the borsh-based `#[event]` macro." ]; "type": { "kind": "struct"; "fields": [ { "name": "unstakeCooldownSeconds"; "type": "u64"; }, { "name": "minStakingAmount"; "type": "u64"; }, { "name": "immediateUnstakePenaltyBps"; "type": "u16"; }, { "name": "padding0"; "type": { "array": [ "u8", 6 ]; }; }, { "name": "feeReceiver"; "type": "pubkey"; }, { "name": "padding1"; "type": { "array": [ "u64", 24 ]; }; } ]; }; }, { "name": "stakingMetrics"; "serialization": "bytemuck"; "repr": { "kind": "c"; }; "type": { "kind": "struct"; "fields": [ { "name": "totalEscrowCount"; "docs": [ "The total number of escrows belongs to this staking account" ]; "type": "u64"; }, { "name": "padding0"; "docs": [ "Padding for future metrics" ]; "type": { "array": [ "u64", 12 ]; }; } ]; }; }, { "name": "transferOwnerEvt"; "type": { "kind": "struct"; "fields": [ { "name": "oldOwner"; "docs": [ "The old owner of the staking account" ]; "type": "pubkey"; }, { "name": "newOwner"; "docs": [ "The new owner of the staking account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account" ]; "type": "pubkey"; } ]; }; }, { "name": "unstake"; "serialization": "bytemuck"; "repr": { "kind": "c"; }; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the partial unstake" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "The escrow account associated with the partial unstake" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the partial unstake" ]; "type": "pubkey"; }, { "name": "amount"; "docs": [ "The amount of tokens that the user has partially unstaked but not yet withdrawn" ]; "type": "u64"; }, { "name": "withdrawableTimestamp"; "docs": [ "The timestamp when the user can withdraw their unstaked tokens" ]; "type": "u64"; }, { "name": "padding0"; "docs": [ "Padding for future use" ]; "type": { "array": [ "u64", 12 ]; }; } ]; }; }, { "name": "unstakeEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "unstake"; "docs": [ "The unstake account created for this unstake" ]; "type": "pubkey"; }, { "name": "payer"; "docs": [ "The payer who pays for the unstake account rental" ]; "type": "pubkey"; }, { "name": "actualUnstakeAmount"; "docs": [ "The actual unstake amount processed" ]; "type": "u64"; }, { "name": "escrowAmountLatest"; "docs": [ "Latest escrow amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "stakingAmountLatest"; "docs": [ "Latest staking amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "params"; "docs": [ "Unstake params" ]; "type": { "defined": { "name": "unstakeParams"; }; }; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; }, { "name": "withdrawableTimestamp"; "docs": [ "The timestamp when the user can withdraw the unstaked tokens" ]; "type": "u64"; } ]; }; }, { "name": "unstakeParams"; "type": { "kind": "struct"; "fields": [ { "name": "maxAmount"; "docs": [ "The maximum amount of tokens to unstake. User can pass in u64::MAX to unstake the full amount." ]; "type": "u64"; }, { "name": "padding0"; "type": { "array": [ "u64", 5 ]; }; } ]; }; }, { "name": "updateConfigEvt"; "type": { "kind": "struct"; "fields": [ { "name": "staking"; "docs": [ "The staking account associated with the config update" ]; "type": "pubkey"; }, { "name": "owner"; "docs": [ "The owner who updates the config" ]; "type": "pubkey"; }, { "name": "oldConfig"; "docs": [ "The old config before the update" ]; "type": { "defined": { "name": "stakingConfigEvt"; }; }; }, { "name": "newConfig"; "docs": [ "The new config after the update" ]; "type": { "defined": { "name": "stakingConfigEvt"; }; }; } ]; }; }, { "name": "updateConfigParams"; "type": { "kind": "struct"; "fields": [ { "name": "fieldsToUpdate"; "type": { "vec": { "defined": { "name": "configFields"; }; }; }; }, { "name": "padding0"; "type": { "array": [ "u64", 8 ]; }; } ]; }; }, { "name": "updatePenaltyFeeReceiverEvt"; "type": { "kind": "struct"; "fields": [ { "name": "staking"; "docs": [ "The staking account associated with the operator" ]; "type": "pubkey"; }, { "name": "oldFeeReceiver"; "docs": [ "The old fee receiver" ]; "type": "pubkey"; }, { "name": "newFeeReceiver"; "docs": [ "The new fee receiver" ]; "type": "pubkey"; } ]; }; }, { "name": "withdrawEvt"; "type": { "kind": "struct"; "fields": [ { "name": "owner"; "docs": [ "The owner of the escrow" ]; "type": "pubkey"; }, { "name": "escrow"; "docs": [ "Escrow account" ]; "type": "pubkey"; }, { "name": "staking"; "docs": [ "The staking account associated with the escrow" ]; "type": "pubkey"; }, { "name": "unstake"; "docs": [ "The unstake account created for this unstake" ]; "type": "pubkey"; }, { "name": "unstakeAmount"; "docs": [ "The unstake amount" ]; "type": "u64"; }, { "name": "rentReceiver"; "docs": [ "The account that receives the lamports from closing the unstake account" ]; "type": "pubkey"; }, { "name": "receiver"; "docs": [ "The token account that receives the unstake token" ]; "type": "pubkey"; }, { "name": "escrowAmountLatest"; "docs": [ "Latest escrow amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "stakingAmountLatest"; "docs": [ "Latest staking amount after the unstake" ]; "type": { "defined": { "name": "stakingAmountLatest"; }; }; }, { "name": "tokenMint"; "docs": [ "The staking account token mint" ]; "type": "pubkey"; } ]; }; } ]; "constants": [ { "name": "maximumUnstakeCooldownSeconds"; "type": "u64"; "value": "31536000"; }, { "name": "minimumUnstakeCooldownSeconds"; "type": "u64"; "value": "86400"; } ]; }; type ReferralProgram = Program; type StakingAccount = IdlAccounts["staking"]; type EscrowAccount = IdlAccounts["escrow"]; type UnstakeAccount = IdlAccounts["unstake"]; type StakingConfig = IdlTypes["stakingConfig"]; type StakingMetrics = IdlTypes["stakingMetrics"]; type ConfigFields = IdlTypes["configFields"]; declare const U64_MAX: BN; interface IStakingWrapper { getStakingAccount(): StakingAccount; getOwner(): PublicKey; getTokenMint(): PublicKey; getTokenVault(): PublicKey; getStakedAmount(): BN; getUiStakedAmount(): number; getPartialUnstakedAmount(): BN; getUiPartialUnstakedAmount(): number; getPenaltyFeeAmount(): BN; getUiPenaltyFeeAmount(): number; getTotalLockedAmount(): BN; getUiTotalLockedAmount(): number; getUnstakeCooldownSeconds(): number; getMinStakingAmount(): BN; getUiMinStakingAmount(): number; getImmediateUnstakePenaltyBps(): number; getImmediateUnstakePenaltyPercentage(): number; getFeeReceiver(): PublicKey; getTotalEscrowCount(): number; isUnstakeEnabled(): boolean; quoteImmediateUnstake(amount: BN): { userReceiveAmount: BN; penaltyFeeAmount: BN; }; } declare class StakingWrapper implements IStakingWrapper { stakingAccount: StakingAccount; tokenDecimals: number; private multiplier; constructor(stakingAccount: StakingAccount, tokenDecimals: number); getStakingAccount(): StakingAccount; getOwner(): PublicKey; getTokenMint(): PublicKey; getTokenVault(): PublicKey; getStakedAmount(): BN; getUiStakedAmount(): number; getPartialUnstakedAmount(): BN; getUiPartialUnstakedAmount(): number; getPenaltyFeeAmount(): BN; getUiPenaltyFeeAmount(): number; getTotalLockedAmount(): BN; getUiTotalLockedAmount(): number; getUnstakeCooldownSeconds(): number; getMinStakingAmount(): BN; getUiMinStakingAmount(): number; getImmediateUnstakePenaltyBps(): number; getImmediateUnstakePenaltyPercentage(): number; getFeeReceiver(): PublicKey; getTotalEscrowCount(): number; isUnstakeEnabled(): boolean; quoteImmediateUnstake(amount: BN): { userReceiveAmount: BN; penaltyFeeAmount: BN; }; } interface IEscrowWrapper { getEscrowAccount(): EscrowAccount; getStakingAddress(): PublicKey; getOwner(): PublicKey; getStakedAmount(): BN; getUiStakedAmount(): number; getPartialUnstakedAmount(): BN; getUiPartialUnstakedAmount(): number; isEmpty(): boolean; canClose(): boolean; } declare class EscrowWrapper implements IEscrowWrapper { escrowAccount: EscrowAccount; tokenDecimals: number; private multiplier; constructor(escrowAccount: EscrowAccount, tokenDecimals: number); getEscrowAccount(): EscrowAccount; getStakingAddress(): PublicKey; getOwner(): PublicKey; getStakedAmount(): BN; getUiStakedAmount(): number; getPartialUnstakedAmount(): BN; getUiPartialUnstakedAmount(): number; isEmpty(): boolean; canClose(): boolean; } interface IUnstakeWrapper { getUnstakeAccount(): UnstakeAccount; getOwner(): PublicKey; getEscrowAddress(): PublicKey; getStakingAddress(): PublicKey; getAmount(): BN; getUiAmount(): number; getWithdrawableTimestamp(): number; canWithdraw(currentTimestamp: number): boolean; getTimeUntilWithdrawable(currentTimestamp: number): number; } declare class UnstakeWrapper implements IUnstakeWrapper { unstakeAccount: UnstakeAccount; tokenDecimals: number; private multiplier; constructor(unstakeAccount: UnstakeAccount, tokenDecimals: number); getUnstakeAccount(): UnstakeAccount; getOwner(): PublicKey; getEscrowAddress(): PublicKey; getStakingAddress(): PublicKey; getAmount(): BN; getUiAmount(): number; getWithdrawableTimestamp(): number; canWithdraw(currentTimestamp: number): boolean; getTimeUntilWithdrawable(currentTimestamp: number): number; } interface IInitializeStakingParams { referralProgram: ReferralProgram; owner: PublicKey; tokenMint: PublicKey; stakingPenaltyFeeReceiver: PublicKey; staking: Keypair; payer: PublicKey; unstakeCooldownSeconds: BN; minStakingAmount: BN; immediateUnstakePenaltyBps: number; } declare function createInitializeStakingIx(params: IInitializeStakingParams): Promise; interface IInitializeEscrowParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; owner: PublicKey; payer: PublicKey; } declare function createInitializeEscrowIx(params: IInitializeEscrowParams): Promise; interface IStakeParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; stakingAccount: StakingAccount; escrowAddress: PublicKey; owner: PublicKey; amount: BN; } declare function createStakeIx(params: IStakeParams): Promise; interface IImmediateUnstakeParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; stakingAccount: StakingAccount; escrowAddress: PublicKey; owner: PublicKey; maxAmount: BN; maxImmediateUnstakePenaltyBps: number; receiver: PublicKey; } declare function createImmediateUnstakeIx(params: IImmediateUnstakeParams): Promise; interface IUnstakeParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; escrowAddress: PublicKey; owner: PublicKey; payer: PublicKey; maxAmount: BN; unstakeKeypair?: Keypair; } declare function createUnstakeIx(params: IUnstakeParams): Promise<{ instruction: TransactionInstruction; unstakeKeypair: Keypair; }>; interface ICancelUnstakeParams { referralProgram: ReferralProgram; unstakeAddress: PublicKey; escrowAddress: PublicKey; stakingAddress: PublicKey; owner: PublicKey; rentReceiver: PublicKey; } declare function createCancelUnstakeIx(params: ICancelUnstakeParams): Promise; interface IWithdrawParams { referralProgram: ReferralProgram; unstakeAddress: PublicKey; escrowAddress: PublicKey; stakingAddress: PublicKey; stakingAccount: StakingAccount; owner: PublicKey; rentReceiver: PublicKey; receiver: PublicKey; } declare function createWithdrawIx(params: IWithdrawParams): Promise; interface ICloseEscrowParams { referralProgram: ReferralProgram; escrowAddress: PublicKey; stakingAddress: PublicKey; owner: PublicKey; rentReceiver: PublicKey; skipCloseIfNonEmpty: boolean; } declare function createCloseEscrowIx(params: ICloseEscrowParams): Promise; interface IClaimPenaltyFeeParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; stakingAccount: StakingAccount; maxAmount: BN; } declare function createClaimPenaltyFeeIx(params: IClaimPenaltyFeeParams): Promise; interface IUpdatePenaltyFeeReceiverParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; owner: PublicKey; newFeeReceiver: PublicKey; } declare function createUpdatePenaltyFeeReceiverIx(params: IUpdatePenaltyFeeReceiverParams): Promise; interface ITransferOwnerParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; owner: PublicKey; newOwner: PublicKey; } declare function createTransferOwnerIx(params: ITransferOwnerParams): Promise; interface IUpdateConfigParams { referralProgram: ReferralProgram; stakingAddress: PublicKey; owner: PublicKey; fieldsToUpdate: ConfigFields[]; } declare function createUpdateConfigIx(params: IUpdateConfigParams): Promise; declare class Referral { program: ReferralProgram; stakingAddress: PublicKey; stakingAccount: StakingAccount; tokenDecimals: number; shouldOptimizeComputeUnit: boolean; constructor(program: ReferralProgram, stakingAddress: PublicKey, stakingAccount: StakingAccount, tokenDecimals: number, shouldOptimizeComputeUnit: boolean); static create(connection: Connection, stakingAddress: PublicKey, programId?: PublicKey): Promise; /** Permissionless: Anyone can initialize a new staking pool. Signers: staking, payer. */ static initializeStaking(connection: Connection, params: Omit, programId?: PublicKey, shouldOptimizeComputeUnit?: boolean): Promise; private get connection(); setComputeUnitOptimization(enable: boolean): void; refetchState(): Promise; getStakingWrapper(): StakingWrapper; /** Permissionless: Anyone can initialize an escrow for any owner. Signer: payer. */ initializeEscrow(params: { owner: PublicKey; payer: PublicKey; }): Promise; /** Escrow-owner-gated: Only the escrow owner can stake into their escrow. Signer: owner. */ stake(params: { escrowAddress: PublicKey; owner: PublicKey; amount: BN; }): Promise; /** Permissioned: Only the escrow owner can immediate unstake. Signer: owner. */ immediateUnstake(params: { escrowAddress: PublicKey; owner: PublicKey; maxAmount: BN; maxImmediateUnstakePenaltyBps: number; receiver: PublicKey; }): Promise; /** Permissioned: Only the escrow owner can unstake. Signers: owner, payer, unstakeKeypair. */ unstake(params: { escrowAddress: PublicKey; owner: PublicKey; payer: PublicKey; maxAmount: BN; unstakeKeypair?: Keypair; }): Promise<{ transaction: Transaction; unstakeKeypair: Keypair; }>; /** Permissioned: Only the unstake owner can cancel an unstake. Signer: owner. */ cancelUnstake(params: { unstakeAddress: PublicKey; escrowAddress: PublicKey; owner: PublicKey; rentReceiver: PublicKey; }): Promise; /** Permissioned: Only the unstake owner can withdraw after cooldown. Signer: owner. */ withdraw(params: { unstakeAddress: PublicKey; escrowAddress: PublicKey; owner: PublicKey; rentReceiver: PublicKey; receiver: PublicKey; }): Promise; /** Permissioned: Only the escrow owner can close the escrow. Signer: owner. */ closeEscrow(params: { escrowAddress: PublicKey; owner: PublicKey; rentReceiver: PublicKey; skipCloseIfNonEmpty: boolean; }): Promise; /** Permissionless: Anyone can trigger penalty fee claim. Tokens are sent to the configured fee receiver. */ claimPenaltyFee(params: { maxAmount: BN; }): Promise; /** Permissioned: Only the staking owner can update the penalty fee receiver. Signer: owner. */ updatePenaltyFeeReceiver(params: { owner: PublicKey; newFeeReceiver: PublicKey; }): Promise; /** Permissioned: Only the staking owner can transfer ownership. Signer: owner. */ transferOwner(params: { owner: PublicKey; newOwner: PublicKey; }): Promise; /** Permissioned: Only the staking owner can update config. Signer: owner. */ updateConfig(params: { owner: PublicKey; fieldsToUpdate: ConfigFields[]; }): Promise; fetchEscrow(owner: PublicKey): Promise; fetchAllEscrows(): Promise<{ pubkey: PublicKey; account: EscrowWrapper; }[]>; fetchUnstakesByOwner(owner: PublicKey): Promise<{ pubkey: PublicKey; account: UnstakeWrapper; }[]>; fetchUnstakesByOwnerAndEscrow(owner: PublicKey, escrow: PublicKey): Promise<{ pubkey: PublicKey; account: UnstakeWrapper; }[]>; } declare const MAXIMUM_UNSTAKE_COOLDOWN_SECONDS: BN; declare const MINIMUM_UNSTAKE_COOLDOWN_SECONDS: BN; declare const MAX_FEE_BASIS_POINTS = 10000; declare const MAX_BPS: BN; declare const ESCROW_DISCRIMINATOR: Buffer; declare const STAKING_DISCRIMINATOR: Buffer; declare const UNSTAKE_DISCRIMINATOR: Buffer; declare function calculateFeeExcludedAmount(amount: BN, feeBps: number): { feeExcludedAmount: BN; feeAmount: BN; }; declare function getOnChainTimestamp(connection: Connection): Promise; declare function fetchMultipleAccountsAutoChunk(connection: Connection, addresses: PublicKey[]): Promise<{ pubkey: PublicKey; account: _solana_web3_js.AccountInfo> | null; }[]>; declare const getSimulationComputeUnits: (connection: Connection, instructions: Array, payer: PublicKey, lookupTables: Array | [], commitment?: Commitment) => Promise; declare function getStakingFilter(): MemcmpFilter; declare function getEscrowFilter(): MemcmpFilter; declare function getUnstakeFilter(): MemcmpFilter; declare function getEscrowStakingFilter(staking: PublicKey): MemcmpFilter; declare function getEscrowOwnerFilter(owner: PublicKey): MemcmpFilter; declare function getUnstakeOwnerFilter(owner: PublicKey): MemcmpFilter; declare function getUnstakeEscrowFilter(escrow: PublicKey): MemcmpFilter; declare function getUnstakeStakingFilter(staking: PublicKey): MemcmpFilter; declare const REFERRAL_PROGRAM_ID: PublicKey; export { type ConfigFields, ESCROW_DISCRIMINATOR, type EscrowAccount, EscrowWrapper, type ICancelUnstakeParams, type IClaimPenaltyFeeParams, type ICloseEscrowParams, type IEscrowWrapper, type IImmediateUnstakeParams, type IInitializeEscrowParams, type IInitializeStakingParams, type IStakeParams, type IStakingWrapper, type ITransferOwnerParams, type IUnstakeParams, type IUnstakeWrapper, type IUpdateConfigParams, type IUpdatePenaltyFeeReceiverParams, type IWithdrawParams, MAXIMUM_UNSTAKE_COOLDOWN_SECONDS, MAX_BPS, MAX_FEE_BASIS_POINTS, MINIMUM_UNSTAKE_COOLDOWN_SECONDS, REFERRAL_PROGRAM_ID, Referral, type ReferralProgram, STAKING_DISCRIMINATOR, type StakingAccount, type StakingConfig, type StakingMetrics, StakingWrapper, U64_MAX, UNSTAKE_DISCRIMINATOR, type UnstakeAccount, UnstakeWrapper, calculateFeeExcludedAmount, createCancelUnstakeIx, createClaimPenaltyFeeIx, createCloseEscrowIx, createImmediateUnstakeIx, createInitializeEscrowIx, createInitializeStakingIx, createStakeIx, createTransferOwnerIx, createUnstakeIx, createUpdateConfigIx, createUpdatePenaltyFeeReceiverIx, createWithdrawIx, deriveEscrow, deriveEventAuthority, deriveStakingAuthority, deriveTokenVault, fetchMultipleAccountsAutoChunk, getEscrowFilter, getEscrowOwnerFilter, getEscrowStakingFilter, getOnChainTimestamp, getSimulationComputeUnits, getStakingFilter, getUnstakeEscrowFilter, getUnstakeFilter, getUnstakeOwnerFilter, getUnstakeStakingFilter };