@theliem/xmarket-sdk 3.13.0 → 3.16.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 +140 -5
- package/dist/index.d.ts +140 -5
- package/dist/index.js +1111 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1109 -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);
|
|
@@ -2922,6 +3092,98 @@ var AdminClient = class {
|
|
|
2922
3092
|
}).transaction();
|
|
2923
3093
|
}
|
|
2924
3094
|
};
|
|
3095
|
+
var ReferralClient = class {
|
|
3096
|
+
constructor(program, provider, programIds) {
|
|
3097
|
+
this.program = program;
|
|
3098
|
+
this.provider = provider;
|
|
3099
|
+
this.programIds = programIds;
|
|
3100
|
+
}
|
|
3101
|
+
get walletPubkey() {
|
|
3102
|
+
return this.provider.wallet.publicKey;
|
|
3103
|
+
}
|
|
3104
|
+
referralVault(owner, collateralMint) {
|
|
3105
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3106
|
+
return splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3107
|
+
}
|
|
3108
|
+
async fetchConfig(owner) {
|
|
3109
|
+
try {
|
|
3110
|
+
const [pda] = PDA.referralConfig(owner, this.programIds);
|
|
3111
|
+
const acc = await this.program.account.referralConfig.fetch(pda);
|
|
3112
|
+
return {
|
|
3113
|
+
owner: acc.owner,
|
|
3114
|
+
collateralMint: acc.collateralMint,
|
|
3115
|
+
whitelist: acc.whitelist.slice(0, acc.whitelistLen),
|
|
3116
|
+
bump: acc.bump
|
|
3117
|
+
};
|
|
3118
|
+
} catch {
|
|
3119
|
+
return null;
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* Build initialize tx — creates referral config PDA.
|
|
3124
|
+
* Also prepends an ATA creation instruction for the referral vault (idempotent).
|
|
3125
|
+
* Build-tx pattern.
|
|
3126
|
+
*/
|
|
3127
|
+
async buildInitializeTx(collateralMint, owner = this.walletPubkey, payer = owner) {
|
|
3128
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3129
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3130
|
+
const vaultAta = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3131
|
+
const createVaultIx = splToken.createAssociatedTokenAccountIdempotentInstruction(
|
|
3132
|
+
payer,
|
|
3133
|
+
vaultAta,
|
|
3134
|
+
configPda,
|
|
3135
|
+
collateralMint
|
|
3136
|
+
);
|
|
3137
|
+
const initTx = await this.program.methods.initialize().accounts({
|
|
3138
|
+
owner,
|
|
3139
|
+
payer,
|
|
3140
|
+
config: configPda,
|
|
3141
|
+
collateralMint,
|
|
3142
|
+
systemProgram: web3_js.SystemProgram.programId
|
|
3143
|
+
}).transaction();
|
|
3144
|
+
const tx = new web3_js.Transaction().add(createVaultIx, ...initTx.instructions);
|
|
3145
|
+
return { tx, configPda, vaultAta };
|
|
3146
|
+
}
|
|
3147
|
+
/** Build add-to-whitelist tx. Build-tx pattern. */
|
|
3148
|
+
async buildAddToWhitelistTx(address, owner = this.walletPubkey, payer = owner) {
|
|
3149
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3150
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3151
|
+
return this.program.methods.addToWhitelist(address).accounts({ owner, payer, config: configPda }).transaction();
|
|
3152
|
+
}
|
|
3153
|
+
/** Build remove-from-whitelist tx. Build-tx pattern. */
|
|
3154
|
+
async buildRemoveFromWhitelistTx(address, owner = this.walletPubkey, payer = owner) {
|
|
3155
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3156
|
+
const [configPda] = PDA.referralConfig(owner, this.programIds);
|
|
3157
|
+
return this.program.methods.removeFromWhitelist(address).accounts({ owner, payer, config: configPda }).transaction();
|
|
3158
|
+
}
|
|
3159
|
+
/**
|
|
3160
|
+
* Build batchSendUsds tx. Build-tx pattern.
|
|
3161
|
+
* @param recipients - wallet addresses to send to
|
|
3162
|
+
* @param amounts - corresponding amounts in token smallest units
|
|
3163
|
+
* @param configOwner - owner of referral config (used to derive config + vault)
|
|
3164
|
+
* @param collateralMint - token mint
|
|
3165
|
+
* @param authority - whitelisted signer
|
|
3166
|
+
* @param payer - fee payer (can differ from authority)
|
|
3167
|
+
*/
|
|
3168
|
+
async buildBatchSendUsdsTx(recipients, amounts, configOwner, collateralMint, authority = this.walletPubkey, payer = authority) {
|
|
3169
|
+
if (!this.programIds.referral) throw new Error("referral program ID not configured");
|
|
3170
|
+
if (recipients.length !== amounts.length) throw new Error("recipients and amounts must have same length");
|
|
3171
|
+
if (recipients.length === 0) throw new Error("recipients array is empty");
|
|
3172
|
+
const [configPda] = PDA.referralConfig(configOwner, this.programIds);
|
|
3173
|
+
const referralVault = splToken.getAssociatedTokenAddressSync(collateralMint, configPda, true);
|
|
3174
|
+
const recipientAtas = recipients.map(
|
|
3175
|
+
(wallet) => splToken.getAssociatedTokenAddressSync(collateralMint, wallet)
|
|
3176
|
+
);
|
|
3177
|
+
return this.program.methods.batchSendUsds(amounts).accounts({
|
|
3178
|
+
authority,
|
|
3179
|
+
config: configPda,
|
|
3180
|
+
referralVault,
|
|
3181
|
+
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
3182
|
+
}).remainingAccounts(
|
|
3183
|
+
recipientAtas.map((ata) => ({ pubkey: ata, isSigner: false, isWritable: true }))
|
|
3184
|
+
).transaction();
|
|
3185
|
+
}
|
|
3186
|
+
};
|
|
2925
3187
|
|
|
2926
3188
|
// src/idls/oracle.json
|
|
2927
3189
|
var oracle_default = {
|
|
@@ -8784,92 +9046,260 @@ var clob_exchange_default = {
|
|
|
8784
9046
|
]
|
|
8785
9047
|
},
|
|
8786
9048
|
{
|
|
8787
|
-
name: "
|
|
9049
|
+
name: "batch_collect_redeem_early",
|
|
8788
9050
|
docs: [
|
|
8789
|
-
"
|
|
9051
|
+
"Batch collect fee tokens from winning users after question resolution,",
|
|
9052
|
+
"redeem them via CTF, and distribute USDS via fee_management."
|
|
8790
9053
|
],
|
|
8791
9054
|
discriminator: [
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
9055
|
+
87,
|
|
9056
|
+
149,
|
|
9057
|
+
45,
|
|
9058
|
+
245,
|
|
9059
|
+
249,
|
|
9060
|
+
25,
|
|
9061
|
+
207,
|
|
9062
|
+
82
|
|
8800
9063
|
],
|
|
8801
9064
|
accounts: [
|
|
8802
9065
|
{
|
|
8803
|
-
name: "
|
|
8804
|
-
docs: [
|
|
8805
|
-
"Must be the order maker/signer"
|
|
8806
|
-
],
|
|
9066
|
+
name: "operator",
|
|
8807
9067
|
signer: true
|
|
8808
9068
|
},
|
|
8809
9069
|
{
|
|
8810
|
-
name: "
|
|
9070
|
+
name: "payer",
|
|
9071
|
+
writable: true,
|
|
9072
|
+
signer: true
|
|
9073
|
+
},
|
|
9074
|
+
{
|
|
9075
|
+
name: "clob_config",
|
|
8811
9076
|
writable: true,
|
|
8812
9077
|
pda: {
|
|
8813
9078
|
seeds: [
|
|
8814
9079
|
{
|
|
8815
9080
|
kind: "const",
|
|
8816
9081
|
value: [
|
|
9082
|
+
99,
|
|
9083
|
+
108,
|
|
8817
9084
|
111,
|
|
8818
|
-
|
|
8819
|
-
100,
|
|
8820
|
-
101,
|
|
8821
|
-
114,
|
|
9085
|
+
98,
|
|
8822
9086
|
95,
|
|
8823
|
-
114,
|
|
8824
|
-
101,
|
|
8825
9087
|
99,
|
|
8826
9088
|
111,
|
|
8827
|
-
|
|
8828
|
-
|
|
9089
|
+
110,
|
|
9090
|
+
102,
|
|
9091
|
+
105,
|
|
9092
|
+
103
|
|
8829
9093
|
]
|
|
8830
|
-
},
|
|
8831
|
-
{
|
|
8832
|
-
kind: "account",
|
|
8833
|
-
path: "maker"
|
|
8834
|
-
},
|
|
8835
|
-
{
|
|
8836
|
-
kind: "arg",
|
|
8837
|
-
path: "nonce"
|
|
8838
9094
|
}
|
|
8839
9095
|
]
|
|
8840
9096
|
}
|
|
8841
9097
|
},
|
|
8842
9098
|
{
|
|
8843
|
-
name: "
|
|
8844
|
-
|
|
8845
|
-
}
|
|
8846
|
-
],
|
|
8847
|
-
args: [
|
|
8848
|
-
{
|
|
8849
|
-
name: "nonce",
|
|
8850
|
-
type: "u64"
|
|
8851
|
-
}
|
|
8852
|
-
]
|
|
8853
|
-
},
|
|
8854
|
-
{
|
|
8855
|
-
name: "force_reset_clob",
|
|
8856
|
-
discriminator: [
|
|
8857
|
-
96,
|
|
8858
|
-
95,
|
|
8859
|
-
187,
|
|
8860
|
-
95,
|
|
8861
|
-
65,
|
|
8862
|
-
135,
|
|
8863
|
-
120,
|
|
8864
|
-
204
|
|
8865
|
-
],
|
|
8866
|
-
accounts: [
|
|
9099
|
+
name: "condition",
|
|
9100
|
+
writable: true
|
|
9101
|
+
},
|
|
8867
9102
|
{
|
|
8868
|
-
name: "
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
9103
|
+
name: "collateral_vault",
|
|
9104
|
+
writable: true,
|
|
9105
|
+
pda: {
|
|
9106
|
+
seeds: [
|
|
9107
|
+
{
|
|
9108
|
+
kind: "const",
|
|
9109
|
+
value: [
|
|
9110
|
+
99,
|
|
9111
|
+
111,
|
|
9112
|
+
108,
|
|
9113
|
+
108,
|
|
9114
|
+
97,
|
|
9115
|
+
116,
|
|
9116
|
+
101,
|
|
9117
|
+
114,
|
|
9118
|
+
97,
|
|
9119
|
+
108,
|
|
9120
|
+
95,
|
|
9121
|
+
118,
|
|
9122
|
+
97,
|
|
9123
|
+
117,
|
|
9124
|
+
108,
|
|
9125
|
+
116
|
|
9126
|
+
]
|
|
9127
|
+
},
|
|
9128
|
+
{
|
|
9129
|
+
kind: "account",
|
|
9130
|
+
path: "condition.collateral_mint",
|
|
9131
|
+
account: "Condition"
|
|
9132
|
+
}
|
|
9133
|
+
],
|
|
9134
|
+
program: {
|
|
9135
|
+
kind: "account",
|
|
9136
|
+
path: "conditional_tokens_program"
|
|
9137
|
+
}
|
|
9138
|
+
}
|
|
9139
|
+
},
|
|
9140
|
+
{
|
|
9141
|
+
name: "vault_token_account",
|
|
9142
|
+
writable: true
|
|
9143
|
+
},
|
|
9144
|
+
{
|
|
9145
|
+
name: "fee_recipient",
|
|
9146
|
+
docs: [
|
|
9147
|
+
"CLOB's USDS ATA \u2014 receives USDS payout from redeem, then distribute_fee draws from it."
|
|
9148
|
+
],
|
|
9149
|
+
writable: true
|
|
9150
|
+
},
|
|
9151
|
+
{
|
|
9152
|
+
name: "yes_mint",
|
|
9153
|
+
writable: true
|
|
9154
|
+
},
|
|
9155
|
+
{
|
|
9156
|
+
name: "no_mint",
|
|
9157
|
+
writable: true
|
|
9158
|
+
},
|
|
9159
|
+
{
|
|
9160
|
+
name: "clob_yes_ata",
|
|
9161
|
+
docs: [
|
|
9162
|
+
"CLOB's YES ATA (Token-2022) \u2014 must be pre-initialized (created during prior matchOrders)."
|
|
9163
|
+
],
|
|
9164
|
+
writable: true
|
|
9165
|
+
},
|
|
9166
|
+
{
|
|
9167
|
+
name: "clob_no_ata",
|
|
9168
|
+
docs: [
|
|
9169
|
+
"CLOB's NO ATA (Token-2022) \u2014 must be pre-initialized."
|
|
9170
|
+
],
|
|
9171
|
+
writable: true
|
|
9172
|
+
},
|
|
9173
|
+
{
|
|
9174
|
+
name: "clob_yes_position",
|
|
9175
|
+
writable: true
|
|
9176
|
+
},
|
|
9177
|
+
{
|
|
9178
|
+
name: "clob_no_position",
|
|
9179
|
+
writable: true
|
|
9180
|
+
},
|
|
9181
|
+
{
|
|
9182
|
+
name: "ix_sysvar"
|
|
9183
|
+
},
|
|
9184
|
+
{
|
|
9185
|
+
name: "conditional_tokens_program",
|
|
9186
|
+
address: "A6N1F8MRsdgcojAx8p6FaECvw8mo8w6qJcWsbKQBANK4"
|
|
9187
|
+
},
|
|
9188
|
+
{
|
|
9189
|
+
name: "token_program",
|
|
9190
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
9191
|
+
},
|
|
9192
|
+
{
|
|
9193
|
+
name: "token_2022_program",
|
|
9194
|
+
address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
9195
|
+
},
|
|
9196
|
+
{
|
|
9197
|
+
name: "system_program",
|
|
9198
|
+
address: "11111111111111111111111111111111"
|
|
9199
|
+
}
|
|
9200
|
+
],
|
|
9201
|
+
args: [
|
|
9202
|
+
{
|
|
9203
|
+
name: "ix_index",
|
|
9204
|
+
type: "u8"
|
|
9205
|
+
},
|
|
9206
|
+
{
|
|
9207
|
+
name: "order_count",
|
|
9208
|
+
type: "u8"
|
|
9209
|
+
},
|
|
9210
|
+
{
|
|
9211
|
+
name: "outcome_index",
|
|
9212
|
+
type: "u8"
|
|
9213
|
+
}
|
|
9214
|
+
]
|
|
9215
|
+
},
|
|
9216
|
+
{
|
|
9217
|
+
name: "cancel_order",
|
|
9218
|
+
docs: [
|
|
9219
|
+
"Cancel an order \u2014 close OrderRecord PDA, return rent to maker."
|
|
9220
|
+
],
|
|
9221
|
+
discriminator: [
|
|
9222
|
+
95,
|
|
9223
|
+
129,
|
|
9224
|
+
237,
|
|
9225
|
+
240,
|
|
9226
|
+
8,
|
|
9227
|
+
49,
|
|
9228
|
+
223,
|
|
9229
|
+
132
|
|
9230
|
+
],
|
|
9231
|
+
accounts: [
|
|
9232
|
+
{
|
|
9233
|
+
name: "maker",
|
|
9234
|
+
docs: [
|
|
9235
|
+
"Must be the order maker/signer"
|
|
9236
|
+
],
|
|
9237
|
+
signer: true
|
|
9238
|
+
},
|
|
9239
|
+
{
|
|
9240
|
+
name: "order_record",
|
|
9241
|
+
writable: true,
|
|
9242
|
+
pda: {
|
|
9243
|
+
seeds: [
|
|
9244
|
+
{
|
|
9245
|
+
kind: "const",
|
|
9246
|
+
value: [
|
|
9247
|
+
111,
|
|
9248
|
+
114,
|
|
9249
|
+
100,
|
|
9250
|
+
101,
|
|
9251
|
+
114,
|
|
9252
|
+
95,
|
|
9253
|
+
114,
|
|
9254
|
+
101,
|
|
9255
|
+
99,
|
|
9256
|
+
111,
|
|
9257
|
+
114,
|
|
9258
|
+
100
|
|
9259
|
+
]
|
|
9260
|
+
},
|
|
9261
|
+
{
|
|
9262
|
+
kind: "account",
|
|
9263
|
+
path: "maker"
|
|
9264
|
+
},
|
|
9265
|
+
{
|
|
9266
|
+
kind: "arg",
|
|
9267
|
+
path: "nonce"
|
|
9268
|
+
}
|
|
9269
|
+
]
|
|
9270
|
+
}
|
|
9271
|
+
},
|
|
9272
|
+
{
|
|
9273
|
+
name: "system_program",
|
|
9274
|
+
address: "11111111111111111111111111111111"
|
|
9275
|
+
}
|
|
9276
|
+
],
|
|
9277
|
+
args: [
|
|
9278
|
+
{
|
|
9279
|
+
name: "nonce",
|
|
9280
|
+
type: "u64"
|
|
9281
|
+
}
|
|
9282
|
+
]
|
|
9283
|
+
},
|
|
9284
|
+
{
|
|
9285
|
+
name: "force_reset_clob",
|
|
9286
|
+
discriminator: [
|
|
9287
|
+
96,
|
|
9288
|
+
95,
|
|
9289
|
+
187,
|
|
9290
|
+
95,
|
|
9291
|
+
65,
|
|
9292
|
+
135,
|
|
9293
|
+
120,
|
|
9294
|
+
204
|
|
9295
|
+
],
|
|
9296
|
+
accounts: [
|
|
9297
|
+
{
|
|
9298
|
+
name: "upgrade_authority",
|
|
9299
|
+
docs: [
|
|
9300
|
+
"Must be the upgrade authority (deployer). Checked in handler via",
|
|
9301
|
+
"programdata account so we don't hardcode the pubkey."
|
|
9302
|
+
],
|
|
8873
9303
|
writable: true,
|
|
8874
9304
|
signer: true
|
|
8875
9305
|
},
|
|
@@ -8996,7 +9426,7 @@ var clob_exchange_default = {
|
|
|
8996
9426
|
{
|
|
8997
9427
|
name: "match_complementary",
|
|
8998
9428
|
docs: [
|
|
8999
|
-
"COMPLEMENTARY match: 1 taker (BUY) + N makers (
|
|
9429
|
+
"COMPLEMENTARY match: 1 taker (BUY or SELL) + N makers (opposite side) via remaining_accounts."
|
|
9000
9430
|
],
|
|
9001
9431
|
discriminator: [
|
|
9002
9432
|
100,
|
|
@@ -9289,9 +9719,6 @@ var clob_exchange_default = {
|
|
|
9289
9719
|
},
|
|
9290
9720
|
{
|
|
9291
9721
|
name: "clob_usdc_ata",
|
|
9292
|
-
docs: [
|
|
9293
|
-
"USDC ATA owned by clob_config \u2014 receives USDC from vault after merge"
|
|
9294
|
-
],
|
|
9295
9722
|
writable: true,
|
|
9296
9723
|
pda: {
|
|
9297
9724
|
seeds: [
|
|
@@ -9568,9 +9995,6 @@ var clob_exchange_default = {
|
|
|
9568
9995
|
},
|
|
9569
9996
|
{
|
|
9570
9997
|
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
9998
|
writable: true,
|
|
9575
9999
|
pda: {
|
|
9576
10000
|
seeds: [
|
|
@@ -9628,30 +10052,18 @@ var clob_exchange_default = {
|
|
|
9628
10052
|
},
|
|
9629
10053
|
{
|
|
9630
10054
|
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
10055
|
writable: true
|
|
9635
10056
|
},
|
|
9636
10057
|
{
|
|
9637
10058
|
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
10059
|
writable: true
|
|
9642
10060
|
},
|
|
9643
10061
|
{
|
|
9644
10062
|
name: "clob_yes_position",
|
|
9645
|
-
docs: [
|
|
9646
|
-
"YES Position PDA for clob_config (set by CTF split_position init_if_needed)"
|
|
9647
|
-
],
|
|
9648
10063
|
writable: true
|
|
9649
10064
|
},
|
|
9650
10065
|
{
|
|
9651
10066
|
name: "clob_no_position",
|
|
9652
|
-
docs: [
|
|
9653
|
-
"NO Position PDA for clob_config (set by CTF split_position init_if_needed)"
|
|
9654
|
-
],
|
|
9655
10067
|
writable: true
|
|
9656
10068
|
},
|
|
9657
10069
|
{
|
|
@@ -10687,11 +11099,18 @@ var fee_management_default = {
|
|
|
10687
11099
|
{
|
|
10688
11100
|
name: "market_oracle_vault",
|
|
10689
11101
|
docs: [
|
|
10690
|
-
"Writable: tokens are transferred here when is_admin=false.",
|
|
11102
|
+
"Writable: tokens are transferred here (investors share) when is_admin=false.",
|
|
10691
11103
|
"For admin questions pass any writable account (no transfer occurs)."
|
|
10692
11104
|
],
|
|
10693
11105
|
writable: true
|
|
10694
11106
|
},
|
|
11107
|
+
{
|
|
11108
|
+
name: "referral_vault",
|
|
11109
|
+
docs: [
|
|
11110
|
+
"Must match fee_config.referral_vault."
|
|
11111
|
+
],
|
|
11112
|
+
writable: true
|
|
11113
|
+
},
|
|
10695
11114
|
{
|
|
10696
11115
|
name: "token_program",
|
|
10697
11116
|
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
@@ -11550,7 +11969,8 @@ var fee_management_default = {
|
|
|
11550
11969
|
{
|
|
11551
11970
|
name: "investors_market_rev",
|
|
11552
11971
|
docs: [
|
|
11553
|
-
"Market revenue split
|
|
11972
|
+
"Market revenue split \u2014 three parts must sum to FEE_DENOMINATOR (10_000).",
|
|
11973
|
+
"investors_market_rev + company_market_rev + referral_market_rev == 10_000"
|
|
11554
11974
|
],
|
|
11555
11975
|
type: "u32"
|
|
11556
11976
|
},
|
|
@@ -11561,7 +11981,7 @@ var fee_management_default = {
|
|
|
11561
11981
|
{
|
|
11562
11982
|
name: "agents_presale_rev",
|
|
11563
11983
|
docs: [
|
|
11564
|
-
"Presale revenue split: agents + company (out of FEE_DENOMINATOR =
|
|
11984
|
+
"Presale revenue split: agents + company (out of FEE_DENOMINATOR = 10_000)"
|
|
11565
11985
|
],
|
|
11566
11986
|
type: "u32"
|
|
11567
11987
|
},
|
|
@@ -11586,12 +12006,26 @@ var fee_management_default = {
|
|
|
11586
12006
|
name: "bump",
|
|
11587
12007
|
type: "u8"
|
|
11588
12008
|
},
|
|
12009
|
+
{
|
|
12010
|
+
name: "referral_market_rev",
|
|
12011
|
+
docs: [
|
|
12012
|
+
"Share of market trading fees routed to referral_vault (e.g. 2_000 = 20%)"
|
|
12013
|
+
],
|
|
12014
|
+
type: "u32"
|
|
12015
|
+
},
|
|
12016
|
+
{
|
|
12017
|
+
name: "referral_vault",
|
|
12018
|
+
docs: [
|
|
12019
|
+
"ATA of referral program config PDA \u2014 receives referral_market_rev% of trading fees"
|
|
12020
|
+
],
|
|
12021
|
+
type: "pubkey"
|
|
12022
|
+
},
|
|
11589
12023
|
{
|
|
11590
12024
|
name: "_reserved",
|
|
11591
12025
|
type: {
|
|
11592
12026
|
array: [
|
|
11593
12027
|
"u8",
|
|
11594
|
-
|
|
12028
|
+
28
|
|
11595
12029
|
]
|
|
11596
12030
|
}
|
|
11597
12031
|
}
|
|
@@ -11718,6 +12152,14 @@ var fee_management_default = {
|
|
|
11718
12152
|
{
|
|
11719
12153
|
name: "company_presale_rev",
|
|
11720
12154
|
type: "u32"
|
|
12155
|
+
},
|
|
12156
|
+
{
|
|
12157
|
+
name: "referral_market_rev",
|
|
12158
|
+
type: "u32"
|
|
12159
|
+
},
|
|
12160
|
+
{
|
|
12161
|
+
name: "referral_vault",
|
|
12162
|
+
type: "pubkey"
|
|
11721
12163
|
}
|
|
11722
12164
|
]
|
|
11723
12165
|
}
|
|
@@ -11978,6 +12420,14 @@ var fee_management_default = {
|
|
|
11978
12420
|
{
|
|
11979
12421
|
name: "company_presale_rev",
|
|
11980
12422
|
type: "u32"
|
|
12423
|
+
},
|
|
12424
|
+
{
|
|
12425
|
+
name: "referral_market_rev",
|
|
12426
|
+
type: "u32"
|
|
12427
|
+
},
|
|
12428
|
+
{
|
|
12429
|
+
name: "referral_vault",
|
|
12430
|
+
type: "pubkey"
|
|
11981
12431
|
}
|
|
11982
12432
|
]
|
|
11983
12433
|
}
|
|
@@ -15326,27 +15776,517 @@ var admin_contract_default = {
|
|
|
15326
15776
|
]
|
|
15327
15777
|
};
|
|
15328
15778
|
|
|
15329
|
-
// src/
|
|
15330
|
-
var
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15779
|
+
// src/idls/referral.json
|
|
15780
|
+
var referral_default = {
|
|
15781
|
+
address: "7b5ohWDqrQ2KRcDJMWwj1dwgRkt5ZJdMavSmrXn9oBgL",
|
|
15782
|
+
metadata: {
|
|
15783
|
+
name: "referral",
|
|
15784
|
+
version: "0.1.0",
|
|
15785
|
+
spec: "0.1.0",
|
|
15786
|
+
description: "Referral program for XMarket \u2014 whitelist-gated batch USDS distribution"
|
|
15787
|
+
},
|
|
15788
|
+
instructions: [
|
|
15789
|
+
{
|
|
15790
|
+
name: "add_to_whitelist",
|
|
15791
|
+
discriminator: [
|
|
15792
|
+
157,
|
|
15793
|
+
211,
|
|
15794
|
+
52,
|
|
15795
|
+
54,
|
|
15796
|
+
144,
|
|
15797
|
+
81,
|
|
15798
|
+
5,
|
|
15799
|
+
55
|
|
15800
|
+
],
|
|
15801
|
+
accounts: [
|
|
15802
|
+
{
|
|
15803
|
+
name: "owner",
|
|
15804
|
+
signer: true
|
|
15805
|
+
},
|
|
15806
|
+
{
|
|
15807
|
+
name: "payer",
|
|
15808
|
+
writable: true,
|
|
15809
|
+
signer: true
|
|
15810
|
+
},
|
|
15811
|
+
{
|
|
15812
|
+
name: "config",
|
|
15813
|
+
writable: true,
|
|
15814
|
+
pda: {
|
|
15815
|
+
seeds: [
|
|
15816
|
+
{
|
|
15817
|
+
kind: "const",
|
|
15818
|
+
value: [
|
|
15819
|
+
114,
|
|
15820
|
+
101,
|
|
15821
|
+
102,
|
|
15822
|
+
101,
|
|
15823
|
+
114,
|
|
15824
|
+
114,
|
|
15825
|
+
97,
|
|
15826
|
+
108,
|
|
15827
|
+
95,
|
|
15828
|
+
99,
|
|
15829
|
+
111,
|
|
15830
|
+
110,
|
|
15831
|
+
102,
|
|
15832
|
+
105,
|
|
15833
|
+
103
|
|
15834
|
+
]
|
|
15835
|
+
},
|
|
15836
|
+
{
|
|
15837
|
+
kind: "account",
|
|
15838
|
+
path: "config.owner",
|
|
15839
|
+
account: "ReferralConfig"
|
|
15840
|
+
}
|
|
15841
|
+
]
|
|
15842
|
+
}
|
|
15843
|
+
}
|
|
15844
|
+
],
|
|
15845
|
+
args: [
|
|
15846
|
+
{
|
|
15847
|
+
name: "address",
|
|
15848
|
+
type: "pubkey"
|
|
15849
|
+
}
|
|
15850
|
+
]
|
|
15851
|
+
},
|
|
15852
|
+
{
|
|
15853
|
+
name: "batch_send_usds",
|
|
15854
|
+
discriminator: [
|
|
15855
|
+
255,
|
|
15856
|
+
33,
|
|
15857
|
+
77,
|
|
15858
|
+
124,
|
|
15859
|
+
42,
|
|
15860
|
+
207,
|
|
15861
|
+
250,
|
|
15862
|
+
162
|
|
15863
|
+
],
|
|
15864
|
+
accounts: [
|
|
15865
|
+
{
|
|
15866
|
+
name: "authority",
|
|
15867
|
+
docs: [
|
|
15868
|
+
"Whitelisted caller (authority, signs tx)"
|
|
15869
|
+
],
|
|
15870
|
+
signer: true
|
|
15871
|
+
},
|
|
15872
|
+
{
|
|
15873
|
+
name: "config",
|
|
15874
|
+
pda: {
|
|
15875
|
+
seeds: [
|
|
15876
|
+
{
|
|
15877
|
+
kind: "const",
|
|
15878
|
+
value: [
|
|
15879
|
+
114,
|
|
15880
|
+
101,
|
|
15881
|
+
102,
|
|
15882
|
+
101,
|
|
15883
|
+
114,
|
|
15884
|
+
114,
|
|
15885
|
+
97,
|
|
15886
|
+
108,
|
|
15887
|
+
95,
|
|
15888
|
+
99,
|
|
15889
|
+
111,
|
|
15890
|
+
110,
|
|
15891
|
+
102,
|
|
15892
|
+
105,
|
|
15893
|
+
103
|
|
15894
|
+
]
|
|
15895
|
+
},
|
|
15896
|
+
{
|
|
15897
|
+
kind: "account",
|
|
15898
|
+
path: "config.owner",
|
|
15899
|
+
account: "ReferralConfig"
|
|
15900
|
+
}
|
|
15901
|
+
]
|
|
15902
|
+
}
|
|
15903
|
+
},
|
|
15904
|
+
{
|
|
15905
|
+
name: "referral_vault",
|
|
15906
|
+
docs: [
|
|
15907
|
+
"Referral vault \u2014 source of transfers (ATA owned by config PDA)"
|
|
15908
|
+
],
|
|
15909
|
+
writable: true,
|
|
15910
|
+
pda: {
|
|
15911
|
+
seeds: [
|
|
15912
|
+
{
|
|
15913
|
+
kind: "account",
|
|
15914
|
+
path: "config"
|
|
15915
|
+
},
|
|
15916
|
+
{
|
|
15917
|
+
kind: "const",
|
|
15918
|
+
value: [
|
|
15919
|
+
6,
|
|
15920
|
+
221,
|
|
15921
|
+
246,
|
|
15922
|
+
225,
|
|
15923
|
+
215,
|
|
15924
|
+
101,
|
|
15925
|
+
161,
|
|
15926
|
+
147,
|
|
15927
|
+
217,
|
|
15928
|
+
203,
|
|
15929
|
+
225,
|
|
15930
|
+
70,
|
|
15931
|
+
206,
|
|
15932
|
+
235,
|
|
15933
|
+
121,
|
|
15934
|
+
172,
|
|
15935
|
+
28,
|
|
15936
|
+
180,
|
|
15937
|
+
133,
|
|
15938
|
+
237,
|
|
15939
|
+
95,
|
|
15940
|
+
91,
|
|
15941
|
+
55,
|
|
15942
|
+
145,
|
|
15943
|
+
58,
|
|
15944
|
+
140,
|
|
15945
|
+
245,
|
|
15946
|
+
133,
|
|
15947
|
+
126,
|
|
15948
|
+
255,
|
|
15949
|
+
0,
|
|
15950
|
+
169
|
|
15951
|
+
]
|
|
15952
|
+
},
|
|
15953
|
+
{
|
|
15954
|
+
kind: "account",
|
|
15955
|
+
path: "config.collateral_mint",
|
|
15956
|
+
account: "ReferralConfig"
|
|
15957
|
+
}
|
|
15958
|
+
],
|
|
15959
|
+
program: {
|
|
15960
|
+
kind: "const",
|
|
15961
|
+
value: [
|
|
15962
|
+
140,
|
|
15963
|
+
151,
|
|
15964
|
+
37,
|
|
15965
|
+
143,
|
|
15966
|
+
78,
|
|
15967
|
+
36,
|
|
15968
|
+
137,
|
|
15969
|
+
241,
|
|
15970
|
+
187,
|
|
15971
|
+
61,
|
|
15972
|
+
16,
|
|
15973
|
+
41,
|
|
15974
|
+
20,
|
|
15975
|
+
142,
|
|
15976
|
+
13,
|
|
15977
|
+
131,
|
|
15978
|
+
11,
|
|
15979
|
+
90,
|
|
15980
|
+
19,
|
|
15981
|
+
153,
|
|
15982
|
+
218,
|
|
15983
|
+
255,
|
|
15984
|
+
16,
|
|
15985
|
+
132,
|
|
15986
|
+
4,
|
|
15987
|
+
142,
|
|
15988
|
+
123,
|
|
15989
|
+
216,
|
|
15990
|
+
219,
|
|
15991
|
+
233,
|
|
15992
|
+
248,
|
|
15993
|
+
89
|
|
15994
|
+
]
|
|
15995
|
+
}
|
|
15996
|
+
}
|
|
15997
|
+
},
|
|
15998
|
+
{
|
|
15999
|
+
name: "token_program",
|
|
16000
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
16001
|
+
}
|
|
16002
|
+
],
|
|
16003
|
+
args: [
|
|
16004
|
+
{
|
|
16005
|
+
name: "amounts",
|
|
16006
|
+
type: {
|
|
16007
|
+
vec: "u64"
|
|
16008
|
+
}
|
|
16009
|
+
}
|
|
16010
|
+
]
|
|
16011
|
+
},
|
|
16012
|
+
{
|
|
16013
|
+
name: "initialize",
|
|
16014
|
+
discriminator: [
|
|
16015
|
+
175,
|
|
16016
|
+
175,
|
|
16017
|
+
109,
|
|
16018
|
+
31,
|
|
16019
|
+
13,
|
|
16020
|
+
152,
|
|
16021
|
+
155,
|
|
16022
|
+
237
|
|
16023
|
+
],
|
|
16024
|
+
accounts: [
|
|
16025
|
+
{
|
|
16026
|
+
name: "owner",
|
|
16027
|
+
writable: true,
|
|
16028
|
+
signer: true
|
|
16029
|
+
},
|
|
16030
|
+
{
|
|
16031
|
+
name: "payer",
|
|
16032
|
+
writable: true,
|
|
16033
|
+
signer: true
|
|
16034
|
+
},
|
|
16035
|
+
{
|
|
16036
|
+
name: "config",
|
|
16037
|
+
writable: true,
|
|
16038
|
+
pda: {
|
|
16039
|
+
seeds: [
|
|
16040
|
+
{
|
|
16041
|
+
kind: "const",
|
|
16042
|
+
value: [
|
|
16043
|
+
114,
|
|
16044
|
+
101,
|
|
16045
|
+
102,
|
|
16046
|
+
101,
|
|
16047
|
+
114,
|
|
16048
|
+
114,
|
|
16049
|
+
97,
|
|
16050
|
+
108,
|
|
16051
|
+
95,
|
|
16052
|
+
99,
|
|
16053
|
+
111,
|
|
16054
|
+
110,
|
|
16055
|
+
102,
|
|
16056
|
+
105,
|
|
16057
|
+
103
|
|
16058
|
+
]
|
|
16059
|
+
},
|
|
16060
|
+
{
|
|
16061
|
+
kind: "account",
|
|
16062
|
+
path: "owner"
|
|
16063
|
+
}
|
|
16064
|
+
]
|
|
16065
|
+
}
|
|
16066
|
+
},
|
|
16067
|
+
{
|
|
16068
|
+
name: "collateral_mint"
|
|
16069
|
+
},
|
|
16070
|
+
{
|
|
16071
|
+
name: "system_program",
|
|
16072
|
+
address: "11111111111111111111111111111111"
|
|
16073
|
+
}
|
|
16074
|
+
],
|
|
16075
|
+
args: []
|
|
16076
|
+
},
|
|
16077
|
+
{
|
|
16078
|
+
name: "remove_from_whitelist",
|
|
16079
|
+
discriminator: [
|
|
16080
|
+
7,
|
|
16081
|
+
144,
|
|
16082
|
+
216,
|
|
16083
|
+
239,
|
|
16084
|
+
243,
|
|
16085
|
+
236,
|
|
16086
|
+
193,
|
|
16087
|
+
235
|
|
16088
|
+
],
|
|
16089
|
+
accounts: [
|
|
16090
|
+
{
|
|
16091
|
+
name: "owner",
|
|
16092
|
+
signer: true
|
|
16093
|
+
},
|
|
16094
|
+
{
|
|
16095
|
+
name: "payer",
|
|
16096
|
+
writable: true,
|
|
16097
|
+
signer: true
|
|
16098
|
+
},
|
|
16099
|
+
{
|
|
16100
|
+
name: "config",
|
|
16101
|
+
writable: true,
|
|
16102
|
+
pda: {
|
|
16103
|
+
seeds: [
|
|
16104
|
+
{
|
|
16105
|
+
kind: "const",
|
|
16106
|
+
value: [
|
|
16107
|
+
114,
|
|
16108
|
+
101,
|
|
16109
|
+
102,
|
|
16110
|
+
101,
|
|
16111
|
+
114,
|
|
16112
|
+
114,
|
|
16113
|
+
97,
|
|
16114
|
+
108,
|
|
16115
|
+
95,
|
|
16116
|
+
99,
|
|
16117
|
+
111,
|
|
16118
|
+
110,
|
|
16119
|
+
102,
|
|
16120
|
+
105,
|
|
16121
|
+
103
|
|
16122
|
+
]
|
|
16123
|
+
},
|
|
16124
|
+
{
|
|
16125
|
+
kind: "account",
|
|
16126
|
+
path: "config.owner",
|
|
16127
|
+
account: "ReferralConfig"
|
|
16128
|
+
}
|
|
16129
|
+
]
|
|
16130
|
+
}
|
|
16131
|
+
}
|
|
16132
|
+
],
|
|
16133
|
+
args: [
|
|
16134
|
+
{
|
|
16135
|
+
name: "address",
|
|
16136
|
+
type: "pubkey"
|
|
16137
|
+
}
|
|
16138
|
+
]
|
|
16139
|
+
}
|
|
16140
|
+
],
|
|
16141
|
+
accounts: [
|
|
16142
|
+
{
|
|
16143
|
+
name: "ReferralConfig",
|
|
16144
|
+
discriminator: [
|
|
16145
|
+
102,
|
|
16146
|
+
148,
|
|
16147
|
+
171,
|
|
16148
|
+
235,
|
|
16149
|
+
148,
|
|
16150
|
+
83,
|
|
16151
|
+
250,
|
|
16152
|
+
140
|
|
16153
|
+
]
|
|
16154
|
+
}
|
|
16155
|
+
],
|
|
16156
|
+
events: [
|
|
16157
|
+
{
|
|
16158
|
+
name: "BatchSent",
|
|
16159
|
+
discriminator: [
|
|
16160
|
+
116,
|
|
16161
|
+
64,
|
|
16162
|
+
207,
|
|
16163
|
+
63,
|
|
16164
|
+
56,
|
|
16165
|
+
97,
|
|
16166
|
+
15,
|
|
16167
|
+
100
|
|
16168
|
+
]
|
|
16169
|
+
},
|
|
16170
|
+
{
|
|
16171
|
+
name: "ReferralInitialized",
|
|
16172
|
+
discriminator: [
|
|
16173
|
+
129,
|
|
16174
|
+
190,
|
|
16175
|
+
249,
|
|
16176
|
+
4,
|
|
16177
|
+
198,
|
|
16178
|
+
5,
|
|
16179
|
+
141,
|
|
16180
|
+
226
|
|
16181
|
+
]
|
|
16182
|
+
}
|
|
16183
|
+
],
|
|
16184
|
+
types: [
|
|
16185
|
+
{
|
|
16186
|
+
name: "BatchSent",
|
|
16187
|
+
type: {
|
|
16188
|
+
kind: "struct",
|
|
16189
|
+
fields: [
|
|
16190
|
+
{
|
|
16191
|
+
name: "config",
|
|
16192
|
+
type: "pubkey"
|
|
16193
|
+
},
|
|
16194
|
+
{
|
|
16195
|
+
name: "sent_by",
|
|
16196
|
+
type: "pubkey"
|
|
16197
|
+
},
|
|
16198
|
+
{
|
|
16199
|
+
name: "recipients",
|
|
16200
|
+
type: "u8"
|
|
16201
|
+
}
|
|
16202
|
+
]
|
|
16203
|
+
}
|
|
16204
|
+
},
|
|
16205
|
+
{
|
|
16206
|
+
name: "ReferralConfig",
|
|
16207
|
+
type: {
|
|
16208
|
+
kind: "struct",
|
|
16209
|
+
fields: [
|
|
16210
|
+
{
|
|
16211
|
+
name: "version",
|
|
16212
|
+
type: "u8"
|
|
16213
|
+
},
|
|
16214
|
+
{
|
|
16215
|
+
name: "owner",
|
|
16216
|
+
type: "pubkey"
|
|
16217
|
+
},
|
|
16218
|
+
{
|
|
16219
|
+
name: "collateral_mint",
|
|
16220
|
+
type: "pubkey"
|
|
16221
|
+
},
|
|
16222
|
+
{
|
|
16223
|
+
name: "whitelist",
|
|
16224
|
+
type: {
|
|
16225
|
+
array: [
|
|
16226
|
+
"pubkey",
|
|
16227
|
+
10
|
|
16228
|
+
]
|
|
16229
|
+
}
|
|
16230
|
+
},
|
|
16231
|
+
{
|
|
16232
|
+
name: "whitelist_len",
|
|
16233
|
+
type: "u8"
|
|
16234
|
+
},
|
|
16235
|
+
{
|
|
16236
|
+
name: "bump",
|
|
16237
|
+
type: "u8"
|
|
16238
|
+
},
|
|
16239
|
+
{
|
|
16240
|
+
name: "_reserved",
|
|
16241
|
+
type: {
|
|
16242
|
+
array: [
|
|
16243
|
+
"u8",
|
|
16244
|
+
64
|
|
16245
|
+
]
|
|
16246
|
+
}
|
|
16247
|
+
}
|
|
16248
|
+
]
|
|
16249
|
+
}
|
|
16250
|
+
},
|
|
16251
|
+
{
|
|
16252
|
+
name: "ReferralInitialized",
|
|
16253
|
+
type: {
|
|
16254
|
+
kind: "struct",
|
|
16255
|
+
fields: [
|
|
16256
|
+
{
|
|
16257
|
+
name: "config",
|
|
16258
|
+
type: "pubkey"
|
|
16259
|
+
},
|
|
16260
|
+
{
|
|
16261
|
+
name: "owner",
|
|
16262
|
+
type: "pubkey"
|
|
16263
|
+
}
|
|
16264
|
+
]
|
|
16265
|
+
}
|
|
16266
|
+
}
|
|
16267
|
+
]
|
|
16268
|
+
};
|
|
16269
|
+
|
|
16270
|
+
// src/sdk.ts
|
|
16271
|
+
var XMarketSDK = class {
|
|
16272
|
+
constructor(config, wallet, marketOwner) {
|
|
16273
|
+
this.networkConfig = config;
|
|
16274
|
+
this.provider = new anchor5__namespace.AnchorProvider(
|
|
16275
|
+
new web3_js.Connection(config.rpcUrl, "confirmed"),
|
|
16276
|
+
wallet,
|
|
16277
|
+
{ commitment: "confirmed", preflightCommitment: "confirmed" }
|
|
16278
|
+
);
|
|
16279
|
+
anchor5__namespace.setProvider(this.provider);
|
|
16280
|
+
this._programIds = config.programIds;
|
|
16281
|
+
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
16282
|
+
}
|
|
16283
|
+
_withAddress(idl, address) {
|
|
16284
|
+
return { ...idl, address: address.toBase58() };
|
|
16285
|
+
}
|
|
16286
|
+
get oracle() {
|
|
16287
|
+
if (!this._oracle) {
|
|
16288
|
+
const program = new anchor5__namespace.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
|
|
16289
|
+
this._oracle = new OracleClient(program, this.provider, this._programIds);
|
|
15350
16290
|
}
|
|
15351
16291
|
return this._oracle;
|
|
15352
16292
|
}
|
|
@@ -15415,6 +16355,14 @@ var XMarketSDK = class {
|
|
|
15415
16355
|
}
|
|
15416
16356
|
return this._admin;
|
|
15417
16357
|
}
|
|
16358
|
+
get referral() {
|
|
16359
|
+
if (!this._referral) {
|
|
16360
|
+
if (!this._programIds.referral) throw new Error("referral program ID not configured in NetworkConfig");
|
|
16361
|
+
const program = new anchor5__namespace.Program(this._withAddress(referral_default, this._programIds.referral), this.provider);
|
|
16362
|
+
this._referral = new ReferralClient(program, this.provider, this._programIds);
|
|
16363
|
+
}
|
|
16364
|
+
return this._referral;
|
|
16365
|
+
}
|
|
15418
16366
|
};
|
|
15419
16367
|
var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
15420
16368
|
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
@@ -15503,12 +16451,14 @@ exports.OracleClient = OracleClient;
|
|
|
15503
16451
|
exports.PDA = PDA;
|
|
15504
16452
|
exports.PresaleClient = PresaleClient;
|
|
15505
16453
|
exports.QuestionStatus = QuestionStatus;
|
|
16454
|
+
exports.ReferralClient = ReferralClient;
|
|
15506
16455
|
exports.SEEDS = SEEDS;
|
|
15507
16456
|
exports.UnauthorizedError = UnauthorizedError;
|
|
15508
16457
|
exports.XMarketError = XMarketError;
|
|
15509
16458
|
exports.XMarketSDK = XMarketSDK;
|
|
15510
16459
|
exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
|
|
15511
16460
|
exports.buildApproveCollateralTx = buildApproveCollateralTx;
|
|
16461
|
+
exports.buildBatchedCollectFeeEd25519Instruction = buildBatchedCollectFeeEd25519Instruction;
|
|
15512
16462
|
exports.buildBatchedEd25519Instruction = buildBatchedEd25519Instruction;
|
|
15513
16463
|
exports.buildCreateUserAtasTx = buildCreateUserAtasTx;
|
|
15514
16464
|
exports.buildOrder = buildOrder;
|
|
@@ -15519,6 +16469,7 @@ exports.generateContentHash = generateContentHash;
|
|
|
15519
16469
|
exports.generateQuestionId = generateQuestionId;
|
|
15520
16470
|
exports.getOrderSignBytes = getOrderSignBytes;
|
|
15521
16471
|
exports.orderAmountsFromPrice = orderAmountsFromPrice;
|
|
16472
|
+
exports.serializeCollectFeeOrderToBytes = serializeCollectFeeOrderToBytes;
|
|
15522
16473
|
exports.serializeOrderToBytes = serializeOrderToBytes;
|
|
15523
16474
|
exports.serializeSignedOrder = serializeSignedOrder;
|
|
15524
16475
|
exports.signOrder = signOrder;
|