Skip to main content
These examples use placeholders. Nothing moves funds until the send step. Load the API key and the manager keypair from your bot’s secret store.

Read vault state

Build transactions

Each body below goes to POST https://hedgin.xyz/api/external/v1/transactions/{action} with Content-Type: application/json. Amounts are base-unit strings.
The dlmm/open body creates bins -20 to 20, because upperBinId is exclusive there. See Units and views.

Sign, send, and confirm a whole build

This TypeScript module runs one build to completion. It follows the batch and next rules, and it never builds again after an unknown send. It needs Node.js 18 or later and @solana/web3.js.
execute sends real mainnet transactions. Call it only with a vault and amounts you are ready to trade.
hedgin.ts
Call it with a key that has the builder’s scope and send:
If execute throws partway through a batch, confirmed steps stay on chain, and steps sent alongside the failing one can still land. A send that threw after the request left your machine, such as a network timeout, may also have reached the API. Wait about a minute for the blockhash to expire, then read current state before you call execute again. execute does not handle Phoenix onboarding. Send a phoenix/onboard step to transactions/phoenix/onboard/submit instead of transactions/send.