@verified-network/verified-sdk 1.1.7 → 1.1.8
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/abi/assetmanager/Vault.json +1181 -1179
- package/dist/abi/assetmanager/balancer/MarginIssueManager.json +5765 -5765
- package/dist/abi/assetmanager/balancer/PrimaryIssueManager.json +14879 -14520
- package/dist/abi/assetmanager/balancer/SecondaryIssueManager.json +8377 -8377
- package/dist/abi/distribution/Distribution.json +3 -3
- package/dist/abi/liquidity/Liquidity.json +6339 -6325
- package/dist/abi/securities/Client.json +248 -248
- package/dist/abi/securities/SecuritiesFactory.json +2060 -2060
- package/dist/abi/securities/Security.json +5495 -5339
- package/dist/contract/pool/index.js +78 -3
- package/dist/contractAddress/index.js +11 -10
- package/package.json +2 -1
|
@@ -1,18 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// SPDX-License-Identifier: BUSL-1.1
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
4
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
8
|
const index_1 = require("../index");
|
|
6
9
|
const Vault_json_1 = require("../../abi/assetmanager/Vault.json");
|
|
10
|
+
const contractAddress_1 = __importDefault(require("../../contractAddress"));
|
|
7
11
|
var FUNCTIONS;
|
|
8
12
|
(function (FUNCTIONS) {
|
|
9
|
-
FUNCTIONS["
|
|
13
|
+
FUNCTIONS["BATCHSWAP"] = "batchSwap";
|
|
14
|
+
FUNCTIONS["SINGLESWAP"] = "swap";
|
|
15
|
+
FUNCTIONS["GETPOOLTOKENS"] = "getPoolTokens";
|
|
10
16
|
})(FUNCTIONS || (FUNCTIONS = {}));
|
|
11
17
|
class PoolContract extends index_1.VerifiedContract {
|
|
12
|
-
constructor(signer
|
|
13
|
-
const address =
|
|
18
|
+
constructor(signer) {
|
|
19
|
+
const address = contractAddress_1.default['balancerVault'];
|
|
14
20
|
super(address, JSON.stringify(Vault_json_1.abi), signer);
|
|
15
21
|
this.contractAddress = address;
|
|
16
22
|
}
|
|
23
|
+
//API below for single and batch swaps, and price and volume data from verified subgraphs for pool
|
|
24
|
+
/**
|
|
25
|
+
* API to perform Balancer Batch swap
|
|
26
|
+
* @params (string _poolId,)
|
|
27
|
+
* @returns {address[] memory}
|
|
28
|
+
*/
|
|
29
|
+
async batchSwap(_poolId, _swapType, _limitAmount, _assetIn, _assetOut, _amount, _account, options) {
|
|
30
|
+
await this.validateInput(index_1.DATATYPES.STRING, _poolId);
|
|
31
|
+
await this.validateInput(index_1.DATATYPES.STRING, _swapType);
|
|
32
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _limitAmount);
|
|
33
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _amount);
|
|
34
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _account);
|
|
35
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _assetIn);
|
|
36
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _assetOut);
|
|
37
|
+
const poolTokens = (await this.fetchPoolTokens(_poolId)).response.result[0];
|
|
38
|
+
const _assetInIndex = poolTokens.findIndex(address => address.toLowerCase() === _assetIn.toLowerCase());
|
|
39
|
+
const _assetOutIndex = poolTokens.findIndex(address => address.toLowerCase() === _assetOut.toLowerCase());
|
|
40
|
+
let limitArr = new Array(3).fill(0);
|
|
41
|
+
limitArr[_assetInIndex] = _limitAmount;
|
|
42
|
+
// Where are the tokens coming from/going to?
|
|
43
|
+
const fund_struct = {
|
|
44
|
+
"sender": _account,
|
|
45
|
+
"recipient": _account,
|
|
46
|
+
"fromInternalBalance": false,
|
|
47
|
+
"toInternalBalance": false
|
|
48
|
+
};
|
|
49
|
+
// When should the transaction timeout?
|
|
50
|
+
const deadline = "999999999999999999";
|
|
51
|
+
const swap_step_struct = [{
|
|
52
|
+
poolId: _poolId,
|
|
53
|
+
assetInIndex: _assetInIndex,
|
|
54
|
+
assetOutIndex: _assetOutIndex,
|
|
55
|
+
amount: _amount,
|
|
56
|
+
userData: '0x'
|
|
57
|
+
}];
|
|
58
|
+
const swapKind = _swapType === "Sell" ? 0 : 1;
|
|
59
|
+
return this.callContract(FUNCTIONS.BATCHSWAP, swapKind, swap_step_struct, poolTokens, fund_struct, limitArr, deadline, options);
|
|
60
|
+
}
|
|
61
|
+
async singleSwap(_poolId, _swapType, _assetIn, _assetOut, _limitAmount, _amount, _account, options) {
|
|
62
|
+
await this.validateInput(index_1.DATATYPES.STRING, _poolId);
|
|
63
|
+
await this.validateInput(index_1.DATATYPES.STRING, _swapType);
|
|
64
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _assetIn);
|
|
65
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _assetOut);
|
|
66
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _limitAmount);
|
|
67
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _amount);
|
|
68
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, _account);
|
|
69
|
+
const swapKind = _swapType === "Sell" ? 0 : 1;
|
|
70
|
+
// Where are the tokens coming from/going to?
|
|
71
|
+
const fund_struct = {
|
|
72
|
+
"sender": _account,
|
|
73
|
+
"recipient": _account,
|
|
74
|
+
"fromInternalBalance": false,
|
|
75
|
+
"toInternalBalance": false
|
|
76
|
+
};
|
|
77
|
+
// When should the transaction timeout?
|
|
78
|
+
const deadline = "999999999999999999";
|
|
79
|
+
const swap_struct = {
|
|
80
|
+
poolId: _poolId,
|
|
81
|
+
kind: swapKind,
|
|
82
|
+
assetIn: _assetIn,
|
|
83
|
+
assetOut: _assetOut,
|
|
84
|
+
amount: _amount,
|
|
85
|
+
userData: '0x'
|
|
86
|
+
};
|
|
87
|
+
return this.callContract(FUNCTIONS.SINGLESWAP, swap_struct, fund_struct, _limitAmount, deadline, options);
|
|
88
|
+
}
|
|
89
|
+
async fetchPoolTokens(_poolId, options) {
|
|
90
|
+
return this.callContract(FUNCTIONS.GETPOOLTOKENS, _poolId, options);
|
|
91
|
+
}
|
|
17
92
|
}
|
|
18
93
|
exports.default = PoolContract;
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const contractAddress = {
|
|
4
4
|
5: {
|
|
5
|
-
'Client': '
|
|
5
|
+
'Client': '0x3e132ee9fc32428655b2151A4E6C3f2B1FD49923',
|
|
6
6
|
'Factory': '0x4c74BB3B701Ad556bEC623228555e363923d7d7f',
|
|
7
7
|
'Cash': '0x8e0eF99e187d99f38ed8c4f65c0eE5b9e8FC7304',
|
|
8
8
|
'Bond': '0xf9f1715dC1512693C03F8767Cbc9C39d84ffD93a',
|
|
9
9
|
'Token': '0x5f22708f8Ed8622E1E5296c99215c56fDc5f1C04',
|
|
10
10
|
'Oracle': '0x0Ae1A4711d7bAe34865A9Bf1A69C4243b89ac073',
|
|
11
11
|
'Rates': '0xC805B6D74d17c9DD2dA508AbeA90a1b9bCC2344c',
|
|
12
|
-
'Security': '
|
|
13
|
-
'SecuritiesFactory': '
|
|
14
|
-
'Vitta': '
|
|
15
|
-
'Liquidity': '
|
|
16
|
-
'Distribution': '
|
|
17
|
-
'BalancerPrimaryIssueManager': '
|
|
18
|
-
'BalancerSecondaryIssueManager': '
|
|
19
|
-
'BalancerMarginIssueManager': '
|
|
12
|
+
'Security': '0x93527FaeCD88c108C3Fb78a1Ca72536eeb1Adbf7',
|
|
13
|
+
'SecuritiesFactory': '0x647a7EA364a31fa18c65f4043CD55718d245D774',
|
|
14
|
+
'Vitta': '0x28eF2E4b593d347B106E768966637deE53C5C99c',
|
|
15
|
+
'Liquidity': '0xc3ca9B6406564F84284d27364C5f770b799247C1',
|
|
16
|
+
'Distribution': '0x9Fe25dDe1b4C0A1Ea5de4A523cF17740793E7889',
|
|
17
|
+
'BalancerPrimaryIssueManager': '0x7bA391843372E503dDE48A5A58356a105D94B3c1',
|
|
18
|
+
'BalancerSecondaryIssueManager': '0x40DBb9084B817DB8417A5Fb45159d95Fe915FD74',
|
|
19
|
+
'BalancerMarginIssueManager': '0x94Fc9264304d46518d7A39946F80B55cA569b403',
|
|
20
20
|
'Custody': '0x60aEDad13a34b1DC45bDeA9eD6a66d639563e917',
|
|
21
21
|
'CASH': {
|
|
22
22
|
'VCUSD': '0xcd9e67b873Cf50eeb1Dc08b95a29782a5f108f1A',
|
|
@@ -240,6 +240,7 @@ const contractAddress = {
|
|
|
240
240
|
'VCCHF': '0x8eE273Ac39C83EF01e3Df73d15B562a9056B03Bd',
|
|
241
241
|
'VBINR': '0xd9b9A355Baf5FC1467118306e1C82732771eD140'
|
|
242
242
|
},
|
|
243
|
-
}
|
|
243
|
+
},
|
|
244
|
+
'balancerVault': '0xBA12222222228d8Ba445958a75a0704d566BF2C8'
|
|
244
245
|
};
|
|
245
246
|
exports.default = contractAddress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verified-network/verified-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "An SDK to develop applications on the Verified Network",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"greet": "./bin/index.bin.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"ethereumjs-tx": "^2.1.2",
|
|
34
35
|
"ethers": "^5.0.31"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|