@interest-protocol/vortex-sdk 6.3.0 → 7.0.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/deposit-with-account.d.ts +1 -1
- package/dist/deposit-with-account.d.ts.map +1 -1
- package/dist/deposit.d.ts +1 -1
- package/dist/deposit.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +176 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -36
- package/dist/index.mjs.map +1 -1
- package/dist/swap.d.ts +2 -2
- package/dist/swap.d.ts.map +1 -1
- package/dist/utils/decrypt.d.ts +8 -0
- package/dist/utils/decrypt.d.ts.map +1 -1
- package/dist/utils/deposit.d.ts +1 -2
- package/dist/utils/deposit.d.ts.map +1 -1
- package/dist/utils/withdraw.d.ts +1 -2
- package/dist/utils/withdraw.d.ts.map +1 -1
- package/dist/vortex-api.d.ts +15 -0
- package/dist/vortex-api.d.ts.map +1 -0
- package/dist/vortex-api.types.d.ts +114 -0
- package/dist/vortex-api.types.d.ts.map +1 -0
- package/dist/vortex.d.ts +1 -0
- package/dist/vortex.d.ts.map +1 -1
- package/dist/vortex.types.d.ts +4 -7
- package/dist/vortex.types.d.ts.map +1 -1
- package/dist/withdraw-with-account.d.ts +1 -1
- package/dist/withdraw-with-account.d.ts.map +1 -1
- package/dist/withdraw.d.ts +1 -1
- package/dist/withdraw.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/deposit-with-account.ts +0 -2
- package/src/deposit.ts +0 -2
- package/src/index.ts +2 -0
- package/src/swap.ts +0 -4
- package/src/utils/decrypt.ts +57 -1
- package/src/utils/deposit.ts +5 -6
- package/src/utils/withdraw.ts +4 -4
- package/src/vortex-api.ts +189 -0
- package/src/vortex-api.types.ts +137 -0
- package/src/vortex.ts +9 -9
- package/src/vortex.types.ts +3 -7
- package/src/withdraw-with-account.ts +0 -2
- package/src/withdraw.ts +10 -6
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import invariant from 'tiny-invariant';
|
|
2
|
+
import {
|
|
3
|
+
VortexAPIConstructorArgs,
|
|
4
|
+
VORTEX_API_URL,
|
|
5
|
+
HealthResponse,
|
|
6
|
+
AccountsResponse,
|
|
7
|
+
CreateAccountRequest,
|
|
8
|
+
AccountResponse,
|
|
9
|
+
PoolsResponse,
|
|
10
|
+
GetPoolsArgs,
|
|
11
|
+
CommitmentsResponse,
|
|
12
|
+
GetCommitmentsArgs,
|
|
13
|
+
MerklePathRequest,
|
|
14
|
+
MerklePathResponse,
|
|
15
|
+
ExecuteTransactionRequest,
|
|
16
|
+
TransactionResponse,
|
|
17
|
+
RelayerResponse,
|
|
18
|
+
ApiResponse,
|
|
19
|
+
ErrorResponse,
|
|
20
|
+
} from './vortex-api.types';
|
|
21
|
+
|
|
22
|
+
export class VortexAPI {
|
|
23
|
+
#apiUrl: string;
|
|
24
|
+
|
|
25
|
+
constructor({ apiUrl = VORTEX_API_URL }: VortexAPIConstructorArgs = {}) {
|
|
26
|
+
this.#apiUrl = apiUrl.replace(/\/$/, '');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async health(): Promise<HealthResponse> {
|
|
30
|
+
const response = await this.#get<HealthResponse>('/api/health');
|
|
31
|
+
|
|
32
|
+
this.#assertSuccess(response);
|
|
33
|
+
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getAccounts(hashedSecret: string): Promise<AccountsResponse> {
|
|
38
|
+
const params = new URLSearchParams({ hashed_secret: hashedSecret });
|
|
39
|
+
|
|
40
|
+
const response = await this.#get<AccountsResponse>(
|
|
41
|
+
`/api/v1/accounts?${params.toString()}`
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
this.#assertSuccess(response);
|
|
45
|
+
|
|
46
|
+
return response;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async createAccount(args: CreateAccountRequest): Promise<AccountResponse> {
|
|
50
|
+
const response = await this.#post<AccountResponse>('/api/v1/accounts', {
|
|
51
|
+
owner: args.owner,
|
|
52
|
+
hashedSecret: args.hashedSecret,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
this.#assertSuccess(response);
|
|
56
|
+
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async getPools(args: GetPoolsArgs = {}): Promise<PoolsResponse> {
|
|
61
|
+
const params = new URLSearchParams();
|
|
62
|
+
|
|
63
|
+
if (args.page !== undefined) {
|
|
64
|
+
params.set('page', args.page.toString());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (args.limit !== undefined) {
|
|
68
|
+
params.set('limit', args.limit.toString());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (args.coinType !== undefined) {
|
|
72
|
+
params.set('coin_type', args.coinType);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const query = params.toString();
|
|
76
|
+
const path = query ? `/api/v1/pools?${query}` : '/api/v1/pools';
|
|
77
|
+
|
|
78
|
+
const response = await this.#get<PoolsResponse>(path);
|
|
79
|
+
|
|
80
|
+
this.#assertSuccess(response);
|
|
81
|
+
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async getCommitments(args: GetCommitmentsArgs): Promise<CommitmentsResponse> {
|
|
86
|
+
const params = new URLSearchParams({
|
|
87
|
+
coin_type: args.coinType,
|
|
88
|
+
index: args.index.toString(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (args.op !== undefined) {
|
|
92
|
+
params.set('op', args.op);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (args.page !== undefined) {
|
|
96
|
+
params.set('page', args.page.toString());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (args.limit !== undefined) {
|
|
100
|
+
params.set('limit', args.limit.toString());
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const response = await this.#get<CommitmentsResponse>(
|
|
104
|
+
`/api/v1/commitments?${params.toString()}`
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
this.#assertSuccess(response);
|
|
108
|
+
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async getMerklePath(args: MerklePathRequest): Promise<MerklePathResponse> {
|
|
113
|
+
const response = await this.#post<MerklePathResponse>(
|
|
114
|
+
'/api/v1/merkle/path',
|
|
115
|
+
{
|
|
116
|
+
coin_type: args.coinType,
|
|
117
|
+
index: args.index,
|
|
118
|
+
amount: args.amount,
|
|
119
|
+
public_key: args.publicKey,
|
|
120
|
+
blinding: args.blinding,
|
|
121
|
+
vortex_pool: args.vortexPool,
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
this.#assertSuccess(response);
|
|
126
|
+
|
|
127
|
+
return response;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async executeTransaction(
|
|
131
|
+
args: ExecuteTransactionRequest
|
|
132
|
+
): Promise<TransactionResponse> {
|
|
133
|
+
const response = await this.#post<TransactionResponse>(
|
|
134
|
+
'/api/v1/transactions',
|
|
135
|
+
{
|
|
136
|
+
txBytes: args.txBytes,
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
this.#assertSuccess(response);
|
|
141
|
+
|
|
142
|
+
return response;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async getRelayer(): Promise<RelayerResponse> {
|
|
146
|
+
const response = await this.#get<RelayerResponse>('/api/v1/relayer');
|
|
147
|
+
|
|
148
|
+
this.#assertSuccess(response);
|
|
149
|
+
|
|
150
|
+
return response;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async #get<T>(path: string): Promise<ApiResponse<T>> {
|
|
154
|
+
const response = await fetch(`${this.#apiUrl}${path}`, {
|
|
155
|
+
method: 'GET',
|
|
156
|
+
headers: {
|
|
157
|
+
'Content-Type': 'application/json',
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return response.json() as Promise<ApiResponse<T>>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async #post<T>(
|
|
165
|
+
path: string,
|
|
166
|
+
body: Record<string, unknown>
|
|
167
|
+
): Promise<ApiResponse<T>> {
|
|
168
|
+
const response = await fetch(`${this.#apiUrl}${path}`, {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
headers: {
|
|
171
|
+
'Content-Type': 'application/json',
|
|
172
|
+
},
|
|
173
|
+
body: JSON.stringify(body),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return response.json() as Promise<ApiResponse<T>>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#assertSuccess<T extends { success: true }>(
|
|
180
|
+
response: ApiResponse<T>
|
|
181
|
+
): asserts response is T {
|
|
182
|
+
invariant(
|
|
183
|
+
(response as T).success === true,
|
|
184
|
+
`VortexAPI request failed: ${(response as ErrorResponse).error}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const vortexAPI = new VortexAPI();
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { MerklePath } from './utils';
|
|
2
|
+
|
|
3
|
+
export const VORTEX_API_URL = 'https://api.vortexfi.xyz';
|
|
4
|
+
|
|
5
|
+
export interface VortexAPIConstructorArgs {
|
|
6
|
+
apiUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface HealthStatus {
|
|
10
|
+
mongodb: boolean;
|
|
11
|
+
redis: boolean;
|
|
12
|
+
sui: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface HealthResponse {
|
|
16
|
+
success: true;
|
|
17
|
+
data: HealthStatus;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Account {
|
|
21
|
+
owner: string;
|
|
22
|
+
hashedSecret: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AccountsResponse {
|
|
26
|
+
success: true;
|
|
27
|
+
data: Account[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CreateAccountRequest {
|
|
31
|
+
owner: string;
|
|
32
|
+
hashedSecret: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AccountResponse {
|
|
36
|
+
success: true;
|
|
37
|
+
data: Account;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Pool {
|
|
41
|
+
objectId: string;
|
|
42
|
+
coinType: string;
|
|
43
|
+
balance: string;
|
|
44
|
+
nextIndex: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Pagination {
|
|
48
|
+
page: number;
|
|
49
|
+
limit: number;
|
|
50
|
+
total: number;
|
|
51
|
+
totalPages: number;
|
|
52
|
+
hasNext: boolean;
|
|
53
|
+
hasPrev: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PoolsResponse {
|
|
57
|
+
success: true;
|
|
58
|
+
data: {
|
|
59
|
+
items: Pool[];
|
|
60
|
+
pagination: Pagination;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface GetPoolsArgs {
|
|
65
|
+
page?: number;
|
|
66
|
+
limit?: number;
|
|
67
|
+
coinType?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface Commitment {
|
|
71
|
+
commitment: string;
|
|
72
|
+
index: number;
|
|
73
|
+
coinType: string;
|
|
74
|
+
encryptedOutput: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface CommitmentsResponse {
|
|
78
|
+
success: true;
|
|
79
|
+
data: {
|
|
80
|
+
items: Commitment[];
|
|
81
|
+
pagination: Pagination;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type CommitmentsOperator = 'gt' | 'gte' | 'lt' | 'lte';
|
|
86
|
+
|
|
87
|
+
export interface GetCommitmentsArgs {
|
|
88
|
+
coinType: string;
|
|
89
|
+
index: number;
|
|
90
|
+
op?: CommitmentsOperator;
|
|
91
|
+
page?: number;
|
|
92
|
+
limit?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface MerklePathRequest {
|
|
96
|
+
coinType: string;
|
|
97
|
+
index: number;
|
|
98
|
+
amount: string;
|
|
99
|
+
publicKey: string;
|
|
100
|
+
blinding: string;
|
|
101
|
+
vortexPool: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface MerklePathResponse {
|
|
105
|
+
success: true;
|
|
106
|
+
data: {
|
|
107
|
+
path: MerklePath;
|
|
108
|
+
root: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ExecuteTransactionRequest {
|
|
113
|
+
txBytes: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface TransactionResponse {
|
|
117
|
+
success: true;
|
|
118
|
+
data: {
|
|
119
|
+
digest: string;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface Relayer {
|
|
124
|
+
address: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface RelayerResponse {
|
|
128
|
+
success: true;
|
|
129
|
+
data: Relayer;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface ErrorResponse {
|
|
133
|
+
success: false;
|
|
134
|
+
error: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type ApiResponse<T> = T | ErrorResponse;
|
package/src/vortex.ts
CHANGED
|
@@ -213,7 +213,7 @@ export class Vortex {
|
|
|
213
213
|
? publicValue
|
|
214
214
|
: BN254_FIELD_MODULUS - publicValue;
|
|
215
215
|
|
|
216
|
-
const vortex = await this
|
|
216
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
217
217
|
|
|
218
218
|
const proof = tx.moveCall({
|
|
219
219
|
target: `${this.packageId}::vortex_proof::new`,
|
|
@@ -240,7 +240,7 @@ export class Vortex {
|
|
|
240
240
|
extData,
|
|
241
241
|
deposit,
|
|
242
242
|
}: TransactArgs) {
|
|
243
|
-
const vortex = await this
|
|
243
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
244
244
|
|
|
245
245
|
const coin = tx.moveCall({
|
|
246
246
|
target: `${this.packageId}::vortex::transact`,
|
|
@@ -259,7 +259,7 @@ export class Vortex {
|
|
|
259
259
|
proof,
|
|
260
260
|
extData,
|
|
261
261
|
}: TransactWithAccountArgs) {
|
|
262
|
-
const vortex = await this
|
|
262
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
263
263
|
|
|
264
264
|
const coin = tx.moveCall({
|
|
265
265
|
target: `${this.packageId}::vortex::transact_with_account`,
|
|
@@ -320,7 +320,7 @@ export class Vortex {
|
|
|
320
320
|
async nextIndex(vortexPool: string | VortexPool) {
|
|
321
321
|
const tx = new Transaction();
|
|
322
322
|
|
|
323
|
-
const vortex = await this
|
|
323
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
324
324
|
|
|
325
325
|
tx.moveCall({
|
|
326
326
|
target: `${this.packageId}::vortex::next_index`,
|
|
@@ -338,7 +338,7 @@ export class Vortex {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
async isNullifierSpent({ nullifier, vortexPool }: IsNullifierSpentArgs) {
|
|
341
|
-
const vortex = await this
|
|
341
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
342
342
|
|
|
343
343
|
const tx = new Transaction();
|
|
344
344
|
|
|
@@ -361,7 +361,7 @@ export class Vortex {
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
async areNullifiersSpent({ nullifiers, vortexPool }: AreNullifiersSpentArgs) {
|
|
364
|
-
const vortex = await this
|
|
364
|
+
const vortex = await this.resolveVortexPool(vortexPool);
|
|
365
365
|
|
|
366
366
|
if (nullifiers.length === 0) return [];
|
|
367
367
|
|
|
@@ -398,7 +398,7 @@ export class Vortex {
|
|
|
398
398
|
minAmountOut,
|
|
399
399
|
coinOutType,
|
|
400
400
|
}: StartSwapArgs) {
|
|
401
|
-
const vortexPool = await this
|
|
401
|
+
const vortexPool = await this.resolveVortexPool(vortex);
|
|
402
402
|
|
|
403
403
|
const [receipt, coinIn] = tx.moveCall({
|
|
404
404
|
target: `${this.swapPackageId}::vortex_swap::start_swap`,
|
|
@@ -424,7 +424,7 @@ export class Vortex {
|
|
|
424
424
|
receipt,
|
|
425
425
|
coinInType,
|
|
426
426
|
}: FinishSwapArgs) {
|
|
427
|
-
const vortexPool = await this
|
|
427
|
+
const vortexPool = await this.resolveVortexPool(vortex);
|
|
428
428
|
|
|
429
429
|
tx.moveCall({
|
|
430
430
|
target: `${this.swapPackageId}::vortex_swap::finish_swap`,
|
|
@@ -490,7 +490,7 @@ export class Vortex {
|
|
|
490
490
|
});
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
async
|
|
493
|
+
async resolveVortexPool(vortex: string | VortexPool): Promise<VortexPool> {
|
|
494
494
|
return typeof vortex === 'string' ? this.getVortexPool(vortex) : vortex;
|
|
495
495
|
}
|
|
496
496
|
}
|
package/src/vortex.types.ts
CHANGED
|
@@ -16,7 +16,9 @@ interface NestedResult {
|
|
|
16
16
|
NestedResult: [number, number];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export type GetMerklePathFn = (
|
|
19
|
+
export type GetMerklePathFn = (
|
|
20
|
+
utxo: Utxo | null
|
|
21
|
+
) => Promise<{ path: MerklePath; root: bigint }>;
|
|
20
22
|
|
|
21
23
|
export interface RegisterArgs extends MaybeTx {
|
|
22
24
|
encryptionKey: string;
|
|
@@ -102,7 +104,6 @@ export interface DepositArgs extends MaybeTx {
|
|
|
102
104
|
vortexSdk: Vortex;
|
|
103
105
|
vortexPool: string | VortexPool;
|
|
104
106
|
vortexKeypair: VortexKeypair;
|
|
105
|
-
root: bigint;
|
|
106
107
|
getMerklePathFn: GetMerklePathFn;
|
|
107
108
|
unspentUtxos?: Utxo[];
|
|
108
109
|
relayer?: string;
|
|
@@ -113,7 +114,6 @@ export interface DepositWithAccountArgs extends MaybeTx {
|
|
|
113
114
|
vortexSdk: Vortex;
|
|
114
115
|
vortexPool: string | VortexPool;
|
|
115
116
|
vortexKeypair: VortexKeypair;
|
|
116
|
-
root: bigint;
|
|
117
117
|
getMerklePathFn: GetMerklePathFn;
|
|
118
118
|
unspentUtxos?: Utxo[];
|
|
119
119
|
account: string;
|
|
@@ -129,7 +129,6 @@ export interface WithdrawArgs extends MaybeTx {
|
|
|
129
129
|
unspentUtxos: Utxo[];
|
|
130
130
|
vortexSdk: Vortex;
|
|
131
131
|
vortexKeypair: VortexKeypair;
|
|
132
|
-
root: bigint;
|
|
133
132
|
getMerklePathFn: GetMerklePathFn;
|
|
134
133
|
relayer: string;
|
|
135
134
|
relayerFee: bigint;
|
|
@@ -139,7 +138,6 @@ export interface WithdrawWithAccountArgs extends MaybeTx {
|
|
|
139
138
|
vortexSdk: Vortex;
|
|
140
139
|
vortexPool: string | VortexPool;
|
|
141
140
|
vortexKeypair: VortexKeypair;
|
|
142
|
-
root: bigint;
|
|
143
141
|
getMerklePathFn: GetMerklePathFn;
|
|
144
142
|
unspentUtxos?: Utxo[];
|
|
145
143
|
account: string;
|
|
@@ -206,7 +204,6 @@ export interface StartSwapHelperArgs extends MaybeTx {
|
|
|
206
204
|
unspentUtxos: Utxo[];
|
|
207
205
|
vortexSdk: Vortex;
|
|
208
206
|
vortexKeypair: VortexKeypair;
|
|
209
|
-
root: bigint;
|
|
210
207
|
getMerklePathFn: GetMerklePathFn;
|
|
211
208
|
relayer: string;
|
|
212
209
|
minAmountOut: bigint;
|
|
@@ -218,7 +215,6 @@ export interface FinishSwapHelperArgs extends MaybeTx {
|
|
|
218
215
|
vortexSdk: Vortex;
|
|
219
216
|
vortexPool: string | VortexPool;
|
|
220
217
|
vortexKeypair: VortexKeypair;
|
|
221
|
-
root: bigint;
|
|
222
218
|
getMerklePathFn: GetMerklePathFn;
|
|
223
219
|
unspentUtxos?: Utxo[];
|
|
224
220
|
coinOut: TransactionResult;
|
|
@@ -7,7 +7,6 @@ export const withdrawWithAccount = async ({
|
|
|
7
7
|
unspentUtxos = [],
|
|
8
8
|
vortexPool,
|
|
9
9
|
vortexKeypair,
|
|
10
|
-
root,
|
|
11
10
|
getMerklePathFn,
|
|
12
11
|
relayer,
|
|
13
12
|
relayerFee,
|
|
@@ -27,7 +26,6 @@ export const withdrawWithAccount = async ({
|
|
|
27
26
|
unspentUtxos,
|
|
28
27
|
vortexPool,
|
|
29
28
|
vortexKeypair,
|
|
30
|
-
root,
|
|
31
29
|
getMerklePathFn,
|
|
32
30
|
relayer,
|
|
33
31
|
relayerFee,
|
package/src/withdraw.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { WithdrawArgs } from './vortex.types';
|
|
3
3
|
import { prepareWithdraw } from './utils/withdraw';
|
|
4
|
+
import { SUI_FRAMEWORK_ADDRESS } from '@mysten/sui/utils';
|
|
4
5
|
|
|
5
6
|
export const withdraw = async ({
|
|
6
7
|
tx = new Transaction(),
|
|
@@ -8,14 +9,13 @@ export const withdraw = async ({
|
|
|
8
9
|
unspentUtxos = [],
|
|
9
10
|
vortexPool,
|
|
10
11
|
vortexKeypair,
|
|
11
|
-
root,
|
|
12
12
|
getMerklePathFn,
|
|
13
13
|
relayer,
|
|
14
14
|
relayerFee,
|
|
15
15
|
vortexSdk,
|
|
16
16
|
}: WithdrawArgs) => {
|
|
17
17
|
const {
|
|
18
|
-
tx:
|
|
18
|
+
tx: tx2,
|
|
19
19
|
moveProof,
|
|
20
20
|
extData,
|
|
21
21
|
vortexPool: pool,
|
|
@@ -25,7 +25,6 @@ export const withdraw = async ({
|
|
|
25
25
|
unspentUtxos,
|
|
26
26
|
vortexPool,
|
|
27
27
|
vortexKeypair,
|
|
28
|
-
root,
|
|
29
28
|
getMerklePathFn,
|
|
30
29
|
relayer,
|
|
31
30
|
relayerFee,
|
|
@@ -33,13 +32,18 @@ export const withdraw = async ({
|
|
|
33
32
|
accountSecret: 0n,
|
|
34
33
|
});
|
|
35
34
|
|
|
36
|
-
const
|
|
35
|
+
const vortexPoolObject = await vortexSdk.resolveVortexPool(pool);
|
|
36
|
+
|
|
37
|
+
const zeroCoin = tx2.moveCall({
|
|
38
|
+
target: `${SUI_FRAMEWORK_ADDRESS}::coin::zero`,
|
|
39
|
+
typeArguments: [vortexPoolObject.coinType],
|
|
40
|
+
});
|
|
37
41
|
|
|
38
42
|
return vortexSdk.transact({
|
|
39
43
|
vortexPool: pool,
|
|
40
|
-
tx:
|
|
44
|
+
tx: tx2,
|
|
41
45
|
proof: moveProof,
|
|
42
46
|
extData: extData,
|
|
43
|
-
deposit:
|
|
47
|
+
deposit: zeroCoin,
|
|
44
48
|
});
|
|
45
49
|
};
|