@theliem/xmarket-sdk 3.1.1 → 3.1.3

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.mjs CHANGED
@@ -273,28 +273,24 @@ var OracleClient = class {
273
273
  }
274
274
  /**
275
275
  * Whitelisted reporter resolves a question.
276
- * CPIs directly into CTF.set_payout condition is resolved in one tx.
277
- * @param conditionPda - CTF condition account (oracle_config = oraclePda, question_id must match)
278
- * @param ownerPubkey - oracle config owner (defaults to wallet)
279
- * @param payer - fee payer (defaults to wallet)
276
+ * reporter signs the instruction; payer covers the tx fee (Kora pattern).
280
277
  */
281
- async resolveQuestion(questionId, outcomeCount, payoutNumerators, conditionPda, ownerPubkey, payer, signers = []) {
278
+ async resolveQuestion(questionId, outcomeCount, payoutNumerators, conditionPda, reporter = this.walletPubkey, payer = this.walletPubkey, ownerPubkey) {
282
279
  const oracleConfig = this.configPda(ownerPubkey);
283
280
  const [questionResultPda] = PDA.questionResult(oracleConfig, questionId, this.programIds);
284
- const sig = await this.program.methods.resolveQuestion(
281
+ return this.program.methods.resolveQuestion(
285
282
  Array.from(questionId),
286
283
  outcomeCount,
287
284
  payoutNumerators.map((n) => new anchor4.BN(n))
288
285
  ).accounts({
289
- reporter: this.walletPubkey,
286
+ reporter,
290
287
  oracleConfig,
291
288
  questionResult: questionResultPda,
292
289
  condition: conditionPda,
293
290
  conditionalTokensProgram: this.programIds.conditionalTokens,
294
- payer: payer ?? this.walletPubkey,
291
+ payer,
295
292
  systemProgram: SystemProgram.programId
296
- }).signers(signers).rpc();
297
- return { signature: sig };
293
+ }).transaction();
298
294
  }
299
295
  /** Owner updates the admin. */
