@atomiqlabs/chain-solana 8.0.3 → 9.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 +11 -11
- package/dist/index.js +11 -11
- package/dist/solana/SolanaChainType.d.ts +3 -2
- package/dist/solana/SolanaInitializer.d.ts +2 -2
- package/dist/solana/SolanaInitializer.js +9 -5
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +4 -4
- package/dist/solana/btcrelay/SolanaBtcRelay.js +13 -14
- package/dist/solana/{base → chain}/SolanaAction.d.ts +2 -2
- package/dist/solana/chain/SolanaChainInterface.d.ts +58 -0
- package/dist/solana/chain/SolanaChainInterface.js +112 -0
- package/dist/solana/{base → chain}/SolanaModule.d.ts +3 -3
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -0
- package/dist/solana/{base → chain}/modules/SolanaAddresses.js +2 -3
- package/dist/solana/events/SolanaChainEvents.d.ts +0 -4
- package/dist/solana/events/SolanaChainEvents.js +0 -16
- package/dist/solana/events/SolanaChainEventsBrowser.js +0 -1
- package/dist/solana/program/SolanaProgramBase.d.ts +11 -5
- package/dist/solana/program/SolanaProgramBase.js +7 -7
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -0
- package/dist/solana/program/SolanaProgramModule.js +11 -0
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +4 -3
- package/dist/solana/program/modules/SolanaProgramEvents.js +8 -8
- package/dist/solana/swaps/SolanaSwapData.js +1 -1
- package/dist/solana/swaps/SolanaSwapModule.d.ts +6 -5
- package/dist/solana/swaps/SolanaSwapModule.js +5 -6
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +4 -23
- package/dist/solana/swaps/SolanaSwapProgram.js +22 -98
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +3 -2
- package/dist/solana/swaps/modules/SolanaDataAccount.js +9 -9
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +1 -1
- package/dist/solana/swaps/modules/SolanaLpVault.js +13 -13
- package/dist/solana/swaps/modules/SwapClaim.d.ts +3 -2
- package/dist/solana/swaps/modules/SwapClaim.js +15 -15
- package/dist/solana/swaps/modules/SwapInit.d.ts +1 -1
- package/dist/solana/swaps/modules/SwapInit.js +21 -21
- package/dist/solana/swaps/modules/SwapRefund.d.ts +1 -1
- package/dist/solana/swaps/modules/SwapRefund.js +17 -17
- package/package.json +2 -2
- package/src/index.ts +11 -11
- package/src/solana/SolanaChainType.ts +7 -2
- package/src/solana/SolanaInitializer.ts +13 -9
- package/src/solana/btcrelay/SolanaBtcRelay.ts +17 -17
- package/src/solana/{base → chain}/SolanaAction.ts +3 -3
- package/src/solana/chain/SolanaChainInterface.ts +175 -0
- package/src/solana/{base → chain}/SolanaModule.ts +3 -3
- package/src/solana/{base → chain}/modules/SolanaAddresses.ts +2 -3
- package/src/solana/events/SolanaChainEvents.ts +0 -17
- package/src/solana/events/SolanaChainEventsBrowser.ts +0 -1
- package/src/solana/program/SolanaProgramBase.ts +13 -10
- package/src/solana/program/SolanaProgramModule.ts +16 -0
- package/src/solana/program/modules/SolanaProgramEvents.ts +10 -9
- package/src/solana/swaps/SolanaSwapData.ts +1 -1
- package/src/solana/swaps/SolanaSwapModule.ts +8 -8
- package/src/solana/swaps/SolanaSwapProgram.ts +28 -133
- package/src/solana/swaps/modules/SolanaDataAccount.ts +11 -10
- package/src/solana/swaps/modules/SolanaLpVault.ts +15 -15
- package/src/solana/swaps/modules/SwapClaim.ts +17 -16
- package/src/solana/swaps/modules/SwapInit.ts +22 -22
- package/src/solana/swaps/modules/SwapRefund.ts +18 -18
- package/dist/solana/base/SolanaBase.d.ts +0 -36
- package/dist/solana/base/SolanaBase.js +0 -30
- package/dist/solana/base/modules/SolanaAddresses.d.ts +0 -9
- package/src/solana/base/SolanaBase.ts +0 -56
- /package/dist/solana/{base → chain}/SolanaAction.js +0 -0
- /package/dist/solana/{base → chain}/SolanaModule.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaBlocks.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaBlocks.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaEvents.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaEvents.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaFees.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaFees.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaSignatures.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaSignatures.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaSlots.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaSlots.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaTokens.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaTokens.js +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaTransactions.d.ts +0 -0
- /package/dist/solana/{base → chain}/modules/SolanaTransactions.js +0 -0
- /package/src/solana/{base → chain}/modules/SolanaBlocks.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaEvents.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaFees.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaSignatures.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaSlots.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaTokens.ts +0 -0
- /package/src/solana/{base → chain}/modules/SolanaTransactions.ts +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaProgramModule = void 0;
|
|
4
|
+
const SolanaModule_1 = require("../chain/SolanaModule");
|
|
5
|
+
class SolanaProgramModule extends SolanaModule_1.SolanaModule {
|
|
6
|
+
constructor(chainInterface, program) {
|
|
7
|
+
super(chainInterface);
|
|
8
|
+
this.program = program;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SolanaProgramModule = SolanaProgramModule;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { SolanaEvents } from "../../
|
|
1
|
+
import { SolanaEvents } from "../../chain/modules/SolanaEvents";
|
|
2
2
|
import { DecodeType, Event, Idl, IdlTypes } from "@coral-xyz/anchor";
|
|
3
3
|
import { IdlField, IdlInstruction } from "@coral-xyz/anchor/dist/cjs/idl";
|
|
4
4
|
import { ParsedMessage, PublicKey } from "@solana/web3.js";
|
|
5
5
|
import { SolanaProgramBase } from "../SolanaProgramBase";
|
|
6
|
+
import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
|
|
6
7
|
type DecodedFieldOrNull<D, Defined> = D extends IdlField ? DecodeType<D["type"], Defined> : unknown;
|
|
7
8
|
type ArgsTuple<A extends IdlField[], Defined> = {
|
|
8
9
|
[K in A[number]["name"]]: DecodedFieldOrNull<Extract<A[number], {
|
|
@@ -21,9 +22,9 @@ export type ProgramEvent<IDL extends Idl> = Event<IDL["events"][number], Record<
|
|
|
21
22
|
export declare class SolanaProgramEvents<IDL extends Idl> extends SolanaEvents {
|
|
22
23
|
private readonly programCoder;
|
|
23
24
|
private readonly eventParser;
|
|
24
|
-
readonly
|
|
25
|
+
private readonly program;
|
|
25
26
|
private readonly nameMappedInstructions;
|
|
26
|
-
constructor(
|
|
27
|
+
constructor(chain: SolanaChainInterface, program: SolanaProgramBase<IDL>);
|
|
27
28
|
/**
|
|
28
29
|
* Gets events from specific transaction as specified by signature, events are ordered from newest to oldest
|
|
29
30
|
*
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SolanaProgramEvents = void 0;
|
|
4
|
-
const SolanaEvents_1 = require("../../
|
|
4
|
+
const SolanaEvents_1 = require("../../chain/modules/SolanaEvents");
|
|
5
5
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
6
|
class SolanaProgramEvents extends SolanaEvents_1.SolanaEvents {
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
9
|
-
this.
|
|
10
|
-
this.programCoder = new anchor_1.BorshCoder(
|
|
11
|
-
this.eventParser = new anchor_1.EventParser(
|
|
7
|
+
constructor(chain, program) {
|
|
8
|
+
super(chain);
|
|
9
|
+
this.program = program;
|
|
10
|
+
this.programCoder = new anchor_1.BorshCoder(program.program.idl);
|
|
11
|
+
this.eventParser = new anchor_1.EventParser(program.program.programId, this.programCoder);
|
|
12
12
|
this.nameMappedInstructions = {};
|
|
13
|
-
for (let ix of
|
|
13
|
+
for (let ix of program.program.idl.instructions) {
|
|
14
14
|
this.nameMappedInstructions[ix.name] = ix;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -62,7 +62,7 @@ class SolanaProgramEvents extends SolanaEvents_1.SolanaEvents {
|
|
|
62
62
|
decodeInstructions(transactionMessage) {
|
|
63
63
|
const instructions = [];
|
|
64
64
|
for (let _ix of transactionMessage.instructions) {
|
|
65
|
-
if (!_ix.programId.equals(this.
|
|
65
|
+
if (!_ix.programId.equals(this.program.program.programId)) {
|
|
66
66
|
instructions.push(null);
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
@@ -8,7 +8,7 @@ const SwapTypeEnum_1 = require("./SwapTypeEnum");
|
|
|
8
8
|
const buffer_1 = require("buffer");
|
|
9
9
|
const spl_token_1 = require("@solana/spl-token");
|
|
10
10
|
const Utils_1 = require("../../utils/Utils");
|
|
11
|
-
const SolanaTokens_1 = require("../
|
|
11
|
+
const SolanaTokens_1 = require("../chain/modules/SolanaTokens");
|
|
12
12
|
const EXPIRY_BLOCKHEIGHT_THRESHOLD = new BN("1000000000");
|
|
13
13
|
class SolanaSwapData extends base_1.SwapData {
|
|
14
14
|
constructor(offererOrData, claimer, token, amount, paymentHash, sequence, expiry, nonce, confirmations, payOut, kind, payIn, offererAta, claimerAta, securityDeposit, claimerBounty, txoHash) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { SolanaModule } from "../base/SolanaModule";
|
|
2
1
|
import { SolanaSwapProgram } from "./SolanaSwapProgram";
|
|
3
2
|
import { Program } from "@coral-xyz/anchor";
|
|
4
3
|
import { SwapProgram } from "./programTypes";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { SolanaProgramModule } from "../program/SolanaProgramModule";
|
|
5
|
+
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
6
|
+
export declare class SolanaSwapModule extends SolanaProgramModule<SwapProgram> {
|
|
7
|
+
protected readonly program: SolanaSwapProgram;
|
|
8
|
+
protected readonly swapProgram: Program<SwapProgram>;
|
|
9
|
+
constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram);
|
|
9
10
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SolanaSwapModule = void 0;
|
|
4
|
-
const
|
|
5
|
-
class SolanaSwapModule extends
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
8
|
-
this.
|
|
9
|
-
this.program = root.program;
|
|
4
|
+
const SolanaProgramModule_1 = require("../program/SolanaProgramModule");
|
|
5
|
+
class SolanaSwapModule extends SolanaProgramModule_1.SolanaProgramModule {
|
|
6
|
+
constructor(chainInterface, program) {
|
|
7
|
+
super(chainInterface, program);
|
|
8
|
+
this.swapProgram = program.program;
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
exports.SolanaSwapModule = SolanaSwapModule;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SolanaSwapData } from "./SolanaSwapData";
|
|
3
|
-
import {
|
|
3
|
+
import { PublicKey } from "@solana/web3.js";
|
|
4
4
|
import { SolanaBtcRelay } from "../btcrelay/SolanaBtcRelay";
|
|
5
5
|
import { IStorageManager, SwapContract, ChainSwapType, IntermediaryReputationType, SwapCommitStatus, TransactionConfirmationOptions, SignatureData, RelaySynchronizer } from "@atomiqlabs/base";
|
|
6
6
|
import { SolanaBtcStoredHeader } from "../btcrelay/headers/SolanaBtcStoredHeader";
|
|
7
|
-
import { SolanaFees } from "../base/modules/SolanaFees";
|
|
8
7
|
import { SwapProgram } from "./programTypes";
|
|
9
|
-
import {
|
|
8
|
+
import { SolanaChainInterface } from "../chain/SolanaChainInterface";
|
|
10
9
|
import { SolanaProgramBase } from "../program/SolanaProgramBase";
|
|
11
|
-
import { SolanaTx } from "../
|
|
10
|
+
import { SolanaTx } from "../chain/modules/SolanaTransactions";
|
|
12
11
|
import { SwapInit, SolanaPreFetchData, SolanaPreFetchVerification } from "./modules/SwapInit";
|
|
13
12
|
import { SolanaDataAccount, StoredDataAccount } from "./modules/SolanaDataAccount";
|
|
14
13
|
import { SwapRefund } from "./modules/SwapRefund";
|
|
@@ -34,7 +33,7 @@ export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> im
|
|
|
34
33
|
readonly Claim: SwapClaim;
|
|
35
34
|
readonly DataAccount: SolanaDataAccount;
|
|
36
35
|
readonly LpVault: SolanaLpVault;
|
|
37
|
-
constructor(
|
|
36
|
+
constructor(chainInterface: SolanaChainInterface, btcRelay: SolanaBtcRelay<any>, storage: IStorageManager<StoredDataAccount>, programAddress?: string);
|
|
38
37
|
start(): Promise<void>;
|
|
39
38
|
getClaimableDeposits(signer: string): Promise<{
|
|
40
39
|
count: number;
|
|
@@ -140,8 +139,6 @@ export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> im
|
|
|
140
139
|
}>;
|
|
141
140
|
getIntermediaryReputation(address: string, token: string): Promise<IntermediaryReputationType>;
|
|
142
141
|
getIntermediaryBalance(address: PublicKey, token: PublicKey): Promise<bigint>;
|
|
143
|
-
isValidAddress(address: string): boolean;
|
|
144
|
-
getNativeCurrencyAddress(): string;
|
|
145
142
|
txsClaimWithSecret(signer: string | SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, feeRate?: string, skipAtaCheck?: boolean): Promise<SolanaTx[]>;
|
|
146
143
|
txsClaimWithTxData(signer: string | SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
147
144
|
blockhash: string;
|
|
@@ -165,7 +162,6 @@ export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> im
|
|
|
165
162
|
}, skipChecks?: boolean, feeRate?: string): Promise<SolanaTx[]>;
|
|
166
163
|
txsWithdraw(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
167
164
|
txsDeposit(signer: string, token: string, amount: bigint, feeRate?: string): Promise<SolanaTx[]>;
|
|
168
|
-
txsTransfer(signer: string, token: string, amount: bigint, dstAddress: string, feeRate?: string): Promise<SolanaTx[]>;
|
|
169
165
|
claimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, secret: string, checkExpiry?: boolean, initAta?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
170
166
|
claimWithTxData(signer: SolanaSigner, swapData: SolanaSwapData, tx: {
|
|
171
167
|
blockhash: string;
|
|
@@ -180,12 +176,6 @@ export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> im
|
|
|
180
176
|
initAndClaimWithSecret(signer: SolanaSigner, swapData: SolanaSwapData, signature: SignatureData, secret: string, skipChecks?: boolean, txOptions?: TransactionConfirmationOptions): Promise<string[]>;
|
|
181
177
|
withdraw(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
182
178
|
deposit(signer: SolanaSigner, token: string, amount: bigint, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
183
|
-
transfer(signer: SolanaSigner, token: string, amount: bigint, dstAddress: string, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
184
|
-
sendAndConfirm(signer: SolanaSigner, txs: SolanaTx[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
185
|
-
serializeTx(tx: SolanaTx): Promise<string>;
|
|
186
|
-
deserializeTx(txData: string): Promise<SolanaTx>;
|
|
187
|
-
getTxIdStatus(txId: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
188
|
-
getTxStatus(tx: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
189
179
|
getInitPayInFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
190
180
|
getInitFeeRate(offerer?: string, claimer?: string, token?: string, claimHash?: string): Promise<string>;
|
|
191
181
|
getRefundFeeRate(swapData: SolanaSwapData): Promise<string>;
|
|
@@ -208,14 +198,5 @@ export declare class SolanaSwapProgram extends SolanaProgramBase<SwapProgram> im
|
|
|
208
198
|
* Get the estimated solana transaction fee of the refund transaction
|
|
209
199
|
*/
|
|
210
200
|
getRawRefundFee(swapData: SolanaSwapData, feeRate?: string): Promise<bigint>;
|
|
211
|
-
offBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): boolean;
|
|
212
|
-
onBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): void;
|
|
213
|
-
onBeforeTxSigned(callback: (tx: SolanaTx) => Promise<void>): void;
|
|
214
|
-
offBeforeTxSigned(callback: (tx: SolanaTx) => Promise<void>): boolean;
|
|
215
|
-
onSendTransaction(callback: (tx: Buffer, options?: SendOptions) => Promise<string>): void;
|
|
216
|
-
offSendTransaction(callback: (tx: Buffer, options?: SendOptions) => Promise<string>): boolean;
|
|
217
|
-
isValidToken(tokenIdentifier: string): boolean;
|
|
218
|
-
randomAddress(): string;
|
|
219
|
-
randomSigner(): SolanaSigner;
|
|
220
201
|
getExtraData(outputScript: Buffer, amount: bigint, confirmations: number, nonce?: bigint): Buffer;
|
|
221
202
|
}
|
|
@@ -7,7 +7,6 @@ const sha2_1 = require("@noble/hashes/sha2");
|
|
|
7
7
|
const programIdl = require("./programIdl.json");
|
|
8
8
|
const base_1 = require("@atomiqlabs/base");
|
|
9
9
|
const spl_token_1 = require("@solana/spl-token");
|
|
10
|
-
const SolanaFees_1 = require("../base/modules/SolanaFees");
|
|
11
10
|
const SolanaProgramBase_1 = require("../program/SolanaProgramBase");
|
|
12
11
|
const SwapInit_1 = require("./modules/SwapInit");
|
|
13
12
|
const SolanaDataAccount_1 = require("./modules/SolanaDataAccount");
|
|
@@ -15,17 +14,15 @@ const SwapRefund_1 = require("./modules/SwapRefund");
|
|
|
15
14
|
const SwapClaim_1 = require("./modules/SwapClaim");
|
|
16
15
|
const SolanaLpVault_1 = require("./modules/SolanaLpVault");
|
|
17
16
|
const buffer_1 = require("buffer");
|
|
18
|
-
const SolanaSigner_1 = require("../wallet/SolanaSigner");
|
|
19
|
-
const SolanaKeypairWallet_1 = require("../wallet/SolanaKeypairWallet");
|
|
20
17
|
const Utils_1 = require("../../utils/Utils");
|
|
21
|
-
const SolanaTokens_1 = require("../
|
|
18
|
+
const SolanaTokens_1 = require("../chain/modules/SolanaTokens");
|
|
22
19
|
const BN = require("bn.js");
|
|
23
20
|
function toPublicKeyOrNull(str) {
|
|
24
21
|
return str == null ? null : new web3_js_1.PublicKey(str);
|
|
25
22
|
}
|
|
26
23
|
class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
27
|
-
constructor(
|
|
28
|
-
super(
|
|
24
|
+
constructor(chainInterface, btcRelay, storage, programAddress) {
|
|
25
|
+
super(chainInterface, programIdl, programAddress);
|
|
29
26
|
////////////////////////
|
|
30
27
|
//// Constants
|
|
31
28
|
this.ESCROW_STATE_RENT_EXEMPT = 2658720;
|
|
@@ -44,11 +41,11 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
44
41
|
this.claimGracePeriod = 10 * 60;
|
|
45
42
|
this.refundGracePeriod = 10 * 60;
|
|
46
43
|
this.authGracePeriod = 5 * 60;
|
|
47
|
-
this.Init = new SwapInit_1.SwapInit(this);
|
|
48
|
-
this.Refund = new SwapRefund_1.SwapRefund(this);
|
|
49
|
-
this.Claim = new SwapClaim_1.SwapClaim(this, btcRelay);
|
|
50
|
-
this.DataAccount = new SolanaDataAccount_1.SolanaDataAccount(this, storage);
|
|
51
|
-
this.LpVault = new SolanaLpVault_1.SolanaLpVault(this);
|
|
44
|
+
this.Init = new SwapInit_1.SwapInit(chainInterface, this);
|
|
45
|
+
this.Refund = new SwapRefund_1.SwapRefund(chainInterface, this);
|
|
46
|
+
this.Claim = new SwapClaim_1.SwapClaim(chainInterface, this, btcRelay);
|
|
47
|
+
this.DataAccount = new SolanaDataAccount_1.SolanaDataAccount(chainInterface, this, storage);
|
|
48
|
+
this.LpVault = new SolanaLpVault_1.SolanaLpVault(chainInterface, this);
|
|
52
49
|
}
|
|
53
50
|
async start() {
|
|
54
51
|
await this.DataAccount.init();
|
|
@@ -86,10 +83,10 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
86
83
|
return this.Refund.isSignatureValid(swapData, timeout, prefix, signature);
|
|
87
84
|
}
|
|
88
85
|
getDataSignature(signer, data) {
|
|
89
|
-
return this.Signatures.getDataSignature(signer, data);
|
|
86
|
+
return this.Chain.Signatures.getDataSignature(signer, data);
|
|
90
87
|
}
|
|
91
88
|
isValidDataSignature(data, signature, publicKey) {
|
|
92
|
-
return this.Signatures.isValidDataSignature(data, signature, publicKey);
|
|
89
|
+
return this.Chain.Signatures.isValidDataSignature(data, signature, publicKey);
|
|
93
90
|
}
|
|
94
91
|
////////////////////////////////////////////
|
|
95
92
|
//// Swap data utils
|
|
@@ -280,19 +277,12 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
280
277
|
////////////////////////////////////////////
|
|
281
278
|
//// Utils
|
|
282
279
|
async getBalance(signer, tokenAddress, inContract) {
|
|
280
|
+
if (!inContract) {
|
|
281
|
+
return await this.Chain.getBalance(signer, tokenAddress);
|
|
282
|
+
}
|
|
283
283
|
const token = new web3_js_1.PublicKey(tokenAddress);
|
|
284
284
|
const publicKey = new web3_js_1.PublicKey(signer);
|
|
285
|
-
|
|
286
|
-
return await this.getIntermediaryBalance(publicKey, token);
|
|
287
|
-
let { balance } = await this.Tokens.getTokenBalance(publicKey, token);
|
|
288
|
-
if (token.equals(SolanaTokens_1.SolanaTokens.WSOL_ADDRESS)) {
|
|
289
|
-
const accountRentExemptCost = 1000000n;
|
|
290
|
-
balance = balance - accountRentExemptCost;
|
|
291
|
-
if (balance < 0n)
|
|
292
|
-
balance = 0n;
|
|
293
|
-
}
|
|
294
|
-
this.logger.debug("getBalance(): token balance, token: " + token.toBase58() + " balance: " + balance.toString(10));
|
|
295
|
-
return balance;
|
|
285
|
+
return await this.getIntermediaryBalance(publicKey, token);
|
|
296
286
|
}
|
|
297
287
|
getIntermediaryData(address, token) {
|
|
298
288
|
return this.LpVault.getIntermediaryData(new web3_js_1.PublicKey(address), new web3_js_1.PublicKey(token));
|
|
@@ -303,12 +293,6 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
303
293
|
getIntermediaryBalance(address, token) {
|
|
304
294
|
return this.LpVault.getIntermediaryBalance(address, token);
|
|
305
295
|
}
|
|
306
|
-
isValidAddress(address) {
|
|
307
|
-
return this.Addresses.isValidAddress(address);
|
|
308
|
-
}
|
|
309
|
-
getNativeCurrencyAddress() {
|
|
310
|
-
return this.Tokens.getNativeCurrencyAddress().toString();
|
|
311
|
-
}
|
|
312
296
|
////////////////////////////////////////////
|
|
313
297
|
//// Transaction initializers
|
|
314
298
|
async txsClaimWithSecret(signer, swapData, secret, checkExpiry, initAta, feeRate, skipAtaCheck) {
|
|
@@ -343,14 +327,11 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
343
327
|
txsDeposit(signer, token, amount, feeRate) {
|
|
344
328
|
return this.LpVault.txsDeposit(new web3_js_1.PublicKey(signer), new web3_js_1.PublicKey(token), amount, feeRate);
|
|
345
329
|
}
|
|
346
|
-
txsTransfer(signer, token, amount, dstAddress, feeRate) {
|
|
347
|
-
return this.Tokens.txsTransfer(new web3_js_1.PublicKey(signer), new web3_js_1.PublicKey(token), amount, new web3_js_1.PublicKey(dstAddress), feeRate);
|
|
348
|
-
}
|
|
349
330
|
////////////////////////////////////////////
|
|
350
331
|
//// Executors
|
|
351
332
|
async claimWithSecret(signer, swapData, secret, checkExpiry, initAta, txOptions) {
|
|
352
333
|
const result = await this.Claim.txsClaimWithSecret(signer.getPublicKey(), swapData, secret, checkExpiry, initAta, txOptions?.feeRate);
|
|
353
|
-
const [signature] = await this.
|
|
334
|
+
const [signature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
354
335
|
return signature;
|
|
355
336
|
}
|
|
356
337
|
async claimWithTxData(signer, swapData, tx, requiredConfirmations, vout, commitedHeader, synchronizer, initAta, txOptions) {
|
|
@@ -363,18 +344,18 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
363
344
|
if (txs === null)
|
|
364
345
|
throw new Error("Btc relay not synchronized to required blockheight!");
|
|
365
346
|
//TODO: This doesn't return proper tx signature
|
|
366
|
-
const [signature] = await this.
|
|
347
|
+
const [signature] = await this.Chain.sendAndConfirm(signer, txs, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
367
348
|
await this.DataAccount.removeDataAccount(data.storageAcc);
|
|
368
349
|
return signature;
|
|
369
350
|
}
|
|
370
351
|
async refund(signer, swapData, check, initAta, txOptions) {
|
|
371
352
|
let result = await this.txsRefund(signer.getAddress(), swapData, check, initAta, txOptions?.feeRate);
|
|
372
|
-
const [signature] = await this.
|
|
353
|
+
const [signature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
373
354
|
return signature;
|
|
374
355
|
}
|
|
375
356
|
async refundWithAuthorization(signer, swapData, signature, check, initAta, txOptions) {
|
|
376
357
|
let result = await this.txsRefundWithAuthorization(signer.getAddress(), swapData, signature, check, initAta, txOptions?.feeRate);
|
|
377
|
-
const [txSignature] = await this.
|
|
358
|
+
const [txSignature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
378
359
|
return txSignature;
|
|
379
360
|
}
|
|
380
361
|
async init(signer, swapData, signature, skipChecks, txOptions) {
|
|
@@ -387,7 +368,7 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
387
368
|
throw new Error("Invalid signer provided!");
|
|
388
369
|
}
|
|
389
370
|
const result = await this.txsInit(swapData, signature, skipChecks, txOptions?.feeRate);
|
|
390
|
-
const [txSignature] = await this.
|
|
371
|
+
const [txSignature] = await this.Chain.sendAndConfirm(signer, result, txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
391
372
|
return txSignature;
|
|
392
373
|
}
|
|
393
374
|
async initAndClaimWithSecret(signer, swapData, signature, secret, skipChecks, txOptions) {
|
|
@@ -395,41 +376,19 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
395
376
|
throw new Error("Invalid signer provided!");
|
|
396
377
|
const txsCommit = await this.txsInit(swapData, signature, skipChecks, txOptions?.feeRate);
|
|
397
378
|
const txsClaim = await this.Claim.txsClaimWithSecret(signer.getPublicKey(), swapData, secret, true, false, txOptions?.feeRate, true);
|
|
398
|
-
return await this.
|
|
379
|
+
return await this.Chain.sendAndConfirm(signer, txsCommit.concat(txsClaim), txOptions?.waitForConfirmation, txOptions?.abortSignal);
|
|
399
380
|
}
|
|
400
381
|
async withdraw(signer, token, amount, txOptions) {
|
|
401
382
|
const txs = await this.LpVault.txsWithdraw(signer.getPublicKey(), new web3_js_1.PublicKey(token), amount, txOptions?.feeRate);
|
|
402
|
-
const [txId] = await this.
|
|
383
|
+
const [txId] = await this.Chain.sendAndConfirm(signer, txs, txOptions?.waitForConfirmation, txOptions?.abortSignal, false);
|
|
403
384
|
return txId;
|
|
404
385
|
}
|
|
405
386
|
async deposit(signer, token, amount, txOptions) {
|
|
406
387
|
const txs = await this.LpVault.txsDeposit(signer.getPublicKey(), new web3_js_1.PublicKey(token), amount, txOptions?.feeRate);
|
|
407
|
-
const [txId] = await this.
|
|
408
|
-
return txId;
|
|
409
|
-
}
|
|
410
|
-
async transfer(signer, token, amount, dstAddress, txOptions) {
|
|
411
|
-
const txs = await this.Tokens.txsTransfer(signer.getPublicKey(), new web3_js_1.PublicKey(token), amount, new web3_js_1.PublicKey(dstAddress), txOptions?.feeRate);
|
|
412
|
-
const [txId] = await this.Transactions.sendAndConfirm(signer, txs, txOptions?.waitForConfirmation, txOptions?.abortSignal, false);
|
|
388
|
+
const [txId] = await this.Chain.sendAndConfirm(signer, txs, txOptions?.waitForConfirmation, txOptions?.abortSignal, false);
|
|
413
389
|
return txId;
|
|
414
390
|
}
|
|
415
391
|
////////////////////////////////////////////
|
|
416
|
-
//// Transactions
|
|
417
|
-
sendAndConfirm(signer, txs, waitForConfirmation, abortSignal, parallel, onBeforePublish) {
|
|
418
|
-
return this.Transactions.sendAndConfirm(signer, txs, waitForConfirmation, abortSignal, parallel, onBeforePublish);
|
|
419
|
-
}
|
|
420
|
-
serializeTx(tx) {
|
|
421
|
-
return this.Transactions.serializeTx(tx);
|
|
422
|
-
}
|
|
423
|
-
deserializeTx(txData) {
|
|
424
|
-
return this.Transactions.deserializeTx(txData);
|
|
425
|
-
}
|
|
426
|
-
getTxIdStatus(txId) {
|
|
427
|
-
return this.Transactions.getTxIdStatus(txId);
|
|
428
|
-
}
|
|
429
|
-
getTxStatus(tx) {
|
|
430
|
-
return this.Transactions.getTxStatus(tx);
|
|
431
|
-
}
|
|
432
|
-
////////////////////////////////////////////
|
|
433
392
|
//// Fees
|
|
434
393
|
getInitPayInFeeRate(offerer, claimer, token, claimHash) {
|
|
435
394
|
const paymentHash = claimHash == null ? null : (0, Utils_1.fromClaimHash)(claimHash).paymentHash;
|
|
@@ -475,41 +434,6 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
|
|
|
475
434
|
getRawRefundFee(swapData, feeRate) {
|
|
476
435
|
return this.Refund.getRawRefundFee(swapData, feeRate);
|
|
477
436
|
}
|
|
478
|
-
///////////////////////////////////
|
|
479
|
-
//// Callbacks & handlers
|
|
480
|
-
offBeforeTxReplace(callback) {
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
onBeforeTxReplace(callback) { }
|
|
484
|
-
onBeforeTxSigned(callback) {
|
|
485
|
-
this.Transactions.onBeforeTxSigned(callback);
|
|
486
|
-
}
|
|
487
|
-
offBeforeTxSigned(callback) {
|
|
488
|
-
return this.Transactions.offBeforeTxSigned(callback);
|
|
489
|
-
}
|
|
490
|
-
onSendTransaction(callback) {
|
|
491
|
-
this.Transactions.onSendTransaction(callback);
|
|
492
|
-
}
|
|
493
|
-
offSendTransaction(callback) {
|
|
494
|
-
return this.Transactions.offSendTransaction(callback);
|
|
495
|
-
}
|
|
496
|
-
isValidToken(tokenIdentifier) {
|
|
497
|
-
try {
|
|
498
|
-
new web3_js_1.PublicKey(tokenIdentifier);
|
|
499
|
-
return true;
|
|
500
|
-
}
|
|
501
|
-
catch (e) {
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
randomAddress() {
|
|
506
|
-
return web3_js_1.Keypair.generate().publicKey.toString();
|
|
507
|
-
}
|
|
508
|
-
randomSigner() {
|
|
509
|
-
const keypair = web3_js_1.Keypair.generate();
|
|
510
|
-
const wallet = new SolanaKeypairWallet_1.SolanaKeypairWallet(keypair);
|
|
511
|
-
return new SolanaSigner_1.SolanaSigner(wallet, keypair);
|
|
512
|
-
}
|
|
513
437
|
getExtraData(outputScript, amount, confirmations, nonce) {
|
|
514
438
|
return buffer_1.Buffer.from((0, sha2_1.sha256)(buffer_1.Buffer.concat([
|
|
515
439
|
base_1.BigIntBufferUtils.toBuffer(amount, "le", 8),
|
|
@@ -3,8 +3,9 @@ import { SolanaSwapModule } from "../SolanaSwapModule";
|
|
|
3
3
|
import { PublicKey, Signer } from "@solana/web3.js";
|
|
4
4
|
import { IStorageManager, StorageObject } from "@atomiqlabs/base";
|
|
5
5
|
import { SolanaSwapProgram } from "../SolanaSwapProgram";
|
|
6
|
-
import { SolanaTx } from "../../
|
|
6
|
+
import { SolanaTx } from "../../chain/modules/SolanaTransactions";
|
|
7
7
|
import { SolanaSigner } from "../../wallet/SolanaSigner";
|
|
8
|
+
import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
|
|
8
9
|
export declare class StoredDataAccount implements StorageObject {
|
|
9
10
|
accountKey: PublicKey;
|
|
10
11
|
owner: PublicKey;
|
|
@@ -46,7 +47,7 @@ export declare class SolanaDataAccount extends SolanaSwapModule {
|
|
|
46
47
|
* @returns {Promise<{bytesWritten: number, action: SolanaAction}>} bytes written to the data account & action
|
|
47
48
|
*/
|
|
48
49
|
private WriteData;
|
|
49
|
-
constructor(
|
|
50
|
+
constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, storage: IStorageManager<StoredDataAccount>);
|
|
50
51
|
/**
|
|
51
52
|
* Saves data account to the storage, the storage is required such that we are able to close the accounts later
|
|
52
53
|
* manually in case the claim doesn't happen (expires due to fees, etc.)
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SolanaDataAccount = exports.StoredDataAccount = void 0;
|
|
4
4
|
const SolanaSwapModule_1 = require("../SolanaSwapModule");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
const SolanaAction_1 = require("../../
|
|
6
|
+
const SolanaAction_1 = require("../../chain/SolanaAction");
|
|
7
7
|
const Utils_1 = require("../../../utils/Utils");
|
|
8
8
|
const SolanaSigner_1 = require("../../wallet/SolanaSigner");
|
|
9
9
|
const utils_1 = require("@noble/hashes/utils");
|
|
@@ -44,9 +44,9 @@ class SolanaDataAccount extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
44
44
|
newAccountPubkey: accountKey.publicKey,
|
|
45
45
|
lamports: lamportsDeposit,
|
|
46
46
|
space: accountSize,
|
|
47
|
-
programId: this.
|
|
47
|
+
programId: this.swapProgram.programId
|
|
48
48
|
}),
|
|
49
|
-
await this.
|
|
49
|
+
await this.swapProgram.methods
|
|
50
50
|
.initData()
|
|
51
51
|
.accounts({
|
|
52
52
|
signer,
|
|
@@ -62,7 +62,7 @@ class SolanaDataAccount extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
62
62
|
* @param publicKey
|
|
63
63
|
*/
|
|
64
64
|
async CloseDataAccount(signer, publicKey) {
|
|
65
|
-
return new SolanaAction_1.SolanaAction(signer, this.root, await this.
|
|
65
|
+
return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
|
|
66
66
|
.closeData()
|
|
67
67
|
.accounts({
|
|
68
68
|
signer,
|
|
@@ -86,7 +86,7 @@ class SolanaDataAccount extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
86
86
|
const writeLen = Math.min(writeData.length - offset, sizeLimit);
|
|
87
87
|
return {
|
|
88
88
|
bytesWritten: writeLen,
|
|
89
|
-
action: new SolanaAction_1.SolanaAction(signer, this.root, await this.
|
|
89
|
+
action: new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
|
|
90
90
|
.writeData(offset, writeData.slice(offset, offset + writeLen))
|
|
91
91
|
.accounts({
|
|
92
92
|
signer,
|
|
@@ -95,10 +95,10 @@ class SolanaDataAccount extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
95
95
|
.instruction(), SolanaDataAccount.CUCosts.DATA_WRITE)
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
constructor(
|
|
99
|
-
super(
|
|
100
|
-
this.SwapTxDataAlt = this.
|
|
101
|
-
this.SwapTxDataAltBuffer = this.
|
|
98
|
+
constructor(chainInterface, program, storage) {
|
|
99
|
+
super(chainInterface, program);
|
|
100
|
+
this.SwapTxDataAlt = this.program.keypair((reversedTxId, signer) => [Buffer.from(signer.secretKey), reversedTxId]);
|
|
101
|
+
this.SwapTxDataAltBuffer = this.program.keypair((reversedTxId, secret) => [secret, reversedTxId]);
|
|
102
102
|
this.storage = storage;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SolanaSwapModule } from "../SolanaSwapModule";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
|
-
import { SolanaTx } from "../../
|
|
3
|
+
import { SolanaTx } from "../../chain/modules/SolanaTransactions";
|
|
4
4
|
import { IntermediaryReputationType } from "@atomiqlabs/base";
|
|
5
5
|
export declare class SolanaLpVault extends SolanaSwapModule {
|
|
6
6
|
private static readonly CUCosts;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SolanaLpVault = void 0;
|
|
4
4
|
const SolanaSwapModule_1 = require("../SolanaSwapModule");
|
|
5
|
-
const SolanaAction_1 = require("../../
|
|
5
|
+
const SolanaAction_1 = require("../../chain/SolanaAction");
|
|
6
6
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
7
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
8
|
const Utils_1 = require("../../../utils/Utils");
|
|
9
|
-
const SolanaTokens_1 = require("../../
|
|
9
|
+
const SolanaTokens_1 = require("../../chain/modules/SolanaTokens");
|
|
10
10
|
class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
|
|
11
11
|
/**
|
|
12
12
|
* Action for withdrawing funds from the LP vault
|
|
@@ -19,14 +19,14 @@ class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
19
19
|
*/
|
|
20
20
|
async Withdraw(signer, token, amount) {
|
|
21
21
|
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
|
|
22
|
-
return new SolanaAction_1.SolanaAction(signer, this.root, await this.
|
|
22
|
+
return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
|
|
23
23
|
.withdraw((0, Utils_1.toBN)(amount))
|
|
24
24
|
.accounts({
|
|
25
25
|
signer,
|
|
26
26
|
signerAta: ata,
|
|
27
|
-
userData: this.
|
|
28
|
-
vault: this.
|
|
29
|
-
vaultAuthority: this.
|
|
27
|
+
userData: this.program.SwapUserVault(signer, token),
|
|
28
|
+
vault: this.program.SwapVault(token),
|
|
29
|
+
vaultAuthority: this.program.SwapVaultAuthority,
|
|
30
30
|
mint: token,
|
|
31
31
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
|
|
32
32
|
})
|
|
@@ -43,14 +43,14 @@ class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
43
43
|
*/
|
|
44
44
|
async Deposit(signer, token, amount) {
|
|
45
45
|
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(token, signer);
|
|
46
|
-
return new SolanaAction_1.SolanaAction(signer, this.root, await this.
|
|
46
|
+
return new SolanaAction_1.SolanaAction(signer, this.root, await this.swapProgram.methods
|
|
47
47
|
.deposit((0, Utils_1.toBN)(amount))
|
|
48
48
|
.accounts({
|
|
49
49
|
signer,
|
|
50
50
|
signerAta: ata,
|
|
51
|
-
userData: this.
|
|
52
|
-
vault: this.
|
|
53
|
-
vaultAuthority: this.
|
|
51
|
+
userData: this.program.SwapUserVault(signer, token),
|
|
52
|
+
vault: this.program.SwapVault(token),
|
|
53
|
+
vaultAuthority: this.program.SwapVaultAuthority,
|
|
54
54
|
mint: token,
|
|
55
55
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
56
56
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
|
|
@@ -64,7 +64,7 @@ class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
64
64
|
* @param token
|
|
65
65
|
*/
|
|
66
66
|
async getIntermediaryData(address, token) {
|
|
67
|
-
const data = await this.
|
|
67
|
+
const data = await this.swapProgram.account.userAccount.fetchNullable(this.program.SwapUserVault(address, token));
|
|
68
68
|
if (data == null)
|
|
69
69
|
return null;
|
|
70
70
|
const response = [];
|
|
@@ -161,8 +161,8 @@ class SolanaLpVault extends SolanaSwapModule_1.SolanaSwapModule {
|
|
|
161
161
|
return this.root.Fees.getFeeRate([
|
|
162
162
|
signer,
|
|
163
163
|
ata,
|
|
164
|
-
this.
|
|
165
|
-
this.
|
|
164
|
+
this.program.SwapUserVault(signer, token),
|
|
165
|
+
this.program.SwapVault(token)
|
|
166
166
|
]);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -2,11 +2,12 @@ import { SolanaSwapModule } from "../SolanaSwapModule";
|
|
|
2
2
|
import { SolanaSwapData } from "../SolanaSwapData";
|
|
3
3
|
import { RelaySynchronizer } from "@atomiqlabs/base";
|
|
4
4
|
import { PublicKey } from "@solana/web3.js";
|
|
5
|
-
import { SolanaTx } from "../../
|
|
5
|
+
import { SolanaTx } from "../../chain/modules/SolanaTransactions";
|
|
6
6
|
import { SolanaBtcStoredHeader } from "../../btcrelay/headers/SolanaBtcStoredHeader";
|
|
7
7
|
import { SolanaBtcRelay } from "../../btcrelay/SolanaBtcRelay";
|
|
8
8
|
import { SolanaSwapProgram } from "../SolanaSwapProgram";
|
|
9
9
|
import { SolanaSigner } from "../../wallet/SolanaSigner";
|
|
10
|
+
import { SolanaChainInterface } from "../../chain/SolanaChainInterface";
|
|
10
11
|
export declare class SwapClaim extends SolanaSwapModule {
|
|
11
12
|
private static readonly CUCosts;
|
|
12
13
|
readonly btcRelay: SolanaBtcRelay<any>;
|
|
@@ -34,7 +35,7 @@ export declare class SwapClaim extends SolanaSwapModule {
|
|
|
34
35
|
* @private
|
|
35
36
|
*/
|
|
36
37
|
private VerifyAndClaim;
|
|
37
|
-
constructor(
|
|
38
|
+
constructor(chainInterface: SolanaChainInterface, program: SolanaSwapProgram, btcRelay: SolanaBtcRelay<any>);
|
|
38
39
|
/**
|
|
39
40
|
* Gets the compute budget required for claiming the swap
|
|
40
41
|
*
|