@ichidao/ichi-vaults-sdk 0.1.43 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -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 +217 -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 +12 -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 +12 -13
- package/dist/src/types/index.js +1 -0
- 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 +276 -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
|
@@ -3,174 +3,94 @@
|
|
|
3
3
|
/* eslint-disable import/no-unresolved */
|
|
4
4
|
/* eslint-disable import/no-cycle */
|
|
5
5
|
/* eslint-disable import/prefer-default-export */
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
-
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;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
8
|
};
|
|
45
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
10
|
exports.getAllRewardInfo = exports.getRewardInfo = void 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function sendRewardInfoQueryRequest(url, vaultAddress, query) {
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
vaultAddress: vaultAddress.toLowerCase(),
|
|
57
|
-
}).then(function (_a) {
|
|
58
|
-
var ichiVault = _a.ichiVault;
|
|
59
|
-
return ichiVault;
|
|
60
|
-
})];
|
|
61
|
-
});
|
|
62
|
-
});
|
|
11
|
+
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
12
|
+
const cache_1 = __importDefault(require("../utils/cache"));
|
|
13
|
+
const getGraphUrls_1 = require("../utils/getGraphUrls");
|
|
14
|
+
const queries_1 = require("../graphql/queries");
|
|
15
|
+
const isVelodrome_1 = require("../utils/isVelodrome");
|
|
16
|
+
async function sendRewardInfoQueryRequest(url, vaultAddress, query) {
|
|
17
|
+
return (0, graphql_request_1.default)(url, query, {
|
|
18
|
+
vaultAddress: vaultAddress.toLowerCase(),
|
|
19
|
+
}).then(({ ichiVault }) => ichiVault);
|
|
63
20
|
}
|
|
64
|
-
function sendAllRewardInfoQueryRequest(url, query) {
|
|
65
|
-
return
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
return [2 /*return*/, (0, graphql_request_1.default)(url, query).then(function (_a) {
|
|
68
|
-
var ichiVaults = _a.ichiVaults;
|
|
69
|
-
return ichiVaults;
|
|
70
|
-
})];
|
|
71
|
-
});
|
|
72
|
-
});
|
|
21
|
+
async function sendAllRewardInfoQueryRequest(url, query) {
|
|
22
|
+
return (0, graphql_request_1.default)(url, query).then(({ ichiVaults }) => ichiVaults);
|
|
73
23
|
}
|
|
74
|
-
function getRewardInfo(chainId, dex, vaultAddress) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
_b.trys.push([5, 7, , 8]);
|
|
109
|
-
return [4 /*yield*/, sendRewardInfoQueryRequest(url, vaultAddress, queries_1.rewardInfoQuery)];
|
|
110
|
-
case 6:
|
|
111
|
-
result = _b.sent();
|
|
112
|
-
cache_1.default.set(key, result, ttl);
|
|
113
|
-
return [2 /*return*/, result];
|
|
114
|
-
case 7:
|
|
115
|
-
error2_1 = _b.sent();
|
|
116
|
-
console.error('Request to public graph URL failed:', error2_1);
|
|
117
|
-
throw new Error("Could not get Reward info for ".concat(vaultAddress));
|
|
118
|
-
case 8: return [3 /*break*/, 9];
|
|
119
|
-
case 9: return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
24
|
+
async function getRewardInfo(chainId, dex, vaultAddress) {
|
|
25
|
+
const isVelodrome = (0, isVelodrome_1.isVelodromeDex)(chainId, dex);
|
|
26
|
+
if (!isVelodrome) {
|
|
27
|
+
throw new Error(`This function is not supported on chain ${chainId} and dex ${dex}`);
|
|
28
|
+
}
|
|
29
|
+
const key = `rewardinfo-${chainId}-${vaultAddress}`;
|
|
30
|
+
const ttl = 6 * 60 * 60 * 1000; // 6 hours
|
|
31
|
+
const cachedData = cache_1.default.get(key);
|
|
32
|
+
if (cachedData) {
|
|
33
|
+
return cachedData;
|
|
34
|
+
}
|
|
35
|
+
const { url, publishedUrl } = (0, getGraphUrls_1.getGraphUrls)(chainId, dex);
|
|
36
|
+
try {
|
|
37
|
+
if (publishedUrl) {
|
|
38
|
+
const result = await sendRewardInfoQueryRequest(publishedUrl, vaultAddress, queries_1.rewardInfoQuery);
|
|
39
|
+
cache_1.default.set(key, result, ttl);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Published URL is invalid for ${vaultAddress}`);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (publishedUrl) {
|
|
46
|
+
console.error('Request to published graph URL failed:', error);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const result = await sendRewardInfoQueryRequest(url, vaultAddress, queries_1.rewardInfoQuery);
|
|
50
|
+
cache_1.default.set(key, result, ttl);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (error2) {
|
|
54
|
+
console.error('Request to public graph URL failed:', error2);
|
|
55
|
+
throw new Error(`Could not get Reward info for ${vaultAddress}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
123
58
|
}
|
|
124
59
|
exports.getRewardInfo = getRewardInfo;
|
|
125
|
-
function getAllRewardInfo(chainId, dex) {
|
|
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
|
-
_b.trys.push([5, 7, , 8]);
|
|
160
|
-
return [4 /*yield*/, sendAllRewardInfoQueryRequest(url, queries_1.allRewardInfoQuery)];
|
|
161
|
-
case 6:
|
|
162
|
-
result = _b.sent();
|
|
163
|
-
cache_1.default.set(key, result, ttl);
|
|
164
|
-
return [2 /*return*/, result];
|
|
165
|
-
case 7:
|
|
166
|
-
error2_2 = _b.sent();
|
|
167
|
-
console.error('Request to public graph URL failed:', error2_2);
|
|
168
|
-
throw new Error("Could not get all Reward info for ".concat(dex));
|
|
169
|
-
case 8: return [3 /*break*/, 9];
|
|
170
|
-
case 9: return [2 /*return*/];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
60
|
+
async function getAllRewardInfo(chainId, dex) {
|
|
61
|
+
const isVelodrome = (0, isVelodrome_1.isVelodromeDex)(chainId, dex);
|
|
62
|
+
if (!isVelodrome) {
|
|
63
|
+
throw new Error(`This function is not supported on chain ${chainId} and dex ${dex}`);
|
|
64
|
+
}
|
|
65
|
+
const key = `allrewardinfo-${chainId}-${dex}`;
|
|
66
|
+
const ttl = 6 * 60 * 60 * 1000; // 6 hours
|
|
67
|
+
const cachedData = cache_1.default.get(key);
|
|
68
|
+
if (cachedData) {
|
|
69
|
+
return cachedData;
|
|
70
|
+
}
|
|
71
|
+
const { url, publishedUrl } = (0, getGraphUrls_1.getGraphUrls)(chainId, dex);
|
|
72
|
+
try {
|
|
73
|
+
if (publishedUrl) {
|
|
74
|
+
const result = await sendAllRewardInfoQueryRequest(publishedUrl, queries_1.allRewardInfoQuery);
|
|
75
|
+
cache_1.default.set(key, result, ttl);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Published URL is invalid for ${dex}`);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (publishedUrl) {
|
|
82
|
+
console.error('Request to published graph URL failed:', error);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = await sendAllRewardInfoQueryRequest(url, queries_1.allRewardInfoQuery);
|
|
86
|
+
cache_1.default.set(key, result, ttl);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
catch (error2) {
|
|
90
|
+
console.error('Request to public graph URL failed:', error2);
|
|
91
|
+
throw new Error(`Could not get all Reward info for ${dex}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
174
94
|
}
|
|
175
95
|
exports.getAllRewardInfo = getAllRewardInfo;
|
|
176
96
|
//# sourceMappingURL=rewardInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewardInfo.js","sourceRoot":"","sources":["../../../src/functions/rewardInfo.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,yCAAyC;AACzC,oCAAoC;AACpC,iDAAiD
|
|
1
|
+
{"version":3,"file":"rewardInfo.js","sourceRoot":"","sources":["../../../src/functions/rewardInfo.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,yCAAyC;AACzC,oCAAoC;AACpC,iDAAiD;;;;;;AAEjD,sEAAsC;AAEtC,2DAAmC;AACnC,wDAAqD;AACrD,gDAAyE;AAEzE,sDAAsD;AAEtD,KAAK,UAAU,0BAA0B,CAAC,G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AY,EAAE;YAChB,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,YAAY,EAAE,4BAAkB,CAAC,CAAC;YACrF,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAC5B,OAAO,MAAM,CAAC;SACf;QACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC;KACxD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,YAAY,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;SAChE;QACD,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,GAAG,EAAE,4BAAkB,CAAC,CAAC;YAC5E,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAC5B,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,MAAM,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;SAC7D;KACF;AACH,CAAC;AAnCD,4CAmCC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { JsonRpcProvider } from '
|
|
2
|
-
import { BigNumber } from 'ethers';
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
3
2
|
import { SupportedDex, TotalAmounts, TotalAmountsBN } from '../types';
|
|
4
3
|
export declare function getTotalAmounts(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex): Promise<TotalAmounts>;
|
|
5
4
|
export declare function getTotalAmounts(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<TotalAmountsBN>;
|
|
6
5
|
export declare function getTotalSupply(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex): Promise<string>;
|
|
7
|
-
export declare function getTotalSupply(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<
|
|
6
|
+
export declare function getTotalSupply(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<bigint>;
|
|
@@ -1,78 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable no-redeclare */
|
|
3
3
|
/* eslint-disable import/prefer-default-export */
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
5
|
exports.getTotalSupply = exports.getTotalAmounts = void 0;
|
|
42
6
|
// eslint-disable-next-line import/no-cycle
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function getTotalAmounts(vaultAddress, jsonProvider, dex, raw) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case 1:
|
|
52
|
-
_a = _b.sent(), chainId = _a.chainId, vault = _a.vault;
|
|
53
|
-
if (!raw) {
|
|
54
|
-
return [2 /*return*/, (0, _totalBalances_1._getTotalAmounts)(vault, jsonProvider, chainId)];
|
|
55
|
-
}
|
|
56
|
-
return [2 /*return*/, (0, _totalBalances_1._getTotalAmounts)(vault, jsonProvider, chainId, true)];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
7
|
+
const vault_1 = require("./vault");
|
|
8
|
+
const _totalBalances_1 = require("./_totalBalances");
|
|
9
|
+
async function getTotalAmounts(vaultAddress, jsonProvider, dex, raw) {
|
|
10
|
+
const { chainId, vault } = await (0, vault_1.validateVaultData)(vaultAddress, jsonProvider, dex);
|
|
11
|
+
if (!raw) {
|
|
12
|
+
return (0, _totalBalances_1._getTotalAmounts)(vault, jsonProvider, chainId);
|
|
13
|
+
}
|
|
14
|
+
return (0, _totalBalances_1._getTotalAmounts)(vault, jsonProvider, chainId, true);
|
|
60
15
|
}
|
|
61
16
|
exports.getTotalAmounts = getTotalAmounts;
|
|
62
|
-
function getTotalSupply(vaultAddress, jsonProvider, dex, raw) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_a.sent();
|
|
69
|
-
if (!raw) {
|
|
70
|
-
return [2 /*return*/, (0, _totalBalances_1._getTotalSupply)(vaultAddress, jsonProvider)];
|
|
71
|
-
}
|
|
72
|
-
return [2 /*return*/, (0, _totalBalances_1._getTotalSupply)(vaultAddress, jsonProvider, true)];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
17
|
+
async function getTotalSupply(vaultAddress, jsonProvider, dex, raw) {
|
|
18
|
+
await (0, vault_1.validateVaultData)(vaultAddress, jsonProvider, dex);
|
|
19
|
+
if (!raw) {
|
|
20
|
+
return (0, _totalBalances_1._getTotalSupply)(vaultAddress, jsonProvider);
|
|
21
|
+
}
|
|
22
|
+
return (0, _totalBalances_1._getTotalSupply)(vaultAddress, jsonProvider, true);
|
|
76
23
|
}
|
|
77
24
|
exports.getTotalSupply = getTotalSupply;
|
|
78
25
|
//# sourceMappingURL=totalBalances.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"totalBalances.js","sourceRoot":"","sources":["../../../src/functions/totalBalances.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,iDAAiD
|
|
1
|
+
{"version":3,"file":"totalBalances.js","sourceRoot":"","sources":["../../../src/functions/totalBalances.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,iDAAiD;;;AAIjD,2CAA2C;AAC3C,mCAA4C;AAC5C,qDAAqE;AAe9D,KAAK,UAAU,eAAe,CACnC,YAAoB,EACpB,YAA6B,EAC7B,GAAiB,EACjB,GAAU;IAEV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,yBAAiB,EAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;IAEpF,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAA,iCAAgB,EAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;KACvD;IACD,OAAO,IAAA,iCAAgB,EAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AAZD,0CAYC;AAeM,KAAK,UAAU,cAAc,CAClC,YAAoB,EACpB,YAA6B,EAC7B,GAAiB,EACjB,GAAU;IAEV,MAAM,IAAA,yBAAiB,EAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;IAEzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAA,gCAAe,EAAC,YAAY,EAAE,YAAY,CAAC,CAAC;KACpD;IACD,OAAO,IAAA,gCAAe,EAAC,YAAY,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAZD,wCAYC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { JsonRpcProvider } from '
|
|
2
|
-
import { BigNumber } from 'ethers';
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
3
2
|
import { SupportedDex, UserAmounts, UserAmountsBN, UserAmountsInVault, UserAmountsInVaultBN, UserBalanceInVault, UserBalanceInVaultBN } from '../types';
|
|
4
3
|
import { UserBalancesQueryData } from '../types/vaultQueryData';
|
|
5
4
|
export declare function getUserBalance(accountAddress: string, vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex): Promise<string>;
|
|
6
|
-
export declare function getUserBalance(accountAddress: string, vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<
|
|
5
|
+
export declare function getUserBalance(accountAddress: string, vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<bigint>;
|
|
7
6
|
export declare function sendUserBalancesQueryRequest(url: string, accountAddress: string, query: string, vaultAddress?: string): Promise<UserBalancesQueryData['user']>;
|
|
8
7
|
export declare function getAllUserBalances(accountAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex): Promise<UserBalanceInVault[]>;
|
|
9
8
|
export declare function getAllUserBalances(accountAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, raw: true): Promise<UserBalanceInVaultBN[]>;
|