Options
All
  • Public
  • Public/Protected
  • All
Menu

@unstake-it/sol-ag

Index

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

AddressMap<Accounts>: { [ k in Cluster]: Accounts }

Type Parameters

  • Accounts extends {}

ComputeRoutesXSolParams: Omit<Parameters<Jupiter["computeRoutes"]>[0], "outputMint" | "feeBps"> & { asLegacyTransaction?: boolean; currentEpoch?: number; jupFeeBps?: number; shouldIgnoreRouteErrors?: boolean; stakePoolsToExclude?: StakePoolsToExclude }
FeeAccounts: { [ token in string]?: PublicKey }

Map of token mint to token accounts to receive referral fees If token is So11111111111111111111111111111111111111112, the value should be a wrapped SOL token account, not a system account. SyncNative is not guaranteed to be called after transferring SOL referral fees

KnownSplStakePoolProgramIdStr: typeof KNOWN_SPL_STAKE_POOL_PROGRAM_IDS_STR[number]
LidoAccounts: { program: PublicKey; solido: PublicKey; stakePoolToken: PublicKey; validatorList: PublicKey }

Type declaration

  • program: PublicKey
  • solido: PublicKey
  • stakePoolToken: PublicKey
  • validatorList: PublicKey
LoadParams: JupiterLoadParams & { shouldIgnoreLoadErrors?: boolean }
MarinadeAccounts: { program: PublicKey; stakePoolToken: PublicKey; state: PublicKey; validatorRecords: PublicKey }

Type declaration

  • program: PublicKey
  • stakePoolToken: PublicKey
  • state: PublicKey
  • validatorRecords: PublicKey

    Similar to SPL stake pool, this can be read from state but we are updating accounts in one-shot so we need to know this beforehand

SplStakePoolAccounts: { program: PublicKey; stakePool: PublicKey; stakePoolToken: PublicKey; validatorList: PublicKey }

Type declaration

  • program: PublicKey
  • stakePool: PublicKey
  • stakePoolToken: PublicKey
  • validatorList: PublicKey

    This can be read from the stake pool struct but we are updating accounts in one-shot so we need to know this beforehand

StakePoolLabel: "unstake.it" | "Marinade" | "Socean" | "Eversol" | "JPool" | "SolBlaze" | "DAOPool" | "Jito" | "Laine" | "Cogent" | "Risk.lol" | "mrgn"
StakePoolsToExclude: { [ label in StakePoolLabel]?: boolean }

Exclude certain StakePools from the route search

e.g. { "Marinade": true, "Socean": true }

StakeQuote: Quote & { additionalRentLamports: bigint }
TransactionWithSigners: { signers: Signer[]; tx: Transaction }

Type declaration

  • signers: Signer[]
  • tx: Transaction
UnstakeItAccounts: { pool: PublicKey; program: PublicKey }

Type declaration

  • pool: PublicKey
  • program: PublicKey
UnstakeXSolRouteJupDirect: { jup: RouteInfo }

Type declaration

  • jup: RouteInfo
UnstakeXSolRouteWithdrawStake: { intermediateDummyStakeAccountInfo: AccountInfo<StakeAccount>; unstake: UnstakeRoute; withdrawStake: WithdrawStakeRoute }

Type declaration

  • intermediateDummyStakeAccountInfo: AccountInfo<StakeAccount>

    Should be result.outputDummyStakeAccountInfo of WithdrawStakeQuote

  • unstake: UnstakeRoute
  • withdrawStake: WithdrawStakeRoute
VersionedTransactionWithSigners: { signers: Signer[]; tx: VersionedTransaction }

Type declaration

  • signers: Signer[]
  • tx: VersionedTransaction
WithdrawStakePoolLabel: "Lido" | "Socean" | "Eversol" | "JPool" | "SolBlaze" | "DAOPool" | "Jito" | "Laine" | "Cogent" | "Risk.lol" | "mrgn"

Variables

COGENT_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

DAOPOOL_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

EVERSOL_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

EVERSOL_SPL_STAKE_POOL_PROGRAM_ID: PublicKey = ...
EVERSOL_SPL_STAKE_POOL_PROGRAM_ID_STR: "EverSFw9uN5t1V8kS3ficHUcKffSjwpGzUSGd7mgmSks" = "EverSFw9uN5t1V8kS3ficHUcKffSjwpGzUSGd7mgmSks"
JITO_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

JPOOL_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

KNOWN_SPL_STAKE_POOL_PROGRAM_IDS_STR: readonly ["SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy", "5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx", "EverSFw9uN5t1V8kS3ficHUcKffSjwpGzUSGd7mgmSks"] = ...
LAINE_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

