@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.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ interface ProgramIds {
|
|
|
13
13
|
presale?: PublicKey;
|
|
14
14
|
marketOracle?: PublicKey;
|
|
15
15
|
adminContract?: PublicKey;
|
|
16
|
+
referral?: PublicKey;
|
|
16
17
|
}
|
|
17
18
|
interface CollateralConfig {
|
|
18
19
|
mint: PublicKey;
|
|
@@ -214,6 +215,21 @@ interface SignedOrder {
|
|
|
214
215
|
/** Ed25519 signature (64 bytes) from order.maker over serializeOrderToBytes() */
|
|
215
216
|
signature: Uint8Array;
|
|
216
217
|
}
|
|
218
|
+
/** Authorization for CLOB to collect fee_amount winning tokens after question resolution. */
|
|
219
|
+
interface CollectFeeOrder {
|
|
220
|
+
user: PublicKey;
|
|
221
|
+
condition: PublicKey;
|
|
222
|
+
tokenMint: PublicKey;
|
|
223
|
+
amount: BN;
|
|
224
|
+
nonce: BN;
|
|
225
|
+
/** Unix timestamp, 0 = no expiry */
|
|
226
|
+
expiry: BN;
|
|
227
|
+
}
|
|
228
|
+
interface SignedCollectFeeOrder {
|
|
229
|
+
order: CollectFeeOrder;
|
|
230
|
+
/** Ed25519 signature (64 bytes) from order.user over serializeCollectFeeOrderToBytes() */
|
|
231
|
+
signature: Uint8Array;
|
|
232
|
+
}
|
|
217
233
|
declare class XMarketError extends Error {
|
|
218
234
|
code?: string | undefined;
|
|
219
235
|
constructor(message: string, code?: string | undefined);
|
|
@@ -529,7 +545,21 @@ declare class FeeManagementClient {
|
|
|
529
545
|
private readonly provider;
|
|
530
546
|
private readonly programIds;
|
|
531
547
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
|
|
532
|
-
initFeeConfig(
|
|
548
|
+
initFeeConfig(params: {
|
|
549
|
+
admin: PublicKey;
|
|
550
|
+
companyAddress: PublicKey;
|
|
551
|
+
referralAddress: PublicKey;
|
|
552
|
+
presaleRevenueAddress: PublicKey;
|
|
553
|
+
investorsMarketRev: number;
|
|
554
|
+
companyMarketRev: number;
|
|
555
|
+
agentsPresaleRev: number;
|
|
556
|
+
companyPresaleRev: number;
|
|
557
|
+
/** Share routed to referral vault (e.g. 2_000 = 20%). Must satisfy referral+company+investors=10_000 */
|
|
558
|
+
referralMarketRev: number;
|
|
559
|
+
referralVault: PublicKey;
|
|
560
|
+
authority: PublicKey;
|
|
561
|
+
payer: PublicKey;
|
|
562
|
+
}): Promise<TxResult>;
|
|
533
563
|
fetchFeeConfig(owner: PublicKey): Promise<any | null>;
|
|
534
564
|
/**
|
|
535
565
|
* Fetch per-market fees for a condition.
|
|
@@ -549,11 +579,43 @@ declare class FeeManagementClient {
|
|
|
549
579
|
* @param authority - signer authorized in fee_config whitelist / admin / owner
|
|
550
580
|
* @param payer - rent + tx fee payer
|
|
551
581
|
*/
|
|
552
|
-
updateFeeConfig(
|
|
582
|
+
updateFeeConfig(params: {
|
|
583
|
+
companyAddress: PublicKey;
|
|
584
|
+
referralAddress: PublicKey;
|
|
585
|
+
presaleRevenueAddress: PublicKey;
|
|
586
|
+
investorsMarketRev: number;
|
|
587
|
+
companyMarketRev: number;
|
|
588
|
+
agentsPresaleRev: number;
|
|
589
|
+
companyPresaleRev: number;
|
|
590
|
+
referralMarketRev: number;
|
|
591
|
+
referralVault: PublicKey;
|
|
592
|
+
authority: PublicKey;
|
|
593
|
+
payer: PublicKey;
|
|
594
|
+
}): Promise<TxResult>;
|
|
553
595
|
setMarketFeeOverride(conditionPda: PublicKey, investors: number, company: number, isAdmin: boolean, feeConfigOwner: PublicKey, authority: PublicKey, payer: PublicKey): Promise<TxResult>;
|
|
554
|
-
|
|
555
|
-
|
|
596
|
+
/**
|
|
597
|
+
* Build editMarketFee transaction (whitelist-only).
|
|
598
|
+
* @param conditionPda - condition PDA (market identifier)
|
|
599
|
+
* @param mergeFee - out of FEE_DENOMINATOR (10_000), e.g. 2_000 = 20%
|
|
600
|
+
* @param redeemFee - out of FEE_DENOMINATOR
|
|
601
|
+
* @param swapFee - trading fee out of FEE_DENOMINATOR, e.g. 200 = 2%
|
|
602
|
+
* @param feeConfigOwner - owner of fee_config PDA
|
|
603
|
+
* @param authority - whitelisted signer (signs tx externally)
|
|
604
|
+
* @param payer - fee payer (can differ from authority)
|
|
605
|
+
*/
|
|
606
|
+
buildEditMarketFeeTx(conditionPda: PublicKey, mergeFee: BN, redeemFee: BN, swapFee: BN, feeConfigOwner: PublicKey, authority: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
607
|
+
/** @deprecated use buildEditMarketFeeTx */
|
|
556
608
|
setQuestionFee(conditionPda: PublicKey, mergeFee: BN, redeemFee: BN, swapFee: BN, feeConfigOwner: PublicKey, authority: PublicKey, payer: PublicKey): Promise<TxResult>;
|
|
609
|
+
/**
|
|
610
|
+
* Build addToWhitelist tx — authority (admin/owner) signs externally.
|
|
611
|
+
* Whitelist members can call editMarketFee / setQuestionFee.
|
|
612
|
+
*/
|
|
613
|
+
/** Build addToWhitelist tx — authority (admin/owner) signs externally. */
|
|
614
|
+
buildAddToWhitelistTx(address: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
615
|
+
/** Build removeFromWhitelist tx — authority (admin/owner) signs externally. */
|
|
616
|
+
buildRemoveFromWhitelistTx(address: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
617
|
+
/** Build setAdmin tx — only owner signs externally. */
|
|
618
|
+
buildSetAdminTx(newAdmin: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
557
619
|
}
|
|
558
620
|
|
|
559
621
|
declare class ClobClient {
|
|
@@ -566,6 +628,8 @@ declare class ClobClient {
|
|
|
566
628
|
feeConfigOwner?: PublicKey;
|
|
567
629
|
/** Cached company_address from fee_config to avoid repeated RPC calls */
|
|
568
630
|
private _companyAddress?;
|
|
631
|
+
/** Cached referral_vault from fee_config */
|
|
632
|
+
private _referralVault?;
|
|
569
633
|
/** ALT cache: condition.toBase58() → loaded ALT account */
|
|
570
634
|
private _altCache;
|
|
571
635
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
|
|
@@ -574,6 +638,7 @@ declare class ClobClient {
|
|
|
574
638
|
};
|
|
575
639
|
});
|
|
576
640
|
private companyAddress;
|
|
641
|
+
private referralVault;
|
|
577
642
|
get walletPubkey(): PublicKey;
|
|
578
643
|
/**
|
|
579
644
|
* Get or create an ALT for a condition.
|
|
@@ -736,6 +801,23 @@ declare class ClobClient {
|
|
|
736
801
|
buildMatchOrdersTx(taker: SignedOrder, makers: SignedOrder[], operator: PublicKey, payer: PublicKey, opts?: {
|
|
737
802
|
marketOracleVault?: PublicKey;
|
|
738
803
|
}): Promise<VersionedTransaction>;
|
|
804
|
+
/**
|
|
805
|
+
* Build VersionedTransaction for batchCollectRedeemEarly.
|
|
806
|
+
*
|
|
807
|
+
* Flow: Ed25519 ix (user sigs) + batchCollectRedeemEarly ix.
|
|
808
|
+
* Each SignedCollectFeeOrder authorizes CLOB to collect `amount` winning tokens
|
|
809
|
+
* from that user, redeem via CTF, then distribute as fees.
|
|
810
|
+
*
|
|
811
|
+
* @param signedOrders - Array of { order, signature } from winning users
|
|
812
|
+
* @param condition - Market condition PDA
|
|
813
|
+
* @param outcomeIndex - 0 = NO wins, 1 = YES wins
|
|
814
|
+
* @param operator - Whitelisted operator pubkey (must sign)
|
|
815
|
+
* @param payer - Fee payer pubkey (must sign)
|
|
816
|
+
* @param opts.marketOracleVault - MarketOracle vault for fee distribution
|
|
817
|
+
*/
|
|
818
|
+
buildBatchCollectRedeemEarlyTx(signedOrders: SignedCollectFeeOrder[], condition: PublicKey, outcomeIndex: 0 | 1, operator: PublicKey, payer: PublicKey, opts?: {
|
|
819
|
+
marketOracleVault?: PublicKey;
|
|
820
|
+
}): Promise<VersionedTransaction>;
|
|
739
821
|
fetchConfig(): Promise<ClobConfig | null>;
|
|
740
822
|
fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
|
|
741
823
|
fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
|
|
@@ -884,6 +966,46 @@ declare class AdminClient {
|
|
|
884
966
|
distributeMarket(conditionId: Uint8Array, amount: anchor.BN, collateralMint: PublicKey, marketOracleVault: PublicKey, owner: PublicKey, claimer?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
885
967
|
}
|
|
886
968
|
|
|
969
|
+
interface ReferralConfigInfo {
|
|
970
|
+
owner: PublicKey;
|
|
971
|
+
collateralMint: PublicKey;
|
|
972
|
+
whitelist: PublicKey[];
|
|
973
|
+
bump: number;
|
|
974
|
+
}
|
|
975
|
+
declare class ReferralClient {
|
|
976
|
+
private readonly program;
|
|
977
|
+
private readonly provider;
|
|
978
|
+
private readonly programIds;
|
|
979
|
+
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
|
|
980
|
+
get walletPubkey(): PublicKey;
|
|
981
|
+
referralVault(owner: PublicKey, collateralMint: PublicKey): PublicKey;
|
|
982
|
+
fetchConfig(owner: PublicKey): Promise<ReferralConfigInfo | null>;
|
|
983
|
+
/**
|
|
984
|
+
* Build initialize tx — creates referral config PDA.
|
|
985
|
+
* Also prepends an ATA creation instruction for the referral vault (idempotent).
|
|
986
|
+
* Build-tx pattern.
|
|
987
|
+
*/
|
|
988
|
+
buildInitializeTx(collateralMint: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<{
|
|
989
|
+
tx: Transaction;
|
|
990
|
+
configPda: PublicKey;
|
|
991
|
+
vaultAta: PublicKey;
|
|
992
|
+
}>;
|
|
993
|
+
/** Build add-to-whitelist tx. Build-tx pattern. */
|
|
994
|
+
buildAddToWhitelistTx(address: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
995
|
+
/** Build remove-from-whitelist tx. Build-tx pattern. */
|
|
996
|
+
buildRemoveFromWhitelistTx(address: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
997
|
+
/**
|
|
998
|
+
* Build batchSendUsds tx. Build-tx pattern.
|
|
999
|
+
* @param recipients - wallet addresses to send to
|
|
1000
|
+
* @param amounts - corresponding amounts in token smallest units
|
|
1001
|
+
* @param configOwner - owner of referral config (used to derive config + vault)
|
|
1002
|
+
* @param collateralMint - token mint
|
|
1003
|
+
* @param authority - whitelisted signer
|
|
1004
|
+
* @param payer - fee payer (can differ from authority)
|
|
1005
|
+
*/
|
|
1006
|
+
buildBatchSendUsdsTx(recipients: PublicKey[], amounts: BN[], configOwner: PublicKey, collateralMint: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
887
1009
|
declare class XMarketSDK {
|
|
888
1010
|
readonly provider: anchor.AnchorProvider;
|
|
889
1011
|
readonly networkConfig: NetworkConfig;
|
|
@@ -898,6 +1020,7 @@ declare class XMarketSDK {
|
|
|
898
1020
|
private _presale?;
|
|
899
1021
|
private _marketOracle?;
|
|
900
1022
|
private _admin?;
|
|
1023
|
+
private _referral?;
|
|
901
1024
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
902
1025
|
private _withAddress;
|
|
903
1026
|
get oracle(): OracleClient;
|
|
@@ -909,6 +1032,7 @@ declare class XMarketSDK {
|
|
|
909
1032
|
get presale(): PresaleClient;
|
|
910
1033
|
get marketOracle(): MarketOracleClient;
|
|
911
1034
|
get admin(): AdminClient;
|
|
1035
|
+
get referral(): ReferralClient;
|
|
912
1036
|
}
|
|
913
1037
|
|
|
914
1038
|
declare const SEEDS: {
|
|
@@ -929,6 +1053,7 @@ declare const SEEDS: {
|
|
|
929
1053
|
readonly clobConfig: Buffer<ArrayBuffer>;
|
|
930
1054
|
readonly order: Buffer<ArrayBuffer>;
|
|
931
1055
|
readonly feeConfig: Buffer<ArrayBuffer>;
|
|
1056
|
+
readonly referralConfig: Buffer<ArrayBuffer>;
|
|
932
1057
|
readonly questionFee: Buffer<ArrayBuffer>;
|
|
933
1058
|
readonly marketFee: Buffer<ArrayBuffer>;
|
|
934
1059
|
readonly presale: Buffer<ArrayBuffer>;
|
|
@@ -968,6 +1093,7 @@ declare class PDA {
|
|
|
968
1093
|
static userBuyRecord(presalePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
969
1094
|
static marketOraclePda(questionPda: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
|
|
970
1095
|
static userClaimRecord(marketOraclePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
|
|
1096
|
+
static referralConfig(owner: PublicKey, programIds: Pick<ProgramIds, "referral">): [PublicKey, number];
|
|
971
1097
|
static adminConfig(owner: PublicKey, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
|
|
972
1098
|
static claimRecord(conditionId: Uint8Array, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
|
|
973
1099
|
}
|
|
@@ -1008,6 +1134,25 @@ declare function buildBatchedEd25519Instruction(orders: SignedOrder[]): Transact
|
|
|
1008
1134
|
* Pass this as `ixSysvar` to all match_* instruction accounts.
|
|
1009
1135
|
*/
|
|
1010
1136
|
declare const IX_SYSVAR: _solana_web3_js.PublicKey;
|
|
1137
|
+
/**
|
|
1138
|
+
* Convert SignedOrder to the shape anchor expects for SignedOrder struct.
|
|
1139
|
+
* The signature must be passed as a fixed-size array of 64 numbers.
|
|
1140
|
+
*/
|
|
1141
|
+
/**
|
|
1142
|
+
* Serialize a CollectFeeOrder to 120 bytes — must match Rust `CollectFeeOrder::to_signable_bytes()`.
|
|
1143
|
+
* [0..32] user pubkey
|
|
1144
|
+
* [32..64] condition pubkey
|
|
1145
|
+
* [64..96] token_mint pubkey
|
|
1146
|
+
* [96..104] amount (u64 le)
|
|
1147
|
+
* [104..112] nonce (u64 le)
|
|
1148
|
+
* [112..120] expiry (i64 le)
|
|
1149
|
+
*/
|
|
1150
|
+
declare function serializeCollectFeeOrderToBytes(order: CollectFeeOrder): Uint8Array;
|
|
1151
|
+
/**
|
|
1152
|
+
* Build a batched Ed25519 precompile instruction for N signed CollectFeeOrders.
|
|
1153
|
+
* Same layout as buildBatchedEd25519Instruction but with 120-byte messages.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function buildBatchedCollectFeeEd25519Instruction(orders: SignedCollectFeeOrder[]): TransactionInstruction;
|
|
1011
1156
|
|
|
1012
1157
|
/**
|
|
1013
1158
|
* High-level order utilities — build, sign, serialize, verify, detect match type.
|
|
@@ -1160,4 +1305,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1160
1305
|
*/
|
|
1161
1306
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1162
1307
|
|
|
1163
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, SEEDS, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1308
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface ProgramIds {
|
|
|
13
13
|
presale?: PublicKey;
|
|
14
14
|
marketOracle?: PublicKey;
|
|
15
15
|
adminContract?: PublicKey;
|
|
16
|
+
referral?: PublicKey;
|
|
16
17
|
}
|
|
17
18
|
interface CollateralConfig {
|
|
18
19
|
mint: PublicKey;
|
|
@@ -214,6 +215,21 @@ interface SignedOrder {
|
|
|
214
215
|
/** Ed25519 signature (64 bytes) from order.maker over serializeOrderToBytes() */
|
|
215
216
|
signature: Uint8Array;
|
|
216
217
|
}
|
|
218
|
+
/** Authorization for CLOB to collect fee_amount winning tokens after question resolution. */
|
|
219
|
+
interface CollectFeeOrder {
|
|
220
|
+
user: PublicKey;
|
|
221
|
+
condition: PublicKey;
|
|
222
|
+
tokenMint: PublicKey;
|
|
223
|
+
amount: BN;
|
|
224
|
+
nonce: BN;
|
|
225
|
+
/** Unix timestamp, 0 = no expiry */
|
|
226
|
+
expiry: BN;
|
|
227
|
+
}
|
|
228
|
+
interface SignedCollectFeeOrder {
|
|
229
|
+
order: CollectFeeOrder;
|
|
230
|
+
/** Ed25519 signature (64 bytes) from order.user over serializeCollectFeeOrderToBytes() */
|
|
231
|
+
signature: Uint8Array;
|
|
232
|
+
}
|
|
217
233
|
declare class XMarketError extends Error {
|
|
218
234
|
code?: string | undefined;
|
|
219
235
|
constructor(message: string, code?: string | undefined);
|
|
@@ -529,7 +545,21 @@ declare class FeeManagementClient {
|
|
|
529
545
|
private readonly provider;
|
|
530
546
|
private readonly programIds;
|
|
531
547
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
|
|
532
|
-
initFeeConfig(
|
|
548
|
+
initFeeConfig(params: {
|
|
549
|
+
admin: PublicKey;
|
|
550
|
+
companyAddress: PublicKey;
|
|
551
|
+
referralAddress: PublicKey;
|
|
552
|
+
presaleRevenueAddress: PublicKey;
|
|
553
|
+
investorsMarketRev: number;
|
|
554
|
+
companyMarketRev: number;
|
|
555
|
+
agentsPresaleRev: number;
|
|
556
|
+
companyPresaleRev: number;
|
|
557
|
+
/** Share routed to referral vault (e.g. 2_000 = 20%). Must satisfy referral+company+investors=10_000 */
|
|
558
|
+
referralMarketRev: number;
|
|
559
|
+
referralVault: PublicKey;
|
|
560
|
+
authority: PublicKey;
|
|
561
|
+
payer: PublicKey;
|
|
562
|
+
}): Promise<TxResult>;
|
|
533
563
|
fetchFeeConfig(owner: PublicKey): Promise<any | null>;
|
|
534
564
|
/**
|
|
535
565
|
* Fetch per-market fees for a condition.
|
|
@@ -549,11 +579,43 @@ declare class FeeManagementClient {
|
|
|
549
579
|
* @param authority - signer authorized in fee_config whitelist / admin / owner
|
|
550
580
|
* @param payer - rent + tx fee payer
|
|
551
581
|
*/
|
|
552
|
-
updateFeeConfig(
|
|
582
|
+
updateFeeConfig(params: {
|
|
583
|
+
companyAddress: PublicKey;
|
|
584
|
+
referralAddress: PublicKey;
|
|
585
|
+
presaleRevenueAddress: PublicKey;
|
|
586
|
+
investorsMarketRev: number;
|
|
587
|
+
companyMarketRev: number;
|
|
588
|
+
agentsPresaleRev: number;
|
|
589
|
+
companyPresaleRev: number;
|
|
590
|
+
referralMarketRev: number;
|
|
591
|
+
referralVault: PublicKey;
|
|
592
|
+
authority: PublicKey;
|
|
593
|
+
payer: PublicKey;
|
|
594
|
+
}): Promise<TxResult>;
|
|
553
595
|
setMarketFeeOverride(conditionPda: PublicKey, investors: number, company: number, isAdmin: boolean, feeConfigOwner: PublicKey, authority: PublicKey, payer: PublicKey): Promise<TxResult>;
|
|
554
|
-
|
|
555
|
-
|
|
596
|
+
/**
|
|
597
|
+
* Build editMarketFee transaction (whitelist-only).
|
|
598
|
+
* @param conditionPda - condition PDA (market identifier)
|
|
599
|
+
* @param mergeFee - out of FEE_DENOMINATOR (10_000), e.g. 2_000 = 20%
|
|
600
|
+
* @param redeemFee - out of FEE_DENOMINATOR
|
|
601
|
+
* @param swapFee - trading fee out of FEE_DENOMINATOR, e.g. 200 = 2%
|
|
602
|
+
* @param feeConfigOwner - owner of fee_config PDA
|
|
603
|
+
* @param authority - whitelisted signer (signs tx externally)
|
|
604
|
+
* @param payer - fee payer (can differ from authority)
|
|
605
|
+
*/
|
|
606
|
+
buildEditMarketFeeTx(conditionPda: PublicKey, mergeFee: BN, redeemFee: BN, swapFee: BN, feeConfigOwner: PublicKey, authority: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
607
|
+
/** @deprecated use buildEditMarketFeeTx */
|
|
556
608
|
setQuestionFee(conditionPda: PublicKey, mergeFee: BN, redeemFee: BN, swapFee: BN, feeConfigOwner: PublicKey, authority: PublicKey, payer: PublicKey): Promise<TxResult>;
|
|
609
|
+
/**
|
|
610
|
+
* Build addToWhitelist tx — authority (admin/owner) signs externally.
|
|
611
|
+
* Whitelist members can call editMarketFee / setQuestionFee.
|
|
612
|
+
*/
|
|
613
|
+
/** Build addToWhitelist tx — authority (admin/owner) signs externally. */
|
|
614
|
+
buildAddToWhitelistTx(address: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
615
|
+
/** Build removeFromWhitelist tx — authority (admin/owner) signs externally. */
|
|
616
|
+
buildRemoveFromWhitelistTx(address: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
617
|
+
/** Build setAdmin tx — only owner signs externally. */
|
|
618
|
+
buildSetAdminTx(newAdmin: PublicKey, feeConfigOwner: PublicKey, authority: PublicKey): Promise<Transaction>;
|
|
557
619
|
}
|
|
558
620
|
|
|
559
621
|
declare class ClobClient {
|
|
@@ -566,6 +628,8 @@ declare class ClobClient {
|
|
|
566
628
|
feeConfigOwner?: PublicKey;
|
|
567
629
|
/** Cached company_address from fee_config to avoid repeated RPC calls */
|
|
568
630
|
private _companyAddress?;
|
|
631
|
+
/** Cached referral_vault from fee_config */
|
|
632
|
+
private _referralVault?;
|
|
569
633
|
/** ALT cache: condition.toBase58() → loaded ALT account */
|
|
570
634
|
private _altCache;
|
|
571
635
|
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds, networkConfig: {
|
|
@@ -574,6 +638,7 @@ declare class ClobClient {
|
|
|
574
638
|
};
|
|
575
639
|
});
|
|
576
640
|
private companyAddress;
|
|
641
|
+
private referralVault;
|
|
577
642
|
get walletPubkey(): PublicKey;
|
|
578
643
|
/**
|
|
579
644
|
* Get or create an ALT for a condition.
|
|
@@ -736,6 +801,23 @@ declare class ClobClient {
|
|
|
736
801
|
buildMatchOrdersTx(taker: SignedOrder, makers: SignedOrder[], operator: PublicKey, payer: PublicKey, opts?: {
|
|
737
802
|
marketOracleVault?: PublicKey;
|
|
738
803
|
}): Promise<VersionedTransaction>;
|
|
804
|
+
/**
|
|
805
|
+
* Build VersionedTransaction for batchCollectRedeemEarly.
|
|
806
|
+
*
|
|
807
|
+
* Flow: Ed25519 ix (user sigs) + batchCollectRedeemEarly ix.
|
|
808
|
+
* Each SignedCollectFeeOrder authorizes CLOB to collect `amount` winning tokens
|
|
809
|
+
* from that user, redeem via CTF, then distribute as fees.
|
|
810
|
+
*
|
|
811
|
+
* @param signedOrders - Array of { order, signature } from winning users
|
|
812
|
+
* @param condition - Market condition PDA
|
|
813
|
+
* @param outcomeIndex - 0 = NO wins, 1 = YES wins
|
|
814
|
+
* @param operator - Whitelisted operator pubkey (must sign)
|
|
815
|
+
* @param payer - Fee payer pubkey (must sign)
|
|
816
|
+
* @param opts.marketOracleVault - MarketOracle vault for fee distribution
|
|
817
|
+
*/
|
|
818
|
+
buildBatchCollectRedeemEarlyTx(signedOrders: SignedCollectFeeOrder[], condition: PublicKey, outcomeIndex: 0 | 1, operator: PublicKey, payer: PublicKey, opts?: {
|
|
819
|
+
marketOracleVault?: PublicKey;
|
|
820
|
+
}): Promise<VersionedTransaction>;
|
|
739
821
|
fetchConfig(): Promise<ClobConfig | null>;
|
|
740
822
|
fetchOrderStatus(maker: PublicKey, nonce: anchor.BN): Promise<OrderStatus | null>;
|
|
741
823
|
fetchOrderRecord(maker: PublicKey, nonce: anchor.BN): Promise<{
|
|
@@ -884,6 +966,46 @@ declare class AdminClient {
|
|
|
884
966
|
distributeMarket(conditionId: Uint8Array, amount: anchor.BN, collateralMint: PublicKey, marketOracleVault: PublicKey, owner: PublicKey, claimer?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
885
967
|
}
|
|
886
968
|
|
|
969
|
+
interface ReferralConfigInfo {
|
|
970
|
+
owner: PublicKey;
|
|
971
|
+
collateralMint: PublicKey;
|
|
972
|
+
whitelist: PublicKey[];
|
|
973
|
+
bump: number;
|
|
974
|
+
}
|
|
975
|
+
declare class ReferralClient {
|
|
976
|
+
private readonly program;
|
|
977
|
+
private readonly provider;
|
|
978
|
+
private readonly programIds;
|
|
979
|
+
constructor(program: anchor.Program, provider: anchor.AnchorProvider, programIds: ProgramIds);
|
|
980
|
+
get walletPubkey(): PublicKey;
|
|
981
|
+
referralVault(owner: PublicKey, collateralMint: PublicKey): PublicKey;
|
|
982
|
+
fetchConfig(owner: PublicKey): Promise<ReferralConfigInfo | null>;
|
|
983
|
+
/**
|
|
984
|
+
* Build initialize tx — creates referral config PDA.
|
|
985
|
+
* Also prepends an ATA creation instruction for the referral vault (idempotent).
|
|
986
|
+
* Build-tx pattern.
|
|
987
|
+
*/
|
|
988
|
+
buildInitializeTx(collateralMint: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<{
|
|
989
|
+
tx: Transaction;
|
|
990
|
+
configPda: PublicKey;
|
|
991
|
+
vaultAta: PublicKey;
|
|
992
|
+
}>;
|
|
993
|
+
/** Build add-to-whitelist tx. Build-tx pattern. */
|
|
994
|
+
buildAddToWhitelistTx(address: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
995
|
+
/** Build remove-from-whitelist tx. Build-tx pattern. */
|
|
996
|
+
buildRemoveFromWhitelistTx(address: PublicKey, owner?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
997
|
+
/**
|
|
998
|
+
* Build batchSendUsds tx. Build-tx pattern.
|
|
999
|
+
* @param recipients - wallet addresses to send to
|
|
1000
|
+
* @param amounts - corresponding amounts in token smallest units
|
|
1001
|
+
* @param configOwner - owner of referral config (used to derive config + vault)
|
|
1002
|
+
* @param collateralMint - token mint
|
|
1003
|
+
* @param authority - whitelisted signer
|
|
1004
|
+
* @param payer - fee payer (can differ from authority)
|
|
1005
|
+
*/
|
|
1006
|
+
buildBatchSendUsdsTx(recipients: PublicKey[], amounts: BN[], configOwner: PublicKey, collateralMint: PublicKey, authority?: PublicKey, payer?: PublicKey): Promise<Transaction>;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
887
1009
|
declare class XMarketSDK {
|
|
888
1010
|
readonly provider: anchor.AnchorProvider;
|
|
889
1011
|
readonly networkConfig: NetworkConfig;
|
|
@@ -898,6 +1020,7 @@ declare class XMarketSDK {
|
|
|
898
1020
|
private _presale?;
|
|
899
1021
|
private _marketOracle?;
|
|
900
1022
|
private _admin?;
|
|
1023
|
+
private _referral?;
|
|
901
1024
|
constructor(config: NetworkConfig, wallet: anchor.Wallet, marketOwner?: PublicKey);
|
|
902
1025
|
private _withAddress;
|
|
903
1026
|
get oracle(): OracleClient;
|
|
@@ -909,6 +1032,7 @@ declare class XMarketSDK {
|
|
|
909
1032
|
get presale(): PresaleClient;
|
|
910
1033
|
get marketOracle(): MarketOracleClient;
|
|
911
1034
|
get admin(): AdminClient;
|
|
1035
|
+
get referral(): ReferralClient;
|
|
912
1036
|
}
|
|
913
1037
|
|
|
914
1038
|
declare const SEEDS: {
|
|
@@ -929,6 +1053,7 @@ declare const SEEDS: {
|
|
|
929
1053
|
readonly clobConfig: Buffer<ArrayBuffer>;
|
|
930
1054
|
readonly order: Buffer<ArrayBuffer>;
|
|
931
1055
|
readonly feeConfig: Buffer<ArrayBuffer>;
|
|
1056
|
+
readonly referralConfig: Buffer<ArrayBuffer>;
|
|
932
1057
|
readonly questionFee: Buffer<ArrayBuffer>;
|
|
933
1058
|
readonly marketFee: Buffer<ArrayBuffer>;
|
|
934
1059
|
readonly presale: Buffer<ArrayBuffer>;
|
|
@@ -968,6 +1093,7 @@ declare class PDA {
|
|
|
968
1093
|
static userBuyRecord(presalePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "presale">): [PublicKey, number];
|
|
969
1094
|
static marketOraclePda(questionPda: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
|
|
970
1095
|
static userClaimRecord(marketOraclePda: PublicKey, user: PublicKey, programIds: Pick<ProgramIds, "marketOracle">): [PublicKey, number];
|
|
1096
|
+
static referralConfig(owner: PublicKey, programIds: Pick<ProgramIds, "referral">): [PublicKey, number];
|
|
971
1097
|
static adminConfig(owner: PublicKey, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
|
|
972
1098
|
static claimRecord(conditionId: Uint8Array, programIds: Pick<ProgramIds, "adminContract">): [PublicKey, number];
|
|
973
1099
|
}
|
|
@@ -1008,6 +1134,25 @@ declare function buildBatchedEd25519Instruction(orders: SignedOrder[]): Transact
|
|
|
1008
1134
|
* Pass this as `ixSysvar` to all match_* instruction accounts.
|
|
1009
1135
|
*/
|
|
1010
1136
|
declare const IX_SYSVAR: _solana_web3_js.PublicKey;
|
|
1137
|
+
/**
|
|
1138
|
+
* Convert SignedOrder to the shape anchor expects for SignedOrder struct.
|
|
1139
|
+
* The signature must be passed as a fixed-size array of 64 numbers.
|
|
1140
|
+
*/
|
|
1141
|
+
/**
|
|
1142
|
+
* Serialize a CollectFeeOrder to 120 bytes — must match Rust `CollectFeeOrder::to_signable_bytes()`.
|
|
1143
|
+
* [0..32] user pubkey
|
|
1144
|
+
* [32..64] condition pubkey
|
|
1145
|
+
* [64..96] token_mint pubkey
|
|
1146
|
+
* [96..104] amount (u64 le)
|
|
1147
|
+
* [104..112] nonce (u64 le)
|
|
1148
|
+
* [112..120] expiry (i64 le)
|
|
1149
|
+
*/
|
|
1150
|
+
declare function serializeCollectFeeOrderToBytes(order: CollectFeeOrder): Uint8Array;
|
|
1151
|
+
/**
|
|
1152
|
+
* Build a batched Ed25519 precompile instruction for N signed CollectFeeOrders.
|
|
1153
|
+
* Same layout as buildBatchedEd25519Instruction but with 120-byte messages.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function buildBatchedCollectFeeEd25519Instruction(orders: SignedCollectFeeOrder[]): TransactionInstruction;
|
|
1011
1156
|
|
|
1012
1157
|
/**
|
|
1013
1158
|
* High-level order utilities — build, sign, serialize, verify, detect match type.
|
|
@@ -1160,4 +1305,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1160
1305
|
*/
|
|
1161
1306
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1162
1307
|
|
|
1163
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, SEEDS, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1308
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, FEE_DENOMINATOR, FeeManagementClient, HookClient, type HookConfig, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, type MarketOracleInfo, type MatchType, type NetworkConfig, type NetworkName, OracleClient, type OracleConfig, type Order, type OrderStatus, PDA, type Position, PresaleClient, type PresaleInfo, type ProgramIds, type Question, type QuestionFee, type QuestionMarketConfig, type QuestionResult, QuestionStatus, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|