@gabox-labs/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +37 -11
- package/dist/{index-C4at2cZ_.d.ts → index-CQcBMEah.d.ts} +192 -6
- package/dist/index.d.ts +32 -15
- package/dist/index.js +37 -38
- package/dist/index.js.map +1 -1
- package/dist/raydium/index.d.ts +2 -2
- package/dist/raydium/index.js +2 -2
- package/dist/{raydium-CU-tZzIk.js → raydium-DIF1WOvI.js} +618 -62
- package/dist/raydium-DIF1WOvI.js.map +1 -0
- package/package.json +1 -1
- package/skills/gabox-sdk/SKILL.md +4 -2
- package/skills/gabox-sdk/references/api.md +16 -7
- package/dist/raydium-CU-tZzIk.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dt as POOL_DISCRIMINATOR, I as getFundPrizesInstruction, Ot as decodePool, Rt as DRAW_DISCRIMINATOR, W as getExpireDrawInstruction, _t as decodeWalletActivity, b as getRetryDrawInstruction, ft as findPoolPda, gt as WALLET_ACTIVITY_DISCRIMINATOR, ht as findActivityPda, k as getInitializePoolInstructionAsync, mt as findDrawPda, p as getSellTokensInstructionAsync, pt as findIdentityPda, st as getBuyPackInstructionAsync, zt as decodeDraw } from "./gabox-DGTCh34U.js";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as readAccounts, $t as vrfIdentityAddress, A as wsolAccountFor, An as tierAmount, Bn as SLOT_HASHES_SYSVAR, Cn as TIERS, Ct as listDrawsByPurchaser, D as quoteAccountFor, Dn as quote, Dr as PLATFORM_ADMIN, E as newCurveReserves, En as maxMultiplierBps, Er as METAPLEX_PROGRAM_ADDRESS, Et as tiersOf, Fn as IDENTITY_SEED, Gt as tokenAccountAmount, Hn as VRF_DEFAULT_QUEUE, I as curveBuyExactOut, In as INSTRUCTIONS_SYSVAR, It as decodeCpmmAmmConfig, J as fetchQuoteAsset, Jt as associatedTokenAddress, Ln as MAX_ATTEMPTS, Lt as decodeCpmmPool, Mn as validatePack, N as cpmmSwapBaseInput, Nn as validateTiers, Nr as TOKEN_PROGRAM_ADDRESS, O as resolveVenue, On as resolveReservation, P as cpmmSwapBaseOutput, Pn as GABOX_PROGRAM_ID, Pr as WSOL_MINT, Qt as vaultAddress, Rn as PACK_TOKENS, S as fetchCurveSettings, Sn as TICKETS, St as listDrawsByPool, Tn as choose, Tr as LAUNCH_TOTAL_BASE_SELL, Tt as quotePool, Un as VRF_PROGRAM_ADDRESS, Vn as TIMEOUT_SLOTS, W as launchlabBuyAccounts, X as fetchQuoteDisplay, Xt as poolAddress, Yt as drawAddress, Zn as LAUNCH_DECIMALS, Zt as scopedVrfIdentityAddress, _ as buildMessage, _n as BPS, _t as fetchPoolByMint, at as HARVEST_COMPUTE_UNITS, b as creatorFeeOnInput, bn as MAX_MULTIPLIER_BPS, bt as fetchWalletActivity, ct as computeBudgetInstructions, dn as launchlabVaultAddress, dt as DRAW_POOL_OFFSET, en as ata, et as BUY_PACK_COMPUTE_UNITS, ft as DRAW_PURCHASER_OFFSET, g as getLaunchInstruction, gt as fetchPoolAt, hn as platformFeeVaultAddress, ht as fetchDraw, in as creatorFeeVaultAddress, it as DEFAULT_COMPUTE_UNIT_LIMIT, jn as uncappedMaximum, jr as SYSTEM_PROGRAM_ADDRESS, kn as seedTokens, lr as ASSOCIATED_TOKEN_PROGRAM_ADDRESS, lt as getSetComputeUnitLimitInstruction, mr as CPMM_SWAP_BASE_OUTPUT, mt as POOL_MINT_OFFSET, nt as COMPUTE_BUDGET_PROGRAM_ADDRESS, ot as MAX_COMPUTE_UNIT_LIMIT, pr as CPMM_SWAP_BASE_INPUT, pt as POOL_CREATOR_OFFSET, q as order, qt as activityAddress, rt as CREATE_MACHINE_COMPUTE_UNITS, sr as raydiumIds, st as REDEEM_COMPUTE_UNITS, t as raydium_exports, tt as CLAIM_COMPUTE_UNITS, un as launchlabPoolAddress, ut as getSetComputeUnitPriceInstruction, v as withRemainingAccounts, vn as DEFAULT_TIERS, vt as fetchPoolInventory, wn as averageMultiplierBps, wt as listPools, xn as MIN_SEED_MULTIPLIER_BPS, xt as listDraws, yn as GaboxMathError, yt as fetchVaultBalance, zn as RETRY_SLOTS } from "./raydium-DIF1WOvI.js";
|
|
3
3
|
import { DRAW_RESOLVED_EVENT_DISCRIMINATOR, PACK_BOUGHT_EVENT_DISCRIMINATOR, POOL_CREATED_EVENT_DISCRIMINATOR, PRIZES_FUNDED_EVENT_DISCRIMINATOR, RANDOMNESS_RETRIED_EVENT_DISCRIMINATOR, TOKENS_SOLD_EVENT_DISCRIMINATOR, getDrawResolvedEventDecoder, getPackBoughtEventDecoder, getPoolCreatedEventDecoder, getPrizesFundedEventDecoder, getRandomnessRetriedEventDecoder, getTokensSoldEventDecoder, t as generated_exports } from "./generated/index.js";
|
|
4
4
|
import { AccountRole, address, createNoopSigner, createSolanaRpc, createSolanaRpcSubscriptions, getAddressDecoder, getBase64Encoder, getU64Encoder } from "@solana/kit";
|
|
5
5
|
import { getCloseAccountInstruction, getCreateAssociatedTokenIdempotentInstruction, getSyncNativeInstruction } from "@solana-program/token";
|
|
@@ -1060,6 +1060,9 @@ function unwrapWsol(owner, account) {
|
|
|
1060
1060
|
* transaction, before `buy_pack`. A sale does the reverse afterwards. `routeQuoteIn` and
|
|
1061
1061
|
* `routeQuoteOut` build those, and `assertRouteIsSafe` checks the result before it is used.
|
|
1062
1062
|
*
|
|
1063
|
+
* The third shape belongs to packs only. A machine's seed is always paid by its creator, in the
|
|
1064
|
+
* machine's own quote token, so `createMachine` uses `quoteLegFromWallet` and never swaps.
|
|
1065
|
+
*
|
|
1063
1066
|
* Nothing here ever splits the work across two transactions. A swap that settles separately would
|
|
1064
1067
|
* leave the wallet holding a token it never asked for whenever the second half failed.
|
|
1065
1068
|
*/
|
|
@@ -1074,13 +1077,16 @@ function createQuoteAccount(owner, venue) {
|
|
|
1074
1077
|
});
|
|
1075
1078
|
}
|
|
1076
1079
|
/**
|
|
1077
|
-
* The leg
|
|
1080
|
+
* The leg for a wallet that already holds what it is about to spend. No swap.
|
|
1078
1081
|
*
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1082
|
+
* A WSOL pool is the one case where "already holds it" means lamports, so those are wrapped and the
|
|
1083
|
+
* account is closed again afterwards. Any other quote only needs its account to exist; closing it
|
|
1084
|
+
* would throw away a real balance.
|
|
1085
|
+
*
|
|
1086
|
+
* `createMachine` uses this and nothing else: the seed is always the creator's own money, in the
|
|
1087
|
+
* machine's quote token.
|
|
1081
1088
|
*/
|
|
1082
|
-
async function
|
|
1083
|
-
const { venue, payer, maxQuoteIn, payWith } = input;
|
|
1089
|
+
async function quoteLegFromWallet(venue, payer, maxQuoteIn) {
|
|
1084
1090
|
if (venue.quoteMint === "So11111111111111111111111111111111111111112") {
|
|
1085
1091
|
const wsol = await fundWsol(payer, maxQuoteIn);
|
|
1086
1092
|
return {
|
|
@@ -1092,7 +1098,7 @@ async function quoteLegIn(client, input) {
|
|
|
1092
1098
|
computeUnits: 0
|
|
1093
1099
|
};
|
|
1094
1100
|
}
|
|
1095
|
-
|
|
1101
|
+
return {
|
|
1096
1102
|
before: [createQuoteAccount(payer, venue)],
|
|
1097
1103
|
after: [],
|
|
1098
1104
|
lookupTables: {},
|
|
@@ -1100,6 +1106,16 @@ async function quoteLegIn(client, input) {
|
|
|
1100
1106
|
solAmount: null,
|
|
1101
1107
|
computeUnits: 0
|
|
1102
1108
|
};
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* The leg that puts `maxQuoteIn` of the quote token in the buyer's quote account.
|
|
1112
|
+
*
|
|
1113
|
+
* `payWith` decides where it comes from. On a WSOL pool the choice makes no difference: the quote
|
|
1114
|
+
* token is SOL either way, so the builder wraps it.
|
|
1115
|
+
*/
|
|
1116
|
+
async function quoteLegIn(client, input) {
|
|
1117
|
+
const { venue, payer, maxQuoteIn, payWith } = input;
|
|
1118
|
+
if (venue.quoteMint === "So11111111111111111111111111111111111111112" || payWith === "quote") return await quoteLegFromWallet(venue, payer, maxQuoteIn);
|
|
1103
1119
|
const route = await routeQuoteIn(client, providerOf(client, venue.quoteMint), {
|
|
1104
1120
|
quoteMint: venue.quoteMint,
|
|
1105
1121
|
amount: maxQuoteIn,
|
|
@@ -1325,39 +1341,22 @@ async function createMachine(client, input) {
|
|
|
1325
1341
|
maxSeedNativeDebit,
|
|
1326
1342
|
extraSeedTokens
|
|
1327
1343
|
});
|
|
1328
|
-
const leg = await
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
},
|
|
1334
|
-
payer: creator,
|
|
1335
|
-
maxQuoteIn: maxSeedQuoteIn,
|
|
1336
|
-
payWith: seed === 0n ? "quote" : input.payWith ?? "sol",
|
|
1337
|
-
gaboxAccounts: [
|
|
1338
|
-
await poolAddress(mint),
|
|
1339
|
-
await vaultAddress(mint),
|
|
1340
|
-
await ata(creator.address, mint)
|
|
1341
|
-
]
|
|
1342
|
-
});
|
|
1344
|
+
const leg = await quoteLegFromWallet({
|
|
1345
|
+
quoteMint: quote.mint,
|
|
1346
|
+
quoteTokenProgram: quote.tokenProgram,
|
|
1347
|
+
userQuoteToken
|
|
1348
|
+
}, creator, maxSeedQuoteIn);
|
|
1343
1349
|
const instructions = [
|
|
1344
1350
|
create,
|
|
1345
1351
|
...leg.before,
|
|
1346
1352
|
withRemainingAccounts(initialize, venueAccounts),
|
|
1347
1353
|
...leg.after
|
|
1348
1354
|
];
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
},
|
|
1355
|
-
computeUnitLimit: input.computeUnitLimit ?? computeUnitsWithRoute(35e4, leg),
|
|
1356
|
-
...input.computeUnitPrice === void 0 ? {} : { computeUnitPrice: input.computeUnitPrice }
|
|
1357
|
-
});
|
|
1358
|
-
} catch (cause) {
|
|
1359
|
-
throw routeSizeHint(cause, leg);
|
|
1360
|
-
}
|
|
1355
|
+
return await buildMessage(client, creator, instructions, {
|
|
1356
|
+
addressLookupTables: input.addressLookupTables ?? client.addressLookupTables,
|
|
1357
|
+
computeUnitLimit: input.computeUnitLimit ?? 35e4,
|
|
1358
|
+
...input.computeUnitPrice === void 0 ? {} : { computeUnitPrice: input.computeUnitPrice }
|
|
1359
|
+
});
|
|
1361
1360
|
}
|
|
1362
1361
|
/**
|
|
1363
1362
|
* What the seed for this table costs, fees included, and how many tokens it is.
|
|
@@ -1367,9 +1366,9 @@ async function createMachine(client, input) {
|
|
|
1367
1366
|
* same transaction, so this is exact up to a change in Raydium's fee rates between the read and the
|
|
1368
1367
|
* send.
|
|
1369
1368
|
*
|
|
1370
|
-
* `solAmount` is
|
|
1371
|
-
*
|
|
1372
|
-
* caller passes `raydiumCpmmRoute(pool)`.
|
|
1369
|
+
* `solAmount` is what that cost is worth in SOL, priced through the client's route provider. It is
|
|
1370
|
+
* a display: the creator pays in the quote token. It is `null` when the client has no provider, or
|
|
1371
|
+
* when no route exists: a devnet client has none unless the caller passes `raydiumCpmmRoute(pool)`.
|
|
1373
1372
|
*
|
|
1374
1373
|
* Defaults to `DEFAULT_TIERS`, wrapped SOL and no extra seed. Throws if `tiers` fails
|
|
1375
1374
|
* `validateTiers`/`validatePack`, if `extraSeedTokens` is negative, if the total seed is bigger
|
|
@@ -1582,6 +1581,6 @@ async function oracleAccounts() {
|
|
|
1582
1581
|
};
|
|
1583
1582
|
}
|
|
1584
1583
|
//#endregion
|
|
1585
|
-
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, BPS, BUY_PACK_COMPUTE_UNITS, CLAIM_COMPUTE_UNITS, CLUSTER_ENDPOINTS, COMPUTE_BUDGET_PROGRAM_ADDRESS, CPMM_ROUTE_COMPUTE_UNITS, CPMM_ROUTE_SLIPPAGE_BPS, CREATE_MACHINE_COMPUTE_UNITS, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_TIERS, DEVNET_ADDRESS_LOOKUP_TABLES, DEVNET_HTTP, DEVNET_LOOKUP_TABLE_ADDRESS, DEVNET_LOOKUP_TABLE_ADDRESSES, DEVNET_WS, DRAW_DISCRIMINATOR, DRAW_POOL_OFFSET, DRAW_PURCHASER_OFFSET, EXACT_IN_MARGIN_BPS, GABOX_PROGRAM_ID, GaboxMathError, IDENTITY_SEED, INSTRUCTIONS_SYSVAR, JUPITER_DEFAULT_COMPUTE_UNITS, JUPITER_DEFAULT_SLIPPAGE_BPS, JUPITER_LITE_URL, LAUNCH_DECIMALS, MAX_ATTEMPTS, MAX_COMPUTE_UNIT_LIMIT, MAX_MULTIPLIER_BPS, METAPLEX_PROGRAM_ADDRESS, MIN_SEED_MULTIPLIER_BPS, PACK_TOKENS, PLATFORM_ADMIN, POOL_CREATOR_OFFSET, POOL_DISCRIMINATOR, POOL_MINT_OFFSET, REDEEM_COMPUTE_UNITS, RETRY_SLOTS, SLOT_HASHES_SYSVAR, SYSTEM_PROGRAM_ADDRESS, TICKETS, TIERS, TIMEOUT_SLOTS, TOKEN_PROGRAM_ADDRESS, VRF_DEFAULT_QUEUE, VRF_PROGRAM_ADDRESS, WALLET_ACTIVITY_DISCRIMINATOR, WSOL_MINT, activityAddress, assertClusterUrl, assertRouteIsSafe, associatedTokenAddress, averageMultiplierBps, buildMessage, buyPack, choose, clusterNamedBy, computeBudgetInstructions, computeUnitsOf, computeUnitsWithRoute, createClient, createMachine, createQuoteAccount, decodeDraw, decodeEvent, decodeEvents, decodePool, decodeWalletActivity, defaultAddressLookupTables, defaultRoute, drawAddress, drawAvailability, expireDraw, fetchAddressLookupTables, fetchDraw, fetchEvents, fetchPoolAt, fetchPoolByMint, fetchPoolInventory, fetchVaultBalance, fetchWalletActivity, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, findResolvedDraw, fundPrizes, fundWsol, generated_exports as generated, getOffer, getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, jupiterRoute, listDraws, listDrawsByPool, listDrawsByPurchaser, listPools, maxMultiplierBps, offerFromState, oracleAccounts, poolAddress, providerOf, quote, quoteLegIn, quoteLegOut, quotePool, raydium_exports as raydium, raydiumCpmmRoute, resolveReservation, retryDraw, routeFrom, routeQuoteIn, routeQuoteOut, routeSizeHint, scopedVrfIdentityAddress, seedCostEstimate, seedShortfall, seedTokens, sellTokens, solPriceOf, tierAmount, tiersOf, uncappedMaximum, unwrapWsol, validatePack, validateTiers, vaultAddress, vrfIdentityAddress, websocketUrlFor, withRemainingAccounts };
|
|
1584
|
+
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, BPS, BUY_PACK_COMPUTE_UNITS, CLAIM_COMPUTE_UNITS, CLUSTER_ENDPOINTS, COMPUTE_BUDGET_PROGRAM_ADDRESS, CPMM_ROUTE_COMPUTE_UNITS, CPMM_ROUTE_SLIPPAGE_BPS, CREATE_MACHINE_COMPUTE_UNITS, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_TIERS, DEVNET_ADDRESS_LOOKUP_TABLES, DEVNET_HTTP, DEVNET_LOOKUP_TABLE_ADDRESS, DEVNET_LOOKUP_TABLE_ADDRESSES, DEVNET_WS, DRAW_DISCRIMINATOR, DRAW_POOL_OFFSET, DRAW_PURCHASER_OFFSET, EXACT_IN_MARGIN_BPS, GABOX_PROGRAM_ID, GaboxMathError, HARVEST_COMPUTE_UNITS, IDENTITY_SEED, INSTRUCTIONS_SYSVAR, JUPITER_DEFAULT_COMPUTE_UNITS, JUPITER_DEFAULT_SLIPPAGE_BPS, JUPITER_LITE_URL, LAUNCH_DECIMALS, MAX_ATTEMPTS, MAX_COMPUTE_UNIT_LIMIT, MAX_MULTIPLIER_BPS, METAPLEX_PROGRAM_ADDRESS, MIN_SEED_MULTIPLIER_BPS, PACK_TOKENS, PLATFORM_ADMIN, POOL_CREATOR_OFFSET, POOL_DISCRIMINATOR, POOL_MINT_OFFSET, REDEEM_COMPUTE_UNITS, RETRY_SLOTS, SLOT_HASHES_SYSVAR, SYSTEM_PROGRAM_ADDRESS, TICKETS, TIERS, TIMEOUT_SLOTS, TOKEN_PROGRAM_ADDRESS, VRF_DEFAULT_QUEUE, VRF_PROGRAM_ADDRESS, WALLET_ACTIVITY_DISCRIMINATOR, WSOL_MINT, activityAddress, assertClusterUrl, assertRouteIsSafe, associatedTokenAddress, averageMultiplierBps, buildMessage, buyPack, choose, clusterNamedBy, computeBudgetInstructions, computeUnitsOf, computeUnitsWithRoute, createClient, createMachine, createQuoteAccount, decodeDraw, decodeEvent, decodeEvents, decodePool, decodeWalletActivity, defaultAddressLookupTables, defaultRoute, drawAddress, drawAvailability, expireDraw, fetchAddressLookupTables, fetchDraw, fetchEvents, fetchPoolAt, fetchPoolByMint, fetchPoolInventory, fetchVaultBalance, fetchWalletActivity, findActivityPda, findDrawPda, findIdentityPda, findPoolPda, findResolvedDraw, fundPrizes, fundWsol, generated_exports as generated, getOffer, getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, jupiterRoute, listDraws, listDrawsByPool, listDrawsByPurchaser, listPools, maxMultiplierBps, offerFromState, oracleAccounts, poolAddress, providerOf, quote, quoteLegFromWallet, quoteLegIn, quoteLegOut, quotePool, raydium_exports as raydium, raydiumCpmmRoute, resolveReservation, retryDraw, routeFrom, routeQuoteIn, routeQuoteOut, routeSizeHint, scopedVrfIdentityAddress, seedCostEstimate, seedShortfall, seedTokens, sellTokens, solPriceOf, tierAmount, tiersOf, uncappedMaximum, unwrapWsol, validatePack, validateTiers, vaultAddress, vrfIdentityAddress, websocketUrlFor, withRemainingAccounts };
|
|
1586
1585
|
|
|
1587
1586
|
//# sourceMappingURL=index.js.map
|