drama-pm-client 0.4.9 → 0.4.10
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/idl.d.ts +76 -29
- package/dist/idl.js +210 -1
- package/dist/index.d.ts +93 -0
- package/dist/index.js +179 -1
- package/dist/types.d.ts +209 -0
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,29 @@ export interface RefundParams {
|
|
|
57
57
|
tokenAmount?: number | BN;
|
|
58
58
|
closeAccount?: boolean;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Parameters for refundV2 - refunding both Yes and No positions in one transaction.
|
|
62
|
+
* Use this when a user has bet on both outcomes and wants to refund everything at once.
|
|
63
|
+
*/
|
|
64
|
+
export interface RefundV2Params {
|
|
65
|
+
user: PublicKey;
|
|
66
|
+
market: PublicKey;
|
|
67
|
+
bettingToken: PublicKey;
|
|
68
|
+
yesTokenAmount?: number | BN;
|
|
69
|
+
noTokenAmount?: number | BN;
|
|
70
|
+
closeYesAccount?: boolean;
|
|
71
|
+
closeNoAccount?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters for claim_burn_market instruction
|
|
75
|
+
* Combines claiming rewards (if won) and burning tokens (if lost) in one call.
|
|
76
|
+
* Always closes token accounts to reclaim rent.
|
|
77
|
+
*/
|
|
78
|
+
export interface ClaimBurnMarketParams {
|
|
79
|
+
user: PublicKey;
|
|
80
|
+
market: PublicKey;
|
|
81
|
+
bettingToken: PublicKey;
|
|
82
|
+
}
|
|
60
83
|
/**
|
|
61
84
|
* Parameters for placeBetV2 - combines user bet and bonus account bet in one transaction
|
|
62
85
|
* Requires both user and bonusAccount to sign the transaction
|
|
@@ -249,6 +272,62 @@ export declare class DramaPmClient {
|
|
|
249
272
|
* Build a complete transaction to refund
|
|
250
273
|
*/
|
|
251
274
|
buildRefundTx(params: RefundParams): Promise<Transaction>;
|
|
275
|
+
/**
|
|
276
|
+
* Refund both Yes and No positions in a single transaction.
|
|
277
|
+
*
|
|
278
|
+
* Use this method when a user has bet on both Yes and No outcomes and needs to
|
|
279
|
+
* refund all positions after the market has been resolved as "Refunded" (None).
|
|
280
|
+
*
|
|
281
|
+
* This method automatically:
|
|
282
|
+
* - Checks if the user has Yes tokens and/or No tokens
|
|
283
|
+
* - Only includes refund instructions for outcomes the user actually holds
|
|
284
|
+
* - Closes the token accounts after refunding (by default)
|
|
285
|
+
*
|
|
286
|
+
* @param params - RefundV2Params
|
|
287
|
+
* @param params.user - User's public key (signer)
|
|
288
|
+
* @param params.market - Market PDA address
|
|
289
|
+
* @param params.bettingToken - Betting token mint (e.g., USDC)
|
|
290
|
+
* @param params.yesTokenAmount - Optional. Amount of Yes tokens to refund. 0 or undefined = refund all.
|
|
291
|
+
* @param params.noTokenAmount - Optional. Amount of No tokens to refund. 0 or undefined = refund all.
|
|
292
|
+
* @param params.closeYesAccount - Optional. Whether to close the Yes token account after refund. Default: true
|
|
293
|
+
* @param params.closeNoAccount - Optional. Whether to close the No token account after refund. Default: true
|
|
294
|
+
*
|
|
295
|
+
* @returns Transaction containing refund instructions for both outcomes (if applicable)
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Basic usage: Refund all Yes and No tokens
|
|
300
|
+
* const tx = await client.buildRefundV2Tx({
|
|
301
|
+
* user: userPublicKey,
|
|
302
|
+
* market: marketPda,
|
|
303
|
+
* bettingToken: usdcMint,
|
|
304
|
+
* });
|
|
305
|
+
*
|
|
306
|
+
* // Sign and send
|
|
307
|
+
* tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
308
|
+
* tx.feePayer = userPublicKey;
|
|
309
|
+
* await wallet.signTransaction(tx);
|
|
310
|
+
* await connection.sendRawTransaction(tx.serialize());
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* // Keep token accounts open (don't close them)
|
|
316
|
+
* const tx = await client.buildRefundV2Tx({
|
|
317
|
+
* user: userPublicKey,
|
|
318
|
+
* market: marketPda,
|
|
319
|
+
* bettingToken: usdcMint,
|
|
320
|
+
* closeYesAccount: false, // Keep Yes token account open
|
|
321
|
+
* closeNoAccount: false, // Keep No token account open
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* - The market must be in "Refunded" status for this method to work
|
|
327
|
+
* - If the user only has tokens on one side, only that side will be refunded
|
|
328
|
+
* - The returned transaction will be empty if the user has no tokens on either side
|
|
329
|
+
*/
|
|
330
|
+
buildRefundV2Tx(params: RefundV2Params): Promise<Transaction>;
|
|
252
331
|
/**
|
|
253
332
|
* Resolve a market (Admin only)
|
|
254
333
|
*/
|
|
@@ -305,6 +384,20 @@ export declare class DramaPmClient {
|
|
|
305
384
|
* @param closeAccount - Whether to close the losing token account after burning all tokens (default: false)
|
|
306
385
|
*/
|
|
307
386
|
buildBurnMarketTokensTx(user: PublicKey, market: PublicKey, losingOutcome: Outcome, tokenAmount?: number | BN, closeAccount?: boolean): Promise<Transaction>;
|
|
387
|
+
/**
|
|
388
|
+
* Claim rewards if won, or burn tokens if lost, with optional account closure.
|
|
389
|
+
* This instruction combines claim_rewards and burn_market_tokens logic into a single call.
|
|
390
|
+
*
|
|
391
|
+
* @param params - ClaimBurnMarketParams
|
|
392
|
+
* @param userYesToken - User's YES token account (optional, pass null if user has no YES tokens)
|
|
393
|
+
* @param userNoToken - User's NO token account (optional, pass null if user has no NO tokens)
|
|
394
|
+
*/
|
|
395
|
+
claimBurnMarket(params: ClaimBurnMarketParams, userYesToken: PublicKey | null, userNoToken: PublicKey | null): Promise<TransactionInstruction>;
|
|
396
|
+
/**
|
|
397
|
+
* Build a complete transaction to claim rewards (if won) or burn tokens (if lost)
|
|
398
|
+
* Automatically creates user outcome token accounts based on user's holdings
|
|
399
|
+
*/
|
|
400
|
+
buildClaimBurnMarketTx(params: ClaimBurnMarketParams): Promise<Transaction>;
|
|
308
401
|
/**
|
|
309
402
|
* Fetch global config account data
|
|
310
403
|
*/
|