@theliem/xmarket-sdk 3.23.0 → 3.25.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/dist/index.d.mts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +355 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +355 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -161,6 +161,14 @@ var PDA = class {
|
|
|
161
161
|
programIds.clobExchange
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
|
+
static collectFeeOrderRecord(user, nonce, programIds) {
|
|
165
|
+
const nonceBuf = Buffer.alloc(8);
|
|
166
|
+
nonceBuf.writeBigUInt64LE(BigInt(nonce.toString()));
|
|
167
|
+
return PublicKey.findProgramAddressSync(
|
|
168
|
+
[Buffer.from("collect_order"), user.toBuffer(), nonceBuf],
|
|
169
|
+
programIds.clobExchange
|
|
170
|
+
);
|
|
171
|
+
}
|
|
164
172
|
// ─── Fee Management ─────────────────────────────────────────────────────────
|
|
165
173
|
static feeConfig(owner, programIds) {
|
|
166
174
|
if (!programIds.feeManagement) throw new Error("feeManagement program ID not configured");
|
|
@@ -1618,6 +1626,39 @@ var ClobClient = class {
|
|
|
1618
1626
|
this._marketOracleVaultCache.set(key, vault);
|
|
1619
1627
|
return vault;
|
|
1620
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Returns a createATA ix for the oracle vault when:
|
|
1631
|
+
* - takerFee > 0
|
|
1632
|
+
* - marketFeeOverride exists for the condition
|
|
1633
|
+
* - oracle vault ATA is not yet initialized
|
|
1634
|
+
* Idempotent — safe to call every tx; returns null if vault already exists.
|
|
1635
|
+
*/
|
|
1636
|
+
async buildInitOracleVaultIfNeeded(condition, collateralMint, takerFee, payer) {
|
|
1637
|
+
if (takerFee.isZero()) return null;
|
|
1638
|
+
if (!this.feeConfigOwner || !this.programIds.feeManagement) return null;
|
|
1639
|
+
if (!this.ctfClient || !this.qmConfigPda || !this.programIds.marketOracle) return null;
|
|
1640
|
+
const companyAddr = await this.companyAddress();
|
|
1641
|
+
const refVault = await this.referralVault();
|
|
1642
|
+
if (!companyAddr || !refVault) return null;
|
|
1643
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
1644
|
+
const cond = await this.ctfClient.fetchCondition(condition);
|
|
1645
|
+
if (!cond) return null;
|
|
1646
|
+
const [questionPda] = PDA.question(this.qmConfigPda, cond.questionId, this.programIds);
|
|
1647
|
+
const [marketOraclePda] = PDA.marketOraclePda(questionPda, this.programIds);
|
|
1648
|
+
const vault = getAssociatedTokenAddressSync(collateralMint, marketOraclePda, true);
|
|
1649
|
+
const [feeOverrideInfo, vaultInfo] = await Promise.all([
|
|
1650
|
+
this.provider.connection.getAccountInfo(feeOverridePda),
|
|
1651
|
+
this.provider.connection.getAccountInfo(vault)
|
|
1652
|
+
]);
|
|
1653
|
+
if (!feeOverrideInfo) return null;
|
|
1654
|
+
if (vaultInfo) return null;
|
|
1655
|
+
return createAssociatedTokenAccountIdempotentInstruction(
|
|
1656
|
+
payer,
|
|
1657
|
+
vault,
|
|
1658
|
+
marketOraclePda,
|
|
1659
|
+
collateralMint
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1621
1662
|
get walletPubkey() {
|
|
1622
1663
|
return this.provider.wallet.publicKey;
|
|
1623
1664
|
}
|
|
@@ -1756,8 +1797,8 @@ var ClobClient = class {
|
|
|
1756
1797
|
async _sendLegacyTxSig(instructions) {
|
|
1757
1798
|
const { connection } = this.provider;
|
|
1758
1799
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1759
|
-
const { Transaction:
|
|
1760
|
-
const tx = new
|
|
1800
|
+
const { Transaction: Transaction12 } = await import('@solana/web3.js');
|
|
1801
|
+
const tx = new Transaction12();
|
|
1761
1802
|
tx.recentBlockhash = blockhash;
|
|
1762
1803
|
tx.feePayer = this.walletPubkey;
|
|
1763
1804
|
tx.add(...instructions);
|
|
@@ -1783,10 +1824,10 @@ ${logs.join("\n")}`);
|
|
|
1783
1824
|
connection.getAccountInfo(clobYesAta),
|
|
1784
1825
|
connection.getAccountInfo(clobNoAta)
|
|
1785
1826
|
]);
|
|
1786
|
-
const { createAssociatedTokenAccountIdempotentInstruction:
|
|
1827
|
+
const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction5 } = await import('@solana/spl-token');
|
|
1787
1828
|
const ixs = [];
|
|
1788
1829
|
if (!yesInfo) {
|
|
1789
|
-
ixs.push(
|
|
1830
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction5(
|
|
1790
1831
|
this.walletPubkey,
|
|
1791
1832
|
clobYesAta,
|
|
1792
1833
|
clobConfig,
|
|
@@ -1795,7 +1836,7 @@ ${logs.join("\n")}`);
|
|
|
1795
1836
|
));
|
|
1796
1837
|
}
|
|
1797
1838
|
if (!noInfo) {
|
|
1798
|
-
ixs.push(
|
|
1839
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction5(
|
|
1799
1840
|
this.walletPubkey,
|
|
1800
1841
|
clobNoAta,
|
|
1801
1842
|
clobConfig,
|
|
@@ -1878,6 +1919,49 @@ ${logs.join("\n")}`);
|
|
|
1878
1919
|
await this.registerOrder(signed);
|
|
1879
1920
|
}
|
|
1880
1921
|
}
|
|
1922
|
+
// ─── Register CollectFeeOrder ────────────────────────────────────────────────
|
|
1923
|
+
/**
|
|
1924
|
+
* Build a legacy Transaction to register a CollectFeeOrder on-chain.
|
|
1925
|
+
* Must be signed and sent before calling buildBatchCollectRedeemEarlyTx.
|
|
1926
|
+
*
|
|
1927
|
+
* Flow: [Ed25519 ix (1 user sig) + register_collect_fee_order ix]
|
|
1928
|
+
* Caller signs with payer keypair and sends.
|
|
1929
|
+
*/
|
|
1930
|
+
async buildRegisterCollectFeeOrderTx(signedOrder, payer) {
|
|
1931
|
+
const { order } = signedOrder;
|
|
1932
|
+
const [collectFeeOrderRecord] = PDA.collectFeeOrderRecord(order.user, order.nonce, this.programIds);
|
|
1933
|
+
const ed25519Ix = buildBatchedCollectFeeEd25519Instruction([signedOrder]);
|
|
1934
|
+
const registerIx = await this.program.methods.registerCollectFeeOrder(order.nonce).accounts({
|
|
1935
|
+
payer,
|
|
1936
|
+
clobConfig: this.configPda(),
|
|
1937
|
+
ixSysvar: IX_SYSVAR,
|
|
1938
|
+
orderSigner: order.user,
|
|
1939
|
+
collectFeeOrderRecord,
|
|
1940
|
+
systemProgram: SystemProgram.programId
|
|
1941
|
+
}).instruction();
|
|
1942
|
+
const { blockhash } = await this.provider.connection.getLatestBlockhash();
|
|
1943
|
+
const tx = new Transaction();
|
|
1944
|
+
tx.recentBlockhash = blockhash;
|
|
1945
|
+
tx.feePayer = payer;
|
|
1946
|
+
tx.add(ed25519Ix, registerIx);
|
|
1947
|
+
return tx;
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Register a CollectFeeOrder on-chain and send immediately (operator-signed flow).
|
|
1951
|
+
* Idempotent — skips if PDA already exists.
|
|
1952
|
+
*/
|
|
1953
|
+
async registerCollectFeeOrderIfNeeded(signedOrder) {
|
|
1954
|
+
const [pda] = PDA.collectFeeOrderRecord(
|
|
1955
|
+
signedOrder.order.user,
|
|
1956
|
+
signedOrder.order.nonce,
|
|
1957
|
+
this.programIds
|
|
1958
|
+
);
|
|
1959
|
+
const existing = await this.program.account.collectFeeOrderRecord?.fetchNullable(pda);
|
|
1960
|
+
if (!existing) {
|
|
1961
|
+
const tx = await this.buildRegisterCollectFeeOrderTx(signedOrder, this.walletPubkey);
|
|
1962
|
+
await this._sendLegacyTx(tx.instructions);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1881
1965
|
/** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
|
|
1882
1966
|
async cancelOrder(nonce) {
|
|
1883
1967
|
const [orderRecord] = PDA.orderRecord(this.walletPubkey, nonce, this.programIds);
|
|
@@ -2460,6 +2544,13 @@ ${logs.join("\n")}`);
|
|
|
2460
2544
|
if (yIx) hookInitIxs.push(yIx);
|
|
2461
2545
|
if (nIx) hookInitIxs.push(nIx);
|
|
2462
2546
|
}
|
|
2547
|
+
const oracleVaultInitIx = await this.buildInitOracleVaultIfNeeded(
|
|
2548
|
+
t.condition,
|
|
2549
|
+
collateralMint,
|
|
2550
|
+
t.fee,
|
|
2551
|
+
payer
|
|
2552
|
+
);
|
|
2553
|
+
const preIxs = oracleVaultInitIx ? [...hookInitIxs, oracleVaultInitIx] : hookInitIxs;
|
|
2463
2554
|
if (t.tokenId === m0.tokenId) {
|
|
2464
2555
|
let buySignedOrder, sellCandidates;
|
|
2465
2556
|
if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
|
|
@@ -2479,7 +2570,7 @@ ${logs.join("\n")}`);
|
|
|
2479
2570
|
opts,
|
|
2480
2571
|
false
|
|
2481
2572
|
);
|
|
2482
|
-
return this._buildUnsignedVtx([...
|
|
2573
|
+
return this._buildUnsignedVtx([...preIxs, ...ixs3], alt, payer);
|
|
2483
2574
|
} else {
|
|
2484
2575
|
throw new InvalidParamError("COMPLEMENTARY requires one BUY and one or more SELLs on same tokenId");
|
|
2485
2576
|
}
|
|
@@ -2495,7 +2586,7 @@ ${logs.join("\n")}`);
|
|
|
2495
2586
|
operator,
|
|
2496
2587
|
opts
|
|
2497
2588
|
);
|
|
2498
|
-
return this._buildUnsignedVtx([...
|
|
2589
|
+
return this._buildUnsignedVtx([...preIxs, ...ixs2], alt, payer);
|
|
2499
2590
|
}
|
|
2500
2591
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
2501
2592
|
const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
|
|
@@ -2516,7 +2607,7 @@ ${logs.join("\n")}`);
|
|
|
2516
2607
|
]);
|
|
2517
2608
|
await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
|
|
2518
2609
|
const ix = allBuy ? await this._buildMintIx(taker, makers, collateralMint, operator, payer) : await this._buildMergeIx(taker, makers, collateralMint, operator, payer, opts);
|
|
2519
|
-
return this._buildUnsignedVtx([...
|
|
2610
|
+
return this._buildUnsignedVtx([...preIxs, ix], alt, payer);
|
|
2520
2611
|
}
|
|
2521
2612
|
await Promise.all([
|
|
2522
2613
|
this.registerOrderIfNeeded(taker),
|
|
@@ -2528,17 +2619,19 @@ ${logs.join("\n")}`);
|
|
|
2528
2619
|
const ix = allBuy ? await this._buildMintIx(yesMaker, [taker], collateralMint, operator, payer) : await this._buildMergeIx(yesMaker, [taker], collateralMint, operator, payer, opts);
|
|
2529
2620
|
ixs.push(ix);
|
|
2530
2621
|
}
|
|
2531
|
-
return this._buildUnsignedVtx([...
|
|
2622
|
+
return this._buildUnsignedVtx([...preIxs, ...ixs], alt, payer);
|
|
2532
2623
|
}
|
|
2533
2624
|
// ─── batchCollectRedeemEarly ─────────────────────────────────────────────────
|
|
2534
2625
|
/**
|
|
2535
2626
|
* Build VersionedTransaction for batchCollectRedeemEarly.
|
|
2536
2627
|
*
|
|
2537
|
-
*
|
|
2538
|
-
*
|
|
2539
|
-
* from that user, redeem via CTF, then distribute as fees.
|
|
2628
|
+
* Prerequisite: each user's CollectFeeOrder must be registered on-chain via
|
|
2629
|
+
* buildRegisterCollectFeeOrderTx (one tx per user).
|
|
2540
2630
|
*
|
|
2541
|
-
*
|
|
2631
|
+
* Flow: batchCollectRedeemEarly ix reads CollectFeeOrderRecord PDAs — no Ed25519 inline.
|
|
2632
|
+
* No tx-size limit from signatures, supports 10+ orders in one tx.
|
|
2633
|
+
*
|
|
2634
|
+
* @param signedOrders - Array of { order, signature } (used to derive record PDAs)
|
|
2542
2635
|
* @param condition - Market condition PDA
|
|
2543
2636
|
* @param outcomeIndex - 0 = NO wins, 1 = YES wins
|
|
2544
2637
|
* @param operator - Whitelisted operator pubkey (must sign)
|
|
@@ -2564,9 +2657,11 @@ ${logs.join("\n")}`);
|
|
|
2564
2657
|
const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
|
|
2565
2658
|
const userAccounts = [];
|
|
2566
2659
|
for (const { order } of signedOrders) {
|
|
2660
|
+
const [collectFeeOrderRecord] = PDA.collectFeeOrderRecord(order.user, order.nonce, this.programIds);
|
|
2567
2661
|
const userTokenAta = getAssociatedTokenAddressSync(outcomeMint, order.user, false, TOKEN_2022_PROGRAM_ID);
|
|
2568
2662
|
const [userPosition] = PDA.position(condition, outcomeIndex, order.user, this.programIds);
|
|
2569
2663
|
userAccounts.push(
|
|
2664
|
+
{ pubkey: collectFeeOrderRecord, isSigner: false, isWritable: true },
|
|
2570
2665
|
{ pubkey: order.user, isSigner: false, isWritable: false },
|
|
2571
2666
|
{ pubkey: userTokenAta, isSigner: false, isWritable: true },
|
|
2572
2667
|
{ pubkey: userPosition, isSigner: false, isWritable: true }
|
|
@@ -2603,11 +2698,7 @@ ${logs.join("\n")}`);
|
|
|
2603
2698
|
const ix = await this.hookClient.buildInitHookIxIfNeeded(outcomeMint, payer);
|
|
2604
2699
|
if (ix) hookInitIxs.push(ix);
|
|
2605
2700
|
}
|
|
2606
|
-
const ed25519Ix = buildBatchedCollectFeeEd25519Instruction(signedOrders);
|
|
2607
|
-
const ed25519IxIndex = 2 + hookInitIxs.length;
|
|
2608
2701
|
const collectIx = await this.program.methods.batchCollectRedeemEarly(
|
|
2609
|
-
ed25519IxIndex,
|
|
2610
|
-
// ix_index: adjusted for any prepended hook init ixs
|
|
2611
2702
|
signedOrders.length,
|
|
2612
2703
|
outcomeIndex
|
|
2613
2704
|
).accounts({
|
|
@@ -2624,14 +2715,96 @@ ${logs.join("\n")}`);
|
|
|
2624
2715
|
clobNoAta,
|
|
2625
2716
|
clobYesPosition,
|
|
2626
2717
|
clobNoPosition,
|
|
2627
|
-
ixSysvar: IX_SYSVAR,
|
|
2628
2718
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
2629
2719
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2630
2720
|
token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
2631
2721
|
systemProgram: SystemProgram.programId
|
|
2632
2722
|
}).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
|
|
2633
|
-
const alt = opts?.lookupTable ??
|
|
2634
|
-
return this._buildUnsignedVtx([...hookInitIxs,
|
|
2723
|
+
const alt = opts?.lookupTable ?? await this.buildAltForCollectBatch(condition, payer, collateralMint, signedOrders, outcomeIndex);
|
|
2724
|
+
return this._buildUnsignedVtx([...hookInitIxs, collectIx], alt, payer);
|
|
2725
|
+
}
|
|
2726
|
+
/**
|
|
2727
|
+
* Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
|
|
2728
|
+
* remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
|
|
2729
|
+
*/
|
|
2730
|
+
async buildAltForCollectBatch(condition, payer, collateralMint, signedOrders, outcomeIndex) {
|
|
2731
|
+
const userKeys = signedOrders.map((o) => o.order.user.toBase58()).sort((a, b) => a.localeCompare(b)).join(",");
|
|
2732
|
+
const cacheKey = `${condition.toBase58()}:collect:${userKeys}`;
|
|
2733
|
+
if (this._altCache.has(cacheKey)) return this._altCache.get(cacheKey);
|
|
2734
|
+
const { connection } = this.provider;
|
|
2735
|
+
const clobConfigPda = this.configPda();
|
|
2736
|
+
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
2737
|
+
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
2738
|
+
const outcomeMint = outcomeIndex === 1 ? yesMint : noMint;
|
|
2739
|
+
const [extraAccountMeta] = PDA.extraAccountMetaList(outcomeMint, this.programIds);
|
|
2740
|
+
const [hookConfig] = PDA.hookConfig(this.programIds);
|
|
2741
|
+
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
2742
|
+
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
2743
|
+
const clobYesAta = getAssociatedTokenAddressSync(yesMint, clobConfigPda, true, TOKEN_2022_PROGRAM_ID);
|
|
2744
|
+
const clobNoAta = getAssociatedTokenAddressSync(noMint, clobConfigPda, true, TOKEN_2022_PROGRAM_ID);
|
|
2745
|
+
const [clobYesPos] = PDA.position(condition, 1, clobConfigPda, this.programIds);
|
|
2746
|
+
const [clobNoPos] = PDA.position(condition, 0, clobConfigPda, this.programIds);
|
|
2747
|
+
const feeRecipientAddr = (await this.fetchConfig())?.feeRecipient;
|
|
2748
|
+
const addresses = [
|
|
2749
|
+
this.programIds.clobExchange,
|
|
2750
|
+
this.programIds.conditionalTokens,
|
|
2751
|
+
this.programIds.hook,
|
|
2752
|
+
TOKEN_PROGRAM_ID,
|
|
2753
|
+
TOKEN_2022_PROGRAM_ID,
|
|
2754
|
+
SystemProgram.programId,
|
|
2755
|
+
clobConfigPda,
|
|
2756
|
+
hookConfig,
|
|
2757
|
+
condition,
|
|
2758
|
+
yesMint,
|
|
2759
|
+
noMint,
|
|
2760
|
+
extraAccountMeta,
|
|
2761
|
+
collateralVault,
|
|
2762
|
+
vaultTokenAccount,
|
|
2763
|
+
clobYesAta,
|
|
2764
|
+
clobNoAta,
|
|
2765
|
+
clobYesPos,
|
|
2766
|
+
clobNoPos
|
|
2767
|
+
];
|
|
2768
|
+
if (feeRecipientAddr) addresses.push(feeRecipientAddr);
|
|
2769
|
+
if (this.feeConfigOwner && this.programIds.feeManagement) {
|
|
2770
|
+
const companyAddr = await this.companyAddress();
|
|
2771
|
+
const refVault = await this.referralVault();
|
|
2772
|
+
addresses.push(this.programIds.feeManagement);
|
|
2773
|
+
addresses.push(PDA.feeConfig(this.feeConfigOwner, this.programIds)[0]);
|
|
2774
|
+
addresses.push(PDA.marketFeeOverride(condition, this.programIds)[0]);
|
|
2775
|
+
if (companyAddr) addresses.push(getAssociatedTokenAddressSync(collateralMint, companyAddr));
|
|
2776
|
+
if (refVault) addresses.push(refVault);
|
|
2777
|
+
const oracleVault = await this.getMarketOracleVault(condition, collateralMint) ?? payer;
|
|
2778
|
+
addresses.push(oracleVault);
|
|
2779
|
+
}
|
|
2780
|
+
for (const { order } of signedOrders) {
|
|
2781
|
+
const [collectFeeOrderRecord] = PDA.collectFeeOrderRecord(order.user, order.nonce, this.programIds);
|
|
2782
|
+
const userTokenAta = getAssociatedTokenAddressSync(outcomeMint, order.user, false, TOKEN_2022_PROGRAM_ID);
|
|
2783
|
+
const [userPosition] = PDA.position(condition, outcomeIndex, order.user, this.programIds);
|
|
2784
|
+
addresses.push(collectFeeOrderRecord, order.user, userTokenAta, userPosition);
|
|
2785
|
+
}
|
|
2786
|
+
const slot = await connection.getSlot("finalized");
|
|
2787
|
+
const [createIx, altAddress] = AddressLookupTableProgram.createLookupTable(
|
|
2788
|
+
{ authority: payer, payer, recentSlot: slot }
|
|
2789
|
+
);
|
|
2790
|
+
const BATCH = 30;
|
|
2791
|
+
const extendIxs = [];
|
|
2792
|
+
for (let i = 0; i < addresses.length; i += BATCH) {
|
|
2793
|
+
extendIxs.push(AddressLookupTableProgram.extendLookupTable(
|
|
2794
|
+
{ payer, authority: payer, lookupTable: altAddress, addresses: addresses.slice(i, i + BATCH) }
|
|
2795
|
+
));
|
|
2796
|
+
}
|
|
2797
|
+
await this._sendLegacyTx([createIx, extendIxs[0]]);
|
|
2798
|
+
for (let i = 1; i < extendIxs.length; i++) await this._sendLegacyTx([extendIxs[i]]);
|
|
2799
|
+
for (let attempt = 0; attempt < 30; attempt++) {
|
|
2800
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
2801
|
+
const res = await connection.getAddressLookupTable(altAddress);
|
|
2802
|
+
if (res.value && res.value.state.addresses.length === addresses.length) {
|
|
2803
|
+
this._altCache.set(cacheKey, res.value);
|
|
2804
|
+
return res.value;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
throw new Error(`ALT ${altAddress.toBase58()} not active after 30s`);
|
|
2635
2808
|
}
|
|
2636
2809
|
/**
|
|
2637
2810
|
* Build ALT with static accounts for a condition — no order-specific PDAs needed.
|
|
@@ -9394,7 +9567,8 @@ var clob_exchange_default = {
|
|
|
9394
9567
|
name: "batch_collect_redeem_early",
|
|
9395
9568
|
docs: [
|
|
9396
9569
|
"Batch collect fee tokens from winning users after question resolution,",
|
|
9397
|
-
"redeem them via CTF, and distribute USDS via fee_management."
|
|
9570
|
+
"redeem them via CTF, and distribute USDS via fee_management.",
|
|
9571
|
+
"Requires each user's CollectFeeOrderRecord to be registered via register_collect_fee_order."
|
|
9398
9572
|
],
|
|
9399
9573
|
discriminator: [
|
|
9400
9574
|
87,
|
|
@@ -9504,7 +9678,7 @@ var clob_exchange_default = {
|
|
|
9504
9678
|
{
|
|
9505
9679
|
name: "clob_yes_ata",
|
|
9506
9680
|
docs: [
|
|
9507
|
-
"CLOB's YES ATA (Token-2022) \u2014 must be pre-initialized
|
|
9681
|
+
"CLOB's YES ATA (Token-2022) \u2014 must be pre-initialized."
|
|
9508
9682
|
],
|
|
9509
9683
|
writable: true
|
|
9510
9684
|
},
|
|
@@ -9523,9 +9697,6 @@ var clob_exchange_default = {
|
|
|
9523
9697
|
name: "clob_no_position",
|
|
9524
9698
|
writable: true
|
|
9525
9699
|
},
|
|
9526
|
-
{
|
|
9527
|
-
name: "ix_sysvar"
|
|
9528
|
-
},
|
|
9529
9700
|
{
|
|
9530
9701
|
name: "conditional_tokens_program",
|
|
9531
9702
|
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
@@ -9544,10 +9715,6 @@ var clob_exchange_default = {
|
|
|
9544
9715
|
}
|
|
9545
9716
|
],
|
|
9546
9717
|
args: [
|
|
9547
|
-
{
|
|
9548
|
-
name: "ix_index",
|
|
9549
|
-
type: "u8"
|
|
9550
|
-
},
|
|
9551
9718
|
{
|
|
9552
9719
|
name: "order_count",
|
|
9553
9720
|
type: "u8"
|
|
@@ -10493,6 +10660,105 @@ var clob_exchange_default = {
|
|
|
10493
10660
|
}
|
|
10494
10661
|
]
|
|
10495
10662
|
},
|
|
10663
|
+
{
|
|
10664
|
+
name: "register_collect_fee_order",
|
|
10665
|
+
docs: [
|
|
10666
|
+
"Register a signed CollectFeeOrder on-chain (Ed25519 verify at registration time).",
|
|
10667
|
+
"ix[0] must be Ed25519 precompile with 1 entry for order.user.",
|
|
10668
|
+
"Call once per user before batch_collect_redeem_early."
|
|
10669
|
+
],
|
|
10670
|
+
discriminator: [
|
|
10671
|
+
63,
|
|
10672
|
+
26,
|
|
10673
|
+
202,
|
|
10674
|
+
98,
|
|
10675
|
+
195,
|
|
10676
|
+
2,
|
|
10677
|
+
211,
|
|
10678
|
+
36
|
|
10679
|
+
],
|
|
10680
|
+
accounts: [
|
|
10681
|
+
{
|
|
10682
|
+
name: "payer",
|
|
10683
|
+
writable: true,
|
|
10684
|
+
signer: true
|
|
10685
|
+
},
|
|
10686
|
+
{
|
|
10687
|
+
name: "clob_config",
|
|
10688
|
+
pda: {
|
|
10689
|
+
seeds: [
|
|
10690
|
+
{
|
|
10691
|
+
kind: "const",
|
|
10692
|
+
value: [
|
|
10693
|
+
99,
|
|
10694
|
+
108,
|
|
10695
|
+
111,
|
|
10696
|
+
98,
|
|
10697
|
+
95,
|
|
10698
|
+
99,
|
|
10699
|
+
111,
|
|
10700
|
+
110,
|
|
10701
|
+
102,
|
|
10702
|
+
105,
|
|
10703
|
+
103
|
|
10704
|
+
]
|
|
10705
|
+
}
|
|
10706
|
+
]
|
|
10707
|
+
}
|
|
10708
|
+
},
|
|
10709
|
+
{
|
|
10710
|
+
name: "ix_sysvar",
|
|
10711
|
+
address: "Sysvar1nstructions1111111111111111111111111"
|
|
10712
|
+
},
|
|
10713
|
+
{
|
|
10714
|
+
name: "order_signer"
|
|
10715
|
+
},
|
|
10716
|
+
{
|
|
10717
|
+
name: "collect_fee_order_record",
|
|
10718
|
+
writable: true,
|
|
10719
|
+
pda: {
|
|
10720
|
+
seeds: [
|
|
10721
|
+
{
|
|
10722
|
+
kind: "const",
|
|
10723
|
+
value: [
|
|
10724
|
+
99,
|
|
10725
|
+
111,
|
|
10726
|
+
108,
|
|
10727
|
+
108,
|
|
10728
|
+
101,
|
|
10729
|
+
99,
|
|
10730
|
+
116,
|
|
10731
|
+
95,
|
|
10732
|
+
111,
|
|
10733
|
+
114,
|
|
10734
|
+
100,
|
|
10735
|
+
101,
|
|
10736
|
+
114
|
|
10737
|
+
]
|
|
10738
|
+
},
|
|
10739
|
+
{
|
|
10740
|
+
kind: "account",
|
|
10741
|
+
path: "order_signer"
|
|
10742
|
+
},
|
|
10743
|
+
{
|
|
10744
|
+
kind: "arg",
|
|
10745
|
+
path: "nonce"
|
|
10746
|
+
}
|
|
10747
|
+
]
|
|
10748
|
+
}
|
|
10749
|
+
},
|
|
10750
|
+
{
|
|
10751
|
+
name: "system_program",
|
|
10752
|
+
address: "11111111111111111111111111111111"
|
|
10753
|
+
}
|
|
10754
|
+
],
|
|
10755
|
+
args: [
|
|
10756
|
+
{
|
|
10757
|
+
name: "nonce",
|
|
10758
|
+
type: "u64"
|
|
10759
|
+
}
|
|
10760
|
+
]
|
|
10761
|
+
},
|
|
10496
10762
|
{
|
|
10497
10763
|
name: "register_order",
|
|
10498
10764
|
docs: [
|
|
@@ -10783,6 +11049,19 @@ var clob_exchange_default = {
|
|
|
10783
11049
|
160
|
|
10784
11050
|
]
|
|
10785
11051
|
},
|
|
11052
|
+
{
|
|
11053
|
+
name: "CollectFeeOrderRecord",
|
|
11054
|
+
discriminator: [
|
|
11055
|
+
145,
|
|
11056
|
+
140,
|
|
11057
|
+
193,
|
|
11058
|
+
74,
|
|
11059
|
+
12,
|
|
11060
|
+
98,
|
|
11061
|
+
74,
|
|
11062
|
+
130
|
|
11063
|
+
]
|
|
11064
|
+
},
|
|
10786
11065
|
{
|
|
10787
11066
|
name: "OrderStatus",
|
|
10788
11067
|
discriminator: [
|
|
@@ -10992,6 +11271,53 @@ var clob_exchange_default = {
|
|
|
10992
11271
|
]
|
|
10993
11272
|
}
|
|
10994
11273
|
},
|
|
11274
|
+
{
|
|
11275
|
+
name: "CollectFeeOrderRecord",
|
|
11276
|
+
docs: [
|
|
11277
|
+
"On-chain record of a signed CollectFeeOrder.",
|
|
11278
|
+
"Created by `register_collect_fee_order` after Ed25519 verification.",
|
|
11279
|
+
"Read and marked collected by `batch_collect_redeem_early`.",
|
|
11280
|
+
"",
|
|
11281
|
+
'PDA seeds: [b"collect_order", user, nonce_le_bytes]'
|
|
11282
|
+
],
|
|
11283
|
+
type: {
|
|
11284
|
+
kind: "struct",
|
|
11285
|
+
fields: [
|
|
11286
|
+
{
|
|
11287
|
+
name: "user",
|
|
11288
|
+
type: "pubkey"
|
|
11289
|
+
},
|
|
11290
|
+
{
|
|
11291
|
+
name: "condition",
|
|
11292
|
+
type: "pubkey"
|
|
11293
|
+
},
|
|
11294
|
+
{
|
|
11295
|
+
name: "token_mint",
|
|
11296
|
+
type: "pubkey"
|
|
11297
|
+
},
|
|
11298
|
+
{
|
|
11299
|
+
name: "amount",
|
|
11300
|
+
type: "u64"
|
|
11301
|
+
},
|
|
11302
|
+
{
|
|
11303
|
+
name: "nonce",
|
|
11304
|
+
type: "u64"
|
|
11305
|
+
},
|
|
11306
|
+
{
|
|
11307
|
+
name: "expiry",
|
|
11308
|
+
type: "i64"
|
|
11309
|
+
},
|
|
11310
|
+
{
|
|
11311
|
+
name: "is_collected",
|
|
11312
|
+
type: "bool"
|
|
11313
|
+
},
|
|
11314
|
+
{
|
|
11315
|
+
name: "bump",
|
|
11316
|
+
type: "u8"
|
|
11317
|
+
}
|
|
11318
|
+
]
|
|
11319
|
+
}
|
|
11320
|
+
},
|
|
10995
11321
|
{
|
|
10996
11322
|
name: "ComplementaryMatchEvent",
|
|
10997
11323
|
type: {
|