@theliem/xmarket-sdk 3.25.0 → 3.26.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 +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +794 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +793 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -231,6 +231,30 @@ interface SignedCollectFeeOrder {
|
|
|
231
231
|
/** Ed25519 signature (64 bytes) from order.user over serializeCollectFeeOrderToBytes() */
|
|
232
232
|
signature: Uint8Array;
|
|
233
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Authorization for CLOB to collect YES or NO tokens for redeem/merge, returning net USDS after fee.
|
|
236
|
+
* Used with batchRedeemWithFee and batchMergeWithFee instructions.
|
|
237
|
+
*/
|
|
238
|
+
interface RedeemFeeOrder {
|
|
239
|
+
user: PublicKey;
|
|
240
|
+
condition: PublicKey;
|
|
241
|
+
tokenMint: PublicKey;
|
|
242
|
+
amount: BN;
|
|
243
|
+
/** Net USDS to receive back after fee deduction. 0 for the losing side. */
|
|
244
|
+
takerAmount: BN;
|
|
245
|
+
nonce: BN;
|
|
246
|
+
expiry: BN;
|
|
247
|
+
}
|
|
248
|
+
interface SignedRedeemFeeOrder {
|
|
249
|
+
order: RedeemFeeOrder;
|
|
250
|
+
/** Ed25519 signature (64 bytes) from order.user over serializeRedeemFeeOrderToBytes() */
|
|
251
|
+
signature: Uint8Array;
|
|
252
|
+
}
|
|
253
|
+
/** A pair of YES + NO orders for one user in batchRedeemWithFee / batchMergeWithFee. */
|
|
254
|
+
interface RedeemFeeOrderPair {
|
|
255
|
+
yes: SignedRedeemFeeOrder;
|
|
256
|
+
no: SignedRedeemFeeOrder;
|
|
257
|
+
}
|
|
234
258
|
declare class XMarketError extends Error {
|
|
235
259
|
code?: string | undefined;
|
|
236
260
|
constructor(message: string, code?: string | undefined);
|
|
@@ -864,6 +888,36 @@ declare class ClobClient {
|
|
|
864
888
|
marketOracleVault?: PublicKey;
|
|
865
889
|
lookupTable?: AddressLookupTableAccount;
|
|
866
890
|
}): Promise<VersionedTransaction>;
|
|
891
|
+
/**
|
|
892
|
+
* Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
|
|
893
|
+
* Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
|
|
894
|
+
*
|
|
895
|
+
* ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
|
|
896
|
+
* ix[1]: register_redeem_fee_order(nonce)
|
|
897
|
+
*/
|
|
898
|
+
buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
|
|
899
|
+
/**
|
|
900
|
+
* Build a VersionedTransaction for batchRedeemWithFee.
|
|
901
|
+
* Each pair has a YES order + NO order for the same user (same signer or different).
|
|
902
|
+
* After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
|
|
903
|
+
*
|
|
904
|
+
* Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
|
|
905
|
+
*/
|
|
906
|
+
buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
|
|
907
|
+
marketOracleVault?: PublicKey;
|
|
908
|
+
lookupTable?: AddressLookupTableAccount;
|
|
909
|
+
}): Promise<VersionedTransaction>;
|
|
910
|
+
/**
|
|
911
|
+
* Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
|
|
912
|
+
* Each pair: YES order + NO order with equal amounts for the same user.
|
|
913
|
+
* Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
|
|
914
|
+
*
|
|
915
|
+
* Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
|
|
916
|
+
*/
|
|
917
|
+
buildBatchMergeWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
|
|
918
|
+
marketOracleVault?: PublicKey;
|
|
919
|
+
lookupTable?: AddressLookupTableAccount;
|
|
920
|
+
}): Promise<VersionedTransaction>;
|
|
867
921
|
/**
|
|
868
922
|
* Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
|
|
869
923
|
* remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
|
|
@@ -1187,6 +1241,7 @@ declare class PDA {
|
|
|
1187
1241
|
static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1188
1242
|
static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1189
1243
|
static collectFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1244
|
+
static redeemFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1190
1245
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1191
1246
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1192
1247
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
@@ -1259,6 +1314,22 @@ declare function serializeCollectFeeOrderToBytes(order: CollectFeeOrder): Uint8A
|
|
|
1259
1314
|
* Same layout as buildBatchedEd25519Instruction but with 120-byte messages.
|
|
1260
1315
|
*/
|
|
1261
1316
|
declare function buildBatchedCollectFeeEd25519Instruction(orders: SignedCollectFeeOrder[]): TransactionInstruction;
|
|
1317
|
+
/**
|
|
1318
|
+
* Serialize a RedeemFeeOrder to 128 bytes — must match Rust `RedeemFeeOrder::to_signable_bytes()`.
|
|
1319
|
+
* [0..32] user pubkey
|
|
1320
|
+
* [32..64] condition pubkey
|
|
1321
|
+
* [64..96] token_mint pubkey
|
|
1322
|
+
* [96..104] amount (u64 le)
|
|
1323
|
+
* [104..112] taker_amount (u64 le)
|
|
1324
|
+
* [112..120] nonce (u64 le)
|
|
1325
|
+
* [120..128] expiry (i64 le)
|
|
1326
|
+
*/
|
|
1327
|
+
declare function serializeRedeemFeeOrderToBytes(order: RedeemFeeOrder): Uint8Array;
|
|
1328
|
+
/**
|
|
1329
|
+
* Build a batched Ed25519 precompile instruction for N signed RedeemFeeOrders.
|
|
1330
|
+
* Same layout as buildBatchedCollectFeeEd25519Instruction but with 128-byte messages.
|
|
1331
|
+
*/
|
|
1332
|
+
declare function buildBatchedRedeemFeeEd25519Instruction(orders: SignedRedeemFeeOrder[]): TransactionInstruction;
|
|
1262
1333
|
|
|
1263
1334
|
/**
|
|
1264
1335
|
* High-level order utilities — build, sign, serialize, verify, detect match type.
|
|
@@ -1411,4 +1482,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1411
1482
|
*/
|
|
1412
1483
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1413
1484
|
|
|
1414
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, 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, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1485
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, 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, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -231,6 +231,30 @@ interface SignedCollectFeeOrder {
|
|
|
231
231
|
/** Ed25519 signature (64 bytes) from order.user over serializeCollectFeeOrderToBytes() */
|
|
232
232
|
signature: Uint8Array;
|
|
233
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Authorization for CLOB to collect YES or NO tokens for redeem/merge, returning net USDS after fee.
|
|
236
|
+
* Used with batchRedeemWithFee and batchMergeWithFee instructions.
|
|
237
|
+
*/
|
|
238
|
+
interface RedeemFeeOrder {
|
|
239
|
+
user: PublicKey;
|
|
240
|
+
condition: PublicKey;
|
|
241
|
+
tokenMint: PublicKey;
|
|
242
|
+
amount: BN;
|
|
243
|
+
/** Net USDS to receive back after fee deduction. 0 for the losing side. */
|
|
244
|
+
takerAmount: BN;
|
|
245
|
+
nonce: BN;
|
|
246
|
+
expiry: BN;
|
|
247
|
+
}
|
|
248
|
+
interface SignedRedeemFeeOrder {
|
|
249
|
+
order: RedeemFeeOrder;
|
|
250
|
+
/** Ed25519 signature (64 bytes) from order.user over serializeRedeemFeeOrderToBytes() */
|
|
251
|
+
signature: Uint8Array;
|
|
252
|
+
}
|
|
253
|
+
/** A pair of YES + NO orders for one user in batchRedeemWithFee / batchMergeWithFee. */
|
|
254
|
+
interface RedeemFeeOrderPair {
|
|
255
|
+
yes: SignedRedeemFeeOrder;
|
|
256
|
+
no: SignedRedeemFeeOrder;
|
|
257
|
+
}
|
|
234
258
|
declare class XMarketError extends Error {
|
|
235
259
|
code?: string | undefined;
|
|
236
260
|
constructor(message: string, code?: string | undefined);
|
|
@@ -864,6 +888,36 @@ declare class ClobClient {
|
|
|
864
888
|
marketOracleVault?: PublicKey;
|
|
865
889
|
lookupTable?: AddressLookupTableAccount;
|
|
866
890
|
}): Promise<VersionedTransaction>;
|
|
891
|
+
/**
|
|
892
|
+
* Build a Transaction to register a RedeemFeeOrder on-chain (Ed25519 verify + PDA).
|
|
893
|
+
* Must be sent before calling buildBatchRedeemWithFeeTx / buildBatchMergeWithFeeTx.
|
|
894
|
+
*
|
|
895
|
+
* ix[0]: batched Ed25519 { pubkey=order.user, sig, msg=128 bytes }
|
|
896
|
+
* ix[1]: register_redeem_fee_order(nonce)
|
|
897
|
+
*/
|
|
898
|
+
buildRegisterRedeemFeeOrderTx(signedOrder: SignedRedeemFeeOrder, payer: PublicKey): Promise<anchor.web3.Transaction>;
|
|
899
|
+
/**
|
|
900
|
+
* Build a VersionedTransaction for batchRedeemWithFee.
|
|
901
|
+
* Each pair has a YES order + NO order for the same user (same signer or different).
|
|
902
|
+
* After resolution: YES holder taker_amount > 0, NO holder taker_amount = 0 (or vice versa).
|
|
903
|
+
*
|
|
904
|
+
* Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
|
|
905
|
+
*/
|
|
906
|
+
buildBatchRedeemWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
|
|
907
|
+
marketOracleVault?: PublicKey;
|
|
908
|
+
lookupTable?: AddressLookupTableAccount;
|
|
909
|
+
}): Promise<VersionedTransaction>;
|
|
910
|
+
/**
|
|
911
|
+
* Build a VersionedTransaction for batchMergeWithFee (pre-resolution merge with fee).
|
|
912
|
+
* Each pair: YES order + NO order with equal amounts for the same user.
|
|
913
|
+
* Only yes_signer receives net USDS (mirrors EVM _matchMergeOrder).
|
|
914
|
+
*
|
|
915
|
+
* Prerequisite: each order's RedeemFeeOrderRecord must be registered via buildRegisterRedeemFeeOrderTx.
|
|
916
|
+
*/
|
|
917
|
+
buildBatchMergeWithFeeTx(orderPairs: RedeemFeeOrderPair[], condition: PublicKey, operator: PublicKey, payer: PublicKey, opts?: {
|
|
918
|
+
marketOracleVault?: PublicKey;
|
|
919
|
+
lookupTable?: AddressLookupTableAccount;
|
|
920
|
+
}): Promise<VersionedTransaction>;
|
|
867
921
|
/**
|
|
868
922
|
* Build ALT for batchCollectRedeemEarly — includes per-user accounts so all
|
|
869
923
|
* remaining_accounts fit as 1-byte ALT indices instead of 32-byte inline addresses.
|
|
@@ -1187,6 +1241,7 @@ declare class PDA {
|
|
|
1187
1241
|
static orderStatus(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1188
1242
|
static orderRecord(maker: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1189
1243
|
static collectFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1244
|
+
static redeemFeeOrderRecord(user: PublicKey, nonce: BN, programIds: Pick<ProgramIds, "clobExchange">): [PublicKey, number];
|
|
1190
1245
|
static feeConfig(owner: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1191
1246
|
static questionFee(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
1192
1247
|
static marketFeeOverride(conditionPda: PublicKey, programIds: Pick<ProgramIds, "feeManagement">): [PublicKey, number];
|
|
@@ -1259,6 +1314,22 @@ declare function serializeCollectFeeOrderToBytes(order: CollectFeeOrder): Uint8A
|
|
|
1259
1314
|
* Same layout as buildBatchedEd25519Instruction but with 120-byte messages.
|
|
1260
1315
|
*/
|
|
1261
1316
|
declare function buildBatchedCollectFeeEd25519Instruction(orders: SignedCollectFeeOrder[]): TransactionInstruction;
|
|
1317
|
+
/**
|
|
1318
|
+
* Serialize a RedeemFeeOrder to 128 bytes — must match Rust `RedeemFeeOrder::to_signable_bytes()`.
|
|
1319
|
+
* [0..32] user pubkey
|
|
1320
|
+
* [32..64] condition pubkey
|
|
1321
|
+
* [64..96] token_mint pubkey
|
|
1322
|
+
* [96..104] amount (u64 le)
|
|
1323
|
+
* [104..112] taker_amount (u64 le)
|
|
1324
|
+
* [112..120] nonce (u64 le)
|
|
1325
|
+
* [120..128] expiry (i64 le)
|
|
1326
|
+
*/
|
|
1327
|
+
declare function serializeRedeemFeeOrderToBytes(order: RedeemFeeOrder): Uint8Array;
|
|
1328
|
+
/**
|
|
1329
|
+
* Build a batched Ed25519 precompile instruction for N signed RedeemFeeOrders.
|
|
1330
|
+
* Same layout as buildBatchedCollectFeeEd25519Instruction but with 128-byte messages.
|
|
1331
|
+
*/
|
|
1332
|
+
declare function buildBatchedRedeemFeeEd25519Instruction(orders: SignedRedeemFeeOrder[]): TransactionInstruction;
|
|
1262
1333
|
|
|
1263
1334
|
/**
|
|
1264
1335
|
* High-level order utilities — build, sign, serialize, verify, detect match type.
|
|
@@ -1411,4 +1482,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1411
1482
|
*/
|
|
1412
1483
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1413
1484
|
|
|
1414
|
-
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, 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, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1485
|
+
export { AccountNotFoundError, AdminClient, type AdminConfigInfo, type ClaimRecordInfo, ClobClient, type ClobConfig, type CollateralConfig, type CollateralVault, type CollectFeeOrder, type Condition, type CreateQuestionParams, CtfClient, type CtfConfig, DisputeClient, type DisputeConfigInfo, type DisputeMarketInfo, 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, type RedeemFeeOrder, type RedeemFeeOrderPair, ReferralClient, type ReferralConfigInfo, SEEDS, type SignedCollectFeeOrder, type SignedOrder, type SignedRedeemFeeOrder, type TxResult, UnauthorizedError, type UserBuyRecord, type UserClaimRecord, type UserDisputeInfo, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedCollectFeeEd25519Instruction, buildBatchedEd25519Instruction, buildBatchedRedeemFeeEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeCollectFeeOrderToBytes, serializeOrderToBytes, serializeRedeemFeeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|