@gearbox-protocol/sdk 0.0.100 → 0.0.103
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/.eslintignore +4 -0
- package/.eslintrc.js +52 -0
- package/.husky/pre-push +4 -0
- package/lib/apy/convexAPY.d.ts +8 -0
- package/lib/apy/convexAPY.js +200 -0
- package/lib/apy/lidoAPY.d.ts +4 -0
- package/lib/apy/lidoAPY.js +103 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +2 -1
- package/lib/contracts/contracts.d.ts +9 -4
- package/lib/contracts/contracts.js +52 -14
- package/lib/contracts/contractsRegister.js +16 -4
- package/lib/core/constants.d.ts +7 -1
- package/lib/core/constants.js +11 -5
- package/lib/core/creditAccount.d.ts +3 -1
- package/lib/core/creditAccount.js +33 -31
- package/lib/core/creditManager.d.ts +13 -2
- package/lib/core/creditManager.js +77 -33
- package/lib/core/creditSession.js +14 -3
- package/lib/core/errors.d.ts +10 -0
- package/lib/core/errors.js +16 -1
- package/lib/core/eventOrTx.d.ts +1 -1
- package/lib/core/events.d.ts +19 -19
- package/lib/core/events.js +32 -30
- package/lib/core/multicall.d.ts +1 -1
- package/lib/core/pool.d.ts +2 -2
- package/lib/core/pool.js +8 -12
- package/lib/core/price.d.ts +2 -0
- package/lib/core/price.js +14 -0
- package/lib/core/strategy.d.ts +36 -0
- package/lib/core/strategy.js +57 -0
- package/lib/core/tokenDistributor.js +1 -1
- package/lib/core/transactions.d.ts +18 -3
- package/lib/core/transactions.js +39 -3
- package/lib/index.d.ts +8 -3
- package/lib/index.js +9 -4
- package/lib/oracles/priceFeeds.js +1 -1
- package/lib/pathfinder/convexLP.d.ts +1 -1
- package/lib/pathfinder/convexLP.js +26 -29
- package/lib/pathfinder/curveLP.d.ts +1 -1
- package/lib/pathfinder/curveLP.js +5 -7
- package/lib/pathfinder/path.d.ts +1 -1
- package/lib/pathfinder/path.js +38 -42
- package/lib/pathfinder/trade.d.ts +1 -2
- package/lib/pathfinder/tradeTypes.d.ts +5 -5
- package/lib/pathfinder/yVault.d.ts +2 -2
- package/lib/pathfinder/yVault.js +22 -19
- package/lib/payload/creditAccount.d.ts +4 -26
- package/lib/payload/creditManager.d.ts +3 -25
- package/lib/payload/pool.d.ts +2 -17
- package/lib/payload/pool.js +0 -1
- package/lib/strategies/curve.d.ts +6 -60
- package/lib/strategies/curve.js +6 -0
- package/lib/strategies/uniswapV2.js +3 -19
- package/lib/strategies/uniswapV3.js +1 -1
- package/lib/strategies/yearn.js +15 -11
- package/lib/tokens/convex.d.ts +3 -3
- package/lib/tokens/curveLP.d.ts +2 -2
- package/lib/tokens/curveLP.js +1 -1
- package/lib/tokens/gear.d.ts +2 -2
- package/lib/tokens/gear.js +1 -1
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/token.js +9 -9
- package/lib/tokens/tokenData.d.ts +3 -1
- package/lib/tokens/tokenData.js +10 -8
- package/lib/tokens/yearn.d.ts +3 -3
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/formatter.d.ts +2 -1
- package/lib/utils/formatter.js +23 -15
- package/lib/utils/loading.d.ts +2 -1
- package/lib/utils/loading.js +9 -13
- package/lib/utils/mappers.d.ts +2 -1
- package/lib/utils/mappers.js +13 -5
- package/lib/utils/multicall.js +4 -3
- package/lib/utils/network.js +2 -2
- package/lib/utils/repeater.js +12 -24
- package/lib/utils/types.d.ts +1 -0
- package/lib/utils/validate.js +1 -1
- package/package.json +26 -8
- package/src/apy/convexAPY.ts +250 -0
- package/src/apy/lidoAPY.ts +89 -0
- package/src/config.ts +2 -1
- package/src/contracts/contracts.ts +73 -19
- package/src/contracts/contractsRegister.ts +19 -4
- package/src/core/constants.ts +11 -4
- package/src/core/creditAccount.ts +69 -37
- package/src/core/creditManager.ts +256 -148
- package/src/core/creditOperation.ts +7 -7
- package/src/core/creditSession.ts +25 -5
- package/src/core/errors.ts +25 -0
- package/src/core/eventOrTx.ts +8 -5
- package/src/core/events.ts +978 -911
- package/src/core/history.ts +46 -46
- package/src/core/multicall.ts +1 -1
- package/src/core/operations.ts +6 -0
- package/src/core/pool.ts +75 -58
- package/src/core/price.ts +13 -0
- package/src/core/strategy.ts +134 -0
- package/src/core/tokenDistributor.ts +2 -2
- package/src/core/transactions.ts +427 -350
- package/src/index.ts +9 -4
- package/src/oracles/priceFeeds.ts +523 -523
- package/src/pathfinder/contracts.ts +15 -13
- package/src/pathfinder/convexLP.ts +29 -25
- package/src/pathfinder/curveLP.ts +57 -53
- package/src/pathfinder/path.ts +158 -150
- package/src/pathfinder/priority.ts +11 -11
- package/src/pathfinder/trade.ts +84 -77
- package/src/pathfinder/tradeTypes.ts +98 -94
- package/src/pathfinder/yVault.ts +79 -63
- package/src/payload/creditAccount.ts +4 -26
- package/src/payload/creditManager.ts +4 -26
- package/src/payload/pool.ts +2 -19
- package/src/payload/token.ts +3 -3
- package/src/strategies/convex.ts +217 -210
- package/src/strategies/creditFacade.ts +70 -53
- package/src/strategies/curve.ts +263 -194
- package/src/strategies/lido.ts +33 -37
- package/src/strategies/uniswapV2.ts +90 -112
- package/src/strategies/uniswapV3.ts +114 -91
- package/src/strategies/yearn.ts +58 -62
- package/src/tokens/connectors.ts +6 -6
- package/src/tokens/convex.ts +297 -296
- package/src/tokens/curveLP.ts +170 -165
- package/src/tokens/gear.ts +47 -45
- package/src/tokens/normal.ts +801 -802
- package/src/tokens/token.ts +19 -10
- package/src/tokens/tokenData.ts +19 -9
- package/src/tokens/tokenType.ts +11 -11
- package/src/tokens/yearn.ts +126 -124
- package/src/utils/errors.ts +11 -0
- package/src/utils/formatter.ts +26 -18
- package/src/utils/loading.ts +14 -6
- package/src/utils/mappers.ts +15 -6
- package/src/utils/multicall.ts +6 -9
- package/src/utils/network.ts +21 -21
- package/src/utils/repeater.ts +2 -2
- package/src/utils/types.ts +6 -2
- package/src/utils/validate.ts +1 -1
- package/lib/core/adapters.d.ts +0 -15
- package/lib/core/adapters.js +0 -19
- package/lib/core/contracts.d.ts +0 -67
- package/lib/core/contracts.js +0 -254
- package/lib/core/contractsRegister.d.ts +0 -2
- package/lib/core/contractsRegister.js +0 -58
- package/lib/core/creditCard.d.ts +0 -13
- package/lib/core/creditCard.js +0 -2
- package/lib/core/oracles.d.ts +0 -38
- package/lib/core/oracles.js +0 -12
- package/lib/core/priceFeeds.d.ts +0 -3
- package/lib/core/priceFeeds.js +0 -492
- package/lib/core/protocols.d.ts +0 -13
- package/lib/core/protocols.js +0 -39
- package/lib/core/swap.d.ts +0 -4
- package/lib/core/swap.js +0 -8
- package/lib/core/trade.d.ts +0 -35
- package/lib/core/trade.js +0 -62
- package/lib/core/tradeTypes.d.ts +0 -79
- package/lib/core/tradeTypes.js +0 -21
- package/lib/utils/events.d.ts +0 -2
- package/lib/utils/events.js +0 -13
- package/src/utils/events.ts +0 -10
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: "@typescript-eslint/parser",
|
|
4
|
+
parserOptions: {
|
|
5
|
+
project: ["./tsconfig.json"],
|
|
6
|
+
tsconfigRootDir: __dirname
|
|
7
|
+
},
|
|
8
|
+
plugins: ["@typescript-eslint", "prettier"],
|
|
9
|
+
extends: [
|
|
10
|
+
"airbnb-base",
|
|
11
|
+
"airbnb-typescript/base",
|
|
12
|
+
"plugin:import/recommended",
|
|
13
|
+
"prettier"
|
|
14
|
+
],
|
|
15
|
+
settings: {
|
|
16
|
+
"import/resolver": {
|
|
17
|
+
typescript: {},
|
|
18
|
+
node: {
|
|
19
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
20
|
+
moduleDirectory: ["node_modules", "./"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
react: {
|
|
24
|
+
version: "detect"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
"prettier/prettier": "error",
|
|
29
|
+
"import/no-extraneous-dependencies": ["error", { devDependencies: true }],
|
|
30
|
+
"@typescript-eslint/no-use-before-define": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
functions: false,
|
|
34
|
+
classes: false
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"no-console": ["error", { allow: ["warn", "error", "debug"] }],
|
|
38
|
+
"@typescript-eslint/default-param-last": ["warn"],
|
|
39
|
+
|
|
40
|
+
"no-nested-ternary": ["warn"],
|
|
41
|
+
"@typescript-eslint/no-unused-vars": ["warn"],
|
|
42
|
+
"no-underscore-dangle": ["error", { allowAfterThis: true }],
|
|
43
|
+
|
|
44
|
+
"react/no-unused-prop-types": ["off"], // switch on when necessary
|
|
45
|
+
"max-classes-per-file": ["off"],
|
|
46
|
+
"react/jsx-props-no-spreading": ["off"],
|
|
47
|
+
"react/no-array-index-key": ["off"],
|
|
48
|
+
"react/require-default-props": ["off"],
|
|
49
|
+
"import/prefer-default-export": ["off"],
|
|
50
|
+
"react/jsx-no-useless-fragment": ["off"]
|
|
51
|
+
}
|
|
52
|
+
};
|
package/.husky/pre-push
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BigNumber, providers } from "ethers";
|
|
2
|
+
import { ConvexPoolContract } from "../contracts/contracts";
|
|
3
|
+
import { CurveLPToken } from "../tokens/curveLP";
|
|
4
|
+
import { NetworkType } from "../core/constants";
|
|
5
|
+
declare type SupportedPools = Extract<ConvexPoolContract, "CONVEX_3CRV_POOL" | "CONVEX_FRAX3CRV_POOL" | "CONVEX_LUSD3CRV_POOL" | "CONVEX_GUSD_POOL" | "CONVEX_SUSD_POOL">;
|
|
6
|
+
export declare function getConvexApy(pool: SupportedPools, provider: providers.Provider, networkType: NetworkType, getTokenPrice: (tokenAddress: string) => BigNumber): Promise<BigNumber>;
|
|
7
|
+
export declare function getCurveBaseApy(curveLPToken: CurveLPToken): Promise<BigNumber>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
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 (_) 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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.getCurveBaseApy = exports.getConvexApy = void 0;
|
|
52
|
+
var ethers_1 = require("ethers");
|
|
53
|
+
var axios_1 = __importDefault(require("axios"));
|
|
54
|
+
var contracts_1 = require("../contracts/contracts");
|
|
55
|
+
var token_1 = require("../tokens/token");
|
|
56
|
+
var types_1 = require("../types");
|
|
57
|
+
var multicall_1 = require("../utils/multicall");
|
|
58
|
+
var formatter_1 = require("../utils/formatter");
|
|
59
|
+
var constants_1 = require("../core/constants");
|
|
60
|
+
var curveSwapByPool = {
|
|
61
|
+
CONVEX_3CRV_POOL: "CURVE_3CRV_POOL",
|
|
62
|
+
CONVEX_FRAX3CRV_POOL: "CURVE_FRAX_POOL",
|
|
63
|
+
CONVEX_LUSD3CRV_POOL: "CURVE_LUSD_POOL",
|
|
64
|
+
CONVEX_GUSD_POOL: "CURVE_GUSD_POOL",
|
|
65
|
+
CONVEX_SUSD_POOL: "CURVE_SUSD_POOL"
|
|
66
|
+
};
|
|
67
|
+
function getConvexApy(pool, provider, networkType, getTokenPrice) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var tokenList, contractsList, poolParams, stakedTokenParams, underlying, basePoolAddress, swapPoolAddress, cvxAddress, extraPoolAddresses, _a, basePoolRate, basePoolSupply, vPrice, cvxSupply, extra, cvxPrice, crvPrice, crvPerSecond, virtualSupply, crvPerUnderlying, crvPerYear, cvxPerYear, crvAPY, cvxAPY, extraAPRs, extraAPYTotal, baseApyRAY;
|
|
70
|
+
var _this = this;
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
tokenList = token_1.tokenDataByNetwork[networkType];
|
|
75
|
+
contractsList = contracts_1.contractsByNetwork[networkType];
|
|
76
|
+
poolParams = contracts_1.contractParams[pool];
|
|
77
|
+
stakedTokenParams = token_1.supportedTokens[poolParams.stakedToken];
|
|
78
|
+
underlying = stakedTokenParams.underlying;
|
|
79
|
+
basePoolAddress = contractsList[pool];
|
|
80
|
+
swapPoolAddress = contractsList[curveSwapByPool[pool]];
|
|
81
|
+
cvxAddress = tokenList.CVX;
|
|
82
|
+
extraPoolAddresses = poolParams.extraRewards.map(function (d) { return d.poolAddress[networkType]; });
|
|
83
|
+
return [4 /*yield*/, getPoolData(basePoolAddress, swapPoolAddress, cvxAddress, extraPoolAddresses, provider)];
|
|
84
|
+
case 1:
|
|
85
|
+
_a = _b.sent(), basePoolRate = _a[0], basePoolSupply = _a[1], vPrice = _a[2], cvxSupply = _a[3], extra = _a.slice(4);
|
|
86
|
+
cvxPrice = getTokenPrice(tokenList.CVX);
|
|
87
|
+
crvPrice = getTokenPrice(tokenList.CRV);
|
|
88
|
+
crvPerSecond = basePoolRate;
|
|
89
|
+
virtualSupply = basePoolSupply.mul(vPrice).div(constants_1.WAD);
|
|
90
|
+
crvPerUnderlying = crvPerSecond.mul(constants_1.WAD).div(virtualSupply);
|
|
91
|
+
crvPerYear = crvPerUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
92
|
+
cvxPerYear = getCVXMintAmount(crvPerYear, cvxSupply);
|
|
93
|
+
crvAPY = crvPerYear.mul(cvxPrice).div(constants_1.PRICE_DECIMALS);
|
|
94
|
+
cvxAPY = cvxPerYear.mul(crvPrice).div(constants_1.PRICE_DECIMALS);
|
|
95
|
+
return [4 /*yield*/, Promise.all(extraPoolAddresses.map(function (_, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
var extraRewardSymbol, extraPoolRate, perUnderlying, perYear, extraPrise, extraAPY;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
extraRewardSymbol = poolParams.extraRewards[index].rewardToken;
|
|
99
|
+
extraPoolRate = extra[index];
|
|
100
|
+
perUnderlying = extraPoolRate.mul(constants_1.WAD).div(virtualSupply);
|
|
101
|
+
perYear = perUnderlying.mul(constants_1.SECONDS_PER_YEAR);
|
|
102
|
+
extraPrise = getTokenPrice(tokenList[extraRewardSymbol]);
|
|
103
|
+
extraAPY = perYear.mul(extraPrise).div(constants_1.PRICE_DECIMALS);
|
|
104
|
+
return [2 /*return*/, extraAPY];
|
|
105
|
+
});
|
|
106
|
+
}); }))];
|
|
107
|
+
case 2:
|
|
108
|
+
extraAPRs = _b.sent();
|
|
109
|
+
extraAPYTotal = extraAPRs.reduce(function (acc, apy) { return acc.add(apy); }, ethers_1.BigNumber.from(0));
|
|
110
|
+
return [4 /*yield*/, getCurveBaseApy(underlying)];
|
|
111
|
+
case 3:
|
|
112
|
+
baseApyRAY = _b.sent();
|
|
113
|
+
return [2 /*return*/, baseApyRAY.add(crvAPY).add(cvxAPY).add(extraAPYTotal)];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.getConvexApy = getConvexApy;
|
|
119
|
+
var CVX_MAX_SUPPLY = constants_1.WAD.mul(100000000);
|
|
120
|
+
var CVX_REDUCTION_PER_CLIFF = ethers_1.BigNumber.from(100000);
|
|
121
|
+
var CVX_TOTAL_CLIFFS = constants_1.WAD.mul(1000);
|
|
122
|
+
function getCVXMintAmount(crvAmount, cvxSupply) {
|
|
123
|
+
var currentCliff = cvxSupply.div(CVX_REDUCTION_PER_CLIFF);
|
|
124
|
+
if (currentCliff.lt(CVX_TOTAL_CLIFFS)) {
|
|
125
|
+
var remainingCliffs = CVX_TOTAL_CLIFFS.sub(currentCliff);
|
|
126
|
+
var mintedAmount = crvAmount.mul(remainingCliffs).div(CVX_TOTAL_CLIFFS);
|
|
127
|
+
var amountTillMax = CVX_MAX_SUPPLY.sub(cvxSupply);
|
|
128
|
+
return mintedAmount.gt(amountTillMax) ? amountTillMax : mintedAmount;
|
|
129
|
+
}
|
|
130
|
+
return ethers_1.BigNumber.from(0);
|
|
131
|
+
}
|
|
132
|
+
function getPoolData(basePoolAddress, underlying, cvxAddress, extraPoolAddresses, provider) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
var calls;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
calls = __spreadArray([
|
|
137
|
+
{
|
|
138
|
+
address: basePoolAddress,
|
|
139
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
140
|
+
method: "rewardRate()"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
address: basePoolAddress,
|
|
144
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
145
|
+
method: "totalSupply()"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
address: underlying,
|
|
149
|
+
interface: types_1.CurveV1AdapterStETH__factory.createInterface(),
|
|
150
|
+
method: "get_virtual_price()"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
address: cvxAddress,
|
|
154
|
+
interface: types_1.IConvexToken__factory.createInterface(),
|
|
155
|
+
method: "totalSupply()"
|
|
156
|
+
}
|
|
157
|
+
], extraPoolAddresses.map(function (extraPoolAddress) { return ({
|
|
158
|
+
address: extraPoolAddress,
|
|
159
|
+
interface: types_1.IBaseRewardPool__factory.createInterface(),
|
|
160
|
+
method: "rewardRate()"
|
|
161
|
+
}); }), true);
|
|
162
|
+
return [2 /*return*/, (0, multicall_1.multicall)(calls, provider)];
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
var curveLPTokenToPoolName = {
|
|
167
|
+
"3Crv": "3pool",
|
|
168
|
+
FRAX3CRV: "frax",
|
|
169
|
+
gusd3CRV: "gusd",
|
|
170
|
+
LUSD3CRV: "lusd",
|
|
171
|
+
crvPlain3andSUSD: "susdv2",
|
|
172
|
+
steCRV: "steth"
|
|
173
|
+
};
|
|
174
|
+
var RESPONSE_DECIMALS = 100;
|
|
175
|
+
// https://www.convexfinance.com/api/curve-apys
|
|
176
|
+
function getCurveBaseApy(curveLPToken) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
178
|
+
var poolName, url, result, _a, baseApy, e_1;
|
|
179
|
+
return __generator(this, function (_b) {
|
|
180
|
+
switch (_b.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
poolName = curveLPTokenToPoolName[curveLPToken];
|
|
183
|
+
_b.label = 1;
|
|
184
|
+
case 1:
|
|
185
|
+
_b.trys.push([1, 3, , 4]);
|
|
186
|
+
url = "https://www.convexfinance.com/api/curve-apys";
|
|
187
|
+
return [4 /*yield*/, axios_1.default.get(url)];
|
|
188
|
+
case 2:
|
|
189
|
+
result = _b.sent();
|
|
190
|
+
_a = (result.data.apys[poolName] || {}).baseApy, baseApy = _a === void 0 ? 0 : _a;
|
|
191
|
+
return [2 /*return*/, (0, formatter_1.toBN)((baseApy / RESPONSE_DECIMALS).toString(), constants_1.WAD_DECIMALS_POW)];
|
|
192
|
+
case 3:
|
|
193
|
+
e_1 = _b.sent();
|
|
194
|
+
return [2 /*return*/, ethers_1.BigNumber.from(0)];
|
|
195
|
+
case 4: return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
exports.getCurveBaseApy = getCurveBaseApy;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { NetworkType } from "../core/constants";
|
|
3
|
+
export declare function getLidoApy(provider: providers.Provider, networkType: NetworkType): Promise<readonly [import("ethers").BigNumber, number]>;
|
|
4
|
+
export declare const LIDO_FEE_DECIMALS = 10000;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 (_) 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.LIDO_FEE_DECIMALS = exports.getLidoApy = void 0;
|
|
40
|
+
var multicall_1 = require("../utils/multicall");
|
|
41
|
+
var contracts_1 = require("../contracts/contracts");
|
|
42
|
+
var token_1 = require("../tokens/token");
|
|
43
|
+
var constants_1 = require("../core/constants");
|
|
44
|
+
var types_1 = require("../types");
|
|
45
|
+
var lidoOracles = contracts_1.contractParams.LIDO_STETH_GATEWAY.oracle;
|
|
46
|
+
var lidoStEth = {
|
|
47
|
+
Mainnet: token_1.tokenDataByNetwork.Mainnet.STETH,
|
|
48
|
+
Kovan: token_1.tokenDataByNetwork.Kovan.STETH
|
|
49
|
+
};
|
|
50
|
+
function getLidoApy(provider, networkType) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var _a, _b, postTotalPooledEther, preTotalPooledEther, timeElapsed, fee, lidoAPRRay;
|
|
53
|
+
return __generator(this, function (_c) {
|
|
54
|
+
switch (_c.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
if (!lidoOracles[networkType]) {
|
|
57
|
+
throw new Error("No Lido APR oracle found on current network: ".concat(networkType));
|
|
58
|
+
}
|
|
59
|
+
if (!lidoStEth[networkType]) {
|
|
60
|
+
throw new Error("No Lido stETH found on current network: ".concat(networkType));
|
|
61
|
+
}
|
|
62
|
+
return [4 /*yield*/, geLidoData(lidoOracles[networkType], lidoStEth[networkType], provider, networkType)];
|
|
63
|
+
case 1:
|
|
64
|
+
_a = _c.sent(), _b = _a[0], postTotalPooledEther = _b.postTotalPooledEther, preTotalPooledEther = _b.preTotalPooledEther, timeElapsed = _b.timeElapsed, fee = _a[1];
|
|
65
|
+
lidoAPRRay = postTotalPooledEther
|
|
66
|
+
.sub(preTotalPooledEther)
|
|
67
|
+
.mul(constants_1.SECONDS_PER_YEAR)
|
|
68
|
+
.mul(constants_1.WAD)
|
|
69
|
+
.div(preTotalPooledEther.mul(timeElapsed));
|
|
70
|
+
return [2 /*return*/, [lidoAPRRay, fee]];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.getLidoApy = getLidoApy;
|
|
76
|
+
exports.LIDO_FEE_DECIMALS = 10000;
|
|
77
|
+
function geLidoData(lidoOracleAddress, stETHAddress, provider, network) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var calls, _a, stats, _b, fee;
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
switch (_c.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
calls = [
|
|
84
|
+
{
|
|
85
|
+
address: lidoOracleAddress,
|
|
86
|
+
interface: types_1.ILidoOracle__factory.createInterface(),
|
|
87
|
+
method: "getLastCompletedReportDelta()"
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
if (network !== "Kovan")
|
|
91
|
+
calls.push({
|
|
92
|
+
address: stETHAddress,
|
|
93
|
+
interface: types_1.IstETH__factory.createInterface(),
|
|
94
|
+
method: "getFee()"
|
|
95
|
+
});
|
|
96
|
+
return [4 /*yield*/, (0, multicall_1.multicall)(calls, provider)];
|
|
97
|
+
case 1:
|
|
98
|
+
_a = _c.sent(), stats = _a[0], _b = _a[1], fee = _b === void 0 ? Math.floor(exports.LIDO_FEE_DECIMALS / 10) : _b;
|
|
99
|
+
return [2 /*return*/, [stats, fee]];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STATIC_TOKEN = void 0;
|
|
3
|
+
exports.MULTICALL_ADDRESS = exports.STATIC_TOKEN = void 0;
|
|
4
4
|
exports.STATIC_TOKEN = "https://static.gearbox.fi/tokens/";
|
|
5
|
+
exports.MULTICALL_ADDRESS = "0x5ba1e12693dc8f9c48aad8770482f4739beed696";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AdapterInterface } from "./adapters";
|
|
2
2
|
import { NetworkType } from "../core/constants";
|
|
3
3
|
import { Protocols } from "./protocols";
|
|
4
|
-
import { ConvexStakedPhantomToken } from "../tokens/convex";
|
|
5
|
-
import { CurveLPToken } from "../tokens/curveLP";
|
|
6
|
-
import { NormalToken } from "../tokens/normal";
|
|
4
|
+
import type { ConvexStakedPhantomToken } from "../tokens/convex";
|
|
5
|
+
import type { CurveLPToken } from "../tokens/curveLP";
|
|
6
|
+
import type { NormalToken } from "../tokens/normal";
|
|
7
7
|
export declare type UniswapV2Contract = "UNISWAP_V2_ROUTER" | "SUSHISWAP_ROUTER";
|
|
8
8
|
export declare type CurvePoolContract = "CURVE_3CRV_POOL" | "CURVE_STETH_GATEWAY" | "CURVE_FRAX_POOL" | "CURVE_LUSD_POOL" | "CURVE_GUSD_POOL" | "CURVE_SUSD_POOL" | "CURVE_SUSD_DEPOSIT";
|
|
9
9
|
export declare type YearnVaultContract = "YEARN_DAI_VAULT" | "YEARN_USDC_VAULT" | "YEARN_WETH_VAULT" | "YEARN_WBTC_VAULT" | "YEARN_CURVE_FRAX_VAULT" | "YEARN_CURVE_STETH_VAULT";
|
|
@@ -44,10 +44,15 @@ declare type ConvexParams = {
|
|
|
44
44
|
protocol: Protocols.Convex;
|
|
45
45
|
type: AdapterInterface.CONVEX_V1_BOOSTER | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
|
|
46
46
|
} & BaseContractParams;
|
|
47
|
-
declare type
|
|
47
|
+
declare type ConvexExtraPoolParams = {
|
|
48
|
+
rewardToken: NormalToken;
|
|
49
|
+
poolAddress: Record<NetworkType, string>;
|
|
50
|
+
};
|
|
51
|
+
export declare type ConvexPoolParams = {
|
|
48
52
|
protocol: Protocols.Convex;
|
|
49
53
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
|
|
50
54
|
stakedToken: ConvexStakedPhantomToken;
|
|
55
|
+
extraRewards: Array<ConvexExtraPoolParams>;
|
|
51
56
|
} & BaseContractParams;
|
|
52
57
|
export declare type LidoParams = {
|
|
53
58
|
protocol: Protocols.Lido;
|
|
@@ -197,46 +197,84 @@ exports.contractParams = {
|
|
|
197
197
|
protocol: protocols_1.Protocols.Convex,
|
|
198
198
|
type: adapters_1.AdapterInterface.CONVEX_V1_BOOSTER
|
|
199
199
|
},
|
|
200
|
+
CONVEX_CLAIM_ZAP: {
|
|
201
|
+
name: "Convex ZAP",
|
|
202
|
+
protocol: protocols_1.Protocols.Convex,
|
|
203
|
+
type: adapters_1.AdapterInterface.CONVEX_V1_CLAIM_ZAP
|
|
204
|
+
},
|
|
200
205
|
CONVEX_3CRV_POOL: {
|
|
201
206
|
name: "Convex 3crv",
|
|
202
207
|
protocol: protocols_1.Protocols.Convex,
|
|
203
208
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
204
|
-
stakedToken: "stkcvx3Crv"
|
|
209
|
+
stakedToken: "stkcvx3Crv",
|
|
210
|
+
extraRewards: []
|
|
205
211
|
},
|
|
206
212
|
CONVEX_GUSD_POOL: {
|
|
207
213
|
name: "Convex GUSD",
|
|
208
214
|
protocol: protocols_1.Protocols.Convex,
|
|
209
215
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
210
|
-
stakedToken: "stkcvxgusd3CRV"
|
|
216
|
+
stakedToken: "stkcvxgusd3CRV",
|
|
217
|
+
extraRewards: []
|
|
211
218
|
},
|
|
212
219
|
CONVEX_SUSD_POOL: {
|
|
213
220
|
name: "Convex SUSD",
|
|
214
221
|
protocol: protocols_1.Protocols.Convex,
|
|
215
222
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
216
|
-
stakedToken: "stkcvxcrvPlain3andSUSD"
|
|
223
|
+
stakedToken: "stkcvxcrvPlain3andSUSD",
|
|
224
|
+
extraRewards: [
|
|
225
|
+
{
|
|
226
|
+
rewardToken: "SNX",
|
|
227
|
+
poolAddress: {
|
|
228
|
+
Mainnet: "0x81fCe3E10D12Da6c7266a1A169c4C96813435263",
|
|
229
|
+
Kovan: "0x26a535146557FA58FA37e3078FEAc523b554939C"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
]
|
|
217
233
|
},
|
|
218
234
|
CONVEX_STECRV_POOL: {
|
|
219
235
|
name: "Convex STECRV",
|
|
220
236
|
protocol: protocols_1.Protocols.Convex,
|
|
221
237
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
222
|
-
stakedToken: "stkcvxsteCRV"
|
|
238
|
+
stakedToken: "stkcvxsteCRV",
|
|
239
|
+
extraRewards: [
|
|
240
|
+
{
|
|
241
|
+
rewardToken: "LDO",
|
|
242
|
+
poolAddress: {
|
|
243
|
+
Mainnet: "0x008aEa5036b819B4FEAEd10b2190FBb3954981E8",
|
|
244
|
+
Kovan: "0xd0B1CC3B4839363b1eC92F35eF45794CB07B1183"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
]
|
|
223
248
|
},
|
|
224
249
|
CONVEX_FRAX3CRV_POOL: {
|
|
225
250
|
name: "Convex FRAX3CRV",
|
|
226
251
|
protocol: protocols_1.Protocols.Convex,
|
|
227
252
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
228
|
-
stakedToken: "stkcvxFRAX3CRV"
|
|
253
|
+
stakedToken: "stkcvxFRAX3CRV",
|
|
254
|
+
extraRewards: [
|
|
255
|
+
{
|
|
256
|
+
rewardToken: "FXS",
|
|
257
|
+
poolAddress: {
|
|
258
|
+
Mainnet: "0xcDEC6714eB482f28f4889A0c122868450CDBF0b0",
|
|
259
|
+
Kovan: "0x89869c2e79FC6EFf51e714F1239D53702B5CDFCD"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
]
|
|
229
263
|
},
|
|
230
264
|
CONVEX_LUSD3CRV_POOL: {
|
|
231
265
|
name: "Convex LUSD3CRV",
|
|
232
266
|
protocol: protocols_1.Protocols.Convex,
|
|
233
267
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
234
|
-
stakedToken: "stkcvxLUSD3CRV"
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
268
|
+
stakedToken: "stkcvxLUSD3CRV",
|
|
269
|
+
extraRewards: [
|
|
270
|
+
{
|
|
271
|
+
rewardToken: "LQTY",
|
|
272
|
+
poolAddress: {
|
|
273
|
+
Mainnet: "0x55d59b791f06dc519B176791c4E037E8Cf2f6361",
|
|
274
|
+
Kovan: ""
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
]
|
|
240
278
|
},
|
|
241
279
|
LIDO_STETH_GATEWAY: {
|
|
242
280
|
name: "Lido STETH",
|
|
@@ -249,7 +287,7 @@ exports.contractParams = {
|
|
|
249
287
|
lpToken: "steCRV"
|
|
250
288
|
}
|
|
251
289
|
};
|
|
252
|
-
exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce(function (
|
|
253
|
-
var
|
|
254
|
-
return __assign(__assign({},
|
|
290
|
+
exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce(function (acc, _a) {
|
|
291
|
+
var contracts = _a[1];
|
|
292
|
+
return (__assign(__assign({}, acc), (0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(contracts)))));
|
|
255
293
|
}, {});
|
|
@@ -38,18 +38,30 @@ exports.deployedContracts = {
|
|
|
38
38
|
"0xe04b4db67127d1930D36f16B51653120C4285708": "WBTC",
|
|
39
39
|
"0x600073357c29d169aAF3E543A4519749830553F1": "WETH",
|
|
40
40
|
"0xdBAd1361d9A03B81Be8D3a54Ef0dc9e39a1bA5b3": "USDC",
|
|
41
|
-
"0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI"
|
|
41
|
+
"0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI",
|
|
42
42
|
// [YEARN_DAI_VAULT_KOVAN_MOCK]: "Yearn DAI",
|
|
43
43
|
// [YEARN_USDC_VAULT_KOVAN_MOCK]: "Yearn USDC",
|
|
44
44
|
// [SUSHISWAP_KOVAN]: "Sushiswap"
|
|
45
|
+
"0x94cd5F09727ae04d7D6fd36A9c9DD96D0d54646B": "DAI",
|
|
46
|
+
"0x53B4a7389EA369a9299DfF524f916EC3cB77ffF4": "USDC",
|
|
47
|
+
"0xE6631f7b18744651A385a02ea2C89634d20D7819": "WETH",
|
|
48
|
+
"0x4d2cBA0E43Ad3B3E1C3B1922fe6E8e910b8C3ae0": "WBTC",
|
|
49
|
+
"0x6Ae9Ed829AF469Df9526FA7443E876bfaBC79eff": "DAI V2",
|
|
50
|
+
"0x8E0a874E3475de1C16490E386b7E2904CdC03086": "USDC V2",
|
|
51
|
+
"0x816a74B75D60839247C848518545fb17cedDC460": "WETH V2",
|
|
52
|
+
// pools
|
|
53
|
+
"0xA7b1C8f322596C40A04dBd3DffaE37a0849B8b59": "DAI",
|
|
54
|
+
"0xb8ecDB926F07FCbd870eafE72d116413A0BEb236": "USDC",
|
|
55
|
+
"0xAda6b2747295b2ba6ba52ce2d0D5e681D25D63D8": "WETH",
|
|
56
|
+
"0x85c54CCCf27466eEa1C74a73F75CbE385C271EE4": "WBTC"
|
|
45
57
|
};
|
|
46
|
-
var contractNames = Object.entries(contracts_1.contractsByAddress).reduce(function (
|
|
58
|
+
var contractNames = Object.entries(contracts_1.contractsByAddress).reduce(function (acc, _a) {
|
|
47
59
|
var _b;
|
|
48
60
|
var addr = _a[0], cSymbol = _a[1];
|
|
49
61
|
var params = contracts_1.contractParams[cSymbol];
|
|
50
62
|
if (!params)
|
|
51
|
-
return
|
|
52
|
-
return __assign(__assign({},
|
|
63
|
+
return acc;
|
|
64
|
+
return __assign(__assign({}, acc), (_b = {}, _b[addr] = params.name, _b));
|
|
53
65
|
}, {});
|
|
54
66
|
var contractsFullList = __assign(__assign({}, (0, mappers_1.keyToLowercase)(exports.deployedContracts)), contractNames);
|
|
55
67
|
function getContractName(address) {
|
package/lib/core/constants.d.ts
CHANGED
|
@@ -5,13 +5,19 @@ export declare const KOVAN_NETWORK = 42;
|
|
|
5
5
|
export declare const LOCAL_NETWORK = 1337;
|
|
6
6
|
export declare type NetworkType = "Mainnet" | "Kovan";
|
|
7
7
|
export declare const getNetworkType: (chainId: number) => NetworkType;
|
|
8
|
+
export declare const RAY_DECIMALS_POW = 27;
|
|
8
9
|
export declare const RAY: BigNumber;
|
|
9
10
|
export declare const halfRAY: BigNumber;
|
|
11
|
+
export declare const WAD_DECIMALS_POW = 18;
|
|
10
12
|
export declare const WAD: BigNumber;
|
|
13
|
+
export declare const PRICE_DECIMALS_POW = 8;
|
|
14
|
+
export declare const PRICE_DECIMALS: BigNumber;
|
|
11
15
|
export declare const SECONDS_PER_YEAR: number;
|
|
16
|
+
export declare const PERCENTAGE_DECIMALS = 100;
|
|
12
17
|
export declare const PERCENTAGE_FACTOR = 10000;
|
|
13
18
|
export declare const LIQUIDATION_DISCOUNTED_SUM = 9500;
|
|
14
19
|
export declare const UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = 9300;
|
|
15
20
|
export declare const timeRanges: Record<string, number>;
|
|
16
21
|
export declare const LEVERAGE_DECIMALS = 100;
|
|
17
|
-
export declare const
|
|
22
|
+
export declare const SLIPPAGE_DECIMALS = 100;
|
|
23
|
+
export declare const ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
|
package/lib/core/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ADDRESS_0X0 = exports.SLIPPAGE_DECIMALS = exports.LEVERAGE_DECIMALS = exports.timeRanges = exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = exports.LIQUIDATION_DISCOUNTED_SUM = exports.PERCENTAGE_FACTOR = exports.PERCENTAGE_DECIMALS = exports.SECONDS_PER_YEAR = exports.PRICE_DECIMALS = exports.PRICE_DECIMALS_POW = exports.WAD = exports.WAD_DECIMALS_POW = exports.halfRAY = exports.RAY = exports.RAY_DECIMALS_POW = exports.getNetworkType = exports.LOCAL_NETWORK = exports.KOVAN_NETWORK = exports.MAINNET_NETWORK = exports.MAX_INT = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
5
|
exports.MAX_INT = ethers_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
6
6
|
exports.MAINNET_NETWORK = 1;
|
|
@@ -18,10 +18,15 @@ var getNetworkType = function (chainId) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
exports.getNetworkType = getNetworkType;
|
|
21
|
-
exports.
|
|
21
|
+
exports.RAY_DECIMALS_POW = 27;
|
|
22
|
+
exports.RAY = ethers_1.BigNumber.from(10).pow(exports.RAY_DECIMALS_POW);
|
|
22
23
|
exports.halfRAY = exports.RAY.div(2);
|
|
23
|
-
exports.
|
|
24
|
+
exports.WAD_DECIMALS_POW = 18;
|
|
25
|
+
exports.WAD = ethers_1.BigNumber.from(10).pow(exports.WAD_DECIMALS_POW);
|
|
26
|
+
exports.PRICE_DECIMALS_POW = 8;
|
|
27
|
+
exports.PRICE_DECIMALS = ethers_1.BigNumber.from(10).pow(exports.PRICE_DECIMALS_POW);
|
|
24
28
|
exports.SECONDS_PER_YEAR = 365 * 24 * 3600;
|
|
29
|
+
exports.PERCENTAGE_DECIMALS = 100;
|
|
25
30
|
exports.PERCENTAGE_FACTOR = 1e4;
|
|
26
31
|
exports.LIQUIDATION_DISCOUNTED_SUM = 9500;
|
|
27
32
|
exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = 9300;
|
|
@@ -30,7 +35,8 @@ exports.timeRanges = {
|
|
|
30
35
|
"1D": 3600 * 24,
|
|
31
36
|
"1W": 3600 * 24 * 7,
|
|
32
37
|
"1M": 3600 * 24 * 30,
|
|
33
|
-
"1Y": 3600 * 24 * 365
|
|
38
|
+
"1Y": 3600 * 24 * 365
|
|
34
39
|
};
|
|
35
40
|
exports.LEVERAGE_DECIMALS = 100;
|
|
36
|
-
exports.
|
|
41
|
+
exports.SLIPPAGE_DECIMALS = 100;
|
|
42
|
+
exports.ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
|
|
@@ -23,8 +23,10 @@ export declare class CreditAccountData {
|
|
|
23
23
|
isDeleting: boolean;
|
|
24
24
|
readonly version: number;
|
|
25
25
|
constructor(payload: CreditAccountDataPayload);
|
|
26
|
-
balancesSorted(prices: Record<string,
|
|
26
|
+
balancesSorted(prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): Array<Balance>;
|
|
27
27
|
}
|
|
28
|
+
export declare function sortBalances(balances: Record<string, BigNumber>, prices: Record<string, BigNumber>, tokens: Record<string, TokenData>): [string, BigNumber][];
|
|
29
|
+
export declare function tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1;
|
|
28
30
|
export declare class CreditAccountDataExtended extends CreditAccountData {
|
|
29
31
|
readonly repayAmount: BigNumber;
|
|
30
32
|
readonly liquidationAmount: BigNumber;
|