@interest-protocol/vortex-sdk 5.0.0 → 6.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/__tests__/test-utils.d.ts +1 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -17
- package/dist/index.mjs.map +1 -1
- package/dist/swap.d.ts +17 -0
- package/dist/swap.d.ts.map +1 -0
- package/dist/utils/deposit.d.ts.map +1 -1
- package/dist/utils/withdraw.d.ts +4 -5
- package/dist/utils/withdraw.d.ts.map +1 -1
- package/dist/vortex.d.ts +18 -3
- package/dist/vortex.d.ts.map +1 -1
- package/dist/vortex.types.d.ts +45 -3
- 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 +3 -3
- package/src/__tests__/test-utils.ts +4 -0
- package/src/constants.ts +12 -6
- package/src/index.ts +1 -0
- package/src/swap.ts +93 -0
- package/src/utils/deposit.ts +1 -4
- package/src/utils/withdraw.ts +2 -5
- package/src/vortex.ts +59 -2
- package/src/vortex.types.ts +50 -3
- package/src/withdraw-with-account.ts +0 -2
- package/src/withdraw.ts +0 -2
|
@@ -6,6 +6,7 @@ export declare const TEST_VORTEX_PACKAGE_ID = "0xe5c3cc57317735311a9e054fa3d59c6
|
|
|
6
6
|
export declare const TEST_VORTEX_SHARED_OBJECT_ID = "0x9751819ded69b113eea0ca81b4fcb95be8a07b166a88858ce58057417b5713d3";
|
|
7
7
|
export declare const TEST_REGISTRY_SHARED_OBJECT_ID = "0x86b4429f15c699d4a225474be82490f1165c1123228dcfedc6966c245b840ac2";
|
|
8
8
|
export declare const TEST_UPGRADE_CAP_ID = "0xb76878578f39017a04a892e7250a146c13663282de80876fae7d62fb5b073f4b";
|
|
9
|
+
export declare const TEST_VORTEX_SWAP_PACKAGE_ID = "0x7efc1d6d42b8c6d6846172a3925f2f28cd5d71cff617ad81f8c3d45a842eabbb";
|
|
9
10
|
export declare const TEST_REGISTRY_INITIAL_SHARED_VERSION = "8";
|
|
10
11
|
export declare const TEST_VORTEX_INITIAL_SHARED_VERSION = "8";
|
|
11
12
|
interface ExpectDevInspectTransactionBlockArgs {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,eAAO,MAAM,eAAe,WAE1B,CAAC;AAEH,eAAO,MAAM,sBAAsB,uEACmC,CAAC;AAEvE,eAAO,MAAM,4BAA4B,uEAC6B,CAAC;AAEvE,eAAO,MAAM,8BAA8B,uEAC2B,CAAC;AAEvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AAEvE,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,UAAU,oCAAoC;IAC5C,EAAE,EAAE,WAAW,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,gCAAgC,GAAU,+BAIpD,oCAAoC,kBAUtC,CAAC;AAEF,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,eAAO,MAAM,eAAe,WAE1B,CAAC;AAEH,eAAO,MAAM,sBAAsB,uEACmC,CAAC;AAEvE,eAAO,MAAM,4BAA4B,uEAC6B,CAAC;AAEvE,eAAO,MAAM,8BAA8B,uEAC2B,CAAC;AAEvE,eAAO,MAAM,mBAAmB,uEACsC,CAAC;AAEvE,eAAO,MAAM,2BAA2B,uEAC8B,CAAC;AAEvE,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,UAAU,oCAAoC;IAC5C,EAAE,EAAE,WAAW,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,gCAAgC,GAAU,+BAIpD,oCAAoC,kBAUtC,CAAC;AAEF,eAAO,MAAM,UAAU,QAOrB,CAAC;AAEH,UAAU,eAAe;IACvB,EAAE,EAAE,WAAW,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,mBAAmB,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,mBAAmB,GAAI,8BAIjC,eAAe,SAMjB,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -26,10 +26,12 @@ export declare const ERROR_CODES: {
|
|
|
26
26
|
13: string;
|
|
27
27
|
14: string;
|
|
28
28
|
};
|
|
29
|
-
export declare const VORTEX_PACKAGE_ID = "
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const REGISTRY_OBJECT_ID = "
|
|
32
|
-
export declare const
|
|
29
|
+
export declare const VORTEX_PACKAGE_ID = "0xcf81b96e392f82b776ee980108357426b726c4043c838822545a307e12c5ded6";
|
|
30
|
+
export declare const VORTEX_UPGRADE_CAP = "0xc2d1925fd45559e09c51f5491ec96d61f9e9108c967d34fe22a053c1b307ddfc";
|
|
31
|
+
export declare const REGISTRY_OBJECT_ID = "0xf2c11c297e0581e0279714f6ba47e26d03d9a70756036fab5882ebc0f1d2b3b1";
|
|
32
|
+
export declare const VORTEX_SWAP_PACKAGE_ID = "0x2ddd33debbac3e0461b3551bb00bd40d3055ea5cd441b4fad8624dcbb095e8fb";
|
|
33
|
+
export declare const VORTEX_SWAP_UPGRADE_CAP = "0xec0beaf1453b0e09d92f8addf25abcfb4bc6ce43ead828914836cadc8df249a0";
|
|
34
|
+
export declare const INITIAL_SHARED_VERSION = "692442863";
|
|
33
35
|
export declare const LSK_FETCH_OFFSET = "fetch_offset";
|
|
34
36
|
export declare const LSK_ENCRYPTED_OUTPUTS = "encrypted_outputs";
|
|
35
37
|
export declare const VORTEX_SIGNATURE_DOMAIN = "VORTEXFI.XYZ";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iFACgD,CAAC;AAGjF,eAAO,MAAM,UAAU,iFACyD,CAAC;AAEjF,eAAO,MAAM,gBAAgB,iFAAa,CAAC;AAE3C,eAAO,MAAM,oBAAoB,UAiChC,CAAC;AAEF,oBAAY,OAAO;IACjB,OAAO,oBAAoB;IAC3B,KAAK,iBAAiB;IACtB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,uEACwC,CAAC;AAEvE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,iFACgD,CAAC;AAGjF,eAAO,MAAM,UAAU,iFACyD,CAAC;AAEjF,eAAO,MAAM,gBAAgB,iFAAa,CAAC;AAE3C,eAAO,MAAM,oBAAoB,UAiChC,CAAC;AAEF,oBAAY,OAAO;IACjB,OAAO,oBAAoB;IAC3B,KAAK,iBAAiB;IACtB,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,uEACwC,CAAC;AAEvE,eAAO,MAAM,kBAAkB,uEACuC,CAAC;AAEvE,eAAO,MAAM,kBAAkB,uEACuC,CAAC;AAEvE,eAAO,MAAM,sBAAsB,uEACmC,CAAC;AAEvE,eAAO,MAAM,uBAAuB,uEACkC,CAAC;AAEvE,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,uEACyC,CAAC;AAGvE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,eAAO,MAAM,YAAY,SAAU,CAAC;AAEpC,eAAO,MAAM,eAAe;;CAG3B,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3372,10 +3372,12 @@ const ERROR_CODES = {
|
|
|
3372
3372
|
13: 'Invalid relayer',
|
|
3373
3373
|
14: 'Invalid output flag',
|
|
3374
3374
|
};
|
|
3375
|
-
const VORTEX_PACKAGE_ID = '
|
|
3376
|
-
const
|
|
3377
|
-
const REGISTRY_OBJECT_ID = '
|
|
3378
|
-
const
|
|
3375
|
+
const VORTEX_PACKAGE_ID = '0xcf81b96e392f82b776ee980108357426b726c4043c838822545a307e12c5ded6';
|
|
3376
|
+
const VORTEX_UPGRADE_CAP = '0xc2d1925fd45559e09c51f5491ec96d61f9e9108c967d34fe22a053c1b307ddfc';
|
|
3377
|
+
const REGISTRY_OBJECT_ID = '0xf2c11c297e0581e0279714f6ba47e26d03d9a70756036fab5882ebc0f1d2b3b1';
|
|
3378
|
+
const VORTEX_SWAP_PACKAGE_ID = '0x2ddd33debbac3e0461b3551bb00bd40d3055ea5cd441b4fad8624dcbb095e8fb';
|
|
3379
|
+
const VORTEX_SWAP_UPGRADE_CAP = '0xec0beaf1453b0e09d92f8addf25abcfb4bc6ce43ead828914836cadc8df249a0';
|
|
3380
|
+
const INITIAL_SHARED_VERSION = '692442863';
|
|
3379
3381
|
const LSK_FETCH_OFFSET = 'fetch_offset';
|
|
3380
3382
|
const LSK_ENCRYPTED_OUTPUTS = 'encrypted_outputs';
|
|
3381
3383
|
const VORTEX_SIGNATURE_DOMAIN = 'VORTEXFI.XYZ';
|
|
@@ -3384,7 +3386,7 @@ const TREASURY_ADDRESS = '0x894261575b948c035d002adc3ca4d73c683c01a1bfafac183870
|
|
|
3384
3386
|
const DEPOSIT_FEE_IN_BASIS_POINTS = 50n;
|
|
3385
3387
|
const BASIS_POINTS = 10000n;
|
|
3386
3388
|
const VORTEX_POOL_IDS = {
|
|
3387
|
-
[SUI_TYPE_ARG]: '
|
|
3389
|
+
[SUI_TYPE_ARG]: '0x1e3672f35853fccded923505434b5138543829231f025120d57fda95b86b504c',
|
|
3388
3390
|
};
|
|
3389
3391
|
|
|
3390
3392
|
/******************************************************************************
|
|
@@ -39319,7 +39321,7 @@ const parseVortexPool = (data) => {
|
|
|
39319
39321
|
|
|
39320
39322
|
var _Vortex_instances, _Vortex_suiClient, _Vortex_newPoolEventType, _Vortex_newAccountEventType, _Vortex_newCommitmentEventType, _Vortex_nullifierSpentEventType, _Vortex_newEncryptionKeyEventType, _Vortex_getVortexPool;
|
|
39321
39323
|
class Vortex {
|
|
39322
|
-
constructor({ registry, packageId, fullNodeUrl = getFullnodeUrl('devnet'), }) {
|
|
39324
|
+
constructor({ registry, packageId, swapPackageId, fullNodeUrl = getFullnodeUrl('devnet'), }) {
|
|
39323
39325
|
_Vortex_instances.add(this);
|
|
39324
39326
|
_Vortex_suiClient.set(this, void 0);
|
|
39325
39327
|
_Vortex_newPoolEventType.set(this, void 0);
|
|
@@ -39335,6 +39337,7 @@ class Vortex {
|
|
|
39335
39337
|
__classPrivateFieldSet(this, _Vortex_newCommitmentEventType, `${packageId}::vortex_events::NewCommitment`, "f");
|
|
39336
39338
|
__classPrivateFieldSet(this, _Vortex_nullifierSpentEventType, `${packageId}::vortex_events::NullifierSpent`, "f");
|
|
39337
39339
|
__classPrivateFieldSet(this, _Vortex_newEncryptionKeyEventType, `${packageId}::vortex_events::NewEncryptionKey`, "f");
|
|
39340
|
+
this.swapPackageId = swapPackageId;
|
|
39338
39341
|
this.packageId = packageId;
|
|
39339
39342
|
this.registry = registry;
|
|
39340
39343
|
}
|
|
@@ -39416,11 +39419,10 @@ class Vortex {
|
|
|
39416
39419
|
invariant(result[0], 'Encryption key devInspectAndGetReturnValues failed');
|
|
39417
39420
|
return result[0][0];
|
|
39418
39421
|
}
|
|
39419
|
-
newExtData({ tx = new Transaction(),
|
|
39422
|
+
newExtData({ tx = new Transaction(), value, action, relayer, relayerFee, encryptedOutput1, encryptedOutput0, }) {
|
|
39420
39423
|
const extData = tx.moveCall({
|
|
39421
39424
|
target: `${this.packageId}::vortex_ext_data::new`,
|
|
39422
39425
|
arguments: [
|
|
39423
|
-
tx.pure.address(recipient),
|
|
39424
39426
|
tx.pure.u64(value),
|
|
39425
39427
|
tx.pure.bool(action === exports.Action.Deposit), // true for deposit, false for withdraw
|
|
39426
39428
|
tx.pure.address(relayer),
|
|
@@ -39550,6 +39552,36 @@ class Vortex {
|
|
|
39550
39552
|
invariant(result[0], 'Is nullifier spent devInspectAndGetReturnValues failed');
|
|
39551
39553
|
return result.flat();
|
|
39552
39554
|
}
|
|
39555
|
+
async startSwap({ tx = new Transaction(), vortex, proof, extData, relayer, minAmountOut, coinOutType, }) {
|
|
39556
|
+
const vortexPool = await __classPrivateFieldGet(this, _Vortex_instances, "m", _Vortex_getVortexPool).call(this, vortex);
|
|
39557
|
+
const [receipt, coinIn] = tx.moveCall({
|
|
39558
|
+
target: `${this.swapPackageId}::vortex_swap::start_swap`,
|
|
39559
|
+
arguments: [
|
|
39560
|
+
tx.object(vortexPool.objectId),
|
|
39561
|
+
proof,
|
|
39562
|
+
extData,
|
|
39563
|
+
tx.pure.address(relayer),
|
|
39564
|
+
tx.pure.u64(minAmountOut),
|
|
39565
|
+
],
|
|
39566
|
+
typeArguments: [vortexPool.coinType, coinOutType],
|
|
39567
|
+
});
|
|
39568
|
+
return { tx, receipt, coinIn };
|
|
39569
|
+
}
|
|
39570
|
+
async finishSwap({ tx = new Transaction(), vortex, coinOut, proof, extData, receipt, coinInType, }) {
|
|
39571
|
+
const vortexPool = await __classPrivateFieldGet(this, _Vortex_instances, "m", _Vortex_getVortexPool).call(this, vortex);
|
|
39572
|
+
tx.moveCall({
|
|
39573
|
+
target: `${this.swapPackageId}::vortex_swap::finish_swap`,
|
|
39574
|
+
arguments: [
|
|
39575
|
+
tx.object(vortexPool.objectId),
|
|
39576
|
+
coinOut,
|
|
39577
|
+
receipt,
|
|
39578
|
+
proof,
|
|
39579
|
+
extData,
|
|
39580
|
+
],
|
|
39581
|
+
typeArguments: [coinInType, vortexPool.coinType],
|
|
39582
|
+
});
|
|
39583
|
+
return { tx };
|
|
39584
|
+
}
|
|
39553
39585
|
async getVortexPool(objectId) {
|
|
39554
39586
|
const objectResponse = await __classPrivateFieldGet(this, _Vortex_suiClient, "f").getObject({
|
|
39555
39587
|
id: objectId,
|
|
@@ -39599,6 +39631,7 @@ const vortexSDK = new Vortex({
|
|
|
39599
39631
|
objectId: REGISTRY_OBJECT_ID,
|
|
39600
39632
|
initialSharedVersion: INITIAL_SHARED_VERSION,
|
|
39601
39633
|
},
|
|
39634
|
+
swapPackageId: VORTEX_SWAP_PACKAGE_ID,
|
|
39602
39635
|
fullNodeUrl: getFullnodeUrl('testnet'),
|
|
39603
39636
|
});
|
|
39604
39637
|
|
|
@@ -39611,7 +39644,6 @@ const buildMerkleTree = () => new fixedMerkleTree.MerkleTree(MERKLE_TREE_HEIGHT,
|
|
|
39611
39644
|
const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vortexSdk, vortexKeypair, vortexPool, root, getMerklePathFn, relayer, relayerFee, }) => {
|
|
39612
39645
|
const vortexObjectId = typeof vortexPool === 'string' ? vortexPool : vortexPool.objectId;
|
|
39613
39646
|
// Deposits we do not need a recipient, so we use a random one.
|
|
39614
|
-
const randomRecipient = normalizeSuiAddress(Ed25519Keypair.generate().toSuiAddress());
|
|
39615
39647
|
const randomVortexKeypair = VortexKeypair.generate();
|
|
39616
39648
|
// Determine input UTXOs
|
|
39617
39649
|
const inputUtxo0 = unspentUtxos.length > 0 && unspentUtxos[0].amount > 0n
|
|
@@ -39679,7 +39711,6 @@ const prepareDepositProof = async ({ tx, amount, accountSecret, unspentUtxos, vo
|
|
|
39679
39711
|
invariant(verify(proofJson), 'Proof verification failed');
|
|
39680
39712
|
const { extData, tx: tx2 } = vortexSdk.newExtData({
|
|
39681
39713
|
tx,
|
|
39682
|
-
recipient: randomRecipient,
|
|
39683
39714
|
value: amount,
|
|
39684
39715
|
action: exports.Action.Deposit,
|
|
39685
39716
|
relayer,
|
|
@@ -39737,7 +39768,7 @@ const deposit = async ({ tx = new Transaction(), amount, unspentUtxos = [], vort
|
|
|
39737
39768
|
});
|
|
39738
39769
|
};
|
|
39739
39770
|
|
|
39740
|
-
const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn,
|
|
39771
|
+
const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, relayer, relayerFee, vortexSdk, accountSecret, }) => {
|
|
39741
39772
|
invariant(unspentUtxos.length >= 1, 'Must have at least 1 unspent UTXO');
|
|
39742
39773
|
unspentUtxos.sort((a, b) => new bn_js.BN(b.amount).cmp(new bn_js.BN(a.amount)));
|
|
39743
39774
|
const totalUnspentUtxosAmount = unspentUtxos
|
|
@@ -39807,7 +39838,6 @@ const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos =
|
|
|
39807
39838
|
invariant(verify(proofJson), 'Proof verification failed');
|
|
39808
39839
|
const { extData, tx: tx2 } = vortexSdk.newExtData({
|
|
39809
39840
|
tx,
|
|
39810
|
-
recipient,
|
|
39811
39841
|
value: amount,
|
|
39812
39842
|
action: exports.Action.Withdraw,
|
|
39813
39843
|
relayer: normalizeSuiAddress(relayer),
|
|
@@ -39835,7 +39865,7 @@ const prepareWithdraw = async ({ tx = new Transaction(), amount, unspentUtxos =
|
|
|
39835
39865
|
};
|
|
39836
39866
|
};
|
|
39837
39867
|
|
|
39838
|
-
const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn,
|
|
39868
|
+
const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, relayer, relayerFee, vortexSdk, }) => {
|
|
39839
39869
|
const { tx: tx3, moveProof, extData, vortexPool: pool, } = await prepareWithdraw({
|
|
39840
39870
|
tx,
|
|
39841
39871
|
amount,
|
|
@@ -39844,7 +39874,6 @@ const withdraw = async ({ tx = new Transaction(), amount, unspentUtxos = [], vor
|
|
|
39844
39874
|
vortexKeypair,
|
|
39845
39875
|
root,
|
|
39846
39876
|
getMerklePathFn,
|
|
39847
|
-
recipient,
|
|
39848
39877
|
relayer,
|
|
39849
39878
|
relayerFee,
|
|
39850
39879
|
vortexSdk,
|
|
@@ -39892,7 +39921,7 @@ const depositWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], v
|
|
|
39892
39921
|
});
|
|
39893
39922
|
};
|
|
39894
39923
|
|
|
39895
|
-
const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn,
|
|
39924
|
+
const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [], vortexPool, vortexKeypair, root, getMerklePathFn, relayer, relayerFee, vortexSdk, account, accountSecret, amount, }) => {
|
|
39896
39925
|
const { tx: tx3, moveProof, extData, vortexPool: pool, } = await prepareWithdraw({
|
|
39897
39926
|
tx,
|
|
39898
39927
|
amount,
|
|
@@ -39901,7 +39930,6 @@ const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [],
|
|
|
39901
39930
|
vortexKeypair,
|
|
39902
39931
|
root,
|
|
39903
39932
|
getMerklePathFn,
|
|
39904
|
-
recipient,
|
|
39905
39933
|
relayer,
|
|
39906
39934
|
relayerFee,
|
|
39907
39935
|
vortexSdk,
|
|
@@ -39917,6 +39945,56 @@ const withdrawWithAccount = async ({ tx = new Transaction(), unspentUtxos = [],
|
|
|
39917
39945
|
});
|
|
39918
39946
|
};
|
|
39919
39947
|
|
|
39948
|
+
const startSwap = async ({ tx = new Transaction(), amount, vortexPool, unspentUtxos, vortexKeypair, root, getMerklePathFn, relayer, minAmountOut, vortexSdk, coinOutType, }) => {
|
|
39949
|
+
const { tx: tx2, moveProof, extData, vortexPool: pool, } = await prepareWithdraw({
|
|
39950
|
+
tx,
|
|
39951
|
+
amount,
|
|
39952
|
+
vortexPool,
|
|
39953
|
+
unspentUtxos,
|
|
39954
|
+
vortexKeypair,
|
|
39955
|
+
root,
|
|
39956
|
+
getMerklePathFn,
|
|
39957
|
+
relayer,
|
|
39958
|
+
relayerFee: 0n,
|
|
39959
|
+
vortexSdk,
|
|
39960
|
+
accountSecret: 0n,
|
|
39961
|
+
});
|
|
39962
|
+
return vortexSdk.startSwap({
|
|
39963
|
+
tx: tx2,
|
|
39964
|
+
vortex: pool,
|
|
39965
|
+
proof: moveProof,
|
|
39966
|
+
extData,
|
|
39967
|
+
relayer,
|
|
39968
|
+
minAmountOut,
|
|
39969
|
+
coinOutType,
|
|
39970
|
+
});
|
|
39971
|
+
};
|
|
39972
|
+
const finishSwap = async ({ tx = new Transaction(), amount, vortexSdk, vortexPool, vortexKeypair, root, getMerklePathFn, unspentUtxos, coinOut, receipt, coinInType, }) => {
|
|
39973
|
+
const accountSecret = 0n;
|
|
39974
|
+
const { extData, tx: tx3, moveProof, } = await prepareDepositProof({
|
|
39975
|
+
tx,
|
|
39976
|
+
amount,
|
|
39977
|
+
accountSecret,
|
|
39978
|
+
unspentUtxos: unspentUtxos ?? [],
|
|
39979
|
+
vortexSdk,
|
|
39980
|
+
vortexKeypair,
|
|
39981
|
+
vortexPool,
|
|
39982
|
+
root,
|
|
39983
|
+
getMerklePathFn,
|
|
39984
|
+
relayer: normalizeSuiAddress('0x0'),
|
|
39985
|
+
relayerFee: 0n,
|
|
39986
|
+
});
|
|
39987
|
+
return vortexSdk.finishSwap({
|
|
39988
|
+
tx: tx3,
|
|
39989
|
+
vortex: vortexPool,
|
|
39990
|
+
coinOut: coinOut,
|
|
39991
|
+
proof: moveProof,
|
|
39992
|
+
extData,
|
|
39993
|
+
receipt,
|
|
39994
|
+
coinInType,
|
|
39995
|
+
});
|
|
39996
|
+
};
|
|
39997
|
+
|
|
39920
39998
|
exports.BASIS_POINTS = BASIS_POINTS;
|
|
39921
39999
|
exports.BN254_FIELD_MODULUS = BN254_FIELD_MODULUS;
|
|
39922
40000
|
exports.DEPOSIT_FEE_IN_BASIS_POINTS = DEPOSIT_FEE_IN_BASIS_POINTS;
|
|
@@ -39931,17 +40009,20 @@ exports.OPT = OPT;
|
|
|
39931
40009
|
exports.REGISTRY_OBJECT_ID = REGISTRY_OBJECT_ID;
|
|
39932
40010
|
exports.ROOT_HISTORY_SIZE = ROOT_HISTORY_SIZE;
|
|
39933
40011
|
exports.TREASURY_ADDRESS = TREASURY_ADDRESS;
|
|
39934
|
-
exports.UPGRADE_CAP = UPGRADE_CAP;
|
|
39935
40012
|
exports.Utxo = Utxo;
|
|
39936
40013
|
exports.VORTEX_PACKAGE_ID = VORTEX_PACKAGE_ID;
|
|
39937
40014
|
exports.VORTEX_POOL_IDS = VORTEX_POOL_IDS;
|
|
39938
40015
|
exports.VORTEX_SIGNATURE_DOMAIN = VORTEX_SIGNATURE_DOMAIN;
|
|
40016
|
+
exports.VORTEX_SWAP_PACKAGE_ID = VORTEX_SWAP_PACKAGE_ID;
|
|
40017
|
+
exports.VORTEX_SWAP_UPGRADE_CAP = VORTEX_SWAP_UPGRADE_CAP;
|
|
40018
|
+
exports.VORTEX_UPGRADE_CAP = VORTEX_UPGRADE_CAP;
|
|
39939
40019
|
exports.Vortex = Vortex;
|
|
39940
40020
|
exports.VortexKeypair = VortexKeypair;
|
|
39941
40021
|
exports.ZERO_VALUE = ZERO_VALUE;
|
|
39942
40022
|
exports.buildMerkleTree = buildMerkleTree;
|
|
39943
40023
|
exports.deposit = deposit;
|
|
39944
40024
|
exports.depositWithAccount = depositWithAccount;
|
|
40025
|
+
exports.finishSwap = finishSwap;
|
|
39945
40026
|
exports.getMerklePath = getMerklePath;
|
|
39946
40027
|
exports.getUnspentUtxos = getUnspentUtxos;
|
|
39947
40028
|
exports.parseNewCommitmentEvent = parseNewCommitmentEvent;
|
|
@@ -39951,6 +40032,7 @@ exports.poseidon2 = poseidon2;
|
|
|
39951
40032
|
exports.poseidon3 = poseidon3;
|
|
39952
40033
|
exports.poseidon4 = poseidon4;
|
|
39953
40034
|
exports.prove = prove;
|
|
40035
|
+
exports.startSwap = startSwap;
|
|
39954
40036
|
exports.toProveInput = toProveInput;
|
|
39955
40037
|
exports.verify = verify;
|
|
39956
40038
|
exports.vortexSDK = vortexSDK;
|