@theliem/xmarket-sdk 3.9.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 +44 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1593,10 +1593,10 @@ ${logs.join("\n")}`);
|
|
|
1593
1593
|
connection.getAccountInfo(clobYesAta),
|
|
1594
1594
|
connection.getAccountInfo(clobNoAta)
|
|
1595
1595
|
]);
|
|
1596
|
-
const { createAssociatedTokenAccountIdempotentInstruction:
|
|
1596
|
+
const { createAssociatedTokenAccountIdempotentInstruction: createAssociatedTokenAccountIdempotentInstruction3 } = await import('@solana/spl-token');
|
|
1597
1597
|
const ixs = [];
|
|
1598
1598
|
if (!yesInfo) {
|
|
1599
|
-
ixs.push(
|
|
1599
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
|
|
1600
1600
|
this.walletPubkey,
|
|
1601
1601
|
clobYesAta,
|
|
1602
1602
|
clobConfig,
|
|
@@ -1605,7 +1605,7 @@ ${logs.join("\n")}`);
|
|
|
1605
1605
|
));
|
|
1606
1606
|
}
|
|
1607
1607
|
if (!noInfo) {
|
|
1608
|
-
ixs.push(
|
|
1608
|
+
ixs.push(createAssociatedTokenAccountIdempotentInstruction3(
|
|
1609
1609
|
this.walletPubkey,
|
|
1610
1610
|
clobNoAta,
|
|
1611
1611
|
clobConfig,
|
|
@@ -2130,10 +2130,19 @@ ${logs.join("\n")}`);
|
|
|
2130
2130
|
const allBuy = t.side === SIDE_BUY && makers.every((m) => m.order.side === SIDE_BUY);
|
|
2131
2131
|
const allSell = t.side === SIDE_SELL && makers.every((m) => m.order.side === SIDE_SELL);
|
|
2132
2132
|
if (!allBuy && !allSell) throw new InvalidParamError("MINT/MERGE: all orders must be same side");
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
if (
|
|
2136
|
-
|
|
2133
|
+
const takerIsYes = t.tokenId === 1 && makers.every((m) => m.order.tokenId === 0);
|
|
2134
|
+
const takerIsNo = t.tokenId === 0 && makers.every((m) => m.order.tokenId === 1);
|
|
2135
|
+
if (!takerIsYes && !takerIsNo) throw new InvalidParamError("MINT/MERGE: orders must be complementary YES+NO pair");
|
|
2136
|
+
if (takerIsYes) {
|
|
2137
|
+
if (allBuy) return this.matchMintOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt);
|
|
2138
|
+
return this.matchMergeOrders(taker, makers, collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2139
|
+
}
|
|
2140
|
+
let lastResult;
|
|
2141
|
+
for (const yesMaker of makers) {
|
|
2142
|
+
if (allBuy) lastResult = await this.matchMintOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt);
|
|
2143
|
+
else lastResult = await this.matchMergeOrders(yesMaker, [taker], collateralMint, feeRecipient, operatorWallet, alt, opts);
|
|
2144
|
+
}
|
|
2145
|
+
return lastResult;
|
|
2137
2146
|
}
|
|
2138
2147
|
/**
|
|
2139
2148
|
* High-level match: caller passes price + quantity + keypair — SDK builds,
|
|
@@ -14981,6 +14990,33 @@ var XMarketSDK = class {
|
|
|
14981
14990
|
}
|
|
14982
14991
|
};
|
|
14983
14992
|
var MAX_APPROVE_AMOUNT = new BN4("18446744073709551615");
|
|
14993
|
+
function buildCreateUserAtasTx(condition, user, payer, programIds) {
|
|
14994
|
+
const [yesMint] = PDA.yesMint(condition, programIds);
|
|
14995
|
+
const [noMint] = PDA.noMint(condition, programIds);
|
|
14996
|
+
const yesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
|
|
14997
|
+
const noAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
|
|
14998
|
+
const tx = new Transaction();
|
|
14999
|
+
tx.feePayer = payer;
|
|
15000
|
+
tx.add(
|
|
15001
|
+
createAssociatedTokenAccountIdempotentInstruction(
|
|
15002
|
+
payer,
|
|
15003
|
+
yesAta,
|
|
15004
|
+
user,
|
|
15005
|
+
yesMint,
|
|
15006
|
+
TOKEN_2022_PROGRAM_ID,
|
|
15007
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15008
|
+
),
|
|
15009
|
+
createAssociatedTokenAccountIdempotentInstruction(
|
|
15010
|
+
payer,
|
|
15011
|
+
noAta,
|
|
15012
|
+
user,
|
|
15013
|
+
noMint,
|
|
15014
|
+
TOKEN_2022_PROGRAM_ID,
|
|
15015
|
+
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
15016
|
+
)
|
|
15017
|
+
);
|
|
15018
|
+
return tx;
|
|
15019
|
+
}
|
|
14984
15020
|
function buildApproveCollateralTx(collateralMint, signer, payer, delegate, amount = MAX_APPROVE_AMOUNT) {
|
|
14985
15021
|
const ownerAta = getAssociatedTokenAddressSync(collateralMint, signer, false, TOKEN_PROGRAM_ID);
|
|
14986
15022
|
const approveIx = createApproveInstruction(
|
|
@@ -15024,6 +15060,6 @@ function buildApproveAllOutcomeTokensTx(condition, signer, payer, delegate, prog
|
|
|
15024
15060
|
return tx;
|
|
15025
15061
|
}
|
|
15026
15062
|
|
|
15027
|
-
export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
15063
|
+
export { AccountNotFoundError, AdminClient, ClobClient, CtfClient, FEE_DENOMINATOR, FeeManagementClient, HookClient, IX_SYSVAR, InvalidParamError, MAX_APPROVE_AMOUNT, MarketClient, MarketOracleClient, OracleClient, PDA, PresaleClient, QuestionStatus, SEEDS, UnauthorizedError, XMarketError, XMarketSDK, buildApproveAllOutcomeTokensTx, buildApproveCollateralTx, buildBatchedEd25519Instruction, buildCreateUserAtasTx, buildOrder, buildOrderFromPrice, deserializeSignedOrder, detectMatchType, generateContentHash, generateQuestionId, getOrderSignBytes, orderAmountsFromPrice, serializeOrderToBytes, serializeSignedOrder, signOrder, signOrderWithKeypair, verifySignedOrder };
|
|
15028
15064
|
//# sourceMappingURL=index.mjs.map
|
|
15029
15065
|
//# sourceMappingURL=index.mjs.map
|