TypeScript SDK for Scale AMM and Scale VMM.
npm install @scalecrx/sdk @coral-xyz/anchor @solana/web3.jsimport { AMM_ADDRESS, VMM_ADDRESS, CLUSTER_RPC_URLS } from "@scalecrx/sdk";AMM_ADDRESS=>SCALEwAvEK5gtkdHiFzXfPgtk2YwJxPDzaV3aDmR7tAVMM_ADDRESS=>SCALEWoRSpVZpMRqHEcDfNvBh3nUSe34jDr9r689gLa
import { Scale } from "@scalecrx/sdk";
const sdk = new Scale("https://my-rpc.example.com", walletOptional);import { Scale } from "@scalecrx/sdk";
const sdkDevnet = new Scale("devnet", walletOptional); // uses https://api.devnet.solana.com
const sdkMainnet = new Scale("mainnet", walletOptional); // uses https://api.mainnet-beta.solana.comIf wallet is omitted, read-only and instruction-building flows still work, but direct execution methods throw.
Every write flow has two styles:
- Execute now (requires wallet):
await sdk.amm.buy(poolAddress, { amount: 1_000, limit: 1 }, opts);- Return instructions only (no send):
const bundle = await sdk.amm.buyInstructions(poolAddress, { amount: 1_000, limit: 1 }, opts);
// bundle.instructions -> add to Transaction yourselfSame pattern exists for AMM and VMM (buy/sell/create*, plus config instruction builders).
Pool/pair creation supports exactly two curve configs:
constantProduct: standard x*y=k style curve.exponential: steeper curve profile than constant product for the same inputs.
Use one of:
{ constantProduct: {} }
// or
{ exponential: {} }- Most numeric args are
number | BN. - On-chain values are integer base units (raw token units), not UI decimals.
shift: virtual token A liquidity shift used by curve math.initialTokenBReserves: initial token B reserves deposited for create.curve:{ constantProduct: {} } | { exponential: {} }.feeBeneficiaries: array of{ wallet: PublicKey, shareBps: number }.
payer?: transaction payer (defaults to SDK wallet public key).owner?(AMM only): pool owner PDA seed input (defaults to SDK wallet).tokenWalletB?: token B source account for create.tokenWalletAuthority?: authority fortokenWalletBtransfers.autoCreateBeneficiaryAtas?: auto-create platform-fee and beneficiary ATAs formintAduring create (defaulttrue).signers?: extra signers appended to returned bundle/send.
amount: input amount in raw units.limit: slippage guard / minimum-out style bound enforced by program.
userTokenAccountA?,userTokenAccountB?: user token accounts override.platformFeeTokenAccount?: explicit platform fee token A account.beneficiaryTokenAccounts?: explicit creator fee accounts (order-sensitive).wrapSol?: wrap SOL into WSOL before swap when mint A is native.unwrapSol?: unwrap WSOL after swap when mint A is native.autoCreateAta?: auto-create missing ATAs (default true).
In addition to SwapOptions, VMM accepts optional explicit AMM graduation accounts:
ammPool?,ammVaultA?,ammVaultB?,ammConfig?
The VMM client always targets the Scale AMM program
SCALEwAvEK5gtkdHiFzXfPgtk2YwJxPDzaV3aDmR7tA for graduation. ammProgramId
is not configurable in VMM flows.
const pair = await sdk.vmm.getPairByMints(mintA, mintB);
const isGraduated = pair.data.graduated;ammProgramId?: override the AMM client program ID.vmmProgramId?: override the VMM client program ID.ammIdl?,vmmIdl?: IDL overrides.programId?,idl?: legacy AMM alias fallback.providerOptions?: Anchor provider confirmation/preflight options.
const config = await sdk.amm.getPlatformConfig();
const pool = await sdk.amm.getPoolByMints(owner, mintA, mintB);
const quote = await sdk.amm.estimateBuy(pool.address, { amount: 10_000, limit: 1 });const createBundle = await sdk.amm.createPoolInstructions(
{
shift: 1_000_000,
initialTokenBReserves: 100_000,
curve: { constantProduct: {} },
feeBeneficiaries: [],
},
mintA,
mintB,
{
payer,
owner,
tokenWalletB,
tokenWalletAuthority,
autoCreateBeneficiaryAtas: true,
}
);
const swapBundle = await sdk.amm.buyInstructions(
poolAddress,
{ amount: 10_000, limit: 1 },
{
userTokenAccountA,
userTokenAccountB,
platformFeeTokenAccount,
beneficiaryTokenAccounts,
wrapSol: true,
unwrapSol: false,
autoCreateAta: true,
}
);const config = await sdk.vmm.getPlatformConfig();
const pair = await sdk.vmm.getPairByMints(mintA, mintB);
const quote = await sdk.vmm.estimateSell(pair.address, { amount: 10_000, limit: 1 });const createBundle = await sdk.vmm.createPairInstructions(
{
shift: 1_000_000,
initialTokenBReserves: 100_000,
curve: { exponential: {} },
feeBeneficiaries: [],
},
mintA,
mintB,
{
payer,
tokenWalletB,
tokenWalletAuthority,
autoCreateBeneficiaryAtas: true,
}
);
const swapBundle = await sdk.vmm.sellInstructions(
pairAddress,
{ amount: 10_000, limit: 1 },
{
userTokenAccountA,
userTokenAccountB,
platformFeeTokenAccount,
beneficiaryTokenAccounts,
autoCreateAta: true,
}
);new Scale(connection, wallet, options)new Scale(rpcUrl, wallet?, options?)new Scale("devnet" | "mainnet", wallet?, options?)amm,vmm,loadAmm,loadVmmloadAmm(programId?, idlOverride?)loadVmm(programId?, idlOverride?)
- Read-only:
getConfigAddress,getPoolAddress,getVaultAddress,getPlatformConfig,getPlatformBaseToken,getPool*,getFee*,estimateBuy,estimateSell - Execute:
createPool,buy,sell - Instruction builders:
createPoolInstructions,createWithDevBuyInstructions,buyInstructions,sellInstructionscreatePool(params, mintA, mintB, options?)createPoolInstructions(params, mintA, mintB, options?)createWithDevBuyInstructions(params, mintA, mintB, buyParams, options?)buy(poolInput, params, options?)sell(poolInput, params, options?)buyInstructions(poolInput, params, options?)sellInstructions(poolInput, params, options?)
- Read-only:
getConfigAddress,getPairAddress,getVaultAddress,getAmmPoolAddress,getAmmVaultAddress,getPlatformConfig,getPlatformConfigView,getPlatformBaseToken,getGraduationThreshold,getPair*,getFee*,estimateBuy,estimateSell - Execute:
setGraduationThreshold,createPair,buy,sell - Instruction builders:
setGraduationThresholdInstruction,createPairInstructions,createWithDevBuyInstructions,buyInstructions,sellInstructionssetGraduationThreshold(threshold)setGraduationThresholdInstruction(threshold)createPair(params, mintA, mintB, options?)createPairInstructions(params, mintA, mintB, options?)createWithDevBuyInstructions(params, mintA, mintB, buyParams, options?)buy(pairInput, params, options?)sell(pairInput, params, options?)buyInstructions(pairInput, params, options?)sellInstructions(pairInput, params, options?)
Use this prompt in your AI coding agent to integrate an existing project with Scale SDK:
Integrate Scale SDK into this project end-to-end using the official docs:
https://github.com/scalecrx/sdk/blob/main/README.md
Requirements:
1. Install and configure @scalecrx/sdk and required Solana/Anchor dependencies.
2. Detect this project’s package manager, TypeScript setup, and runtime (Node/server/client), then implement integration in the correct layer.
3. Add a reusable Scale client module and environment-driven RPC/network configuration.
4. Implement at least one read flow (platform config + pair/pool fetch/quote) and one transaction instruction-building flow using this SDK.
5. If wallet execution is not available in this project context, use instruction builders only and wire outputs for external signing.
6. Keep all amounts in raw base units (not UI decimals) and add safe input validation.
7. Add/update minimal docs in this repo explaining how to run and use the integration.
8. Run build/typecheck/tests (if present) and fix any issues caused by the integration.
Output format:
- Summary of files changed and why
- Exact commands run
- Any assumptions or follow-up tasks
Official Scale branding assets are available here:
Basic partner guidelines:
- Use only the logos, marks, icons, wordmarks, screenshots, and visual assets provided in the official drive above.
- Do not recreate, redraw, recolor, stretch, crop, animate, or otherwise modify Scale brand assets unless the provided files explicitly include an approved variant.
- Do not source logos or visuals from third-party websites, search results, old decks, social screenshots, or cached copies.
- When updating partner surfaces, always pull the latest assets from the official drive link rather than reusing locally stored copies from older integrations.
- If a required format, size, or asset variant is missing, request it instead of generating your own replacement.
SDK integration references for partners:
- Official docs: README.md
- Public package:
@scalecrx/sdkon npm - Source repository: scalecrx/sdk on GitHub
Integration notes:
- Install from npm with
npm install @scalecrx/sdk. - Treat on-chain numeric inputs as raw base units, not UI-decimal values.
- If your integration cannot sign transactions directly, use the SDK instruction builders and pass the built instructions into your existing wallet or signing flow.
- For graduation checks, fetch the VMM pair with
sdk.vmm.getPairByMints(mintA, mintB)and readpair.data.graduated. - For production integrations, keep RPC URL and network selection environment-driven so the same codepath can be promoted cleanly across environments.