@theliem/xmarket-sdk 3.13.0 → 3.18.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 +150 -5
- package/dist/index.d.ts +150 -5
- package/dist/index.js +1115 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1113 -161
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@ var SEEDS = {
|
|
|
50
50
|
clobConfig: Buffer.from("clob_config"),
|
|
51
51
|
order: Buffer.from("order"),
|
|
52
52
|
feeConfig: Buffer.from("fee_config"),
|
|
53
|
+
referralConfig: Buffer.from("referral_config"),
|
|
53
54
|
questionFee: Buffer.from("question_fee"),
|
|
54
55
|
marketFee: Buffer.from("market_fee"),
|
|
55
56
|
// Presale
|
|
@@ -250,6 +251,14 @@ var PDA = class {
|
|
|
250
251
|
programIds.marketOracle
|
|
251
252
|
);
|
|
252
253
|
}
|
|
254
|
+
// ─── Referral Program ────────────────────────────────────────────────────
|
|
255
|
+
static referralConfig(owner, programIds) {
|
|
256
|
+
if (!programIds.referral) throw new Error("referral program ID not configured");
|
|
257
|
+
return web3_js.PublicKey.findProgramAddressSync(
|
|
258
|
+
[SEEDS.referralConfig, owner.toBuffer()],
|
|
259
|
+
programIds.referral
|
|
260
|
+
);
|
|
261
|
+
}
|
|
253
262
|
// ─── Admin Contract ──────────────────────────────────────────────────────
|
|
254
263
|
static adminConfig(owner, programIds) {
|
|
255
264
|
if (!programIds.adminContract) throw new Error("adminContract program ID not configured");
|
|
@@ -1388,6 +1397,49 @@ function buildBatchedEd25519Instruction(orders) {
|
|
|
1388
1397
|
});
|
|
1389
1398
|
}
|
|
1390
1399
|
var IX_SYSVAR = web3_js.SYSVAR_INSTRUCTIONS_PUBKEY;
|
|
1400
|
+
function serializeCollectFeeOrderToBytes(order) {
|
|
1401
|
+
const buf = new Uint8Array(120);
|
|
1402
|
+
buf.set(order.user.toBytes(), 0);
|
|
1403
|
+
buf.set(order.condition.toBytes(), 32);
|
|
1404
|
+
buf.set(order.tokenMint.toBytes(), 64);
|
|
1405
|
+
buf.set(order.amount.toArrayLike(Buffer, "le", 8), 96);
|
|
1406
|
+
buf.set(order.nonce.toArrayLike(Buffer, "le", 8), 104);
|
|
1407
|
+
buf.set(order.expiry.toArrayLike(Buffer, "le", 8), 112);
|
|
1408
|
+
return buf;
|
|
1409
|
+
}
|
|
1410
|
+
function buildBatchedCollectFeeEd25519Instruction(orders) {
|
|
1411
|
+
const N = orders.length;
|
|
1412
|
+
if (N === 0) throw new Error("At least 1 order required");
|
|
1413
|
+
const MSG_SIZE = 120;
|
|
1414
|
+
const SIG_SIZE = 64;
|
|
1415
|
+
const PK_SIZE = 32;
|
|
1416
|
+
const HEADER = 2 + N * 14;
|
|
1417
|
+
const sigBase = HEADER;
|
|
1418
|
+
const pkBase = sigBase + N * SIG_SIZE;
|
|
1419
|
+
const msgBase = pkBase + N * PK_SIZE;
|
|
1420
|
+
const totalSize = msgBase + N * MSG_SIZE;
|
|
1421
|
+
const data = Buffer.alloc(totalSize);
|
|
1422
|
+
data[0] = N;
|
|
1423
|
+
data[1] = 0;
|
|
1424
|
+
for (let i = 0; i < N; i++) {
|
|
1425
|
+
const e = 2 + i * 14;
|
|
1426
|
+
data.writeUInt16LE(sigBase + i * SIG_SIZE, e);
|
|
1427
|
+
data.writeUInt16LE(65535, e + 2);
|
|
1428
|
+
data.writeUInt16LE(pkBase + i * PK_SIZE, e + 4);
|
|
1429
|
+
data.writeUInt16LE(65535, e + 6);
|
|
1430
|
+
data.writeUInt16LE(msgBase + i * MSG_SIZE, e + 8);
|
|
1431
|
+
data.writeUInt16LE(MSG_SIZE, e + 10);
|
|
1432
|
+
data.writeUInt16LE(65535, e + 12);
|
|
1433
|
+
data.set(orders[i].signature, sigBase + i * SIG_SIZE);
|
|
1434
|
+
data.set(orders[i].order.user.toBytes(), pkBase + i * PK_SIZE);
|
|
1435
|
+
data.set(serializeCollectFeeOrderToBytes(orders[i].order), msgBase + i * MSG_SIZE);
|
|
1436
|
+
}
|
|
1437
|
+
return new web3_js.TransactionInstruction({
|
|
1438
|
+
keys: [],
|
|
1439
|
+
programId: web3_js.Ed25519Program.programId,
|
|
1440
|
+
data
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1391
1443
|
function buildOrder(params) {
|
|
1392
1444
|
return {
|
|
1393
1445
|
maker: params.maker,
|
|
@@ -1505,10 +1557,17 @@ var ClobClient = class {
|
|
|
1505
1557
|
if (!this.feeClient || !this.feeConfigOwner) return void 0;
|
|
1506
1558
|
if (!this._companyAddress) {
|
|
1507
1559
|
const cfg = await this.feeClient.fetchFeeConfig(this.feeConfigOwner);
|
|
1508
|
-
if (cfg)
|
|
1560
|
+
if (cfg) {
|
|
1561
|
+
this._companyAddress = cfg.companyAddress;
|
|
1562
|
+
this._referralVault = cfg.referralVault;
|
|
1563
|
+
}
|
|
1509
1564
|
}
|
|
1510
1565
|
return this._companyAddress;
|
|
1511
1566
|
}
|
|
1567
|
+
async referralVault() {
|
|
1568
|
+
await this.companyAddress();
|
|
1569
|
+
return this._referralVault;
|
|
1570
|
+
}
|
|
1512
1571
|
get walletPubkey() {
|
|
1513
1572
|
return this.provider.wallet.publicKey;
|
|
1514
1573
|
}
|
|
@@ -1599,6 +1658,7 @@ var ClobClient = class {
|
|
|
1599
1658
|
}
|
|
1600
1659
|
if (this.programIds.feeManagement && this.feeConfigOwner) {
|
|
1601
1660
|
const companyAddr = await this.companyAddress();
|
|
1661
|
+
const refVault = await this.referralVault();
|
|
1602
1662
|
addresses.push(
|
|
1603
1663
|
this.programIds.feeManagement,
|
|
1604
1664
|
PDA.feeConfig(this.feeConfigOwner, this.programIds)[0],
|
|
@@ -1608,6 +1668,10 @@ var ClobClient = class {
|
|
|
1608
1668
|
addresses.push(splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr));
|
|
1609
1669
|
}
|
|
1610
1670
|
addresses.push(payer);
|
|
1671
|
+
if (refVault) {
|
|
1672
|
+
addresses.push(refVault);
|
|
1673
|
+
}
|
|
1674
|
+
addresses.push(splToken.TOKEN_PROGRAM_ID);
|
|
1611
1675
|
}
|
|
1612
1676
|
const slot = await connection.getSlot("finalized");
|
|
1613
1677
|
const [createIx, altAddress] = web3_js.AddressLookupTableProgram.createLookupTable({
|
|
@@ -1642,8 +1706,8 @@ var ClobClient = class {
|
|
|
1642
1706
|
async _sendLegacyTxSig(instructions) {
|
|
1643
1707
|
const { connection } = this.provider;
|
|
1644
1708
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1645
|
-
const { Transaction:
|
|
1646
|
-
const tx = new
|
|
1709
|
+
const { Transaction: Transaction10 } = await import('@solana/web3.js');
|
|
1710
|
+
const tx = new Transaction10();
|
|
1647
1711
|
tx.recentBlockhash = blockhash;
|
|
1648
1712
|
tx.feePayer = this.walletPubkey;
|
|
1649
1713
|
tx.add(...instructions);
|
|
@@ -1669,10 +1733,10 @@ ${logs.join("\n")}`);
|
|
|
1669
1733
|
connection.getAccountInfo(clobYesAta),
|
|
1670
1734
|
connection.getAccountInfo(clobNoAta)
|
|
1671
1735
|
]);
|
|
1672
|
-
const { createAssociatedTokenAccountIdempotentInstruction:
|
|
1736
|
+
const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction4 } = await import('@solana/spl-token');
|
|
1673
1737
|
const ixs = [];
|
|
1674
1738
|
if (!yesInfo) {
|
|
1675
|
-
ixs.push(
|
|
1739
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction4(
|
|
1676
1740
|
this.walletPubkey,
|
|
1677
1741
|
clobYesAta,
|
|
1678
1742
|
clobConfig,
|
|
@@ -1681,7 +1745,7 @@ ${logs.join("\n")}`);
|
|
|
1681
1745
|
));
|
|
1682
1746
|
}
|
|
1683
1747
|
if (!noInfo) {
|
|
1684
|
-
ixs.push(
|
|
1748
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction4(
|
|
1685
1749
|
this.walletPubkey,
|
|
1686
1750
|
clobNoAta,
|
|
1687
1751
|
clobConfig,
|
|
@@ -1865,7 +1929,8 @@ ${logs.join("\n")}`);
|
|
|
1865
1929
|
let feeAccounts = [];
|
|
1866
1930
|
if (takerSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
1867
1931
|
const companyAddr = await this.companyAddress();
|
|
1868
|
-
|
|
1932
|
+
const refVault = await this.referralVault();
|
|
1933
|
+
if (companyAddr && refVault) {
|
|
1869
1934
|
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
1870
1935
|
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
1871
1936
|
if (feeOverrideExists) {
|
|
@@ -1875,7 +1940,8 @@ ${logs.join("\n")}`);
|
|
|
1875
1940
|
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
1876
1941
|
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
1877
1942
|
{ pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
1878
|
-
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
1943
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true },
|
|
1944
|
+
{ pubkey: refVault, isSigner: false, isWritable: true }
|
|
1879
1945
|
];
|
|
1880
1946
|
}
|
|
1881
1947
|
}
|
|
@@ -2119,7 +2185,8 @@ ${logs.join("\n")}`);
|
|
|
2119
2185
|
);
|
|
2120
2186
|
if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
2121
2187
|
const companyAddr = await this.companyAddress();
|
|
2122
|
-
|
|
2188
|
+
const refVault = await this.referralVault();
|
|
2189
|
+
if (companyAddr && refVault) {
|
|
2123
2190
|
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2124
2191
|
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2125
2192
|
if (feeOverrideExists) {
|
|
@@ -2129,7 +2196,9 @@ ${logs.join("\n")}`);
|
|
|
2129
2196
|
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2130
2197
|
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2131
2198
|
{ pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2132
|
-
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
2199
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true },
|
|
2200
|
+
{ pubkey: refVault, isSigner: false, isWritable: true },
|
|
2201
|
+
{ pubkey: splToken.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }
|
|
2133
2202
|
);
|
|
2134
2203
|
}
|
|
2135
2204
|
}
|
|
@@ -2400,6 +2469,103 @@ ${logs.join("\n")}`);
|
|
|
2400
2469
|
}
|
|
2401
2470
|
return this._buildUnsignedVtx(ixs, alt, payer);
|
|
2402
2471
|
}
|
|
2472
|
+
// ─── batchCollectRedeemEarly ─────────────────────────────────────────────────
|
|
2473
|
+
/**
|
|
2474
|
+
* Build VersionedTransaction for batchCollectRedeemEarly.
|
|
2475
|
+
*
|
|
2476
|
+
* Flow: Ed25519 ix (user sigs) + batchCollectRedeemEarly ix.
|
|
2477
|
+
* Each SignedCollectFeeOrder authorizes CLOB to collect `amount` winning tokens
|
|
2478
|
+
* from that user, redeem via CTF, then distribute as fees.
|
|
2479
|
+
*
|
|
2480
|
+
* @param signedOrders - Array of { order, signature } from winning users
|
|
2481
|
+
* @param condition - Market condition PDA
|
|
2482
|
+
* @param outcomeIndex - 0 = NO wins, 1 = YES wins
|
|
2483
|
+
* @param operator - Whitelisted operator pubkey (must sign)
|
|
2484
|
+
* @param payer - Fee payer pubkey (must sign)
|
|
2485
|
+
* @param opts.marketOracleVault - MarketOracle vault for fee distribution
|
|
2486
|
+
*/
|
|
2487
|
+
async buildBatchCollectRedeemEarlyTx(signedOrders, condition, outcomeIndex, operator, payer, opts) {
|
|
2488
|
+
if (signedOrders.length === 0) throw new InvalidParamError("At least 1 order required");
|
|
2489
|
+
const collateralMint = this.networkConfig.defaultCollateral.mint;
|
|
2490
|
+
const cfg = await this.fetchConfig();
|
|
2491
|
+
if (!cfg) throw new InvalidParamError("CLOB config not found on-chain");
|
|
2492
|
+
const clobConfig = this.configPda();
|
|
2493
|
+
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
2494
|
+
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
2495
|
+
const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
|
|
2496
|
+
const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
|
|
2497
|
+
const clobYesAta = splToken.getAssociatedTokenAddressSync(yesMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
|
|
2498
|
+
const clobNoAta = splToken.getAssociatedTokenAddressSync(noMint, clobConfig, true, splToken.TOKEN_2022_PROGRAM_ID);
|
|
2499
|
+
const outcomeMint = outcomeIndex === 1 ? yesMint : noMint;
|
|
2500
|
+
const [extraAccountMeta] = PDA.extraAccountMetaList(outcomeMint, this.programIds);
|
|
2501
|
+
const [hookConfig] = PDA.hookConfig(this.programIds);
|
|
2502
|
+
const [clobYesPosition] = PDA.position(condition, 1, clobConfig, this.programIds);
|
|
2503
|
+
const [clobNoPosition] = PDA.position(condition, 0, clobConfig, this.programIds);
|
|
2504
|
+
const userAccounts = [];
|
|
2505
|
+
for (const { order } of signedOrders) {
|
|
2506
|
+
const userTokenAta = splToken.getAssociatedTokenAddressSync(outcomeMint, order.user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
2507
|
+
const [userPosition] = PDA.position(condition, outcomeIndex, order.user, this.programIds);
|
|
2508
|
+
userAccounts.push(
|
|
2509
|
+
{ pubkey: order.user, isSigner: false, isWritable: false },
|
|
2510
|
+
{ pubkey: userTokenAta, isSigner: false, isWritable: true },
|
|
2511
|
+
{ pubkey: userPosition, isSigner: false, isWritable: true }
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
const hookAccounts = [
|
|
2515
|
+
{ pubkey: extraAccountMeta, isSigner: false, isWritable: false },
|
|
2516
|
+
{ pubkey: hookConfig, isSigner: false, isWritable: false },
|
|
2517
|
+
{ pubkey: this.programIds.hook, isSigner: false, isWritable: false }
|
|
2518
|
+
];
|
|
2519
|
+
let feeAccounts = [];
|
|
2520
|
+
if (this.programIds.feeManagement && this.feeConfigOwner) {
|
|
2521
|
+
const companyAddr = await this.companyAddress();
|
|
2522
|
+
const refVault = await this.referralVault();
|
|
2523
|
+
if (companyAddr && refVault) {
|
|
2524
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2525
|
+
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2526
|
+
if (feeOverrideExists) {
|
|
2527
|
+
const oracleVault = opts?.marketOracleVault ?? payer;
|
|
2528
|
+
feeAccounts = [
|
|
2529
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2530
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2531
|
+
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2532
|
+
{ pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2533
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true },
|
|
2534
|
+
{ pubkey: refVault, isSigner: false, isWritable: true }
|
|
2535
|
+
];
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
await this._ensureClobOutcomeAtas(yesMint, noMint, clobConfig, clobYesAta, clobNoAta);
|
|
2540
|
+
const ed25519Ix = buildBatchedCollectFeeEd25519Instruction(signedOrders);
|
|
2541
|
+
const collectIx = await this.program.methods.batchCollectRedeemEarly(
|
|
2542
|
+
2,
|
|
2543
|
+
// ix_index: Ed25519 ix is ix[2] (cuLimit=0, heapFrame=1, ed25519=2)
|
|
2544
|
+
signedOrders.length,
|
|
2545
|
+
outcomeIndex
|
|
2546
|
+
).accounts({
|
|
2547
|
+
operator,
|
|
2548
|
+
payer,
|
|
2549
|
+
clobConfig,
|
|
2550
|
+
condition,
|
|
2551
|
+
collateralVault,
|
|
2552
|
+
vaultTokenAccount,
|
|
2553
|
+
feeRecipient: cfg.feeRecipient,
|
|
2554
|
+
yesMint,
|
|
2555
|
+
noMint,
|
|
2556
|
+
clobYesAta,
|
|
2557
|
+
clobNoAta,
|
|
2558
|
+
clobYesPosition,
|
|
2559
|
+
clobNoPosition,
|
|
2560
|
+
ixSysvar: IX_SYSVAR,
|
|
2561
|
+
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
2562
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
2563
|
+
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
2564
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
2565
|
+
}).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
|
|
2566
|
+
const cachedAlt = this._altCache.get(condition.toBase58());
|
|
2567
|
+
return this._buildUnsignedVtx([ed25519Ix, collectIx], cachedAlt, payer);
|
|
2568
|
+
}
|
|
2403
2569
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
2404
2570
|
async fetchConfig() {
|
|
2405
2571
|
try {
|
|
@@ -2448,20 +2614,22 @@ var FeeManagementClient = class {
|
|
|
2448
2614
|
this.provider = provider;
|
|
2449
2615
|
this.programIds = programIds;
|
|
2450
2616
|
}
|
|
2451
|
-
async initFeeConfig(
|
|
2452
|
-
const [feeConfigPda] = PDA.feeConfig(authority, this.programIds);
|
|
2617
|
+
async initFeeConfig(params) {
|
|
2618
|
+
const [feeConfigPda] = PDA.feeConfig(params.authority, this.programIds);
|
|
2453
2619
|
const sig = await this.program.methods.initialize({
|
|
2454
|
-
admin,
|
|
2455
|
-
companyAddress,
|
|
2456
|
-
referralAddress,
|
|
2457
|
-
presaleRevenueAddress,
|
|
2458
|
-
investorsMarketRev,
|
|
2459
|
-
companyMarketRev,
|
|
2460
|
-
agentsPresaleRev,
|
|
2461
|
-
companyPresaleRev
|
|
2620
|
+
admin: params.admin,
|
|
2621
|
+
companyAddress: params.companyAddress,
|
|
2622
|
+
referralAddress: params.referralAddress,
|
|
2623
|
+
presaleRevenueAddress: params.presaleRevenueAddress,
|
|
2624
|
+
investorsMarketRev: params.investorsMarketRev,
|
|
2625
|
+
companyMarketRev: params.companyMarketRev,
|
|
2626
|
+
agentsPresaleRev: params.agentsPresaleRev,
|
|
2627
|
+
companyPresaleRev: params.companyPresaleRev,
|
|
2628
|
+
referralMarketRev: params.referralMarketRev,
|
|
2629
|
+
referralVault: params.referralVault
|
|
2462
2630
|
}).accounts({
|
|
2463
|
-
authority,
|
|
2464
|
-
payer,
|
|
2631
|
+
authority: params.authority,
|
|
2632
|
+
payer: params.payer,
|
|
2465
2633
|
feeConfig: feeConfigPda,
|
|
2466
2634
|
systemProgram: web3_js.SystemProgram.programId
|
|
2467
2635
|
}).signers([]).rpc();
|
|
@@ -2509,19 +2677,21 @@ var FeeManagementClient = class {
|
|
|
2509
2677
|
* @param authority - signer authorized in fee_config whitelist / admin / owner
|
|
2510
2678
|
* @param payer - rent + tx fee payer
|
|
2511
2679
|
*/
|
|
2512
|
-
async updateFeeConfig(
|
|
2513
|
-
const [feeConfigPda] = PDA.feeConfig(authority, this.programIds);
|
|
2680
|
+
async updateFeeConfig(params) {
|
|
2681
|
+
const [feeConfigPda] = PDA.feeConfig(params.authority, this.programIds);
|
|
2514
2682
|
const sig = await this.program.methods.updateConfig({
|
|
2515
|
-
companyAddress,
|
|
2516
|
-
referralAddress,
|
|
2517
|
-
presaleRevenueAddress,
|
|
2518
|
-
investorsMarketRev,
|
|
2519
|
-
companyMarketRev,
|
|
2520
|
-
agentsPresaleRev,
|
|
2521
|
-
companyPresaleRev
|
|
2683
|
+
companyAddress: params.companyAddress,
|
|
2684
|
+
referralAddress: params.referralAddress,
|
|
2685
|
+
presaleRevenueAddress: params.presaleRevenueAddress,
|
|
2686
|
+
investorsMarketRev: params.investorsMarketRev,
|
|
2687
|
+
companyMarketRev: params.companyMarketRev,
|
|
2688
|
+
agentsPresaleRev: params.agentsPresaleRev,
|
|
2689
|
+
companyPresaleRev: params.companyPresaleRev,
|
|
2690
|
+
referralMarketRev: params.referralMarketRev,
|
|
2691
|
+
referralVault: params.referralVault
|
|
2522
2692
|
}).accounts({
|
|
2523
|
-
authority,
|
|
2524
|
-
payer,
|
|
2693
|
+
authority: params.authority,
|
|
2694
|
+
payer: params.payer,
|
|
2525
2695
|
feeConfig: feeConfigPda
|
|
2526
2696
|
}).signers([]).rpc();
|
|
2527
2697
|
return { signature: sig };
|
|
@@ -2538,33 +2708,33 @@ var FeeManagementClient = class {
|
|
|
2538
2708
|
}).signers([]).rpc();
|
|
2539
2709
|
return { signature: sig };
|
|
2540
2710
|
}
|
|
2541
|
-
|
|
2711
|
+
/**
|
|
2712
|
+
* Build editMarketFee transaction (whitelist-only).
|
|
2713
|
+
* @param conditionPda - condition PDA (market identifier)
|
|
2714
|
+
* @param mergeFee - out of FEE_DENOMINATOR (10_000), e.g. 2_000 = 20%
|
|
2715
|
+
* @param redeemFee - out of FEE_DENOMINATOR
|
|
2716
|
+
* @param swapFee - trading fee out of FEE_DENOMINATOR, e.g. 200 = 2%
|
|
2717
|
+
* @param feeConfigOwner - owner of fee_config PDA
|
|
2718
|
+
* @param authority - whitelisted signer (signs tx externally)
|
|
2719
|
+
* @param payer - fee payer (can differ from authority)
|
|
2720
|
+
*/
|
|
2721
|
+
async buildEditMarketFeeTx(conditionPda, mergeFee, redeemFee, swapFee, feeConfigOwner, authority, payer = authority) {
|
|
2542
2722
|
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2543
|
-
const [
|
|
2544
|
-
return this.program.methods.
|
|
2545
|
-
|
|
2546
|
-
|
|
2723
|
+
const [questionFeePda] = PDA.questionFee(conditionPda, this.programIds);
|
|
2724
|
+
return this.program.methods.setQuestionFee(
|
|
2725
|
+
Array.from(conditionPda.toBytes()),
|
|
2726
|
+
mergeFee,
|
|
2727
|
+
redeemFee,
|
|
2728
|
+
swapFee
|
|
2729
|
+
).accounts({
|
|
2547
2730
|
authority,
|
|
2548
|
-
|
|
2549
|
-
companyAta,
|
|
2550
|
-
marketOracleVault,
|
|
2551
|
-
tokenProgram: new web3_js.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
|
|
2552
|
-
}).instruction();
|
|
2553
|
-
}
|
|
2554
|
-
async distributeFee(conditionPda, amount, feeConfigOwner, sourceAta, companyAta, marketOracleVault, authority) {
|
|
2555
|
-
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2556
|
-
const [marketFeeOverridePda] = PDA.marketFeeOverride(conditionPda, this.programIds);
|
|
2557
|
-
const sig = await this.program.methods.distributeFee(conditionPda, amount).accounts({
|
|
2731
|
+
payer,
|
|
2558
2732
|
feeConfig: feeConfigPda,
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
companyAta,
|
|
2563
|
-
marketOracleVault,
|
|
2564
|
-
tokenProgram: new web3_js.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
|
|
2565
|
-
}).signers([]).rpc();
|
|
2566
|
-
return { signature: sig };
|
|
2733
|
+
questionFee: questionFeePda,
|
|
2734
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
2735
|
+
}).transaction();
|
|
2567
2736
|
}
|
|
2737
|
+
/** @deprecated use buildEditMarketFeeTx */
|
|
2568
2738
|
async setQuestionFee(conditionPda, mergeFee, redeemFee, swapFee, feeConfigOwner, authority, payer) {
|
|
2569
2739
|
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2570
2740
|
const [questionFeePda] = PDA.questionFee(conditionPda, this.programIds);
|
|
@@ -2582,6 +2752,25 @@ var FeeManagementClient = class {
|
|
|
2582
2752
|
}).signers([]).rpc();
|
|
2583
2753
|
return { signature: sig };
|
|
2584
2754
|
}
|
|
2755
|
+
/**
|
|
2756
|
+
* Build addToWhitelist tx — authority (admin/owner) signs externally.
|
|
2757
|
+
* Whitelist members can call editMarketFee / setQuestionFee.
|
|
2758
|
+
*/
|
|
2759
|
+
/** Build addToWhitelist tx — authority (admin/owner) signs externally. */
|
|
2760
|
+
async buildAddToWhitelistTx(address, feeConfigOwner, authority) {
|
|
2761
|
+
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2762
|
+
return this.program.methods.addToWhitelist(address).accounts({ authority, feeConfig: feeConfigPda }).transaction();
|
|
2763
|
+
}
|
|
2764
|
+
/** Build removeFromWhitelist tx — authority (admin/owner) signs externally. */
|
|
2765
|
+
async buildRemoveFromWhitelistTx(address, feeConfigOwner, authority) {
|
|
2766
|
+
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2767
|
+
return this.program.methods.removeFromWhitelist(address).accounts({ authority, feeConfig: feeConfigPda }).transaction();
|
|
2768
|
+
}
|
|
2769
|
+
/** Build setAdmin tx — only owner signs externally. */
|
|
2770
|
+
async buildSetAdminTx(newAdmin, feeConfigOwner, authority) {
|
|
2771
|
+
const [feeConfigPda] = PDA.feeConfig(feeConfigOwner, this.programIds);
|
|
2772
|
+
return this.program.methods.setAdmin(newAdmin).accounts({ authority, feeConfig: feeConfigPda }).transaction();
|
|
2773
|
+
}
|
|
2585
2774
|
};
|
|
2586
2775
|
var PresaleClient = class {
|
|
2587
2776
|
constructor(program, provider, programIds) {
|
|
@@ -2922,6 +3111,98 @@ var AdminClient = class {
|
|
|
2922
3111
|
}).transaction();
|
|
2923
3112
|
}
|
|
2924
3113
|
};
|
|
3114
|
+
var ReferralClient = class {
|
|
3115
|
+
constructor(program, provider, programIds) {
|
|
3116
|
+
this.program = program;
|
|
3117
|
+
this.provider = provider;
|
|
3118
|
+
this.programIds = programIds;
|
|
3119
|
+
}
|
|
3120
|
+
get walletPubkey() {
|
|
3121
|
+
return this.provider.wallet.publicKey;
|
|
3122
|
+
}
|
|
3123
|
+
referralVault(owner, collateralMint) {
|
|
3124
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3125
|
+
return splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3126
|
+
}
|
|
3127
|
+
async fetchConfig(owner) {
|
|
3128
|
+
try {
|
|
3129
|
+
const [pda] = PDA.referralConfig(owner, this.programIds);
|
|
3130
|
+
const acc = await this.program.account.referralConfig.fetch(pda);
|
|
3131
|
+
return {
|
|
3132
|
+
owner: acc.owner,
|
|
3133
|
+
collateralMint: acc.collateralMint,
|
|
3134
|
+
whitelist: acc.whitelist.slice(0, acc.whitelistLen),
|
|
3135
|
+
bump: acc.bump
|
|
3136
|
+
};
|
|
3137
|
+
} catch {
|
|
3138
|
+
return null;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
/**
|
|
3142
|
+
* Build initialize tx — creates referral config PDA.
|
|
3143
|
+
* Also prepends an ATA creation instruction for the referral vault (idempotent).
|
|
3144
|
+
* Build-tx pattern.
|
|
3145
|
+
*/
|
|
3146
|
+
async buildInitializeTx(collateralMint, owner = this.walletPubkey, payer = owner) {
|
|
3147
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3148
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3149
|
+
const vaultAta = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3150
|
+
const createVaultIx = splToken.createAssociatedTokenAccountIdempotentInstruction(
|
|
3151
|
+
payer,
|
|
3152
|
+
vaultAta,
|
|
3153
|
+
configPda,
|
|
3154
|
+
collateralMint
|
|
3155
|
+
);
|
|
3156
|
+
const initTx = await this.program.methods.initialize().accounts({
|
|
3157
|
+
owner,
|
|
3158
|
+
payer,
|
|
3159
|
+
config: configPda,
|
|
3160
|
+
collateralMint,
|
|
3161
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
3162
|
+
}).transaction();
|
|
3163
|
+
const tx = new web3_js.Transaction().add(createVaultIx, ...initTx.instructions);
|
|
3164
|
+
return { tx, configPda, vaultAta };
|
|
3165
|
+
}
|
|
3166
|
+
/** Build add-to-whitelist tx. Build-tx pattern. */
|
|
3167
|
+
async buildAddToWhitelistTx(address, owner = this.walletPubkey, payer = owner) {
|
|
3168
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3169
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3170
|
+
return this.program.methods.addToWhitelist(address).accounts({ owner, payer, config: configPda }).transaction();
|
|
3171
|
+
}
|
|
3172
|
+
/** Build remove-from-whitelist tx. Build-tx pattern. */
|
|
3173
|
+
async buildRemoveFromWhitelistTx(address, owner = this.walletPubkey, payer = owner) {
|
|
3174
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3175
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3176
|
+
return this.program.methods.removeFromWhitelist(address).accounts({ owner, payer, config: configPda }).transaction();
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Build batchSendUsds tx. Build-tx pattern.
|
|
3180
|
+
* @param recipients - wallet addresses to send to
|
|
3181
|
+
* @param amounts - corresponding amounts in token smallest units
|
|
3182
|
+
* @param configOwner - owner of referral config (used to derive config + vault)
|
|
3183
|
+
* @param collateralMint - token mint
|
|
3184
|
+
* @param authority - whitelisted signer
|
|
3185
|
+
* @param payer - fee payer (can differ from authority)
|
|
3186
|
+
*/
|
|
3187
|
+
async buildBatchSendUsdsTx(recipients, amounts, configOwner, collateralMint, authority = this.walletPubkey, payer = authority) {
|
|
3188
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3189
|
+
if (recipients.length !== amounts.length) throw new Error("recipients and amounts must have same length");
|
|
3190
|
+
if (recipients.length === 0) throw new Error("recipients array is empty");
|
|
3191
|
+
const [configPda] = PDA.referralConfig(configOwner, this.programIds);
|
|
3192
|
+
const referralVault = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3193
|
+
const recipientAtas = recipients.map(
|
|
3194
|
+
(wallet) => splToken.getAssociatedTokenAddressSync(collateralMint, wallet)
|
|
3195
|
+
);
|
|
3196
|
+
return this.program.methods.batchSendUsds(amounts).accounts({
|
|
3197
|
+
authority,
|
|
3198
|
+
config: configPda,
|
|
3199
|
+
referralVault,
|
|
3200
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
3201
|
+
}).remainingAccounts(
|
|
3202
|
+
recipientAtas.map((ata) => ({ pubkey: ata, isSigner: false, isWritable: true }))
|
|
3203
|
+
).transaction();
|
|
3204
|
+
}
|
|
3205
|
+
};
|
|
2925
3206
|
|
|
2926
3207
|
// src/idls/oracle.json
|
|
2927
3208
|
var oracle_default = {
|
|
@@ -8784,84 +9065,252 @@ var clob_exchange_default = {
|
|
|
8784
9065
|
]
|
|
8785
9066
|
},
|
|
8786
9067
|
{
|
|
8787
|
-
name: "
|
|
9068
|
+
name: "batch_collect_redeem_early",
|
|
8788
9069
|
docs: [
|
|
8789
|
-
"
|
|
9070
|
+
"Batch collect fee tokens from winning users after question resolution,",
|
|
9071
|
+
"redeem them via CTF, and distribute USDS via fee_management."
|
|
8790
9072
|
],
|
|
8791
9073
|
discriminator: [
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
9074
|
+
87,
|
|
9075
|
+
149,
|
|
9076
|
+
45,
|
|
9077
|
+
245,
|
|
9078
|
+
249,
|
|
9079
|
+
25,
|
|
9080
|
+
207,
|
|
9081
|
+
82
|
|
8800
9082
|
],
|
|
8801
9083
|
accounts: [
|
|
8802
9084
|
{
|
|
8803
|
-
name: "
|
|
8804
|
-
docs: [
|
|
8805
|
-
"Must be the order maker/signer"
|
|
8806
|
-
],
|
|
9085
|
+
name: "operator",
|
|
8807
9086
|
signer: true
|
|
8808
9087
|
},
|
|
8809
9088
|
{
|
|
8810
|
-
name: "
|
|
9089
|
+
name: "payer",
|
|
9090
|
+
writable: true,
|
|
9091
|
+
signer: true
|
|
9092
|
+
},
|
|
9093
|
+
{
|
|
9094
|
+
name: "clob_config",
|
|
8811
9095
|
writable: true,
|
|
8812
9096
|
pda: {
|
|
8813
9097
|
seeds: [
|
|
8814
9098
|
{
|
|
8815
9099
|
kind: "const",
|
|
8816
9100
|
value: [
|
|
9101
|
+
99,
|
|
9102
|
+
108,
|
|
8817
9103
|
111,
|
|
8818
|
-
|
|
8819
|
-
100,
|
|
8820
|
-
101,
|
|
8821
|
-
114,
|
|
9104
|
+
98,
|
|
8822
9105
|
95,
|
|
8823
|
-
114,
|
|
8824
|
-
101,
|
|
8825
9106
|
99,
|
|
8826
9107
|
111,
|
|
8827
|
-
|
|
8828
|
-
|
|
9108
|
+
110,
|
|
9109
|
+
102,
|
|
9110
|
+
105,
|
|
9111
|
+
103
|
|
8829
9112
|
]
|
|
8830
|
-
},
|
|
8831
|
-
{
|
|
8832
|
-
kind: "account",
|
|
8833
|
-
path: "maker"
|
|
8834
|
-
},
|
|
8835
|
-
{
|
|
8836
|
-
kind: "arg",
|
|
8837
|
-
path: "nonce"
|
|
8838
9113
|
}
|
|
8839
9114
|
]
|
|
8840
9115
|
}
|
|
8841
9116
|
},
|
|
8842
9117
|
{
|
|
8843
|
-
name: "
|
|
8844
|
-
|
|
8845
|
-
}
|
|
8846
|
-
],
|
|
8847
|
-
args: [
|
|
9118
|
+
name: "condition",
|
|
9119
|
+
writable: true
|
|
9120
|
+
},
|
|
8848
9121
|
{
|
|
8849
|
-
name: "
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
9122
|
+
name: "collateral_vault",
|
|
9123
|
+
writable: true,
|
|
9124
|
+
pda: {
|
|
9125
|
+
seeds: [
|
|
9126
|
+
{
|
|
9127
|
+
kind: "const",
|
|
9128
|
+
value: [
|
|
9129
|
+
99,
|
|
9130
|
+
111,
|
|
9131
|
+
108,
|
|
9132
|
+
108,
|
|
9133
|
+
97,
|
|
9134
|
+
116,
|
|
9135
|
+
101,
|
|
9136
|
+
114,
|
|
9137
|
+
97,
|
|
9138
|
+
108,
|
|
9139
|
+
95,
|
|
9140
|
+
118,
|
|
9141
|
+
97,
|
|
9142
|
+
117,
|
|
9143
|
+
108,
|
|
9144
|
+
116
|
|
9145
|
+
]
|
|
9146
|
+
},
|
|
9147
|
+
{
|
|
9148
|
+
kind: "account",
|
|
9149
|
+
path: "condition.collateral_mint",
|
|
9150
|
+
account: "Condition"
|
|
9151
|
+
}
|
|
9152
|
+
],
|
|
9153
|
+
program: {
|
|
9154
|
+
kind: "account",
|
|
9155
|
+
path: "conditional_tokens_program"
|
|
9156
|
+
}
|
|
9157
|
+
}
|
|
9158
|
+
},
|
|
9159
|
+
{
|
|
9160
|
+
name: "vault_token_account",
|
|
9161
|
+
writable: true
|
|
9162
|
+
},
|
|
9163
|
+
{
|
|
9164
|
+
name: "fee_recipient",
|
|
9165
|
+
docs: [
|
|
9166
|
+
"CLOB's USDS ATA \u2014 receives USDS payout from redeem, then distribute_fee draws from it."
|
|
9167
|
+
],
|
|
9168
|
+
writable: true
|
|
9169
|
+
},
|
|
9170
|
+
{
|
|
9171
|
+
name: "yes_mint",
|
|
9172
|
+
writable: true
|
|
9173
|
+
},
|
|
9174
|
+
{
|
|
9175
|
+
name: "no_mint",
|
|
9176
|
+
writable: true
|
|
9177
|
+
},
|
|
9178
|
+
{
|
|
9179
|
+
name: "clob_yes_ata",
|
|
9180
|
+
docs: [
|
|
9181
|
+
"CLOB's YES ATA (Token-2022) \u2014 must be pre-initialized (created during prior matchOrders)."
|
|
9182
|
+
],
|
|
9183
|
+
writable: true
|
|
9184
|
+
},
|
|
9185
|
+
{
|
|
9186
|
+
name: "clob_no_ata",
|
|
9187
|
+
docs: [
|
|
9188
|
+
"CLOB's NO ATA (Token-2022) \u2014 must be pre-initialized."
|
|
9189
|
+
],
|
|
9190
|
+
writable: true
|
|
9191
|
+
},
|
|
9192
|
+
{
|
|
9193
|
+
name: "clob_yes_position",
|
|
9194
|
+
writable: true
|
|
9195
|
+
},
|
|
9196
|
+
{
|
|
9197
|
+
name: "clob_no_position",
|
|
9198
|
+
writable: true
|
|
9199
|
+
},
|
|
9200
|
+
{
|
|
9201
|
+
name: "ix_sysvar"
|
|
9202
|
+
},
|
|
9203
|
+
{
|
|
9204
|
+
name: "conditional_tokens_program",
|
|
9205
|
+
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
9206
|
+
},
|
|
9207
|
+
{
|
|
9208
|
+
name: "token_program",
|
|
9209
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
9210
|
+
},
|
|
9211
|
+
{
|
|
9212
|
+
name: "token_2022_program",
|
|
9213
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
9214
|
+
},
|
|
9215
|
+
{
|
|
9216
|
+
name: "system_program",
|
|
9217
|
+
address: "11111111111111111111111111111111"
|
|
9218
|
+
}
|
|
9219
|
+
],
|
|
9220
|
+
args: [
|
|
9221
|
+
{
|
|
9222
|
+
name: "ix_index",
|
|
9223
|
+
type: "u8"
|
|
9224
|
+
},
|
|
9225
|
+
{
|
|
9226
|
+
name: "order_count",
|
|
9227
|
+
type: "u8"
|
|
9228
|
+
},
|
|
9229
|
+
{
|
|
9230
|
+
name: "outcome_index",
|
|
9231
|
+
type: "u8"
|
|
9232
|
+
}
|
|
9233
|
+
]
|
|
9234
|
+
},
|
|
9235
|
+
{
|
|
9236
|
+
name: "cancel_order",
|
|
9237
|
+
docs: [
|
|
9238
|
+
"Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
|
|
9239
|
+
],
|
|
9240
|
+
discriminator: [
|
|
9241
|
+
95,
|
|
9242
|
+
129,
|
|
9243
|
+
237,
|
|
9244
|
+
240,
|
|
9245
|
+
8,
|
|
9246
|
+
49,
|
|
9247
|
+
223,
|
|
9248
|
+
132
|
|
9249
|
+
],
|
|
9250
|
+
accounts: [
|
|
9251
|
+
{
|
|
9252
|
+
name: "maker",
|
|
9253
|
+
docs: [
|
|
9254
|
+
"Must be the order maker/signer"
|
|
9255
|
+
],
|
|
9256
|
+
signer: true
|
|
9257
|
+
},
|
|
9258
|
+
{
|
|
9259
|
+
name: "order_record",
|
|
9260
|
+
writable: true,
|
|
9261
|
+
pda: {
|
|
9262
|
+
seeds: [
|
|
9263
|
+
{
|
|
9264
|
+
kind: "const",
|
|
9265
|
+
value: [
|
|
9266
|
+
111,
|
|
9267
|
+
114,
|
|
9268
|
+
100,
|
|
9269
|
+
101,
|
|
9270
|
+
114,
|
|
9271
|
+
95,
|
|
9272
|
+
114,
|
|
9273
|
+
101,
|
|
9274
|
+
99,
|
|
9275
|
+
111,
|
|
9276
|
+
114,
|
|
9277
|
+
100
|
|
9278
|
+
]
|
|
9279
|
+
},
|
|
9280
|
+
{
|
|
9281
|
+
kind: "account",
|
|
9282
|
+
path: "maker"
|
|
9283
|
+
},
|
|
9284
|
+
{
|
|
9285
|
+
kind: "arg",
|
|
9286
|
+
path: "nonce"
|
|
9287
|
+
}
|
|
9288
|
+
]
|
|
9289
|
+
}
|
|
9290
|
+
},
|
|
9291
|
+
{
|
|
9292
|
+
name: "system_program",
|
|
9293
|
+
address: "11111111111111111111111111111111"
|
|
9294
|
+
}
|
|
9295
|
+
],
|
|
9296
|
+
args: [
|
|
9297
|
+
{
|
|
9298
|
+
name: "nonce",
|
|
9299
|
+
type: "u64"
|
|
9300
|
+
}
|
|
9301
|
+
]
|
|
9302
|
+
},
|
|
9303
|
+
{
|
|
9304
|
+
name: "force_reset_clob",
|
|
9305
|
+
discriminator: [
|
|
9306
|
+
96,
|
|
9307
|
+
95,
|
|
9308
|
+
187,
|
|
9309
|
+
95,
|
|
9310
|
+
65,
|
|
9311
|
+
135,
|
|
9312
|
+
120,
|
|
9313
|
+
204
|
|
8865
9314
|
],
|
|
8866
9315
|
accounts: [
|
|
8867
9316
|
{
|
|
@@ -8996,7 +9445,7 @@ var clob_exchange_default = {
|
|
|
8996
9445
|
{
|
|
8997
9446
|
name: "match_complementary",
|
|
8998
9447
|
docs: [
|
|
8999
|
-
"COMPLEMENTARY match: 1 taker (BUY) + N makers (
|
|
9448
|
+
"COMPLEMENTARY match: 1 taker (BUY or SELL) + N makers (opposite side) via remaining_accounts."
|
|
9000
9449
|
],
|
|
9001
9450
|
discriminator: [
|
|
9002
9451
|
100,
|
|
@@ -9289,9 +9738,6 @@ var clob_exchange_default = {
|
|
|
9289
9738
|
},
|
|
9290
9739
|
{
|
|
9291
9740
|
name: "clob_usdc_ata",
|
|
9292
|
-
docs: [
|
|
9293
|
-
"USDC ATA owned by clob_config \u2014 receives USDC from vault after merge"
|
|
9294
|
-
],
|
|
9295
9741
|
writable: true,
|
|
9296
9742
|
pda: {
|
|
9297
9743
|
seeds: [
|
|
@@ -9568,9 +10014,6 @@ var clob_exchange_default = {
|
|
|
9568
10014
|
},
|
|
9569
10015
|
{
|
|
9570
10016
|
name: "clob_usdc_ata",
|
|
9571
|
-
docs: [
|
|
9572
|
-
"USDC ATA owned by clob_config \u2014 receives combined USDC, then split_position pulls from here"
|
|
9573
|
-
],
|
|
9574
10017
|
writable: true,
|
|
9575
10018
|
pda: {
|
|
9576
10019
|
seeds: [
|
|
@@ -9628,30 +10071,18 @@ var clob_exchange_default = {
|
|
|
9628
10071
|
},
|
|
9629
10072
|
{
|
|
9630
10073
|
name: "clob_yes_ata",
|
|
9631
|
-
docs: [
|
|
9632
|
-
"YES Token-2022 ATA owned by clob_config \u2014 receives YES from split, then transferred to taker"
|
|
9633
|
-
],
|
|
9634
10074
|
writable: true
|
|
9635
10075
|
},
|
|
9636
10076
|
{
|
|
9637
10077
|
name: "clob_no_ata",
|
|
9638
|
-
docs: [
|
|
9639
|
-
"NO Token-2022 ATA owned by clob_config \u2014 receives NO from split, then transferred to makers"
|
|
9640
|
-
],
|
|
9641
10078
|
writable: true
|
|
9642
10079
|
},
|
|
9643
10080
|
{
|
|
9644
10081
|
name: "clob_yes_position",
|
|
9645
|
-
docs: [
|
|
9646
|
-
"YES Position PDA for clob_config (set by CTF split_position init_if_needed)"
|
|
9647
|
-
],
|
|
9648
10082
|
writable: true
|
|
9649
10083
|
},
|
|
9650
10084
|
{
|
|
9651
10085
|
name: "clob_no_position",
|
|
9652
|
-
docs: [
|
|
9653
|
-
"NO Position PDA for clob_config (set by CTF split_position init_if_needed)"
|
|
9654
|
-
],
|
|
9655
10086
|
writable: true
|
|
9656
10087
|
},
|
|
9657
10088
|
{
|
|
@@ -10565,11 +10996,6 @@ var fee_management_default = {
|
|
|
10565
10996
|
name: "authority",
|
|
10566
10997
|
signer: true
|
|
10567
10998
|
},
|
|
10568
|
-
{
|
|
10569
|
-
name: "payer",
|
|
10570
|
-
writable: true,
|
|
10571
|
-
signer: true
|
|
10572
|
-
},
|
|
10573
10999
|
{
|
|
10574
11000
|
name: "fee_config",
|
|
10575
11001
|
writable: true,
|
|
@@ -10687,11 +11113,18 @@ var fee_management_default = {
|
|
|
10687
11113
|
{
|
|
10688
11114
|
name: "market_oracle_vault",
|
|
10689
11115
|
docs: [
|
|
10690
|
-
"Writable: tokens are transferred here when is_admin=false.",
|
|
11116
|
+
"Writable: tokens are transferred here (investors share) when is_admin=false.",
|
|
10691
11117
|
"For admin questions pass any writable account (no transfer occurs)."
|
|
10692
11118
|
],
|
|
10693
11119
|
writable: true
|
|
10694
11120
|
},
|
|
11121
|
+
{
|
|
11122
|
+
name: "referral_vault",
|
|
11123
|
+
docs: [
|
|
11124
|
+
"Must match fee_config.referral_vault."
|
|
11125
|
+
],
|
|
11126
|
+
writable: true
|
|
11127
|
+
},
|
|
10695
11128
|
{
|
|
10696
11129
|
name: "token_program",
|
|
10697
11130
|
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
@@ -10854,11 +11287,6 @@ var fee_management_default = {
|
|
|
10854
11287
|
name: "authority",
|
|
10855
11288
|
signer: true
|
|
10856
11289
|
},
|
|
10857
|
-
{
|
|
10858
|
-
name: "payer",
|
|
10859
|
-
writable: true,
|
|
10860
|
-
signer: true
|
|
10861
|
-
},
|
|
10862
11290
|
{
|
|
10863
11291
|
name: "fee_config",
|
|
10864
11292
|
writable: true,
|
|
@@ -10912,11 +11340,6 @@ var fee_management_default = {
|
|
|
10912
11340
|
name: "authority",
|
|
10913
11341
|
signer: true
|
|
10914
11342
|
},
|
|
10915
|
-
{
|
|
10916
|
-
name: "payer",
|
|
10917
|
-
writable: true,
|
|
10918
|
-
signer: true
|
|
10919
|
-
},
|
|
10920
11343
|
{
|
|
10921
11344
|
name: "fee_config",
|
|
10922
11345
|
writable: true,
|
|
@@ -11550,7 +11973,8 @@ var fee_management_default = {
|
|
|
11550
11973
|
{
|
|
11551
11974
|
name: "investors_market_rev",
|
|
11552
11975
|
docs: [
|
|
11553
|
-
"Market revenue split
|
|
11976
|
+
"Market revenue split \u2014 three parts must sum to FEE_DENOMINATOR (10_000).",
|
|
11977
|
+
"investors_market_rev + company_market_rev + referral_market_rev == 10_000"
|
|
11554
11978
|
],
|
|
11555
11979
|
type: "u32"
|
|
11556
11980
|
},
|
|
@@ -11561,7 +11985,7 @@ var fee_management_default = {
|
|
|
11561
11985
|
{
|
|
11562
11986
|
name: "agents_presale_rev",
|
|
11563
11987
|
docs: [
|
|
11564
|
-
"Presale revenue split: agents + company (out of FEE_DENOMINATOR =
|
|
11988
|
+
"Presale revenue split: agents + company (out of FEE_DENOMINATOR = 10_000)"
|
|
11565
11989
|
],
|
|
11566
11990
|
type: "u32"
|
|
11567
11991
|
},
|
|
@@ -11586,12 +12010,26 @@ var fee_management_default = {
|
|
|
11586
12010
|
name: "bump",
|
|
11587
12011
|
type: "u8"
|
|
11588
12012
|
},
|
|
12013
|
+
{
|
|
12014
|
+
name: "referral_market_rev",
|
|
12015
|
+
docs: [
|
|
12016
|
+
"Share of market trading fees routed to referral_vault (e.g. 2_000 = 20%)"
|
|
12017
|
+
],
|
|
12018
|
+
type: "u32"
|
|
12019
|
+
},
|
|
12020
|
+
{
|
|
12021
|
+
name: "referral_vault",
|
|
12022
|
+
docs: [
|
|
12023
|
+
"ATA of referral program config PDA \u2014 receives referral_market_rev% of trading fees"
|
|
12024
|
+
],
|
|
12025
|
+
type: "pubkey"
|
|
12026
|
+
},
|
|
11589
12027
|
{
|
|
11590
12028
|
name: "_reserved",
|
|
11591
12029
|
type: {
|
|
11592
12030
|
array: [
|
|
11593
12031
|
"u8",
|
|
11594
|
-
|
|
12032
|
+
28
|
|
11595
12033
|
]
|
|
11596
12034
|
}
|
|
11597
12035
|
}
|
|
@@ -11718,6 +12156,14 @@ var fee_management_default = {
|
|
|
11718
12156
|
{
|
|
11719
12157
|
name: "company_presale_rev",
|
|
11720
12158
|
type: "u32"
|
|
12159
|
+
},
|
|
12160
|
+
{
|
|
12161
|
+
name: "referral_market_rev",
|
|
12162
|
+
type: "u32"
|
|
12163
|
+
},
|
|
12164
|
+
{
|
|
12165
|
+
name: "referral_vault",
|
|
12166
|
+
type: "pubkey"
|
|
11721
12167
|
}
|
|
11722
12168
|
]
|
|
11723
12169
|
}
|
|
@@ -11978,6 +12424,14 @@ var fee_management_default = {
|
|
|
11978
12424
|
{
|
|
11979
12425
|
name: "company_presale_rev",
|
|
11980
12426
|
type: "u32"
|
|
12427
|
+
},
|
|
12428
|
+
{
|
|
12429
|
+
name: "referral_market_rev",
|
|
12430
|
+
type: "u32"
|
|
12431
|
+
},
|
|
12432
|
+
{
|
|
12433
|
+
name: "referral_vault",
|
|
12434
|
+
type: "pubkey"
|
|
11981
12435
|
}
|
|
11982
12436
|
]
|
|
11983
12437
|
}
|
|
@@ -15326,20 +15780,510 @@ var admin_contract_default = {
|
|
|
15326
15780
|
]
|
|
15327
15781
|
};
|
|
15328
15782
|
|
|
15329
|
-
// src/
|
|
15330
|
-
var
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15783
|
+
// src/idls/referral.json
|
|
15784
|
+
var referral_default = {
|
|
15785
|
+
address: "7b5ohWDqrQ2KRcDJMWwj1dwgRkt5ZJdMavSmrXn9oBgL",
|
|
15786
|
+
metadata: {
|
|
15787
|
+
name: "referral",
|
|
15788
|
+
version: "0.1.0",
|
|
15789
|
+
spec: "0.1.0",
|
|
15790
|
+
description: "Referral program for XMarket \u2014 whitelist-gated batch USDS distribution"
|
|
15791
|
+
},
|
|
15792
|
+
instructions: [
|
|
15793
|
+
{
|
|
15794
|
+
name: "add_to_whitelist",
|
|
15795
|
+
discriminator: [
|
|
15796
|
+
157,
|
|
15797
|
+
211,
|
|
15798
|
+
52,
|
|
15799
|
+
54,
|
|
15800
|
+
144,
|
|
15801
|
+
81,
|
|
15802
|
+
5,
|
|
15803
|
+
55
|
|
15804
|
+
],
|
|
15805
|
+
accounts: [
|
|
15806
|
+
{
|
|
15807
|
+
name: "owner",
|
|
15808
|
+
signer: true
|
|
15809
|
+
},
|
|
15810
|
+
{
|
|
15811
|
+
name: "payer",
|
|
15812
|
+
writable: true,
|
|
15813
|
+
signer: true
|
|
15814
|
+
},
|
|
15815
|
+
{
|
|
15816
|
+
name: "config",
|
|
15817
|
+
writable: true,
|
|
15818
|
+
pda: {
|
|
15819
|
+
seeds: [
|
|
15820
|
+
{
|
|
15821
|
+
kind: "const",
|
|
15822
|
+
value: [
|
|
15823
|
+
114,
|
|
15824
|
+
101,
|
|
15825
|
+
102,
|
|
15826
|
+
101,
|
|
15827
|
+
114,
|
|
15828
|
+
114,
|
|
15829
|
+
97,
|
|
15830
|
+
108,
|
|
15831
|
+
95,
|
|
15832
|
+
99,
|
|
15833
|
+
111,
|
|
15834
|
+
110,
|
|
15835
|
+
102,
|
|
15836
|
+
105,
|
|
15837
|
+
103
|
|
15838
|
+
]
|
|
15839
|
+
},
|
|
15840
|
+
{
|
|
15841
|
+
kind: "account",
|
|
15842
|
+
path: "config.owner",
|
|
15843
|
+
account: "ReferralConfig"
|
|
15844
|
+
}
|
|
15845
|
+
]
|
|
15846
|
+
}
|
|
15847
|
+
}
|
|
15848
|
+
],
|
|
15849
|
+
args: [
|
|
15850
|
+
{
|
|
15851
|
+
name: "address",
|
|
15852
|
+
type: "pubkey"
|
|
15853
|
+
}
|
|
15854
|
+
]
|
|
15855
|
+
},
|
|
15856
|
+
{
|
|
15857
|
+
name: "batch_send_usds",
|
|
15858
|
+
discriminator: [
|
|
15859
|
+
255,
|
|
15860
|
+
33,
|
|
15861
|
+
77,
|
|
15862
|
+
124,
|
|
15863
|
+
42,
|
|
15864
|
+
207,
|
|
15865
|
+
250,
|
|
15866
|
+
162
|
|
15867
|
+
],
|
|
15868
|
+
accounts: [
|
|
15869
|
+
{
|
|
15870
|
+
name: "authority",
|
|
15871
|
+
docs: [
|
|
15872
|
+
"Whitelisted caller (authority, signs tx)"
|
|
15873
|
+
],
|
|
15874
|
+
signer: true
|
|
15875
|
+
},
|
|
15876
|
+
{
|
|
15877
|
+
name: "config",
|
|
15878
|
+
pda: {
|
|
15879
|
+
seeds: [
|
|
15880
|
+
{
|
|
15881
|
+
kind: "const",
|
|
15882
|
+
value: [
|
|
15883
|
+
114,
|
|
15884
|
+
101,
|
|
15885
|
+
102,
|
|
15886
|
+
101,
|
|
15887
|
+
114,
|
|
15888
|
+
114,
|
|
15889
|
+
97,
|
|
15890
|
+
108,
|
|
15891
|
+
95,
|
|
15892
|
+
99,
|
|
15893
|
+
111,
|
|
15894
|
+
110,
|
|
15895
|
+
102,
|
|
15896
|
+
105,
|
|
15897
|
+
103
|
|
15898
|
+
]
|
|
15899
|
+
},
|
|
15900
|
+
{
|
|
15901
|
+
kind: "account",
|
|
15902
|
+
path: "config.owner",
|
|
15903
|
+
account: "ReferralConfig"
|
|
15904
|
+
}
|
|
15905
|
+
]
|
|
15906
|
+
}
|
|
15907
|
+
},
|
|
15908
|
+
{
|
|
15909
|
+
name: "referral_vault",
|
|
15910
|
+
docs: [
|
|
15911
|
+
"Referral vault \u2014 source of transfers (ATA owned by config PDA)"
|
|
15912
|
+
],
|
|
15913
|
+
writable: true,
|
|
15914
|
+
pda: {
|
|
15915
|
+
seeds: [
|
|
15916
|
+
{
|
|
15917
|
+
kind: "account",
|
|
15918
|
+
path: "config"
|
|
15919
|
+
},
|
|
15920
|
+
{
|
|
15921
|
+
kind: "const",
|
|
15922
|
+
value: [
|
|
15923
|
+
6,
|
|
15924
|
+
221,
|
|
15925
|
+
246,
|
|
15926
|
+
225,
|
|
15927
|
+
215,
|
|
15928
|
+
101,
|
|
15929
|
+
161,
|
|
15930
|
+
147,
|
|
15931
|
+
217,
|
|
15932
|
+
203,
|
|
15933
|
+
225,
|
|
15934
|
+
70,
|
|
15935
|
+
206,
|
|
15936
|
+
235,
|
|
15937
|
+
121,
|
|
15938
|
+
172,
|
|
15939
|
+
28,
|
|
15940
|
+
180,
|
|
15941
|
+
133,
|
|
15942
|
+
237,
|
|
15943
|
+
95,
|
|
15944
|
+
91,
|
|
15945
|
+
55,
|
|
15946
|
+
145,
|
|
15947
|
+
58,
|
|
15948
|
+
140,
|
|
15949
|
+
245,
|
|
15950
|
+
133,
|
|
15951
|
+
126,
|
|
15952
|
+
255,
|
|
15953
|
+
0,
|
|
15954
|
+
169
|
|
15955
|
+
]
|
|
15956
|
+
},
|
|
15957
|
+
{
|
|
15958
|
+
kind: "account",
|
|
15959
|
+
path: "config.collateral_mint",
|
|
15960
|
+
account: "ReferralConfig"
|
|
15961
|
+
}
|
|
15962
|
+
],
|
|
15963
|
+
program: {
|
|
15964
|
+
kind: "const",
|
|
15965
|
+
value: [
|
|
15966
|
+
140,
|
|
15967
|
+
151,
|
|
15968
|
+
37,
|
|
15969
|
+
143,
|
|
15970
|
+
78,
|
|
15971
|
+
36,
|
|
15972
|
+
137,
|
|
15973
|
+
241,
|
|
15974
|
+
187,
|
|
15975
|
+
61,
|
|
15976
|
+
16,
|
|
15977
|
+
41,
|
|
15978
|
+
20,
|
|
15979
|
+
142,
|
|
15980
|
+
13,
|
|
15981
|
+
131,
|
|
15982
|
+
11,
|
|
15983
|
+
90,
|
|
15984
|
+
19,
|
|
15985
|
+
153,
|
|
15986
|
+
218,
|
|
15987
|
+
255,
|
|
15988
|
+
16,
|
|
15989
|
+
132,
|
|
15990
|
+
4,
|
|
15991
|
+
142,
|
|
15992
|
+
123,
|
|
15993
|
+
216,
|
|
15994
|
+
219,
|
|
15995
|
+
233,
|
|
15996
|
+
248,
|
|
15997
|
+
89
|
|
15998
|
+
]
|
|
15999
|
+
}
|
|
16000
|
+
}
|
|
16001
|
+
},
|
|
16002
|
+
{
|
|
16003
|
+
name: "token_program",
|
|
16004
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
16005
|
+
}
|
|
16006
|
+
],
|
|
16007
|
+
args: [
|
|
16008
|
+
{
|
|
16009
|
+
name: "amounts",
|
|
16010
|
+
type: {
|
|
16011
|
+
vec: "u64"
|
|
16012
|
+
}
|
|
16013
|
+
}
|
|
16014
|
+
]
|
|
16015
|
+
},
|
|
16016
|
+
{
|
|
16017
|
+
name: "initialize",
|
|
16018
|
+
discriminator: [
|
|
16019
|
+
175,
|
|
16020
|
+
175,
|
|
16021
|
+
109,
|
|
16022
|
+
31,
|
|
16023
|
+
13,
|
|
16024
|
+
152,
|
|
16025
|
+
155,
|
|
16026
|
+
237
|
|
16027
|
+
],
|
|
16028
|
+
accounts: [
|
|
16029
|
+
{
|
|
16030
|
+
name: "owner",
|
|
16031
|
+
writable: true,
|
|
16032
|
+
signer: true
|
|
16033
|
+
},
|
|
16034
|
+
{
|
|
16035
|
+
name: "payer",
|
|
16036
|
+
writable: true,
|
|
16037
|
+
signer: true
|
|
16038
|
+
},
|
|
16039
|
+
{
|
|
16040
|
+
name: "config",
|
|
16041
|
+
writable: true,
|
|
16042
|
+
pda: {
|
|
16043
|
+
seeds: [
|
|
16044
|
+
{
|
|
16045
|
+
kind: "const",
|
|
16046
|
+
value: [
|
|
16047
|
+
114,
|
|
16048
|
+
101,
|
|
16049
|
+
102,
|
|
16050
|
+
101,
|
|
16051
|
+
114,
|
|
16052
|
+
114,
|
|
16053
|
+
97,
|
|
16054
|
+
108,
|
|
16055
|
+
95,
|
|
16056
|
+
99,
|
|
16057
|
+
111,
|
|
16058
|
+
110,
|
|
16059
|
+
102,
|
|
16060
|
+
105,
|
|
16061
|
+
103
|
|
16062
|
+
]
|
|
16063
|
+
},
|
|
16064
|
+
{
|
|
16065
|
+
kind: "account",
|
|
16066
|
+
path: "owner"
|
|
16067
|
+
}
|
|
16068
|
+
]
|
|
16069
|
+
}
|
|
16070
|
+
},
|
|
16071
|
+
{
|
|
16072
|
+
name: "collateral_mint"
|
|
16073
|
+
},
|
|
16074
|
+
{
|
|
16075
|
+
name: "system_program",
|
|
16076
|
+
address: "11111111111111111111111111111111"
|
|
16077
|
+
}
|
|
16078
|
+
],
|
|
16079
|
+
args: []
|
|
16080
|
+
},
|
|
16081
|
+
{
|
|
16082
|
+
name: "remove_from_whitelist",
|
|
16083
|
+
discriminator: [
|
|
16084
|
+
7,
|
|
16085
|
+
144,
|
|
16086
|
+
216,
|
|
16087
|
+
239,
|
|
16088
|
+
243,
|
|
16089
|
+
236,
|
|
16090
|
+
193,
|
|
16091
|
+
235
|
|
16092
|
+
],
|
|
16093
|
+
accounts: [
|
|
16094
|
+
{
|
|
16095
|
+
name: "owner",
|
|
16096
|
+
signer: true
|
|
16097
|
+
},
|
|
16098
|
+
{
|
|
16099
|
+
name: "payer",
|
|
16100
|
+
writable: true,
|
|
16101
|
+
signer: true
|
|
16102
|
+
},
|
|
16103
|
+
{
|
|
16104
|
+
name: "config",
|
|
16105
|
+
writable: true,
|
|
16106
|
+
pda: {
|
|
16107
|
+
seeds: [
|
|
16108
|
+
{
|
|
16109
|
+
kind: "const",
|
|
16110
|
+
value: [
|
|
16111
|
+
114,
|
|
16112
|
+
101,
|
|
16113
|
+
102,
|
|
16114
|
+
101,
|
|
16115
|
+
114,
|
|
16116
|
+
114,
|
|
16117
|
+
97,
|
|
16118
|
+
108,
|
|
16119
|
+
95,
|
|
16120
|
+
99,
|
|
16121
|
+
111,
|
|
16122
|
+
110,
|
|
16123
|
+
102,
|
|
16124
|
+
105,
|
|
16125
|
+
103
|
|
16126
|
+
]
|
|
16127
|
+
},
|
|
16128
|
+
{
|
|
16129
|
+
kind: "account",
|
|
16130
|
+
path: "config.owner",
|
|
16131
|
+
account: "ReferralConfig"
|
|
16132
|
+
}
|
|
16133
|
+
]
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
],
|
|
16137
|
+
args: [
|
|
16138
|
+
{
|
|
16139
|
+
name: "address",
|
|
16140
|
+
type: "pubkey"
|
|
16141
|
+
}
|
|
16142
|
+
]
|
|
16143
|
+
}
|
|
16144
|
+
],
|
|
16145
|
+
accounts: [
|
|
16146
|
+
{
|
|
16147
|
+
name: "ReferralConfig",
|
|
16148
|
+
discriminator: [
|
|
16149
|
+
102,
|
|
16150
|
+
148,
|
|
16151
|
+
171,
|
|
16152
|
+
235,
|
|
16153
|
+
148,
|
|
16154
|
+
83,
|
|
16155
|
+
250,
|
|
16156
|
+
140
|
|
16157
|
+
]
|
|
16158
|
+
}
|
|
16159
|
+
],
|
|
16160
|
+
events: [
|
|
16161
|
+
{
|
|
16162
|
+
name: "BatchSent",
|
|
16163
|
+
discriminator: [
|
|
16164
|
+
116,
|
|
16165
|
+
64,
|
|
16166
|
+
207,
|
|
16167
|
+
63,
|
|
16168
|
+
56,
|
|
16169
|
+
97,
|
|
16170
|
+
15,
|
|
16171
|
+
100
|
|
16172
|
+
]
|
|
16173
|
+
},
|
|
16174
|
+
{
|
|
16175
|
+
name: "ReferralInitialized",
|
|
16176
|
+
discriminator: [
|
|
16177
|
+
129,
|
|
16178
|
+
190,
|
|
16179
|
+
249,
|
|
16180
|
+
4,
|
|
16181
|
+
198,
|
|
16182
|
+
5,
|
|
16183
|
+
141,
|
|
16184
|
+
226
|
|
16185
|
+
]
|
|
16186
|
+
}
|
|
16187
|
+
],
|
|
16188
|
+
types: [
|
|
16189
|
+
{
|
|
16190
|
+
name: "BatchSent",
|
|
16191
|
+
type: {
|
|
16192
|
+
kind: "struct",
|
|
16193
|
+
fields: [
|
|
16194
|
+
{
|
|
16195
|
+
name: "config",
|
|
16196
|
+
type: "pubkey"
|
|
16197
|
+
},
|
|
16198
|
+
{
|
|
16199
|
+
name: "sent_by",
|
|
16200
|
+
type: "pubkey"
|
|
16201
|
+
},
|
|
16202
|
+
{
|
|
16203
|
+
name: "recipients",
|
|
16204
|
+
type: "u8"
|
|
16205
|
+
}
|
|
16206
|
+
]
|
|
16207
|
+
}
|
|
16208
|
+
},
|
|
16209
|
+
{
|
|
16210
|
+
name: "ReferralConfig",
|
|
16211
|
+
type: {
|
|
16212
|
+
kind: "struct",
|
|
16213
|
+
fields: [
|
|
16214
|
+
{
|
|
16215
|
+
name: "version",
|
|
16216
|
+
type: "u8"
|
|
16217
|
+
},
|
|
16218
|
+
{
|
|
16219
|
+
name: "owner",
|
|
16220
|
+
type: "pubkey"
|
|
16221
|
+
},
|
|
16222
|
+
{
|
|
16223
|
+
name: "collateral_mint",
|
|
16224
|
+
type: "pubkey"
|
|
16225
|
+
},
|
|
16226
|
+
{
|
|
16227
|
+
name: "whitelist",
|
|
16228
|
+
type: {
|
|
16229
|
+
array: [
|
|
16230
|
+
"pubkey",
|
|
16231
|
+
10
|
|
16232
|
+
]
|
|
16233
|
+
}
|
|
16234
|
+
},
|
|
16235
|
+
{
|
|
16236
|
+
name: "whitelist_len",
|
|
16237
|
+
type: "u8"
|
|
16238
|
+
},
|
|
16239
|
+
{
|
|
16240
|
+
name: "bump",
|
|
16241
|
+
type: "u8"
|
|
16242
|
+
},
|
|
16243
|
+
{
|
|
16244
|
+
name: "_reserved",
|
|
16245
|
+
type: {
|
|
16246
|
+
array: [
|
|
16247
|
+
"u8",
|
|
16248
|
+
64
|
|
16249
|
+
]
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
]
|
|
16253
|
+
}
|
|
16254
|
+
},
|
|
16255
|
+
{
|
|
16256
|
+
name: "ReferralInitialized",
|
|
16257
|
+
type: {
|
|
16258
|
+
kind: "struct",
|
|
16259
|
+
fields: [
|
|
16260
|
+
{
|
|
16261
|
+
name: "config",
|
|
16262
|
+
type: "pubkey"
|
|
16263
|
+
},
|
|
16264
|
+
{
|
|
16265
|
+
name: "owner",
|
|
16266
|
+
type: "pubkey"
|
|
16267
|
+
}
|
|
16268
|
+
]
|
|
16269
|
+
}
|
|
16270
|
+
}
|
|
16271
|
+
]
|
|
16272
|
+
};
|
|
16273
|
+
|
|
16274
|
+
// src/sdk.ts
|
|
16275
|
+
var XMarketSDK = class {
|
|
16276
|
+
constructor(config, wallet, marketOwner) {
|
|
16277
|
+
this.networkConfig = config;
|
|
16278
|
+
this.provider = new anchor5__namespace.AnchorProvider(
|
|
16279
|
+
new web3_js.Connection(config.rpcUrl, "confirmed"),
|
|
16280
|
+
wallet,
|
|
16281
|
+
{ commitment: "confirmed", preflightCommitment: "confirmed" }
|
|
16282
|
+
);
|
|
16283
|
+
anchor5__namespace.setProvider(this.provider);
|
|
16284
|
+
this._programIds = config.programIds;
|
|
16285
|
+
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
16286
|
+
}
|
|
15343
16287
|
_withAddress(idl, address) {
|
|
15344
16288
|
return { ...idl, address: address.toBase58() };
|
|
15345
16289
|
}
|
|
@@ -15415,6 +16359,14 @@ var XMarketSDK = class {
|
|
|
15415
16359
|
}
|
|
15416
16360
|
return this._admin;
|
|
15417
16361
|
}
|
|
16362
|
+
get referral() {
|
|
16363
|
+
if (!this._referral) {
|
|
16364
|
+
if (!this._programIds.referral) throw new Error("referral program ID not configured in NetworkConfig");
|
|
16365
|
+
const program = new anchor5__namespace.Program(this._withAddress(referral_default, this._programIds.referral), this.provider);
|
|
16366
|
+
this._referral = new ReferralClient(program, this.provider, this._programIds);
|
|
16367
|
+
}
|
|
16368
|
+
return this._referral;
|
|
16369
|
+
}
|
|
15418
16370
|
};
|
|
15419
16371
|
var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
15420
16372
|
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
@@ -15503,12 +16455,14 @@ exports.OracleClient = OracleClient;
|
|
|
15503
16455
|
exports.PDA = PDA;
|
|
15504
16456
|
exports.PresaleClient = PresaleClient;
|
|
15505
16457
|
exports.QuestionStatus = QuestionStatus;
|
|
16458
|
+
exports.ReferralClient = ReferralClient;
|
|
15506
16459
|
exports.SEEDS = SEEDS;
|
|
15507
16460
|
exports.UnauthorizedError = UnauthorizedError;
|
|
15508
16461
|
exports.XMarketError = XMarketError;
|
|
15509
16462
|
exports.XMarketSDK = XMarketSDK;
|
|
15510
16463
|
exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
|
|
15511
16464
|
exports.buildApproveCollateralTx = buildApproveCollateralTx;
|
|
16465
|
+
exports.buildBatchedCollectFeeEd25519Instruction = buildBatchedCollectFeeEd25519Instruction;
|
|
15512
16466
|
exports.buildBatchedEd25519Instruction = buildBatchedEd25519Instruction;
|
|
15513
16467
|
exports.buildCreateUserAtasTx = buildCreateUserAtasTx;
|
|
15514
16468
|
exports.buildOrder = buildOrder;
|
|
@@ -15519,6 +16473,7 @@ exports.generateContentHash = generateContentHash;
|
|
|
15519
16473
|
exports.generateQuestionId = generateQuestionId;
|
|
15520
16474
|
exports.getOrderSignBytes = getOrderSignBytes;
|
|
15521
16475
|
exports.orderAmountsFromPrice = orderAmountsFromPrice;
|
|
16476
|
+
exports.serializeCollectFeeOrderToBytes = serializeCollectFeeOrderToBytes;
|
|
15522
16477
|
exports.serializeOrderToBytes = serializeOrderToBytes;
|
|
15523
16478
|
exports.serializeSignedOrder = serializeSignedOrder;
|
|
15524
16479
|
exports.signOrder = signOrder;
|