LEGACY_TX_UNUSABLE_JUP_MARKETS_LABELS: Set<Amm["label"]> = ...

Markets that we can't use because they use too many accounts resulting in tx too large

TODO: add more as they come up

LIDO_ADDRESS_MAP: AddressMap<LidoAccounts> = ...
MARINADE_ADDRESS_MAP: AddressMap<MarinadeAccounts> = ...
MRGN_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

OFFICIAL_SPL_STAKE_POOL_PROGRAM_ID: PublicKey = ...
OFFICIAL_SPL_STAKE_POOL_PROGRAM_ID_STR: "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy" = "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy"
RISK_LOL_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

SOCEAN_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...
SOCEAN_SPL_STAKE_POOL_PROGRAM_ID: PublicKey = ...
SOCEAN_SPL_STAKE_POOL_PROGRAM_ID_STR: "5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx" = "5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx"
SOLBLAZE_ADDRESS_MAP: AddressMap<SplStakePoolAccounts> = ...

NOTE: DEVNET AND TESTNET DONT WORK

STAKE_STATE_LEN: 200 = 200
U64_MAX: BN = ...
UNSTAKE_IT_ADDRESS_MAP: AddressMap<UnstakeItAccounts> = ...
WITHDRAW_STAKE_QUOTE_FAILED: WithdrawStakeQuote = {}

