@ichidao/ichi-vaults-sdk 0.1.43 → 2.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/README.md +61 -208
- package/dist/abis/types/AlgebraIntegralPool.d.ts +702 -793
- package/dist/abis/types/AlgebraPool.d.ts +693 -730
- package/dist/abis/types/ClPool.d.ts +789 -871
- package/dist/abis/types/DepositGuard.d.ts +193 -178
- package/dist/abis/types/DepositGuardWithHtsWrapping.d.ts +300 -297
- package/dist/abis/types/ERC20.d.ts +120 -147
- package/dist/abis/types/ERC20Wrapper.d.ts +147 -155
- package/dist/abis/types/IchiVault.d.ts +598 -728
- package/dist/abis/types/MultiFeeDistributer.d.ts +314 -423
- package/dist/abis/types/Multicall.d.ts +58 -73
- package/dist/abis/types/UniswapV3Pool.d.ts +654 -693
- package/dist/abis/types/common.d.ts +40 -12
- package/dist/abis/types/factories/AlgebraIntegralPool__factory.d.ts +2 -3
- package/dist/abis/types/factories/AlgebraIntegralPool__factory.js +10 -13
- package/dist/abis/types/factories/AlgebraIntegralPool__factory.js.map +1 -1
- package/dist/abis/types/factories/AlgebraPool__factory.d.ts +2 -3
- package/dist/abis/types/factories/AlgebraPool__factory.js +10 -13
- package/dist/abis/types/factories/AlgebraPool__factory.js.map +1 -1
- package/dist/abis/types/factories/ClPool__factory.d.ts +2 -3
- package/dist/abis/types/factories/ClPool__factory.js +10 -13
- package/dist/abis/types/factories/ClPool__factory.js.map +1 -1
- package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.d.ts +2 -3
- package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.js +10 -13
- package/dist/abis/types/factories/DepositGuardWithHtsWrapping__factory.js.map +1 -1
- package/dist/abis/types/factories/DepositGuard__factory.d.ts +2 -3
- package/dist/abis/types/factories/DepositGuard__factory.js +10 -13
- package/dist/abis/types/factories/DepositGuard__factory.js.map +1 -1
- package/dist/abis/types/factories/ERC20Wrapper__factory.d.ts +2 -3
- package/dist/abis/types/factories/ERC20Wrapper__factory.js +10 -13
- package/dist/abis/types/factories/ERC20Wrapper__factory.js.map +1 -1
- package/dist/abis/types/factories/ERC20__factory.d.ts +2 -3
- package/dist/abis/types/factories/ERC20__factory.js +10 -13
- package/dist/abis/types/factories/ERC20__factory.js.map +1 -1
- package/dist/abis/types/factories/IchiVault__factory.d.ts +2 -3
- package/dist/abis/types/factories/IchiVault__factory.js +10 -13
- package/dist/abis/types/factories/IchiVault__factory.js.map +1 -1
- package/dist/abis/types/factories/MultiFeeDistributer__factory.d.ts +2 -3
- package/dist/abis/types/factories/MultiFeeDistributer__factory.js +10 -13
- package/dist/abis/types/factories/MultiFeeDistributer__factory.js.map +1 -1
- package/dist/abis/types/factories/Multicall__factory.d.ts +2 -3
- package/dist/abis/types/factories/Multicall__factory.js +10 -13
- package/dist/abis/types/factories/Multicall__factory.js.map +1 -1
- package/dist/abis/types/factories/UniswapV3Pool__factory.d.ts +2 -3
- package/dist/abis/types/factories/UniswapV3Pool__factory.js +10 -13
- package/dist/abis/types/factories/UniswapV3Pool__factory.js.map +1 -1
- package/dist/src/__tests__/index.test.js +356 -738
- package/dist/src/__tests__/index.test.js.map +1 -1
- package/dist/src/abis/types/AlgebraIntegralPool.d.ts +702 -793
- package/dist/src/abis/types/AlgebraPool.d.ts +693 -730
- package/dist/src/abis/types/ClPool.d.ts +789 -871
- package/dist/src/abis/types/DepositGuard.d.ts +193 -178
- package/dist/src/abis/types/DepositGuardWithHtsWrapping.d.ts +300 -297
- package/dist/src/abis/types/ERC20.d.ts +120 -147
- package/dist/src/abis/types/ERC20Wrapper.d.ts +147 -155
- package/dist/src/abis/types/IchiVault.d.ts +598 -728
- package/dist/src/abis/types/MultiFeeDistributer.d.ts +314 -423
- package/dist/src/abis/types/Multicall.d.ts +58 -73
- package/dist/src/abis/types/UniswapV3Pool.d.ts +654 -693
- package/dist/src/abis/types/common.d.ts +40 -12
- package/dist/src/abis/types/factories/AlgebraIntegralPool__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/AlgebraPool__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/ClPool__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/DepositGuardWithHtsWrapping__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/DepositGuard__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/ERC20Wrapper__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/ERC20__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/IchiVault__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/MultiFeeDistributer__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/Multicall__factory.d.ts +2 -3
- package/dist/src/abis/types/factories/UniswapV3Pool__factory.d.ts +2 -3
- package/dist/src/contracts/index.d.ts +1 -1
- package/dist/src/contracts/index.js +12 -12
- package/dist/src/contracts/index.js.map +1 -1
- package/dist/src/functions/_totalBalances.d.ts +2 -3
- package/dist/src/functions/_totalBalances.js +46 -117
- package/dist/src/functions/_totalBalances.js.map +1 -1
- package/dist/src/functions/_vaultEvents.js +347 -488
- package/dist/src/functions/_vaultEvents.js.map +1 -1
- package/dist/src/functions/_withdrawHelpers.d.ts +2 -3
- package/dist/src/functions/_withdrawHelpers.js +13 -62
- package/dist/src/functions/_withdrawHelpers.js.map +1 -1
- package/dist/src/functions/calculateApr.d.ts +1 -1
- package/dist/src/functions/calculateApr.js +77 -150
- package/dist/src/functions/calculateApr.js.map +1 -1
- package/dist/src/functions/calculateDtr.d.ts +1 -1
- package/dist/src/functions/calculateDtr.js +84 -169
- package/dist/src/functions/calculateDtr.js.map +1 -1
- package/dist/src/functions/calculateFees.d.ts +1 -1
- package/dist/src/functions/calculateFees.js +97 -172
- package/dist/src/functions/calculateFees.js.map +1 -1
- package/dist/src/functions/chains.js +6 -6
- package/dist/src/functions/chains.js.map +1 -1
- package/dist/src/functions/claimRewards.d.ts +3 -4
- package/dist/src/functions/claimRewards.js +29 -92
- package/dist/src/functions/claimRewards.js.map +1 -1
- package/dist/src/functions/deposit.d.ts +7 -9
- package/dist/src/functions/deposit.js +199 -364
- package/dist/src/functions/deposit.js.map +1 -1
- package/dist/src/functions/depositWithHtsWrapping.d.ts +4 -6
- package/dist/src/functions/depositWithHtsWrapping.js +109 -226
- package/dist/src/functions/depositWithHtsWrapping.js.map +1 -1
- package/dist/src/functions/getFeeAprs.d.ts +1 -1
- package/dist/src/functions/getFeeAprs.js +55 -111
- package/dist/src/functions/getFeeAprs.js.map +1 -1
- package/dist/src/functions/priceFromPool.d.ts +3 -4
- package/dist/src/functions/priceFromPool.js +99 -208
- package/dist/src/functions/priceFromPool.js.map +1 -1
- package/dist/src/functions/rewardInfo.js +79 -159
- package/dist/src/functions/rewardInfo.js.map +1 -1
- package/dist/src/functions/totalBalances.d.ts +2 -3
- package/dist/src/functions/totalBalances.js +14 -67
- package/dist/src/functions/totalBalances.js.map +1 -1
- package/dist/src/functions/userBalances.d.ts +2 -3
- package/dist/src/functions/userBalances.js +244 -368
- package/dist/src/functions/userBalances.js.map +1 -1
- package/dist/src/functions/userRewards.d.ts +1 -1
- package/dist/src/functions/userRewards.js +87 -145
- package/dist/src/functions/userRewards.js.map +1 -1
- package/dist/src/functions/vault.d.ts +1 -1
- package/dist/src/functions/vault.js +203 -383
- package/dist/src/functions/vault.js.map +1 -1
- package/dist/src/functions/vaultBasics.js +6 -7
- package/dist/src/functions/vaultBasics.js.map +1 -1
- package/dist/src/functions/vaultMetrics.d.ts +1 -1
- package/dist/src/functions/vaultMetrics.js +111 -189
- package/dist/src/functions/vaultMetrics.js.map +1 -1
- package/dist/src/functions/vaultPositions.d.ts +1 -1
- package/dist/src/functions/vaultPositions.js +69 -134
- package/dist/src/functions/vaultPositions.js.map +1 -1
- package/dist/src/functions/vaultTvl.d.ts +1 -1
- package/dist/src/functions/vaultTvl.js +80 -165
- package/dist/src/functions/vaultTvl.js.map +1 -1
- package/dist/src/functions/withdraw.d.ts +6 -8
- package/dist/src/functions/withdraw.js +165 -295
- package/dist/src/functions/withdraw.js.map +1 -1
- package/dist/src/functions/withdrawWithErc20Wrapping.d.ts +2 -4
- package/dist/src/functions/withdrawWithErc20Wrapping.js +59 -126
- package/dist/src/functions/withdrawWithErc20Wrapping.js.map +1 -1
- package/dist/src/graphql/constants.js +211 -212
- package/dist/src/graphql/constants.js.map +1 -1
- package/dist/src/graphql/functions.js +30 -102
- package/dist/src/graphql/functions.js.map +1 -1
- package/dist/src/graphql/queries.js +407 -42
- package/dist/src/graphql/queries.js.map +1 -1
- package/dist/src/index.cjs.js +2 -2
- package/dist/src/index.esm.js +2 -2
- package/dist/src/src/contracts/index.d.ts +1 -1
- package/dist/src/src/functions/_totalBalances.d.ts +2 -3
- package/dist/src/src/functions/_withdrawHelpers.d.ts +2 -3
- package/dist/src/src/functions/calculateApr.d.ts +1 -1
- package/dist/src/src/functions/calculateDtr.d.ts +1 -1
- package/dist/src/src/functions/calculateFees.d.ts +1 -1
- package/dist/src/src/functions/claimRewards.d.ts +3 -4
- package/dist/src/src/functions/deposit.d.ts +7 -9
- package/dist/src/src/functions/depositWithHtsWrapping.d.ts +4 -6
- package/dist/src/src/functions/getFeeAprs.d.ts +1 -1
- package/dist/src/src/functions/priceFromPool.d.ts +3 -4
- package/dist/src/src/functions/totalBalances.d.ts +2 -3
- package/dist/src/src/functions/userBalances.d.ts +2 -3
- package/dist/src/src/functions/userRewards.d.ts +1 -1
- package/dist/src/src/functions/vault.d.ts +1 -1
- package/dist/src/src/functions/vaultMetrics.d.ts +1 -1
- package/dist/src/src/functions/vaultPositions.d.ts +1 -1
- package/dist/src/src/functions/vaultTvl.d.ts +1 -1
- package/dist/src/src/functions/withdraw.d.ts +6 -8
- package/dist/src/src/functions/withdrawWithErc20Wrapping.d.ts +2 -4
- package/dist/src/src/types/calculateGasMargin.d.ts +1 -2
- package/dist/src/src/types/index.d.ts +11 -13
- package/dist/src/src/utils/amountWithSlippage.d.ts +1 -2
- package/dist/src/src/utils/config/addresses.d.ts +1 -1
- package/dist/src/src/utils/formatBigInt.d.ts +1 -2
- package/dist/src/src/utils/getPrice.d.ts +1 -2
- package/dist/src/src/utils/multicallUtils.d.ts +9 -10
- package/dist/src/src/utils/parseBigInt.d.ts +1 -2
- package/dist/src/types/calculateGasMargin.d.ts +1 -2
- package/dist/src/types/calculateGasMargin.js +4 -5
- package/dist/src/types/calculateGasMargin.js.map +1 -1
- package/dist/src/types/index.d.ts +11 -13
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/utils/amountWithSlippage.d.ts +1 -2
- package/dist/src/utils/amountWithSlippage.js +1 -1
- package/dist/src/utils/amountWithSlippage.js.map +1 -1
- package/dist/src/utils/cache.js +2 -2
- package/dist/src/utils/cache.js.map +1 -1
- package/dist/src/utils/config/addresses.d.ts +1 -1
- package/dist/src/utils/config/addresses.js +267 -268
- package/dist/src/utils/config/addresses.js.map +1 -1
- package/dist/src/utils/formatBigInt.d.ts +1 -2
- package/dist/src/utils/formatBigInt.js +4 -5
- package/dist/src/utils/formatBigInt.js.map +1 -1
- package/dist/src/utils/getConfigByFactory.js +24 -28
- package/dist/src/utils/getConfigByFactory.js.map +1 -1
- package/dist/src/utils/getGraphUrls.js +8 -12
- package/dist/src/utils/getGraphUrls.js.map +1 -1
- package/dist/src/utils/getPrice.d.ts +1 -2
- package/dist/src/utils/getPrice.js +5 -6
- package/dist/src/utils/getPrice.js.map +1 -1
- package/dist/src/utils/isVelodrome.js +2 -3
- package/dist/src/utils/isVelodrome.js.map +1 -1
- package/dist/src/utils/multicallUtils.d.ts +9 -10
- package/dist/src/utils/multicallUtils.js +38 -93
- package/dist/src/utils/multicallUtils.js.map +1 -1
- package/dist/src/utils/parseBigInt.d.ts +1 -2
- package/dist/src/utils/parseBigInt.js +5 -7
- package/dist/src/utils/parseBigInt.js.map +1 -1
- package/dist/src/utils/positionKey.js +2 -4
- package/dist/src/utils/positionKey.js.map +1 -1
- package/package.json +5 -17
|
@@ -1,787 +1,405 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
3
|
/* eslint-disable no-undef */
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
-
function step(op) {
|
|
18
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
-
switch (op[0]) {
|
|
23
|
-
case 0: case 1: t = op; break;
|
|
24
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
-
default:
|
|
28
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
-
if (t[2]) _.ops.pop();
|
|
33
|
-
_.trys.pop(); continue;
|
|
34
|
-
}
|
|
35
|
-
op = body.call(thisArg, _);
|
|
36
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
6
|
};
|
|
43
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
8
|
require("dotenv/config");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var account = process.env.ACCOUNT;
|
|
60
|
-
var vault = {
|
|
61
|
-
address: '0x6b068a06a23edc1de4f63c4d421e57d71e33573d',
|
|
9
|
+
const ethers_1 = require("ethers");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const IchiVault_json_1 = __importDefault(require("../abis/IchiVault.json"));
|
|
12
|
+
const index_1 = require("../index");
|
|
13
|
+
const formatBigInt_1 = __importDefault(require("../utils/formatBigInt"));
|
|
14
|
+
const parseBigInt_1 = __importDefault(require("../utils/parseBigInt"));
|
|
15
|
+
const _totalBalances_1 = require("../functions/_totalBalances");
|
|
16
|
+
// In ethers v6, use JsonRpcProvider directly for read operations
|
|
17
|
+
// For write operations (transactions), a Wallet with the private key is needed
|
|
18
|
+
const provider = new ethers_1.JsonRpcProvider(process.env.PROVIDER_URL, types_1.SupportedChainId.hedera);
|
|
19
|
+
const wallet = new ethers_1.Wallet(process.env.PRIVATE_KEY, provider);
|
|
20
|
+
const account = process.env.ACCOUNT;
|
|
21
|
+
const vault = {
|
|
22
|
+
address: '0x4431a822e59e12cea7fa614791ae39fe8b931d0f',
|
|
62
23
|
chainId: types_1.SupportedChainId.hedera,
|
|
63
24
|
dex: types_1.SupportedDex.Bonzo,
|
|
64
25
|
};
|
|
65
|
-
|
|
66
|
-
address: '
|
|
26
|
+
const pool = {
|
|
27
|
+
address: '0xE539b14a87D3Db4a2945ac99b29A69DE61531592',
|
|
67
28
|
chainId: types_1.SupportedChainId.hedera,
|
|
68
29
|
dex: types_1.SupportedDex.Bonzo,
|
|
69
30
|
};
|
|
70
|
-
|
|
71
|
-
pairedToken: '
|
|
72
|
-
depositToken: '
|
|
31
|
+
const tokens = {
|
|
32
|
+
pairedToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
33
|
+
depositToken: '0xD302A92fb82EA59aa676Ae3d5799AC296AFa7390',
|
|
73
34
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
describe('Vault',
|
|
80
|
-
|
|
81
|
-
it.skip('getFeeAprs',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
it('
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
it('
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
vaultFromQuery = _b.sent();
|
|
250
|
-
if (!vaultFromQuery)
|
|
251
|
-
throw new Error("Vault ".concat(vault.address, " not found on chain ").concat(vault.chainId, " and dex ").concat(vault.dex, "]"));
|
|
252
|
-
return [4 /*yield*/, (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenA, provider, vault.chainId)];
|
|
253
|
-
case 6:
|
|
254
|
-
token0Decimals = _b.sent();
|
|
255
|
-
return [4 /*yield*/, (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenB, provider, vault.chainId)];
|
|
256
|
-
case 7:
|
|
257
|
-
token1Decimals = _b.sent();
|
|
258
|
-
if (!isAllowed0 && Number(amount0) > 0)
|
|
259
|
-
return [2 /*return*/];
|
|
260
|
-
if (!isAllowed1 && Number(amount1) > 0)
|
|
261
|
-
return [2 /*return*/];
|
|
262
|
-
if ((0, parseBigInt_1.default)(amount0, token0Decimals).gt(maxDeposit0) || (0, parseBigInt_1.default)(amount1, token1Decimals).gt(maxDeposit1))
|
|
263
|
-
return [2 /*return*/];
|
|
264
|
-
return [4 /*yield*/, (0, index_1.depositNativeToken)(account, amount0, amount1, vault.address, provider, vault.dex)];
|
|
265
|
-
case 8:
|
|
266
|
-
r = _b.sent();
|
|
267
|
-
return [4 /*yield*/, r.wait()];
|
|
268
|
-
case 9:
|
|
269
|
-
a = _b.sent();
|
|
270
|
-
result = (_a = a.logs
|
|
271
|
-
.map(function (e) {
|
|
272
|
-
try {
|
|
273
|
-
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
274
|
-
return iface.parseLog(e);
|
|
275
|
-
}
|
|
276
|
-
catch (error) {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
.find(function (e) { return e && e.name === 'Deposit'; })) === null || _a === void 0 ? void 0 : _a.args;
|
|
281
|
-
console.log('Deposit:', result);
|
|
282
|
-
share = (0, formatBigInt_1.default)(result.shares);
|
|
283
|
-
console.log('Deposit share:', share);
|
|
284
|
-
return [2 /*return*/];
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}); });
|
|
288
|
-
it.skip('depositWithHtsWrapping', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
|
-
var isAllowed0, isAllowed1, vaultFromQuery, token0Decimals, token1Decimals, r, a, result;
|
|
290
|
-
var _a;
|
|
291
|
-
return __generator(this, function (_b) {
|
|
292
|
-
switch (_b.label) {
|
|
293
|
-
case 0: return [4 /*yield*/, (0, index_1.isTokenAllowed)(0, vault.address, provider, vault.dex)];
|
|
294
|
-
case 1:
|
|
295
|
-
isAllowed0 = _b.sent();
|
|
296
|
-
return [4 /*yield*/, (0, index_1.isTokenAllowed)(1, vault.address, provider, vault.dex)];
|
|
297
|
-
case 2:
|
|
298
|
-
isAllowed1 = _b.sent();
|
|
299
|
-
console.log({ isAllowed0: isAllowed0 }, { isAllowed1: isAllowed1 });
|
|
300
|
-
return [4 /*yield*/, (0, index_1.getIchiVaultInfo)(vault.chainId, vault.dex, vault.address, provider)];
|
|
301
|
-
case 3:
|
|
302
|
-
vaultFromQuery = _b.sent();
|
|
303
|
-
if (!vaultFromQuery)
|
|
304
|
-
throw new Error("Vault ".concat(vault.address, " not found on chain ").concat(vault.chainId, " and dex ").concat(vault.dex, "]"));
|
|
305
|
-
return [4 /*yield*/, (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenA, provider, vault.chainId)];
|
|
306
|
-
case 4:
|
|
307
|
-
token0Decimals = _b.sent();
|
|
308
|
-
return [4 /*yield*/, (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenB, provider, vault.chainId)];
|
|
309
|
-
case 5:
|
|
310
|
-
token1Decimals = _b.sent();
|
|
311
|
-
if (!isAllowed0 && Number(amount0) > 0)
|
|
312
|
-
return [2 /*return*/];
|
|
313
|
-
if (!isAllowed1 && Number(amount1) > 0)
|
|
314
|
-
return [2 /*return*/];
|
|
315
|
-
return [4 /*yield*/, (0, index_1.depositWithHtsWrapping)(account, amount0, amount1, vault.address, provider, vault.dex)];
|
|
316
|
-
case 6:
|
|
317
|
-
r = _b.sent();
|
|
318
|
-
return [4 /*yield*/, r.wait()];
|
|
319
|
-
case 7:
|
|
320
|
-
a = _b.sent();
|
|
321
|
-
result = (_a = a.logs
|
|
322
|
-
.map(function (e) {
|
|
323
|
-
try {
|
|
324
|
-
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
325
|
-
return iface.parseLog(e);
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
})
|
|
331
|
-
.find(function (e) { return e && e.name === 'Deposit'; })) === null || _a === void 0 ? void 0 : _a.args;
|
|
332
|
-
console.log('Deposit:', result);
|
|
333
|
-
share = (0, formatBigInt_1.default)(result.shares);
|
|
334
|
-
console.log('Deposit share:', share);
|
|
335
|
-
return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}); });
|
|
339
|
-
it('getUserBalance', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
340
|
-
var userShares;
|
|
341
|
-
return __generator(this, function (_a) {
|
|
342
|
-
switch (_a.label) {
|
|
343
|
-
case 0: return [4 /*yield*/, (0, index_1.getUserBalance)(account, vault.address, provider, vault.dex)];
|
|
344
|
-
case 1:
|
|
345
|
-
userShares = _a.sent();
|
|
346
|
-
expect(Number(userShares)).toBeGreaterThanOrEqual(0);
|
|
347
|
-
return [2 /*return*/];
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}); });
|
|
351
|
-
it('getAllUserBalances', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
352
|
-
var userShares;
|
|
353
|
-
return __generator(this, function (_a) {
|
|
354
|
-
switch (_a.label) {
|
|
355
|
-
case 0: return [4 /*yield*/, (0, index_1.getAllUserBalances)(account, provider, vault.dex)];
|
|
356
|
-
case 1:
|
|
357
|
-
userShares = _a.sent();
|
|
358
|
-
expect(Number(userShares[0].shares)).toBeGreaterThanOrEqual(0);
|
|
359
|
-
return [2 /*return*/];
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
}); });
|
|
363
|
-
it('getAllUserAmounts', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
|
-
var userAmounts;
|
|
365
|
-
return __generator(this, function (_a) {
|
|
366
|
-
switch (_a.label) {
|
|
367
|
-
case 0: return [4 /*yield*/, (0, index_1.getAllUserAmounts)(account, provider, vault.dex)];
|
|
368
|
-
case 1:
|
|
369
|
-
userAmounts = _a.sent();
|
|
370
|
-
expect(Number(userAmounts[0].userAmounts.amount0)).toBeGreaterThanOrEqual(0);
|
|
371
|
-
return [2 /*return*/];
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
}); });
|
|
375
|
-
it('getTotalAmounts', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
376
|
-
var totalAmounts;
|
|
377
|
-
return __generator(this, function (_a) {
|
|
378
|
-
switch (_a.label) {
|
|
379
|
-
case 0: return [4 /*yield*/, (0, index_1.getTotalAmounts)(vault.address, provider, vault.dex)];
|
|
380
|
-
case 1:
|
|
381
|
-
totalAmounts = _a.sent();
|
|
382
|
-
expect(Number(totalAmounts.total0)).toBeGreaterThan(0);
|
|
383
|
-
return [2 /*return*/];
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}); });
|
|
387
|
-
it('getUserAmounts', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
388
|
-
var amounts;
|
|
389
|
-
return __generator(this, function (_a) {
|
|
390
|
-
switch (_a.label) {
|
|
391
|
-
case 0: return [4 /*yield*/, (0, index_1.getUserAmounts)(account, vault.address, provider, vault.dex)];
|
|
392
|
-
case 1:
|
|
393
|
-
amounts = _a.sent();
|
|
394
|
-
expect(Number(amounts.amount0)).toBeGreaterThanOrEqual(0);
|
|
395
|
-
return [2 /*return*/];
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
}); });
|
|
399
|
-
it('getFeesCollected_All', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
400
|
-
var amounts;
|
|
401
|
-
return __generator(this, function (_a) {
|
|
402
|
-
switch (_a.label) {
|
|
403
|
-
case 0: return [4 /*yield*/, (0, index_1.getFeesCollected)(vault.address, provider, vault.dex)];
|
|
404
|
-
case 1:
|
|
405
|
-
amounts = _a.sent();
|
|
406
|
-
expect(Number(amounts[0])).toBeGreaterThanOrEqual(0);
|
|
407
|
-
return [2 /*return*/];
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}); });
|
|
411
|
-
it('getFeesCollectedInfo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
412
|
-
var feeCollected;
|
|
413
|
-
return __generator(this, function (_a) {
|
|
414
|
-
switch (_a.label) {
|
|
415
|
-
case 0: return [4 /*yield*/, (0, index_1.getFeesCollectedInfo)(vault.address, provider, vault.dex, [1, 7, 30, 1000])];
|
|
416
|
-
case 1:
|
|
417
|
-
feeCollected = _a.sent();
|
|
418
|
-
expect(Number(feeCollected[0].pctAPR)).toBeGreaterThanOrEqual(0);
|
|
419
|
-
return [2 /*return*/];
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}); });
|
|
423
|
-
it('getAverageDepositTokenRatios', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
424
|
-
var avgDtr;
|
|
425
|
-
return __generator(this, function (_a) {
|
|
426
|
-
switch (_a.label) {
|
|
427
|
-
case 0: return [4 /*yield*/, (0, index_1.getAverageDepositTokenRatios)(vault.address, provider, vault.dex)];
|
|
428
|
-
case 1:
|
|
429
|
-
avgDtr = _a.sent();
|
|
430
|
-
expect(Number(avgDtr[0].percent)).toBeGreaterThanOrEqual(0);
|
|
431
|
-
return [2 /*return*/];
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}); });
|
|
435
|
-
it('getLpApr', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
436
|
-
var lpAprs;
|
|
437
|
-
var _a;
|
|
438
|
-
return __generator(this, function (_b) {
|
|
439
|
-
switch (_b.label) {
|
|
440
|
-
case 0: return [4 /*yield*/, (0, index_1.getLpApr)(vault.address, provider, vault.dex)];
|
|
441
|
-
case 1:
|
|
442
|
-
lpAprs = _b.sent();
|
|
443
|
-
expect(Number((_a = lpAprs[0]) === null || _a === void 0 ? void 0 : _a.timeInterval)).toEqual(1);
|
|
444
|
-
return [2 /*return*/];
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
}); });
|
|
448
|
-
it('getLpPriceChange', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
449
|
-
var lpPriceChange;
|
|
450
|
-
var _a;
|
|
451
|
-
return __generator(this, function (_b) {
|
|
452
|
-
switch (_b.label) {
|
|
453
|
-
case 0: return [4 /*yield*/, (0, index_1.getLpPriceChange)(vault.address, provider, vault.dex)];
|
|
454
|
-
case 1:
|
|
455
|
-
lpPriceChange = _b.sent();
|
|
456
|
-
expect(Number((_a = lpPriceChange[0]) === null || _a === void 0 ? void 0 : _a.timeInterval)).toEqual(1);
|
|
457
|
-
return [2 /*return*/];
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
}); });
|
|
461
|
-
it('getVaultPositions', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
462
|
-
var positions;
|
|
463
|
-
return __generator(this, function (_a) {
|
|
464
|
-
switch (_a.label) {
|
|
465
|
-
case 0: return [4 /*yield*/, (0, index_1.getVaultPositions)(vault.address, provider, vault.dex)];
|
|
466
|
-
case 1:
|
|
467
|
-
positions = _a.sent();
|
|
468
|
-
expect(positions.currentPrice).toBeGreaterThanOrEqual(0);
|
|
469
|
-
return [2 /*return*/];
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
}); });
|
|
35
|
+
const iface = new ethers_1.ethers.Interface(IchiVault_json_1.default);
|
|
36
|
+
const amount1 = '10';
|
|
37
|
+
const amount0 = '0';
|
|
38
|
+
const sharesToWithdraw = '10';
|
|
39
|
+
const bigAmount = '1000';
|
|
40
|
+
describe('Vault', () => {
|
|
41
|
+
let share = null;
|
|
42
|
+
it.skip('getFeeAprs', async () => {
|
|
43
|
+
const feeAprs = await (0, index_1.getFeeAprs)(vault.address, provider, vault.dex);
|
|
44
|
+
if (feeAprs) {
|
|
45
|
+
expect(Number(feeAprs.feeApr_1d)).toBeGreaterThanOrEqual(0);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
it('getVaultMetrics', async () => {
|
|
49
|
+
const metrics = await (0, index_1.getVaultMetrics)(vault.address, provider, vault.dex);
|
|
50
|
+
expect(Number(metrics[0]?.avgDtr)).toBeGreaterThan(0);
|
|
51
|
+
});
|
|
52
|
+
it('getTotalSupply', async () => {
|
|
53
|
+
const totalSupply = await (0, index_1.getTotalSupply)(vault.address, provider, vault.dex);
|
|
54
|
+
expect(Number(totalSupply)).toBeGreaterThan(0);
|
|
55
|
+
});
|
|
56
|
+
it.skip('approve', async () => {
|
|
57
|
+
let approve = null;
|
|
58
|
+
approve = await (0, index_1.approveDepositToken)(account, 1, vault.address, wallet, vault.dex, amount1);
|
|
59
|
+
await approve.wait();
|
|
60
|
+
const isApproved = await (0, index_1.isDepositTokenApproved)(account, 1, amount1, vault.address, provider, vault.dex);
|
|
61
|
+
expect(isApproved).toEqual(true);
|
|
62
|
+
});
|
|
63
|
+
it.skip('approveToken', async () => {
|
|
64
|
+
const approve = await (0, index_1.approveToken)(account, '0xd7d4d91d64a6061fa00a94e2b3a2d2a5fb677849', vault.address, wallet, vault.dex, amount1);
|
|
65
|
+
await approve.wait();
|
|
66
|
+
const isApproved = await (0, index_1.isTokenApproved)(account, '0xd7d4d91d64a6061fa00a94e2b3a2d2a5fb677849', amount1, vault.address, provider, vault.dex);
|
|
67
|
+
expect(isApproved).toEqual(true);
|
|
68
|
+
});
|
|
69
|
+
it('isDepositTokenApproved', async () => {
|
|
70
|
+
const isApproved = await (0, index_1.isDepositTokenApproved)(account, 0, bigAmount, vault.address, provider, vault.dex);
|
|
71
|
+
expect(isApproved).toEqual(false);
|
|
72
|
+
});
|
|
73
|
+
it.skip('deposit', async () => {
|
|
74
|
+
const isAllowed0 = await (0, index_1.isTokenAllowed)(0, vault.address, provider, vault.dex);
|
|
75
|
+
const isAllowed1 = await (0, index_1.isTokenAllowed)(1, vault.address, provider, vault.dex);
|
|
76
|
+
const maxDeposit0 = await (0, index_1.getMaxDepositAmount)(0, vault.address, provider, vault.dex);
|
|
77
|
+
const maxDeposit1 = await (0, index_1.getMaxDepositAmount)(1, vault.address, provider, vault.dex);
|
|
78
|
+
const vaultFromQuery = await (0, index_1.getIchiVaultInfo)(vault.chainId, vault.dex, vault.address, provider);
|
|
79
|
+
if (!vaultFromQuery)
|
|
80
|
+
throw new Error(`Vault ${vault.address} not found on chain ${vault.chainId} and dex ${vault.dex}]`);
|
|
81
|
+
const token0Decimals = await (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenA, provider, vault.chainId);
|
|
82
|
+
const token1Decimals = await (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenB, provider, vault.chainId);
|
|
83
|
+
if (!isAllowed0 && Number(amount0) > 0)
|
|
84
|
+
return;
|
|
85
|
+
if (!isAllowed1 && Number(amount1) > 0)
|
|
86
|
+
return;
|
|
87
|
+
if ((0, parseBigInt_1.default)(amount0, token0Decimals) > maxDeposit0 || (0, parseBigInt_1.default)(amount1, token1Decimals) > maxDeposit1)
|
|
88
|
+
return;
|
|
89
|
+
const r = await (0, index_1.deposit)(account, amount0, amount1, vault.address, wallet, vault.dex);
|
|
90
|
+
const a = await r.wait();
|
|
91
|
+
const result = a.logs
|
|
92
|
+
.map((e) => {
|
|
93
|
+
try {
|
|
94
|
+
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
95
|
+
return iface.parseLog(e);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.find((e) => e && e.name === 'Deposit')?.args;
|
|
102
|
+
console.log('Deposit:', result);
|
|
103
|
+
share = (0, formatBigInt_1.default)(result.shares);
|
|
104
|
+
console.log('Deposit share:', share);
|
|
105
|
+
});
|
|
106
|
+
it.skip('depositNativeToken', async () => {
|
|
107
|
+
const isAllowed0 = await (0, index_1.isTokenAllowed)(0, vault.address, provider, vault.dex);
|
|
108
|
+
const isAllowed1 = await (0, index_1.isTokenAllowed)(1, vault.address, provider, vault.dex);
|
|
109
|
+
const maxDeposit0 = await (0, index_1.getMaxDepositAmount)(0, vault.address, provider, vault.dex);
|
|
110
|
+
const maxDeposit1 = await (0, index_1.getMaxDepositAmount)(1, vault.address, provider, vault.dex);
|
|
111
|
+
const vaultFromQuery = await (0, index_1.getIchiVaultInfo)(vault.chainId, vault.dex, vault.address, provider);
|
|
112
|
+
if (!vaultFromQuery)
|
|
113
|
+
throw new Error(`Vault ${vault.address} not found on chain ${vault.chainId} and dex ${vault.dex}]`);
|
|
114
|
+
const token0Decimals = await (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenA, provider, vault.chainId);
|
|
115
|
+
const token1Decimals = await (0, _totalBalances_1.getTokenDecimals)(vaultFromQuery.tokenB, provider, vault.chainId);
|
|
116
|
+
if (!isAllowed0 && Number(amount0) > 0)
|
|
117
|
+
return;
|
|
118
|
+
if (!isAllowed1 && Number(amount1) > 0)
|
|
119
|
+
return;
|
|
120
|
+
if ((0, parseBigInt_1.default)(amount0, token0Decimals) > maxDeposit0 || (0, parseBigInt_1.default)(amount1, token1Decimals) > maxDeposit1)
|
|
121
|
+
return;
|
|
122
|
+
const r = await (0, index_1.depositNativeToken)(account, amount0, amount1, vault.address, wallet, vault.dex);
|
|
123
|
+
const a = await r.wait();
|
|
124
|
+
const result = a.logs
|
|
125
|
+
.map((e) => {
|
|
126
|
+
try {
|
|
127
|
+
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
128
|
+
return iface.parseLog(e);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
.find((e) => e && e.name === 'Deposit')?.args;
|
|
135
|
+
console.log('Deposit:', result);
|
|
136
|
+
share = (0, formatBigInt_1.default)(result.shares);
|
|
137
|
+
console.log('Deposit share:', share);
|
|
138
|
+
});
|
|
139
|
+
it.skip('depositWithHtsWrapping', async () => {
|
|
140
|
+
const isAllowed0 = await (0, index_1.isTokenAllowed)(0, vault.address, provider, vault.dex);
|
|
141
|
+
const isAllowed1 = await (0, index_1.isTokenAllowed)(1, vault.address, provider, vault.dex);
|
|
142
|
+
const vaultFromQuery = await (0, index_1.getIchiVaultInfo)(vault.chainId, vault.dex, vault.address, provider);
|
|
143
|
+
if (!vaultFromQuery)
|
|
144
|
+
throw new Error(`Vault ${vault.address} not found on chain ${vault.chainId} and dex ${vault.dex}]`);
|
|
145
|
+
if (!isAllowed0 && Number(amount0) > 0)
|
|
146
|
+
return;
|
|
147
|
+
if (!isAllowed1 && Number(amount1) > 0)
|
|
148
|
+
return;
|
|
149
|
+
const r = await (0, index_1.depositWithHtsWrapping)(account, amount0, amount1, vault.address, wallet, vault.dex);
|
|
150
|
+
const a = await r.wait();
|
|
151
|
+
const result = a.logs
|
|
152
|
+
.map((e) => {
|
|
153
|
+
try {
|
|
154
|
+
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
155
|
+
return iface.parseLog(e);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
.find((e) => e && e.name === 'Deposit')?.args;
|
|
162
|
+
console.log('Deposit:', result);
|
|
163
|
+
share = (0, formatBigInt_1.default)(result.shares);
|
|
164
|
+
console.log('Deposit share:', share);
|
|
165
|
+
});
|
|
166
|
+
it('getUserBalance', async () => {
|
|
167
|
+
const userShares = await (0, index_1.getUserBalance)(account, vault.address, provider, vault.dex);
|
|
168
|
+
expect(Number(userShares)).toBeGreaterThanOrEqual(0);
|
|
169
|
+
});
|
|
170
|
+
it('getAllUserBalances', async () => {
|
|
171
|
+
const allUserShares = await (0, index_1.getAllUserBalances)(account, provider, vault.dex);
|
|
172
|
+
expect(Number(allUserShares[0].shares)).toBeGreaterThanOrEqual(0);
|
|
173
|
+
});
|
|
174
|
+
it('getAllUserAmounts', async () => {
|
|
175
|
+
const userAmounts = await (0, index_1.getAllUserAmounts)(account, provider, vault.dex);
|
|
176
|
+
expect(Number(userAmounts[0].userAmounts.amount0)).toBeGreaterThanOrEqual(0);
|
|
177
|
+
});
|
|
178
|
+
it('getTotalAmounts', async () => {
|
|
179
|
+
const totalAmounts = await (0, index_1.getTotalAmounts)(vault.address, provider, vault.dex);
|
|
180
|
+
expect(Number(totalAmounts.total0)).toBeGreaterThan(0);
|
|
181
|
+
});
|
|
182
|
+
it('getUserAmounts', async () => {
|
|
183
|
+
const amounts = await (0, index_1.getUserAmounts)(account, vault.address, provider, vault.dex);
|
|
184
|
+
expect(Number(amounts.amount0)).toBeGreaterThanOrEqual(0);
|
|
185
|
+
});
|
|
186
|
+
it('getFeesCollected_All', async () => {
|
|
187
|
+
const fees = await (0, index_1.getFeesCollected)(vault.address, provider, vault.dex);
|
|
188
|
+
expect(Number(fees[0])).toBeGreaterThanOrEqual(0);
|
|
189
|
+
});
|
|
190
|
+
it('getFeesCollectedInfo', async () => {
|
|
191
|
+
const feeCollected = await (0, index_1.getFeesCollectedInfo)(vault.address, provider, vault.dex, [1, 7, 30, 1000]);
|
|
192
|
+
expect(Number(feeCollected[0].pctAPR)).toBeGreaterThanOrEqual(0);
|
|
193
|
+
});
|
|
194
|
+
it('getAverageDepositTokenRatios', async () => {
|
|
195
|
+
const avgDtr = await (0, index_1.getAverageDepositTokenRatios)(vault.address, provider, vault.dex);
|
|
196
|
+
expect(Number(avgDtr[0].percent)).toBeGreaterThanOrEqual(0);
|
|
197
|
+
});
|
|
198
|
+
it('getLpApr', async () => {
|
|
199
|
+
const lpAprs = await (0, index_1.getLpApr)(vault.address, provider, vault.dex);
|
|
200
|
+
expect(Number(lpAprs[0]?.timeInterval)).toEqual(1);
|
|
201
|
+
});
|
|
202
|
+
it('getLpPriceChange', async () => {
|
|
203
|
+
const lpPriceChange = await (0, index_1.getLpPriceChange)(vault.address, provider, vault.dex);
|
|
204
|
+
expect(Number(lpPriceChange[0]?.timeInterval)).toEqual(1);
|
|
205
|
+
});
|
|
206
|
+
it('getVaultPositions', async () => {
|
|
207
|
+
const positions = await (0, index_1.getVaultPositions)(vault.address, provider, vault.dex);
|
|
208
|
+
expect(positions.currentPrice).toBeGreaterThanOrEqual(0);
|
|
209
|
+
});
|
|
473
210
|
});
|
|
474
|
-
describe('Withdraws',
|
|
475
|
-
it.skip('withdraw:deposited',
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
.find(function (e) { return e && e.name === 'Withdraw'; })) === null || _a === void 0 ? void 0 : _a.args;
|
|
492
|
-
console.log('Withdraw:', result);
|
|
493
|
-
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
494
|
-
})];
|
|
495
|
-
case 1:
|
|
496
|
-
_a.sent();
|
|
497
|
-
return [2 /*return*/];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
}); });
|
|
501
|
-
it.skip('approveVaultToken', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
502
|
-
var approve, isApproved;
|
|
503
|
-
return __generator(this, function (_a) {
|
|
504
|
-
switch (_a.label) {
|
|
505
|
-
case 0:
|
|
506
|
-
approve = null;
|
|
507
|
-
return [4 /*yield*/, (0, index_1.approveVaultToken)(account, vault.address, provider, vault.dex, sharesToWithdraw)];
|
|
508
|
-
case 1:
|
|
509
|
-
approve = _a.sent();
|
|
510
|
-
return [4 /*yield*/, approve.wait()];
|
|
511
|
-
case 2:
|
|
512
|
-
_a.sent();
|
|
513
|
-
return [4 /*yield*/, (0, index_1.isVaultTokenApproved)(account, sharesToWithdraw, vault.address, provider, vault.dex)];
|
|
514
|
-
case 3:
|
|
515
|
-
isApproved = _a.sent();
|
|
516
|
-
expect(isApproved).toEqual(true);
|
|
517
|
-
return [2 /*return*/];
|
|
518
|
-
}
|
|
211
|
+
describe('Withdraws', () => {
|
|
212
|
+
it.skip('withdraw:deposited', async () => {
|
|
213
|
+
await (0, index_1.withdraw)(account, sharesToWithdraw, vault.address, wallet, vault.dex)
|
|
214
|
+
.then((e) => e.wait())
|
|
215
|
+
.then((a) => {
|
|
216
|
+
const result = a.logs
|
|
217
|
+
.map((e) => {
|
|
218
|
+
try {
|
|
219
|
+
return iface.parseLog(e);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
.find((e) => e && e.name === 'Withdraw')?.args;
|
|
226
|
+
console.log('Withdraw:', result);
|
|
227
|
+
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
519
228
|
});
|
|
520
|
-
});
|
|
521
|
-
it.skip('
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
229
|
+
});
|
|
230
|
+
it.skip('approveVaultToken', async () => {
|
|
231
|
+
let approve = null;
|
|
232
|
+
approve = await (0, index_1.approveVaultToken)(account, vault.address, wallet, vault.dex, Number(sharesToWithdraw) * 2);
|
|
233
|
+
await approve.wait();
|
|
234
|
+
const isApproved = await (0, index_1.isVaultTokenApproved)(account, sharesToWithdraw, vault.address, provider, vault.dex);
|
|
235
|
+
expect(isApproved).toEqual(true);
|
|
236
|
+
});
|
|
237
|
+
it.skip('withdrawWithSlippage', async () => {
|
|
238
|
+
await (0, index_1.withdrawWithSlippage)(account, sharesToWithdraw, vault.address, wallet, vault.dex, 2)
|
|
239
|
+
.then((e) => e.wait())
|
|
240
|
+
.then((a) => {
|
|
241
|
+
const result = a.logs
|
|
242
|
+
.map((e) => {
|
|
243
|
+
try {
|
|
244
|
+
return iface.parseLog(e);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
.find((e) => e && e.name === 'Withdraw')?.args;
|
|
251
|
+
console.log('Withdraw with slippage:', result);
|
|
252
|
+
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
545
253
|
});
|
|
546
|
-
});
|
|
547
|
-
it.skip('withdrawNativeToken',
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
.find(function (e) { return e && e.name === 'Withdraw'; })) === null || _a === void 0 ? void 0 : _a.args;
|
|
564
|
-
console.log('withdrawNativeToken:', result);
|
|
565
|
-
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
566
|
-
})];
|
|
567
|
-
case 1:
|
|
568
|
-
_a.sent();
|
|
569
|
-
return [2 /*return*/];
|
|
570
|
-
}
|
|
254
|
+
});
|
|
255
|
+
it.skip('withdrawNativeToken', async () => {
|
|
256
|
+
await (0, index_1.withdrawNativeToken)(account, sharesToWithdraw, vault.address, wallet, vault.dex)
|
|
257
|
+
.then((e) => e.wait())
|
|
258
|
+
.then((a) => {
|
|
259
|
+
const result = a.logs
|
|
260
|
+
.map((e) => {
|
|
261
|
+
try {
|
|
262
|
+
return iface.parseLog(e);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
.find((e) => e && e.name === 'Withdraw')?.args;
|
|
269
|
+
console.log('withdrawNativeToken:', result);
|
|
270
|
+
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
571
271
|
});
|
|
572
|
-
});
|
|
573
|
-
it.skip('withdrawWithErc20Wrapping',
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
.find(function (e) { return e && e.name === 'Withdraw'; })) === null || _a === void 0 ? void 0 : _a.args;
|
|
590
|
-
console.log('withdrawWithErc20Wrapping:', result);
|
|
591
|
-
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
592
|
-
})];
|
|
593
|
-
case 1:
|
|
594
|
-
_a.sent();
|
|
595
|
-
return [2 /*return*/];
|
|
596
|
-
}
|
|
272
|
+
});
|
|
273
|
+
it.skip('withdrawWithErc20Wrapping', async () => {
|
|
274
|
+
await (0, index_1.withdrawWithErc20Wrapping)(account, sharesToWithdraw, vault.address, wallet, vault.dex)
|
|
275
|
+
.then((e) => e.wait())
|
|
276
|
+
.then((a) => {
|
|
277
|
+
const result = a.logs
|
|
278
|
+
.map((e) => {
|
|
279
|
+
try {
|
|
280
|
+
return iface.parseLog(e);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
.find((e) => e && e.name === 'Withdraw')?.args;
|
|
287
|
+
console.log('withdrawWithErc20Wrapping:', result);
|
|
288
|
+
expect((0, formatBigInt_1.default)(result.shares)).toEqual(sharesToWithdraw);
|
|
597
289
|
});
|
|
598
|
-
});
|
|
290
|
+
});
|
|
599
291
|
});
|
|
600
|
-
describe('GraphQL',
|
|
601
|
-
it('GetIchiVaultInfo',
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
});
|
|
613
|
-
it('Get vaults by tokens', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
614
|
-
var vaults;
|
|
615
|
-
return __generator(this, function (_a) {
|
|
616
|
-
switch (_a.label) {
|
|
617
|
-
case 0: return [4 /*yield*/, (0, index_1.getVaultsByTokens)(vault.chainId, vault.dex, tokens.depositToken, tokens.pairedToken)];
|
|
618
|
-
case 1:
|
|
619
|
-
vaults = _a.sent();
|
|
620
|
-
expect(vaults).toBeTruthy();
|
|
621
|
-
return [2 /*return*/];
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
}); });
|
|
625
|
-
it('Get vaults by pool', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
626
|
-
var vaults;
|
|
627
|
-
return __generator(this, function (_a) {
|
|
628
|
-
switch (_a.label) {
|
|
629
|
-
case 0: return [4 /*yield*/, (0, index_1.getVaultsByPool)(pool.address, pool.chainId, pool.dex)];
|
|
630
|
-
case 1:
|
|
631
|
-
vaults = _a.sent();
|
|
632
|
-
expect(vaults).toBeTruthy();
|
|
633
|
-
return [2 /*return*/];
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
}); });
|
|
292
|
+
describe('GraphQL', () => {
|
|
293
|
+
it('GetIchiVaultInfo', async () => {
|
|
294
|
+
const vaultInfo = await (0, index_1.getIchiVaultInfo)(vault.chainId, vault.dex, vault.address, provider);
|
|
295
|
+
expect(vaultInfo).toBeTruthy();
|
|
296
|
+
});
|
|
297
|
+
it('Get vaults by tokens', async () => {
|
|
298
|
+
const vaultsByTokens = await (0, index_1.getVaultsByTokens)(vault.chainId, vault.dex, tokens.depositToken, tokens.pairedToken);
|
|
299
|
+
expect(vaultsByTokens).toBeTruthy();
|
|
300
|
+
});
|
|
301
|
+
it('Get vaults by pool', async () => {
|
|
302
|
+
const vaultsByPool = await (0, index_1.getVaultsByPool)(pool.address, pool.chainId, pool.dex);
|
|
303
|
+
expect(vaultsByPool).toBeTruthy();
|
|
304
|
+
});
|
|
637
305
|
});
|
|
638
|
-
describe('Dexes',
|
|
639
|
-
it('getSupportedDexes',
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
});
|
|
647
|
-
it('getChainsForDex', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
648
|
-
var chains;
|
|
649
|
-
return __generator(this, function (_a) {
|
|
650
|
-
chains = (0, index_1.getChainsForDex)(vault.dex);
|
|
651
|
-
expect(chains.length).toBeGreaterThan(0);
|
|
652
|
-
return [2 /*return*/];
|
|
653
|
-
});
|
|
654
|
-
}); });
|
|
306
|
+
describe('Dexes', () => {
|
|
307
|
+
it('getSupportedDexes', async () => {
|
|
308
|
+
const dexes = (0, index_1.getSupportedDexes)(vault.chainId);
|
|
309
|
+
expect(dexes.length).toBeGreaterThan(0);
|
|
310
|
+
});
|
|
311
|
+
it('getChainsForDex', async () => {
|
|
312
|
+
const chains = (0, index_1.getChainsForDex)(vault.dex);
|
|
313
|
+
expect(chains.length).toBeGreaterThan(0);
|
|
314
|
+
});
|
|
655
315
|
});
|
|
656
|
-
describe('Rewards',
|
|
657
|
-
it.skip('getRewardInfo',
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
});
|
|
669
|
-
it.skip('
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
expect(allRewardInfo.length).toBeGreaterThan(0);
|
|
677
|
-
return [2 /*return*/];
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
}); });
|
|
681
|
-
it.skip('getUserRewards', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
682
|
-
var userRewards;
|
|
683
|
-
return __generator(this, function (_a) {
|
|
684
|
-
switch (_a.label) {
|
|
685
|
-
case 0: return [4 /*yield*/, (0, index_1.getUserRewards)(account, vault.address, provider, vault.dex)];
|
|
686
|
-
case 1:
|
|
687
|
-
userRewards = _a.sent();
|
|
688
|
-
expect(Number(userRewards[0].rewardAmount)).toBeGreaterThan(0);
|
|
689
|
-
return [2 /*return*/];
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
}); });
|
|
693
|
-
it.skip('claimRewards', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
694
|
-
var tx, a;
|
|
695
|
-
return __generator(this, function (_a) {
|
|
696
|
-
switch (_a.label) {
|
|
697
|
-
case 0: return [4 /*yield*/, (0, index_1.claimRewards)(account, vault.address, provider, vault.dex)];
|
|
698
|
-
case 1:
|
|
699
|
-
tx = _a.sent();
|
|
700
|
-
return [4 /*yield*/, tx.wait()];
|
|
701
|
-
case 2:
|
|
702
|
-
a = _a.sent();
|
|
703
|
-
a.logs.map(function (e) {
|
|
704
|
-
try {
|
|
705
|
-
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
706
|
-
return iface.parseLog(e);
|
|
707
|
-
}
|
|
708
|
-
catch (error) {
|
|
709
|
-
return null;
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
return [2 /*return*/];
|
|
316
|
+
describe('Rewards', () => {
|
|
317
|
+
it.skip('getRewardInfo', async () => {
|
|
318
|
+
const rewardInfo = await (0, index_1.getRewardInfo)(vault.chainId, vault.dex, vault.address);
|
|
319
|
+
expect(rewardInfo.id).toBeDefined();
|
|
320
|
+
});
|
|
321
|
+
it.skip('getAllRewardInfo', async () => {
|
|
322
|
+
const allRewardInfo = await (0, index_1.getAllRewardInfo)(vault.chainId, vault.dex);
|
|
323
|
+
expect(allRewardInfo.length).toBeGreaterThan(0);
|
|
324
|
+
});
|
|
325
|
+
it.skip('getUserRewards', async () => {
|
|
326
|
+
const userRewards = await (0, index_1.getUserRewards)(account, vault.address, provider, vault.dex);
|
|
327
|
+
expect(Number(userRewards[0].rewardAmount)).toBeGreaterThan(0);
|
|
328
|
+
});
|
|
329
|
+
it.skip('claimRewards', async () => {
|
|
330
|
+
const tx = await (0, index_1.claimRewards)(account, vault.address, wallet, vault.dex);
|
|
331
|
+
const a = await tx.wait();
|
|
332
|
+
a.logs.map((e) => {
|
|
333
|
+
try {
|
|
334
|
+
console.log('iface.parseLog(e):', iface.parseLog(e));
|
|
335
|
+
return iface.parseLog(e);
|
|
713
336
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
it.skip('getAllUserRewards', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
717
|
-
var rewards;
|
|
718
|
-
return __generator(this, function (_a) {
|
|
719
|
-
switch (_a.label) {
|
|
720
|
-
case 0: return [4 /*yield*/, (0, index_1.getAllUserRewards)(account, provider, vault.dex)];
|
|
721
|
-
case 1:
|
|
722
|
-
rewards = _a.sent();
|
|
723
|
-
expect(rewards.length).toBeGreaterThan(0);
|
|
724
|
-
return [2 /*return*/];
|
|
337
|
+
catch (error) {
|
|
338
|
+
return null;
|
|
725
339
|
}
|
|
726
340
|
});
|
|
727
|
-
});
|
|
341
|
+
});
|
|
342
|
+
it.skip('getAllUserRewards', async () => {
|
|
343
|
+
const rewards = await (0, index_1.getAllUserRewards)(account, provider, vault.dex);
|
|
344
|
+
console.log({ rewards });
|
|
345
|
+
expect(rewards.length).toBeGreaterThan(0);
|
|
346
|
+
});
|
|
728
347
|
});
|
|
729
|
-
describe('Factory Config',
|
|
730
|
-
it('getConfigByFactory returns config for valid factory',
|
|
348
|
+
describe('Factory Config', () => {
|
|
349
|
+
it('getConfigByFactory returns config for valid factory', () => {
|
|
731
350
|
// Use Base Aerodrome factory address
|
|
732
|
-
|
|
733
|
-
|
|
351
|
+
const factoryAddress = '0xf6B5Ab192F2696921F60a1Ff00b99596C4045FA6';
|
|
352
|
+
const config = (0, index_1.getConfigByFactory)(types_1.SupportedChainId.base, factoryAddress);
|
|
734
353
|
expect(config).toBeDefined();
|
|
735
|
-
expect(config
|
|
736
|
-
expect(config
|
|
737
|
-
expect(config
|
|
738
|
-
expect(config
|
|
739
|
-
expect(typeof
|
|
740
|
-
expect(typeof
|
|
741
|
-
});
|
|
742
|
-
it('getConfigByFactory returns config case-insensitively',
|
|
354
|
+
expect(config?.dex).toBe(types_1.SupportedDex.Aerodrome);
|
|
355
|
+
expect(config?.factoryAddress.toLowerCase()).toBe(factoryAddress.toLowerCase());
|
|
356
|
+
expect(config?.vaultDeployerAddress).toBeDefined();
|
|
357
|
+
expect(config?.graphUrl).toBeDefined();
|
|
358
|
+
expect(typeof config?.supportsCollectFees).toBe('boolean');
|
|
359
|
+
expect(typeof config?.isAlgebra).toBe('boolean');
|
|
360
|
+
});
|
|
361
|
+
it('getConfigByFactory returns config case-insensitively', () => {
|
|
743
362
|
// Use lowercase version of factory address
|
|
744
|
-
|
|
745
|
-
|
|
363
|
+
const factoryAddress = '0xf6b5ab192f2696921f60a1ff00b99596c4045fa6';
|
|
364
|
+
const config = (0, index_1.getConfigByFactory)(types_1.SupportedChainId.base, factoryAddress);
|
|
746
365
|
expect(config).toBeDefined();
|
|
747
|
-
expect(config
|
|
366
|
+
expect(config?.dex).toBe(types_1.SupportedDex.Aerodrome);
|
|
748
367
|
});
|
|
749
|
-
it('getConfigByFactory returns undefined for invalid factory',
|
|
750
|
-
|
|
368
|
+
it('getConfigByFactory returns undefined for invalid factory', () => {
|
|
369
|
+
const config = (0, index_1.getConfigByFactory)(types_1.SupportedChainId.base, '0x0000000000000000000000000000000000000000');
|
|
751
370
|
expect(config).toBeUndefined();
|
|
752
371
|
});
|
|
753
|
-
it('getConfigByFactory returns undefined for invalid chain',
|
|
754
|
-
|
|
755
|
-
|
|
372
|
+
it('getConfigByFactory returns undefined for invalid chain', () => {
|
|
373
|
+
const factoryAddress = '0xf6B5Ab192F2696921F60a1Ff00b99596C4045FA6';
|
|
374
|
+
const config = (0, index_1.getConfigByFactory)(999999, factoryAddress);
|
|
756
375
|
expect(config).toBeUndefined();
|
|
757
376
|
});
|
|
758
|
-
it('getAllFactoryConfigs returns all factories for a chain',
|
|
759
|
-
|
|
377
|
+
it('getAllFactoryConfigs returns all factories for a chain', () => {
|
|
378
|
+
const configs = (0, index_1.getAllFactoryConfigs)(types_1.SupportedChainId.base);
|
|
760
379
|
expect(configs.size).toBeGreaterThan(0);
|
|
761
380
|
// Verify the structure of returned configs
|
|
762
|
-
|
|
763
|
-
expect(firstConfig
|
|
764
|
-
expect(firstConfig
|
|
765
|
-
expect(firstConfig
|
|
766
|
-
expect(typeof firstConfig
|
|
767
|
-
});
|
|
768
|
-
it('getAllFactoryConfigs returns empty map for invalid chain',
|
|
769
|
-
|
|
381
|
+
const firstConfig = configs.values().next().value;
|
|
382
|
+
expect(firstConfig?.dex).toBeDefined();
|
|
383
|
+
expect(firstConfig?.factoryAddress).toBeDefined();
|
|
384
|
+
expect(firstConfig?.vaultDeployerAddress).toBeDefined();
|
|
385
|
+
expect(typeof firstConfig?.isAlgebra).toBe('boolean');
|
|
386
|
+
});
|
|
387
|
+
it('getAllFactoryConfigs returns empty map for invalid chain', () => {
|
|
388
|
+
const configs = (0, index_1.getAllFactoryConfigs)(999999);
|
|
770
389
|
expect(configs.size).toBe(0);
|
|
771
390
|
});
|
|
772
|
-
it('getAllFactoryConfigs keys are lowercase factory addresses',
|
|
773
|
-
|
|
774
|
-
configs.forEach(
|
|
391
|
+
it('getAllFactoryConfigs keys are lowercase factory addresses', () => {
|
|
392
|
+
const configs = (0, index_1.getAllFactoryConfigs)(types_1.SupportedChainId.base);
|
|
393
|
+
configs.forEach((value, key) => {
|
|
775
394
|
expect(key).toBe(key.toLowerCase());
|
|
776
395
|
expect(key).toBe(value.factoryAddress.toLowerCase());
|
|
777
396
|
});
|
|
778
397
|
});
|
|
779
|
-
it('addressConfig is exported and has expected structure',
|
|
780
|
-
var _a, _b, _c;
|
|
398
|
+
it('addressConfig is exported and has expected structure', () => {
|
|
781
399
|
expect(index_1.addressConfig).toBeDefined();
|
|
782
400
|
expect(index_1.addressConfig[types_1.SupportedChainId.base]).toBeDefined();
|
|
783
|
-
expect(
|
|
784
|
-
expect(
|
|
401
|
+
expect(index_1.addressConfig[types_1.SupportedChainId.base]?.[types_1.SupportedDex.Aerodrome]).toBeDefined();
|
|
402
|
+
expect(index_1.addressConfig[types_1.SupportedChainId.base]?.[types_1.SupportedDex.Aerodrome]?.factoryAddress).toBeDefined();
|
|
785
403
|
});
|
|
786
404
|
});
|
|
787
405
|
//# sourceMappingURL=index.test.js.map
|