300
296
  async updateAdmin(newAdmin, ownerPubkey) {
@@ -936,7 +932,7 @@ var CtfClient = class {
936
932
  * Split `amount` collateral into equal YES + NO tokens.
937
933
  * ATAs created automatically via `init_if_needed`.
938
934
  */
939
- async splitPosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey, signers = []) {
935
+ async splitPosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey) {
940
936
  const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
941
937
  const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
942
938
  const [yesMint] = PDA.yesMint(condition, this.programIds);
@@ -947,7 +943,7 @@ var CtfClient = class {
947
943
  const userYesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
948
944
  const userNoAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
949
945
  const userCollateral = getAssociatedTokenAddressSync(collateralMint, user);
950
- const sig = await this.program.methods.splitPosition(amount).accounts({
946
+ return this.program.methods.splitPosition(amount).accounts({
951
947
  user,
952
948
  payer,
953
949
  condition,
@@ -965,14 +961,13 @@ var CtfClient = class {
965
961
  token2022Program: TOKEN_2022_PROGRAM_ID,
966
962
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
967
963
  systemProgram: SystemProgram.programId
968
- }).signers(signers).rpc({ skipPreflight: true });
969
- return { signature: sig };
964
+ }).transaction();
970
965
  }
971
966
  /**
972
967
  * Merge `amount` YES + NO tokens back into collateral.
973
968
  * Both token balances must be ≥ amount.
974
969
  */
975
- async mergePosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey, signers = []) {
970
+ async mergePosition(condition, collateralMint, amount, user = this.walletPubkey, payer = this.walletPubkey) {
976
971
  const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
977
972
  const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
978
973
  const [yesMint] = PDA.yesMint(condition, this.programIds);
@@ -982,7 +977,7 @@ var CtfClient = class {
982
977
  const userYesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
983
978
  const userNoAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
984
979
  const userCollateral = getAssociatedTokenAddressSync(collateralMint, user);
985
- const sig = await this.program.methods.mergePosition(amount).accounts({
980
+ return this.program.methods.mergePosition(amount).accounts({
986
981
  user,
987
982
  payer,
988
983
  condition,
@@ -998,14 +993,13 @@ var CtfClient = class {
998
993
  tokenProgram: TOKEN_PROGRAM_ID,
999
994
  token2022Program: TOKEN_2022_PROGRAM_ID,
1000
995
  systemProgram: SystemProgram.programId
1001
- }).signers(signers).rpc({ skipPreflight: true });
1002
- return { signature: sig };
996
+ }).transaction();
1003
997
  }
1004
998
  /**
1005
999
  * After condition resolves: burn outcome tokens proportional to payout
1006
1000
  * and receive USDC. Works for winning, losing, or both positions.
1007
1001
  */
1008
- async redeemPositions(condition, collateralMint, user = this.walletPubkey, payer = this.walletPubkey, signers = []) {
1002
+ async redeemPositions(condition, collateralMint, user = this.walletPubkey, payer = this.walletPubkey) {
1009
1003
  const [collateralVault] = PDA.collateralVault(collateralMint, this.programIds);
1010
1004
  const [vaultTokenAccount] = PDA.vaultToken(collateralMint, this.programIds);
1011
1005
  const [yesMint] = PDA.yesMint(condition, this.programIds);
@@ -1015,7 +1009,7 @@ var CtfClient = class {
1015
1009
  const userYesAta = getAssociatedTokenAddressSync(yesMint, user, false, TOKEN_2022_PROGRAM_ID);
1016
1010
  const userNoAta = getAssociatedTokenAddressSync(noMint, user, false, TOKEN_2022_PROGRAM_ID);
1017
1011
  const userCollateral = getAssociatedTokenAddressSync(collateralMint, user);
1018
- const sig = await this.program.methods.redeemPositions().accounts({
1012
+ return this.program.methods.redeemPositions().accounts({
1019
1013
  user,
1020
1014
  payer,
1021
1015
  condition,
@@ -1031,8 +1025,7 @@ var CtfClient = class {
1031
1025
  tokenProgram: TOKEN_PROGRAM_ID,
1032
1026
  token2022Program: TOKEN_2022_PROGRAM_ID,
1033
1027
  systemProgram: SystemProgram.programId
1034
- }).signers(signers).rpc({ skipPreflight: true });
1035
- return { signature: sig };
1028
+ }).transaction();
1036
1029
  }
1037
1030
  /**
1038
1031
  * Oracle directly resolves a condition with payout numerators.
@@ -1373,8 +1366,8 @@ var ClobClient = class {
1373
1366
  async _sendLegacyTx(instructions) {
1374
1367
  const { connection } = this.provider;
1375
1368
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
1376
- const { Transaction: Transaction4 } = await import('@solana/web3.js');
1377
- const tx = new Transaction4();
1369
+ const { Transaction: Transaction7 } = await import('@solana/web3.js');
1370
+ const tx = new Transaction7();
1378
1371
  tx.recentBlockhash = blockhash;
1379
1372
  tx.feePayer = this.walletPubkey;
1380
1373
  tx.add(...instructions);
@@ -2057,7 +2050,7 @@ var PresaleClient = class {
2057
2050
  * qtAmount: amount of MST to receive (9 decimals).
2058
2051
  * USDC cost = qtAmount * price / 1e9.
2059
2052
  */
2060
- async buy(presalePda, qtAmount, buyer = this.walletPubkey, payer = this.walletPubkey, signers = []) {
2053
+ async buy(presalePda, qtAmount, buyer = this.walletPubkey, payer = this.walletPubkey) {
2061
2054
  const presale = await this.fetchPresale(presalePda);
2062
2055
  if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2063
2056
  const qtMint = presale.qtMint;
@@ -2067,7 +2060,7 @@ var PresaleClient = class {
2067
2060
  const buyerQtAta = getAssociatedTokenAddressSync(qtMint, buyer);
2068
2061
  const buyerCurrencyAta = getAssociatedTokenAddressSync(currencyMint, buyer);
2069
2062
  const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2070
- const sig = await this.program.methods.buy(qtAmount).accounts({
2063
+ return this.program.methods.buy(qtAmount).accounts({
2071
2064
  buyer,
2072
2065
  payer,
2073
2066
  presale: presalePda,
@@ -2081,14 +2074,13 @@ var PresaleClient = class {
2081
2074
  tokenProgram: TOKEN_PROGRAM_ID,
2082
2075
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2083
2076
  systemProgram: SystemProgram.programId
2084
- }).signers(signers).rpc();
2085
- return { signature: sig };
2077
+ }).transaction();
2086
2078
  }
2087
2079
  /**
2088
2080
  * Refund: burn user's MST and return USDC.
2089
2081
  * Only callable when presale status = Rejected.
2090
2082
  */
2091
- async refund(presalePda, user = this.walletPubkey, signers = []) {
2083
+ async refund(presalePda, user = this.walletPubkey) {
2092
2084
  const presale = await this.fetchPresale(presalePda);
2093
2085
  if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2094
2086
  const qtMint = presale.qtMint;
@@ -2097,7 +2089,7 @@ var PresaleClient = class {
2097
2089
  const userQtAta = getAssociatedTokenAddressSync(qtMint, user);
2098
2090
  const userCurrencyAta = getAssociatedTokenAddressSync(currencyMint, user);
2099
2091
  const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2100
- const sig = await this.program.methods.refund().accounts({
2092
+ return this.program.methods.refund().accounts({
2101
2093
  user,
2102
2094
  presale: presalePda,
2103
2095
  qtMint,
@@ -2109,19 +2101,18 @@ var PresaleClient = class {
2109
2101
  tokenProgram: TOKEN_PROGRAM_ID,
2110
2102
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2111
2103
  systemProgram: SystemProgram.programId
2112
- }).signers(signers).rpc();
2113
- return { signature: sig };
2104
+ }).transaction();
2114
2105
  }
2115
2106
  /**
2116
2107
  * Creator claims their share of presale revenue after distribute_presale_revenue.
2117
2108
  */
2118
- async claimRevenue(presalePda, creator = this.walletPubkey, signers = []) {
2109
+ async claimRevenue(presalePda, creator = this.walletPubkey) {
2119
2110
  const presale = await this.fetchPresale(presalePda);
2120
2111
  if (!presale) throw new Error(`Presale not found: ${presalePda.toBase58()}`);
2121
2112
  const currencyMint = presale.currencyMint;
2122
2113
  const presaleVault = getAssociatedTokenAddressSync(currencyMint, presalePda, true);
2123
2114
  const creatorCurrencyAta = getAssociatedTokenAddressSync(currencyMint, creator);
2124
- const sig = await this.program.methods.claimRevenue().accounts({
2115
+ return this.program.methods.claimRevenue().accounts({
2125
2116
  creator,
2126
2117
  presale: presalePda,
2127
2118
  presaleVault,
@@ -2130,8 +2121,7 @@ var PresaleClient = class {
2130
2121
  tokenProgram: TOKEN_PROGRAM_ID,
2131
2122
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2132
2123
  systemProgram: SystemProgram.programId
2133
- }).signers(signers).rpc();
2134
- return { signature: sig };
2124
+ }).transaction();
2135
2125
  }
2136
2126
  /**
2137
2127
  * Transfer creator_claimable_revenue (80%) to BOTMM wallet.
@@ -2218,7 +2208,7 @@ var MarketOracleClient = class {
2218
2208
  * User burns their MST and claims proportional share of oracle vault USDC.
2219
2209
  * Call after market.collectTradingFee snapshotted qt supply.
2220
2210
  */
2221
- async claimFeesShare(marketOraclePda, user = this.walletPubkey, payer = this.walletPubkey, signers = []) {
2211
+ async claimFeesShare(marketOraclePda, user = this.walletPubkey, payer = this.walletPubkey) {
2222
2212
  const oracle = await this.fetchMarketOracle(marketOraclePda);
2223
2213
  if (!oracle) throw new Error(`MarketOracle not found: ${marketOraclePda.toBase58()}`);
2224
2214
  const currencyMint = oracle.currencyMint;
@@ -2227,7 +2217,7 @@ var MarketOracleClient = class {
2227
2217
  const userQtAta = getAssociatedTokenAddressSync(qtMint, user);
2228
2218
  const userCurrencyAta = getAssociatedTokenAddressSync(currencyMint, user);
2229
2219
  const userClaimRecord = this.userClaimRecordPda(marketOraclePda, user);
2230
- const sig = await this.program.methods.claimFeesShare().accounts({
2220
+ return this.program.methods.claimFeesShare().accounts({
2231
2221
  user,
2232
2222
  payer,
2233
2223
  marketOracle: marketOraclePda,
@@ -2240,8 +2230,7 @@ var MarketOracleClient = class {
2240
2230
  tokenProgram: TOKEN_PROGRAM_ID,
2241
2231
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
2242
2232
  systemProgram: SystemProgram.programId
2243
- }).signers(signers).rpc();
2244
- return { signature: sig };
2233
+ }).transaction();
2245
2234
  }
2246
2235
  // ─── Queries ─────────────────────────────────────────────────────────────────
2247
2236
  async fetchMarketOracle(marketOraclePda) {