@gearbox-protocol/sdk 0.0.54 → 0.0.55
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/lib/core/contracts.d.ts +29 -17
- package/lib/core/contracts.js +43 -3
- package/lib/core/contractsRegister.js +24 -6
- package/lib/core/creditAccount.js +26 -20
- package/lib/core/events.d.ts +10 -10
- package/lib/core/events.js +22 -22
- package/lib/core/priceFeeds.js +61 -0
- package/lib/core/token.d.ts +42 -15
- package/lib/core/token.js +197 -36
- package/lib/core/transactions.d.ts +2 -2
- package/lib/core/transactions.js +10 -10
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lib/utils/mappers.d.ts +6 -0
- package/lib/utils/mappers.js +33 -0
- package/package.json +1 -1
- package/src/core/adapters.ts +13 -15
- package/src/core/contracts.ts +97 -42
- package/src/core/contractsRegister.ts +16 -8
- package/src/core/creditAccount.ts +33 -19
- package/src/core/events.ts +30 -22
- package/src/core/priceFeeds.ts +66 -0
- package/src/core/token.ts +633 -370
- package/src/core/transactions.ts +10 -10
- package/src/index.ts +2 -0
- package/src/utils/mappers.ts +23 -0
package/lib/core/contracts.d.ts
CHANGED
|
@@ -9,38 +9,50 @@ export declare type ConvexPoolContract = "CONVEX_3CRV_POOL" | "CONVEX_GUSD_POOL"
|
|
|
9
9
|
export declare type SupportedContract = UniswapV2Contract | "UNISWAP_V3_ROUTER" | CurvePoolContract | YearnVaultContract | "CONVEX_BOOSTER" | ConvexPoolContract | "CONVEX_CLAIM_ZAP" | "LIDO_STETH_GATEWAY";
|
|
10
10
|
export declare const contractsByNetwork: Record<NetworkType, Record<SupportedContract, string>>;
|
|
11
11
|
export declare const UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
|
|
12
|
-
export interface
|
|
13
|
-
|
|
14
|
-
type: AdapterInterface.CURVE_V1_STECRV_POOL;
|
|
15
|
-
pool: Record<NetworkType, string>;
|
|
16
|
-
lpToken: "steCRV";
|
|
17
|
-
}
|
|
18
|
-
export interface LidoParams {
|
|
19
|
-
protocol: Protocols.Lido;
|
|
20
|
-
type: AdapterInterface.LIDO_V1;
|
|
21
|
-
contract: Record<NetworkType, string>;
|
|
12
|
+
export interface BaseContractParams {
|
|
13
|
+
name: string;
|
|
22
14
|
}
|
|
23
|
-
|
|
15
|
+
declare type UniswapV2Params = {
|
|
24
16
|
protocol: Protocols.Uniswap | Protocols.Sushiswap;
|
|
25
17
|
type: AdapterInterface.UNISWAP_V2_ROUTER;
|
|
26
|
-
}
|
|
18
|
+
} & BaseContractParams;
|
|
19
|
+
declare type UniswapV3Params = {
|
|
27
20
|
protocol: Protocols.Uniswap;
|
|
28
21
|
type: AdapterInterface.UNISWAP_V3_ROUTER;
|
|
29
22
|
quoter: string;
|
|
30
|
-
}
|
|
23
|
+
} & BaseContractParams;
|
|
24
|
+
declare type CurveParams = {
|
|
31
25
|
protocol: Protocols.Curve;
|
|
32
26
|
type: AdapterInterface.CURVE_V1_2ASSETS | AdapterInterface.CURVE_V1_3ASSETS | AdapterInterface.CURVE_V1_4ASSETS;
|
|
33
27
|
lpToken: CurveLPToken;
|
|
34
28
|
tokens: Array<NormalToken | CurveLPToken>;
|
|
35
|
-
}
|
|
29
|
+
} & BaseContractParams;
|
|
30
|
+
export declare type CurveSteCRVPoolParams = {
|
|
31
|
+
protocol: Protocols.Curve;
|
|
32
|
+
type: AdapterInterface.CURVE_V1_STECRV_POOL;
|
|
33
|
+
pool: Record<NetworkType, string>;
|
|
34
|
+
lpToken: "steCRV";
|
|
35
|
+
} & BaseContractParams;
|
|
36
|
+
declare type YearnParams = {
|
|
36
37
|
protocol: Protocols.Yearn;
|
|
37
38
|
type: AdapterInterface.YEARN_V2;
|
|
38
|
-
}
|
|
39
|
+
} & BaseContractParams;
|
|
40
|
+
declare type ConvexParams = {
|
|
39
41
|
protocol: Protocols.Convex;
|
|
40
42
|
type: AdapterInterface.CONVEX_V1_BOOSTER | AdapterInterface.CONVEX_V1_CLAIM_ZAP;
|
|
41
|
-
}
|
|
43
|
+
} & BaseContractParams;
|
|
44
|
+
declare type ConvexPoolParams = {
|
|
42
45
|
protocol: Protocols.Convex;
|
|
43
46
|
type: AdapterInterface.CONVEX_V1_BASE_REWARD_POOL;
|
|
44
47
|
stakedToken: ConvexStakedPhantomToken;
|
|
45
|
-
}
|
|
48
|
+
} & BaseContractParams;
|
|
49
|
+
export declare type LidoParams = {
|
|
50
|
+
protocol: Protocols.Lido;
|
|
51
|
+
type: AdapterInterface.LIDO_V1;
|
|
52
|
+
contract: Record<NetworkType, string>;
|
|
53
|
+
lpToken: "steCRV";
|
|
54
|
+
} & BaseContractParams;
|
|
55
|
+
export declare type ContractParams = UniswapV2Params | UniswapV3Params | CurveParams | CurveSteCRVPoolParams | YearnParams | ConvexParams | ConvexPoolParams | LidoParams;
|
|
46
56
|
export declare const contractParams: Record<SupportedContract, ContractParams>;
|
|
57
|
+
export declare const contractsByAddress: Record<string, SupportedContract>;
|
|
58
|
+
export {};
|
package/lib/core/contracts.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.contractsByAddress = exports.contractParams = exports.UNISWAP_V3_QUOTER = exports.contractsByNetwork = void 0;
|
|
2
15
|
/*
|
|
3
16
|
* SPDX-License-Identifier: BSL-1.1
|
|
4
17
|
* Gearbox. Generalized leverage protocol, which allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.
|
|
5
18
|
* (c) Gearbox.fi, 2021
|
|
6
19
|
*/
|
|
7
|
-
|
|
8
|
-
exports.contractParams = exports.UNISWAP_V3_QUOTER = exports.contractsByNetwork = void 0;
|
|
20
|
+
var mappers_1 = require("../utils/mappers");
|
|
9
21
|
var adapters_1 = require("./adapters");
|
|
10
22
|
var protocols_1 = require("./protocols");
|
|
11
23
|
var token_1 = require("./token");
|
|
@@ -72,25 +84,30 @@ exports.contractsByNetwork = {
|
|
|
72
84
|
exports.UNISWAP_V3_QUOTER = "0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6";
|
|
73
85
|
exports.contractParams = {
|
|
74
86
|
UNISWAP_V2_ROUTER: {
|
|
87
|
+
name: "Uniswap V2",
|
|
75
88
|
protocol: protocols_1.Protocols.Uniswap,
|
|
76
89
|
type: adapters_1.AdapterInterface.UNISWAP_V2_ROUTER
|
|
77
90
|
},
|
|
78
91
|
UNISWAP_V3_ROUTER: {
|
|
92
|
+
name: "Uniswap V3",
|
|
79
93
|
protocol: protocols_1.Protocols.Uniswap,
|
|
80
94
|
quoter: exports.UNISWAP_V3_QUOTER,
|
|
81
95
|
type: adapters_1.AdapterInterface.UNISWAP_V3_ROUTER
|
|
82
96
|
},
|
|
83
97
|
SUSHISWAP_ROUTER: {
|
|
98
|
+
name: "Sushiswap",
|
|
84
99
|
protocol: protocols_1.Protocols.Sushiswap,
|
|
85
100
|
type: adapters_1.AdapterInterface.UNISWAP_V2_ROUTER
|
|
86
101
|
},
|
|
87
102
|
CURVE_3CRV_POOL: {
|
|
103
|
+
name: "Curve 3Pool",
|
|
88
104
|
protocol: protocols_1.Protocols.Curve,
|
|
89
105
|
type: adapters_1.AdapterInterface.CURVE_V1_3ASSETS,
|
|
90
106
|
lpToken: "3Crv",
|
|
91
107
|
tokens: ["DAI", "USDC", "USDT"]
|
|
92
108
|
},
|
|
93
109
|
CURVE_STETH_GATEWAY: {
|
|
110
|
+
name: "Curve stETH",
|
|
94
111
|
protocol: protocols_1.Protocols.Curve,
|
|
95
112
|
type: adapters_1.AdapterInterface.CURVE_V1_STECRV_POOL,
|
|
96
113
|
pool: {
|
|
@@ -100,92 +117,115 @@ exports.contractParams = {
|
|
|
100
117
|
lpToken: "steCRV"
|
|
101
118
|
},
|
|
102
119
|
CURVE_FRAX_POOL: {
|
|
120
|
+
name: "Curve FRAX",
|
|
103
121
|
protocol: protocols_1.Protocols.Curve,
|
|
104
122
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
105
123
|
lpToken: "FRAX3CRV",
|
|
106
124
|
tokens: ["3Crv", "FRAX"]
|
|
107
125
|
},
|
|
108
126
|
CURVE_LUSD_POOL: {
|
|
127
|
+
name: "Curve LUSD",
|
|
109
128
|
protocol: protocols_1.Protocols.Curve,
|
|
110
129
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
111
130
|
lpToken: "LUSD3CRV",
|
|
112
131
|
tokens: ["3Crv", "LUSD"]
|
|
113
132
|
},
|
|
114
133
|
CURVE_SUSD_POOL: {
|
|
134
|
+
name: "Curve SUSD",
|
|
115
135
|
protocol: protocols_1.Protocols.Curve,
|
|
116
136
|
type: adapters_1.AdapterInterface.CURVE_V1_4ASSETS,
|
|
117
137
|
lpToken: "crvPlain3andSUSD",
|
|
118
138
|
tokens: ["DAI", "USDC", "USDT", "sUSD"]
|
|
119
139
|
},
|
|
120
140
|
CURVE_GUSD_POOL: {
|
|
141
|
+
name: "Curve GUSD",
|
|
121
142
|
protocol: protocols_1.Protocols.Curve,
|
|
122
143
|
type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
|
|
123
144
|
lpToken: "gusd3CRV",
|
|
124
145
|
tokens: ["3Crv", "FRAX"]
|
|
125
146
|
},
|
|
126
147
|
YEARN_DAI_VAULT: {
|
|
148
|
+
name: "Yearn DAI",
|
|
127
149
|
protocol: protocols_1.Protocols.Yearn,
|
|
128
150
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
129
151
|
},
|
|
130
152
|
YEARN_USDC_VAULT: {
|
|
153
|
+
name: "Yearn USDC",
|
|
131
154
|
protocol: protocols_1.Protocols.Yearn,
|
|
132
155
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
133
156
|
},
|
|
134
157
|
YEARN_WETH_VAULT: {
|
|
158
|
+
name: "Yearn WETH",
|
|
135
159
|
protocol: protocols_1.Protocols.Yearn,
|
|
136
160
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
137
161
|
},
|
|
138
162
|
YEARN_WBTC_VAULT: {
|
|
163
|
+
name: "Yearn WBTC",
|
|
139
164
|
protocol: protocols_1.Protocols.Yearn,
|
|
140
165
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
141
166
|
},
|
|
142
167
|
YEARN_CURVE_FRAX_VAULT: {
|
|
168
|
+
name: "Yearn Curve FRAX",
|
|
143
169
|
protocol: protocols_1.Protocols.Yearn,
|
|
144
170
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
145
171
|
},
|
|
146
172
|
YEARN_CURVE_STETH_VAULT: {
|
|
173
|
+
name: "Yearn Curve STETH",
|
|
147
174
|
protocol: protocols_1.Protocols.Yearn,
|
|
148
175
|
type: adapters_1.AdapterInterface.YEARN_V2
|
|
149
176
|
},
|
|
150
177
|
CONVEX_BOOSTER: {
|
|
178
|
+
name: "Convex BOOSTER",
|
|
151
179
|
protocol: protocols_1.Protocols.Convex,
|
|
152
180
|
type: adapters_1.AdapterInterface.CONVEX_V1_BOOSTER
|
|
153
181
|
},
|
|
154
182
|
CONVEX_3CRV_POOL: {
|
|
183
|
+
name: "Convex 3crv",
|
|
155
184
|
protocol: protocols_1.Protocols.Convex,
|
|
156
185
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
157
186
|
stakedToken: "stkcvx3Crv"
|
|
158
187
|
},
|
|
159
188
|
CONVEX_GUSD_POOL: {
|
|
189
|
+
name: "Convex GUSD",
|
|
160
190
|
protocol: protocols_1.Protocols.Convex,
|
|
161
191
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
162
192
|
stakedToken: "stkcvxgusd3CRV"
|
|
163
193
|
},
|
|
164
194
|
CONVEX_SUSD_POOL: {
|
|
195
|
+
name: "Convex SUSD",
|
|
165
196
|
protocol: protocols_1.Protocols.Convex,
|
|
166
197
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
167
198
|
stakedToken: "stkcvxcrvPlain3andSUSD"
|
|
168
199
|
},
|
|
169
200
|
CONVEX_STECRV_POOL: {
|
|
201
|
+
name: "Convex STECRV",
|
|
170
202
|
protocol: protocols_1.Protocols.Convex,
|
|
171
203
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
172
204
|
stakedToken: "stkcvxsteCRV"
|
|
173
205
|
},
|
|
174
206
|
CONVEX_FRAX3CRV_POOL: {
|
|
207
|
+
name: "Convex FRAX3CRV",
|
|
175
208
|
protocol: protocols_1.Protocols.Convex,
|
|
176
209
|
type: adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL,
|
|
177
210
|
stakedToken: "stkcvxFRAX3CRV"
|
|
178
211
|
},
|
|
179
212
|
CONVEX_CLAIM_ZAP: {
|
|
213
|
+
name: "Convex ZAP",
|
|
180
214
|
protocol: protocols_1.Protocols.Convex,
|
|
181
215
|
type: adapters_1.AdapterInterface.CONVEX_V1_CLAIM_ZAP
|
|
182
216
|
},
|
|
183
217
|
LIDO_STETH_GATEWAY: {
|
|
218
|
+
name: "Lido STETH",
|
|
184
219
|
protocol: protocols_1.Protocols.Lido,
|
|
185
220
|
type: adapters_1.AdapterInterface.LIDO_V1,
|
|
186
221
|
contract: {
|
|
187
222
|
Mainnet: "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
|
|
188
223
|
Kovan: ""
|
|
189
|
-
}
|
|
224
|
+
},
|
|
225
|
+
lpToken: "steCRV"
|
|
190
226
|
}
|
|
191
227
|
};
|
|
228
|
+
exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce(function (sum, _a) {
|
|
229
|
+
var _ = _a[0], contracts = _a[1];
|
|
230
|
+
return __assign(__assign({}, sum), (0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(contracts)));
|
|
231
|
+
}, {});
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.getContractName = exports.deployedContracts = void 0;
|
|
15
|
+
var mappers_1 = require("../utils/mappers");
|
|
16
|
+
var contracts_1 = require("./contracts");
|
|
4
17
|
exports.deployedContracts = {
|
|
5
18
|
// MAINNET
|
|
6
19
|
"0x24946bCbBd028D5ABb62ad9B635EB1b1a67AF668": "DAI",
|
|
@@ -25,16 +38,21 @@ exports.deployedContracts = {
|
|
|
25
38
|
"0xe04b4db67127d1930D36f16B51653120C4285708": "WBTC",
|
|
26
39
|
"0x600073357c29d169aAF3E543A4519749830553F1": "WETH",
|
|
27
40
|
"0xdBAd1361d9A03B81Be8D3a54Ef0dc9e39a1bA5b3": "USDC",
|
|
28
|
-
"0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI"
|
|
41
|
+
"0x50d1fA47b0D88BA0D108148B8481b4A762eFB99e": "DAI"
|
|
29
42
|
// [YEARN_DAI_VAULT_KOVAN_MOCK]: "Yearn DAI",
|
|
30
43
|
// [YEARN_USDC_VAULT_KOVAN_MOCK]: "Yearn USDC",
|
|
31
44
|
// [SUSHISWAP_KOVAN]: "Sushiswap"
|
|
32
45
|
};
|
|
46
|
+
var contractNames = Object.entries(contracts_1.contractsByAddress).reduce(function (sum, _a) {
|
|
47
|
+
var _b;
|
|
48
|
+
var addr = _a[0], cSymbol = _a[1];
|
|
49
|
+
var params = contracts_1.contractParams[cSymbol];
|
|
50
|
+
if (!params)
|
|
51
|
+
return sum;
|
|
52
|
+
return __assign(__assign({}, sum), (_b = {}, _b[addr] = params.name, _b));
|
|
53
|
+
}, {});
|
|
54
|
+
var contractsFullList = __assign(__assign({}, (0, mappers_1.keyToLowercase)(exports.deployedContracts)), contractNames);
|
|
33
55
|
function getContractName(address) {
|
|
34
|
-
|
|
35
|
-
var addr = _a[0], name = _a[1];
|
|
36
|
-
exports.deployedContracts[addr.toLowerCase()] = name;
|
|
37
|
-
});
|
|
38
|
-
return exports.deployedContracts[address.toLowerCase()] || address;
|
|
56
|
+
return contractsFullList[address.toLowerCase()] || address;
|
|
39
57
|
}
|
|
40
58
|
exports.getContractName = getContractName;
|
|
@@ -54,30 +54,36 @@ var CreditAccountData = /** @class */ (function () {
|
|
|
54
54
|
}
|
|
55
55
|
CreditAccountData.prototype.balancesSorted = function (prices, tokens) {
|
|
56
56
|
var priceCalc = function (addr, amount) {
|
|
57
|
-
var
|
|
57
|
+
var price = prices[addr] || 0;
|
|
58
|
+
var _a = (tokens[addr] || {}).decimals, decimals = _a === void 0 ? 18 : _a;
|
|
58
59
|
return amount
|
|
59
|
-
.mul(Math.floor(1000 *
|
|
60
|
-
.div(ethers_1.BigNumber.from(10).pow(
|
|
60
|
+
.mul(Math.floor(1000 * price))
|
|
61
|
+
.div(ethers_1.BigNumber.from(10).pow(decimals));
|
|
61
62
|
};
|
|
62
63
|
var tokensAbcComparator = function (t1, t2) {
|
|
63
|
-
|
|
64
|
+
var _a = (t1 || {}).symbol, symbol1 = _a === void 0 ? "" : _a;
|
|
65
|
+
var _b = (t2 || {}).symbol, symbol2 = _b === void 0 ? "" : _b;
|
|
66
|
+
return symbol1 > symbol2 ? 1 : -1;
|
|
64
67
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
var safeBalances = this.balances || [];
|
|
69
|
+
return Object.entries(safeBalances)
|
|
70
|
+
.sort(function (_a, _b) {
|
|
71
|
+
var addr1 = _a[0], amount1 = _a[1];
|
|
72
|
+
var addr2 = _b[0], amount2 = _b[1];
|
|
73
|
+
var addr1Lc = addr1.toLowerCase();
|
|
74
|
+
var addr2Lc = addr2.toLowerCase();
|
|
75
|
+
var price1 = priceCalc(addr1Lc, amount1);
|
|
76
|
+
var price2 = priceCalc(addr2Lc, amount2);
|
|
77
|
+
return price1.eq(price2)
|
|
78
|
+
? tokensAbcComparator(tokens[addr1Lc], tokens[addr2Lc])
|
|
79
|
+
: price1.gt(price2)
|
|
80
|
+
? -1
|
|
81
|
+
: 1;
|
|
82
|
+
})
|
|
83
|
+
.map(function (_a) {
|
|
84
|
+
var address = _a[0], balance = _a[1];
|
|
85
|
+
return ({ address: address, balance: balance });
|
|
86
|
+
});
|
|
81
87
|
};
|
|
82
88
|
return CreditAccountData;
|
|
83
89
|
}());
|
package/lib/core/events.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare class EventRepayCreditAccount extends EVMEvent {
|
|
|
82
82
|
readonly underlyingToken: string;
|
|
83
83
|
readonly creditManager: string;
|
|
84
84
|
constructor(opts: RepayCreditAccountProps);
|
|
85
|
-
toString(
|
|
85
|
+
toString(_: Record<string, TokenData>): string;
|
|
86
86
|
}
|
|
87
87
|
interface AddCollateralProps extends EVMEventProps {
|
|
88
88
|
amount: string;
|
|
@@ -288,7 +288,7 @@ export declare class EventNewWithdrawFee extends EVMEvent {
|
|
|
288
288
|
readonly newFee: number;
|
|
289
289
|
readonly prevFee: number;
|
|
290
290
|
constructor(opts: NewWithdrawFeeProps);
|
|
291
|
-
toString(
|
|
291
|
+
toString(_: Record<string, TokenData>): string;
|
|
292
292
|
}
|
|
293
293
|
interface NewPriceFeedProps extends EVMEventProps {
|
|
294
294
|
token: string;
|
|
@@ -308,7 +308,7 @@ export declare class EventTakeForever extends EVMEvent {
|
|
|
308
308
|
readonly creditAccount: string;
|
|
309
309
|
readonly to: string;
|
|
310
310
|
constructor(opts: TakeForeverProps);
|
|
311
|
-
toString(
|
|
311
|
+
toString(_: Record<string, TokenData>): string;
|
|
312
312
|
}
|
|
313
313
|
interface PausedProps extends EVMEventProps {
|
|
314
314
|
contract: string;
|
|
@@ -316,7 +316,7 @@ interface PausedProps extends EVMEventProps {
|
|
|
316
316
|
export declare class EventPaused extends EVMEvent {
|
|
317
317
|
readonly contract: string;
|
|
318
318
|
constructor(opts: PausedProps);
|
|
319
|
-
toString(
|
|
319
|
+
toString(_: Record<string, TokenData>): string;
|
|
320
320
|
}
|
|
321
321
|
interface UnPausedProps extends EVMEventProps {
|
|
322
322
|
contract: string;
|
|
@@ -324,7 +324,7 @@ interface UnPausedProps extends EVMEventProps {
|
|
|
324
324
|
export declare class EventUnPaused extends EVMEvent {
|
|
325
325
|
readonly contract: string;
|
|
326
326
|
constructor(opts: UnPausedProps);
|
|
327
|
-
toString(
|
|
327
|
+
toString(_: Record<string, TokenData>): string;
|
|
328
328
|
}
|
|
329
329
|
interface PausableAdminAddedProps extends EVMEventProps {
|
|
330
330
|
admin: string;
|
|
@@ -332,7 +332,7 @@ interface PausableAdminAddedProps extends EVMEventProps {
|
|
|
332
332
|
export declare class EventPausableAdminAdded extends EVMEvent {
|
|
333
333
|
readonly admin: string;
|
|
334
334
|
constructor(opts: PausableAdminAddedProps);
|
|
335
|
-
toString(
|
|
335
|
+
toString(_: Record<string, TokenData>): string;
|
|
336
336
|
}
|
|
337
337
|
interface PausableAdminRemovedProps extends EVMEventProps {
|
|
338
338
|
admin: string;
|
|
@@ -340,7 +340,7 @@ interface PausableAdminRemovedProps extends EVMEventProps {
|
|
|
340
340
|
export declare class EventPausableAdminRemoved extends EVMEvent {
|
|
341
341
|
readonly admin: string;
|
|
342
342
|
constructor(opts: PausableAdminRemovedProps);
|
|
343
|
-
toString(
|
|
343
|
+
toString(_: Record<string, TokenData>): string;
|
|
344
344
|
}
|
|
345
345
|
interface UnPausableAdminAddedProps extends EVMEventProps {
|
|
346
346
|
admin: string;
|
|
@@ -348,7 +348,7 @@ interface UnPausableAdminAddedProps extends EVMEventProps {
|
|
|
348
348
|
export declare class EventUnPausableAdminAdded extends EVMEvent {
|
|
349
349
|
readonly admin: string;
|
|
350
350
|
constructor(opts: UnPausableAdminAddedProps);
|
|
351
|
-
toString(
|
|
351
|
+
toString(_: Record<string, TokenData>): string;
|
|
352
352
|
}
|
|
353
353
|
interface UnPausableAdminRemovedProps extends EVMEventProps {
|
|
354
354
|
admin: string;
|
|
@@ -356,7 +356,7 @@ interface UnPausableAdminRemovedProps extends EVMEventProps {
|
|
|
356
356
|
export declare class EventUnPausableAdminRemoved extends EVMEvent {
|
|
357
357
|
readonly admin: string;
|
|
358
358
|
constructor(opts: UnPausableAdminRemovedProps);
|
|
359
|
-
toString(
|
|
359
|
+
toString(_: Record<string, TokenData>): string;
|
|
360
360
|
}
|
|
361
361
|
interface TransferOwnershipProps extends EVMEventProps {
|
|
362
362
|
admin: string;
|
|
@@ -364,6 +364,6 @@ interface TransferOwnershipProps extends EVMEventProps {
|
|
|
364
364
|
export declare class EventTransferOwnership extends EVMEvent {
|
|
365
365
|
readonly newOwner: string;
|
|
366
366
|
constructor(opts: TransferOwnershipProps);
|
|
367
|
-
toString(
|
|
367
|
+
toString(_: Record<string, TokenData>): string;
|
|
368
368
|
}
|
|
369
369
|
export {};
|
package/lib/core/events.js
CHANGED
|
@@ -116,7 +116,7 @@ var EventAddLiquidity = /** @class */ (function (_super) {
|
|
|
116
116
|
return _this;
|
|
117
117
|
}
|
|
118
118
|
EventAddLiquidity.prototype.toString = function (tokenData) {
|
|
119
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
119
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
120
120
|
return "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), ": Deposit ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol);
|
|
121
121
|
};
|
|
122
122
|
return EventAddLiquidity;
|
|
@@ -137,7 +137,7 @@ var EventRemoveLiquidity = /** @class */ (function (_super) {
|
|
|
137
137
|
return _this;
|
|
138
138
|
}
|
|
139
139
|
EventRemoveLiquidity.prototype.toString = function (tokenData) {
|
|
140
|
-
var _a = tokenData[this.dieselToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
140
|
+
var _a = tokenData[this.dieselToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
141
141
|
return "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), ": withdraw ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol);
|
|
142
142
|
};
|
|
143
143
|
return EventRemoveLiquidity;
|
|
@@ -158,7 +158,7 @@ var EventOpenCreditAccount = /** @class */ (function (_super) {
|
|
|
158
158
|
return _this;
|
|
159
159
|
}
|
|
160
160
|
EventOpenCreditAccount.prototype.toString = function (tokenData) {
|
|
161
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
161
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
162
162
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": open ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol, " x ").concat(this.leverage.toFixed(2), " \u21D2 \n ").concat((0, formatter_1.formatBN)(this.amount
|
|
163
163
|
.mul(Math.floor(this.leverage + constants_1.LEVERAGE_DECIMALS))
|
|
164
164
|
.div(constants_1.LEVERAGE_DECIMALS), decimals + 2), " ").concat(symbol);
|
|
@@ -180,7 +180,7 @@ var EventCloseCreditAccount = /** @class */ (function (_super) {
|
|
|
180
180
|
return _this;
|
|
181
181
|
}
|
|
182
182
|
EventCloseCreditAccount.prototype.toString = function (tokenData) {
|
|
183
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
183
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
184
184
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": was closed and got ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol, " as remaining funds");
|
|
185
185
|
};
|
|
186
186
|
return EventCloseCreditAccount;
|
|
@@ -200,7 +200,7 @@ var EventLiquidateCreditAccount = /** @class */ (function (_super) {
|
|
|
200
200
|
return _this;
|
|
201
201
|
}
|
|
202
202
|
EventLiquidateCreditAccount.prototype.toString = function (tokenData) {
|
|
203
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
203
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
204
204
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": was liquidated. ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol, " were paid back as remaining funds");
|
|
205
205
|
};
|
|
206
206
|
return EventLiquidateCreditAccount;
|
|
@@ -218,7 +218,7 @@ var EventRepayCreditAccount = /** @class */ (function (_super) {
|
|
|
218
218
|
_this.creditManager = opts.creditManager;
|
|
219
219
|
return _this;
|
|
220
220
|
}
|
|
221
|
-
EventRepayCreditAccount.prototype.toString = function (
|
|
221
|
+
EventRepayCreditAccount.prototype.toString = function (_) {
|
|
222
222
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": was repaid");
|
|
223
223
|
};
|
|
224
224
|
return EventRepayCreditAccount;
|
|
@@ -238,7 +238,7 @@ var EventAddCollateral = /** @class */ (function (_super) {
|
|
|
238
238
|
return _this;
|
|
239
239
|
}
|
|
240
240
|
EventAddCollateral.prototype.toString = function (tokenData) {
|
|
241
|
-
var _a = tokenData[this.addedToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
241
|
+
var _a = tokenData[this.addedToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
242
242
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": added ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol, " as collateral");
|
|
243
243
|
};
|
|
244
244
|
return EventAddCollateral;
|
|
@@ -258,7 +258,7 @@ var EventIncreaseBorrowAmount = /** @class */ (function (_super) {
|
|
|
258
258
|
return _this;
|
|
259
259
|
}
|
|
260
260
|
EventIncreaseBorrowAmount.prototype.toString = function (tokenData) {
|
|
261
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
261
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
262
262
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": borrowed amount was increased for ").concat((0, formatter_1.formatBN)(this.amount, decimals), " ").concat(symbol);
|
|
263
263
|
};
|
|
264
264
|
return EventIncreaseBorrowAmount;
|
|
@@ -289,7 +289,7 @@ var EventCMNewParameters = /** @class */ (function (_super) {
|
|
|
289
289
|
return _this;
|
|
290
290
|
}
|
|
291
291
|
EventCMNewParameters.prototype.toString = function (tokenData) {
|
|
292
|
-
var token = tokenData[this.underlyingToken];
|
|
292
|
+
var token = tokenData[this.underlyingToken.toLowerCase()];
|
|
293
293
|
var msg = "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated: ");
|
|
294
294
|
if (this.minAmount !== this.prevMinAmount) {
|
|
295
295
|
msg += "min amount: ".concat((0, formatter_1.formatBN)(this.prevMinAmount, token.decimals), " => ").concat((0, formatter_1.formatBN)(this.minAmount, token.decimals), " ").concat(token.symbol, ", ");
|
|
@@ -330,7 +330,7 @@ var EventTokenAllowed = /** @class */ (function (_super) {
|
|
|
330
330
|
return _this;
|
|
331
331
|
}
|
|
332
332
|
EventTokenAllowed.prototype.toString = function (tokenData) {
|
|
333
|
-
var token = tokenData[this.token];
|
|
333
|
+
var token = tokenData[this.token.toLowerCase()];
|
|
334
334
|
var msg = "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated ");
|
|
335
335
|
switch (this.status) {
|
|
336
336
|
case "NewToken":
|
|
@@ -357,7 +357,7 @@ var EventTokenForbidden = /** @class */ (function (_super) {
|
|
|
357
357
|
return _this;
|
|
358
358
|
}
|
|
359
359
|
EventTokenForbidden.prototype.toString = function (tokenData) {
|
|
360
|
-
var token = tokenData[this.token];
|
|
360
|
+
var token = tokenData[this.token.toLowerCase()];
|
|
361
361
|
return "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated ").concat(token.symbol, " forbidden");
|
|
362
362
|
};
|
|
363
363
|
return EventTokenForbidden;
|
|
@@ -541,7 +541,7 @@ var EventNewExpectedLiquidityLimit = /** @class */ (function (_super) {
|
|
|
541
541
|
return _this;
|
|
542
542
|
}
|
|
543
543
|
EventNewExpectedLiquidityLimit.prototype.toString = function (tokenData) {
|
|
544
|
-
var _a = tokenData[this.underlyingToken] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
544
|
+
var _a = tokenData[this.underlyingToken.toLowerCase()] || {}, _b = _a.decimals, decimals = _b === void 0 ? 18 : _b, symbol = _a.symbol;
|
|
545
545
|
return this.prevLimit.isZero()
|
|
546
546
|
? "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: expected liquidity limit was set to ").concat((0, formatter_1.formatBN)(this.newLimit, decimals), " ").concat(symbol)
|
|
547
547
|
: "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: expected liquidity limit was ").concat(this.newLimit.gt(this.prevLimit) ? "increased" : "decreased", ": ").concat((0, formatter_1.formatBN)(this.prevLimit, decimals), " ").concat(symbol, " => ").concat((0, formatter_1.formatBN)(this.newLimit, decimals), " ").concat(symbol);
|
|
@@ -563,7 +563,7 @@ var EventNewWithdrawFee = /** @class */ (function (_super) {
|
|
|
563
563
|
_this.prevFee = Number(opts.oldFee);
|
|
564
564
|
return _this;
|
|
565
565
|
}
|
|
566
|
-
EventNewWithdrawFee.prototype.toString = function (
|
|
566
|
+
EventNewWithdrawFee.prototype.toString = function (_) {
|
|
567
567
|
return this.prevFee === 0
|
|
568
568
|
? "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: withdraw fee was set to: ").concat(this.newFee / 100, "%")
|
|
569
569
|
: "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: withdraw fee was ").concat(this.newFee > this.prevFee ? "increased" : "decreased", ": ").concat(this.prevFee / 100, "% => ").concat(this.newFee / 100, "%");
|
|
@@ -584,7 +584,7 @@ var EventNewPriceFeed = /** @class */ (function (_super) {
|
|
|
584
584
|
return _this;
|
|
585
585
|
}
|
|
586
586
|
EventNewPriceFeed.prototype.toString = function (tokenData) {
|
|
587
|
-
var symbol = (tokenData[this.token] || {}).symbol;
|
|
587
|
+
var symbol = (tokenData[this.token.toLowerCase()] || {}).symbol;
|
|
588
588
|
return "PriceOracle: oracle for ".concat(symbol, " was updated to ").concat((0, contractsRegister_1.getContractName)(this.priceFeed));
|
|
589
589
|
};
|
|
590
590
|
return EventNewPriceFeed;
|
|
@@ -602,7 +602,7 @@ var EventTakeForever = /** @class */ (function (_super) {
|
|
|
602
602
|
_this.to = opts.to;
|
|
603
603
|
return _this;
|
|
604
604
|
}
|
|
605
|
-
EventTakeForever.prototype.toString = function (
|
|
605
|
+
EventTakeForever.prototype.toString = function (_) {
|
|
606
606
|
return "AccountFactory: account ".concat(this.creditAccount, " was taken forever and transferred to ").concat(this.to);
|
|
607
607
|
};
|
|
608
608
|
return EventTakeForever;
|
|
@@ -619,7 +619,7 @@ var EventPaused = /** @class */ (function (_super) {
|
|
|
619
619
|
_this.contract = opts.contract;
|
|
620
620
|
return _this;
|
|
621
621
|
}
|
|
622
|
-
EventPaused.prototype.toString = function (
|
|
622
|
+
EventPaused.prototype.toString = function (_) {
|
|
623
623
|
return "".concat((0, contractsRegister_1.getContractName)(this.contract), " was paused");
|
|
624
624
|
};
|
|
625
625
|
return EventPaused;
|
|
@@ -636,7 +636,7 @@ var EventUnPaused = /** @class */ (function (_super) {
|
|
|
636
636
|
_this.contract = opts.contract;
|
|
637
637
|
return _this;
|
|
638
638
|
}
|
|
639
|
-
EventUnPaused.prototype.toString = function (
|
|
639
|
+
EventUnPaused.prototype.toString = function (_) {
|
|
640
640
|
return "".concat((0, contractsRegister_1.getContractName)(this.contract), " was unpaused");
|
|
641
641
|
};
|
|
642
642
|
return EventUnPaused;
|
|
@@ -653,7 +653,7 @@ var EventPausableAdminAdded = /** @class */ (function (_super) {
|
|
|
653
653
|
_this.admin = opts.admin;
|
|
654
654
|
return _this;
|
|
655
655
|
}
|
|
656
|
-
EventPausableAdminAdded.prototype.toString = function (
|
|
656
|
+
EventPausableAdminAdded.prototype.toString = function (_) {
|
|
657
657
|
return "ACL: pausable admin ".concat(this.admin, " was added");
|
|
658
658
|
};
|
|
659
659
|
return EventPausableAdminAdded;
|
|
@@ -670,7 +670,7 @@ var EventPausableAdminRemoved = /** @class */ (function (_super) {
|
|
|
670
670
|
_this.admin = opts.admin;
|
|
671
671
|
return _this;
|
|
672
672
|
}
|
|
673
|
-
EventPausableAdminRemoved.prototype.toString = function (
|
|
673
|
+
EventPausableAdminRemoved.prototype.toString = function (_) {
|
|
674
674
|
return "ACL: pausable admin ".concat(this.admin, " was removed");
|
|
675
675
|
};
|
|
676
676
|
return EventPausableAdminRemoved;
|
|
@@ -687,7 +687,7 @@ var EventUnPausableAdminAdded = /** @class */ (function (_super) {
|
|
|
687
687
|
_this.admin = opts.admin;
|
|
688
688
|
return _this;
|
|
689
689
|
}
|
|
690
|
-
EventUnPausableAdminAdded.prototype.toString = function (
|
|
690
|
+
EventUnPausableAdminAdded.prototype.toString = function (_) {
|
|
691
691
|
return "ACL: unpausable admin ".concat(this.admin, " was added");
|
|
692
692
|
};
|
|
693
693
|
return EventUnPausableAdminAdded;
|
|
@@ -704,7 +704,7 @@ var EventUnPausableAdminRemoved = /** @class */ (function (_super) {
|
|
|
704
704
|
_this.admin = opts.admin;
|
|
705
705
|
return _this;
|
|
706
706
|
}
|
|
707
|
-
EventUnPausableAdminRemoved.prototype.toString = function (
|
|
707
|
+
EventUnPausableAdminRemoved.prototype.toString = function (_) {
|
|
708
708
|
return "ACL: unpausable admin ".concat(this.admin, " was removed");
|
|
709
709
|
};
|
|
710
710
|
return EventUnPausableAdminRemoved;
|
|
@@ -722,7 +722,7 @@ var EventTransferOwnership = /** @class */ (function (_super) {
|
|
|
722
722
|
_this.newOwner = opts.admin;
|
|
723
723
|
return _this;
|
|
724
724
|
}
|
|
725
|
-
EventTransferOwnership.prototype.toString = function (
|
|
725
|
+
EventTransferOwnership.prototype.toString = function (_) {
|
|
726
726
|
return "ACL: configurator was changed to ".concat(this.newOwner);
|
|
727
727
|
};
|
|
728
728
|
return EventTransferOwnership;
|