Functions

  • addIxsToTxV0(versionedTx: VersionedTransaction, addressLookupTableAccounts: AddressLookupTableAccount[], prependIxs?: TransactionInstruction[], appendIxs?: TransactionInstruction[], filterTx?: boolean): VersionedTransaction
  • Parameters

    • versionedTx: VersionedTransaction
    • addressLookupTableAccounts: AddressLookupTableAccount[]
    • Optional prependIxs: TransactionInstruction[]
    • Optional appendIxs: TransactionInstruction[]
    • Optional filterTx: boolean

    Returns VersionedTransaction

  • calcStakeUnstakedAmount(lamportsToUnstake: bigint, stakeAccount: AccountInfo<{ info: { meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }; stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } } }; type: "initialized" | "uninitialized" | "delegated" | "rewardsPool" }>, currentEpoch: number): { stakeAmount: JSBI; unstakedAmount: JSBI }
  • Parameters

    • lamportsToUnstake: bigint
    • stakeAccount: AccountInfo<{ info: { meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }; stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } } }; type: "initialized" | "uninitialized" | "delegated" | "rewardsPool" }>
    • currentEpoch: number

    Returns { stakeAmount: JSBI; unstakedAmount: JSBI }

    • stakeAmount: JSBI
    • unstakedAmount: JSBI
  • chunkedGetMultipleAccountInfos(connection: Connection, pks: string[], batchChunkSize?: number, maxAccountsChunkSize?: number): Promise<(AccountInfo<Buffer> | null)[]>
  • Parameters

    • connection: Connection
    • pks: string[]
    • batchChunkSize: number = 1000
    • maxAccountsChunkSize: number = 100

    Returns Promise<(AccountInfo<Buffer> | null)[]>

  • chunks<T>(array: T[], size: number): T[][]
  • Type Parameters

    • T

    Parameters

    • array: T[]
    • size: number

    Returns T[][]

  • dedupPubkeys(arr: PublicKey[]): string[]
  • Deduplicate public keys TODO: PublicKey -> string -> PublicKey conversion is probably slow, see if theres a better way

    Parameters

    • arr: PublicKey[]

    Returns string[]

  • doTokenProgramAccsExist(connection: Connection, tokenAccs: PublicKey[]): Promise<boolean[]>
  • Checks if accounts owned by the token program exists. Does not differentiate between mint and tokenAccount accounts. Returns false if account exists but not owned by token program

    Parameters

    • connection: Connection
    • tokenAccs: PublicKey[]

    Returns Promise<boolean[]>

  • dummyAccountInfoForProgramOwner(programOwner: PublicKey): AccountInfo<Buffer>
  • Parameters

    • programOwner: PublicKey

    Returns AccountInfo<Buffer>

  • dummyStakeAccountInfo(__namedParameters: DummyStakeAccountParams): AccountInfo<StakeAccount>
  • Assumes no lockup. authorized is set to { staker: PublicKey.default, withdrawer: PublicKey.default } creditsObserved is set to 0 warmupCooldownRate is set to 0 stake is null if inactive activation/deactivation epoch is either 0, currentEpoch, or U64_MAX depending on state

    Alternative is a splitStakeAccount() function that copies everything but auths from an AccountInfo but that would mean having to fetch stake account data from onchain

    TODO: back to the drawing board if anything starts using creditsObserved or warmupCooldownRate TODO: activationEpoch set to 0 for active case means in cases where active stake acc is new, deposit to marinade will fail

    Parameters

    • __namedParameters: DummyStakeAccountParams

    Returns AccountInfo<StakeAccount>

  • genShortestUnusedSeed(connection: Connection, basePubkey: PublicKey, programId: PublicKey): Promise<PubkeyFromSeed>
  • Parameters

    • connection: Connection
    • basePubkey: PublicKey
    • programId: PublicKey

    Returns Promise<PubkeyFromSeed>

  • isLockupInForce(stakeAcc: { info: { meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }; stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } } }; type: "initialized" | "uninitialized" | "delegated" | "rewardsPool" }, currentEpoch: number): boolean
  • TODO: this should be exported from @soceanfi/solana-stake-sdk

    Parameters

    • stakeAcc: { info: { meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }; stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } } }; type: "initialized" | "uninitialized" | "delegated" | "rewardsPool" }
      • info: { meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }; stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } } }
        • meta: { authorized: { staker: PublicKey; withdrawer: PublicKey }; lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }; rentExemptReserve: BN }
          • authorized: { staker: PublicKey; withdrawer: PublicKey }
            • staker: PublicKey
            • withdrawer: PublicKey
          • lockup: { custodian: PublicKey; epoch: number; unixTimestamp: number }
            • custodian: PublicKey
            • epoch: number
            • unixTimestamp: number
          • rentExemptReserve: BN
        • stake: null | { creditsObserved: number; delegation: { activationEpoch: BN; deactivationEpoch: BN; stake: BN; voter: PublicKey; warmupCooldownRate: number } }
      • type: "initialized" | "uninitialized" | "delegated" | "rewardsPool"
    • currentEpoch: number

    Returns boolean

  • isNewStakeAccountKeypair(k: PubkeyFromSeed | Keypair): k is Keypair
  • Parameters

    • k: PubkeyFromSeed | Keypair

    Returns k is Keypair

  • legacyTxAmmsToExclude(): SingleLevelAmmValidator
  • Returns SingleLevelAmmValidator

  • makeTransactionV0(__namedParameters: TransactionMessageArgs & { luts?: AddressLookupTableAccount[] }): VersionedTransaction
  • Parameters

    • __namedParameters: TransactionMessageArgs & { luts?: AddressLookupTableAccount[] }

    Returns VersionedTransaction

  • Min amount of lamports to be received for a given route, after max allowed slippage

    Parameters

    Returns bigint

  • Min amount of lamports to be received for a given unstake xSOL route, after max allowed slippage

    Parameters

    Returns bigint

  • newStakeAccountPubkey(k: PubkeyFromSeed | Keypair): PublicKey
  • Parameters

    • k: PubkeyFromSeed | Keypair

    Returns PublicKey

  • Parameters

    Returns bigint

    expected amount of lamports to be received for the given unstake route, excluding slippage.

  • Parameters

    Returns bigint

  • prepareCleanupTx(exchangeReturn: ExchangeReturn, recentBlockhash: string, feePayer: PublicKey): Transaction | undefined
  • Parameters

    • exchangeReturn: ExchangeReturn
    • recentBlockhash: string
    • feePayer: PublicKey

    Returns Transaction | undefined

  • prepareSetupTx(exchangeReturn: ExchangeReturn, recentBlockhash: string, feePayer: PublicKey): Transaction | undefined
  • Parameters

    • exchangeReturn: ExchangeReturn
    • recentBlockhash: string
    • feePayer: PublicKey

    Returns Transaction | undefined

  • prepareUnstakeTx(exchangeReturn: ExchangeReturn, recentBlockhash: string, feePayer: PublicKey): Transaction
  • Parameters

    • exchangeReturn: ExchangeReturn
    • recentBlockhash: string
    • feePayer: PublicKey

    Returns Transaction

  • Parameters

    Returns string[]

  • Parameters

    Returns string[]

  • Parameters

    Returns bigint

  • Parameters

    Returns bigint

  • tryMerge2Txs(feePayer: PublicKey, firstTx: Transaction, secondTx: Transaction): Transaction | null
  • Additional signatures required are accounted for, i.e. actual tx size is tx.serialize().length and not tx.serialize().length + 64 * additional required signatures

    Parameters

    • feePayer: PublicKey
    • firstTx: Transaction
    • secondTx: Transaction

    Returns Transaction | null

    a new transaction with the 2 transaction's instructions merged if possible, null otherwise

Generated using TypeDoc