@ichidao/ichi-vaults-sdk 0.0.18 → 0.0.20
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 +157 -48
- package/dist/abis/types/AlgebraPool.d.ts +817 -0
- package/dist/abis/types/AlgebraPool.js +3 -0
- package/dist/abis/types/AlgebraPool.js.map +1 -0
- package/dist/abis/types/DepositGuard.d.ts +100 -13
- package/dist/abis/types/UniswapV3Pool.d.ts +771 -0
- package/dist/abis/types/UniswapV3Pool.js +3 -0
- package/dist/abis/types/UniswapV3Pool.js.map +1 -0
- package/dist/abis/types/factories/AlgebraPool__factory.d.ts +821 -0
- package/dist/abis/types/factories/AlgebraPool__factory.js +1062 -0
- package/dist/abis/types/factories/AlgebraPool__factory.js.map +1 -0
- package/dist/abis/types/factories/DepositGuard__factory.d.ts +124 -4
- package/dist/abis/types/factories/DepositGuard__factory.js +160 -5
- package/dist/abis/types/factories/DepositGuard__factory.js.map +1 -1
- package/dist/abis/types/factories/UniswapV3Pool__factory.d.ts +781 -0
- package/dist/abis/types/factories/UniswapV3Pool__factory.js +1009 -0
- package/dist/abis/types/factories/UniswapV3Pool__factory.js.map +1 -0
- package/dist/abis/types/factories/index.d.ts +2 -0
- package/dist/abis/types/factories/index.js +5 -1
- package/dist/abis/types/factories/index.js.map +1 -1
- package/dist/abis/types/index.d.ts +4 -0
- package/dist/abis/types/index.js +5 -1
- package/dist/abis/types/index.js.map +1 -1
- package/dist/src/__tests__/index.test.js +37 -41
- package/dist/src/__tests__/index.test.js.map +1 -1
- package/dist/src/abis/types/AlgebraPool.d.ts +817 -0
- package/dist/src/abis/types/DepositGuard.d.ts +100 -13
- package/dist/src/abis/types/UniswapV3Pool.d.ts +771 -0
- package/dist/src/abis/types/factories/AlgebraPool__factory.d.ts +821 -0
- package/dist/src/abis/types/factories/DepositGuard__factory.d.ts +124 -4
- package/dist/src/abis/types/factories/UniswapV3Pool__factory.d.ts +781 -0
- package/dist/src/abis/types/factories/index.d.ts +2 -0
- package/dist/src/abis/types/index.d.ts +4 -0
- package/dist/src/contracts/index.d.ts +4 -1
- package/dist/src/contracts/index.js +21 -1
- package/dist/src/contracts/index.js.map +1 -1
- package/dist/src/functions/balances.js +4 -4
- package/dist/src/functions/balances.js.map +1 -1
- package/dist/src/functions/{feesCollected.d.ts → calculateFees.d.ts} +2 -1
- package/dist/src/functions/calculateFees.js +315 -0
- package/dist/src/functions/calculateFees.js.map +1 -0
- package/dist/src/functions/deposit.js +8 -8
- package/dist/src/functions/deposit.js.map +1 -1
- package/dist/src/functions/fees.d.ts +4 -0
- package/dist/src/functions/fees.js +189 -0
- package/dist/src/functions/fees.js.map +1 -0
- package/dist/src/functions/vault.js +13 -11
- package/dist/src/functions/vault.js.map +1 -1
- package/dist/src/functions/withdraw.js +1 -1
- package/dist/src/functions/withdraw.js.map +1 -1
- package/dist/src/graphql/constants.d.ts +5 -1
- package/dist/src/graphql/constants.js +78 -24
- package/dist/src/graphql/constants.js.map +1 -1
- package/dist/src/graphql/queries.d.ts +2 -1
- package/dist/src/graphql/queries.js +6 -3
- package/dist/src/graphql/queries.js.map +1 -1
- package/dist/src/index.cjs.js +2 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.esm.js +2 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/src/contracts/index.d.ts +4 -1
- package/dist/src/src/functions/{feesCollected.d.ts → calculateFees.d.ts} +2 -1
- package/dist/src/src/functions/fees.d.ts +4 -0
- package/dist/src/src/graphql/constants.d.ts +5 -1
- package/dist/src/src/graphql/queries.d.ts +2 -1
- package/dist/src/src/index.d.ts +1 -0
- package/dist/src/src/types/index.d.ts +10 -1
- package/dist/src/src/types/vaultQueryData.d.ts +5 -2
- package/dist/src/src/utils/config/addresses.d.ts +5 -1
- package/dist/src/src/utils/getPrice.d.ts +2 -0
- package/dist/src/src/utils/timestamps.d.ts +1 -0
- package/dist/src/types/index.d.ts +10 -1
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/vaultQueryData.d.ts +5 -2
- package/dist/src/utils/config/addresses.d.ts +5 -1
- package/dist/src/utils/config/addresses.js +120 -33
- package/dist/src/utils/config/addresses.js.map +1 -1
- package/dist/src/utils/getPrice.d.ts +2 -0
- package/dist/src/utils/getPrice.js +18 -0
- package/dist/src/utils/getPrice.js.map +1 -0
- package/dist/src/utils/timestamps.d.ts +1 -0
- package/dist/src/utils/timestamps.js +7 -0
- package/dist/src/utils/timestamps.js.map +1 -0
- package/package.json +2 -1
- package/dist/src/functions/feesCollected.js +0 -109
- package/dist/src/functions/feesCollected.js.map +0 -1
- package/dist/src/functions/rebalances.d.ts +0 -4
- package/dist/src/functions/rebalances.js +0 -102
- package/dist/src/functions/rebalances.js.map +0 -1
- package/dist/src/src/functions/rebalances.d.ts +0 -4
@@ -1,102 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
-
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;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.getRebalances = void 0;
|
40
|
-
/* eslint-disable camelcase */
|
41
|
-
/* eslint-disable radix */
|
42
|
-
// eslint-disable-next-line import/no-unresolved
|
43
|
-
var graphql_request_1 = require("graphql-request");
|
44
|
-
var types_1 = require("../types");
|
45
|
-
var constants_1 = require("../graphql/constants");
|
46
|
-
var queries_1 = require("../graphql/queries");
|
47
|
-
var promises = {};
|
48
|
-
function daysToMilliseconds(days) {
|
49
|
-
return days * 24 * 60 * 60 * 1000;
|
50
|
-
}
|
51
|
-
// eslint-disable-next-line import/prefer-default-export
|
52
|
-
function getRebalances(vaultAddress, jsonProvider, dex, days) {
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
54
|
-
var chainId, key, url, currTimestamp, startTimestamp;
|
55
|
-
return __generator(this, function (_a) {
|
56
|
-
switch (_a.label) {
|
57
|
-
case 0: return [4 /*yield*/, jsonProvider.getNetwork()];
|
58
|
-
case 1:
|
59
|
-
chainId = (_a.sent()).chainId;
|
60
|
-
if (!Object.values(types_1.SupportedChainId).includes(chainId)) {
|
61
|
-
throw new Error("Unsupported chainId: ".concat(chainId !== null && chainId !== void 0 ? chainId : 'undefined'));
|
62
|
-
}
|
63
|
-
key = "".concat(chainId + vaultAddress, "-rebalances");
|
64
|
-
if (Object.prototype.hasOwnProperty.call(promises, key))
|
65
|
-
return [2 /*return*/, promises[key]];
|
66
|
-
url = constants_1.graphUrls[chainId][dex];
|
67
|
-
if (!url)
|
68
|
-
throw new Error("Unsupported DEX ".concat(dex, " on chain ").concat(chainId));
|
69
|
-
currTimestamp = Date.now();
|
70
|
-
startTimestamp = days
|
71
|
-
? parseInt(((currTimestamp - daysToMilliseconds(days)) / 1000).toString()).toString()
|
72
|
-
: '0';
|
73
|
-
if (url === 'none' && jsonProvider) {
|
74
|
-
// promises[key] = [];
|
75
|
-
}
|
76
|
-
else {
|
77
|
-
promises[key] = (0, graphql_request_1.request)(url, queries_1.rebalancesQuery, {
|
78
|
-
vaultAddress: vaultAddress,
|
79
|
-
createdAtTimestamp_gt: startTimestamp,
|
80
|
-
})
|
81
|
-
.then(function (_a) {
|
82
|
-
var vaultRebalances = _a.vaultRebalances;
|
83
|
-
return vaultRebalances;
|
84
|
-
})
|
85
|
-
.catch(function (err) {
|
86
|
-
console.error(err);
|
87
|
-
if (jsonProvider) {
|
88
|
-
// promises[key] = getVaultInfoFromContract(vaultAddress, jsonProvider);
|
89
|
-
}
|
90
|
-
})
|
91
|
-
.finally(function () { return setTimeout(function () { return delete promises[key]; }, 2 * 60 * 100 /* 2 mins */); });
|
92
|
-
}
|
93
|
-
return [4 /*yield*/, promises[key]];
|
94
|
-
case 2:
|
95
|
-
// eslint-disable-next-line no-return-await
|
96
|
-
return [2 /*return*/, _a.sent()];
|
97
|
-
}
|
98
|
-
});
|
99
|
-
});
|
100
|
-
}
|
101
|
-
exports.getRebalances = getRebalances;
|
102
|
-
//# sourceMappingURL=rebalances.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rebalances.js","sourceRoot":"","sources":["../../../src/functions/rebalances.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,0BAA0B;AAC1B,gDAAgD;AAChD,mDAA0C;AAE1C,kCAA0D;AAG1D,kDAAiD;AACjD,8CAAqD;AAErD,IAAM,QAAQ,GAAiC,EAAE,CAAC;AAElD,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,CAAC;AAED,wDAAwD;AACxD,SAAsB,aAAa,CACjC,YAAoB,EACpB,YAA6B,EAC7B,GAAiB,EACjB,IAAa;;;;;wBAEO,qBAAM,YAAY,CAAC,UAAU,EAAE,EAAA;;oBAA3C,OAAO,GAAK,CAAA,SAA+B,CAAA,QAApC;oBACf,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;wBACtD,MAAM,IAAI,KAAK,CAAC,+BAAwB,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAE,CAAC,CAAC;qBACnE;oBAEK,GAAG,GAAG,UAAG,OAAO,GAAG,YAAY,gBAAa,CAAC;oBACnD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG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D,sCA6CC"}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import { JsonRpcProvider } from '@ethersproject/providers';
|
2
|
-
import { SupportedDex } from '../types';
|
3
|
-
import { RebalancesQueryData } from '../types/vaultQueryData';
|
4
|
-
export declare function getRebalances(vaultAddress: string, jsonProvider: JsonRpcProvider, dex: SupportedDex, days?: number): Promise<RebalancesQueryData['vaultRebalances']>;
|