@theliem/xmarket-sdk 3.3.0 → 3.3.1
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 +64 -63
- package/dist/index.d.ts +64 -63
- package/dist/index.js +836 -594
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +836 -594
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, SYSVAR_RENT_PUBKEY, ComputeBudgetProgram, TransactionInstruction, Ed25519Program, AddressLookupTableProgram, TransactionMessage, VersionedTransaction, Connection
|
|
1
|
+
import * as anchor5 from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, SYSVAR_RENT_PUBKEY, ComputeBudgetProgram, Transaction, TransactionInstruction, Ed25519Program, AddressLookupTableProgram, TransactionMessage, VersionedTransaction, Connection } from '@solana/web3.js';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
|
-
import { TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, createApproveInstruction } from '@solana/spl-token';
|
|
5
|
-
import
|
|
4
|
+
import { TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, createAssociatedTokenAccountIdempotentInstruction, createApproveInstruction } from '@solana/spl-token';
|
|
5
|
+
import BN5 from 'bn.js';
|
|
6
6
|
import * as nacl from 'tweetnacl';
|
|
7
7
|
|
|
8
8
|
// src/sdk.ts
|
|
@@ -145,6 +145,14 @@ var PDA = class {
|
|
|
145
145
|
programIds.clobExchange
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
|
+
static orderRecord(maker, nonce, programIds) {
|
|
149
|
+
const nonceBuf = Buffer.alloc(8);
|
|
150
|
+
nonceBuf.writeBigUInt64LE(BigInt(nonce.toString()));
|
|
151
|
+
return PublicKey.findProgramAddressSync(
|
|
152
|
+
[Buffer.from("order_record"), maker.toBuffer(), nonceBuf],
|
|
153
|
+
programIds.clobExchange
|
|
154
|
+
);
|
|
155
|
+
}
|
|
148
156
|
// ─── Fee Management ─────────────────────────────────────────────────────────
|
|
149
157
|
static feeConfig(owner, programIds) {
|
|
150
158
|
if (!programIds.feeManagement) throw new Error("feeManagement program ID not configured");
|
|
@@ -273,7 +281,7 @@ var OracleClient = class {
|
|
|
273
281
|
return this.program.methods.resolveQuestion(
|
|
274
282
|
Array.from(questionId),
|
|
275
283
|
outcomeCount,
|
|
276
|
-
payoutNumerators.map((n) => new
|
|
284
|
+
payoutNumerators.map((n) => new anchor5.BN(n))
|
|
277
285
|
).accounts({
|
|
278
286
|
reporter,
|
|
279
287
|
oracleConfig,
|
|
@@ -540,7 +548,7 @@ var MarketClient = class {
|
|
|
540
548
|
contentHash: Array.from(contentHash),
|
|
541
549
|
hookProgram: params.hookProgram,
|
|
542
550
|
authorizedClob: params.authorizedClob,
|
|
543
|
-
expirationTime: new
|
|
551
|
+
expirationTime: new anchor5.BN(params.expirationTime)
|
|
544
552
|
}).accounts({
|
|
545
553
|
creator,
|
|
546
554
|
payer,
|
|
@@ -608,6 +616,22 @@ var MarketClient = class {
|
|
|
608
616
|
config: this.configPda
|
|
609
617
|
}).transaction();
|
|
610
618
|
}
|
|
619
|
+
async growConfig(owner = this.walletPubkey, payer = owner) {
|
|
620
|
+
return this.program.methods.growConfig().accounts({
|
|
621
|
+
payer,
|
|
622
|
+
owner,
|
|
623
|
+
config: this.configPda,
|
|
624
|
+
systemProgram: SystemProgram.programId
|
|
625
|
+
}).transaction();
|
|
626
|
+
}
|
|
627
|
+
async restoreConfig(snapshot, owner = this.walletPubkey, payer = owner) {
|
|
628
|
+
return this.program.methods.restoreConfig(Array.from(snapshot)).accounts({
|
|
629
|
+
payer,
|
|
630
|
+
owner,
|
|
631
|
+
config: this.configPda,
|
|
632
|
+
systemProgram: SystemProgram.programId
|
|
633
|
+
}).transaction();
|
|
634
|
+
}
|
|
611
635
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
612
636
|
async fetchConfig() {
|
|
613
637
|
try {
|
|
@@ -1007,7 +1031,21 @@ var CtfClient = class {
|
|
|
1007
1031
|
const userYesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
|
|
1008
1032
|
const userNoAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
|
|
1009
1033
|
const userCollateral = getAssociatedTokenAddressSync(collateralMint, user);
|
|
1010
|
-
|
|
1034
|
+
const createYesAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1035
|
+
payer,
|
|
1036
|
+
userYesAta,
|
|
1037
|
+
user,
|
|
1038
|
+
yesMint,
|
|
1039
|
+
TOKEN_2022_PROGRAM_ID
|
|
1040
|
+
);
|
|
1041
|
+
const createNoAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1042
|
+
payer,
|
|
1043
|
+
userNoAta,
|
|
1044
|
+
user,
|
|
1045
|
+
noMint,
|
|
1046
|
+
TOKEN_2022_PROGRAM_ID
|
|
1047
|
+
);
|
|
1048
|
+
const redeemIx = await this.program.methods.redeemPositions().accounts({
|
|
1011
1049
|
user,
|
|
1012
1050
|
payer,
|
|
1013
1051
|
condition,
|
|
@@ -1023,14 +1061,17 @@ var CtfClient = class {
|
|
|
1023
1061
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1024
1062
|
token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
1025
1063
|
systemProgram: SystemProgram.programId
|
|
1026
|
-
}).
|
|
1064
|
+
}).instruction();
|
|
1065
|
+
const tx = new Transaction();
|
|
1066
|
+
tx.add(createYesAtaIx, createNoAtaIx, redeemIx);
|
|
1067
|
+
return tx;
|
|
1027
1068
|
}
|
|
1028
1069
|
/**
|
|
1029
1070
|
* Oracle directly resolves a condition with payout numerators.
|
|
1030
1071
|
* Bypasses QuestionMarket — only for oracle-owned conditions.
|
|
1031
1072
|
*/
|
|
1032
1073
|
async reportPayouts(condition, payoutNumerators) {
|
|
1033
|
-
const sig = await this.program.methods.reportPayouts(payoutNumerators.map((n) => new
|
|
1074
|
+
const sig = await this.program.methods.reportPayouts(payoutNumerators.map((n) => new anchor5.BN(n))).accounts({
|
|
1034
1075
|
oracle: this.walletPubkey,
|
|
1035
1076
|
condition
|
|
1036
1077
|
}).rpc();
|
|
@@ -1261,57 +1302,60 @@ var ClobClient = class {
|
|
|
1261
1302
|
}
|
|
1262
1303
|
/**
|
|
1263
1304
|
* Get or create an ALT for a condition.
|
|
1264
|
-
*
|
|
1265
|
-
* Subsequent calls for same condition: returns cached ALT instantly.
|
|
1266
|
-
* BE devs never interact with this — called automatically by matchOrders.
|
|
1305
|
+
* Includes order_record PDAs for taker + all makers so match tx stays under 1232 bytes.
|
|
1267
1306
|
*/
|
|
1268
|
-
async ensureAlt(condition, collateralMint,
|
|
1307
|
+
async ensureAlt(condition, collateralMint, takerSigned, makers) {
|
|
1269
1308
|
const cacheKey = condition.toBase58();
|
|
1270
1309
|
if (this._altCache.has(cacheKey)) {
|
|
1271
1310
|
return this._altCache.get(cacheKey);
|
|
1272
1311
|
}
|
|
1273
1312
|
const { connection } = this.provider;
|
|
1274
1313
|
const payer = this.walletPubkey;
|
|
1314
|
+
const taker = takerSigned.order.maker;
|
|
1315
|
+
const takerNonce = takerSigned.order.nonce;
|
|
1316
|
+
const tokenId = takerSigned.order.tokenId;
|
|
1275
1317
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
1318
|
+
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
1276
1319
|
const [extraAccountMeta] = PDA.extraAccountMetaList(yesMint, this.programIds);
|
|
1277
1320
|
const [hookConfig] = PDA.hookConfig(this.programIds);
|
|
1278
|
-
const [
|
|
1279
|
-
const [
|
|
1321
|
+
const [takerOrderStatus] = PDA.orderStatus(taker, takerNonce, this.programIds);
|
|
1322
|
+
const [takerOrderRecord] = PDA.orderRecord(taker, takerNonce, this.programIds);
|
|
1323
|
+
const [takerPosition] = PDA.position(condition, tokenId, taker, this.programIds);
|
|
1280
1324
|
const clobConfigPda = this.configPda();
|
|
1325
|
+
const outcomeMint = tokenId === 1 ? yesMint : noMint;
|
|
1281
1326
|
const feeRecipientAddr = (await this.fetchConfig())?.feeRecipient;
|
|
1282
1327
|
const addresses = [
|
|
1283
|
-
// instruction program IDs — must be in ALT to keep static keys minimal
|
|
1284
1328
|
Ed25519Program.programId,
|
|
1285
1329
|
this.programIds.clobExchange,
|
|
1286
|
-
// other programs
|
|
1287
1330
|
this.programIds.conditionalTokens,
|
|
1288
1331
|
this.programIds.hook,
|
|
1289
1332
|
TOKEN_PROGRAM_ID,
|
|
1290
1333
|
TOKEN_2022_PROGRAM_ID,
|
|
1291
1334
|
SystemProgram.programId,
|
|
1292
1335
|
SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1293
|
-
// config PDAs
|
|
1294
1336
|
clobConfigPda,
|
|
1295
1337
|
hookConfig,
|
|
1296
|
-
// condition PDAs
|
|
1297
1338
|
condition,
|
|
1298
1339
|
yesMint,
|
|
1340
|
+
noMint,
|
|
1299
1341
|
extraAccountMeta,
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
getAssociatedTokenAddressSync(
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1342
|
+
taker,
|
|
1343
|
+
getAssociatedTokenAddressSync(collateralMint, taker),
|
|
1344
|
+
getAssociatedTokenAddressSync(outcomeMint, taker, false, TOKEN_2022_PROGRAM_ID),
|
|
1345
|
+
takerPosition,
|
|
1346
|
+
takerOrderStatus,
|
|
1347
|
+
takerOrderRecord
|
|
1306
1348
|
];
|
|
1307
1349
|
if (feeRecipientAddr) addresses.push(feeRecipientAddr);
|
|
1308
1350
|
for (const m of makers) {
|
|
1309
1351
|
const seller = m.order.maker;
|
|
1310
|
-
const [sellerPos] = PDA.position(condition,
|
|
1352
|
+
const [sellerPos] = PDA.position(condition, tokenId, seller, this.programIds);
|
|
1311
1353
|
const [sellerStatus] = PDA.orderStatus(seller, m.order.nonce, this.programIds);
|
|
1354
|
+
const [sellerRecord] = PDA.orderRecord(seller, m.order.nonce, this.programIds);
|
|
1312
1355
|
addresses.push(
|
|
1313
1356
|
seller,
|
|
1314
|
-
|
|
1357
|
+
sellerRecord,
|
|
1358
|
+
getAssociatedTokenAddressSync(outcomeMint, seller, false, TOKEN_2022_PROGRAM_ID),
|
|
1315
1359
|
getAssociatedTokenAddressSync(collateralMint, seller),
|
|
1316
1360
|
sellerPos,
|
|
1317
1361
|
sellerStatus
|
|
@@ -1359,7 +1403,7 @@ var ClobClient = class {
|
|
|
1359
1403
|
}
|
|
1360
1404
|
throw new Error(`ALT ${altAddress.toBase58()} not active after 30s`);
|
|
1361
1405
|
}
|
|
1362
|
-
async
|
|
1406
|
+
async _sendLegacyTxSig(instructions) {
|
|
1363
1407
|
const { connection } = this.provider;
|
|
1364
1408
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1365
1409
|
const { Transaction: Transaction7 } = await import('@solana/web3.js');
|
|
@@ -1368,25 +1412,33 @@ var ClobClient = class {
|
|
|
1368
1412
|
tx.feePayer = this.walletPubkey;
|
|
1369
1413
|
tx.add(...instructions);
|
|
1370
1414
|
const signed = await this.provider.wallet.signTransaction(tx);
|
|
1371
|
-
const sig = await connection.sendRawTransaction(signed.serialize());
|
|
1372
|
-
await connection.confirmTransaction({ signature: sig, blockhash, lastValidBlockHeight }, "confirmed");
|
|
1415
|
+
const sig = await connection.sendRawTransaction(signed.serialize(), { skipPreflight: true });
|
|
1416
|
+
const result = await connection.confirmTransaction({ signature: sig, blockhash, lastValidBlockHeight }, "confirmed");
|
|
1417
|
+
if (result.value.err) {
|
|
1418
|
+
const txInfo = await connection.getTransaction(sig, { maxSupportedTransactionVersion: 0 });
|
|
1419
|
+
const logs = txInfo?.meta?.logMessages ?? [];
|
|
1420
|
+
const err = new Error(`Register tx failed: ${JSON.stringify(result.value.err)}
|
|
1421
|
+
${logs.join("\n")}`);
|
|
1422
|
+
err.logs = logs;
|
|
1423
|
+
throw err;
|
|
1424
|
+
}
|
|
1425
|
+
return sig;
|
|
1426
|
+
}
|
|
1427
|
+
async _sendLegacyTx(instructions) {
|
|
1428
|
+
await this._sendLegacyTxSig(instructions);
|
|
1373
1429
|
}
|
|
1374
1430
|
/**
|
|
1375
|
-
* Send a match transaction as versioned (v0).
|
|
1376
|
-
*
|
|
1377
|
-
* stay under the 1232-byte limit — required for match_complementary which
|
|
1378
|
-
* has ~25 accounts + 2 Ed25519 precompile instructions (~1697 bytes raw).
|
|
1379
|
-
*
|
|
1380
|
-
* If `whitelistedWallet` is provided and differs from `this.provider.wallet`,
|
|
1381
|
-
* both wallets sign the transaction (whitelisted operator + payer).
|
|
1431
|
+
* Send a match transaction as versioned (v0) with optional ALT.
|
|
1432
|
+
* Both operator wallet and payer (this.provider.wallet) sign.
|
|
1382
1433
|
*/
|
|
1383
1434
|
async sendMatchTx(instructions, lookupTable, whitelistedWallet) {
|
|
1384
1435
|
const { connection } = this.provider;
|
|
1385
1436
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1437
|
+
const cuLimit = ComputeBudgetProgram.setComputeUnitLimit({ units: 8e5 });
|
|
1386
1438
|
const message = new TransactionMessage({
|
|
1387
1439
|
payerKey: this.walletPubkey,
|
|
1388
1440
|
recentBlockhash: blockhash,
|
|
1389
|
-
instructions
|
|
1441
|
+
instructions: [cuLimit, ...instructions]
|
|
1390
1442
|
}).compileToV0Message(lookupTable ? [lookupTable] : []);
|
|
1391
1443
|
const vtx = new VersionedTransaction(message);
|
|
1392
1444
|
const signers = [this.provider.wallet.payer];
|
|
@@ -1395,19 +1447,67 @@ var ClobClient = class {
|
|
|
1395
1447
|
}
|
|
1396
1448
|
vtx.sign(signers);
|
|
1397
1449
|
const sig = await connection.sendRawTransaction(vtx.serialize(), {
|
|
1398
|
-
skipPreflight:
|
|
1450
|
+
skipPreflight: true
|
|
1399
1451
|
});
|
|
1400
|
-
await connection.confirmTransaction(
|
|
1452
|
+
const result = await connection.confirmTransaction(
|
|
1401
1453
|
{ signature: sig, blockhash, lastValidBlockHeight },
|
|
1402
1454
|
"confirmed"
|
|
1403
1455
|
);
|
|
1456
|
+
if (result.value.err) {
|
|
1457
|
+
const txInfo = await connection.getTransaction(sig, { maxSupportedTransactionVersion: 0 });
|
|
1458
|
+
const logs = txInfo?.meta?.logMessages ?? [];
|
|
1459
|
+
const err = new Error(`Match tx failed: ${JSON.stringify(result.value.err)}
|
|
1460
|
+
${logs.join("\n")}`);
|
|
1461
|
+
err.logs = logs;
|
|
1462
|
+
throw err;
|
|
1463
|
+
}
|
|
1404
1464
|
return sig;
|
|
1405
1465
|
}
|
|
1406
1466
|
configPda() {
|
|
1407
1467
|
return PDA.clobConfig(this.programIds)[0];
|
|
1408
1468
|
}
|
|
1409
|
-
// ───
|
|
1410
|
-
/**
|
|
1469
|
+
// ─── Register / Cancel ───────────────────────────────────────────────────────
|
|
1470
|
+
/**
|
|
1471
|
+
* Register a signed order on-chain.
|
|
1472
|
+
* Sends Ed25519 precompile ix + register_order ix in one legacy tx.
|
|
1473
|
+
* Called at match time (engine-triggered), not at order placement.
|
|
1474
|
+
*/
|
|
1475
|
+
async registerOrder(signed) {
|
|
1476
|
+
const nonce = signed.order.nonce;
|
|
1477
|
+
const orderSigner = signed.order.maker;
|
|
1478
|
+
const [orderRecord] = PDA.orderRecord(orderSigner, nonce, this.programIds);
|
|
1479
|
+
const ed25519Ix = buildBatchedEd25519Instruction([signed]);
|
|
1480
|
+
const [orderStatus] = PDA.orderStatus(orderSigner, nonce, this.programIds);
|
|
1481
|
+
const registerIx = await this.program.methods.registerOrder(nonce).accounts({
|
|
1482
|
+
payer: this.walletPubkey,
|
|
1483
|
+
clobConfig: this.configPda(),
|
|
1484
|
+
ixSysvar: IX_SYSVAR,
|
|
1485
|
+
orderSigner,
|
|
1486
|
+
orderRecord,
|
|
1487
|
+
orderStatus,
|
|
1488
|
+
systemProgram: SystemProgram.programId
|
|
1489
|
+
}).instruction();
|
|
1490
|
+
return this._sendLegacyTxSig([ed25519Ix, registerIx]);
|
|
1491
|
+
}
|
|
1492
|
+
/** Register only if the PDA doesn't exist yet (idempotent). */
|
|
1493
|
+
async registerOrderIfNeeded(signed) {
|
|
1494
|
+
const [pda] = PDA.orderRecord(signed.order.maker, signed.order.nonce, this.programIds);
|
|
1495
|
+
const existing = await this.program.account.signedOrderRecord.fetchNullable(pda);
|
|
1496
|
+
if (!existing) {
|
|
1497
|
+
await this.registerOrder(signed);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
/** Cancel an order — closes its OrderRecord PDA and returns rent to maker. */
|
|
1501
|
+
async cancelOrder(nonce) {
|
|
1502
|
+
const [orderRecord] = PDA.orderRecord(this.walletPubkey, nonce, this.programIds);
|
|
1503
|
+
const sig = await this.program.methods.cancelOrder(nonce).accounts({
|
|
1504
|
+
maker: this.walletPubkey,
|
|
1505
|
+
orderRecord,
|
|
1506
|
+
systemProgram: SystemProgram.programId
|
|
1507
|
+
}).rpc();
|
|
1508
|
+
return { signature: sig };
|
|
1509
|
+
}
|
|
1510
|
+
// ─── Admin ───────────────────────────────────────────────────────────────────
|
|
1411
1511
|
async initialize(operators, feeRecipient, feeRateBps) {
|
|
1412
1512
|
const sig = await this.program.methods.initializeClob(
|
|
1413
1513
|
operators,
|
|
@@ -1421,7 +1521,6 @@ var ClobClient = class {
|
|
|
1421
1521
|
}).rpc();
|
|
1422
1522
|
return { signature: sig };
|
|
1423
1523
|
}
|
|
1424
|
-
/** Admin adds an operator to the whitelist. */
|
|
1425
1524
|
async addOperator(operator) {
|
|
1426
1525
|
const sig = await this.program.methods.addOperator(operator).accounts({
|
|
1427
1526
|
admin: this.walletPubkey,
|
|
@@ -1429,7 +1528,6 @@ var ClobClient = class {
|
|
|
1429
1528
|
}).rpc();
|
|
1430
1529
|
return { signature: sig };
|
|
1431
1530
|
}
|
|
1432
|
-
/** Admin removes an operator from the whitelist. */
|
|
1433
1531
|
async removeOperator(operator) {
|
|
1434
1532
|
const sig = await this.program.methods.removeOperator(operator).accounts({
|
|
1435
1533
|
admin: this.walletPubkey,
|
|
@@ -1437,7 +1535,6 @@ var ClobClient = class {
|
|
|
1437
1535
|
}).rpc();
|
|
1438
1536
|
return { signature: sig };
|
|
1439
1537
|
}
|
|
1440
|
-
/** Admin pause/unpause the CLOB. */
|
|
1441
1538
|
async setPaused(paused) {
|
|
1442
1539
|
const sig = await this.program.methods.setPaused(paused).accounts({
|
|
1443
1540
|
admin: this.walletPubkey,
|
|
@@ -1445,9 +1542,6 @@ var ClobClient = class {
|
|
|
1445
1542
|
}).rpc();
|
|
1446
1543
|
return { signature: sig };
|
|
1447
1544
|
}
|
|
1448
|
-
/**
|
|
1449
|
-
* Emergency reset of CLOB config (upgrade authority only).
|
|
1450
|
-
*/
|
|
1451
1545
|
async forceResetClob(programData, newAdmin, newOperators, newFeeRecipient, newFeeRateBps) {
|
|
1452
1546
|
const sig = await this.program.methods.forceResetClob(newAdmin, newOperators, newFeeRecipient, newFeeRateBps).accounts({
|
|
1453
1547
|
upgradeAuthority: this.walletPubkey,
|
|
@@ -1456,31 +1550,44 @@ var ClobClient = class {
|
|
|
1456
1550
|
}).rpc();
|
|
1457
1551
|
return { signature: sig };
|
|
1458
1552
|
}
|
|
1553
|
+
// ─── Match instructions ───────────────────────────────────────────────────────
|
|
1459
1554
|
/**
|
|
1460
|
-
*
|
|
1555
|
+
* Build match_complementary instruction (no Ed25519 — OrderRecord PDAs used).
|
|
1461
1556
|
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
* remaining_accounts: [hook×3] [seller×5 × N]
|
|
1468
|
-
*/
|
|
1469
|
-
/** Build Ed25519 + matchComplementary instructions without sending.
|
|
1470
|
-
*
|
|
1471
|
-
* If `buySigned.order.fee > 0` and `feeClient` + `feeConfigOwner` are wired in,
|
|
1472
|
-
* automatically appends 5 fee_management remaining_accounts so the program CPIs
|
|
1473
|
-
* to distribute_fee internally. No manual `feeDistribute` param needed.
|
|
1557
|
+
* remaining_accounts layout:
|
|
1558
|
+
* [seller, order_record, seller_token, seller_collateral, seller_position, sell_status] × N
|
|
1559
|
+
* [extraAccountMetaList, hookConfig, hookProgram]
|
|
1560
|
+
* [feeManagement, fee_config, mkt_override, company_ata, oracle_vault] (when fee > 0)
|
|
1474
1561
|
*/
|
|
1475
|
-
async buildMatchComplementaryIxs(
|
|
1476
|
-
const condition =
|
|
1477
|
-
const tokenId =
|
|
1562
|
+
async buildMatchComplementaryIxs(takerSigned, makersSigned, collateralMint, feeRecipient, operator, opts) {
|
|
1563
|
+
const condition = takerSigned.order.condition;
|
|
1564
|
+
const tokenId = takerSigned.order.tokenId;
|
|
1565
|
+
const taker = takerSigned.order.maker;
|
|
1566
|
+
const takerNonce = takerSigned.order.nonce;
|
|
1567
|
+
const fillAmount = opts?.fillAmount ?? new anchor5.BN("18446744073709551615");
|
|
1478
1568
|
const [outcomeMint] = tokenId === 1 ? PDA.yesMint(condition, this.programIds) : PDA.noMint(condition, this.programIds);
|
|
1479
|
-
const
|
|
1480
|
-
const
|
|
1481
|
-
const
|
|
1482
|
-
const [
|
|
1483
|
-
const [
|
|
1569
|
+
const [takerOrderRecord] = PDA.orderRecord(taker, takerNonce, this.programIds);
|
|
1570
|
+
const takerCollateral = getAssociatedTokenAddressSync(collateralMint, taker);
|
|
1571
|
+
const takerTokenAccount = getAssociatedTokenAddressSync(outcomeMint, taker, false, TOKEN_2022_PROGRAM_ID);
|
|
1572
|
+
const [takerPosition] = PDA.position(condition, tokenId, taker, this.programIds);
|
|
1573
|
+
const [takerOrderStatus] = PDA.orderStatus(taker, takerNonce, this.programIds);
|
|
1574
|
+
const makerAccounts = [];
|
|
1575
|
+
for (const ms of makersSigned) {
|
|
1576
|
+
const seller = ms.order.maker;
|
|
1577
|
+
const [sellerRecord] = PDA.orderRecord(seller, ms.order.nonce, this.programIds);
|
|
1578
|
+
const sellerToken = getAssociatedTokenAddressSync(outcomeMint, seller, false, TOKEN_2022_PROGRAM_ID);
|
|
1579
|
+
const sellerCollateral = getAssociatedTokenAddressSync(collateralMint, seller);
|
|
1580
|
+
const [sellerPosition] = PDA.position(condition, tokenId, seller, this.programIds);
|
|
1581
|
+
const [sellerStatus] = PDA.orderStatus(seller, ms.order.nonce, this.programIds);
|
|
1582
|
+
makerAccounts.push(
|
|
1583
|
+
{ pubkey: seller, isSigner: false, isWritable: false },
|
|
1584
|
+
{ pubkey: sellerRecord, isSigner: false, isWritable: false },
|
|
1585
|
+
{ pubkey: sellerToken, isSigner: false, isWritable: true },
|
|
1586
|
+
{ pubkey: sellerCollateral, isSigner: false, isWritable: true },
|
|
1587
|
+
{ pubkey: sellerPosition, isSigner: false, isWritable: true },
|
|
1588
|
+
{ pubkey: sellerStatus, isSigner: false, isWritable: true }
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1484
1591
|
const [extraAccountMetaList] = PDA.extraAccountMetaList(outcomeMint, this.programIds);
|
|
1485
1592
|
const [hookConfig] = PDA.hookConfig(this.programIds);
|
|
1486
1593
|
const hookAccounts = [
|
|
@@ -1488,22 +1595,8 @@ var ClobClient = class {
|
|
|
1488
1595
|
{ pubkey: hookConfig, isSigner: false, isWritable: false },
|
|
1489
1596
|
{ pubkey: this.programIds.hook, isSigner: false, isWritable: false }
|
|
1490
1597
|
];
|
|
1491
|
-
const makerAccounts = makersSigned.flatMap((m) => {
|
|
1492
|
-
const seller = m.order.maker;
|
|
1493
|
-
const sellerTokenAccount = getAssociatedTokenAddressSync(outcomeMint, seller, false, TOKEN_2022_PROGRAM_ID);
|
|
1494
|
-
const [sellerPosition] = PDA.position(condition, tokenId, seller, this.programIds);
|
|
1495
|
-
const sellerCollateral = getAssociatedTokenAddressSync(collateralMint, seller);
|
|
1496
|
-
const [sellOrderStatus] = PDA.orderStatus(seller, m.order.nonce, this.programIds);
|
|
1497
|
-
return [
|
|
1498
|
-
{ pubkey: seller, isSigner: false, isWritable: false },
|
|
1499
|
-
{ pubkey: sellerTokenAccount, isSigner: false, isWritable: true },
|
|
1500
|
-
{ pubkey: sellerPosition, isSigner: false, isWritable: true },
|
|
1501
|
-
{ pubkey: sellerCollateral, isSigner: false, isWritable: true },
|
|
1502
|
-
{ pubkey: sellOrderStatus, isSigner: false, isWritable: true }
|
|
1503
|
-
];
|
|
1504
|
-
});
|
|
1505
1598
|
let feeAccounts = [];
|
|
1506
|
-
if (
|
|
1599
|
+
if (takerSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
1507
1600
|
const companyAddr = await this.companyAddress();
|
|
1508
1601
|
if (companyAddr) {
|
|
1509
1602
|
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
@@ -1516,31 +1609,38 @@ var ClobClient = class {
|
|
|
1516
1609
|
];
|
|
1517
1610
|
}
|
|
1518
1611
|
}
|
|
1519
|
-
const
|
|
1520
|
-
const ed25519Ix = buildBatchedEd25519Instruction([buySigned, ...makersSigned]);
|
|
1521
|
-
const matchIx = await this.program.methods.matchComplementary(buySigned.order.nonce, makerNonces).accounts({
|
|
1612
|
+
const matchIx = await this.program.methods.matchComplementary(takerNonce, fillAmount).accounts({
|
|
1522
1613
|
operator,
|
|
1523
1614
|
payer: this.walletPubkey,
|
|
1524
1615
|
clobConfig: this.configPda(),
|
|
1525
|
-
ixSysvar: IX_SYSVAR,
|
|
1526
1616
|
condition,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1617
|
+
taker,
|
|
1618
|
+
takerOrderRecord,
|
|
1619
|
+
takerCollateral,
|
|
1620
|
+
takerTokenAccount,
|
|
1621
|
+
takerPosition,
|
|
1622
|
+
takerOrderStatus,
|
|
1533
1623
|
feeRecipient,
|
|
1624
|
+
outcomeMint,
|
|
1534
1625
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
1535
1626
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1536
1627
|
token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
1537
1628
|
systemProgram: SystemProgram.programId
|
|
1538
|
-
}).remainingAccounts([...
|
|
1539
|
-
return [
|
|
1629
|
+
}).remainingAccounts([...makerAccounts, ...hookAccounts, ...feeAccounts]).instruction();
|
|
1630
|
+
return [matchIx];
|
|
1540
1631
|
}
|
|
1541
|
-
|
|
1632
|
+
/**
|
|
1633
|
+
* COMPLEMENTARY: 1 taker (BUY) + N makers (SELL), same tokenId.
|
|
1634
|
+
* Phase 1: register taker + all makers in parallel.
|
|
1635
|
+
* Phase 2: 1 atomic match tx.
|
|
1636
|
+
*/
|
|
1637
|
+
async matchComplementary(takerSigned, makersSigned, collateralMint, feeRecipient, operatorWallet, lookupTable, opts) {
|
|
1638
|
+
await Promise.all([
|
|
1639
|
+
this.registerOrderIfNeeded(takerSigned),
|
|
1640
|
+
...makersSigned.map((m) => this.registerOrderIfNeeded(m))
|
|
1641
|
+
]);
|
|
1542
1642
|
const ixs = await this.buildMatchComplementaryIxs(
|
|
1543
|
-
|
|
1643
|
+
takerSigned,
|
|
1544
1644
|
makersSigned,
|
|
1545
1645
|
collateralMint,
|
|
1546
1646
|
feeRecipient,
|
|
@@ -1551,160 +1651,167 @@ var ClobClient = class {
|
|
|
1551
1651
|
return { signature: sig };
|
|
1552
1652
|
}
|
|
1553
1653
|
/**
|
|
1554
|
-
* MINT
|
|
1654
|
+
* MINT: 1 YES buyer (taker) + N NO buyers (makers).
|
|
1655
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
1656
|
+
* Phase 2: 1 atomic match tx.
|
|
1555
1657
|
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
* ix[1+i] Ed25519(maker_i/NO buyer)
|
|
1559
|
-
* ix[N+1] match_mint_orders(yesNonce, makerNonces[])
|
|
1560
|
-
*
|
|
1561
|
-
* remaining_accounts: [maker×5 × N] (no hook accounts — mint_to doesn't fire hook)
|
|
1658
|
+
* remaining_accounts per NO maker (5):
|
|
1659
|
+
* [order_record, buyer_no_token, buyer_no_collateral, buyer_no_position, no_order_status]
|
|
1562
1660
|
*/
|
|
1563
|
-
async matchMintOrders(yesSigned,
|
|
1661
|
+
async matchMintOrders(yesSigned, noMakers, collateralMint, _feeRecipient, operatorWallet, lookupTable) {
|
|
1662
|
+
await Promise.all([
|
|
1663
|
+
this.registerOrderIfNeeded(yesSigned),
|
|
1664
|
+
...noMakers.map((m) => this.registerOrderIfNeeded(m))
|
|
1665
|
+
]);
|
|
1564
1666
|
const condition = yesSigned.order.condition;
|
|
1667
|
+
const taker = yesSigned.order.maker;
|
|
1668
|
+
const takerNonce = yesSigned.order.nonce;
|
|
1669
|
+
const fillAmount = new anchor5.BN("18446744073709551615");
|
|
1565
1670
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
1566
1671
|
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
1567
1672
|
const [mintAuthority] = PDA.mintAuthority(condition, this.programIds);
|
|
1568
1673
|
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
1569
1674
|
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
1570
|
-
const
|
|
1571
|
-
const
|
|
1572
|
-
const
|
|
1573
|
-
const [
|
|
1574
|
-
const [
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
const
|
|
1578
|
-
const
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
{ pubkey:
|
|
1585
|
-
{ pubkey:
|
|
1586
|
-
{ pubkey:
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
const
|
|
1592
|
-
|
|
1593
|
-
];
|
|
1594
|
-
const matchIx = await this.program.methods.matchMintOrders(yesSigned.order.nonce, makerNonces).accounts({
|
|
1595
|
-
operator,
|
|
1675
|
+
const [takerOrderRecord] = PDA.orderRecord(taker, takerNonce, this.programIds);
|
|
1676
|
+
const takerCollateral = getAssociatedTokenAddressSync(collateralMint, taker);
|
|
1677
|
+
const takerYesToken = getAssociatedTokenAddressSync(yesMint, taker, false, TOKEN_2022_PROGRAM_ID);
|
|
1678
|
+
const [takerYesPosition] = PDA.position(condition, 1, taker, this.programIds);
|
|
1679
|
+
const [takerOrderStatus] = PDA.orderStatus(taker, takerNonce, this.programIds);
|
|
1680
|
+
const remainingAccounts = [];
|
|
1681
|
+
for (const nm of noMakers) {
|
|
1682
|
+
const noMaker = nm.order.maker;
|
|
1683
|
+
const [noRecord] = PDA.orderRecord(noMaker, nm.order.nonce, this.programIds);
|
|
1684
|
+
const noToken = getAssociatedTokenAddressSync(noMint, noMaker, false, TOKEN_2022_PROGRAM_ID);
|
|
1685
|
+
const noCollateral = getAssociatedTokenAddressSync(collateralMint, noMaker);
|
|
1686
|
+
const [noPosition] = PDA.position(condition, 0, noMaker, this.programIds);
|
|
1687
|
+
const [noStatus] = PDA.orderStatus(noMaker, nm.order.nonce, this.programIds);
|
|
1688
|
+
remainingAccounts.push(
|
|
1689
|
+
{ pubkey: noRecord, isSigner: false, isWritable: false },
|
|
1690
|
+
{ pubkey: noToken, isSigner: false, isWritable: true },
|
|
1691
|
+
{ pubkey: noCollateral, isSigner: false, isWritable: true },
|
|
1692
|
+
{ pubkey: noPosition, isSigner: false, isWritable: true },
|
|
1693
|
+
{ pubkey: noStatus, isSigner: false, isWritable: true }
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount).accounts({
|
|
1697
|
+
operator: operatorWallet.publicKey,
|
|
1596
1698
|
payer: this.walletPubkey,
|
|
1597
1699
|
clobConfig: this.configPda(),
|
|
1598
|
-
ixSysvar: IX_SYSVAR,
|
|
1599
1700
|
condition,
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1701
|
+
taker,
|
|
1702
|
+
takerOrderRecord,
|
|
1703
|
+
takerCollateral,
|
|
1704
|
+
takerYesToken,
|
|
1705
|
+
takerYesPosition,
|
|
1706
|
+
takerOrderStatus,
|
|
1605
1707
|
collateralVault,
|
|
1606
1708
|
vaultTokenAccount,
|
|
1607
1709
|
yesMint,
|
|
1608
1710
|
noMint,
|
|
1609
1711
|
mintAuthority,
|
|
1712
|
+
clobAuthority: this.configPda(),
|
|
1610
1713
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
1611
1714
|
collateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
1612
1715
|
systemProgram: SystemProgram.programId
|
|
1613
|
-
}).remainingAccounts(
|
|
1614
|
-
const sig = await this.sendMatchTx(
|
|
1615
|
-
[...ed25519Ixs, matchIx],
|
|
1616
|
-
lookupTable,
|
|
1617
|
-
operatorWallet
|
|
1618
|
-
);
|
|
1716
|
+
}).remainingAccounts(remainingAccounts).instruction();
|
|
1717
|
+
const sig = await this.sendMatchTx([matchIx], lookupTable, operatorWallet);
|
|
1619
1718
|
return { signature: sig };
|
|
1620
1719
|
}
|
|
1621
1720
|
/**
|
|
1622
|
-
* MERGE
|
|
1623
|
-
*
|
|
1624
|
-
*
|
|
1625
|
-
* ix[0] Ed25519(taker/YES seller)
|
|
1626
|
-
* ix[1+i] Ed25519(maker_i/NO seller)
|
|
1627
|
-
* ix[N+1] match_merge_orders(yesNonce, makerNonces[])
|
|
1721
|
+
* MERGE: 1 YES seller (taker) + N NO sellers (makers).
|
|
1722
|
+
* Phase 1: register taker + all NO makers in parallel.
|
|
1723
|
+
* Phase 2: 1 atomic match tx.
|
|
1628
1724
|
*
|
|
1629
|
-
* remaining_accounts
|
|
1725
|
+
* remaining_accounts per NO maker (5):
|
|
1726
|
+
* [order_record, seller_no_token, seller_no_collateral, seller_no_position, no_order_status]
|
|
1727
|
+
* After all makers, optional 5 fee accounts.
|
|
1630
1728
|
*/
|
|
1631
|
-
async matchMergeOrders(yesSigned,
|
|
1729
|
+
async matchMergeOrders(yesSigned, noMakers, collateralMint, feeRecipient, operatorWallet, lookupTable, opts) {
|
|
1730
|
+
await Promise.all([
|
|
1731
|
+
this.registerOrderIfNeeded(yesSigned),
|
|
1732
|
+
...noMakers.map((m) => this.registerOrderIfNeeded(m))
|
|
1733
|
+
]);
|
|
1632
1734
|
const condition = yesSigned.order.condition;
|
|
1735
|
+
const sellerYes = yesSigned.order.maker;
|
|
1736
|
+
const takerNonce = yesSigned.order.nonce;
|
|
1737
|
+
const fillAmount = new anchor5.BN("18446744073709551615");
|
|
1633
1738
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
1634
1739
|
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
1740
|
+
const [mintAuthority] = PDA.mintAuthority(condition, this.programIds);
|
|
1635
1741
|
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
1636
1742
|
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
1637
|
-
const
|
|
1638
|
-
const
|
|
1639
|
-
const [
|
|
1640
|
-
const
|
|
1641
|
-
const [
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1644
|
-
const
|
|
1645
|
-
const [
|
|
1646
|
-
const
|
|
1647
|
-
const
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
{ pubkey:
|
|
1652
|
-
{ pubkey:
|
|
1653
|
-
{ pubkey:
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1743
|
+
const [takerOrderRecord] = PDA.orderRecord(sellerYes, takerNonce, this.programIds);
|
|
1744
|
+
const takerYesToken = getAssociatedTokenAddressSync(yesMint, sellerYes, false, TOKEN_2022_PROGRAM_ID);
|
|
1745
|
+
const [takerYesPosition] = PDA.position(condition, 1, sellerYes, this.programIds);
|
|
1746
|
+
const takerCollateral = getAssociatedTokenAddressSync(collateralMint, sellerYes);
|
|
1747
|
+
const [takerOrderStatus] = PDA.orderStatus(sellerYes, takerNonce, this.programIds);
|
|
1748
|
+
const remainingAccounts = [];
|
|
1749
|
+
for (const nm of noMakers) {
|
|
1750
|
+
const noMaker = nm.order.maker;
|
|
1751
|
+
const [noRecord] = PDA.orderRecord(noMaker, nm.order.nonce, this.programIds);
|
|
1752
|
+
const noToken = getAssociatedTokenAddressSync(noMint, noMaker, false, TOKEN_2022_PROGRAM_ID);
|
|
1753
|
+
const noCollateral = getAssociatedTokenAddressSync(collateralMint, noMaker);
|
|
1754
|
+
const [noPosition] = PDA.position(condition, 0, noMaker, this.programIds);
|
|
1755
|
+
const [noStatus] = PDA.orderStatus(noMaker, nm.order.nonce, this.programIds);
|
|
1756
|
+
remainingAccounts.push(
|
|
1757
|
+
{ pubkey: noRecord, isSigner: false, isWritable: false },
|
|
1758
|
+
{ pubkey: noToken, isSigner: false, isWritable: true },
|
|
1759
|
+
{ pubkey: noCollateral, isSigner: false, isWritable: true },
|
|
1760
|
+
{ pubkey: noPosition, isSigner: false, isWritable: true },
|
|
1761
|
+
{ pubkey: noStatus, isSigner: false, isWritable: true }
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
1765
|
+
const companyAddr = await this.companyAddress();
|
|
1766
|
+
if (companyAddr) {
|
|
1767
|
+
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
1768
|
+
remainingAccounts.push(
|
|
1769
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
1770
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
1771
|
+
{ pubkey: PDA.marketFeeOverride(condition, this.programIds)[0], isSigner: false, isWritable: false },
|
|
1772
|
+
{ pubkey: getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
1773
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
1774
|
+
);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount).accounts({
|
|
1778
|
+
operator: operatorWallet.publicKey,
|
|
1663
1779
|
payer: this.walletPubkey,
|
|
1664
1780
|
clobConfig: this.configPda(),
|
|
1665
|
-
ixSysvar: IX_SYSVAR,
|
|
1666
1781
|
condition,
|
|
1667
|
-
sellerYes,
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1782
|
+
taker: sellerYes,
|
|
1783
|
+
takerOrderRecord,
|
|
1784
|
+
takerYesToken,
|
|
1785
|
+
takerYesPosition,
|
|
1786
|
+
takerCollateral,
|
|
1787
|
+
takerOrderStatus,
|
|
1672
1788
|
collateralVault,
|
|
1673
1789
|
vaultTokenAccount,
|
|
1674
1790
|
yesMint,
|
|
1675
1791
|
noMint,
|
|
1792
|
+
mintAuthority,
|
|
1676
1793
|
feeRecipient,
|
|
1794
|
+
clobAuthority: this.configPda(),
|
|
1677
1795
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
1678
1796
|
collateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
1679
1797
|
systemProgram: SystemProgram.programId
|
|
1680
|
-
}).remainingAccounts(
|
|
1681
|
-
const sig = await this.sendMatchTx(
|
|
1682
|
-
[...ed25519Ixs, matchIx],
|
|
1683
|
-
lookupTable,
|
|
1684
|
-
operatorWallet
|
|
1685
|
-
);
|
|
1798
|
+
}).remainingAccounts(remainingAccounts).instruction();
|
|
1799
|
+
const sig = await this.sendMatchTx([matchIx], lookupTable, operatorWallet);
|
|
1686
1800
|
return { signature: sig };
|
|
1687
1801
|
}
|
|
1688
1802
|
/**
|
|
1689
|
-
* Auto-detect match type and execute
|
|
1803
|
+
* Auto-detect match type and execute 2-phase:
|
|
1804
|
+
* Phase 1 — register all orders (taker + makers) on-chain in parallel.
|
|
1805
|
+
* Phase 2 — 1 atomic match transaction.
|
|
1690
1806
|
*
|
|
1691
|
-
* Detection (pure, no RPC)
|
|
1692
|
-
* taker.tokenId === makers[0].tokenId:
|
|
1693
|
-
*
|
|
1694
|
-
* taker.tokenId !== makers[0].tokenId +
|
|
1695
|
-
*
|
|
1807
|
+
* Detection (pure, no RPC):
|
|
1808
|
+
* taker.tokenId === makers[0].tokenId:
|
|
1809
|
+
* taker BUY + all makers SELL → COMPLEMENTARY
|
|
1810
|
+
* taker.tokenId !== makers[0].tokenId + all BUY → MINT
|
|
1811
|
+
* taker.tokenId !== makers[0].tokenId + all SELL → MERGE
|
|
1696
1812
|
*
|
|
1697
|
-
*
|
|
1698
|
-
|
|
1699
|
-
/**
|
|
1700
|
-
* Auto-detect match type and execute in a single transaction.
|
|
1701
|
-
* ALT is managed automatically (created on first call per condition, cached thereafter).
|
|
1702
|
-
* feeRecipient and collateralMint are derived from on-chain config.
|
|
1703
|
-
* Fee distribution (distribute_fee CPI) fires automatically when order.fee > 0.
|
|
1704
|
-
*
|
|
1705
|
-
* @param opts.marketOracleVault Required for presale markets (is_admin=false).
|
|
1706
|
-
* Pass the ATA of the market_oracle PDA so 50% of fee goes there.
|
|
1707
|
-
* For admin markets (is_admin=true) omit — payer is used as placeholder (no transfer).
|
|
1813
|
+
* @param opts.marketOracleVault Oracle vault ATA for presale markets.
|
|
1814
|
+
* Omit for admin markets (payer used as placeholder).
|
|
1708
1815
|
*/
|
|
1709
1816
|
async matchOrders(taker, makers, opts) {
|
|
1710
1817
|
if (makers.length === 0) throw new InvalidParamError("At least 1 maker required");
|
|
@@ -1716,8 +1823,7 @@ var ClobClient = class {
|
|
|
1716
1823
|
const alt = await this.ensureAlt(
|
|
1717
1824
|
taker.order.condition,
|
|
1718
1825
|
collateralMint,
|
|
1719
|
-
taker
|
|
1720
|
-
taker.order.nonce,
|
|
1826
|
+
taker,
|
|
1721
1827
|
makers
|
|
1722
1828
|
);
|
|
1723
1829
|
const t = taker.order;
|
|
@@ -1728,9 +1834,6 @@ var ClobClient = class {
|
|
|
1728
1834
|
if (t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_SELL)) {
|
|
1729
1835
|
return this.matchComplementary(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
1730
1836
|
}
|
|
1731
|
-
if (t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_BUY)) {
|
|
1732
|
-
throw new InvalidParamError("COMPLEMENTARY N-maker: taker must be the BUY side");
|
|
1733
|
-
}
|
|
1734
1837
|
throw new InvalidParamError("COMPLEMENTARY requires taker=BUY, makers=SELL on same tokenId");
|
|
1735
1838
|
}
|
|
1736
1839
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
@@ -1739,7 +1842,7 @@ var ClobClient = class {
|
|
|
1739
1842
|
if (t.tokenId !== 1) throw new InvalidParamError("MINT/MERGE: taker must be YES (tokenId=1)");
|
|
1740
1843
|
if (!makers.every((m) => m.order.tokenId === 0)) throw new InvalidParamError("MINT/MERGE: makers must be NO (tokenId=0)");
|
|
1741
1844
|
if (allBuy) return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
|
|
1742
|
-
return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
|
|
1845
|
+
return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
1743
1846
|
}
|
|
1744
1847
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
1745
1848
|
async fetchConfig() {
|
|
@@ -1773,6 +1876,15 @@ var ClobClient = class {
|
|
|
1773
1876
|
return null;
|
|
1774
1877
|
}
|
|
1775
1878
|
}
|
|
1879
|
+
async fetchOrderRecord(maker, nonce) {
|
|
1880
|
+
try {
|
|
1881
|
+
const [pda] = PDA.orderRecord(maker, nonce, this.programIds);
|
|
1882
|
+
const acc = await this.program.account.signedOrderRecord.fetch(pda);
|
|
1883
|
+
return acc;
|
|
1884
|
+
} catch {
|
|
1885
|
+
return null;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1776
1888
|
};
|
|
1777
1889
|
var FeeManagementClient = class {
|
|
1778
1890
|
constructor(program, provider, programIds) {
|
|
@@ -2812,6 +2924,11 @@ var hook_default = {
|
|
|
2812
2924
|
name: "owner",
|
|
2813
2925
|
signer: true
|
|
2814
2926
|
},
|
|
2927
|
+
{
|
|
2928
|
+
name: "payer",
|
|
2929
|
+
writable: true,
|
|
2930
|
+
signer: true
|
|
2931
|
+
},
|
|
2815
2932
|
{
|
|
2816
2933
|
name: "hook_config",
|
|
2817
2934
|
writable: true,
|
|
@@ -2943,6 +3060,11 @@ var hook_default = {
|
|
|
2943
3060
|
name: "owner",
|
|
2944
3061
|
signer: true
|
|
2945
3062
|
},
|
|
3063
|
+
{
|
|
3064
|
+
name: "payer",
|
|
3065
|
+
writable: true,
|
|
3066
|
+
signer: true
|
|
3067
|
+
},
|
|
2946
3068
|
{
|
|
2947
3069
|
name: "hook_config",
|
|
2948
3070
|
writable: true,
|
|
@@ -3151,6 +3273,11 @@ var hook_default = {
|
|
|
3151
3273
|
name: "owner",
|
|
3152
3274
|
signer: true
|
|
3153
3275
|
},
|
|
3276
|
+
{
|
|
3277
|
+
name: "payer",
|
|
3278
|
+
writable: true,
|
|
3279
|
+
signer: true
|
|
3280
|
+
},
|
|
3154
3281
|
{
|
|
3155
3282
|
name: "hook_config",
|
|
3156
3283
|
writable: true,
|
|
@@ -3202,10 +3329,6 @@ var hook_default = {
|
|
|
3202
3329
|
types: [
|
|
3203
3330
|
{
|
|
3204
3331
|
name: "HookConfig",
|
|
3205
|
-
docs: [
|
|
3206
|
-
"Global config for the Hook program.",
|
|
3207
|
-
"Stores the whitelist of programs allowed to transfer YES/NO Token-2022 tokens."
|
|
3208
|
-
],
|
|
3209
3332
|
type: {
|
|
3210
3333
|
kind: "struct",
|
|
3211
3334
|
fields: [
|
|
@@ -3215,16 +3338,10 @@ var hook_default = {
|
|
|
3215
3338
|
},
|
|
3216
3339
|
{
|
|
3217
3340
|
name: "owner",
|
|
3218
|
-
docs: [
|
|
3219
|
-
"Owner who can update the whitelist"
|
|
3220
|
-
],
|
|
3221
3341
|
type: "pubkey"
|
|
3222
3342
|
},
|
|
3223
3343
|
{
|
|
3224
3344
|
name: "whitelist",
|
|
3225
|
-
docs: [
|
|
3226
|
-
"Programs allowed to initiate or receive YES/NO token transfers."
|
|
3227
|
-
],
|
|
3228
3345
|
type: {
|
|
3229
3346
|
array: [
|
|
3230
3347
|
"pubkey",
|
|
@@ -3238,16 +3355,10 @@ var hook_default = {
|
|
|
3238
3355
|
},
|
|
3239
3356
|
{
|
|
3240
3357
|
name: "is_frozen",
|
|
3241
|
-
docs: [
|
|
3242
|
-
"If true, whitelist can no longer be modified (locked forever)"
|
|
3243
|
-
],
|
|
3244
3358
|
type: "bool"
|
|
3245
3359
|
},
|
|
3246
3360
|
{
|
|
3247
3361
|
name: "bump",
|
|
3248
|
-
docs: [
|
|
3249
|
-
"Bump for this PDA"
|
|
3250
|
-
],
|
|
3251
3362
|
type: "u8"
|
|
3252
3363
|
},
|
|
3253
3364
|
{
|
|
@@ -4157,6 +4268,58 @@ var question_market_default = {
|
|
|
4157
4268
|
}
|
|
4158
4269
|
]
|
|
4159
4270
|
},
|
|
4271
|
+
{
|
|
4272
|
+
name: "grow_config",
|
|
4273
|
+
discriminator: [
|
|
4274
|
+
190,
|
|
4275
|
+
5,
|
|
4276
|
+
0,
|
|
4277
|
+
130,
|
|
4278
|
+
65,
|
|
4279
|
+
253,
|
|
4280
|
+
94,
|
|
4281
|
+
228
|
|
4282
|
+
],
|
|
4283
|
+
accounts: [
|
|
4284
|
+
{
|
|
4285
|
+
name: "payer",
|
|
4286
|
+
writable: true,
|
|
4287
|
+
signer: true
|
|
4288
|
+
},
|
|
4289
|
+
{
|
|
4290
|
+
name: "owner",
|
|
4291
|
+
signer: true
|
|
4292
|
+
},
|
|
4293
|
+
{
|
|
4294
|
+
name: "config",
|
|
4295
|
+
writable: true,
|
|
4296
|
+
pda: {
|
|
4297
|
+
seeds: [
|
|
4298
|
+
{
|
|
4299
|
+
kind: "const",
|
|
4300
|
+
value: [
|
|
4301
|
+
99,
|
|
4302
|
+
111,
|
|
4303
|
+
110,
|
|
4304
|
+
102,
|
|
4305
|
+
105,
|
|
4306
|
+
103
|
|
4307
|
+
]
|
|
4308
|
+
},
|
|
4309
|
+
{
|
|
4310
|
+
kind: "account",
|
|
4311
|
+
path: "owner"
|
|
4312
|
+
}
|
|
4313
|
+
]
|
|
4314
|
+
}
|
|
4315
|
+
},
|
|
4316
|
+
{
|
|
4317
|
+
name: "system_program",
|
|
4318
|
+
address: "11111111111111111111111111111111"
|
|
4319
|
+
}
|
|
4320
|
+
],
|
|
4321
|
+
args: []
|
|
4322
|
+
},
|
|
4160
4323
|
{
|
|
4161
4324
|
name: "initialize",
|
|
4162
4325
|
discriminator: [
|
|
@@ -4525,6 +4688,63 @@ var question_market_default = {
|
|
|
4525
4688
|
}
|
|
4526
4689
|
]
|
|
4527
4690
|
},
|
|
4691
|
+
{
|
|
4692
|
+
name: "restore_config",
|
|
4693
|
+
discriminator: [
|
|
4694
|
+
95,
|
|
4695
|
+
203,
|
|
4696
|
+
226,
|
|
4697
|
+
92,
|
|
4698
|
+
60,
|
|
4699
|
+
222,
|
|
4700
|
+
192,
|
|
4701
|
+
221
|
|
4702
|
+
],
|
|
4703
|
+
accounts: [
|
|
4704
|
+
{
|
|
4705
|
+
name: "payer",
|
|
4706
|
+
writable: true,
|
|
4707
|
+
signer: true
|
|
4708
|
+
},
|
|
4709
|
+
{
|
|
4710
|
+
name: "owner",
|
|
4711
|
+
signer: true
|
|
4712
|
+
},
|
|
4713
|
+
{
|
|
4714
|
+
name: "config",
|
|
4715
|
+
writable: true,
|
|
4716
|
+
pda: {
|
|
4717
|
+
seeds: [
|
|
4718
|
+
{
|
|
4719
|
+
kind: "const",
|
|
4720
|
+
value: [
|
|
4721
|
+
99,
|
|
4722
|
+
111,
|
|
4723
|
+
110,
|
|
4724
|
+
102,
|
|
4725
|
+
105,
|
|
4726
|
+
103
|
|
4727
|
+
]
|
|
4728
|
+
},
|
|
4729
|
+
{
|
|
4730
|
+
kind: "account",
|
|
4731
|
+
path: "owner"
|
|
4732
|
+
}
|
|
4733
|
+
]
|
|
4734
|
+
}
|
|
4735
|
+
},
|
|
4736
|
+
{
|
|
4737
|
+
name: "system_program",
|
|
4738
|
+
address: "11111111111111111111111111111111"
|
|
4739
|
+
}
|
|
4740
|
+
],
|
|
4741
|
+
args: [
|
|
4742
|
+
{
|
|
4743
|
+
name: "snapshot",
|
|
4744
|
+
type: "bytes"
|
|
4745
|
+
}
|
|
4746
|
+
]
|
|
4747
|
+
},
|
|
4528
4748
|
{
|
|
4529
4749
|
name: "update_config",
|
|
4530
4750
|
discriminator: [
|
|
@@ -5557,7 +5777,7 @@ var question_market_default = {
|
|
|
5557
5777
|
type: {
|
|
5558
5778
|
array: [
|
|
5559
5779
|
"pubkey",
|
|
5560
|
-
|
|
5780
|
+
30
|
|
5561
5781
|
]
|
|
5562
5782
|
}
|
|
5563
5783
|
},
|
|
@@ -7659,9 +7879,6 @@ var clob_exchange_default = {
|
|
|
7659
7879
|
instructions: [
|
|
7660
7880
|
{
|
|
7661
7881
|
name: "add_operator",
|
|
7662
|
-
docs: [
|
|
7663
|
-
"Add an authorized operator (off-chain matching engine)."
|
|
7664
|
-
],
|
|
7665
7882
|
discriminator: [
|
|
7666
7883
|
149,
|
|
7667
7884
|
142,
|
|
@@ -7710,13 +7927,77 @@ var clob_exchange_default = {
|
|
|
7710
7927
|
]
|
|
7711
7928
|
},
|
|
7712
7929
|
{
|
|
7713
|
-
name: "
|
|
7930
|
+
name: "cancel_order",
|
|
7714
7931
|
docs: [
|
|
7715
|
-
"
|
|
7716
|
-
"Use when the original admin keypair is lost."
|
|
7932
|
+
"Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
|
|
7717
7933
|
],
|
|
7718
7934
|
discriminator: [
|
|
7719
|
-
|
|
7935
|
+
95,
|
|
7936
|
+
129,
|
|
7937
|
+
237,
|
|
7938
|
+
240,
|
|
7939
|
+
8,
|
|
7940
|
+
49,
|
|
7941
|
+
223,
|
|
7942
|
+
132
|
|
7943
|
+
],
|
|
7944
|
+
accounts: [
|
|
7945
|
+
{
|
|
7946
|
+
name: "maker",
|
|
7947
|
+
docs: [
|
|
7948
|
+
"Must be the order maker/signer"
|
|
7949
|
+
],
|
|
7950
|
+
signer: true
|
|
7951
|
+
},
|
|
7952
|
+
{
|
|
7953
|
+
name: "order_record",
|
|
7954
|
+
writable: true,
|
|
7955
|
+
pda: {
|
|
7956
|
+
seeds: [
|
|
7957
|
+
{
|
|
7958
|
+
kind: "const",
|
|
7959
|
+
value: [
|
|
7960
|
+
111,
|
|
7961
|
+
114,
|
|
7962
|
+
100,
|
|
7963
|
+
101,
|
|
7964
|
+
114,
|
|
7965
|
+
95,
|
|
7966
|
+
114,
|
|
7967
|
+
101,
|
|
7968
|
+
99,
|
|
7969
|
+
111,
|
|
7970
|
+
114,
|
|
7971
|
+
100
|
|
7972
|
+
]
|
|
7973
|
+
},
|
|
7974
|
+
{
|
|
7975
|
+
kind: "account",
|
|
7976
|
+
path: "maker"
|
|
7977
|
+
},
|
|
7978
|
+
{
|
|
7979
|
+
kind: "arg",
|
|
7980
|
+
path: "nonce"
|
|
7981
|
+
}
|
|
7982
|
+
]
|
|
7983
|
+
}
|
|
7984
|
+
},
|
|
7985
|
+
{
|
|
7986
|
+
name: "system_program",
|
|
7987
|
+
address: "11111111111111111111111111111111"
|
|
7988
|
+
}
|
|
7989
|
+
],
|
|
7990
|
+
args: [
|
|
7991
|
+
{
|
|
7992
|
+
name: "nonce",
|
|
7993
|
+
type: "u64"
|
|
7994
|
+
}
|
|
7995
|
+
]
|
|
7996
|
+
},
|
|
7997
|
+
{
|
|
7998
|
+
name: "force_reset_clob",
|
|
7999
|
+
discriminator: [
|
|
8000
|
+
96,
|
|
7720
8001
|
95,
|
|
7721
8002
|
187,
|
|
7722
8003
|
95,
|
|
@@ -7789,9 +8070,6 @@ var clob_exchange_default = {
|
|
|
7789
8070
|
},
|
|
7790
8071
|
{
|
|
7791
8072
|
name: "initialize_clob",
|
|
7792
|
-
docs: [
|
|
7793
|
-
"Initialize the CLOB global config."
|
|
7794
|
-
],
|
|
7795
8073
|
discriminator: [
|
|
7796
8074
|
35,
|
|
7797
8075
|
69,
|
|
@@ -7861,10 +8139,7 @@ var clob_exchange_default = {
|
|
|
7861
8139
|
{
|
|
7862
8140
|
name: "match_complementary",
|
|
7863
8141
|
docs: [
|
|
7864
|
-
"COMPLEMENTARY match:
|
|
7865
|
-
"Operator verifies signatures off-chain, executes atomically on-chain.",
|
|
7866
|
-
"",
|
|
7867
|
-
"Execution price = seller's ask (maker-fills-taker model)."
|
|
8142
|
+
"COMPLEMENTARY match: 1 taker (BUY) + N makers (SELL) via remaining_accounts."
|
|
7868
8143
|
],
|
|
7869
8144
|
discriminator: [
|
|
7870
8145
|
100,
|
|
@@ -7879,24 +8154,15 @@ var clob_exchange_default = {
|
|
|
7879
8154
|
accounts: [
|
|
7880
8155
|
{
|
|
7881
8156
|
name: "operator",
|
|
7882
|
-
docs: [
|
|
7883
|
-
"Authorized operator (whitelisted signer)"
|
|
7884
|
-
],
|
|
7885
8157
|
signer: true
|
|
7886
8158
|
},
|
|
7887
8159
|
{
|
|
7888
8160
|
name: "payer",
|
|
7889
|
-
docs: [
|
|
7890
|
-
"Fee payer \u2014 pays tx fee and PDA rent"
|
|
7891
|
-
],
|
|
7892
8161
|
writable: true,
|
|
7893
8162
|
signer: true
|
|
7894
8163
|
},
|
|
7895
8164
|
{
|
|
7896
8165
|
name: "clob_config",
|
|
7897
|
-
docs: [
|
|
7898
|
-
"CLOB config PDA \u2014 also used as the signing authority for CTF CPIs."
|
|
7899
|
-
],
|
|
7900
8166
|
writable: true,
|
|
7901
8167
|
pda: {
|
|
7902
8168
|
seeds: [
|
|
@@ -7919,27 +8185,14 @@ var clob_exchange_default = {
|
|
|
7919
8185
|
]
|
|
7920
8186
|
}
|
|
7921
8187
|
},
|
|
7922
|
-
{
|
|
7923
|
-
name: "ix_sysvar",
|
|
7924
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
7925
|
-
},
|
|
7926
8188
|
{
|
|
7927
8189
|
name: "condition"
|
|
7928
8190
|
},
|
|
7929
8191
|
{
|
|
7930
|
-
name: "
|
|
8192
|
+
name: "taker"
|
|
7931
8193
|
},
|
|
7932
8194
|
{
|
|
7933
|
-
name: "
|
|
7934
|
-
writable: true
|
|
7935
|
-
},
|
|
7936
|
-
{
|
|
7937
|
-
name: "buyer_token_account",
|
|
7938
|
-
writable: true
|
|
7939
|
-
},
|
|
7940
|
-
{
|
|
7941
|
-
name: "buy_order_status",
|
|
7942
|
-
writable: true,
|
|
8195
|
+
name: "taker_order_record",
|
|
7943
8196
|
pda: {
|
|
7944
8197
|
seeds: [
|
|
7945
8198
|
{
|
|
@@ -7949,33 +8202,41 @@ var clob_exchange_default = {
|
|
|
7949
8202
|
114,
|
|
7950
8203
|
100,
|
|
7951
8204
|
101,
|
|
7952
|
-
114
|
|
8205
|
+
114,
|
|
8206
|
+
95,
|
|
8207
|
+
114,
|
|
8208
|
+
101,
|
|
8209
|
+
99,
|
|
8210
|
+
111,
|
|
8211
|
+
114,
|
|
8212
|
+
100
|
|
7953
8213
|
]
|
|
7954
8214
|
},
|
|
7955
8215
|
{
|
|
7956
8216
|
kind: "account",
|
|
7957
|
-
path: "
|
|
8217
|
+
path: "taker"
|
|
7958
8218
|
},
|
|
7959
8219
|
{
|
|
7960
8220
|
kind: "arg",
|
|
7961
|
-
path: "
|
|
8221
|
+
path: "taker_nonce"
|
|
7962
8222
|
}
|
|
7963
8223
|
]
|
|
7964
8224
|
}
|
|
7965
8225
|
},
|
|
7966
8226
|
{
|
|
7967
|
-
name: "
|
|
8227
|
+
name: "taker_collateral",
|
|
8228
|
+
writable: true
|
|
7968
8229
|
},
|
|
7969
8230
|
{
|
|
7970
|
-
name: "
|
|
8231
|
+
name: "taker_token_account",
|
|
7971
8232
|
writable: true
|
|
7972
8233
|
},
|
|
7973
8234
|
{
|
|
7974
|
-
name: "
|
|
8235
|
+
name: "taker_position",
|
|
7975
8236
|
writable: true
|
|
7976
8237
|
},
|
|
7977
8238
|
{
|
|
7978
|
-
name: "
|
|
8239
|
+
name: "taker_order_status",
|
|
7979
8240
|
writable: true,
|
|
7980
8241
|
pda: {
|
|
7981
8242
|
seeds: [
|
|
@@ -7991,11 +8252,11 @@ var clob_exchange_default = {
|
|
|
7991
8252
|
},
|
|
7992
8253
|
{
|
|
7993
8254
|
kind: "account",
|
|
7994
|
-
path: "
|
|
8255
|
+
path: "taker"
|
|
7995
8256
|
},
|
|
7996
8257
|
{
|
|
7997
8258
|
kind: "arg",
|
|
7998
|
-
path: "
|
|
8259
|
+
path: "taker_nonce"
|
|
7999
8260
|
}
|
|
8000
8261
|
]
|
|
8001
8262
|
}
|
|
@@ -8008,17 +8269,9 @@ var clob_exchange_default = {
|
|
|
8008
8269
|
name: "outcome_mint",
|
|
8009
8270
|
writable: true
|
|
8010
8271
|
},
|
|
8011
|
-
{
|
|
8012
|
-
name: "seller_position",
|
|
8013
|
-
writable: true
|
|
8014
|
-
},
|
|
8015
|
-
{
|
|
8016
|
-
name: "buyer_position",
|
|
8017
|
-
writable: true
|
|
8018
|
-
},
|
|
8019
8272
|
{
|
|
8020
8273
|
name: "conditional_tokens_program",
|
|
8021
|
-
address: "
|
|
8274
|
+
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
8022
8275
|
},
|
|
8023
8276
|
{
|
|
8024
8277
|
name: "token_program",
|
|
@@ -8035,20 +8288,8 @@ var clob_exchange_default = {
|
|
|
8035
8288
|
],
|
|
8036
8289
|
args: [
|
|
8037
8290
|
{
|
|
8038
|
-
name: "
|
|
8039
|
-
type:
|
|
8040
|
-
defined: {
|
|
8041
|
-
name: "SignedOrder"
|
|
8042
|
-
}
|
|
8043
|
-
}
|
|
8044
|
-
},
|
|
8045
|
-
{
|
|
8046
|
-
name: "sell_signed",
|
|
8047
|
-
type: {
|
|
8048
|
-
defined: {
|
|
8049
|
-
name: "SignedOrder"
|
|
8050
|
-
}
|
|
8051
|
-
}
|
|
8291
|
+
name: "taker_nonce",
|
|
8292
|
+
type: "u64"
|
|
8052
8293
|
},
|
|
8053
8294
|
{
|
|
8054
8295
|
name: "fill_amount",
|
|
@@ -8059,9 +8300,7 @@ var clob_exchange_default = {
|
|
|
8059
8300
|
{
|
|
8060
8301
|
name: "match_merge_orders",
|
|
8061
8302
|
docs: [
|
|
8062
|
-
"MERGE match:
|
|
8063
|
-
"Their combined 1 YES + 1 NO is merged back into 1 USDC.",
|
|
8064
|
-
"Requires: yes_price_bps + no_price_bps <= 10_000."
|
|
8303
|
+
"MERGE match: 1 taker (YES SELL) + N makers (NO SELL) via remaining_accounts."
|
|
8065
8304
|
],
|
|
8066
8305
|
discriminator: [
|
|
8067
8306
|
105,
|
|
@@ -8076,16 +8315,10 @@ var clob_exchange_default = {
|
|
|
8076
8315
|
accounts: [
|
|
8077
8316
|
{
|
|
8078
8317
|
name: "operator",
|
|
8079
|
-
docs: [
|
|
8080
|
-
"Authorized operator (whitelisted signer)"
|
|
8081
|
-
],
|
|
8082
8318
|
signer: true
|
|
8083
8319
|
},
|
|
8084
8320
|
{
|
|
8085
8321
|
name: "payer",
|
|
8086
|
-
docs: [
|
|
8087
|
-
"Fee payer \u2014 pays tx fee and PDA rent"
|
|
8088
|
-
],
|
|
8089
8322
|
writable: true,
|
|
8090
8323
|
signer: true
|
|
8091
8324
|
},
|
|
@@ -8112,40 +8345,14 @@ var clob_exchange_default = {
|
|
|
8112
8345
|
]
|
|
8113
8346
|
}
|
|
8114
8347
|
},
|
|
8115
|
-
{
|
|
8116
|
-
name: "ix_sysvar",
|
|
8117
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
8118
|
-
},
|
|
8119
8348
|
{
|
|
8120
8349
|
name: "condition"
|
|
8121
8350
|
},
|
|
8122
8351
|
{
|
|
8123
|
-
name: "
|
|
8124
|
-
},
|
|
8125
|
-
{
|
|
8126
|
-
name: "seller_yes_token_account",
|
|
8127
|
-
docs: [
|
|
8128
|
-
"Seller YES's YES token account (tokens leave here)"
|
|
8129
|
-
],
|
|
8130
|
-
writable: true
|
|
8131
|
-
},
|
|
8132
|
-
{
|
|
8133
|
-
name: "seller_yes_position",
|
|
8134
|
-
docs: [
|
|
8135
|
-
"Seller YES's YES Position PDA"
|
|
8136
|
-
],
|
|
8137
|
-
writable: true
|
|
8138
|
-
},
|
|
8139
|
-
{
|
|
8140
|
-
name: "seller_yes_collateral",
|
|
8141
|
-
docs: [
|
|
8142
|
-
"Seller YES receives USDC here"
|
|
8143
|
-
],
|
|
8144
|
-
writable: true
|
|
8352
|
+
name: "taker"
|
|
8145
8353
|
},
|
|
8146
8354
|
{
|
|
8147
|
-
name: "
|
|
8148
|
-
writable: true,
|
|
8355
|
+
name: "taker_order_record",
|
|
8149
8356
|
pda: {
|
|
8150
8357
|
seeds: [
|
|
8151
8358
|
{
|
|
@@ -8155,37 +8362,41 @@ var clob_exchange_default = {
|
|
|
8155
8362
|
114,
|
|
8156
8363
|
100,
|
|
8157
8364
|
101,
|
|
8158
|
-
114
|
|
8365
|
+
114,
|
|
8366
|
+
95,
|
|
8367
|
+
114,
|
|
8368
|
+
101,
|
|
8369
|
+
99,
|
|
8370
|
+
111,
|
|
8371
|
+
114,
|
|
8372
|
+
100
|
|
8159
8373
|
]
|
|
8160
8374
|
},
|
|
8161
8375
|
{
|
|
8162
8376
|
kind: "account",
|
|
8163
|
-
path: "
|
|
8377
|
+
path: "taker"
|
|
8164
8378
|
},
|
|
8165
8379
|
{
|
|
8166
8380
|
kind: "arg",
|
|
8167
|
-
path: "
|
|
8381
|
+
path: "taker_nonce"
|
|
8168
8382
|
}
|
|
8169
8383
|
]
|
|
8170
8384
|
}
|
|
8171
8385
|
},
|
|
8172
8386
|
{
|
|
8173
|
-
name: "
|
|
8174
|
-
},
|
|
8175
|
-
{
|
|
8176
|
-
name: "seller_no_token_account",
|
|
8387
|
+
name: "taker_yes_token",
|
|
8177
8388
|
writable: true
|
|
8178
8389
|
},
|
|
8179
8390
|
{
|
|
8180
|
-
name: "
|
|
8391
|
+
name: "taker_yes_position",
|
|
8181
8392
|
writable: true
|
|
8182
8393
|
},
|
|
8183
8394
|
{
|
|
8184
|
-
name: "
|
|
8395
|
+
name: "taker_collateral",
|
|
8185
8396
|
writable: true
|
|
8186
8397
|
},
|
|
8187
8398
|
{
|
|
8188
|
-
name: "
|
|
8399
|
+
name: "taker_order_status",
|
|
8189
8400
|
writable: true,
|
|
8190
8401
|
pda: {
|
|
8191
8402
|
seeds: [
|
|
@@ -8201,11 +8412,11 @@ var clob_exchange_default = {
|
|
|
8201
8412
|
},
|
|
8202
8413
|
{
|
|
8203
8414
|
kind: "account",
|
|
8204
|
-
path: "
|
|
8415
|
+
path: "taker"
|
|
8205
8416
|
},
|
|
8206
8417
|
{
|
|
8207
8418
|
kind: "arg",
|
|
8208
|
-
path: "
|
|
8419
|
+
path: "taker_nonce"
|
|
8209
8420
|
}
|
|
8210
8421
|
]
|
|
8211
8422
|
}
|
|
@@ -8232,16 +8443,10 @@ var clob_exchange_default = {
|
|
|
8232
8443
|
},
|
|
8233
8444
|
{
|
|
8234
8445
|
name: "fee_recipient",
|
|
8235
|
-
docs: [
|
|
8236
|
-
"Fee recipient (receives spread)"
|
|
8237
|
-
],
|
|
8238
8446
|
writable: true
|
|
8239
8447
|
},
|
|
8240
8448
|
{
|
|
8241
8449
|
name: "clob_authority",
|
|
8242
|
-
docs: [
|
|
8243
|
-
"CLOB authority PDA"
|
|
8244
|
-
],
|
|
8245
8450
|
pda: {
|
|
8246
8451
|
seeds: [
|
|
8247
8452
|
{
|
|
@@ -8265,7 +8470,7 @@ var clob_exchange_default = {
|
|
|
8265
8470
|
},
|
|
8266
8471
|
{
|
|
8267
8472
|
name: "conditional_tokens_program",
|
|
8268
|
-
address: "
|
|
8473
|
+
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
8269
8474
|
},
|
|
8270
8475
|
{
|
|
8271
8476
|
name: "collateral_token_program",
|
|
@@ -8278,20 +8483,8 @@ var clob_exchange_default = {
|
|
|
8278
8483
|
],
|
|
8279
8484
|
args: [
|
|
8280
8485
|
{
|
|
8281
|
-
name: "
|
|
8282
|
-
type:
|
|
8283
|
-
defined: {
|
|
8284
|
-
name: "SignedOrder"
|
|
8285
|
-
}
|
|
8286
|
-
}
|
|
8287
|
-
},
|
|
8288
|
-
{
|
|
8289
|
-
name: "no_signed",
|
|
8290
|
-
type: {
|
|
8291
|
-
defined: {
|
|
8292
|
-
name: "SignedOrder"
|
|
8293
|
-
}
|
|
8294
|
-
}
|
|
8486
|
+
name: "taker_nonce",
|
|
8487
|
+
type: "u64"
|
|
8295
8488
|
},
|
|
8296
8489
|
{
|
|
8297
8490
|
name: "fill_amount",
|
|
@@ -8302,9 +8495,7 @@ var clob_exchange_default = {
|
|
|
8302
8495
|
{
|
|
8303
8496
|
name: "match_mint_orders",
|
|
8304
8497
|
docs: [
|
|
8305
|
-
"MINT match:
|
|
8306
|
-
"Their combined USDC is used to split 1 USDC \u2192 1 YES + 1 NO.",
|
|
8307
|
-
"Requires: yes_price_bps + no_price_bps >= 10_000."
|
|
8498
|
+
"MINT match: 1 taker (YES BUY) + N makers (NO BUY) via remaining_accounts."
|
|
8308
8499
|
],
|
|
8309
8500
|
discriminator: [
|
|
8310
8501
|
146,
|
|
@@ -8319,16 +8510,10 @@ var clob_exchange_default = {
|
|
|
8319
8510
|
accounts: [
|
|
8320
8511
|
{
|
|
8321
8512
|
name: "operator",
|
|
8322
|
-
docs: [
|
|
8323
|
-
"Authorized operator (whitelisted signer)"
|
|
8324
|
-
],
|
|
8325
8513
|
signer: true
|
|
8326
8514
|
},
|
|
8327
8515
|
{
|
|
8328
8516
|
name: "payer",
|
|
8329
|
-
docs: [
|
|
8330
|
-
"Fee payer \u2014 pays tx fee and PDA rent"
|
|
8331
|
-
],
|
|
8332
8517
|
writable: true,
|
|
8333
8518
|
signer: true
|
|
8334
8519
|
},
|
|
@@ -8355,31 +8540,14 @@ var clob_exchange_default = {
|
|
|
8355
8540
|
]
|
|
8356
8541
|
}
|
|
8357
8542
|
},
|
|
8358
|
-
{
|
|
8359
|
-
name: "ix_sysvar",
|
|
8360
|
-
address: "Sysvar1nstructions1111111111111111111111111"
|
|
8361
|
-
},
|
|
8362
8543
|
{
|
|
8363
8544
|
name: "condition"
|
|
8364
8545
|
},
|
|
8365
8546
|
{
|
|
8366
|
-
name: "
|
|
8367
|
-
},
|
|
8368
|
-
{
|
|
8369
|
-
name: "buyer_yes_collateral",
|
|
8370
|
-
writable: true
|
|
8371
|
-
},
|
|
8372
|
-
{
|
|
8373
|
-
name: "buyer_yes_token_account",
|
|
8374
|
-
writable: true
|
|
8375
|
-
},
|
|
8376
|
-
{
|
|
8377
|
-
name: "buyer_yes_position",
|
|
8378
|
-
writable: true
|
|
8547
|
+
name: "taker"
|
|
8379
8548
|
},
|
|
8380
8549
|
{
|
|
8381
|
-
name: "
|
|
8382
|
-
writable: true,
|
|
8550
|
+
name: "taker_order_record",
|
|
8383
8551
|
pda: {
|
|
8384
8552
|
seeds: [
|
|
8385
8553
|
{
|
|
@@ -8389,37 +8557,41 @@ var clob_exchange_default = {
|
|
|
8389
8557
|
114,
|
|
8390
8558
|
100,
|
|
8391
8559
|
101,
|
|
8392
|
-
114
|
|
8560
|
+
114,
|
|
8561
|
+
95,
|
|
8562
|
+
114,
|
|
8563
|
+
101,
|
|
8564
|
+
99,
|
|
8565
|
+
111,
|
|
8566
|
+
114,
|
|
8567
|
+
100
|
|
8393
8568
|
]
|
|
8394
8569
|
},
|
|
8395
8570
|
{
|
|
8396
8571
|
kind: "account",
|
|
8397
|
-
path: "
|
|
8572
|
+
path: "taker"
|
|
8398
8573
|
},
|
|
8399
8574
|
{
|
|
8400
8575
|
kind: "arg",
|
|
8401
|
-
path: "
|
|
8576
|
+
path: "taker_nonce"
|
|
8402
8577
|
}
|
|
8403
8578
|
]
|
|
8404
8579
|
}
|
|
8405
8580
|
},
|
|
8406
8581
|
{
|
|
8407
|
-
name: "
|
|
8408
|
-
},
|
|
8409
|
-
{
|
|
8410
|
-
name: "buyer_no_collateral",
|
|
8582
|
+
name: "taker_collateral",
|
|
8411
8583
|
writable: true
|
|
8412
8584
|
},
|
|
8413
8585
|
{
|
|
8414
|
-
name: "
|
|
8586
|
+
name: "taker_yes_token",
|
|
8415
8587
|
writable: true
|
|
8416
8588
|
},
|
|
8417
8589
|
{
|
|
8418
|
-
name: "
|
|
8590
|
+
name: "taker_yes_position",
|
|
8419
8591
|
writable: true
|
|
8420
8592
|
},
|
|
8421
8593
|
{
|
|
8422
|
-
name: "
|
|
8594
|
+
name: "taker_order_status",
|
|
8423
8595
|
writable: true,
|
|
8424
8596
|
pda: {
|
|
8425
8597
|
seeds: [
|
|
@@ -8435,11 +8607,11 @@ var clob_exchange_default = {
|
|
|
8435
8607
|
},
|
|
8436
8608
|
{
|
|
8437
8609
|
kind: "account",
|
|
8438
|
-
path: "
|
|
8610
|
+
path: "taker"
|
|
8439
8611
|
},
|
|
8440
8612
|
{
|
|
8441
8613
|
kind: "arg",
|
|
8442
|
-
path: "
|
|
8614
|
+
path: "taker_nonce"
|
|
8443
8615
|
}
|
|
8444
8616
|
]
|
|
8445
8617
|
}
|
|
@@ -8466,9 +8638,6 @@ var clob_exchange_default = {
|
|
|
8466
8638
|
},
|
|
8467
8639
|
{
|
|
8468
8640
|
name: "clob_authority",
|
|
8469
|
-
docs: [
|
|
8470
|
-
"CLOB authority PDA (signs CTF CPI)"
|
|
8471
|
-
],
|
|
8472
8641
|
pda: {
|
|
8473
8642
|
seeds: [
|
|
8474
8643
|
{
|
|
@@ -8492,7 +8661,7 @@ var clob_exchange_default = {
|
|
|
8492
8661
|
},
|
|
8493
8662
|
{
|
|
8494
8663
|
name: "conditional_tokens_program",
|
|
8495
|
-
address: "
|
|
8664
|
+
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
8496
8665
|
},
|
|
8497
8666
|
{
|
|
8498
8667
|
name: "collateral_token_program",
|
|
@@ -8505,32 +8674,194 @@ var clob_exchange_default = {
|
|
|
8505
8674
|
],
|
|
8506
8675
|
args: [
|
|
8507
8676
|
{
|
|
8508
|
-
name: "
|
|
8509
|
-
type:
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8677
|
+
name: "taker_nonce",
|
|
8678
|
+
type: "u64"
|
|
8679
|
+
},
|
|
8680
|
+
{
|
|
8681
|
+
name: "fill_amount",
|
|
8682
|
+
type: "u64"
|
|
8683
|
+
}
|
|
8684
|
+
]
|
|
8685
|
+
},
|
|
8686
|
+
{
|
|
8687
|
+
name: "register_order",
|
|
8688
|
+
docs: [
|
|
8689
|
+
"Register a signed order on-chain (Ed25519 verify at registration time).",
|
|
8690
|
+
"ix[0] must be Ed25519 precompile with 1 entry for order.signer."
|
|
8691
|
+
],
|
|
8692
|
+
discriminator: [
|
|
8693
|
+
92,
|
|
8694
|
+
37,
|
|
8695
|
+
29,
|
|
8696
|
+
46,
|
|
8697
|
+
77,
|
|
8698
|
+
250,
|
|
8699
|
+
219,
|
|
8700
|
+
6
|
|
8701
|
+
],
|
|
8702
|
+
accounts: [
|
|
8703
|
+
{
|
|
8704
|
+
name: "payer",
|
|
8705
|
+
docs: [
|
|
8706
|
+
"Operator pays rent for the OrderRecord PDA."
|
|
8707
|
+
],
|
|
8708
|
+
writable: true,
|
|
8709
|
+
signer: true
|
|
8710
|
+
},
|
|
8711
|
+
{
|
|
8712
|
+
name: "clob_config",
|
|
8713
|
+
pda: {
|
|
8714
|
+
seeds: [
|
|
8715
|
+
{
|
|
8716
|
+
kind: "const",
|
|
8717
|
+
value: [
|
|
8718
|
+
99,
|
|
8719
|
+
108,
|
|
8720
|
+
111,
|
|
8721
|
+
98,
|
|
8722
|
+
95,
|
|
8723
|
+
99,
|
|
8724
|
+
111,
|
|
8725
|
+
110,
|
|
8726
|
+
102,
|
|
8727
|
+
105,
|
|
8728
|
+
103
|
|
8729
|
+
]
|
|
8730
|
+
}
|
|
8731
|
+
]
|
|
8513
8732
|
}
|
|
8514
8733
|
},
|
|
8515
8734
|
{
|
|
8516
|
-
name: "
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8735
|
+
name: "ix_sysvar",
|
|
8736
|
+
address: "Sysvar1nstructions1111111111111111111111111"
|
|
8737
|
+
},
|
|
8738
|
+
{
|
|
8739
|
+
name: "order_signer"
|
|
8740
|
+
},
|
|
8741
|
+
{
|
|
8742
|
+
name: "order_record",
|
|
8743
|
+
writable: true,
|
|
8744
|
+
pda: {
|
|
8745
|
+
seeds: [
|
|
8746
|
+
{
|
|
8747
|
+
kind: "const",
|
|
8748
|
+
value: [
|
|
8749
|
+
111,
|
|
8750
|
+
114,
|
|
8751
|
+
100,
|
|
8752
|
+
101,
|
|
8753
|
+
114,
|
|
8754
|
+
95,
|
|
8755
|
+
114,
|
|
8756
|
+
101,
|
|
8757
|
+
99,
|
|
8758
|
+
111,
|
|
8759
|
+
114,
|
|
8760
|
+
100
|
|
8761
|
+
]
|
|
8762
|
+
},
|
|
8763
|
+
{
|
|
8764
|
+
kind: "account",
|
|
8765
|
+
path: "order_signer"
|
|
8766
|
+
},
|
|
8767
|
+
{
|
|
8768
|
+
kind: "arg",
|
|
8769
|
+
path: "nonce"
|
|
8770
|
+
}
|
|
8771
|
+
]
|
|
8521
8772
|
}
|
|
8522
8773
|
},
|
|
8523
8774
|
{
|
|
8524
|
-
name: "
|
|
8775
|
+
name: "order_status",
|
|
8776
|
+
writable: true,
|
|
8777
|
+
pda: {
|
|
8778
|
+
seeds: [
|
|
8779
|
+
{
|
|
8780
|
+
kind: "const",
|
|
8781
|
+
value: [
|
|
8782
|
+
111,
|
|
8783
|
+
114,
|
|
8784
|
+
100,
|
|
8785
|
+
101,
|
|
8786
|
+
114
|
|
8787
|
+
]
|
|
8788
|
+
},
|
|
8789
|
+
{
|
|
8790
|
+
kind: "account",
|
|
8791
|
+
path: "order_signer"
|
|
8792
|
+
},
|
|
8793
|
+
{
|
|
8794
|
+
kind: "arg",
|
|
8795
|
+
path: "nonce"
|
|
8796
|
+
}
|
|
8797
|
+
]
|
|
8798
|
+
}
|
|
8799
|
+
},
|
|
8800
|
+
{
|
|
8801
|
+
name: "system_program",
|
|
8802
|
+
address: "11111111111111111111111111111111"
|
|
8803
|
+
}
|
|
8804
|
+
],
|
|
8805
|
+
args: [
|
|
8806
|
+
{
|
|
8807
|
+
name: "nonce",
|
|
8525
8808
|
type: "u64"
|
|
8526
8809
|
}
|
|
8527
8810
|
]
|
|
8528
8811
|
},
|
|
8529
8812
|
{
|
|
8530
|
-
name: "
|
|
8531
|
-
|
|
8532
|
-
|
|
8813
|
+
name: "reinit_clob",
|
|
8814
|
+
discriminator: [
|
|
8815
|
+
41,
|
|
8816
|
+
95,
|
|
8817
|
+
240,
|
|
8818
|
+
222,
|
|
8819
|
+
95,
|
|
8820
|
+
170,
|
|
8821
|
+
14,
|
|
8822
|
+
224
|
|
8823
|
+
],
|
|
8824
|
+
accounts: [
|
|
8825
|
+
{
|
|
8826
|
+
name: "upgrade_authority",
|
|
8827
|
+
writable: true,
|
|
8828
|
+
signer: true
|
|
8829
|
+
},
|
|
8830
|
+
{
|
|
8831
|
+
name: "program_data"
|
|
8832
|
+
},
|
|
8833
|
+
{
|
|
8834
|
+
name: "clob_config",
|
|
8835
|
+
writable: true
|
|
8836
|
+
}
|
|
8533
8837
|
],
|
|
8838
|
+
args: [
|
|
8839
|
+
{
|
|
8840
|
+
name: "new_admin",
|
|
8841
|
+
type: "pubkey"
|
|
8842
|
+
},
|
|
8843
|
+
{
|
|
8844
|
+
name: "new_operators",
|
|
8845
|
+
type: {
|
|
8846
|
+
vec: "pubkey"
|
|
8847
|
+
}
|
|
8848
|
+
},
|
|
8849
|
+
{
|
|
8850
|
+
name: "new_fee_recipient",
|
|
8851
|
+
type: "pubkey"
|
|
8852
|
+
},
|
|
8853
|
+
{
|
|
8854
|
+
name: "new_fee_rate_bps",
|
|
8855
|
+
type: "u16"
|
|
8856
|
+
},
|
|
8857
|
+
{
|
|
8858
|
+
name: "conditional_tokens_program",
|
|
8859
|
+
type: "pubkey"
|
|
8860
|
+
}
|
|
8861
|
+
]
|
|
8862
|
+
},
|
|
8863
|
+
{
|
|
8864
|
+
name: "remove_operator",
|
|
8534
8865
|
discriminator: [
|
|
8535
8866
|
84,
|
|
8536
8867
|
183,
|
|
@@ -8580,9 +8911,6 @@ var clob_exchange_default = {
|
|
|
8580
8911
|
},
|
|
8581
8912
|
{
|
|
8582
8913
|
name: "set_paused",
|
|
8583
|
-
docs: [
|
|
8584
|
-
"Pause or unpause the CLOB (admin only)."
|
|
8585
|
-
],
|
|
8586
8914
|
discriminator: [
|
|
8587
8915
|
91,
|
|
8588
8916
|
60,
|
|
@@ -8657,6 +8985,19 @@ var clob_exchange_default = {
|
|
|
8657
8985
|
65,
|
|
8658
8986
|
3
|
|
8659
8987
|
]
|
|
8988
|
+
},
|
|
8989
|
+
{
|
|
8990
|
+
name: "SignedOrderRecord",
|
|
8991
|
+
discriminator: [
|
|
8992
|
+
16,
|
|
8993
|
+
167,
|
|
8994
|
+
189,
|
|
8995
|
+
166,
|
|
8996
|
+
85,
|
|
8997
|
+
0,
|
|
8998
|
+
231,
|
|
8999
|
+
55
|
|
9000
|
+
]
|
|
8660
9001
|
}
|
|
8661
9002
|
],
|
|
8662
9003
|
events: [
|
|
@@ -8851,29 +9192,13 @@ var clob_exchange_default = {
|
|
|
8851
9192
|
type: "pubkey"
|
|
8852
9193
|
},
|
|
8853
9194
|
{
|
|
8854
|
-
name: "
|
|
8855
|
-
type: "pubkey"
|
|
8856
|
-
},
|
|
8857
|
-
{
|
|
8858
|
-
name: "seller",
|
|
9195
|
+
name: "taker",
|
|
8859
9196
|
type: "pubkey"
|
|
8860
9197
|
},
|
|
8861
|
-
{
|
|
8862
|
-
name: "token_id",
|
|
8863
|
-
type: "u8"
|
|
8864
|
-
},
|
|
8865
9198
|
{
|
|
8866
9199
|
name: "fill_amount",
|
|
8867
9200
|
type: "u64"
|
|
8868
9201
|
},
|
|
8869
|
-
{
|
|
8870
|
-
name: "price_bps",
|
|
8871
|
-
type: "u64"
|
|
8872
|
-
},
|
|
8873
|
-
{
|
|
8874
|
-
name: "usdc_transferred",
|
|
8875
|
-
type: "u64"
|
|
8876
|
-
},
|
|
8877
9202
|
{
|
|
8878
9203
|
name: "fee",
|
|
8879
9204
|
type: "u64"
|
|
@@ -9024,33 +9349,13 @@ var clob_exchange_default = {
|
|
|
9024
9349
|
type: "pubkey"
|
|
9025
9350
|
},
|
|
9026
9351
|
{
|
|
9027
|
-
name: "
|
|
9028
|
-
type: "pubkey"
|
|
9029
|
-
},
|
|
9030
|
-
{
|
|
9031
|
-
name: "seller_no",
|
|
9352
|
+
name: "taker",
|
|
9032
9353
|
type: "pubkey"
|
|
9033
9354
|
},
|
|
9034
9355
|
{
|
|
9035
9356
|
name: "fill_amount",
|
|
9036
9357
|
type: "u64"
|
|
9037
9358
|
},
|
|
9038
|
-
{
|
|
9039
|
-
name: "yes_price_bps",
|
|
9040
|
-
type: "u64"
|
|
9041
|
-
},
|
|
9042
|
-
{
|
|
9043
|
-
name: "no_price_bps",
|
|
9044
|
-
type: "u64"
|
|
9045
|
-
},
|
|
9046
|
-
{
|
|
9047
|
-
name: "yes_payout",
|
|
9048
|
-
type: "u64"
|
|
9049
|
-
},
|
|
9050
|
-
{
|
|
9051
|
-
name: "no_payout",
|
|
9052
|
-
type: "u64"
|
|
9053
|
-
},
|
|
9054
9359
|
{
|
|
9055
9360
|
name: "fee",
|
|
9056
9361
|
type: "u64"
|
|
@@ -9071,173 +9376,108 @@ var clob_exchange_default = {
|
|
|
9071
9376
|
name: "buyer_yes",
|
|
9072
9377
|
type: "pubkey"
|
|
9073
9378
|
},
|
|
9074
|
-
{
|
|
9075
|
-
name: "buyer_no",
|
|
9076
|
-
type: "pubkey"
|
|
9077
|
-
},
|
|
9078
9379
|
{
|
|
9079
9380
|
name: "fill_amount",
|
|
9080
9381
|
type: "u64"
|
|
9081
|
-
}
|
|
9382
|
+
}
|
|
9383
|
+
]
|
|
9384
|
+
}
|
|
9385
|
+
},
|
|
9386
|
+
{
|
|
9387
|
+
name: "OrderStatus",
|
|
9388
|
+
docs: [
|
|
9389
|
+
"Tracks the fill state of an order for replay protection.",
|
|
9390
|
+
'PDA seeds: [b"order", maker_pubkey, nonce_le_bytes]',
|
|
9391
|
+
"",
|
|
9392
|
+
"Created on first fill (init_if_needed). A missing PDA means the order",
|
|
9393
|
+
"has never been touched (remaining = order.amount)."
|
|
9394
|
+
],
|
|
9395
|
+
type: {
|
|
9396
|
+
kind: "struct",
|
|
9397
|
+
fields: [
|
|
9082
9398
|
{
|
|
9083
|
-
name: "
|
|
9084
|
-
type: "
|
|
9399
|
+
name: "maker",
|
|
9400
|
+
type: "pubkey"
|
|
9085
9401
|
},
|
|
9086
9402
|
{
|
|
9087
|
-
name: "
|
|
9403
|
+
name: "nonce",
|
|
9088
9404
|
type: "u64"
|
|
9089
9405
|
},
|
|
9090
9406
|
{
|
|
9091
|
-
name: "
|
|
9407
|
+
name: "filled_amount",
|
|
9092
9408
|
type: "u64"
|
|
9093
9409
|
},
|
|
9094
9410
|
{
|
|
9095
|
-
name: "
|
|
9096
|
-
type: "
|
|
9411
|
+
name: "bump",
|
|
9412
|
+
type: "u8"
|
|
9097
9413
|
}
|
|
9098
9414
|
]
|
|
9099
9415
|
}
|
|
9100
9416
|
},
|
|
9101
9417
|
{
|
|
9102
|
-
name: "
|
|
9418
|
+
name: "SignedOrderRecord",
|
|
9103
9419
|
docs: [
|
|
9104
|
-
"
|
|
9105
|
-
"
|
|
9420
|
+
"On-chain verified order record.",
|
|
9421
|
+
"Created by `register_order` after Ed25519 signature verification.",
|
|
9422
|
+
"Read by match instructions via remaining_accounts.",
|
|
9423
|
+
"Closed (rent returned) when order is fully filled or cancelled.",
|
|
9424
|
+
"",
|
|
9425
|
+
'PDA seeds: [b"order_record", maker, nonce_le_bytes]'
|
|
9106
9426
|
],
|
|
9107
9427
|
type: {
|
|
9108
9428
|
kind: "struct",
|
|
9109
9429
|
fields: [
|
|
9110
9430
|
{
|
|
9111
9431
|
name: "maker",
|
|
9112
|
-
docs: [
|
|
9113
|
-
"Maker's wallet pubkey"
|
|
9114
|
-
],
|
|
9115
9432
|
type: "pubkey"
|
|
9116
9433
|
},
|
|
9117
9434
|
{
|
|
9118
9435
|
name: "condition",
|
|
9119
|
-
docs: [
|
|
9120
|
-
"Condition PDA this order belongs to"
|
|
9121
|
-
],
|
|
9122
9436
|
type: "pubkey"
|
|
9123
9437
|
},
|
|
9124
9438
|
{
|
|
9125
9439
|
name: "token_id",
|
|
9126
|
-
docs: [
|
|
9127
|
-
"Outcome token: 0=NO, 1=YES"
|
|
9128
|
-
],
|
|
9129
9440
|
type: "u8"
|
|
9130
9441
|
},
|
|
9131
9442
|
{
|
|
9132
9443
|
name: "side",
|
|
9133
|
-
docs: [
|
|
9134
|
-
"Side: 0=SELL (maker gives tokens, wants USDC), 1=BUY (maker gives USDC, wants tokens)"
|
|
9135
|
-
],
|
|
9136
9444
|
type: "u8"
|
|
9137
9445
|
},
|
|
9138
9446
|
{
|
|
9139
|
-
name: "
|
|
9140
|
-
docs: [
|
|
9141
|
-
"Price in basis points (0-10000). e.g. 6000 = 60 cents per $1 of exposure.",
|
|
9142
|
-
"For a BUY: maker pays price_bps / 10000 USDC per token.",
|
|
9143
|
-
"For a SELL: maker wants price_bps / 10000 USDC per token."
|
|
9144
|
-
],
|
|
9447
|
+
name: "maker_amount",
|
|
9145
9448
|
type: "u64"
|
|
9146
9449
|
},
|
|
9147
9450
|
{
|
|
9148
|
-
name: "
|
|
9149
|
-
docs: [
|
|
9150
|
-
"Maximum order size in token units (YES or NO tokens, 0 decimals)."
|
|
9151
|
-
],
|
|
9451
|
+
name: "taker_amount",
|
|
9152
9452
|
type: "u64"
|
|
9153
9453
|
},
|
|
9154
9454
|
{
|
|
9155
9455
|
name: "nonce",
|
|
9156
|
-
docs: [
|
|
9157
|
-
"Unique nonce per maker \u2014 used for OrderStatus PDA derivation & replay protection."
|
|
9158
|
-
],
|
|
9159
9456
|
type: "u64"
|
|
9160
9457
|
},
|
|
9161
9458
|
{
|
|
9162
9459
|
name: "expiry",
|
|
9163
|
-
docs: [
|
|
9164
|
-
"Unix timestamp after which the order is invalid (0 = no expiry)."
|
|
9165
|
-
],
|
|
9166
9460
|
type: "i64"
|
|
9167
|
-
}
|
|
9168
|
-
]
|
|
9169
|
-
}
|
|
9170
|
-
},
|
|
9171
|
-
{
|
|
9172
|
-
name: "OrderStatus",
|
|
9173
|
-
docs: [
|
|
9174
|
-
"Tracks the fill state of an order for replay protection.",
|
|
9175
|
-
'PDA seeds: [b"order", maker_pubkey, nonce_le_bytes]',
|
|
9176
|
-
"",
|
|
9177
|
-
"Created on first fill (init_if_needed). A missing PDA means the order",
|
|
9178
|
-
"has never been touched (remaining = order.amount)."
|
|
9179
|
-
],
|
|
9180
|
-
type: {
|
|
9181
|
-
kind: "struct",
|
|
9182
|
-
fields: [
|
|
9183
|
-
{
|
|
9184
|
-
name: "maker",
|
|
9185
|
-
docs: [
|
|
9186
|
-
"The maker who created the order"
|
|
9187
|
-
],
|
|
9188
|
-
type: "pubkey"
|
|
9189
9461
|
},
|
|
9190
9462
|
{
|
|
9191
|
-
name: "
|
|
9192
|
-
|
|
9193
|
-
"Order nonce (unique per maker)"
|
|
9194
|
-
],
|
|
9195
|
-
type: "u64"
|
|
9463
|
+
name: "created_at",
|
|
9464
|
+
type: "i64"
|
|
9196
9465
|
},
|
|
9197
9466
|
{
|
|
9198
|
-
name: "
|
|
9199
|
-
docs: [
|
|
9200
|
-
"Amount of collateral (USDC) already filled"
|
|
9201
|
-
],
|
|
9467
|
+
name: "fee",
|
|
9202
9468
|
type: "u64"
|
|
9203
9469
|
},
|
|
9204
9470
|
{
|
|
9205
|
-
name: "
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
],
|
|
9209
|
-
type: "u8"
|
|
9210
|
-
}
|
|
9211
|
-
]
|
|
9212
|
-
}
|
|
9213
|
-
},
|
|
9214
|
-
{
|
|
9215
|
-
name: "SignedOrder",
|
|
9216
|
-
docs: [
|
|
9217
|
-
"Order + 64-byte Ed25519 signature over `order.to_signable_bytes()`.",
|
|
9218
|
-
"Passed as instruction data to all match_* instructions.",
|
|
9219
|
-
"On-chain: the program verifies the signature exists in the tx",
|
|
9220
|
-
"via Ed25519 precompile instructions at known indices."
|
|
9221
|
-
],
|
|
9222
|
-
type: {
|
|
9223
|
-
kind: "struct",
|
|
9224
|
-
fields: [
|
|
9471
|
+
name: "taker",
|
|
9472
|
+
type: "pubkey"
|
|
9473
|
+
},
|
|
9225
9474
|
{
|
|
9226
|
-
name: "
|
|
9227
|
-
type:
|
|
9228
|
-
defined: {
|
|
9229
|
-
name: "Order"
|
|
9230
|
-
}
|
|
9231
|
-
}
|
|
9475
|
+
name: "signer",
|
|
9476
|
+
type: "pubkey"
|
|
9232
9477
|
},
|
|
9233
9478
|
{
|
|
9234
|
-
name: "
|
|
9235
|
-
type:
|
|
9236
|
-
array: [
|
|
9237
|
-
"u8",
|
|
9238
|
-
64
|
|
9239
|
-
]
|
|
9240
|
-
}
|
|
9479
|
+
name: "bump",
|
|
9480
|
+
type: "u8"
|
|
9241
9481
|
}
|
|
9242
9482
|
]
|
|
9243
9483
|
}
|
|
@@ -9394,8 +9634,10 @@ var fee_management_default = {
|
|
|
9394
9634
|
{
|
|
9395
9635
|
name: "market_oracle_vault",
|
|
9396
9636
|
docs: [
|
|
9397
|
-
"
|
|
9398
|
-
|
|
9637
|
+
"Writable: tokens are transferred here when is_admin=false.",
|
|
9638
|
+
"For admin questions pass any writable account (no transfer occurs)."
|
|
9639
|
+
],
|
|
9640
|
+
writable: true
|
|
9399
9641
|
},
|
|
9400
9642
|
{
|
|
9401
9643
|
name: "token_program",
|
|
@@ -12956,12 +13198,12 @@ var market_oracle_default = {
|
|
|
12956
13198
|
var XMarketSDK = class {
|
|
12957
13199
|
constructor(config, wallet, marketOwner) {
|
|
12958
13200
|
this.networkConfig = config;
|
|
12959
|
-
this.provider = new
|
|
13201
|
+
this.provider = new anchor5.AnchorProvider(
|
|
12960
13202
|
new Connection(config.rpcUrl, "confirmed"),
|
|
12961
13203
|
wallet,
|
|
12962
13204
|
{ commitment: "confirmed", preflightCommitment: "confirmed" }
|
|
12963
13205
|
);
|
|
12964
|
-
|
|
13206
|
+
anchor5.setProvider(this.provider);
|
|
12965
13207
|
this._programIds = config.programIds;
|
|
12966
13208
|
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
12967
13209
|
}
|
|
@@ -12970,21 +13212,21 @@ var XMarketSDK = class {
|
|
|
12970
13212
|
}
|
|
12971
13213
|
get oracle() {
|
|
12972
13214
|
if (!this._oracle) {
|
|
12973
|
-
const program = new
|
|
13215
|
+
const program = new anchor5.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
|
|
12974
13216
|
this._oracle = new OracleClient(program, this.provider, this._programIds);
|
|
12975
13217
|
}
|
|
12976
13218
|
return this._oracle;
|
|
12977
13219
|
}
|
|
12978
13220
|
get hook() {
|
|
12979
13221
|
if (!this._hook) {
|
|
12980
|
-
const program = new
|
|
13222
|
+
const program = new anchor5.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
|
|
12981
13223
|
this._hook = new HookClient(program, this.provider, this._programIds);
|
|
12982
13224
|
}
|
|
12983
13225
|
return this._hook;
|
|
12984
13226
|
}
|
|
12985
13227
|
get market() {
|
|
12986
13228
|
if (!this._market) {
|
|
12987
|
-
const program = new
|
|
13229
|
+
const program = new anchor5.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
|
|
12988
13230
|
this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
|
|
12989
13231
|
this._market.ctfClient = this.ctf;
|
|
12990
13232
|
}
|
|
@@ -12992,14 +13234,14 @@ var XMarketSDK = class {
|
|
|
12992
13234
|
}
|
|
12993
13235
|
get ctf() {
|
|
12994
13236
|
if (!this._ctf) {
|
|
12995
|
-
const program = new
|
|
13237
|
+
const program = new anchor5.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
|
|
12996
13238
|
this._ctf = new CtfClient(program, this.provider, this._programIds);
|
|
12997
13239
|
}
|
|
12998
13240
|
return this._ctf;
|
|
12999
13241
|
}
|
|
13000
13242
|
get clob() {
|
|
13001
13243
|
if (!this._clob) {
|
|
13002
|
-
const program = new
|
|
13244
|
+
const program = new anchor5.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
|
|
13003
13245
|
this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
|
|
13004
13246
|
if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
|
|
13005
13247
|
this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
|
|
@@ -13011,7 +13253,7 @@ var XMarketSDK = class {
|
|
|
13011
13253
|
get fee() {
|
|
13012
13254
|
if (!this._fee) {
|
|
13013
13255
|
if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
|
|
13014
|
-
const program = new
|
|
13256
|
+
const program = new anchor5.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
|
|
13015
13257
|
this._fee = new FeeManagementClient(program, this.provider, this._programIds);
|
|
13016
13258
|
}
|
|
13017
13259
|
return this._fee;
|
|
@@ -13019,7 +13261,7 @@ var XMarketSDK = class {
|
|
|
13019
13261
|
get presale() {
|
|
13020
13262
|
if (!this._presale) {
|
|
13021
13263
|
if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
|
|
13022
|
-
const program = new
|
|
13264
|
+
const program = new anchor5.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
|
|
13023
13265
|
this._presale = new PresaleClient(program, this.provider, this._programIds);
|
|
13024
13266
|
}
|
|
13025
13267
|
return this._presale;
|
|
@@ -13027,7 +13269,7 @@ var XMarketSDK = class {
|
|
|
13027
13269
|
get marketOracle() {
|
|
13028
13270
|
if (!this._marketOracle) {
|
|
13029
13271
|
if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
|
|
13030
|
-
const program = new
|
|
13272
|
+
const program = new anchor5.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
|
|
13031
13273
|
this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
|
|
13032
13274
|
}
|
|
13033
13275
|
return this._marketOracle;
|
|
@@ -13041,10 +13283,10 @@ function buildOrder(params) {
|
|
|
13041
13283
|
side: params.side,
|
|
13042
13284
|
makerAmount: params.makerAmount,
|
|
13043
13285
|
takerAmount: params.takerAmount,
|
|
13044
|
-
nonce: params.nonce ?? new
|
|
13045
|
-
expiry: params.expiry ?? new
|
|
13046
|
-
createdAt: params.createdAt ?? new
|
|
13047
|
-
fee: params.fee ?? new
|
|
13286
|
+
nonce: params.nonce ?? new BN5(Date.now()),
|
|
13287
|
+
expiry: params.expiry ?? new BN5(0),
|
|
13288
|
+
createdAt: params.createdAt ?? new BN5(Math.floor(Date.now() / 1e3)),
|
|
13289
|
+
fee: params.fee ?? new BN5(0),
|
|
13048
13290
|
taker: params.taker ?? new PublicKey(new Uint8Array(32)),
|
|
13049
13291
|
signer: params.maker
|
|
13050
13292
|
};
|
|
@@ -13067,8 +13309,8 @@ function serializeSignedOrder(signed) {
|
|
|
13067
13309
|
function deserializeSignedOrder(bytes) {
|
|
13068
13310
|
if (bytes.length !== 242) throw new InvalidParamError("SignedOrder must be 242 bytes");
|
|
13069
13311
|
const readPubkey = (offset) => new PublicKey(bytes.slice(offset, offset + 32));
|
|
13070
|
-
const readU64 = (offset) => new
|
|
13071
|
-
const readI64 = (offset) => new
|
|
13312
|
+
const readU64 = (offset) => new BN5(bytes.slice(offset, offset + 8), "le");
|
|
13313
|
+
const readI64 = (offset) => new BN5(bytes.slice(offset, offset + 8), "le");
|
|
13072
13314
|
const order = {
|
|
13073
13315
|
maker: readPubkey(0),
|
|
13074
13316
|
condition: readPubkey(32),
|
|
@@ -13117,7 +13359,7 @@ function _detectMatchType(a, b) {
|
|
|
13117
13359
|
"Orders with different tokenIds must both be BUY (MINT) or both SELL (MERGE)"
|
|
13118
13360
|
);
|
|
13119
13361
|
}
|
|
13120
|
-
var MAX_APPROVE_AMOUNT = new
|
|
13362
|
+
var MAX_APPROVE_AMOUNT = new BN5("18446744073709551615");
|
|
13121
13363
|
function buildApproveCollateralTx(collateralMint, signer, payer, delegate, amount = MAX_APPROVE_AMOUNT) {
|
|
13122
13364
|
const ownerAta = getAssociatedTokenAddressSync(collateralMint, signer, false, TOKEN_PROGRAM_ID);
|
|
13123
13365
|
const approveIx = createApproveInstruction(
|