@gearbox-protocol/sdk 0.0.102 → 0.0.105
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 +5 -0
- package/.eslintrc.js +52 -0
- package/.husky/pre-push +4 -0
- package/lib/apy/convexAPY.js +3 -5
- package/lib/apy/lidoAPY.js +8 -9
- package/lib/contracts/contracts.d.ts +5 -2
- package/lib/contracts/contracts.js +19 -18
- package/lib/core/constants.d.ts +1 -1
- package/lib/core/constants.js +2 -2
- package/lib/core/creditAccount.js +7 -5
- package/lib/core/creditManager.d.ts +1 -1
- package/lib/core/creditManager.js +1 -7
- package/lib/core/creditSession.js +14 -3
- package/lib/core/eventOrTx.d.ts +1 -1
- package/lib/core/events.d.ts +19 -19
- package/lib/core/events.js +23 -21
- package/lib/core/pool.d.ts +1 -1
- package/lib/core/pool.js +1 -7
- package/lib/core/price.js +6 -1
- package/lib/core/strategy.d.ts +1 -3
- package/lib/core/strategy.js +14 -13
- 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 -2
- package/lib/index.js +8 -1
- 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 +18 -15
- package/lib/strategies/convex.d.ts +12 -0
- package/lib/strategies/convex.js +74 -1
- package/lib/strategies/creditFacade.d.ts +1 -0
- package/lib/strategies/creditFacade.js +3 -0
- package/lib/strategies/curve.d.ts +15 -60
- package/lib/strategies/curve.js +74 -1
- package/lib/strategies/lido.d.ts +6 -0
- package/lib/strategies/lido.js +23 -1
- package/lib/strategies/uniswapV2.d.ts +1 -0
- package/lib/strategies/uniswapV2.js +6 -19
- package/lib/strategies/uniswapV3.d.ts +1 -0
- package/lib/strategies/uniswapV3.js +4 -1
- package/lib/strategies/yearn.d.ts +8 -0
- package/lib/strategies/yearn.js +92 -12
- package/lib/tokens/convex.d.ts +3 -3
- package/lib/tokens/curveLP.d.ts +7 -2
- package/lib/tokens/curveLP.js +8 -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 +4 -4
- package/lib/tokens/tokenData.d.ts +3 -1
- package/lib/tokens/tokenData.js +10 -8
- package/lib/tokens/yearn.d.ts +6 -2
- package/lib/tokens/yearn.js +6 -0
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/formatter.d.ts +1 -1
- package/lib/utils/formatter.js +17 -14
- package/lib/utils/loading.d.ts +2 -1
- package/lib/utils/loading.js +9 -13
- package/lib/utils/mappers.js +2 -2
- package/lib/utils/network.js +2 -2
- package/lib/utils/repeater.js +12 -24
- package/lib/utils/validate.js +1 -1
- package/package.json +24 -7
- package/src/apy/convexAPY.ts +6 -6
- package/src/apy/lidoAPY.ts +12 -11
- package/src/contracts/contracts.ts +27 -17
- package/src/core/constants.ts +1 -1
- package/src/core/creditAccount.ts +28 -5
- package/src/core/creditManager.ts +29 -4
- package/src/core/creditOperation.ts +7 -7
- package/src/core/creditSession.ts +25 -5
- package/src/core/errors.ts +1 -0
- package/src/core/eventOrTx.ts +8 -5
- package/src/core/events.ts +85 -24
- package/src/core/history.ts +46 -46
- package/src/core/operations.ts +6 -0
- package/src/core/pool.ts +16 -4
- package/src/core/price.ts +7 -3
- package/src/core/strategy.ts +27 -23
- package/src/core/tokenDistributor.ts +2 -2
- package/src/core/transactions.ts +427 -350
- package/src/index.ts +10 -3
- 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 +17 -9
- 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 +26 -11
- package/src/payload/token.ts +3 -3
- package/src/strategies/convex.ts +361 -186
- package/src/strategies/creditFacade.ts +74 -53
- package/src/strategies/curve.ts +400 -189
- package/src/strategies/lido.ts +70 -32
- package/src/strategies/uniswapV2.ts +93 -111
- package/src/strategies/uniswapV3.ts +118 -91
- package/src/strategies/yearn.ts +187 -60
- package/src/tokens/connectors.ts +6 -6
- package/src/tokens/convex.ts +297 -296
- package/src/tokens/curveLP.ts +176 -165
- package/src/tokens/gear.ts +47 -45
- package/src/tokens/normal.ts +801 -802
- package/src/tokens/token.ts +9 -5
- package/src/tokens/tokenData.ts +19 -9
- package/src/tokens/tokenType.ts +11 -11
- package/src/tokens/yearn.ts +130 -124
- package/src/utils/errors.ts +11 -0
- package/src/utils/formatter.ts +22 -18
- package/src/utils/loading.ts +14 -6
- package/src/utils/mappers.ts +8 -6
- package/src/utils/multicall.ts +2 -0
- package/src/utils/network.ts +21 -21
- package/src/utils/repeater.ts +2 -2
- package/src/utils/validate.ts +1 -1
- package/lib/utils/events.d.ts +0 -2
- package/lib/utils/events.js +0 -13
- package/src/utils/events.ts +0 -10
|
@@ -8,6 +8,7 @@ export declare class UniswapV2Calls {
|
|
|
8
8
|
export declare class UniswapV2Multicaller {
|
|
9
9
|
private readonly _address;
|
|
10
10
|
constructor(address: string);
|
|
11
|
+
static connect(address: string): UniswapV2Multicaller;
|
|
11
12
|
swapExactTokensForTokens(amountIn: BigNumberish, amountOutMin: BigNumberish, path: Array<string>, to: string, deadline: BigNumberish): MultiCallStruct;
|
|
12
13
|
swapTokensForExactTokens(amountOut: BigNumberish, amountInMax: BigNumberish, path: Array<string>, to: string, deadline: BigNumberish): MultiCallStruct;
|
|
13
14
|
swapAllTokensForTokens(rateMinRAY: BigNumberish, path: Array<string>, deadline: BigNumberish): MultiCallStruct;
|
|
@@ -6,29 +6,13 @@ var UniswapV2Calls = /** @class */ (function () {
|
|
|
6
6
|
function UniswapV2Calls() {
|
|
7
7
|
}
|
|
8
8
|
UniswapV2Calls.swapExactTokensForTokens = function (amountIn, amountOutMin, path, to, deadline) {
|
|
9
|
-
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapExactTokensForTokens", [
|
|
10
|
-
amountIn,
|
|
11
|
-
amountOutMin,
|
|
12
|
-
path,
|
|
13
|
-
to,
|
|
14
|
-
deadline
|
|
15
|
-
]);
|
|
9
|
+
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapExactTokensForTokens", [amountIn, amountOutMin, path, to, deadline]);
|
|
16
10
|
};
|
|
17
11
|
UniswapV2Calls.swapTokensForExactTokens = function (amountOut, amountInMax, path, to, deadline) {
|
|
18
|
-
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapTokensForExactTokens", [
|
|
19
|
-
amountOut,
|
|
20
|
-
amountInMax,
|
|
21
|
-
path,
|
|
22
|
-
to,
|
|
23
|
-
deadline
|
|
24
|
-
]);
|
|
12
|
+
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapTokensForExactTokens", [amountOut, amountInMax, path, to, deadline]);
|
|
25
13
|
};
|
|
26
14
|
UniswapV2Calls.swapAllTokensForTokens = function (rateMinRAY, path, deadline) {
|
|
27
|
-
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapAllTokensForTokens", [
|
|
28
|
-
rateMinRAY,
|
|
29
|
-
path,
|
|
30
|
-
deadline
|
|
31
|
-
]);
|
|
15
|
+
return types_1.UniswapV2Adapter__factory.createInterface().encodeFunctionData("swapAllTokensForTokens", [rateMinRAY, path, deadline]);
|
|
32
16
|
};
|
|
33
17
|
return UniswapV2Calls;
|
|
34
18
|
}());
|
|
@@ -37,6 +21,9 @@ var UniswapV2Multicaller = /** @class */ (function () {
|
|
|
37
21
|
function UniswapV2Multicaller(address) {
|
|
38
22
|
this._address = address;
|
|
39
23
|
}
|
|
24
|
+
UniswapV2Multicaller.connect = function (address) {
|
|
25
|
+
return new UniswapV2Multicaller(address);
|
|
26
|
+
};
|
|
40
27
|
UniswapV2Multicaller.prototype.swapExactTokensForTokens = function (amountIn, amountOutMin, path, to, deadline) {
|
|
41
28
|
return {
|
|
42
29
|
target: this._address,
|
|
@@ -11,6 +11,7 @@ export declare class UniswapV3Calls {
|
|
|
11
11
|
export declare class UniswapV3Multicaller {
|
|
12
12
|
private readonly _address;
|
|
13
13
|
constructor(address: string);
|
|
14
|
+
static connect(address: string): UniswapV3Multicaller;
|
|
14
15
|
exactInputSingle(params: ISwapRouter.ExactInputSingleParamsStructOutput): MultiCallStruct;
|
|
15
16
|
exactAllInputSingle(params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput): MultiCallStruct;
|
|
16
17
|
exactInput(params: ISwapRouter.ExactInputParamsStructOutput): MultiCallStruct;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//import { BigNumberish } from "ethers";
|
|
2
|
+
// import { BigNumberish } from "ethers";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.UniswapV3Multicaller = exports.UniswapV3Calls = void 0;
|
|
5
5
|
var types_1 = require("../types");
|
|
@@ -31,6 +31,9 @@ var UniswapV3Multicaller = /** @class */ (function () {
|
|
|
31
31
|
function UniswapV3Multicaller(address) {
|
|
32
32
|
this._address = address;
|
|
33
33
|
}
|
|
34
|
+
UniswapV3Multicaller.connect = function (address) {
|
|
35
|
+
return new UniswapV3Multicaller(address);
|
|
36
|
+
};
|
|
34
37
|
UniswapV3Multicaller.prototype.exactInputSingle = function (params) {
|
|
35
38
|
return {
|
|
36
39
|
target: this._address,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
|
+
import { YearnVaultContract } from "../contracts/contracts";
|
|
3
|
+
import { NetworkType } from "../core/constants";
|
|
4
|
+
import { CreditManagerData } from "../core/creditManager";
|
|
2
5
|
import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
|
|
3
6
|
export declare class YearnV2Calls {
|
|
4
7
|
static deposit(amount?: BigNumberish, recipient?: string): string;
|
|
@@ -7,6 +10,11 @@ export declare class YearnV2Calls {
|
|
|
7
10
|
export declare class YearnV2Multicaller {
|
|
8
11
|
private readonly _address;
|
|
9
12
|
constructor(address: string);
|
|
13
|
+
static connect(address: string): YearnV2Multicaller;
|
|
10
14
|
deposit(amount?: BigNumberish, recipient?: string): MultiCallStruct;
|
|
11
15
|
withdraw(maxShares?: BigNumberish, recipient?: string, maxLoss?: BigNumberish): MultiCallStruct;
|
|
12
16
|
}
|
|
17
|
+
export declare class YearnV2Strategies {
|
|
18
|
+
static underlyingToYearn(data: CreditManagerData, network: NetworkType, yearnVault: YearnVaultContract, underlyingAmount: BigNumberish): void;
|
|
19
|
+
static yearnToUnderlying(data: CreditManagerData, network: NetworkType, yearnVault: YearnVaultContract, yearnSharesAmount: BigNumberish): void;
|
|
20
|
+
}
|
package/lib/strategies/yearn.js
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YearnV2Multicaller = exports.YearnV2Calls = void 0;
|
|
12
|
+
exports.YearnV2Strategies = exports.YearnV2Multicaller = exports.YearnV2Calls = void 0;
|
|
13
|
+
var contracts_1 = require("../contracts/contracts");
|
|
14
|
+
var constants_1 = require("../core/constants");
|
|
15
|
+
var token_1 = require("../tokens/token");
|
|
16
|
+
var tokenType_1 = require("../tokens/tokenType");
|
|
4
17
|
var types_1 = require("../types");
|
|
18
|
+
var curve_1 = require("./curve");
|
|
19
|
+
var uniswapV2_1 = require("./uniswapV2");
|
|
5
20
|
var YearnV2Calls = /** @class */ (function () {
|
|
6
21
|
function YearnV2Calls() {
|
|
7
22
|
}
|
|
8
23
|
YearnV2Calls.deposit = function (amount, recipient) {
|
|
9
24
|
var contractInterface = types_1.YearnV2Adapter__factory.createInterface();
|
|
10
25
|
if (amount && recipient) {
|
|
11
|
-
return contractInterface.encodeFunctionData("deposit(uint256,address)", [
|
|
26
|
+
return contractInterface.encodeFunctionData("deposit(uint256,address)", [
|
|
27
|
+
amount,
|
|
28
|
+
recipient
|
|
29
|
+
]);
|
|
12
30
|
}
|
|
13
|
-
|
|
31
|
+
if (amount) {
|
|
14
32
|
return contractInterface.encodeFunctionData("deposit(uint256)", [amount]);
|
|
15
33
|
}
|
|
16
|
-
|
|
17
|
-
return contractInterface.encodeFunctionData("deposit()");
|
|
18
|
-
}
|
|
34
|
+
return contractInterface.encodeFunctionData("deposit()");
|
|
19
35
|
};
|
|
20
36
|
YearnV2Calls.withdraw = function (maxShares, recipient, maxLoss) {
|
|
21
37
|
var contractInterface = types_1.YearnV2Adapter__factory.createInterface();
|
|
@@ -23,14 +39,17 @@ var YearnV2Calls = /** @class */ (function () {
|
|
|
23
39
|
return contractInterface.encodeFunctionData("withdraw(uint256,address,uint256)", [maxShares, recipient, maxLoss]);
|
|
24
40
|
}
|
|
25
41
|
if (maxShares && recipient) {
|
|
26
|
-
return contractInterface.encodeFunctionData("withdraw(uint256,address)", [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
return contractInterface.encodeFunctionData("withdraw(uint256,address)", [
|
|
43
|
+
maxShares,
|
|
44
|
+
recipient
|
|
45
|
+
]);
|
|
30
46
|
}
|
|
31
|
-
|
|
32
|
-
return contractInterface.encodeFunctionData("withdraw()"
|
|
47
|
+
if (maxShares) {
|
|
48
|
+
return contractInterface.encodeFunctionData("withdraw(uint256)", [
|
|
49
|
+
maxShares
|
|
50
|
+
]);
|
|
33
51
|
}
|
|
52
|
+
return contractInterface.encodeFunctionData("withdraw()");
|
|
34
53
|
};
|
|
35
54
|
return YearnV2Calls;
|
|
36
55
|
}());
|
|
@@ -39,6 +58,9 @@ var YearnV2Multicaller = /** @class */ (function () {
|
|
|
39
58
|
function YearnV2Multicaller(address) {
|
|
40
59
|
this._address = address;
|
|
41
60
|
}
|
|
61
|
+
YearnV2Multicaller.connect = function (address) {
|
|
62
|
+
return new YearnV2Multicaller(address);
|
|
63
|
+
};
|
|
42
64
|
YearnV2Multicaller.prototype.deposit = function (amount, recipient) {
|
|
43
65
|
return {
|
|
44
66
|
target: this._address,
|
|
@@ -54,3 +76,61 @@ var YearnV2Multicaller = /** @class */ (function () {
|
|
|
54
76
|
return YearnV2Multicaller;
|
|
55
77
|
}());
|
|
56
78
|
exports.YearnV2Multicaller = YearnV2Multicaller;
|
|
79
|
+
var YearnV2Strategies = /** @class */ (function () {
|
|
80
|
+
function YearnV2Strategies() {
|
|
81
|
+
}
|
|
82
|
+
YearnV2Strategies.underlyingToYearn = function (data, network, yearnVault, underlyingAmount) {
|
|
83
|
+
var calls = [];
|
|
84
|
+
var vaultParams = contracts_1.contractParams[yearnVault];
|
|
85
|
+
var yearnToken = vaultParams.shareToken;
|
|
86
|
+
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
87
|
+
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
88
|
+
if (data.underlyingToken !==
|
|
89
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
90
|
+
// This should be a pathfinder call
|
|
91
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapExactTokensForTokens(underlyingAmount, 0, [
|
|
92
|
+
data.underlyingToken,
|
|
93
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]
|
|
94
|
+
], constants_1.ADDRESS_0X0, Math.floor(new Date().getTime() / 1000) + 3600));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP ||
|
|
98
|
+
yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP) {
|
|
99
|
+
var curveTokenParams = token_1.supportedTokens[yearnParams.underlying];
|
|
100
|
+
var curvePool = curveTokenParams.pool;
|
|
101
|
+
calls = curve_1.CurveStrategies.underlyingToCurveLP(data, network, curvePool, underlyingAmount);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error("Yearn vault type unknown");
|
|
105
|
+
}
|
|
106
|
+
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault]]).deposit());
|
|
107
|
+
};
|
|
108
|
+
YearnV2Strategies.yearnToUnderlying = function (data, network, yearnVault, yearnSharesAmount) {
|
|
109
|
+
var calls = [];
|
|
110
|
+
var vaultParams = contracts_1.contractParams[yearnVault];
|
|
111
|
+
var yearnToken = vaultParams.shareToken;
|
|
112
|
+
var yearnParams = token_1.supportedTokens[yearnToken];
|
|
113
|
+
calls.push(YearnV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network][yearnVault]]).withdraw(yearnSharesAmount));
|
|
114
|
+
if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT) {
|
|
115
|
+
if (data.underlyingToken !==
|
|
116
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying]) {
|
|
117
|
+
// This should be a pathfinder call
|
|
118
|
+
calls.push(uniswapV2_1.UniswapV2Multicaller.connect(data.adapters[contracts_1.contractsByNetwork[network].UNISWAP_V2_ROUTER]).swapAllTokensForTokens(0, [
|
|
119
|
+
token_1.tokenDataByNetwork[network][yearnParams.underlying],
|
|
120
|
+
data.underlyingToken
|
|
121
|
+
], Math.floor(new Date().getTime() / 1000) + 3600));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP ||
|
|
125
|
+
yearnParams.type === tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP) {
|
|
126
|
+
var curveTokenParams = token_1.supportedTokens[yearnParams.underlying];
|
|
127
|
+
var curvePool = curveTokenParams.pool;
|
|
128
|
+
calls = __spreadArray(__spreadArray([], calls, true), curve_1.CurveStrategies.allCurveLPToUnderlying(data, network, curvePool), true);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error("Yearn vault type unknown");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return YearnV2Strategies;
|
|
135
|
+
}());
|
|
136
|
+
exports.YearnV2Strategies = YearnV2Strategies;
|
package/lib/tokens/convex.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
-
import { TokenBase } from "./token";
|
|
3
|
-
import { ConvexPoolContract } from "../contracts/contracts";
|
|
4
|
-
import { CurveLPToken } from "./curveLP";
|
|
2
|
+
import type { TokenBase } from "./token";
|
|
3
|
+
import type { ConvexPoolContract } from "../contracts/contracts";
|
|
4
|
+
import type { CurveLPToken } from "./curveLP";
|
|
5
5
|
import { TokenType } from "./tokenType";
|
|
6
6
|
export declare type ConvexLPToken = "cvx3Crv" | "cvxsteCRV" | "cvxFRAX3CRV" | "cvxLUSD3CRV" | "cvxcrvPlain3andSUSD" | "cvxgusd3CRV";
|
|
7
7
|
export declare type ConvexStakedPhantomToken = "stkcvx3Crv" | "stkcvxsteCRV" | "stkcvxFRAX3CRV" | "stkcvxLUSD3CRV" | "stkcvxcrvPlain3andSUSD" | "stkcvxgusd3CRV";
|
package/lib/tokens/curveLP.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
import type { CurvePoolContract } from "../contracts/contracts";
|
|
1
3
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
-
import { SupportedToken, TokenBase } from "./token";
|
|
4
|
+
import type { SupportedToken, TokenBase } from "./token";
|
|
3
5
|
import { PartialRecord } from "../utils/types";
|
|
4
|
-
import { BigNumber } from "ethers";
|
|
5
6
|
import { TokenType } from "./tokenType";
|
|
6
7
|
export declare type CurveLPToken = "3Crv" | "steCRV" | "FRAX3CRV" | "LUSD3CRV" | "crvPlain3andSUSD" | "gusd3CRV";
|
|
7
8
|
export declare type CurveLPTokenData = {
|
|
@@ -9,11 +10,15 @@ export declare type CurveLPTokenData = {
|
|
|
9
10
|
type: TokenType.CURVE_LP;
|
|
10
11
|
swapActions?: Array<TradeAction>;
|
|
11
12
|
lpActions: Array<TradeAction>;
|
|
13
|
+
pool: CurvePoolContract;
|
|
14
|
+
wrapper?: CurvePoolContract;
|
|
12
15
|
} & TokenBase;
|
|
13
16
|
export declare type MetaCurveLPTokenData = {
|
|
14
17
|
symbol: CurveLPToken;
|
|
15
18
|
type: TokenType.META_CURVE_LP;
|
|
16
19
|
lpActions: Array<TradeAction>;
|
|
20
|
+
pool: CurvePoolContract;
|
|
21
|
+
wrapper?: CurvePoolContract;
|
|
17
22
|
} & TokenBase;
|
|
18
23
|
export declare const Curve3CrvUnderlyingTokenIndex: PartialRecord<SupportedToken, BigNumber>;
|
|
19
24
|
export declare const curveTokens: Record<CurveLPToken, CurveLPTokenData | MetaCurveLPTokenData>;
|
package/lib/tokens/curveLP.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.curveTokens = exports.Curve3CrvUnderlyingTokenIndex = void 0;
|
|
4
|
-
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
5
4
|
var ethers_1 = require("ethers");
|
|
5
|
+
var tradeTypes_1 = require("../pathfinder/tradeTypes");
|
|
6
6
|
var tokenType_1 = require("./tokenType");
|
|
7
7
|
exports.Curve3CrvUnderlyingTokenIndex = {
|
|
8
8
|
DAI: ethers_1.BigNumber.from(0),
|
|
@@ -16,6 +16,7 @@ exports.curveTokens = {
|
|
|
16
16
|
decimals: 18,
|
|
17
17
|
symbol: "3Crv",
|
|
18
18
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
19
|
+
pool: "CURVE_3CRV_POOL",
|
|
19
20
|
lpActions: [
|
|
20
21
|
{
|
|
21
22
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
@@ -39,6 +40,7 @@ exports.curveTokens = {
|
|
|
39
40
|
decimals: 18,
|
|
40
41
|
symbol: "steCRV",
|
|
41
42
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
43
|
+
pool: "CURVE_STETH_GATEWAY",
|
|
42
44
|
lpActions: [
|
|
43
45
|
{
|
|
44
46
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
@@ -62,6 +64,8 @@ exports.curveTokens = {
|
|
|
62
64
|
decimals: 18,
|
|
63
65
|
symbol: "crvPlain3andSUSD",
|
|
64
66
|
type: tokenType_1.TokenType.CURVE_LP,
|
|
67
|
+
pool: "CURVE_SUSD_POOL",
|
|
68
|
+
wrapper: "CURVE_SUSD_DEPOSIT",
|
|
65
69
|
lpActions: [
|
|
66
70
|
{
|
|
67
71
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
@@ -86,6 +90,7 @@ exports.curveTokens = {
|
|
|
86
90
|
decimals: 18,
|
|
87
91
|
symbol: "FRAX3CRV",
|
|
88
92
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
93
|
+
pool: "CURVE_FRAX_POOL",
|
|
89
94
|
lpActions: [
|
|
90
95
|
{
|
|
91
96
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
@@ -109,6 +114,7 @@ exports.curveTokens = {
|
|
|
109
114
|
decimals: 18,
|
|
110
115
|
symbol: "LUSD3CRV",
|
|
111
116
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
117
|
+
pool: "CURVE_LUSD_POOL",
|
|
112
118
|
lpActions: [
|
|
113
119
|
{
|
|
114
120
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
|
@@ -122,6 +128,7 @@ exports.curveTokens = {
|
|
|
122
128
|
decimals: 18,
|
|
123
129
|
symbol: "gusd3CRV",
|
|
124
130
|
type: tokenType_1.TokenType.META_CURVE_LP,
|
|
131
|
+
pool: "CURVE_GUSD_POOL",
|
|
125
132
|
lpActions: [
|
|
126
133
|
{
|
|
127
134
|
type: tradeTypes_1.TradeType.CurveWithdrawLP,
|
package/lib/tokens/gear.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TokenBase } from "./token";
|
|
2
|
-
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
1
|
+
import type { TokenBase } from "./token";
|
|
2
|
+
import type { TradeAction } from "../pathfinder/tradeTypes";
|
|
3
3
|
import { TokenType } from "./tokenType";
|
|
4
4
|
export declare type DieselTokenTypes = "dDAI" | "dUSDC" | "dWBTC" | "dWETH";
|
|
5
5
|
export declare type GearboxToken = "GEAR";
|
package/lib/tokens/gear.js
CHANGED
package/lib/tokens/normal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
-
import { TokenBase } from "./token";
|
|
2
|
+
import type { TokenBase } from "./token";
|
|
3
3
|
import { TokenType } from "./tokenType";
|
|
4
4
|
export declare type NormalToken = "1INCH" | "AAVE" | "COMP" | "CRV" | "DPI" | "FEI" | "LINK" | "SNX" | "SUSHI" | "UNI" | "USDT" | "USDC" | "DAI" | "WETH" | "WBTC" | "YFI" | "STETH" | "FTM" | "CVX" | "FRAX" | "FXS" | "LDO" | "SPELL" | "LUSD" | "sUSD" | "GUSD" | "LUNA" | "LQTY";
|
|
5
5
|
export declare type NormalTokenData = {
|
package/lib/tokens/token.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.tokenDataByNetwork = {
|
|
|
80
80
|
yvWBTC: "0xA696a63cc78DfFa1a63E9E50587C197387FF6C7E",
|
|
81
81
|
yvCurve_stETH: "0xdCD90C7f6324cfa40d7169ef80b12031770B4325",
|
|
82
82
|
yvCurve_FRAX: "0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139",
|
|
83
|
-
//GEARBOX
|
|
83
|
+
// GEARBOX
|
|
84
84
|
dDAI: "0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA",
|
|
85
85
|
dUSDC: "0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3",
|
|
86
86
|
dWBTC: "0xe753260F1955e8678DCeA8887759e07aa57E8c54",
|
|
@@ -150,7 +150,7 @@ exports.tokenDataByNetwork = {
|
|
|
150
150
|
stkcvxgusd3CRV: "0x9A74e8106f6c28b21b1B6a0F985cf1227BE05F04",
|
|
151
151
|
stkcvxsteCRV: "0xd8bAbB7EfBF7F931a69B209f71b27421F8b18516",
|
|
152
152
|
stkcvxcrvPlain3andSUSD: "0x6b45Cab756B41a7204973b71362ef5F73E67F6DA",
|
|
153
|
-
//GEARBOX
|
|
153
|
+
// GEARBOX
|
|
154
154
|
dDAI: "0x077a3Ce0D572b72436F6644793Fc7721353aF1f4",
|
|
155
155
|
dUSDC: "0x8147e00456c8A3128182730bFFdFd9D1E6bbC048",
|
|
156
156
|
dWBTC: "0x34D9B3c13B25632879B2DaabBde702F612902238",
|
|
@@ -159,6 +159,6 @@ exports.tokenDataByNetwork = {
|
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
161
|
exports.tokenSymbolByAddress = (0, mappers_1.objectEntries)(exports.tokenDataByNetwork).reduce(function (acc, _a) {
|
|
162
|
-
var
|
|
163
|
-
return __assign(__assign({}, acc), (0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(tokens))));
|
|
162
|
+
var tokens = _a[1];
|
|
163
|
+
return (__assign(__assign({}, acc), (0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(tokens)))));
|
|
164
164
|
}, {});
|
|
@@ -2,13 +2,14 @@ import { BigNumber } from "ethers";
|
|
|
2
2
|
import { TokenDataPayload } from "../payload/token";
|
|
3
3
|
import { NetworkType } from "../core/constants";
|
|
4
4
|
import { SupportedToken } from "./token";
|
|
5
|
+
declare type SymbolReplacements = Record<string, string>;
|
|
5
6
|
export declare class TokenData {
|
|
6
7
|
readonly id: string;
|
|
7
8
|
readonly symbol: string;
|
|
8
9
|
readonly address: string;
|
|
9
10
|
readonly decimals: number;
|
|
10
11
|
readonly icon?: string;
|
|
11
|
-
constructor(payload: TokenDataPayload);
|
|
12
|
+
constructor(payload: TokenDataPayload, symbolReplacements?: SymbolReplacements);
|
|
12
13
|
compareBySymbol(b: TokenData): number;
|
|
13
14
|
}
|
|
14
15
|
export interface TokenBalance {
|
|
@@ -22,3 +23,4 @@ export interface TokenAllowance {
|
|
|
22
23
|
export declare const WETHToken: Record<NetworkType, string>;
|
|
23
24
|
export declare const connectors: Record<NetworkType, Array<SupportedToken>>;
|
|
24
25
|
export declare function getConnectors(networkType: NetworkType): string[];
|
|
26
|
+
export {};
|
package/lib/tokens/tokenData.js
CHANGED
|
@@ -3,16 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getConnectors = exports.connectors = exports.WETHToken = exports.TokenData = void 0;
|
|
4
4
|
var config_1 = require("../config");
|
|
5
5
|
var token_1 = require("./token");
|
|
6
|
+
var defaultSymbolReplacement = {
|
|
7
|
+
dWETH: "dETH",
|
|
8
|
+
WETH: "ETH"
|
|
9
|
+
};
|
|
6
10
|
var TokenData = /** @class */ (function () {
|
|
7
|
-
function TokenData(payload) {
|
|
11
|
+
function TokenData(payload, symbolReplacements) {
|
|
12
|
+
if (symbolReplacements === void 0) { symbolReplacements = defaultSymbolReplacement; }
|
|
8
13
|
var _a;
|
|
9
14
|
this.id = payload.addr;
|
|
10
15
|
this.address = payload.addr;
|
|
11
16
|
// this.name = payload.name;
|
|
12
|
-
this.symbol = payload.symbol;
|
|
13
|
-
if (this.symbol === "WETH" || this.symbol === "dWETH") {
|
|
14
|
-
this.symbol = this.symbol.replace("WETH", "ETH");
|
|
15
|
-
}
|
|
17
|
+
this.symbol = symbolReplacements[payload.symbol] || payload.symbol;
|
|
16
18
|
this.decimals = payload.decimals;
|
|
17
19
|
this.icon = "".concat(config_1.STATIC_TOKEN).concat((_a = payload.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase(), ".svg");
|
|
18
20
|
}
|
|
@@ -24,7 +26,7 @@ var TokenData = /** @class */ (function () {
|
|
|
24
26
|
exports.TokenData = TokenData;
|
|
25
27
|
exports.WETHToken = {
|
|
26
28
|
Mainnet: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
27
|
-
Kovan: "0xd0a1e359811322d97991e03f863a0c30c2cf029c"
|
|
29
|
+
Kovan: "0xd0a1e359811322d97991e03f863a0c30c2cf029c"
|
|
28
30
|
};
|
|
29
31
|
exports.connectors = {
|
|
30
32
|
Mainnet: [
|
|
@@ -33,7 +35,7 @@ exports.connectors = {
|
|
|
33
35
|
"DAI",
|
|
34
36
|
"USDC",
|
|
35
37
|
// "USDT",
|
|
36
|
-
"WBTC"
|
|
38
|
+
"WBTC"
|
|
37
39
|
// "stETH",
|
|
38
40
|
// "PAX",
|
|
39
41
|
// "TUSD",
|
|
@@ -41,7 +43,7 @@ exports.connectors = {
|
|
|
41
43
|
// "BAL",
|
|
42
44
|
// "sUSD",
|
|
43
45
|
],
|
|
44
|
-
Kovan: ["WETH", "DAI", "USDC", "WBTC"]
|
|
46
|
+
Kovan: ["WETH", "DAI", "USDC", "WBTC"]
|
|
45
47
|
};
|
|
46
48
|
function getConnectors(networkType) {
|
|
47
49
|
return exports.connectors[networkType].map(function (e) {
|
package/lib/tokens/yearn.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { YearnVaultContract } from "../contracts/contracts";
|
|
1
2
|
import { TradeAction } from "../pathfinder/tradeTypes";
|
|
2
|
-
import { TokenBase } from "./token";
|
|
3
|
-
import { CurveLPToken } from "./curveLP";
|
|
3
|
+
import type { TokenBase } from "./token";
|
|
4
|
+
import type { CurveLPToken } from "./curveLP";
|
|
4
5
|
import { NormalToken } from "./normal";
|
|
5
6
|
import { TokenType } from "./tokenType";
|
|
6
7
|
export declare type YearnLPToken = "yvDAI" | "yvUSDC" | "yvWETH" | "yvWBTC" | "yvCurve_stETH" | "yvCurve_FRAX";
|
|
@@ -9,17 +10,20 @@ export declare type YearnVaultTokenData = {
|
|
|
9
10
|
type: TokenType.YEARN_VAULT;
|
|
10
11
|
underlying: NormalToken;
|
|
11
12
|
lpActions: Array<TradeAction>;
|
|
13
|
+
vault: YearnVaultContract;
|
|
12
14
|
} & TokenBase;
|
|
13
15
|
export declare type YearnVaultOfCurveLPTokenData = {
|
|
14
16
|
symbol: YearnLPToken;
|
|
15
17
|
type: TokenType.YEARN_VAULT_OF_CURVE_LP;
|
|
16
18
|
underlying: CurveLPToken;
|
|
17
19
|
lpActions: Array<TradeAction>;
|
|
20
|
+
vault: YearnVaultContract;
|
|
18
21
|
} & TokenBase;
|
|
19
22
|
export declare type YearnVaultOfMetaCurveLPTokenData = {
|
|
20
23
|
symbol: YearnLPToken;
|
|
21
24
|
type: TokenType.YEARN_VAULT_OF_META_CURVE_LP;
|
|
22
25
|
underlying: CurveLPToken;
|
|
23
26
|
lpActions: Array<TradeAction>;
|
|
27
|
+
vault: YearnVaultContract;
|
|
24
28
|
} & TokenBase;
|
|
25
29
|
export declare const yearnTokens: Record<YearnLPToken, YearnVaultTokenData | YearnVaultOfCurveLPTokenData | YearnVaultOfMetaCurveLPTokenData>;
|
package/lib/tokens/yearn.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.yearnTokens = {
|
|
|
11
11
|
symbol: "yvDAI",
|
|
12
12
|
type: tokenType_1.TokenType.YEARN_VAULT,
|
|
13
13
|
underlying: "DAI",
|
|
14
|
+
vault: "YEARN_DAI_VAULT",
|
|
14
15
|
lpActions: [
|
|
15
16
|
{
|
|
16
17
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -25,6 +26,7 @@ exports.yearnTokens = {
|
|
|
25
26
|
symbol: "yvUSDC",
|
|
26
27
|
type: tokenType_1.TokenType.YEARN_VAULT,
|
|
27
28
|
underlying: "USDC",
|
|
29
|
+
vault: "YEARN_USDC_VAULT",
|
|
28
30
|
lpActions: [
|
|
29
31
|
{
|
|
30
32
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -39,6 +41,7 @@ exports.yearnTokens = {
|
|
|
39
41
|
symbol: "yvWETH",
|
|
40
42
|
type: tokenType_1.TokenType.YEARN_VAULT,
|
|
41
43
|
underlying: "WETH",
|
|
44
|
+
vault: "YEARN_WETH_VAULT",
|
|
42
45
|
lpActions: [
|
|
43
46
|
{
|
|
44
47
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -53,6 +56,7 @@ exports.yearnTokens = {
|
|
|
53
56
|
symbol: "yvWBTC",
|
|
54
57
|
type: tokenType_1.TokenType.YEARN_VAULT,
|
|
55
58
|
underlying: "WBTC",
|
|
59
|
+
vault: "YEARN_WBTC_VAULT",
|
|
56
60
|
lpActions: [
|
|
57
61
|
{
|
|
58
62
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -68,6 +72,7 @@ exports.yearnTokens = {
|
|
|
68
72
|
symbol: "yvCurve_stETH",
|
|
69
73
|
type: tokenType_1.TokenType.YEARN_VAULT_OF_CURVE_LP,
|
|
70
74
|
underlying: "steCRV",
|
|
75
|
+
vault: "YEARN_CURVE_STETH_VAULT",
|
|
71
76
|
lpActions: [
|
|
72
77
|
{
|
|
73
78
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -82,6 +87,7 @@ exports.yearnTokens = {
|
|
|
82
87
|
symbol: "yvCurve_FRAX",
|
|
83
88
|
type: tokenType_1.TokenType.YEARN_VAULT_OF_META_CURVE_LP,
|
|
84
89
|
underlying: "FRAX3CRV",
|
|
90
|
+
vault: "YEARN_CURVE_FRAX_VAULT",
|
|
85
91
|
lpActions: [
|
|
86
92
|
{
|
|
87
93
|
type: tradeTypes_1.TradeType.YearnWithdraw,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMetamaskError = void 0;
|
|
4
|
+
var isMetamaskError = function (e) {
|
|
5
|
+
if (!e)
|
|
6
|
+
return false;
|
|
7
|
+
if (typeof e !== "object")
|
|
8
|
+
return false;
|
|
9
|
+
if (typeof e.code !== "number" || typeof e.message !== "string")
|
|
10
|
+
return false;
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
exports.isMetamaskError = isMetamaskError;
|
package/lib/utils/formatter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BigNumber, BigNumberish } from "ethers";
|
|
2
2
|
export declare function rayToNumber(num: BigNumberish): number;
|
|
3
3
|
export declare function formatRAY(num?: BigNumber): string;
|
|
4
|
-
export declare function formatBN(
|
|
4
|
+
export declare function formatBN(numArg: BigNumberish | undefined, decimals: number, precisionArg?: number): string;
|
|
5
5
|
export declare function formatBn4dig(num: BigNumber, precision?: number): string;
|
|
6
6
|
export declare function toHumanFormat(num: BigNumber, precision?: number): string;
|
|
7
7
|
export declare function toSignificant(num: BigNumber, decimals: number): string;
|
package/lib/utils/formatter.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.formatLeverage = exports.formatHf = exports.formatDate = exports.formatRate = exports.shortHash = exports.shortAddress = exports.toBN = exports.toSignificant = exports.toHumanFormat = exports.formatBn4dig = exports.formatBN = exports.formatRAY = exports.rayToNumber = void 0;
|
|
7
7
|
var ethers_1 = require("ethers");
|
|
8
|
-
var constants_1 = require("../core/constants");
|
|
9
8
|
var decimal_js_light_1 = __importDefault(require("decimal.js-light"));
|
|
9
|
+
var constants_1 = require("../core/constants");
|
|
10
10
|
function rayToNumber(num) {
|
|
11
11
|
return (ethers_1.BigNumber.from(num).div(ethers_1.BigNumber.from(10).pow(21)).toNumber() / 1000000);
|
|
12
12
|
}
|
|
@@ -15,7 +15,9 @@ function formatRAY(num) {
|
|
|
15
15
|
return toSignificant(num || ethers_1.BigNumber.from(0), 27);
|
|
16
16
|
}
|
|
17
17
|
exports.formatRAY = formatRAY;
|
|
18
|
-
function formatBN(
|
|
18
|
+
function formatBN(numArg, decimals, precisionArg) {
|
|
19
|
+
var num = numArg;
|
|
20
|
+
var precision = precisionArg;
|
|
19
21
|
if (!num)
|
|
20
22
|
return "-";
|
|
21
23
|
// if (BigNumber.from(num).gt(BigNumber.from(10).pow(37))) {
|
|
@@ -54,22 +56,20 @@ function formatBn4dig(num, precision) {
|
|
|
54
56
|
if (numStr.length < 6)
|
|
55
57
|
numStr = "0".repeat(6 - numStr.length) + numStr;
|
|
56
58
|
return numStr.length <= 6
|
|
57
|
-
? "0."
|
|
58
|
-
: numStr.slice(0, numStr.length - 6) +
|
|
59
|
-
"." +
|
|
60
|
-
numStr.slice(numStr.length - 6, numStr.length - 6 + precision);
|
|
59
|
+
? "0.".concat(numStr.slice(0, precision))
|
|
60
|
+
: "".concat(numStr.slice(0, numStr.length - 6), ".").concat(numStr.slice(numStr.length - 6, numStr.length - 6 + precision));
|
|
61
61
|
}
|
|
62
62
|
exports.formatBn4dig = formatBn4dig;
|
|
63
63
|
function toHumanFormat(num, precision) {
|
|
64
64
|
if (precision === void 0) { precision = 2; }
|
|
65
65
|
if (num.gte(1e15)) {
|
|
66
|
-
return formatBn4dig(num.div(1e9), precision)
|
|
66
|
+
return "".concat(formatBn4dig(num.div(1e9), precision), "Bn");
|
|
67
67
|
}
|
|
68
68
|
if (num.gte(1e12)) {
|
|
69
|
-
return formatBn4dig(num.div(1e6), precision)
|
|
69
|
+
return "".concat(formatBn4dig(num.div(1e6), precision), "M");
|
|
70
70
|
}
|
|
71
71
|
if (num.gte(1e9)) {
|
|
72
|
-
return formatBn4dig(num.div(1e3), precision)
|
|
72
|
+
return "".concat(formatBn4dig(num.div(1e3), precision), "K");
|
|
73
73
|
}
|
|
74
74
|
return formatBn4dig(num, precision);
|
|
75
75
|
}
|
|
@@ -102,20 +102,23 @@ function shortHash(address) {
|
|
|
102
102
|
exports.shortHash = shortHash;
|
|
103
103
|
var formatRate = function (rate) {
|
|
104
104
|
return rate
|
|
105
|
-
? (ethers_1.BigNumber.from(rate)
|
|
105
|
+
? "".concat((ethers_1.BigNumber.from(rate)
|
|
106
106
|
.mul(constants_1.PERCENTAGE_FACTOR)
|
|
107
107
|
.mul(100)
|
|
108
108
|
.div(constants_1.RAY)
|
|
109
|
-
.toNumber() / constants_1.PERCENTAGE_FACTOR).toFixed(2)
|
|
109
|
+
.toNumber() / constants_1.PERCENTAGE_FACTOR).toFixed(2), "%")
|
|
110
110
|
: "0.00%";
|
|
111
111
|
};
|
|
112
112
|
exports.formatRate = formatRate;
|
|
113
113
|
function formatDate(date) {
|
|
114
|
-
var d = new Date(date)
|
|
114
|
+
var d = new Date(date);
|
|
115
|
+
var month = "".concat(d.getMonth() + 1);
|
|
116
|
+
var day = "".concat(d.getDate());
|
|
117
|
+
var year = d.getFullYear();
|
|
115
118
|
if (month.length < 2)
|
|
116
|
-
month = "0"
|
|
119
|
+
month = "0".concat(month);
|
|
117
120
|
if (day.length < 2)
|
|
118
|
-
day = "0"
|
|
121
|
+
day = "0".concat(day);
|
|
119
122
|
return [year, month, day].join("-");
|
|
120
123
|
}
|
|
121
124
|
exports.formatDate = formatDate;
|
package/lib/utils/loading.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function allLoaded(itemsToLoad: Array<unknown>): boolean;
|
|
2
|
+
export declare function loadingProgress(itemsToLoad: Array<unknown>): number;
|