@ember-finance/sdk 0.0.1
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/LICENSE +201 -0
- package/README.md +102 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/src/common/types.d.ts +1 -0
- package/dist/src/common/types.js +2 -0
- package/dist/src/vaults/bluefin-vaults.d.ts +15 -0
- package/dist/src/vaults/bluefin-vaults.js +19 -0
- package/dist/src/vaults/interfaces/bcs.d.ts +29 -0
- package/dist/src/vaults/interfaces/bcs.js +18 -0
- package/dist/src/vaults/interfaces/index.d.ts +82 -0
- package/dist/src/vaults/interfaces/index.js +2 -0
- package/dist/src/vaults/on-chain-calls/admin.d.ts +88 -0
- package/dist/src/vaults/on-chain-calls/admin.js +144 -0
- package/dist/src/vaults/on-chain-calls/index.d.ts +6 -0
- package/dist/src/vaults/on-chain-calls/index.js +22 -0
- package/dist/src/vaults/on-chain-calls/onchain-calls.d.ts +34 -0
- package/dist/src/vaults/on-chain-calls/onchain-calls.js +53 -0
- package/dist/src/vaults/on-chain-calls/operator.d.ts +74 -0
- package/dist/src/vaults/on-chain-calls/operator.js +136 -0
- package/dist/src/vaults/on-chain-calls/tx-builder.d.ts +252 -0
- package/dist/src/vaults/on-chain-calls/tx-builder.js +805 -0
- package/dist/src/vaults/on-chain-calls/user.d.ts +47 -0
- package/dist/src/vaults/on-chain-calls/user.js +114 -0
- package/dist/src/vaults/on-chain-calls/vault-admin.d.ts +64 -0
- package/dist/src/vaults/on-chain-calls/vault-admin.js +114 -0
- package/dist/src/vaults/on-chain-calls/vault.d.ts +42 -0
- package/dist/src/vaults/on-chain-calls/vault.js +79 -0
- package/dist/src/vaults/utils/common.d.ts +2 -0
- package/dist/src/vaults/utils/common.js +8 -0
- package/dist/src/vaults/utils/deployment-parser.d.ts +13 -0
- package/dist/src/vaults/utils/deployment-parser.js +49 -0
- package/dist/src/vaults/utils/index.d.ts +2 -0
- package/dist/src/vaults/utils/index.js +18 -0
- package/package.json +79 -0
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TxBuilder = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const library_sui_1 = require("@firefly-exchange/library-sui");
|
|
6
|
+
const utils_2 = require("@mysten/sui/utils");
|
|
7
|
+
class TxBuilder {
|
|
8
|
+
constructor(_deployment) {
|
|
9
|
+
this.parser = new utils_1.DeploymentParser(_deployment);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Pauses or unpauses the non-admin operations
|
|
13
|
+
* @param pause True if the non-admin operations should be paused, false otherwise
|
|
14
|
+
* @param options Optional tx building params
|
|
15
|
+
* @returns TransactionBlock
|
|
16
|
+
*/
|
|
17
|
+
pauseNonAdminOperations(pause, options) {
|
|
18
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
19
|
+
txb.moveCall({
|
|
20
|
+
arguments: [
|
|
21
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
22
|
+
txb.object(this.parser.getAdminCap()),
|
|
23
|
+
txb.pure.bool(pause)
|
|
24
|
+
],
|
|
25
|
+
target: `${this.parser.getPackageId()}::gateway::pause_non_admin_operations`
|
|
26
|
+
});
|
|
27
|
+
if (options?.gasBudget)
|
|
28
|
+
txb.setGasBudget(options.gasBudget);
|
|
29
|
+
if (options?.sender)
|
|
30
|
+
txb.setSenderIfNotSet(options.sender);
|
|
31
|
+
return txb;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Increases the version of the protocol supported. Only admin can invoke this
|
|
35
|
+
* @param options Optional tx building params
|
|
36
|
+
* @returns TransactionBlock
|
|
37
|
+
*/
|
|
38
|
+
increaseProtocolVersion(options) {
|
|
39
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
40
|
+
txb.moveCall({
|
|
41
|
+
arguments: [
|
|
42
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
43
|
+
txb.object(this.parser.getAdminCap())
|
|
44
|
+
],
|
|
45
|
+
target: `${this.parser.getPackageId()}::gateway::increase_supported_package_version`
|
|
46
|
+
});
|
|
47
|
+
if (options?.gasBudget)
|
|
48
|
+
txb.setGasBudget(options.gasBudget);
|
|
49
|
+
if (options?.sender)
|
|
50
|
+
txb.setSenderIfNotSet(options.sender);
|
|
51
|
+
return txb;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Updates the platform fee recipient
|
|
55
|
+
* @param recipient Address of the platform fee recipient
|
|
56
|
+
* @param options Optional tx building params
|
|
57
|
+
* @returns TransactionBlock
|
|
58
|
+
*/
|
|
59
|
+
updatePlatformFeeRecipient(recipient, options) {
|
|
60
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
61
|
+
txb.moveCall({
|
|
62
|
+
arguments: [
|
|
63
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
64
|
+
txb.object(this.parser.getAdminCap()),
|
|
65
|
+
txb.pure.address(recipient)
|
|
66
|
+
],
|
|
67
|
+
target: `${this.parser.getPackageId()}::gateway::update_platform_fee_recipient`
|
|
68
|
+
});
|
|
69
|
+
if (options?.gasBudget)
|
|
70
|
+
txb.setGasBudget(options.gasBudget);
|
|
71
|
+
if (options?.sender)
|
|
72
|
+
txb.setSenderIfNotSet(options.sender);
|
|
73
|
+
return txb;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Updates the min rate
|
|
77
|
+
* @param minRate Minimum rate for the protocol
|
|
78
|
+
* @param options Optional tx building params
|
|
79
|
+
* @returns TransactionBlock
|
|
80
|
+
*/
|
|
81
|
+
updateMinRate(minRate, options) {
|
|
82
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
83
|
+
txb.moveCall({
|
|
84
|
+
arguments: [
|
|
85
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
86
|
+
txb.object(this.parser.getAdminCap()),
|
|
87
|
+
txb.pure.u64(minRate)
|
|
88
|
+
],
|
|
89
|
+
target: `${this.parser.getPackageId()}::gateway::update_min_rate`
|
|
90
|
+
});
|
|
91
|
+
if (options?.gasBudget)
|
|
92
|
+
txb.setGasBudget(options.gasBudget);
|
|
93
|
+
if (options?.sender)
|
|
94
|
+
txb.setSenderIfNotSet(options.sender);
|
|
95
|
+
return txb;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Updates the max rate
|
|
99
|
+
* @param maxRate Maximum rate for the protocol
|
|
100
|
+
* @param options Optional tx building params
|
|
101
|
+
* @returns TransactionBlock
|
|
102
|
+
*/
|
|
103
|
+
updateMaxRate(maxRate, options) {
|
|
104
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
105
|
+
txb.moveCall({
|
|
106
|
+
arguments: [
|
|
107
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
108
|
+
txb.object(this.parser.getAdminCap()),
|
|
109
|
+
txb.pure.u64(maxRate)
|
|
110
|
+
],
|
|
111
|
+
target: `${this.parser.getPackageId()}::gateway::update_max_rate`
|
|
112
|
+
});
|
|
113
|
+
if (options?.gasBudget)
|
|
114
|
+
txb.setGasBudget(options.gasBudget);
|
|
115
|
+
if (options?.sender)
|
|
116
|
+
txb.setSenderIfNotSet(options.sender);
|
|
117
|
+
return txb;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Updates the max rate interval
|
|
121
|
+
* @param maxRateInterval Maximum rate interval for the protocol
|
|
122
|
+
* @param options Optional tx building params
|
|
123
|
+
* @returns TransactionBlock
|
|
124
|
+
*/
|
|
125
|
+
updateMaxRateInterval(maxRateInterval, options) {
|
|
126
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
127
|
+
txb.moveCall({
|
|
128
|
+
arguments: [
|
|
129
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
130
|
+
txb.object(this.parser.getAdminCap()),
|
|
131
|
+
txb.pure.u64(maxRateInterval)
|
|
132
|
+
],
|
|
133
|
+
target: `${this.parser.getPackageId()}::gateway::update_max_rate_interval`
|
|
134
|
+
});
|
|
135
|
+
if (options?.gasBudget)
|
|
136
|
+
txb.setGasBudget(options.gasBudget);
|
|
137
|
+
if (options?.sender)
|
|
138
|
+
txb.setSenderIfNotSet(options.sender);
|
|
139
|
+
return txb;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Updates the default rate
|
|
143
|
+
* @param defaultRate Default rate for the protocol
|
|
144
|
+
* @param options Optional tx building params
|
|
145
|
+
* @returns TransactionBlock
|
|
146
|
+
*/
|
|
147
|
+
updateDefaultRate(defaultRate, options) {
|
|
148
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
149
|
+
txb.moveCall({
|
|
150
|
+
arguments: [
|
|
151
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
152
|
+
txb.object(this.parser.getAdminCap()),
|
|
153
|
+
txb.pure.u64(defaultRate)
|
|
154
|
+
],
|
|
155
|
+
target: `${this.parser.getPackageId()}::gateway::update_default_rate`
|
|
156
|
+
});
|
|
157
|
+
if (options?.gasBudget)
|
|
158
|
+
txb.setGasBudget(options.gasBudget);
|
|
159
|
+
if (options?.sender)
|
|
160
|
+
txb.setSenderIfNotSet(options.sender);
|
|
161
|
+
return txb;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Updates the max fee percentage
|
|
165
|
+
* @param maxFeePercentage Max fee percentage for the protocol
|
|
166
|
+
* @param options Optional tx building params
|
|
167
|
+
* @returns TransactionBlock
|
|
168
|
+
*/
|
|
169
|
+
updateMaxFeePercentage(maxFeePercentage, options) {
|
|
170
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
171
|
+
txb.moveCall({
|
|
172
|
+
arguments: [
|
|
173
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
174
|
+
txb.object(this.parser.getAdminCap()),
|
|
175
|
+
txb.pure.u64(maxFeePercentage)
|
|
176
|
+
],
|
|
177
|
+
target: `${this.parser.getPackageId()}::gateway::update_max_fee_percentage`
|
|
178
|
+
});
|
|
179
|
+
if (options?.gasBudget)
|
|
180
|
+
txb.setGasBudget(options.gasBudget);
|
|
181
|
+
if (options?.sender)
|
|
182
|
+
txb.setSenderIfNotSet(options.sender);
|
|
183
|
+
return txb;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Creates a new vault
|
|
187
|
+
* @param depositCoinType Type of the deposit coin
|
|
188
|
+
* @param receiptCoinType Type of the receipt coin
|
|
189
|
+
* @param name Name of the vault
|
|
190
|
+
* @param admin Admin of the vault
|
|
191
|
+
* @param operator Operator of the vault
|
|
192
|
+
* @param maxRateChangePerUpdate Max rate change per update
|
|
193
|
+
* @param feePercentage Fee percentage
|
|
194
|
+
* @param minWithdrawalShares Min withdrawal shares
|
|
195
|
+
* @param rateUpdateInterval Rate update interval
|
|
196
|
+
* @param maxTVL Max TVL
|
|
197
|
+
* @param subAccounts Sub accounts
|
|
198
|
+
* @param options Optional tx building params
|
|
199
|
+
* @returns TransactionBlock
|
|
200
|
+
*/
|
|
201
|
+
createVault(depositCoinType, receiptCoinType, name, admin, operator, maxRateChangePerUpdate, feePercentage, minWithdrawalShares, rateUpdateInterval, maxTVL, subAccounts, options) {
|
|
202
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
203
|
+
const receiptTokenTreasuryCap = this.parser.getReceiptCoinTreasuryCap(receiptCoinType);
|
|
204
|
+
txb.moveCall({
|
|
205
|
+
arguments: [
|
|
206
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
207
|
+
txb.object(receiptTokenTreasuryCap),
|
|
208
|
+
txb.object(this.parser.getAdminCap()),
|
|
209
|
+
txb.pure.string(name),
|
|
210
|
+
txb.pure.address(admin),
|
|
211
|
+
txb.pure.address(operator),
|
|
212
|
+
txb.pure.u64(maxRateChangePerUpdate),
|
|
213
|
+
txb.pure.u64(feePercentage),
|
|
214
|
+
txb.pure.u64(minWithdrawalShares),
|
|
215
|
+
txb.pure.u64(rateUpdateInterval),
|
|
216
|
+
txb.pure.u64(maxTVL),
|
|
217
|
+
txb.pure.vector("address", subAccounts)
|
|
218
|
+
],
|
|
219
|
+
typeArguments: [depositCoinType, receiptCoinType],
|
|
220
|
+
target: `${this.parser.getPackageId()}::gateway::create_vault`
|
|
221
|
+
});
|
|
222
|
+
if (options?.gasBudget)
|
|
223
|
+
txb.setGasBudget(options.gasBudget);
|
|
224
|
+
if (options?.sender)
|
|
225
|
+
txb.setSenderIfNotSet(options.sender);
|
|
226
|
+
return txb;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Updates vault admin
|
|
230
|
+
* @param vaultId Id of the vault
|
|
231
|
+
* @param admin Admin of the vault
|
|
232
|
+
* @param options Optional tx building params
|
|
233
|
+
* @returns TransactionBlock
|
|
234
|
+
*/
|
|
235
|
+
updateVaultAdmin(vaultId, admin, options) {
|
|
236
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
237
|
+
txb.moveCall({
|
|
238
|
+
arguments: [
|
|
239
|
+
txb.object(vaultId),
|
|
240
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
241
|
+
txb.object(this.parser.getAdminCap()),
|
|
242
|
+
txb.pure.address(admin)
|
|
243
|
+
],
|
|
244
|
+
typeArguments: [
|
|
245
|
+
this.parser.getDepositCoinType(vaultId),
|
|
246
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
247
|
+
],
|
|
248
|
+
target: `${this.parser.getPackageId()}::gateway::change_vault_admin`
|
|
249
|
+
});
|
|
250
|
+
if (options?.gasBudget)
|
|
251
|
+
txb.setGasBudget(options.gasBudget);
|
|
252
|
+
if (options?.sender)
|
|
253
|
+
txb.setSenderIfNotSet(options.sender);
|
|
254
|
+
return txb;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Updates the paused status of the vault
|
|
258
|
+
* @param vaultId Id of the vault
|
|
259
|
+
* @param paused Paused status of the vault
|
|
260
|
+
* @param options Optional tx building params
|
|
261
|
+
* @returns TransactionBlock
|
|
262
|
+
*/
|
|
263
|
+
updateVaultPausedStatus(vaultId, paused, options) {
|
|
264
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
265
|
+
txb.moveCall({
|
|
266
|
+
arguments: [
|
|
267
|
+
txb.object(vaultId),
|
|
268
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
269
|
+
txb.pure.bool(paused)
|
|
270
|
+
],
|
|
271
|
+
typeArguments: [
|
|
272
|
+
this.parser.getDepositCoinType(vaultId),
|
|
273
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
274
|
+
],
|
|
275
|
+
target: `${this.parser.getPackageId()}::gateway::set_vault_paused_status`
|
|
276
|
+
});
|
|
277
|
+
if (options?.gasBudget)
|
|
278
|
+
txb.setGasBudget(options.gasBudget);
|
|
279
|
+
if (options?.sender)
|
|
280
|
+
txb.setSenderIfNotSet(options.sender);
|
|
281
|
+
return txb;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Updates the operator of the vault
|
|
285
|
+
* @param vaultId Id of the vault
|
|
286
|
+
* @param operator Operator of the vault
|
|
287
|
+
* @param options Optional tx building params
|
|
288
|
+
* @returns TransactionBlock
|
|
289
|
+
*/
|
|
290
|
+
updateVaultOperator(vaultId, operator, options) {
|
|
291
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
292
|
+
txb.moveCall({
|
|
293
|
+
arguments: [
|
|
294
|
+
txb.object(vaultId),
|
|
295
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
296
|
+
txb.pure.address(operator)
|
|
297
|
+
],
|
|
298
|
+
typeArguments: [
|
|
299
|
+
this.parser.getDepositCoinType(vaultId),
|
|
300
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
301
|
+
],
|
|
302
|
+
target: `${this.parser.getPackageId()}::gateway::change_vault_operator`
|
|
303
|
+
});
|
|
304
|
+
if (options?.gasBudget)
|
|
305
|
+
txb.setGasBudget(options.gasBudget);
|
|
306
|
+
if (options?.sender)
|
|
307
|
+
txb.setSenderIfNotSet(options.sender);
|
|
308
|
+
return txb;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Updates the min withdrawal shares of the vault
|
|
312
|
+
* @param vaultId Id of the vault
|
|
313
|
+
* @param minWithdrawalShares Min withdrawal shares
|
|
314
|
+
* @param options Optional tx building params
|
|
315
|
+
* @returns TransactionBlock
|
|
316
|
+
*/
|
|
317
|
+
updateVaultMinWithdrawalShares(vaultId, minWithdrawalShares, options) {
|
|
318
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
319
|
+
txb.moveCall({
|
|
320
|
+
arguments: [
|
|
321
|
+
txb.object(vaultId),
|
|
322
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
323
|
+
txb.pure.u64(minWithdrawalShares)
|
|
324
|
+
],
|
|
325
|
+
target: `${this.parser.getPackageId()}::gateway::update_vault_min_withdrawal_shares`
|
|
326
|
+
});
|
|
327
|
+
if (options?.gasBudget)
|
|
328
|
+
txb.setGasBudget(options.gasBudget);
|
|
329
|
+
if (options?.sender)
|
|
330
|
+
txb.setSenderIfNotSet(options.sender);
|
|
331
|
+
return txb;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Sets a sub account
|
|
335
|
+
* @param vaultId Id of the vault
|
|
336
|
+
* @param subAccount Sub account of the vault
|
|
337
|
+
* @param isActive Is active
|
|
338
|
+
* @param options Optional tx building params
|
|
339
|
+
* @returns TransactionBlock
|
|
340
|
+
*/
|
|
341
|
+
setSubAccount(vaultId, subAccount, isActive, options) {
|
|
342
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
343
|
+
txb.moveCall({
|
|
344
|
+
arguments: [
|
|
345
|
+
txb.object(vaultId),
|
|
346
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
347
|
+
txb.pure.address(subAccount),
|
|
348
|
+
txb.pure.bool(isActive)
|
|
349
|
+
],
|
|
350
|
+
typeArguments: [
|
|
351
|
+
this.parser.getDepositCoinType(vaultId),
|
|
352
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
353
|
+
],
|
|
354
|
+
target: `${this.parser.getPackageId()}::gateway::set_sub_account`
|
|
355
|
+
});
|
|
356
|
+
if (options?.gasBudget)
|
|
357
|
+
txb.setGasBudget(options.gasBudget);
|
|
358
|
+
if (options?.sender)
|
|
359
|
+
txb.setSenderIfNotSet(options.sender);
|
|
360
|
+
return txb;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Updates vault max TVL
|
|
364
|
+
* @param vaultId Id of the vault
|
|
365
|
+
* @param maxTVL Max TVL of the vault
|
|
366
|
+
* @param options Optional tx building params
|
|
367
|
+
* @returns TransactionBlock
|
|
368
|
+
*/
|
|
369
|
+
updateVaultMaxTVL(vaultId, maxTVL, options) {
|
|
370
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
371
|
+
txb.moveCall({
|
|
372
|
+
arguments: [
|
|
373
|
+
txb.object(vaultId),
|
|
374
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
375
|
+
txb.pure.u64(maxTVL)
|
|
376
|
+
],
|
|
377
|
+
typeArguments: [
|
|
378
|
+
this.parser.getDepositCoinType(vaultId),
|
|
379
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
380
|
+
],
|
|
381
|
+
target: `${this.parser.getPackageId()}::gateway::update_vault_max_tvl`
|
|
382
|
+
});
|
|
383
|
+
if (options?.gasBudget)
|
|
384
|
+
txb.setGasBudget(options.gasBudget);
|
|
385
|
+
if (options?.sender)
|
|
386
|
+
txb.setSenderIfNotSet(options.sender);
|
|
387
|
+
return txb;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Updates the rate update interval of the vault
|
|
391
|
+
* @param vaultId Id of the vault
|
|
392
|
+
* @param rateUpdateInterval Rate update interval in ms
|
|
393
|
+
* @param options Optional tx building params
|
|
394
|
+
* @returns TransactionBlock
|
|
395
|
+
*/
|
|
396
|
+
updateVaultRateUpdateInterval(vaultId, rateUpdateInterval, options) {
|
|
397
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
398
|
+
txb.moveCall({
|
|
399
|
+
arguments: [
|
|
400
|
+
txb.object(vaultId),
|
|
401
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
402
|
+
txb.pure.u64(rateUpdateInterval)
|
|
403
|
+
],
|
|
404
|
+
typeArguments: [
|
|
405
|
+
this.parser.getDepositCoinType(vaultId),
|
|
406
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
407
|
+
],
|
|
408
|
+
target: `${this.parser.getPackageId()}::gateway::change_vault_rate_update_interval`
|
|
409
|
+
});
|
|
410
|
+
if (options?.gasBudget)
|
|
411
|
+
txb.setGasBudget(options.gasBudget);
|
|
412
|
+
if (options?.sender)
|
|
413
|
+
txb.setSenderIfNotSet(options.sender);
|
|
414
|
+
return txb;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Updates the fee percentage of the vault
|
|
418
|
+
* @param vaultId Id of the vault
|
|
419
|
+
* @param feePercentage Fee percentage
|
|
420
|
+
* @param options Optional tx building params
|
|
421
|
+
* @returns TransactionBlock
|
|
422
|
+
*/
|
|
423
|
+
updateVaultFeePercentage(vaultId, feePercentage, options) {
|
|
424
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
425
|
+
txb.moveCall({
|
|
426
|
+
arguments: [
|
|
427
|
+
txb.object(vaultId),
|
|
428
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
429
|
+
txb.pure.u64(feePercentage)
|
|
430
|
+
],
|
|
431
|
+
typeArguments: [
|
|
432
|
+
this.parser.getDepositCoinType(vaultId),
|
|
433
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
434
|
+
],
|
|
435
|
+
target: `${this.parser.getPackageId()}::gateway::update_vault_fee_percentage`
|
|
436
|
+
});
|
|
437
|
+
if (options?.gasBudget)
|
|
438
|
+
txb.setGasBudget(options.gasBudget);
|
|
439
|
+
if (options?.sender)
|
|
440
|
+
txb.setSenderIfNotSet(options.sender);
|
|
441
|
+
return txb;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Set min withdrawal shares
|
|
445
|
+
* @param vaultId Id of the vault
|
|
446
|
+
* @param minWithdrawalShares Min withdrawal shares
|
|
447
|
+
* @param options Optional tx building params
|
|
448
|
+
* @returns TransactionBlock
|
|
449
|
+
*/
|
|
450
|
+
setMinWithdrawalShares(vaultId, minWithdrawalShares, options) {
|
|
451
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
452
|
+
txb.moveCall({
|
|
453
|
+
arguments: [
|
|
454
|
+
txb.object(vaultId),
|
|
455
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
456
|
+
txb.pure.u64(minWithdrawalShares)
|
|
457
|
+
],
|
|
458
|
+
typeArguments: [
|
|
459
|
+
this.parser.getDepositCoinType(vaultId),
|
|
460
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
461
|
+
],
|
|
462
|
+
target: `${this.parser.getPackageId()}::gateway::set_min_withdrawal_shares`
|
|
463
|
+
});
|
|
464
|
+
if (options?.gasBudget)
|
|
465
|
+
txb.setGasBudget(options.gasBudget);
|
|
466
|
+
if (options?.sender)
|
|
467
|
+
txb.setSenderIfNotSet(options.sender);
|
|
468
|
+
return txb;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Sets a blacklisted account
|
|
472
|
+
* @param vaultId Id of the vault
|
|
473
|
+
* @param account Address of the account
|
|
474
|
+
* @param isBlacklisted Is blacklisted
|
|
475
|
+
* @param options Optional tx building params
|
|
476
|
+
* @returns TransactionBlock
|
|
477
|
+
*/
|
|
478
|
+
setBlacklistedAccount(vaultId, account, isBlacklisted, options) {
|
|
479
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
480
|
+
txb.moveCall({
|
|
481
|
+
arguments: [
|
|
482
|
+
txb.object(vaultId),
|
|
483
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
484
|
+
txb.pure.address(account),
|
|
485
|
+
txb.pure.bool(isBlacklisted)
|
|
486
|
+
],
|
|
487
|
+
typeArguments: [
|
|
488
|
+
this.parser.getDepositCoinType(vaultId),
|
|
489
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
490
|
+
],
|
|
491
|
+
target: `${this.parser.getPackageId()}::gateway::set_blacklisted_account`
|
|
492
|
+
});
|
|
493
|
+
if (options?.gasBudget)
|
|
494
|
+
txb.setGasBudget(options.gasBudget);
|
|
495
|
+
if (options?.sender)
|
|
496
|
+
txb.setSenderIfNotSet(options.sender);
|
|
497
|
+
return txb;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Updates the rate of the vault
|
|
501
|
+
* @param vaultId Id of the vault
|
|
502
|
+
* @param rate Rate of the vault
|
|
503
|
+
* @param options Optional tx building params
|
|
504
|
+
* @returns TransactionBlock
|
|
505
|
+
*/
|
|
506
|
+
updateVaultRate(vaultId, rate, options) {
|
|
507
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
508
|
+
txb.moveCall({
|
|
509
|
+
arguments: [
|
|
510
|
+
txb.object(vaultId),
|
|
511
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
512
|
+
txb.pure.u64(rate),
|
|
513
|
+
txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
|
|
514
|
+
],
|
|
515
|
+
typeArguments: [
|
|
516
|
+
this.parser.getDepositCoinType(vaultId),
|
|
517
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
518
|
+
],
|
|
519
|
+
target: `${this.parser.getPackageId()}::gateway::update_vault_rate`
|
|
520
|
+
});
|
|
521
|
+
if (options?.gasBudget)
|
|
522
|
+
txb.setGasBudget(options.gasBudget);
|
|
523
|
+
if (options?.sender)
|
|
524
|
+
txb.setSenderIfNotSet(options.sender);
|
|
525
|
+
return txb;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Deposit to vault without minting shares
|
|
529
|
+
* @param vaultId Id of the vault
|
|
530
|
+
* @param subAccount Sub account of the vault
|
|
531
|
+
* @param coinId Id of the coin
|
|
532
|
+
* @param options Optional tx building params
|
|
533
|
+
* @returns TransactionBlock
|
|
534
|
+
*/
|
|
535
|
+
depositToVaultWithoutMintingShares(vaultId, subAccount, coinId, options) {
|
|
536
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
537
|
+
txb.moveCall({
|
|
538
|
+
arguments: [
|
|
539
|
+
txb.object(vaultId),
|
|
540
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
541
|
+
txb.pure.address(subAccount),
|
|
542
|
+
txb.object(coinId)
|
|
543
|
+
],
|
|
544
|
+
typeArguments: [
|
|
545
|
+
this.parser.getDepositCoinType(vaultId),
|
|
546
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
547
|
+
],
|
|
548
|
+
target: `${this.parser.getPackageId()}::gateway::deposit_to_vault_without_minting_shares`
|
|
549
|
+
});
|
|
550
|
+
if (options?.gasBudget)
|
|
551
|
+
txb.setGasBudget(options.gasBudget);
|
|
552
|
+
if (options?.sender)
|
|
553
|
+
txb.setSenderIfNotSet(options.sender);
|
|
554
|
+
return txb;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Withdraw from vault without redeeming shares
|
|
558
|
+
* @param vaultId Id of the vault
|
|
559
|
+
* @param subAccount Sub account of the vault
|
|
560
|
+
* @param amount Amount to withdraw
|
|
561
|
+
* @param options Optional tx building params
|
|
562
|
+
* @returns TransactionBlock
|
|
563
|
+
*/
|
|
564
|
+
withdrawFromVaultWithoutRedeemingShares(vaultId, subAccount, amount, options) {
|
|
565
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
566
|
+
txb.moveCall({
|
|
567
|
+
arguments: [
|
|
568
|
+
txb.object(vaultId),
|
|
569
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
570
|
+
txb.pure.address(subAccount),
|
|
571
|
+
txb.pure.u64(amount)
|
|
572
|
+
],
|
|
573
|
+
typeArguments: [
|
|
574
|
+
this.parser.getDepositCoinType(vaultId),
|
|
575
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
576
|
+
],
|
|
577
|
+
target: `${this.parser.getPackageId()}::gateway::withdraw_from_vault_without_redeeming_shares`
|
|
578
|
+
});
|
|
579
|
+
if (options?.gasBudget)
|
|
580
|
+
txb.setGasBudget(options.gasBudget);
|
|
581
|
+
if (options?.sender)
|
|
582
|
+
txb.setSenderIfNotSet(options.sender);
|
|
583
|
+
return txb;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Process withdrawal requests
|
|
587
|
+
* @param vaultId Id of the vault
|
|
588
|
+
* @param requestCount Max number of requests to process
|
|
589
|
+
* @param options Optional tx building params
|
|
590
|
+
* @returns TransactionBlock
|
|
591
|
+
*/
|
|
592
|
+
processWithdrawalRequests(vaultId, requestCount, options) {
|
|
593
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
594
|
+
txb.moveCall({
|
|
595
|
+
arguments: [
|
|
596
|
+
txb.object(vaultId),
|
|
597
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
598
|
+
txb.pure.u64(requestCount),
|
|
599
|
+
txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
|
|
600
|
+
],
|
|
601
|
+
typeArguments: [
|
|
602
|
+
this.parser.getDepositCoinType(vaultId),
|
|
603
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
604
|
+
],
|
|
605
|
+
target: `${this.parser.getPackageId()}::gateway::process_withdrawal_requests`
|
|
606
|
+
});
|
|
607
|
+
if (options?.gasBudget)
|
|
608
|
+
txb.setGasBudget(options.gasBudget);
|
|
609
|
+
if (options?.sender)
|
|
610
|
+
txb.setSenderIfNotSet(options.sender);
|
|
611
|
+
return txb;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Process withdrawal requests up to timestamp
|
|
615
|
+
* @param vaultId Id of the vault
|
|
616
|
+
* @param timestamp Timestamp
|
|
617
|
+
* @param options Optional tx building params
|
|
618
|
+
* @returns TransactionBlock
|
|
619
|
+
*/
|
|
620
|
+
processWithdrawalRequestsUpToTimestamp(vaultId, timestamp, options) {
|
|
621
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
622
|
+
txb.moveCall({
|
|
623
|
+
arguments: [
|
|
624
|
+
txb.object(vaultId),
|
|
625
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
626
|
+
txb.pure.u64(timestamp),
|
|
627
|
+
txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
|
|
628
|
+
],
|
|
629
|
+
typeArguments: [
|
|
630
|
+
this.parser.getDepositCoinType(vaultId),
|
|
631
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
632
|
+
],
|
|
633
|
+
target: `${this.parser.getPackageId()}::gateway::process_withdrawal_requests_up_to_timestamp`
|
|
634
|
+
});
|
|
635
|
+
if (options?.gasBudget)
|
|
636
|
+
txb.setGasBudget(options.gasBudget);
|
|
637
|
+
if (options?.sender)
|
|
638
|
+
txb.setSenderIfNotSet(options.sender);
|
|
639
|
+
return txb;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Charge platform fee
|
|
643
|
+
* @param vaultId Id of the vault
|
|
644
|
+
* @param options Optional tx building params
|
|
645
|
+
* @returns TransactionBlock
|
|
646
|
+
*/
|
|
647
|
+
chargePlatformFee(vaultId, options) {
|
|
648
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
649
|
+
txb.moveCall({
|
|
650
|
+
arguments: [
|
|
651
|
+
txb.object(vaultId),
|
|
652
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
653
|
+
txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
|
|
654
|
+
],
|
|
655
|
+
typeArguments: [
|
|
656
|
+
this.parser.getDepositCoinType(vaultId),
|
|
657
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
658
|
+
],
|
|
659
|
+
target: `${this.parser.getPackageId()}::gateway::charge_platform_fee`
|
|
660
|
+
});
|
|
661
|
+
if (options?.gasBudget)
|
|
662
|
+
txb.setGasBudget(options.gasBudget);
|
|
663
|
+
if (options?.sender)
|
|
664
|
+
txb.setSenderIfNotSet(options.sender);
|
|
665
|
+
return txb;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Collect platform fee
|
|
669
|
+
* @param vaultId Id of the vault
|
|
670
|
+
* @param options Optional tx building params
|
|
671
|
+
* @returns TransactionBlock
|
|
672
|
+
*/
|
|
673
|
+
collectPlatformFee(vaultId, options) {
|
|
674
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
675
|
+
txb.moveCall({
|
|
676
|
+
arguments: [txb.object(vaultId), txb.object(this.parser.getProtocolConfig())],
|
|
677
|
+
typeArguments: [
|
|
678
|
+
this.parser.getDepositCoinType(vaultId),
|
|
679
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
680
|
+
],
|
|
681
|
+
target: `${this.parser.getPackageId()}::gateway::collect_platform_fee`
|
|
682
|
+
});
|
|
683
|
+
if (options?.gasBudget)
|
|
684
|
+
txb.setGasBudget(options.gasBudget);
|
|
685
|
+
if (options?.sender)
|
|
686
|
+
txb.setSenderIfNotSet(options.sender);
|
|
687
|
+
return txb;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Deposit asset
|
|
691
|
+
* @param vaultId Id of the vault
|
|
692
|
+
* @param coinId Id of the coin
|
|
693
|
+
* @param options Optional tx building params
|
|
694
|
+
* @returns TransactionBlock
|
|
695
|
+
*/
|
|
696
|
+
depositAsset(vaultId, coinId, options) {
|
|
697
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
698
|
+
txb.moveCall({
|
|
699
|
+
arguments: [
|
|
700
|
+
txb.object(vaultId),
|
|
701
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
702
|
+
txb.object(coinId)
|
|
703
|
+
],
|
|
704
|
+
typeArguments: [
|
|
705
|
+
this.parser.getDepositCoinType(vaultId),
|
|
706
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
707
|
+
],
|
|
708
|
+
target: `${this.parser.getPackageId()}::gateway::deposit_asset`
|
|
709
|
+
});
|
|
710
|
+
if (options?.gasBudget)
|
|
711
|
+
txb.setGasBudget(options.gasBudget);
|
|
712
|
+
if (options?.sender)
|
|
713
|
+
txb.setSenderIfNotSet(options.sender);
|
|
714
|
+
return txb;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Mint shares
|
|
718
|
+
* @param vaultId Id of the vault
|
|
719
|
+
* @param coinId Id of the coin
|
|
720
|
+
* @param shares Amount of shares
|
|
721
|
+
* @param receiver Address of the receiver
|
|
722
|
+
* @param options Optional tx building params
|
|
723
|
+
* @returns TransactionBlock
|
|
724
|
+
*/
|
|
725
|
+
mintShares(vaultId, coinId, shares, receiver, options) {
|
|
726
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
727
|
+
txb.moveCall({
|
|
728
|
+
arguments: [
|
|
729
|
+
txb.object(vaultId),
|
|
730
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
731
|
+
txb.object(coinId),
|
|
732
|
+
txb.pure.u64(shares),
|
|
733
|
+
txb.pure.vector("address", [receiver])
|
|
734
|
+
],
|
|
735
|
+
typeArguments: [
|
|
736
|
+
this.parser.getDepositCoinType(vaultId),
|
|
737
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
738
|
+
],
|
|
739
|
+
target: `${this.parser.getPackageId()}::gateway::mint_shares`
|
|
740
|
+
});
|
|
741
|
+
if (options?.gasBudget)
|
|
742
|
+
txb.setGasBudget(options.gasBudget);
|
|
743
|
+
if (options?.sender)
|
|
744
|
+
txb.setSenderIfNotSet(options.sender);
|
|
745
|
+
return txb;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Redeems shares
|
|
749
|
+
* @param vaultId Id of the vault
|
|
750
|
+
* @param sharesCoinId Id of the shares coin
|
|
751
|
+
* @param receiver Address of the receiver
|
|
752
|
+
* @param options Optional tx building params
|
|
753
|
+
* @returns TransactionBlock
|
|
754
|
+
*/
|
|
755
|
+
redeemShares(vaultId, sharesCoinId, receiver, options) {
|
|
756
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
757
|
+
txb.moveCall({
|
|
758
|
+
arguments: [
|
|
759
|
+
txb.object(utils_2.SUI_CLOCK_OBJECT_ID),
|
|
760
|
+
txb.object(vaultId),
|
|
761
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
762
|
+
txb.object(sharesCoinId),
|
|
763
|
+
txb.pure.vector("address", [receiver])
|
|
764
|
+
],
|
|
765
|
+
typeArguments: [
|
|
766
|
+
this.parser.getDepositCoinType(vaultId),
|
|
767
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
768
|
+
],
|
|
769
|
+
target: `${this.parser.getPackageId()}::gateway::redeem_shares`
|
|
770
|
+
});
|
|
771
|
+
if (options?.gasBudget)
|
|
772
|
+
txb.setGasBudget(options.gasBudget);
|
|
773
|
+
if (options?.sender)
|
|
774
|
+
txb.setSenderIfNotSet(options.sender);
|
|
775
|
+
return txb;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Cancel pending withdrawal request
|
|
779
|
+
* @param vaultId Id of the vault
|
|
780
|
+
* @param sequenceNumber Sequence number of the withdrawal request
|
|
781
|
+
* @param options Optional tx building params
|
|
782
|
+
* @returns TransactionBlock
|
|
783
|
+
*/
|
|
784
|
+
cancelPendingWithdrawalRequest(vaultId, sequenceNumber, options) {
|
|
785
|
+
const txb = options?.txBlock || new library_sui_1.TransactionBlock();
|
|
786
|
+
txb.moveCall({
|
|
787
|
+
arguments: [
|
|
788
|
+
txb.object(vaultId),
|
|
789
|
+
txb.object(this.parser.getProtocolConfig()),
|
|
790
|
+
txb.pure.u128(sequenceNumber)
|
|
791
|
+
],
|
|
792
|
+
typeArguments: [
|
|
793
|
+
this.parser.getDepositCoinType(vaultId),
|
|
794
|
+
this.parser.getReceiptCoinType(vaultId)
|
|
795
|
+
],
|
|
796
|
+
target: `${this.parser.getPackageId()}::gateway::cancel_pending_withdrawal_request`
|
|
797
|
+
});
|
|
798
|
+
if (options?.gasBudget)
|
|
799
|
+
txb.setGasBudget(options.gasBudget);
|
|
800
|
+
if (options?.sender)
|
|
801
|
+
txb.setSenderIfNotSet(options.sender);
|
|
802
|
+
return txb;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
exports.TxBuilder = TxBuilder;
|