@theliem/xmarket-sdk 3.27.0 → 3.28.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 +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +93 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1015,6 +1015,22 @@ interface UserClaimRecord {
|
|
|
1015
1015
|
hasClaimed: boolean;
|
|
1016
1016
|
bump: number;
|
|
1017
1017
|
}
|
|
1018
|
+
interface FeesShareEstimate {
|
|
1019
|
+
/** Net USDS user will receive if they claim now */
|
|
1020
|
+
share: anchor.BN;
|
|
1021
|
+
/** Total accumulated fees (vault + already claimed) */
|
|
1022
|
+
effectiveTotal: anchor.BN;
|
|
1023
|
+
/** Current vault balance */
|
|
1024
|
+
vaultBalance: anchor.BN;
|
|
1025
|
+
/** User's current MST balance */
|
|
1026
|
+
userQtBalance: anchor.BN;
|
|
1027
|
+
/** Snapshotted total MST supply (0 if not yet distributed) */
|
|
1028
|
+
qtTotalSupply: anchor.BN;
|
|
1029
|
+
/** True if fees_distributed — claim is on-chain executable */
|
|
1030
|
+
feesDistributed: boolean;
|
|
1031
|
+
/** True if user already claimed */
|
|
1032
|
+
hasClaimed: boolean;
|
|
1033
|
+
}
|
|
1018
1034
|
declare class MarketOracleClient {
|
|
1019
1035
|
private readonly program;
|
|
1020
1036
|
private readonly provider;
|
|
@@ -1034,6 +1050,19 @@ declare class MarketOracleClient {
|
|
|
1034
1050
|
* presaleAddress is used as the questionId seed in the question PDA.
|
|
1035
1051
|
*/
|
|
1036
1052
|
getOracleVaultBalance(presaleAddress: PublicKey, qmConfigPda: PublicKey, collateralMint: PublicKey): Promise<number>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Estimate the USDS share a user would receive if they called claimFeesShare now.
|
|
1055
|
+
* Works both before and after fees_distributed — no extra params needed.
|
|
1056
|
+
*
|
|
1057
|
+
* When fees not yet distributed, auto-resolves qtMint via:
|
|
1058
|
+
* oracle.question (questionPda) → raw account bytes[8..40] = presalePda
|
|
1059
|
+
* → PDA.qtMint(presalePda) → qtMint
|
|
1060
|
+
*
|
|
1061
|
+
* Formula mirrors on-chain claim_fees_share_handler:
|
|
1062
|
+
* effective_total = vault_balance + oracle.total_claimed
|
|
1063
|
+
* share = user_qt_balance * effective_total / oracle.qt_total_supply
|
|
1064
|
+
*/
|
|
1065
|
+
estimateFeesShare(marketOraclePda: PublicKey, user: PublicKey): Promise<FeesShareEstimate | null>;
|
|
1037
1066
|
fetchUserClaimRecord(marketOraclePda: PublicKey, user: PublicKey): Promise<UserClaimRecord | null>;
|
|
1038
1067
|
}
|
|
1039
1068
|
|
|
@@ -1487,4 +1516,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1487
1516
|
*/
|
|
1488
1517
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1489
1518
|
|
|
1490
|
-
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 };
|
|
1519
|
+
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, type FeesShareEstimate, 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
|
@@ -1015,6 +1015,22 @@ interface UserClaimRecord {
|
|
|
1015
1015
|
hasClaimed: boolean;
|
|
1016
1016
|
bump: number;
|
|
1017
1017
|
}
|
|
1018
|
+
interface FeesShareEstimate {
|
|
1019
|
+
/** Net USDS user will receive if they claim now */
|
|
1020
|
+
share: anchor.BN;
|
|
1021
|
+
/** Total accumulated fees (vault + already claimed) */
|
|
1022
|
+
effectiveTotal: anchor.BN;
|
|
1023
|
+
/** Current vault balance */
|
|
1024
|
+
vaultBalance: anchor.BN;
|
|
1025
|
+
/** User's current MST balance */
|
|
1026
|
+
userQtBalance: anchor.BN;
|
|
1027
|
+
/** Snapshotted total MST supply (0 if not yet distributed) */
|
|
1028
|
+
qtTotalSupply: anchor.BN;
|
|
1029
|
+
/** True if fees_distributed — claim is on-chain executable */
|
|
1030
|
+
feesDistributed: boolean;
|
|
1031
|
+
/** True if user already claimed */
|
|
1032
|
+
hasClaimed: boolean;
|
|
1033
|
+
}
|
|
1018
1034
|
declare class MarketOracleClient {
|
|
1019
1035
|
private readonly program;
|
|
1020
1036
|
private readonly provider;
|
|
@@ -1034,6 +1050,19 @@ declare class MarketOracleClient {
|
|
|
1034
1050
|
* presaleAddress is used as the questionId seed in the question PDA.
|
|
1035
1051
|
*/
|
|
1036
1052
|
getOracleVaultBalance(presaleAddress: PublicKey, qmConfigPda: PublicKey, collateralMint: PublicKey): Promise<number>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Estimate the USDS share a user would receive if they called claimFeesShare now.
|
|
1055
|
+
* Works both before and after fees_distributed — no extra params needed.
|
|
1056
|
+
*
|
|
1057
|
+
* When fees not yet distributed, auto-resolves qtMint via:
|
|
1058
|
+
* oracle.question (questionPda) → raw account bytes[8..40] = presalePda
|
|
1059
|
+
* → PDA.qtMint(presalePda) → qtMint
|
|
1060
|
+
*
|
|
1061
|
+
* Formula mirrors on-chain claim_fees_share_handler:
|
|
1062
|
+
* effective_total = vault_balance + oracle.total_claimed
|
|
1063
|
+
* share = user_qt_balance * effective_total / oracle.qt_total_supply
|
|
1064
|
+
*/
|
|
1065
|
+
estimateFeesShare(marketOraclePda: PublicKey, user: PublicKey): Promise<FeesShareEstimate | null>;
|
|
1037
1066
|
fetchUserClaimRecord(marketOraclePda: PublicKey, user: PublicKey): Promise<UserClaimRecord | null>;
|
|
1038
1067
|
}
|
|
1039
1068
|
|
|
@@ -1487,4 +1516,4 @@ declare function buildApproveCollateralTx(collateralMint: PublicKey, signer: Pub
|
|
|
1487
1516
|
*/
|
|
1488
1517
|
declare function buildApproveAllOutcomeTokensTx(condition: PublicKey, signer: PublicKey, payer: PublicKey, delegate: PublicKey, programIds: ProgramIds, amount?: BN): Transaction;
|
|
1489
1518
|
|
|
1490
|
-
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 };
|
|
1519
|
+
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, type FeesShareEstimate, 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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var anchor6 = require('@coral-xyz/anchor');
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var splToken = require('@solana/spl-token');
|
|
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
|
|
27
27
|
return Object.freeze(n);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var anchor6__namespace = /*#__PURE__*/_interopNamespace(anchor6);
|
|
31
31
|
var BN4__default = /*#__PURE__*/_interopDefault(BN4);
|
|
32
32
|
var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
|
|
33
33
|
|
|
@@ -376,7 +376,7 @@ var OracleClient = class {
|
|
|
376
376
|
return this.program.methods.resolveQuestion(
|
|
377
377
|
Array.from(questionId),
|
|
378
378
|
outcomeCount,
|
|
379
|
-
payoutNumerators.map((n) => new
|
|
379
|
+
payoutNumerators.map((n) => new anchor6__namespace.BN(n))
|
|
380
380
|
).accounts({
|
|
381
381
|
reporter,
|
|
382
382
|
oracleConfig,
|
|
@@ -665,7 +665,7 @@ var MarketClient = class {
|
|
|
665
665
|
contentHash: Array.from(contentHash),
|
|
666
666
|
hookProgram: params.hookProgram,
|
|
667
667
|
authorizedClob: params.authorizedClob,
|
|
668
|
-
expirationTime: new
|
|
668
|
+
expirationTime: new anchor6__namespace.BN(params.expirationTime)
|
|
669
669
|
}).accounts({
|
|
670
670
|
creator,
|
|
671
671
|
payer,
|
|
@@ -754,7 +754,7 @@ var MarketClient = class {
|
|
|
754
754
|
}).transaction();
|
|
755
755
|
}
|
|
756
756
|
async bumpPresaleCount(count, authority) {
|
|
757
|
-
return this.program.methods.bumpPresaleCount(new
|
|
757
|
+
return this.program.methods.bumpPresaleCount(new anchor6__namespace.BN(count)).accounts({ authority, config: this.configPda }).transaction();
|
|
758
758
|
}
|
|
759
759
|
// ─── Queries ─────────────────────────────────────────────────────────────────
|
|
760
760
|
async fetchConfig() {
|
|
@@ -1262,7 +1262,7 @@ var CtfClient = class {
|
|
|
1262
1262
|
* Bypasses QuestionMarket — only for oracle-owned conditions.
|
|
1263
1263
|
*/
|
|
1264
1264
|
async reportPayouts(condition, payoutNumerators) {
|
|
1265
|
-
const sig = await this.program.methods.reportPayouts(payoutNumerators.map((n) => new
|
|
1265
|
+
const sig = await this.program.methods.reportPayouts(payoutNumerators.map((n) => new anchor6__namespace.BN(n))).accounts({
|
|
1266
1266
|
oracle: this.walletPubkey,
|
|
1267
1267
|
condition
|
|
1268
1268
|
}).rpc();
|
|
@@ -2107,7 +2107,7 @@ ${logs.join("\n")}`);
|
|
|
2107
2107
|
const tokenId = takerSigned.order.tokenId;
|
|
2108
2108
|
const taker = takerSigned.order.maker;
|
|
2109
2109
|
const takerNonce = takerSigned.order.nonce;
|
|
2110
|
-
const fillAmount = opts?.fillAmount ?? new
|
|
2110
|
+
const fillAmount = opts?.fillAmount ?? new anchor6__namespace.BN("18446744073709551615");
|
|
2111
2111
|
const [outcomeMint] = tokenId === 1 ? PDA.yesMint(condition, this.programIds) : PDA.noMint(condition, this.programIds);
|
|
2112
2112
|
const [takerOrderRecord] = PDA.orderRecord(taker, takerNonce, this.programIds);
|
|
2113
2113
|
const takerCollateral = splToken.getAssociatedTokenAddressSync(collateralMint, taker);
|
|
@@ -2248,7 +2248,7 @@ ${logs.join("\n")}`);
|
|
|
2248
2248
|
const condition = yesSigned.order.condition;
|
|
2249
2249
|
const taker = yesSigned.order.maker;
|
|
2250
2250
|
const takerNonce = yesSigned.order.nonce;
|
|
2251
|
-
const fillAmount = new
|
|
2251
|
+
const fillAmount = new anchor6__namespace.BN("18446744073709551615");
|
|
2252
2252
|
const clobConfig = this.configPda();
|
|
2253
2253
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
2254
2254
|
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
@@ -2352,7 +2352,7 @@ ${logs.join("\n")}`);
|
|
|
2352
2352
|
const condition = yesSigned.order.condition;
|
|
2353
2353
|
const sellerYes = yesSigned.order.maker;
|
|
2354
2354
|
const takerNonce = yesSigned.order.nonce;
|
|
2355
|
-
const fillAmount = new
|
|
2355
|
+
const fillAmount = new anchor6__namespace.BN("18446744073709551615");
|
|
2356
2356
|
const clobConfig = this.configPda();
|
|
2357
2357
|
const [yesMint] = PDA.yesMint(condition, this.programIds);
|
|
2358
2358
|
const [noMint] = PDA.noMint(condition, this.programIds);
|
|
@@ -2819,9 +2819,9 @@ ${logs.join("\n")}`);
|
|
|
2819
2819
|
ixSysvar: IX_SYSVAR,
|
|
2820
2820
|
orderSigner: order.user,
|
|
2821
2821
|
redeemFeeOrderRecord,
|
|
2822
|
-
systemProgram:
|
|
2822
|
+
systemProgram: anchor6__namespace.web3.SystemProgram.programId
|
|
2823
2823
|
}).instruction();
|
|
2824
|
-
const tx = new
|
|
2824
|
+
const tx = new anchor6__namespace.web3.Transaction();
|
|
2825
2825
|
tx.add(ed25519Ix, registerIx);
|
|
2826
2826
|
return tx;
|
|
2827
2827
|
}
|
|
@@ -2924,7 +2924,7 @@ ${logs.join("\n")}`);
|
|
|
2924
2924
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
2925
2925
|
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
2926
2926
|
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
2927
|
-
systemProgram:
|
|
2927
|
+
systemProgram: anchor6__namespace.web3.SystemProgram.programId
|
|
2928
2928
|
}).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
|
|
2929
2929
|
const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
|
|
2930
2930
|
return this._buildUnsignedVtx([...hookInitIxs, redeemIx], alt, payer);
|
|
@@ -3026,7 +3026,7 @@ ${logs.join("\n")}`);
|
|
|
3026
3026
|
conditionalTokensProgram: this.programIds.conditionalTokens,
|
|
3027
3027
|
tokenProgram: splToken.TOKEN_PROGRAM_ID,
|
|
3028
3028
|
token2022Program: splToken.TOKEN_2022_PROGRAM_ID,
|
|
3029
|
-
systemProgram:
|
|
3029
|
+
systemProgram: anchor6__namespace.web3.SystemProgram.programId
|
|
3030
3030
|
}).remainingAccounts([...userAccounts, ...hookAccounts, ...feeAccounts]).instruction();
|
|
3031
3031
|
const alt = opts?.lookupTable ?? await this.buildAltForCondition(condition, payer, collateralMint);
|
|
3032
3032
|
return this._buildUnsignedVtx([...hookInitIxs, mergeIx], alt, payer);
|
|
@@ -3597,6 +3597,73 @@ var MarketOracleClient = class {
|
|
|
3597
3597
|
const bal = await this.program.provider.connection.getTokenAccountBalance(vault);
|
|
3598
3598
|
return bal.value.uiAmount ?? 0;
|
|
3599
3599
|
}
|
|
3600
|
+
/**
|
|
3601
|
+
* Estimate the USDS share a user would receive if they called claimFeesShare now.
|
|
3602
|
+
* Works both before and after fees_distributed — no extra params needed.
|
|
3603
|
+
*
|
|
3604
|
+
* When fees not yet distributed, auto-resolves qtMint via:
|
|
3605
|
+
* oracle.question (questionPda) → raw account bytes[8..40] = presalePda
|
|
3606
|
+
* → PDA.qtMint(presalePda) → qtMint
|
|
3607
|
+
*
|
|
3608
|
+
* Formula mirrors on-chain claim_fees_share_handler:
|
|
3609
|
+
* effective_total = vault_balance + oracle.total_claimed
|
|
3610
|
+
* share = user_qt_balance * effective_total / oracle.qt_total_supply
|
|
3611
|
+
*/
|
|
3612
|
+
async estimateFeesShare(marketOraclePda, user) {
|
|
3613
|
+
const { connection } = this.provider;
|
|
3614
|
+
const [oracle, claimRecord] = await Promise.all([
|
|
3615
|
+
this.fetchMarketOracle(marketOraclePda),
|
|
3616
|
+
this.fetchUserClaimRecord(marketOraclePda, user)
|
|
3617
|
+
]);
|
|
3618
|
+
if (!oracle) return null;
|
|
3619
|
+
const hasClaimed = claimRecord?.hasClaimed ?? false;
|
|
3620
|
+
const vaultAta = splToken.getAssociatedTokenAddressSync(oracle.currencyMint, marketOraclePda, true);
|
|
3621
|
+
const needsQtMintResolve = !oracle.feesDistributed || oracle.qtMint.equals(web3_js.PublicKey.default);
|
|
3622
|
+
const [vaultResult, questionAccount] = await Promise.all([
|
|
3623
|
+
connection.getTokenAccountBalance(vaultAta).catch(() => null),
|
|
3624
|
+
needsQtMintResolve ? connection.getAccountInfo(oracle.question).catch(() => null) : Promise.resolve(null)
|
|
3625
|
+
]);
|
|
3626
|
+
const vaultBalance = vaultResult ? new anchor6__namespace.BN(vaultResult.value.amount) : new anchor6__namespace.BN(0);
|
|
3627
|
+
let qtMint = oracle.qtMint;
|
|
3628
|
+
if (needsQtMintResolve && questionAccount) {
|
|
3629
|
+
try {
|
|
3630
|
+
const presalePda = new web3_js.PublicKey(questionAccount.data.slice(41, 73));
|
|
3631
|
+
qtMint = PDA.qtMint(presalePda, this.programIds)[0];
|
|
3632
|
+
} catch {
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
const isDefaultMint = qtMint.equals(web3_js.PublicKey.default);
|
|
3636
|
+
const needsSupply = (!oracle.feesDistributed || oracle.qtTotalSupply.isZero()) && !isDefaultMint;
|
|
3637
|
+
const userQtAta = isDefaultMint ? null : splToken.getAssociatedTokenAddressSync(qtMint, user);
|
|
3638
|
+
const [qtBalResult, supplyResult] = await Promise.all([
|
|
3639
|
+
userQtAta ? connection.getTokenAccountBalance(userQtAta).catch(() => null) : Promise.resolve(null),
|
|
3640
|
+
needsSupply ? connection.getTokenSupply(qtMint).catch(() => null) : Promise.resolve(null)
|
|
3641
|
+
]);
|
|
3642
|
+
const userQtBalance = qtBalResult ? new anchor6__namespace.BN(qtBalResult.value.amount) : new anchor6__namespace.BN(0);
|
|
3643
|
+
const qtTotalSupply = needsSupply && supplyResult ? new anchor6__namespace.BN(supplyResult.value.amount) : oracle.qtTotalSupply;
|
|
3644
|
+
const effectiveTotal = vaultBalance.add(oracle.totalClaimed);
|
|
3645
|
+
if (qtTotalSupply.isZero() || userQtBalance.isZero()) {
|
|
3646
|
+
return {
|
|
3647
|
+
share: new anchor6__namespace.BN(0),
|
|
3648
|
+
effectiveTotal,
|
|
3649
|
+
vaultBalance,
|
|
3650
|
+
userQtBalance,
|
|
3651
|
+
qtTotalSupply,
|
|
3652
|
+
feesDistributed: oracle.feesDistributed,
|
|
3653
|
+
hasClaimed
|
|
3654
|
+
};
|
|
3655
|
+
}
|
|
3656
|
+
const share = userQtBalance.mul(effectiveTotal).div(qtTotalSupply);
|
|
3657
|
+
return {
|
|
3658
|
+
share,
|
|
3659
|
+
effectiveTotal,
|
|
3660
|
+
vaultBalance,
|
|
3661
|
+
userQtBalance,
|
|
3662
|
+
qtTotalSupply,
|
|
3663
|
+
feesDistributed: oracle.feesDistributed,
|
|
3664
|
+
hasClaimed
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3600
3667
|
async fetchUserClaimRecord(marketOraclePda, user) {
|
|
3601
3668
|
try {
|
|
3602
3669
|
const pda = this.userClaimRecordPda(marketOraclePda, user);
|
|
@@ -18734,12 +18801,12 @@ var dispute_default = {
|
|
|
18734
18801
|
var XMarketSDK = class {
|
|
18735
18802
|
constructor(config, wallet, marketOwner) {
|
|
18736
18803
|
this.networkConfig = config;
|
|
18737
|
-
this.provider = new
|
|
18804
|
+
this.provider = new anchor6__namespace.AnchorProvider(
|
|
18738
18805
|
new web3_js.Connection(config.rpcUrl, "confirmed"),
|
|
18739
18806
|
wallet,
|
|
18740
18807
|
{ commitment: "confirmed", preflightCommitment: "confirmed" }
|
|
18741
18808
|
);
|
|
18742
|
-
|
|
18809
|
+
anchor6__namespace.setProvider(this.provider);
|
|
18743
18810
|
this._programIds = config.programIds;
|
|
18744
18811
|
this._marketOwner = marketOwner ?? wallet.publicKey;
|
|
18745
18812
|
}
|
|
@@ -18748,21 +18815,21 @@ var XMarketSDK = class {
|
|
|
18748
18815
|
}
|
|
18749
18816
|
get oracle() {
|
|
18750
18817
|
if (!this._oracle) {
|
|
18751
|
-
const program = new
|
|
18818
|
+
const program = new anchor6__namespace.Program(this._withAddress(oracle_default, this._programIds.oracle), this.provider);
|
|
18752
18819
|
this._oracle = new OracleClient(program, this.provider, this._programIds);
|
|
18753
18820
|
}
|
|
18754
18821
|
return this._oracle;
|
|
18755
18822
|
}
|
|
18756
18823
|
get hook() {
|
|
18757
18824
|
if (!this._hook) {
|
|
18758
|
-
const program = new
|
|
18825
|
+
const program = new anchor6__namespace.Program(this._withAddress(hook_default, this._programIds.hook), this.provider);
|
|
18759
18826
|
this._hook = new HookClient(program, this.provider, this._programIds);
|
|
18760
18827
|
}
|
|
18761
18828
|
return this._hook;
|
|
18762
18829
|
}
|
|
18763
18830
|
get market() {
|
|
18764
18831
|
if (!this._market) {
|
|
18765
|
-
const program = new
|
|
18832
|
+
const program = new anchor6__namespace.Program(this._withAddress(question_market_default, this._programIds.questionMarket), this.provider);
|
|
18766
18833
|
this._market = new MarketClient(program, this.provider, this._programIds, this._marketOwner);
|
|
18767
18834
|
this._market.ctfClient = this.ctf;
|
|
18768
18835
|
this._market.feeConfigOwner = this.networkConfig.feeConfigOwner ?? this._marketOwner;
|
|
@@ -18771,14 +18838,14 @@ var XMarketSDK = class {
|
|
|
18771
18838
|
}
|
|
18772
18839
|
get ctf() {
|
|
18773
18840
|
if (!this._ctf) {
|
|
18774
|
-
const program = new
|
|
18841
|
+
const program = new anchor6__namespace.Program(this._withAddress(conditional_tokens_default, this._programIds.conditionalTokens), this.provider);
|
|
18775
18842
|
this._ctf = new CtfClient(program, this.provider, this._programIds);
|
|
18776
18843
|
}
|
|
18777
18844
|
return this._ctf;
|
|
18778
18845
|
}
|
|
18779
18846
|
get clob() {
|
|
18780
18847
|
if (!this._clob) {
|
|
18781
|
-
const program = new
|
|
18848
|
+
const program = new anchor6__namespace.Program(this._withAddress(clob_exchange_default, this._programIds.clobExchange), this.provider);
|
|
18782
18849
|
this._clob = new ClobClient(program, this.provider, this._programIds, this.networkConfig);
|
|
18783
18850
|
if (this.networkConfig.feeConfigOwner && this._programIds.feeManagement) {
|
|
18784
18851
|
this._clob.feeConfigOwner = this.networkConfig.feeConfigOwner;
|
|
@@ -18793,7 +18860,7 @@ var XMarketSDK = class {
|
|
|
18793
18860
|
get fee() {
|
|
18794
18861
|
if (!this._fee) {
|
|
18795
18862
|
if (!this._programIds.feeManagement) throw new Error("feeManagement program ID not configured in NetworkConfig");
|
|
18796
|
-
const program = new
|
|
18863
|
+
const program = new anchor6__namespace.Program(this._withAddress(fee_management_default, this._programIds.feeManagement), this.provider);
|
|
18797
18864
|
this._fee = new FeeManagementClient(program, this.provider, this._programIds);
|
|
18798
18865
|
}
|
|
18799
18866
|
return this._fee;
|
|
@@ -18801,7 +18868,7 @@ var XMarketSDK = class {
|
|
|
18801
18868
|
get presale() {
|
|
18802
18869
|
if (!this._presale) {
|
|
18803
18870
|
if (!this._programIds.presale) throw new Error("presale program ID not configured in NetworkConfig");
|
|
18804
|
-
const program = new
|
|
18871
|
+
const program = new anchor6__namespace.Program(this._withAddress(presale_default, this._programIds.presale), this.provider);
|
|
18805
18872
|
this._presale = new PresaleClient(program, this.provider, this._programIds);
|
|
18806
18873
|
}
|
|
18807
18874
|
return this._presale;
|
|
@@ -18809,7 +18876,7 @@ var XMarketSDK = class {
|
|
|
18809
18876
|
get marketOracle() {
|
|
18810
18877
|
if (!this._marketOracle) {
|
|
18811
18878
|
if (!this._programIds.marketOracle) throw new Error("marketOracle program ID not configured in NetworkConfig");
|
|
18812
|
-
const program = new
|
|
18879
|
+
const program = new anchor6__namespace.Program(this._withAddress(market_oracle_default, this._programIds.marketOracle), this.provider);
|
|
18813
18880
|
this._marketOracle = new MarketOracleClient(program, this.provider, this._programIds);
|
|
18814
18881
|
}
|
|
18815
18882
|
return this._marketOracle;
|
|
@@ -18817,7 +18884,7 @@ var XMarketSDK = class {
|
|
|
18817
18884
|
get admin() {
|
|
18818
18885
|
if (!this._admin) {
|
|
18819
18886
|
if (!this._programIds.adminContract) throw new Error("adminContract program ID not configured in NetworkConfig");
|
|
18820
|
-
const program = new
|
|
18887
|
+
const program = new anchor6__namespace.Program(this._withAddress(admin_contract_default, this._programIds.adminContract), this.provider);
|
|
18821
18888
|
this._admin = new AdminClient(program, this.provider, this._programIds);
|
|
18822
18889
|
}
|
|
18823
18890
|
return this._admin;
|
|
@@ -18825,7 +18892,7 @@ var XMarketSDK = class {
|
|
|
18825
18892
|
get referral() {
|
|
18826
18893
|
if (!this._referral) {
|
|
18827
18894
|
if (!this._programIds.referral) throw new Error("referral program ID not configured in NetworkConfig");
|
|
18828
|
-
const program = new
|
|
18895
|
+
const program = new anchor6__namespace.Program(this._withAddress(referral_default, this._programIds.referral), this.provider);
|
|
18829
18896
|
this._referral = new ReferralClient(program, this.provider, this._programIds);
|
|
18830
18897
|
}
|
|
18831
18898
|
return this._referral;
|
|
@@ -18833,7 +18900,7 @@ var XMarketSDK = class {
|
|
|
18833
18900
|
get dispute() {
|
|
18834
18901
|
if (!this._dispute) {
|
|
18835
18902
|
if (!this._programIds.dispute) throw new Error("dispute program ID not configured in NetworkConfig");
|
|
18836
|
-
const program = new
|
|
18903
|
+
const program = new anchor6__namespace.Program(this._withAddress(dispute_default, this._programIds.dispute), this.provider);
|
|
18837
18904
|
this._dispute = new DisputeClient(program, this.provider, this._programIds);
|
|
18838
18905
|
}
|
|
18839
18906
|
return this._dispute;
|