UpshiftDocs

SolanaAdapter

Solana adapter for the Upshift SDK — Anchor-based vault deposits, redemptions, and balance/state reads over a configurable RPC connection.

Generated from @augustdigital/sdk 9.3.0

This page is produced from the SDK's TSDoc on every release. To correct it, edit the TSDoc in the SDK repository — an edit here is overwritten by the next release.

Solana Adapter for August SDK

Example

To access the Solana adapter instance

const sdk = new AugustSDK()
sdk.solana.getVaultState()

Constructors

Constructor

new default(endpoint, network, commitment): default

Parameters

ParameterTypeDefault valueDescription
endpoint`https://${string}`undefined-
networkISolanaNetworkSolanaUtils.fallbackNetwork-
commitmentCommitment'finalized'Commitment for every read this adapter makes and for the confirmation of every write, so the two always describe the same chain state — the vault handlers take it from this same Connection. Defaults to 'finalized', which is what this adapter has always used in practice: it previously passed no commitment at all, so both reads and confirmations fell through to the RPC's own 'finalized' default. The default is stated explicitly now rather than inherited, but it is unchanged. Pass 'confirmed' for a markedly faster round trip — seconds rather than tens of seconds — accepting that the state you act on can still, in principle, be rolled back. Also settable as the commitment field of the solana config passed to AugustSDK.

Returns

default

Accessors

connection

Get Signature

get connection(): Connection

Returns

Connection

endpoint

Get Signature

get endpoint(): `https://${string}`

Returns

`https://${string}`

network

Get Signature

get network(): ISolanaNetwork

Returns

ISolanaNetwork

provider

Get Signature

get provider(): AnchorProvider

Returns

AnchorProvider

Methods

fetchUserShareBalance()

fetchUserShareBalance(publicKey, shareMint): Promise<number>

Parameters

ParameterType
publicKeystring | PublicKey
shareMintstring | PublicKey

Returns

Promise<number>

fetchUserShareBalanceRaw()

fetchUserShareBalanceRaw(publicKey, shareMint): Promise<{ amount: string; decimals: number; }>

BigInt-safe variant of fetchUserShareBalance. Returns the raw u64 amount (as a base-units string) plus the mint's decimals (or null when the scale can't be determined — see Returns), so the caller can produce a correct INormalizedNumber without losing precision.

Prefer this anywhere the result feeds BigInt math — positions, max- actions, redemption sizing, allowance checks. fetchUserShareBalance returns a JS-number uiAmount which silently encodes against 18 decimals when passed through toNormalizedBn(value) without an explicit decimals argument; that's exactly how the jitoSOL "missing position" regression manifested.

RPC cost: 1 getParsedTokenAccountsByOwner call. Worst case ~150ms on a healthy mainnet endpoint.

Parameters

ParameterTypeDescription
publicKeystring | PublicKeyWallet owner (PublicKey or base58 string).
shareMintstring | PublicKeyThe vault's share-token mint (PublicKey or base58).

Returns

Promise<{ amount: string; decimals: number; }>

{ amount, decimals }. Three observable shapes:

  • { amount: '<u64>', decimals: <number> } — token account exists.
  • { amount: '0', decimals: null } — no token account for this mint under this wallet, OR tokenAmount was missing from the response, OR publicKey/shareMint was not supplied. Distinguishable from a genuine zero-balance account (decimals would be set there).
  • { amount: '0', decimals: null } — RPC threw (error is logged).

