Skip to main content
Fund lender strategies, manage borrower loans, or hold Loopscale VaultLP positions. The SDK turns Loopscale API responses into vault executions and handles co-signing where required.

Configure the policies

Use separate policies for the surfaces your vault needs. Set principalMint and collateralMint to the assets selected from Loopscale markets.
Install the policies you need using Configure policies. allowedMints restricts strategy deposits/withdrawals and loan collateral/principal transfers. It does not scope strategy creation, updates, closure, or loan maintenance. Omitting it or passing an empty list leaves those token transfers unrestricted. Select actions explicitly: the default also includes lock/unlock permissions that cannot execute through the vault hook. The VaultLP policy requires a nonempty allowedPrincipalMints list. Its principal scope applies to the lending-vault account data, rather than a strategy or loan address.

Prepare the Loopscale client

Use a loaded vault, connection, and manager Keypair. The API wallet is the vault’s Squads asset owner:
Select a vault-owned, already tracked strategyAddress from that response, or retain it after creating your own strategy through the supported flow. Strategies selected for borrower quotes can belong to other lenders. Use getQuotes or getMaxQuote to choose borrowing terms; use getLoanInfo for the live loan, collateral slots, and ledger indices. Select a lending vault using Loopscale’s Earn guide, then read its mint and strategy addresses with resolveLoopscaleVaultContext({ connection, vault: lendingVault }). Configure price paths for collateral and principal tokens. VaultLP shares additionally need a Loopscale Vault LP price source and share/stake tracking; resolveLoopscaleVaultContext and buildLoopscaleVaultLpPriceInterfaceAccounts resolve its public pricing inputs. The builder prepares supported registrations. The vault hook records strategies and loans created through the supported flow. For your own assembly, use those tracked positions and register their token balances before dependent actions; register unstaked VaultLP shares with TrackLoopscaleVaultShares through position updates. Supply the configured price-interface account and retain the stake address from the API response. New stakes are recorded by the hook; AddLoopscaleVaultStakeEntry is only for importing/recovering an existing stake with its live custody accounts and endTime. Confirm registration, refresh AUM, and rebuild against the reloaded vault.

Manage strategies, loans, and VaultLP

A client call returns a raw response, which can contain several transactions. Pass the whole response to the execution path you choose:
Amounts are in the corresponding token’s smallest units. The strategy must accept the chosen principal token.
build() returns a plan containing ordered transactionSets, instructions, additional signers, and lookup table addresses. send() performs supported setup, refreshes, selective Loopscale co-signing, simulation, and ordered submission.

Manage lender strategies

Use the lender policy above. External-yield strategy creation and external-yield updates are rejected by the hook. Each response can replace response in either execution path.
Retain createdStrategy before submitting createResponse; use it for later calls after creation confirms. Building a response does not create the account.

Manage borrower loans

Use the borrower policy above. Choose a strategy and terms from getQuotes/getMaxQuote; do not substitute a guessed APY or collateral slot. The vault hook supports SPL token collateral only (assetType: 0).
The response adapter rejects refinanceLedger, including responses produced with borrowPrincipal.refinanceParams. A prebuilt refinance instruction can use its action wrapper with the sync helpers or addActions; arrange any required Loopscale co-signing explicitly: the raw addActions/sync path does not invoke MPC. Lock/unlock instructions are rejected by the vault hook. They are not a supported allocation path.

Manage VaultLP positions

Use vaultLpPolicy. Set lendingVault to the selected Loopscale lending-vault address, distinct from a lender strategy and from your Strategy Vault.
Pass the complete response through the chosen execution path, preserving any preTransactions and returned stake address. Deposits and withdrawals must each occupy their own policy execution; do not combine them with another slippage-checked action. Configure reward-token price paths before claiming new reward assets.