@theliem/xmarket-sdk 3.8.0 → 3.10.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 +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +66 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1078,6 +1078,18 @@ declare function detectMatchType(a: Order | SignedOrder, b: Order | SignedOrder)
|
|
|
1078
1078
|
|
|
1079
1079
|
/** Maximum u64 — approve "unlimited" amount. */
|
|
1080
1080
|
declare const MAX_APPROVE_AMOUNT: BN;
|
|
1081
|
+
/**
|
|
1082
|
+
* Build a Transaction that creates YES and NO Token-2022 ATAs for a user
|
|
1083
|
+
* (idempotent — safe to call even if they already exist).
|
|
1084
|
+
*
|
|
1085
|
+
* Required signer: payer (fee payer). No user signature needed.
|
|
1086
|
+
*
|
|
1087
|
+
* @param condition - condition PDA
|
|
1088
|
+
* @param user - wallet that will own the ATAs
|
|
1089
|
+
* @param payer - fee payer wallet pubkey
|
|
1090
|
+
* @param programIds - network program IDs
|
|
1091
|
+
*/
|
|
1092
|
+
declare function buildCreateUserAtasTx(condition: PublicKey, user: PublicKey, payer: PublicKey, programIds: ProgramIds): Transaction;
|
|
1081
1093
|
/**
|
|
1082
1094
|
* Build a Transaction that approves the CLOB config PDA to transfer collateral
|
|
1083
1095
|
* (USDC) from the signer's ATA.
|
|
@@ -1099,4 +1111,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1099
1111
|
*/
|
|
1100
1112
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1101
1113
|
|
|
1102
|
-
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, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1114
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1078,6 +1078,18 @@ declare function detectMatchType(a: Order | SignedOrder, b: Order | SignedOrder)
|
|
|
1078
1078
|
|
|
1079
1079
|
/** Maximum u64 — approve "unlimited" amount. */
|
|
1080
1080
|
declare const MAX_APPROVE_AMOUNT: BN;
|
|
1081
|
+
/**
|
|
1082
|
+
* Build a Transaction that creates YES and NO Token-2022 ATAs for a user
|
|
1083
|
+
* (idempotent — safe to call even if they already exist).
|
|
1084
|
+
*
|
|
1085
|
+
* Required signer: payer (fee payer). No user signature needed.
|
|
1086
|
+
*
|
|
1087
|
+
* @param condition - condition PDA
|
|
1088
|
+
* @param user - wallet that will own the ATAs
|
|
1089
|
+
* @param payer - fee payer wallet pubkey
|
|
1090
|
+
* @param programIds - network program IDs
|
|
1091
|
+
*/
|
|
1092
|
+
declare function buildCreateUserAtasTx(condition: PublicKey, user: PublicKey, payer: PublicKey, programIds: ProgramIds): Transaction;
|
|
1081
1093
|
/**
|
|
1082
1094
|
* Build a Transaction that approves the CLOB config PDA to transfer collateral
|
|
1083
1095
|
* (USDC) from the signer's ATA.
|
|
@@ -1099,4 +1111,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1099
1111
|
*/
|
|
1100
1112
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1101
1113
|
|
|
1102
|
-
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, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
1114
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1619,10 +1619,10 @@ ${logs.join("\n")}`);
|
|
|
1619
1619
|
connection.getAccountInfo(clobYesAta),
|
|
1620
1620
|
connection.getAccountInfo(clobNoAta)
|
|
1621
1621
|
]);
|
|
1622
|
-
const { createAssociatedTokenAccountIdempotentInstruction:
|
|
1622
|
+
const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction3 } = await import('@solana/spl-token');
|
|
1623
1623
|
const ixs = [];
|
|
1624
1624
|
if (!yesInfo) {
|
|
1625
|
-
ixs.push(
|
|
1625
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
|
|
1626
1626
|
this.walletPubkey,
|
|
1627
1627
|
clobYesAta,
|
|
1628
1628
|
clobConfig,
|
|
@@ -1631,7 +1631,7 @@ ${logs.join("\n")}`);
|
|
|
1631
1631
|
));
|
|
1632
1632
|
}
|
|
1633
1633
|
if (!noInfo) {
|
|
1634
|
-
ixs.push(
|
|
1634
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
|
|
1635
1635
|
this.walletPubkey,
|
|
1636
1636
|
clobNoAta,
|
|
1637
1637
|
clobConfig,
|
|
@@ -1967,7 +1967,7 @@ ${logs.join("\n")}`);
|
|
|
1967
1967
|
{ pubkey: hookConfig, isSigner: false, isWritable: false },
|
|
1968
1968
|
{ pubkey: hookProgram, isSigner: false, isWritable: false }
|
|
1969
1969
|
);
|
|
1970
|
-
const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount).accounts({
|
|
1970
|
+
const matchIx = await this.program.methods.matchMintOrders(takerNonce, fillAmount, true).accounts({
|
|
1971
1971
|
operator: operatorWallet.publicKey,
|
|
1972
1972
|
payer: this.walletPubkey,
|
|
1973
1973
|
clobConfig,
|
|
@@ -2063,17 +2063,21 @@ ${logs.join("\n")}`);
|
|
|
2063
2063
|
if (yesSigned.order.fee.gtn(0) && this.programIds.feeManagement && this.feeConfigOwner) {
|
|
2064
2064
|
const companyAddr = await this.companyAddress();
|
|
2065
2065
|
if (companyAddr) {
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2066
|
+
const feeOverridePda = PDA.marketFeeOverride(condition, this.programIds)[0];
|
|
2067
|
+
const feeOverrideExists = await this.provider.connection.getAccountInfo(feeOverridePda);
|
|
2068
|
+
if (feeOverrideExists) {
|
|
2069
|
+
const oracleVault = opts?.marketOracleVault ?? this.walletPubkey;
|
|
2070
|
+
remainingAccounts.push(
|
|
2071
|
+
{ pubkey: this.programIds.feeManagement, isSigner: false, isWritable: false },
|
|
2072
|
+
{ pubkey: PDA.feeConfig(this.feeConfigOwner, this.programIds)[0], isSigner: false, isWritable: false },
|
|
2073
|
+
{ pubkey: feeOverridePda, isSigner: false, isWritable: false },
|
|
2074
|
+
{ pubkey: splToken.getAssociatedTokenAddressSync(collateralMint, companyAddr), isSigner: false, isWritable: true },
|
|
2075
|
+
{ pubkey: oracleVault, isSigner: false, isWritable: true }
|
|
2076
|
+
);
|
|
2077
|
+
}
|
|
2074
2078
|
}
|
|
2075
2079
|
}
|
|
2076
|
-
const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount).accounts({
|
|
2080
|
+
const matchIx = await this.program.methods.matchMergeOrders(takerNonce, fillAmount, true).accounts({
|
|
2077
2081
|
operator: operatorWallet.publicKey,
|
|
2078
2082
|
payer: this.walletPubkey,
|
|
2079
2083
|
clobConfig,
|
|
@@ -2152,10 +2156,19 @@ ${logs.join("\n")}`);
|
|
|
2152
2156
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
2153
2157
|
const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
|
|
2154
2158
|
if (!allBuy && !allSell) throw new InvalidParamError("MINT/MERGE: all orders must be same side");
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
if (
|
|
2158
|
-
|
|
2159
|
+
const takerIsYes = t.tokenId === 1 && makers.every((m) => m.order.tokenId === 0);
|
|
2160
|
+
const takerIsNo = t.tokenId === 0 && makers.every((m) => m.order.tokenId === 1);
|
|
2161
|
+
if (!takerIsYes && !takerIsNo) throw new InvalidParamError("MINT/MERGE: orders must be complementary YES+NO pair");
|
|
2162
|
+
if (takerIsYes) {
|
|
2163
|
+
if (allBuy) return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
|
|
2164
|
+
return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2165
|
+
}
|
|
2166
|
+
let lastResult;
|
|
2167
|
+
for (const yesMaker of makers) {
|
|
2168
|
+
if (allBuy) lastResult = await this.matchMintOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt);
|
|
2169
|
+
else lastResult = await this.matchMergeOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2170
|
+
}
|
|
2171
|
+
return lastResult;
|
|
2159
2172
|
}
|
|
2160
2173
|
/**
|
|
2161
2174
|
* High-level match: caller passes price + quantity + keypair — SDK builds,
|
|
@@ -9126,6 +9139,10 @@ var clob_exchange_default = {
|
|
|
9126
9139
|
{
|
|
9127
9140
|
name: "fill_amount",
|
|
9128
9141
|
type: "u64"
|
|
9142
|
+
},
|
|
9143
|
+
{
|
|
9144
|
+
name: "skip_crossing_check",
|
|
9145
|
+
type: "bool"
|
|
9129
9146
|
}
|
|
9130
9147
|
]
|
|
9131
9148
|
},
|
|
@@ -9417,6 +9434,10 @@ var clob_exchange_default = {
|
|
|
9417
9434
|
{
|
|
9418
9435
|
name: "fill_amount",
|
|
9419
9436
|
type: "u64"
|
|
9437
|
+
},
|
|
9438
|
+
{
|
|
9439
|
+
name: "skip_crossing_check",
|
|
9440
|
+
type: "bool"
|
|
9420
9441
|
}
|
|
9421
9442
|
]
|
|
9422
9443
|
},
|
|
@@ -14995,6 +15016,33 @@ var XMarketSDK = class {
|
|
|
14995
15016
|
}
|
|
14996
15017
|
};
|
|
14997
15018
|
var MAX_APPROVE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
15019
|
+
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
15020
|
+
const [yesMint] = PDA.yesMint(condition, programIds);
|
|
15021
|
+
const [noMint] = PDA.noMint(condition, programIds);
|
|
15022
|
+
const yesAta = splToken.getAssociatedTokenAddressSync(yesMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
15023
|
+
const noAta = splToken.getAssociatedTokenAddressSync(noMint, user, false, splToken.TOKEN_2022_PROGRAM_ID);
|
|
15024
|
+
const tx = new web3_js.Transaction();
|
|
15025
|
+
tx.feePayer = payer;
|
|
15026
|
+
tx.add(
|
|
15027
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(
|
|
15028
|
+
payer,
|
|
15029
|
+
yesAta,
|
|
15030
|
+
user,
|
|
15031
|
+
yesMint,
|
|
15032
|
+
splToken.TOKEN_2022_PROGRAM_ID,
|
|
15033
|
+
splToken.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15034
|
+
),
|
|
15035
|
+
splToken.createAssociatedTokenAccountIdempotentInstruction(
|
|
15036
|
+
payer,
|
|
15037
|
+
noAta,
|
|
15038
|
+
user,
|
|
15039
|
+
noMint,
|
|
15040
|
+
splToken.TOKEN_2022_PROGRAM_ID,
|
|
15041
|
+
splToken.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15042
|
+
)
|
|
15043
|
+
);
|
|
15044
|
+
return tx;
|
|
15045
|
+
}
|
|
14998
15046
|
function buildApproveCollateralTx(collateralMint, signer, payer, delegate, amount = MAX_APPROVE_AMOUNT) {
|
|
14999
15047
|
const ownerAta = splToken.getAssociatedTokenAddressSync(collateralMint, signer, false, splToken.TOKEN_PROGRAM_ID);
|
|
15000
15048
|
const approveIx = splToken.createApproveInstruction(
|
|
@@ -15061,6 +15109,7 @@ exports.XMarketSDK = XMarketSDK;
|
|
|
15061
15109
|
exports.buildApproveAllOutcomeTokensTx = buildApproveAllOutcomeTokensTx;
|
|
15062
15110
|
exports.buildApproveCollateralTx = buildApproveCollateralTx;
|
|
15063
15111
|
exports.buildBatchedEd25519Instruction = buildBatchedEd25519Instruction;
|
|
15112
|
+
exports.buildCreateUserAtasTx = buildCreateUserAtasTx;
|
|
15064
15113
|
exports.buildOrder = buildOrder;
|
|
15065
15114
|
exports.buildOrderFromPrice = buildOrderFromPrice;
|
|
15066
15115
|
exports.deserializeSignedOrder = deserializeSignedOrder;
|