@atomiqlabs/chain-solana 7.3.8 → 8.0.0-beta.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.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/solana/SolanaChains.d.ts +14 -0
- package/dist/solana/SolanaChains.js +18 -0
- package/dist/solana/SolanaInitializer.d.ts +18 -0
- package/dist/solana/SolanaInitializer.js +59 -0
- package/dist/solana/base/SolanaAction.js +25 -38
- package/dist/solana/base/modules/SolanaBlocks.js +18 -29
- package/dist/solana/base/modules/SolanaEvents.js +15 -26
- package/dist/solana/base/modules/SolanaFees.d.ts +4 -5
- package/dist/solana/base/modules/SolanaFees.js +168 -182
- package/dist/solana/base/modules/SolanaSlots.js +16 -29
- package/dist/solana/base/modules/SolanaTokens.d.ts +6 -7
- package/dist/solana/base/modules/SolanaTokens.js +63 -84
- package/dist/solana/base/modules/SolanaTransactions.d.ts +2 -2
- package/dist/solana/base/modules/SolanaTransactions.js +143 -165
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +2 -3
- package/dist/solana/btcrelay/SolanaBtcRelay.js +185 -221
- package/dist/solana/events/SolanaChainEvents.js +113 -138
- package/dist/solana/events/SolanaChainEventsBrowser.js +56 -65
- package/dist/solana/program/modules/SolanaProgramEvents.js +13 -24
- package/dist/solana/swaps/SolanaSwapData.d.ts +15 -11
- package/dist/solana/swaps/SolanaSwapData.js +29 -13
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +40 -41
- package/dist/solana/swaps/SolanaSwapProgram.js +212 -221
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +2 -3
- package/dist/solana/swaps/modules/SolanaDataAccount.js +117 -141
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +4 -5
- package/dist/solana/swaps/modules/SolanaLpVault.js +87 -110
- package/dist/solana/swaps/modules/SwapClaim.d.ts +4 -4
- package/dist/solana/swaps/modules/SwapClaim.js +122 -134
- package/dist/solana/swaps/modules/SwapInit.d.ts +2 -3
- package/dist/solana/swaps/modules/SwapInit.js +254 -285
- package/dist/solana/swaps/modules/SwapRefund.d.ts +2 -3
- package/dist/solana/swaps/modules/SwapRefund.js +103 -113
- package/dist/utils/Utils.d.ts +10 -0
- package/dist/utils/Utils.js +62 -35
- package/package.json +9 -6
- package/src/index.ts +1 -0
- package/src/solana/SolanaChains.ts +16 -0
- package/src/solana/SolanaInitializer.ts +98 -0
- package/src/solana/base/SolanaBase.ts +1 -2
- package/src/solana/base/modules/SolanaEvents.ts +0 -1
- package/src/solana/base/modules/SolanaFees.ts +35 -31
- package/src/solana/base/modules/SolanaTokens.ts +26 -27
- package/src/solana/base/modules/SolanaTransactions.ts +33 -28
- package/src/solana/btcrelay/SolanaBtcRelay.ts +6 -10
- package/src/solana/events/SolanaChainEventsBrowser.ts +14 -10
- package/src/solana/program/modules/SolanaProgramEvents.ts +1 -1
- package/src/solana/swaps/SolanaSwapData.ts +38 -19
- package/src/solana/swaps/SolanaSwapProgram.ts +133 -105
- package/src/solana/swaps/modules/SolanaDataAccount.ts +4 -6
- package/src/solana/swaps/modules/SolanaLpVault.ts +18 -18
- package/src/solana/swaps/modules/SwapClaim.ts +14 -17
- package/src/solana/swaps/modules/SwapInit.ts +35 -38
- package/src/solana/swaps/modules/SwapRefund.ts +20 -23
- package/src/utils/Utils.ts +35 -0
|
@@ -6,7 +6,6 @@ import { SolanaTx } from "../../base/modules/SolanaTransactions";
|
|
|
6
6
|
import { SolanaBtcStoredHeader } from "../../btcrelay/headers/SolanaBtcStoredHeader";
|
|
7
7
|
import { SolanaBtcRelay } from "../../btcrelay/SolanaBtcRelay";
|
|
8
8
|
import { SolanaSwapProgram } from "../SolanaSwapProgram";
|
|
9
|
-
import * as BN from "bn.js";
|
|
10
9
|
import { SolanaSigner } from "../../wallet/SolanaSigner";
|
|
11
10
|
export declare class SwapClaim extends SolanaSwapModule {
|
|
12
11
|
private static readonly CUCosts;
|
|
@@ -107,11 +106,12 @@ export declare class SwapClaim extends SolanaSwapModule {
|
|
|
107
106
|
* @param storageAccHolder an object holder filled in with the created data account where tx data is written
|
|
108
107
|
* @param feeRate fee rate to be used for the transactions
|
|
109
108
|
*/
|
|
110
|
-
txsClaimWithTxData(signer: PublicKey | SolanaSigner, swapData: SolanaSwapData,
|
|
109
|
+
txsClaimWithTxData(signer: PublicKey | SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
111
110
|
blockhash: string;
|
|
112
111
|
confirmations: number;
|
|
113
112
|
txid: string;
|
|
114
113
|
hex: string;
|
|
114
|
+
height: number;
|
|
115
115
|
}, vout: number, commitedHeader?: SolanaBtcStoredHeader, synchronizer?: RelaySynchronizer<any, SolanaTx, any>, initAta?: boolean, storageAccHolder?: {
|
|
116
116
|
storageAcc: PublicKey;
|
|
117
117
|
}, feeRate?: string): Promise<SolanaTx[] | null>;
|
|
@@ -120,9 +120,9 @@ export declare class SwapClaim extends SolanaSwapModule {
|
|
|
120
120
|
* Get the estimated solana transaction fee of the claim transaction in the worst case scenario in case where the
|
|
121
121
|
* ATA needs to be initialized again (i.e. adding the ATA rent exempt lamports to the fee)
|
|
122
122
|
*/
|
|
123
|
-
getClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<
|
|
123
|
+
getClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
124
124
|
/**
|
|
125
125
|
* Get the estimated solana transaction fee of the claim transaction, without
|
|
126
126
|
*/
|
|
127
|
-
getRawClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<
|
|
127
|
+
getRawClaimFee(signer: PublicKey, swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
128
128
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.SwapClaim = void 0;
|
|
13
4
|
const SolanaSwapModule_1 = require("../SolanaSwapModule");
|
|
@@ -16,35 +7,43 @@ const spl_token_1 = require("@solana/spl-token");
|
|
|
16
7
|
const base_1 = require("@atomiqlabs/base");
|
|
17
8
|
const web3_js_1 = require("@solana/web3.js");
|
|
18
9
|
const Utils_1 = require("../../../utils/Utils");
|
|
19
|
-
const BN = require("bn.js");
|
|
20
10
|
const SolanaSigner_1 = require("../../wallet/SolanaSigner");
|
|
11
|
+
const SolanaTokens_1 = require("../../base/modules/SolanaTokens");
|
|
12
|
+
const BN = require("bn.js");
|
|
21
13
|
class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
22
|
-
Claim(signer, swapData, secretOrDataKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
14
|
+
async Claim(signer, swapData, secretOrDataKey) {
|
|
15
|
+
const isDataKey = typeof (secretOrDataKey) !== "string";
|
|
16
|
+
const accounts = {
|
|
17
|
+
signer,
|
|
18
|
+
initializer: swapData.isPayIn() ? swapData.offerer : swapData.claimer,
|
|
19
|
+
escrowState: this.root.SwapEscrowState(Buffer.from(swapData.paymentHash, "hex")),
|
|
20
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
21
|
+
data: isDataKey ? secretOrDataKey : null,
|
|
22
|
+
};
|
|
23
|
+
let secretBuffer = isDataKey ?
|
|
24
|
+
Buffer.alloc(0) :
|
|
25
|
+
Buffer.from(secretOrDataKey, "hex");
|
|
26
|
+
if (swapData.isPayOut()) {
|
|
27
|
+
return new SolanaAction_1.SolanaAction(signer, this.root, await this.program.methods
|
|
28
|
+
.claimerClaimPayOut(secretBuffer)
|
|
29
|
+
.accounts({
|
|
30
|
+
...accounts,
|
|
31
|
+
claimerAta: swapData.claimerAta,
|
|
32
|
+
vault: this.root.SwapVault(swapData.token),
|
|
33
|
+
vaultAuthority: this.root.SwapVaultAuthority,
|
|
34
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
|
|
35
|
+
})
|
|
36
|
+
.instruction(), this.getComputeBudget(swapData));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return new SolanaAction_1.SolanaAction(signer, this.root, await this.program.methods
|
|
40
|
+
.claimerClaim(secretBuffer)
|
|
41
|
+
.accounts({
|
|
42
|
+
...accounts,
|
|
43
|
+
claimerUserData: this.root.SwapUserVault(swapData.claimer, swapData.token)
|
|
44
|
+
})
|
|
45
|
+
.instruction(), this.getComputeBudget(swapData));
|
|
46
|
+
}
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Verify and claim action required for BTC on-chain swaps verified through btc relay, adds the btc relay verify
|
|
@@ -59,13 +58,11 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
59
58
|
* @constructor
|
|
60
59
|
* @private
|
|
61
60
|
*/
|
|
62
|
-
VerifyAndClaim(signer, swapData, storeDataKey, merkleProof, commitedHeader) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return action;
|
|
68
|
-
});
|
|
61
|
+
async VerifyAndClaim(signer, swapData, storeDataKey, merkleProof, commitedHeader) {
|
|
62
|
+
const action = await this.btcRelay.Verify(signer, merkleProof.reversedTxId, swapData.confirmations, merkleProof.pos, merkleProof.merkle, commitedHeader);
|
|
63
|
+
action.addAction(await this.Claim(signer, swapData, storeDataKey));
|
|
64
|
+
action.computeBudget = null;
|
|
65
|
+
return action;
|
|
69
66
|
}
|
|
70
67
|
constructor(root, btcRelay) {
|
|
71
68
|
super(root);
|
|
@@ -101,26 +98,24 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
101
98
|
* to the required blockheight
|
|
102
99
|
* @private
|
|
103
100
|
*/
|
|
104
|
-
getCommitedHeaderAndSynchronize(signer, txBlockheight, requiredConfirmations, blockhash, txs, synchronizer) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return resp.computedHeaderMap[txBlockheight];
|
|
123
|
-
});
|
|
101
|
+
async getCommitedHeaderAndSynchronize(signer, txBlockheight, requiredConfirmations, blockhash, txs, synchronizer) {
|
|
102
|
+
const requiredBlockheight = txBlockheight + requiredConfirmations - 1;
|
|
103
|
+
const result = await (0, Utils_1.tryWithRetries)(() => this.btcRelay.retrieveLogAndBlockheight({
|
|
104
|
+
blockhash: blockhash
|
|
105
|
+
}, requiredBlockheight), this.retryPolicy);
|
|
106
|
+
if (result != null)
|
|
107
|
+
return result.header;
|
|
108
|
+
//Need to synchronize
|
|
109
|
+
if (synchronizer == null)
|
|
110
|
+
return null;
|
|
111
|
+
//TODO: We don't have to synchronize to tip, only to our required blockheight
|
|
112
|
+
const resp = await synchronizer.syncToLatestTxs(signer.toString());
|
|
113
|
+
this.logger.debug("getCommitedHeaderAndSynchronize(): BTC Relay not synchronized to required blockheight, " +
|
|
114
|
+
"synchronizing ourselves in " + resp.txs.length + " txs");
|
|
115
|
+
this.logger.debug("getCommitedHeaderAndSynchronize(): BTC Relay computed header map: ", resp.computedHeaderMap);
|
|
116
|
+
resp.txs.forEach(tx => txs.push(tx));
|
|
117
|
+
//Retrieve computed header
|
|
118
|
+
return resp.computedHeaderMap[txBlockheight];
|
|
124
119
|
}
|
|
125
120
|
/**
|
|
126
121
|
* Adds the transactions required for initialization and writing of transaction data to the data account
|
|
@@ -151,7 +146,7 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
151
146
|
*/
|
|
152
147
|
shouldUnwrap(signer, swapData) {
|
|
153
148
|
return swapData.isPayOut() &&
|
|
154
|
-
swapData.token.equals(
|
|
149
|
+
swapData.token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS) &&
|
|
155
150
|
swapData.claimer.equals(signer);
|
|
156
151
|
}
|
|
157
152
|
/**
|
|
@@ -166,33 +161,31 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
166
161
|
* @param feeRate fee rate to use for the transaction
|
|
167
162
|
* @param skipAtaCheck whether to check if ATA exists
|
|
168
163
|
*/
|
|
169
|
-
txsClaimWithSecret(signer, swapData, secret, checkExpiry, initAta, feeRate, skipAtaCheck) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return [yield action.tx(feeRate)];
|
|
195
|
-
});
|
|
164
|
+
async txsClaimWithSecret(signer, swapData, secret, checkExpiry, initAta, feeRate, skipAtaCheck) {
|
|
165
|
+
//We need to be sure that this transaction confirms in time, otherwise we reveal the secret to the counterparty
|
|
166
|
+
// and won't claim the funds
|
|
167
|
+
if (checkExpiry && await this.root.isExpired(swapData.claimer.toString(), swapData)) {
|
|
168
|
+
throw new base_1.SwapDataVerificationError("Not enough time to reliably pay the invoice");
|
|
169
|
+
}
|
|
170
|
+
const shouldInitAta = !skipAtaCheck && swapData.isPayOut() && !await this.root.Tokens.ataExists(swapData.claimerAta);
|
|
171
|
+
if (shouldInitAta && !initAta)
|
|
172
|
+
throw new base_1.SwapDataVerificationError("ATA not initialized");
|
|
173
|
+
if (feeRate == null)
|
|
174
|
+
feeRate = await this.getClaimFeeRate(signer, swapData);
|
|
175
|
+
const action = new SolanaAction_1.SolanaAction(signer, this.root);
|
|
176
|
+
const shouldUnwrap = this.shouldUnwrap(signer, swapData);
|
|
177
|
+
if (shouldInitAta) {
|
|
178
|
+
const initAction = this.root.Tokens.InitAta(signer, swapData.claimer, swapData.token, swapData.claimerAta);
|
|
179
|
+
if (initAction == null)
|
|
180
|
+
throw new base_1.SwapDataVerificationError("Invalid claimer token account address");
|
|
181
|
+
action.add(initAction);
|
|
182
|
+
}
|
|
183
|
+
action.add(await this.Claim(signer, swapData, secret));
|
|
184
|
+
if (shouldUnwrap)
|
|
185
|
+
action.add(this.root.Tokens.Unwrap(signer));
|
|
186
|
+
this.logger.debug("txsClaimWithSecret(): creating claim transaction, swap: " + swapData.getClaimHash() +
|
|
187
|
+
" initializingAta: " + shouldInitAta + " unwrapping: " + shouldUnwrap);
|
|
188
|
+
return [await action.tx(feeRate)];
|
|
196
189
|
}
|
|
197
190
|
/**
|
|
198
191
|
* Creates transaction claiming the swap using a confirmed transaction data (for BTC on-chain swaps)
|
|
@@ -208,37 +201,35 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
208
201
|
* @param storageAccHolder an object holder filled in with the created data account where tx data is written
|
|
209
202
|
* @param feeRate fee rate to be used for the transactions
|
|
210
203
|
*/
|
|
211
|
-
txsClaimWithTxData(signer, swapData,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return txs;
|
|
241
|
-
});
|
|
204
|
+
async txsClaimWithTxData(signer, swapData, tx, vout, commitedHeader, synchronizer, initAta, storageAccHolder, feeRate) {
|
|
205
|
+
const shouldInitAta = swapData.isPayOut() && !await this.root.Tokens.ataExists(swapData.claimerAta);
|
|
206
|
+
if (shouldInitAta && !initAta)
|
|
207
|
+
throw new base_1.SwapDataVerificationError("ATA not initialized");
|
|
208
|
+
const signerKey = signer instanceof SolanaSigner_1.SolanaSigner ? signer.getPublicKey() : signer;
|
|
209
|
+
if (feeRate == null)
|
|
210
|
+
feeRate = await this.getClaimFeeRate(signerKey, swapData);
|
|
211
|
+
const merkleProof = await this.btcRelay.bitcoinRpc.getMerkleProof(tx.txid, tx.blockhash);
|
|
212
|
+
this.logger.debug("txsClaimWithTxData(): merkle proof computed: ", merkleProof);
|
|
213
|
+
const txs = [];
|
|
214
|
+
if (commitedHeader == null)
|
|
215
|
+
commitedHeader = await this.getCommitedHeaderAndSynchronize(signerKey, tx.height, swapData.confirmations, tx.blockhash, txs, synchronizer);
|
|
216
|
+
const storeDataKey = await this.addTxsWriteTransactionData(signer, tx, vout, feeRate, txs);
|
|
217
|
+
if (storageAccHolder != null)
|
|
218
|
+
storageAccHolder.storageAcc = storeDataKey;
|
|
219
|
+
const shouldUnwrap = this.shouldUnwrap(signerKey, swapData);
|
|
220
|
+
if (shouldInitAta) {
|
|
221
|
+
const initAction = this.root.Tokens.InitAta(signerKey, swapData.claimer, swapData.token, swapData.claimerAta);
|
|
222
|
+
if (initAction == null)
|
|
223
|
+
throw new base_1.SwapDataVerificationError("Invalid claimer token account address");
|
|
224
|
+
await initAction.addToTxs(txs, feeRate);
|
|
225
|
+
}
|
|
226
|
+
const claimAction = await this.VerifyAndClaim(signerKey, swapData, storeDataKey, merkleProof, commitedHeader);
|
|
227
|
+
await claimAction.addToTxs(txs, feeRate);
|
|
228
|
+
if (shouldUnwrap)
|
|
229
|
+
await this.root.Tokens.Unwrap(signerKey).addToTxs(txs, feeRate);
|
|
230
|
+
this.logger.debug("txsClaimWithTxData(): creating claim transaction, swap: " + swapData.getClaimHash() +
|
|
231
|
+
" initializingAta: " + shouldInitAta + " unwrapping: " + shouldUnwrap + " num txns: " + txs.length);
|
|
232
|
+
return txs;
|
|
242
233
|
}
|
|
243
234
|
getClaimFeeRate(signer, swapData) {
|
|
244
235
|
const accounts = [signer];
|
|
@@ -276,22 +267,19 @@ class SwapClaim extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
276
267
|
* Get the estimated solana transaction fee of the claim transaction in the worst case scenario in case where the
|
|
277
268
|
* ATA needs to be initialized again (i.e. adding the ATA rent exempt lamports to the fee)
|
|
278
269
|
*/
|
|
279
|
-
getClaimFee(signer, swapData, feeRate) {
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
});
|
|
270
|
+
async getClaimFee(signer, swapData, feeRate) {
|
|
271
|
+
return BigInt(swapData == null || swapData.payOut ? SolanaTokens_1.SolanaTokens.SPL_ATA_RENT_EXEMPT : 0) +
|
|
272
|
+
await this.getRawClaimFee(signer, swapData, feeRate);
|
|
283
273
|
}
|
|
284
274
|
/**
|
|
285
275
|
* Get the estimated solana transaction fee of the claim transaction, without
|
|
286
276
|
*/
|
|
287
|
-
getRawClaimFee(signer, swapData, feeRate) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return new BN(5000).add(this.root.Fees.getPriorityFee(this.getComputeBudget(swapData), feeRate));
|
|
294
|
-
});
|
|
277
|
+
async getRawClaimFee(signer, swapData, feeRate) {
|
|
278
|
+
if (swapData == null)
|
|
279
|
+
return 5000n;
|
|
280
|
+
feeRate = feeRate || await this.getClaimFeeRate(signer, swapData);
|
|
281
|
+
//Include rent exempt in claim fee, to take into consideration worst case cost when user destroys ATA
|
|
282
|
+
return 5000n + this.root.Fees.getPriorityFee(this.getComputeBudget(swapData), feeRate);
|
|
295
283
|
}
|
|
296
284
|
}
|
|
297
285
|
exports.SwapClaim = SwapClaim;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ParsedAccountsModeBlockResponse, PublicKey } from "@solana/web3.js";
|
|
3
|
-
import * as BN from "bn.js";
|
|
4
3
|
import { SolanaSwapData } from "../SolanaSwapData";
|
|
5
4
|
import { SolanaSwapModule } from "../SolanaSwapModule";
|
|
6
5
|
import { SolanaTx } from "../../base/modules/SolanaTransactions";
|
|
@@ -209,9 +208,9 @@ export declare class SwapInit extends SolanaSwapModule {
|
|
|
209
208
|
* Get the estimated solana fee of the init transaction, this includes the required deposit for creating swap PDA
|
|
210
209
|
* and also deposit for ATAs
|
|
211
210
|
*/
|
|
212
|
-
getInitFee(swapData: SolanaSwapData, feeRate?: string): Promise<
|
|
211
|
+
getInitFee(swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
213
212
|
/**
|
|
214
213
|
* Get the estimated solana fee of the init transaction, without the required deposit for creating swap PDA
|
|
215
214
|
*/
|
|
216
|
-
getRawInitFee(swapData: SolanaSwapData, feeRate?: string): Promise<
|
|
215
|
+
getRawInitFee(swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
217
216
|
}
|