Skip to main content
This script allocates tokens to a Kamino Vault and later redeems a chosen amount of shares. It uses the transaction builder for policy matching, supported tracking, refresh scheduling, and ordered submission.

Set up

Install the constrained deposit/withdraw policy and configure the share-price source described in Kamino Vaults. Track the underlying token, fund its Squads account, and keep the required reserve allocation. The signer must have the permissions needed for any first-use tracking.

Script

Save as allocate-and-exit.mts. Running it simulates and submits its execution plan.
allocate-and-exit.mts

Run each phase

Deposit amounts use underlying-token units; exits use share units. Omitting a reserve lets withdrawal planning use several ordered reserve legs when required. All returned sets must execute in order. Resolve an uncertain send status before retrying; an allocation is not safe to replay automatically.