@verified-network/verified-sdk 1.4.2 → 1.4.3
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/.env +2 -2
- package/dist/contract/pool/index.js +33 -66
- package/package.json +1 -1
package/.env
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
BUNDLER_URL_FIRST_SECTION="https://bundler.biconomy.io/api/v2"
|
|
2
2
|
BUNDLER_URL_SECTION_SECTION="nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44"
|
|
3
3
|
GENERAL_PAYMASTER_URL="https://paymaster.biconomy.io/api/v1"
|
|
4
|
-
5_PAYMASTER_API_KEY="Al_uud9et.0420c6d3-2343-4fca-9022-c8c8b648444b"
|
|
4
|
+
# 5_PAYMASTER_API_KEY="Al_uud9et.0420c6d3-2343-4fca-9022-c8c8b648444b" //goerli(chainid 5) not working with biconomy
|
|
5
5
|
80001_PAYMASTER_API_KEY="aT9H1rhpM.d1ed09ff-0e2e-4a94-95ef-fdc18422eb41"
|
|
6
|
-
5_CASH_TOKEN_ADDRESS="0x07865c6E87B9F70255377e024ace6630C1Eaa37F"
|
|
6
|
+
# 5_CASH_TOKEN_ADDRESS="0x07865c6E87B9F70255377e024ace6630C1Eaa37F" //goerli(chainid 5) not workith biconomy
|
|
7
7
|
80001_CASH_TOKEN_ADDRESS="0xda5289fcaaf71d52a80a254da614a192b693e977"
|
|
8
8
|
BICONOMY_REVERT_TOPIC="0x1c4fada7374c0a9ee8841fc38afe82932dc0f8e69012e927f061a8bae611a201"
|
|
@@ -10,8 +10,8 @@ const Vault_json_1 = require("../../abi/assetmanager/Vault.json");
|
|
|
10
10
|
const contractAddress_1 = __importDefault(require("../../contractAddress"));
|
|
11
11
|
var FUNCTIONS;
|
|
12
12
|
(function (FUNCTIONS) {
|
|
13
|
+
FUNCTIONS["SWAP"] = "swap";
|
|
13
14
|
FUNCTIONS["BATCHSWAP"] = "batchSwap";
|
|
14
|
-
FUNCTIONS["SINGLESWAP"] = "swap";
|
|
15
15
|
FUNCTIONS["GETPOOLTOKENS"] = "getPoolTokens";
|
|
16
16
|
})(FUNCTIONS || (FUNCTIONS = {}));
|
|
17
17
|
class PoolContract extends index_1.VerifiedContract {
|
|
@@ -20,73 +20,40 @@ class PoolContract extends index_1.VerifiedContract {
|
|
|
20
20
|
super(address, JSON.stringify(Vault_json_1.abi), signer);
|
|
21
21
|
this.contractAddress = address;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
await this.validateInput(index_1.DATATYPES.
|
|
31
|
-
await this.validateInput(index_1.DATATYPES.
|
|
32
|
-
await this.validateInput(index_1.DATATYPES.NUMBER,
|
|
33
|
-
await this.validateInput(index_1.DATATYPES.NUMBER,
|
|
34
|
-
|
|
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);
|
|
23
|
+
async swap(_swap, _funds, _limit, _deadline, options) {
|
|
24
|
+
const { poolId, kind, assetIn, assetOut, amount, userData } = _swap;
|
|
25
|
+
const { sender, fromInternalBalance, recipient, toInternalBalance } = _funds;
|
|
26
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, kind);
|
|
27
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, assetIn);
|
|
28
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, assetOut);
|
|
29
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, amount);
|
|
30
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, sender);
|
|
31
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, recipient);
|
|
32
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _limit);
|
|
33
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _deadline);
|
|
34
|
+
return this.callContract(FUNCTIONS.SWAP, _swap, _funds, _limit, _deadline, options);
|
|
60
35
|
}
|
|
61
|
-
async
|
|
62
|
-
await this.validateInput(index_1.DATATYPES.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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);
|
|
36
|
+
async batchSwap(_kind, _swaps, _assests, _funds, _limits, _deadline, options) {
|
|
37
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _kind);
|
|
38
|
+
_swaps.map(async (swp) => {
|
|
39
|
+
const { poolId, assetInIndex, assetOutIndex, amount, userData } = swp;
|
|
40
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, assetInIndex);
|
|
41
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, assetOutIndex);
|
|
42
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, amount);
|
|
43
|
+
});
|
|
44
|
+
_assests.map(async (asst) => {
|
|
45
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, asst);
|
|
46
|
+
});
|
|
47
|
+
const { sender, fromInternalBalance, recipient, toInternalBalance } = _funds;
|
|
48
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, sender);
|
|
49
|
+
await this.validateInput(index_1.DATATYPES.ADDRESS, recipient);
|
|
50
|
+
_limits.map(async (lmt) => {
|
|
51
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, lmt);
|
|
52
|
+
});
|
|
53
|
+
await this.validateInput(index_1.DATATYPES.NUMBER, _deadline);
|
|
54
|
+
return this.callContract(FUNCTIONS.BATCHSWAP, _kind, _swaps, _assests, _funds, _limits, _deadline, options);
|
|
88
55
|
}
|
|
89
|
-
async
|
|
56
|
+
async getPoolTokens(_poolId, options) {
|
|
90
57
|
return this.callContract(FUNCTIONS.GETPOOLTOKENS, _poolId, options);
|
|
91
58
|
}
|
|
92
59
|
}
|