decimals === null means "we could not determine the scale" — callers that need an INormalizedNumber must fall back to a known decimals value (typically the deposit mint's decimals from backend metadata) before normalizing. Never throws.

fetchUserTokenBalance()

fetchUserTokenBalance(publicKey, depositMint): Promise<string>

Parameters

ParameterType
publicKeystring | PublicKey
depositMintstring | PublicKey

Returns

Promise<string>

getProgram()

getProgram(programIdl?, programId?): Program<any>

Build an Anchor Program bound to this adapter's provider and network.

The program id is resolved as: explicit programId → the address carried by a custom programIdl → the canonical deployment for this adapter's network. A copy of the SDK's bundled vaultIdl defers to the network default (its embedded address is a build stamp, not network-aware), so forwarding it on devnet never silently targets the mainnet program.

Parameters

ParameterTypeDescription
programIdl?anyAnchor IDL to bind. Defaults to the SDK's bundled august_vault IDL. A custom IDL's address is honoured when it differs from the bundled build stamp.
programId?stringBase58 program id that overrides both the IDL's address and the network default. Use this to target a non-canonical deployment.

Returns

Program<any>

An Anchor Program for the resolved program id. No RPC is made — construction is offline.

Throws

AugustValidationError if no program id can be resolved because this adapter's network has no canonical deployment (e.g. testnet) and neither programId nor a custom IDL address was supplied.

Example

// canonical program on the adapter's network
const program = sdk.solana.getProgram();

// a different deployment, same interface
const legacy = sdk.solana.getProgram(vaultIdl, '7B8n9vL51b6ibqRAd1adZsi3x3kxtq5NZaondh22Vkyq');

getProgramId()

getProgramId(type): string

Canonical program id for a program type on this adapter's network.

Parameters

ParameterTypeDescription
type"vault"Program to look up. Only 'vault' (august_vault) exists today.

Returns

string

The base58 program id.

Throws

AugustValidationError if the canonical program is not deployed on this adapter's network (e.g. testnet). Previously an unmapped network threw a bare TypeError.

getToken()

getToken(mintAddress): Promise<{ address: string; decimals: number; image: string; name: string; symbol: string; }>

Parameters

ParameterType
mintAddressstring | PublicKey

Returns

Promise<{ address: string; decimals: number; image: string; name: string; symbol: string; }>

getTokenSymbol()

getTokenSymbol(mintAddress): Promise<string>

Parameters

ParameterType
mintAddressstring | PublicKey

Returns

Promise<string>

getVaultState()

getVaultState(vaultProgramId, idl, vaultAddress?): Promise<{ depositMintDecimals: number; vaultState: unknown; }>

Parameters

ParameterType
vaultProgramIdstring | PublicKey
idlany
vaultAddress?string | PublicKey

Returns

Promise<{ depositMintDecimals: number; vaultState: unknown; }>

getVaultStateReadOnly()

getVaultStateReadOnly(vaultProgramId, idl, vaultAddress?): Promise<{ depositMintDecimals: number; vaultState: ISolanaVaultState; }>

Parameters

ParameterType
vaultProgramIdstring | PublicKey
idlany
vaultAddress?string | PublicKey

Returns

Promise<{ depositMintDecimals: number; vaultState: ISolanaVaultState; }>

setWalletProvider()

setWalletProvider(_publicKey, signTransaction): void

Parameters

ParameterType
_publicKeystring | PublicKey
signTransaction<T>(transaction) => Promise<T>

Returns

void

vaultDeposit()

vaultDeposit(vaultProgramId, idl, publicKey, depositAmount, sendTransaction?, vaultAddress?, options?): Promise<any>

Deposit funds into a Solana August vault.

Parameters

ParameterTypeDescription
vaultProgramIdstring | PublicKey-
idlany-
publicKeystring | PublicKey-
depositAmountnumber | bigintbigint (raw on-chain units) or number (UI amount).
sendTransaction?(transaction, connection, options?) => Promise<string>Ignored; scheduled for removal in the next major release. Share-account creation is now prepended to the deposit instruction, so the SDK sends no second transaction and never invokes this callback — signing goes through the provider's wallet. Pass undefined here; do not delete the argument. It sits before vaultAddress, so removing it shifts your vault address into this slot and leaves vaultAddress undefined — which silently falls back to the legacy single-vault PDA derivation and targets a different vault.
vaultAddress?string | PublicKey-
options?ISolanaDepositOptionsSlippage protection. By default the SDK quotes the shares this deposit should mint from the vault's current state and passes that quote, lowered by 50 bps, as the floor to the program's checked instruction. See ISolanaDepositOptions.

Returns

Promise<any>

vaultRedeem()

vaultRedeem(vaultProgramId, idl, publicKey, redeemShares, sendTransaction?, vaultAddress?, options?): Promise<any>

Redeem vault shares from a Solana August vault.

Parameters

ParameterTypeDescription
vaultProgramIdstring | PublicKey-
idlany-
publicKeystring | PublicKey-
redeemSharesnumber | bigintbigint (raw share units) or number (UI amount).
sendTransaction?(transaction, connection, options?) => Promise<string>Ignored; scheduled for removal in the next major release. Payout- and fee-recipient-account creation is now prepended to the redeem instruction, so the SDK sends no second transaction and never invokes this callback — signing goes through the provider's wallet. Pass undefined here; do not delete the argument. It sits before vaultAddress, so removing it shifts your vault address into this slot and leaves vaultAddress undefined — which silently falls back to the legacy single-vault PDA derivation and targets a different vault.
vaultAddress?string | PublicKey-
options?ISolanaRedeemOptionsSlippage protection. By default the SDK quotes the net payout these shares should return from the vault's current state and passes that quote, lowered by 50 bps, as the floor to the program's checked instruction. See ISolanaRedeemOptions.

Returns

Promise<any>

Interfaces

ISolanaDepositOptions

Slippage protection for SolanaAdapter.vaultDeposit.

The SDK quotes the shares a deposit should mint from the vault's current state and passes a floor to the program's deposit_checked instruction, which reverts with SlippageExceeded if the share price moves past it before execution.

Properties

PropertyTypeDefault valueDescription
minSharesOut?bigintundefinedExplicit floor in raw share units, passed to deposit_checked as is. Skips the quote and the single snapshot read it needs. 0n restores the unguarded behaviour of the plain deposit instruction. Must be a bigint in 0 .. 2^64-1; anything else throws AugustValidationError before the transaction is built.
slippageBps?number50 (0.5%)Tolerance below the quoted shares, in basis points (0 to 10000). 0 demands the quote exactly. Ignored when minSharesOut is given.

ISolanaRedeemOptions

Slippage protection for SolanaAdapter.vaultRedeem.

The floor is measured net of the withdrawal fee, i.e. on what the wallet actually receives, matching the program's redeem_checked.

Properties

PropertyTypeDefault valueDescription
minAssetsOut?bigintundefinedExplicit floor in raw deposit-mint units, net of the withdrawal fee, passed to redeem_checked as is. Skips the quote. 0n restores the unguarded behaviour of the plain redeem instruction.
slippageBps?number50 (0.5%)Tolerance below the quoted net payout, in basis points (0 to 10000). 0 demands the quote exactly. Ignored when minAssetsOut is given.

Variables

Solana

const Solana: object

Type Declaration

NameTypeDefault value
actions__moduleSolanaActions
constants__moduleSolanaConstants
getters__moduleSolanaGetters
utilsobjectSolanaUtils
utils.deriveShareMintPda()(vaultProgramId) => PublicKey-
utils.deriveVaultStatePda()(vaultProgramId) => PublicKey-
utils.deriveVaultTokenAtaPda()(vaultProgramId, depositMint, vaultVersion?) => PublicKey-
utils.fallbackDecimalsnumber-
utils.fallbackNetworkISolanaNetwork-
utils.fetchUserShareBalance()(__namedParameters) => Promise<number>-
utils.fetchUserShareBalanceRaw()(__namedParameters) => Promise<{ amount: string; decimals: number; }>-
utils.fetchUserTokenBalance()(__namedParameters) => Promise<string>-
utils.getBestRpcEndpoint()(__namedParameters) => Promise<"http://127.0.0.1:8899" | `https://${string}`>-
utils.getExplorerLink()(__namedParameters) => string-
utils.getProgram()(__namedParameters) => Program<any>-
utils.getProvider()(__namedParameters) => AnchorProvider-
utils.getReadOnlyProvider()(__namedParameters) => AnchorProvider-
utils.getToken()(__namedParameters) => Promise<{ address: string; decimals: number; image: string; name: string; symbol: string; }>-
utils.getTokenSymbol()(__namedParameters) => Promise<string>-
utils.getVaultMints()(__namedParameters) => Promise<{ depositMint: string; shareMint: string; vaultVersion: number; }>-
utils.getVaultState()(__namedParameters) => Promise<{ depositMintDecimals: number; vaultState: unknown; }>-
utils.getVaultStateReadOnly()(__namedParameters) => Promise<{ depositMintDecimals: number; vaultState: ISolanaVaultState; }>-
utils.isSolana()(signature) => boolean-
utils.isSolanaAddress()(address) => boolean-
utils.programIdsobject-
utils.programIds.devnetobject-
utils.programIds.devnet.vaultstring'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt'
utils.programIds.localnetobject-
utils.programIds.localnet.vaultstring'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt'
utils.programIds.mainnet-betaobject-
utils.programIds.mainnet-beta.vaultstring'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt'
utils.resolveProgramId()(vaultAddress, solanaMetadata?) => string-