@gearbox-protocol/sdk 0.0.101 → 0.0.104
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 +7 -9
- package/lib/apy/lidoAPY.js +35 -29
- package/lib/contracts/contracts.d.ts +5 -2
- package/lib/contracts/contracts.js +19 -18
- package/lib/contracts/contractsRegister.js +13 -1
- package/lib/core/constants.d.ts +5 -3
- package/lib/core/constants.js +8 -6
- package/lib/core/creditAccount.d.ts +2 -2
- package/lib/core/creditAccount.js +12 -11
- package/lib/core/creditManager.d.ts +1 -1
- package/lib/core/creditManager.js +4 -10
- 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.d.ts +1 -3
- package/lib/core/price.js +9 -7
- package/lib/core/strategy.d.ts +8 -6
- package/lib/core/strategy.js +25 -25
- 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 +22 -22
- package/lib/payload/creditAccount.d.ts +4 -4
- package/lib/payload/creditManager.d.ts +3 -13
- package/lib/payload/pool.d.ts +2 -2
- 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 +8 -8
- 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 +13 -12
- package/src/apy/lidoAPY.ts +35 -27
- package/src/contracts/contracts.ts +27 -17
- package/src/contracts/contractsRegister.ts +16 -1
- package/src/core/constants.ts +8 -5
- package/src/core/creditAccount.ts +42 -16
- package/src/core/creditManager.ts +33 -7
- 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 +10 -13
- package/src/core/strategy.ts +54 -43
- 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 +32 -17
- package/src/payload/creditAccount.ts +4 -4
- package/src/payload/creditManager.ts +3 -13
- package/src/payload/pool.ts +2 -2
- package/src/payload/token.ts +3 -3
- package/src/strategies/convex.ts +360 -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 +13 -9
- 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
package/lib/core/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TokenData } from "../tokens/tokenData";
|
|
2
1
|
import { BigNumber } from "ethers";
|
|
2
|
+
import { TokenData } from "../tokens/tokenData";
|
|
3
3
|
import { EVMEvent, EVMTx, EVMEventProps } from "./eventOrTx";
|
|
4
4
|
export interface EventSerialized {
|
|
5
5
|
type: "EventAddLiquidity" | "EventRemoveLiquidity" | "EventOpenCreditAccount" | "EventCloseCreditAccount" | "EventLiquidateCreditAccount" | "EventRepayCreditAccount" | "EventAddCollateral" | "EventIncreaseBorrowAmount" | "EventCMNewParameters" | "EventTokenAllowed" | "EventTokenForbidden" | "EventContractAllowed" | "EventContractForbidden" | "EventNewFastCheckParameters" | "EventPriceOracleUpdated" | "EventTransferPluginAllowed" | "EventNewInterestRateModel" | "EventNewCreditManagerConnected" | "EventBorrowForbidden" | "EventNewExpectedLiquidityLimit" | "EventNewWithdrawFee" | "EventNewPriceFeed" | "EventTakeForever" | "EventPaused" | "EventUnPaused" | "EventPausableAdminAdded" | "EventPausableAdminRemoved" | "EventUnpausableAdminAdded" | "EventUnpausableAdminRemoved" | "EventOwnershipTransferred";
|
|
@@ -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(): string;
|
|
86
86
|
}
|
|
87
87
|
interface AddCollateralProps extends EVMEventProps {
|
|
88
88
|
amount: string;
|
|
@@ -182,7 +182,7 @@ export declare class EventContractAllowed extends EVMEvent {
|
|
|
182
182
|
readonly adapter: string;
|
|
183
183
|
readonly status: EventContractAllowedStatus;
|
|
184
184
|
constructor(opts: ContractAllowedProps);
|
|
185
|
-
toString(
|
|
185
|
+
toString(): string;
|
|
186
186
|
}
|
|
187
187
|
interface ContractForbiddenProps extends EVMEventProps {
|
|
188
188
|
creditManager: string;
|
|
@@ -192,7 +192,7 @@ export declare class EventContractForbidden extends EVMEvent {
|
|
|
192
192
|
readonly creditManager: string;
|
|
193
193
|
readonly protocol: string;
|
|
194
194
|
constructor(opts: ContractForbiddenProps);
|
|
195
|
-
toString(
|
|
195
|
+
toString(): string;
|
|
196
196
|
}
|
|
197
197
|
interface NewFastCheckParametersProps extends EVMEventProps {
|
|
198
198
|
creditManager: string;
|
|
@@ -208,7 +208,7 @@ export declare class EventNewFastCheckParameters extends EVMEvent {
|
|
|
208
208
|
readonly prevChiThreshold?: number;
|
|
209
209
|
readonly prevFastCheckDelay?: number;
|
|
210
210
|
constructor(opts: NewFastCheckParametersProps);
|
|
211
|
-
toString(
|
|
211
|
+
toString(): string;
|
|
212
212
|
}
|
|
213
213
|
interface PriceOracleUpdatedProps extends EVMEventProps {
|
|
214
214
|
creditManager: string;
|
|
@@ -218,7 +218,7 @@ export declare class EventPriceOracleUpdated extends EVMEvent {
|
|
|
218
218
|
readonly creditManager: string;
|
|
219
219
|
readonly priceOracle: string;
|
|
220
220
|
constructor(opts: PriceOracleUpdatedProps);
|
|
221
|
-
toString(
|
|
221
|
+
toString(): string;
|
|
222
222
|
}
|
|
223
223
|
interface TransferPluginAllowedProps extends EVMEventProps {
|
|
224
224
|
creditManager: string;
|
|
@@ -230,7 +230,7 @@ export declare class EventTransferPluginAllowed extends EVMEvent {
|
|
|
230
230
|
readonly plugin: string;
|
|
231
231
|
readonly state: boolean;
|
|
232
232
|
constructor(opts: TransferPluginAllowedProps);
|
|
233
|
-
toString(
|
|
233
|
+
toString(): string;
|
|
234
234
|
}
|
|
235
235
|
interface NewInterestRateModelProps extends EVMEventProps {
|
|
236
236
|
pool: string;
|
|
@@ -240,7 +240,7 @@ export declare class EventNewInterestRateModel extends EVMEvent {
|
|
|
240
240
|
readonly pool: string;
|
|
241
241
|
readonly newInterestRateModel: string;
|
|
242
242
|
constructor(opts: NewInterestRateModelProps);
|
|
243
|
-
toString(
|
|
243
|
+
toString(): string;
|
|
244
244
|
}
|
|
245
245
|
interface NewCreditManagerConnectedProps extends EVMEventProps {
|
|
246
246
|
pool: string;
|
|
@@ -250,7 +250,7 @@ export declare class EventNewCreditManagerConnected extends EVMEvent {
|
|
|
250
250
|
readonly pool: string;
|
|
251
251
|
readonly creditManager: string;
|
|
252
252
|
constructor(opts: NewCreditManagerConnectedProps);
|
|
253
|
-
toString(
|
|
253
|
+
toString(): string;
|
|
254
254
|
}
|
|
255
255
|
interface BorrowForbiddenProps extends EVMEventProps {
|
|
256
256
|
pool: string;
|
|
@@ -260,7 +260,7 @@ export declare class EventBorrowForbidden extends EVMEvent {
|
|
|
260
260
|
readonly pool: string;
|
|
261
261
|
readonly creditManager: string;
|
|
262
262
|
constructor(opts: BorrowForbiddenProps);
|
|
263
|
-
toString(
|
|
263
|
+
toString(): string;
|
|
264
264
|
}
|
|
265
265
|
interface NewExpectedLiquidityLimitProps extends EVMEventProps {
|
|
266
266
|
pool: 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(): 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(): 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(): 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(): 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(): 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(): 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(): 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(): 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(): string;
|
|
368
368
|
}
|
|
369
369
|
export {};
|
package/lib/core/events.js
CHANGED
|
@@ -95,9 +95,7 @@ var EventParser = /** @class */ (function () {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
EventParser.deserializeArray = function (data) {
|
|
98
|
-
return data.map(function (e) {
|
|
99
|
-
return EventParser.deserialize(e);
|
|
100
|
-
});
|
|
98
|
+
return data.map(function (e) { return EventParser.deserialize(e); });
|
|
101
99
|
};
|
|
102
100
|
return EventParser;
|
|
103
101
|
}());
|
|
@@ -218,7 +216,7 @@ var EventRepayCreditAccount = /** @class */ (function (_super) {
|
|
|
218
216
|
_this.creditManager = opts.creditManager;
|
|
219
217
|
return _this;
|
|
220
218
|
}
|
|
221
|
-
EventRepayCreditAccount.prototype.toString = function (
|
|
219
|
+
EventRepayCreditAccount.prototype.toString = function () {
|
|
222
220
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": was repaid");
|
|
223
221
|
};
|
|
224
222
|
return EventRepayCreditAccount;
|
|
@@ -339,6 +337,8 @@ var EventTokenAllowed = /** @class */ (function (_super) {
|
|
|
339
337
|
return "".concat(msg, ": ").concat(token.symbol, " is allowed now, liquidation threshold: ").concat(this.liquidityThreshold / constants_1.PERCENTAGE_DECIMALS, "%");
|
|
340
338
|
case "LTUpdated":
|
|
341
339
|
return "".concat(msg, ": ").concat(token.symbol, " liquidation threshold: ").concat((this.prevLiquidationThreshold || 0) / constants_1.PERCENTAGE_DECIMALS, " => ").concat(this.liquidityThreshold / constants_1.PERCENTAGE_DECIMALS, "%");
|
|
340
|
+
default:
|
|
341
|
+
return "Error: TokenAllowedProps";
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
344
|
return EventTokenAllowed;
|
|
@@ -377,13 +377,15 @@ var EventContractAllowed = /** @class */ (function (_super) {
|
|
|
377
377
|
_this.status = opts.status;
|
|
378
378
|
return _this;
|
|
379
379
|
}
|
|
380
|
-
EventContractAllowed.prototype.toString = function (
|
|
380
|
+
EventContractAllowed.prototype.toString = function () {
|
|
381
381
|
var msg = "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated");
|
|
382
382
|
switch (this.status) {
|
|
383
383
|
case "Connected":
|
|
384
384
|
return "".concat(msg, " : ").concat((0, contractsRegister_1.getContractName)(this.protocol), " was connected. Adapter at: ").concat(this.adapter);
|
|
385
385
|
case "AdapterUpdate":
|
|
386
386
|
return "".concat(msg, " : ").concat((0, contractsRegister_1.getContractName)(this.protocol), " adapter was updated. New adapter: ").concat(this.adapter);
|
|
387
|
+
default:
|
|
388
|
+
return "Error: EventContractAllowed";
|
|
387
389
|
}
|
|
388
390
|
};
|
|
389
391
|
return EventContractAllowed;
|
|
@@ -401,7 +403,7 @@ var EventContractForbidden = /** @class */ (function (_super) {
|
|
|
401
403
|
_this.protocol = opts.protocol;
|
|
402
404
|
return _this;
|
|
403
405
|
}
|
|
404
|
-
EventContractForbidden.prototype.toString = function (
|
|
406
|
+
EventContractForbidden.prototype.toString = function () {
|
|
405
407
|
return "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated: ").concat((0, contractsRegister_1.getContractName)(this.protocol));
|
|
406
408
|
};
|
|
407
409
|
return EventContractForbidden;
|
|
@@ -422,7 +424,7 @@ var EventNewFastCheckParameters = /** @class */ (function (_super) {
|
|
|
422
424
|
_this.prevFastCheckDelay = opts.prevFastCheckDelay;
|
|
423
425
|
return _this;
|
|
424
426
|
}
|
|
425
|
-
EventNewFastCheckParameters.prototype.toString = function (
|
|
427
|
+
EventNewFastCheckParameters.prototype.toString = function () {
|
|
426
428
|
var msg = "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated: ");
|
|
427
429
|
if (this.chiThreshold !== this.prevChiThreshold) {
|
|
428
430
|
msg += "Chi threshold: ".concat(this.prevChiThreshold, " => ").concat(this.chiThreshold, ", ");
|
|
@@ -447,7 +449,7 @@ var EventPriceOracleUpdated = /** @class */ (function (_super) {
|
|
|
447
449
|
_this.priceOracle = opts.priceOracle;
|
|
448
450
|
return _this;
|
|
449
451
|
}
|
|
450
|
-
EventPriceOracleUpdated.prototype.toString = function (
|
|
452
|
+
EventPriceOracleUpdated.prototype.toString = function () {
|
|
451
453
|
return "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated: price oracle was updated. New price oracle ").concat((0, contractsRegister_1.getContractName)(this.priceOracle));
|
|
452
454
|
};
|
|
453
455
|
return EventPriceOracleUpdated;
|
|
@@ -466,7 +468,7 @@ var EventTransferPluginAllowed = /** @class */ (function (_super) {
|
|
|
466
468
|
_this.state = opts.state;
|
|
467
469
|
return _this;
|
|
468
470
|
}
|
|
469
|
-
EventTransferPluginAllowed.prototype.toString = function (
|
|
471
|
+
EventTransferPluginAllowed.prototype.toString = function () {
|
|
470
472
|
return "Credit manager ".concat((0, contractsRegister_1.getContractName)(this.creditManager), " updated: transfer plugin ").concat((0, contractsRegister_1.getContractName)(this.plugin), " was ").concat(this.state ? "allowed" : "forbidden");
|
|
471
473
|
};
|
|
472
474
|
return EventTransferPluginAllowed;
|
|
@@ -484,7 +486,7 @@ var EventNewInterestRateModel = /** @class */ (function (_super) {
|
|
|
484
486
|
_this.newInterestRateModel = opts.newInterestRateModel;
|
|
485
487
|
return _this;
|
|
486
488
|
}
|
|
487
|
-
EventNewInterestRateModel.prototype.toString = function (
|
|
489
|
+
EventNewInterestRateModel.prototype.toString = function () {
|
|
488
490
|
return "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: interest rate model was updated. New model: ").concat((0, contractsRegister_1.getContractName)(this.newInterestRateModel));
|
|
489
491
|
};
|
|
490
492
|
return EventNewInterestRateModel;
|
|
@@ -502,7 +504,7 @@ var EventNewCreditManagerConnected = /** @class */ (function (_super) {
|
|
|
502
504
|
_this.creditManager = opts.creditManager;
|
|
503
505
|
return _this;
|
|
504
506
|
}
|
|
505
|
-
EventNewCreditManagerConnected.prototype.toString = function (
|
|
507
|
+
EventNewCreditManagerConnected.prototype.toString = function () {
|
|
506
508
|
return "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: new credit manager ").concat((0, contractsRegister_1.getContractName)(this.creditManager), " was connected");
|
|
507
509
|
};
|
|
508
510
|
return EventNewCreditManagerConnected;
|
|
@@ -520,7 +522,7 @@ var EventBorrowForbidden = /** @class */ (function (_super) {
|
|
|
520
522
|
_this.creditManager = opts.creditManager;
|
|
521
523
|
return _this;
|
|
522
524
|
}
|
|
523
|
-
EventBorrowForbidden.prototype.toString = function (
|
|
525
|
+
EventBorrowForbidden.prototype.toString = function () {
|
|
524
526
|
return "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: credit manager ").concat((0, contractsRegister_1.getContractName)(this.creditManager), " was forbidden to borrow");
|
|
525
527
|
};
|
|
526
528
|
return EventBorrowForbidden;
|
|
@@ -563,7 +565,7 @@ var EventNewWithdrawFee = /** @class */ (function (_super) {
|
|
|
563
565
|
_this.prevFee = Number(opts.oldFee);
|
|
564
566
|
return _this;
|
|
565
567
|
}
|
|
566
|
-
EventNewWithdrawFee.prototype.toString = function (
|
|
568
|
+
EventNewWithdrawFee.prototype.toString = function () {
|
|
567
569
|
return this.prevFee === 0
|
|
568
570
|
? "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: withdraw fee was set to: ").concat(this.newFee / constants_1.PERCENTAGE_DECIMALS, "%")
|
|
569
571
|
: "Pool ".concat((0, contractsRegister_1.getContractName)(this.pool), " updated: withdraw fee was ").concat(this.newFee > this.prevFee ? "increased" : "decreased", ": ").concat(this.prevFee / constants_1.PERCENTAGE_DECIMALS, "% => ").concat(this.newFee / constants_1.PERCENTAGE_DECIMALS, "%");
|
|
@@ -602,7 +604,7 @@ var EventTakeForever = /** @class */ (function (_super) {
|
|
|
602
604
|
_this.to = opts.to;
|
|
603
605
|
return _this;
|
|
604
606
|
}
|
|
605
|
-
EventTakeForever.prototype.toString = function (
|
|
607
|
+
EventTakeForever.prototype.toString = function () {
|
|
606
608
|
return "AccountFactory: account ".concat(this.creditAccount, " was taken forever and transferred to ").concat(this.to);
|
|
607
609
|
};
|
|
608
610
|
return EventTakeForever;
|
|
@@ -619,7 +621,7 @@ var EventPaused = /** @class */ (function (_super) {
|
|
|
619
621
|
_this.contract = opts.contract;
|
|
620
622
|
return _this;
|
|
621
623
|
}
|
|
622
|
-
EventPaused.prototype.toString = function (
|
|
624
|
+
EventPaused.prototype.toString = function () {
|
|
623
625
|
return "".concat((0, contractsRegister_1.getContractName)(this.contract), " was paused");
|
|
624
626
|
};
|
|
625
627
|
return EventPaused;
|
|
@@ -636,7 +638,7 @@ var EventUnPaused = /** @class */ (function (_super) {
|
|
|
636
638
|
_this.contract = opts.contract;
|
|
637
639
|
return _this;
|
|
638
640
|
}
|
|
639
|
-
EventUnPaused.prototype.toString = function (
|
|
641
|
+
EventUnPaused.prototype.toString = function () {
|
|
640
642
|
return "".concat((0, contractsRegister_1.getContractName)(this.contract), " was unpaused");
|
|
641
643
|
};
|
|
642
644
|
return EventUnPaused;
|
|
@@ -653,7 +655,7 @@ var EventPausableAdminAdded = /** @class */ (function (_super) {
|
|
|
653
655
|
_this.admin = opts.admin;
|
|
654
656
|
return _this;
|
|
655
657
|
}
|
|
656
|
-
EventPausableAdminAdded.prototype.toString = function (
|
|
658
|
+
EventPausableAdminAdded.prototype.toString = function () {
|
|
657
659
|
return "ACL: pausable admin ".concat(this.admin, " was added");
|
|
658
660
|
};
|
|
659
661
|
return EventPausableAdminAdded;
|
|
@@ -670,7 +672,7 @@ var EventPausableAdminRemoved = /** @class */ (function (_super) {
|
|
|
670
672
|
_this.admin = opts.admin;
|
|
671
673
|
return _this;
|
|
672
674
|
}
|
|
673
|
-
EventPausableAdminRemoved.prototype.toString = function (
|
|
675
|
+
EventPausableAdminRemoved.prototype.toString = function () {
|
|
674
676
|
return "ACL: pausable admin ".concat(this.admin, " was removed");
|
|
675
677
|
};
|
|
676
678
|
return EventPausableAdminRemoved;
|
|
@@ -687,7 +689,7 @@ var EventUnPausableAdminAdded = /** @class */ (function (_super) {
|
|
|
687
689
|
_this.admin = opts.admin;
|
|
688
690
|
return _this;
|
|
689
691
|
}
|
|
690
|
-
EventUnPausableAdminAdded.prototype.toString = function (
|
|
692
|
+
EventUnPausableAdminAdded.prototype.toString = function () {
|
|
691
693
|
return "ACL: unpausable admin ".concat(this.admin, " was added");
|
|
692
694
|
};
|
|
693
695
|
return EventUnPausableAdminAdded;
|
|
@@ -704,7 +706,7 @@ var EventUnPausableAdminRemoved = /** @class */ (function (_super) {
|
|
|
704
706
|
_this.admin = opts.admin;
|
|
705
707
|
return _this;
|
|
706
708
|
}
|
|
707
|
-
EventUnPausableAdminRemoved.prototype.toString = function (
|
|
709
|
+
EventUnPausableAdminRemoved.prototype.toString = function () {
|
|
708
710
|
return "ACL: unpausable admin ".concat(this.admin, " was removed");
|
|
709
711
|
};
|
|
710
712
|
return EventUnPausableAdminRemoved;
|
|
@@ -722,7 +724,7 @@ var EventTransferOwnership = /** @class */ (function (_super) {
|
|
|
722
724
|
_this.newOwner = opts.admin;
|
|
723
725
|
return _this;
|
|
724
726
|
}
|
|
725
|
-
EventTransferOwnership.prototype.toString = function (
|
|
727
|
+
EventTransferOwnership.prototype.toString = function () {
|
|
726
728
|
return "ACL: configurator was changed to ".concat(this.newOwner);
|
|
727
729
|
};
|
|
728
730
|
return EventTransferOwnership;
|
package/lib/core/pool.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ export declare class PoolData {
|
|
|
19
19
|
readonly withdrawFee: number;
|
|
20
20
|
readonly timestampLU: BigNumber;
|
|
21
21
|
readonly cumulativeIndex_RAY: BigNumber;
|
|
22
|
+
readonly isPaused: boolean;
|
|
22
23
|
constructor(payload: PoolDataPayload);
|
|
23
24
|
getContractETH(signer: Signer): IPoolService;
|
|
24
|
-
get isPaused(): boolean;
|
|
25
25
|
}
|
|
26
26
|
export interface PoolsStat {
|
|
27
27
|
tvl: number;
|
package/lib/core/pool.js
CHANGED
|
@@ -7,6 +7,7 @@ var types_1 = require("../types");
|
|
|
7
7
|
var constants_1 = require("./constants");
|
|
8
8
|
var PoolData = /** @class */ (function () {
|
|
9
9
|
function PoolData(payload) {
|
|
10
|
+
this.isPaused = false;
|
|
10
11
|
this.id = payload.addr;
|
|
11
12
|
this.address = payload.addr;
|
|
12
13
|
this.underlyingToken = payload.underlying || "";
|
|
@@ -29,13 +30,6 @@ var PoolData = /** @class */ (function () {
|
|
|
29
30
|
PoolData.prototype.getContractETH = function (signer) {
|
|
30
31
|
return types_1.IPoolService__factory.connect(this.address, signer);
|
|
31
32
|
};
|
|
32
|
-
Object.defineProperty(PoolData.prototype, "isPaused", {
|
|
33
|
-
get: function () {
|
|
34
|
-
return false;
|
|
35
|
-
},
|
|
36
|
-
enumerable: false,
|
|
37
|
-
configurable: true
|
|
38
|
-
});
|
|
39
33
|
return PoolData;
|
|
40
34
|
}());
|
|
41
35
|
exports.PoolData = PoolData;
|
package/lib/core/price.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { BigNumber } from "ethers";
|
|
2
|
-
|
|
3
|
-
export declare const PRICE_DECIMALS = 1000;
|
|
4
|
-
export declare const priceCalc: (price: number, amount: BigNumber, token: TokenData | undefined) => BigNumber;
|
|
2
|
+
export declare const calcTotalPrice: (price: BigNumber, amount: BigNumber, decimals?: number) => BigNumber;
|
package/lib/core/price.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.calcTotalPrice = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
5
|
+
var constants_1 = require("./constants");
|
|
6
|
+
var calcTotalPrice = function (price, amount, decimals) {
|
|
7
|
+
if (decimals === void 0) { decimals = 18; }
|
|
8
8
|
return amount
|
|
9
|
-
.mul(
|
|
10
|
-
.
|
|
9
|
+
.mul(constants_1.WAD)
|
|
10
|
+
.mul(price)
|
|
11
|
+
.div(ethers_1.BigNumber.from(10).pow(decimals))
|
|
12
|
+
.div(constants_1.PRICE_DECIMALS);
|
|
11
13
|
};
|
|
12
|
-
exports.
|
|
14
|
+
exports.calcTotalPrice = calcTotalPrice;
|
package/lib/core/strategy.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
1
2
|
export interface StrategyPayload {
|
|
2
3
|
apy?: number;
|
|
3
4
|
name: string;
|
|
@@ -11,6 +12,11 @@ interface PoolStats {
|
|
|
11
12
|
borrowRate: number;
|
|
12
13
|
}
|
|
13
14
|
declare type PoolList = Record<string, PoolStats>;
|
|
15
|
+
interface TokenDescription {
|
|
16
|
+
price: BigNumber;
|
|
17
|
+
amount: BigNumber;
|
|
18
|
+
decimals: number | undefined;
|
|
19
|
+
}
|
|
14
20
|
export declare class Strategy {
|
|
15
21
|
apy: number | undefined;
|
|
16
22
|
name: string;
|
|
@@ -20,13 +26,9 @@ export declare class Strategy {
|
|
|
20
26
|
leveragableCollateral: Array<string>;
|
|
21
27
|
baseAssets: Array<string>;
|
|
22
28
|
constructor(payload: StrategyPayload);
|
|
23
|
-
|
|
29
|
+
maxAPY(maxLeverage: number, poolApy: PoolList): number;
|
|
24
30
|
overallAPY(apy: number, leverage: number, depositCollateral: string, borrowAPY: number): number;
|
|
25
|
-
liquidationPrice(
|
|
26
|
-
ltStrategyLP(maxLeverage: number): number;
|
|
27
|
-
maxLeverage(ltStrategyLP: number): number;
|
|
28
|
-
private roi;
|
|
29
|
-
private minBorrowApy;
|
|
31
|
+
liquidationPrice(borrowed: TokenDescription, collateral: TokenDescription, lp: TokenDescription, ltCollateral: BigNumber): BigNumber;
|
|
30
32
|
private farmLev;
|
|
31
33
|
private inBaseAssets;
|
|
32
34
|
private inLeveragableAssets;
|
package/lib/core/strategy.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Strategy = void 0;
|
|
4
|
-
var
|
|
4
|
+
var ethers_1 = require("ethers");
|
|
5
|
+
var constants_1 = require("./constants");
|
|
6
|
+
var price_1 = require("./price");
|
|
5
7
|
var Strategy = /** @class */ (function () {
|
|
6
8
|
function Strategy(payload) {
|
|
7
9
|
this.apy = payload.apy;
|
|
@@ -12,33 +14,24 @@ var Strategy = /** @class */ (function () {
|
|
|
12
14
|
this.leveragableCollateral = payload.leveragableCollateral;
|
|
13
15
|
this.baseAssets = payload.baseAssets;
|
|
14
16
|
}
|
|
15
|
-
Strategy.prototype.
|
|
16
|
-
var minApy =
|
|
17
|
-
return this.
|
|
17
|
+
Strategy.prototype.maxAPY = function (maxLeverage, poolApy) {
|
|
18
|
+
var minApy = minBorrowApy(poolApy);
|
|
19
|
+
return roi(this.apy || 0, maxLeverage, maxLeverage - constants_1.LEVERAGE_DECIMALS, minApy);
|
|
18
20
|
};
|
|
19
21
|
Strategy.prototype.overallAPY = function (apy, leverage, depositCollateral, borrowAPY) {
|
|
20
22
|
var farmLev = this.farmLev(leverage, depositCollateral);
|
|
21
|
-
return
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var leverage = Math.floor(1 / (1 - ltStrategyLP));
|
|
34
|
-
return Math.floor(leverage * constants_1.LEVERAGE_DECIMALS);
|
|
35
|
-
};
|
|
36
|
-
Strategy.prototype.roi = function (apy, farmLev, debtLev, borrowAPY) {
|
|
37
|
-
return (apy * farmLev - borrowAPY * debtLev) / constants_1.LEVERAGE_DECIMALS;
|
|
38
|
-
};
|
|
39
|
-
Strategy.prototype.minBorrowApy = function (poolApy) {
|
|
40
|
-
var apys = Object.values(poolApy).sort(function (a, b) { return a.borrowRate - b.borrowRate; });
|
|
41
|
-
return apys.length > 0 ? apys[0].borrowRate : 0;
|
|
23
|
+
return roi(apy, farmLev, leverage - constants_1.LEVERAGE_DECIMALS, borrowAPY);
|
|
24
|
+
};
|
|
25
|
+
// eslint-disable-next-line class-methods-use-this
|
|
26
|
+
Strategy.prototype.liquidationPrice = function (borrowed, collateral, lp, ltCollateral) {
|
|
27
|
+
var borrowedMoney = (0, price_1.calcTotalPrice)(borrowed.price, borrowed.amount, borrowed.decimals);
|
|
28
|
+
var collateralMoney = (0, price_1.calcTotalPrice)(collateral.price, collateral.amount, collateral.decimals)
|
|
29
|
+
.mul(ltCollateral)
|
|
30
|
+
.div(constants_1.PERCENTAGE_FACTOR);
|
|
31
|
+
var lpMoney = (0, price_1.calcTotalPrice)(lp.price, lp.amount, lp.decimals);
|
|
32
|
+
return lpMoney.gt(0)
|
|
33
|
+
? borrowedMoney.sub(collateralMoney).mul(constants_1.WAD).div(lpMoney)
|
|
34
|
+
: ethers_1.BigNumber.from(0);
|
|
42
35
|
};
|
|
43
36
|
Strategy.prototype.farmLev = function (leverage, depositCollateral) {
|
|
44
37
|
return this.inBaseAssets(depositCollateral) ||
|
|
@@ -55,3 +48,10 @@ var Strategy = /** @class */ (function () {
|
|
|
55
48
|
return Strategy;
|
|
56
49
|
}());
|
|
57
50
|
exports.Strategy = Strategy;
|
|
51
|
+
function roi(apy, farmLev, debtLev, borrowAPY) {
|
|
52
|
+
return (apy * farmLev - borrowAPY * debtLev) / constants_1.LEVERAGE_DECIMALS;
|
|
53
|
+
}
|
|
54
|
+
function minBorrowApy(poolApy) {
|
|
55
|
+
var apys = Object.values(poolApy).sort(function (a, b) { return a.borrowRate - b.borrowRate; });
|
|
56
|
+
return apys.length > 0 ? apys[0].borrowRate : 0;
|
|
57
|
+
}
|
|
@@ -5,5 +5,5 @@ var VotingPower;
|
|
|
5
5
|
(function (VotingPower) {
|
|
6
6
|
VotingPower[VotingPower["A"] = 0] = "A";
|
|
7
7
|
VotingPower[VotingPower["B"] = 1] = "B";
|
|
8
|
-
VotingPower[VotingPower["ZERO_VOTING_POWER"] = 2] = "ZERO_VOTING_POWER";
|
|
8
|
+
VotingPower[VotingPower["ZERO_VOTING_POWER"] = 2] = "ZERO_VOTING_POWER"; // zero voting power & B-type vesting parameters
|
|
9
9
|
})(VotingPower = exports.VotingPower || (exports.VotingPower = {}));
|
|
@@ -2,7 +2,7 @@ import { BigNumber } from "ethers";
|
|
|
2
2
|
import { TokenData } from "../tokens/tokenData";
|
|
3
3
|
import { EVMTx, EVMTxProps } from "./eventOrTx";
|
|
4
4
|
export interface TxSerialized {
|
|
5
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove";
|
|
5
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxOpenAccount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount";
|
|
6
6
|
content: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class TxSerializer {
|
|
@@ -97,13 +97,28 @@ export declare class TxOpenAccount extends EVMTx {
|
|
|
97
97
|
toString(tokenData: Record<string, TokenData>): string;
|
|
98
98
|
serialize(): TxSerialized;
|
|
99
99
|
}
|
|
100
|
+
interface TxOpenMultitokenAccountProps extends EVMTxProps {
|
|
101
|
+
borrowedAmount: BigNumber;
|
|
102
|
+
creditManager: string;
|
|
103
|
+
underlyingToken: string;
|
|
104
|
+
assets: Array<string>;
|
|
105
|
+
}
|
|
106
|
+
export declare class TxOpenMultitokenAccount extends EVMTx {
|
|
107
|
+
readonly borrowedAmount: BigNumber;
|
|
108
|
+
readonly creditManager: string;
|
|
109
|
+
readonly underlyingToken: string;
|
|
110
|
+
readonly assets: Array<string>;
|
|
111
|
+
constructor(opts: TxOpenMultitokenAccountProps);
|
|
112
|
+
toString(tokenData: Record<string, TokenData>): string;
|
|
113
|
+
serialize(): TxSerialized;
|
|
114
|
+
}
|
|
100
115
|
interface RepayAccountProps extends EVMTxProps {
|
|
101
116
|
creditManager: string;
|
|
102
117
|
}
|
|
103
118
|
export declare class TxRepayAccount extends EVMTx {
|
|
104
119
|
readonly creditManager: string;
|
|
105
120
|
constructor(opts: RepayAccountProps);
|
|
106
|
-
toString(
|
|
121
|
+
toString(): string;
|
|
107
122
|
serialize(): TxSerialized;
|
|
108
123
|
}
|
|
109
124
|
interface CloseAccountProps extends EVMTxProps {
|
|
@@ -112,7 +127,7 @@ interface CloseAccountProps extends EVMTxProps {
|
|
|
112
127
|
export declare class TxCloseAccount extends EVMTx {
|
|
113
128
|
readonly creditManager: string;
|
|
114
129
|
constructor(opts: CloseAccountProps);
|
|
115
|
-
toString(
|
|
130
|
+
toString(): string;
|
|
116
131
|
serialize(): TxSerialized;
|
|
117
132
|
}
|
|
118
133
|
interface ApproveProps extends EVMTxProps {
|
package/lib/core/transactions.js
CHANGED
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxOpenAccount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
18
|
+
exports.TxApprove = exports.TxCloseAccount = exports.TxRepayAccount = exports.TxOpenMultitokenAccount = exports.TxOpenAccount = exports.TxIncreaseBorrowAmount = exports.TxAddCollateral = exports.TXSwap = exports.TxRemoveLiquidity = exports.TxAddLiquidity = exports.TxSerializer = void 0;
|
|
19
19
|
var ethers_1 = require("ethers");
|
|
20
20
|
var formatter_1 = require("../utils/formatter");
|
|
21
21
|
var eventOrTx_1 = require("./eventOrTx");
|
|
@@ -49,6 +49,8 @@ var TxSerializer = /** @class */ (function () {
|
|
|
49
49
|
return new TxCloseAccount(params);
|
|
50
50
|
case "TxApprove":
|
|
51
51
|
return new TxApprove(params);
|
|
52
|
+
case "TxOpenMultitokenAccount":
|
|
53
|
+
return new TxOpenMultitokenAccount(params);
|
|
52
54
|
default:
|
|
53
55
|
throw new Error("Unknown transaction for parsing");
|
|
54
56
|
}
|
|
@@ -231,6 +233,40 @@ var TxOpenAccount = /** @class */ (function (_super) {
|
|
|
231
233
|
return TxOpenAccount;
|
|
232
234
|
}(eventOrTx_1.EVMTx));
|
|
233
235
|
exports.TxOpenAccount = TxOpenAccount;
|
|
236
|
+
var TxOpenMultitokenAccount = /** @class */ (function (_super) {
|
|
237
|
+
__extends(TxOpenMultitokenAccount, _super);
|
|
238
|
+
function TxOpenMultitokenAccount(opts) {
|
|
239
|
+
var _this = _super.call(this, {
|
|
240
|
+
block: opts.block,
|
|
241
|
+
txHash: opts.txHash,
|
|
242
|
+
txStatus: opts.txStatus,
|
|
243
|
+
timestamp: opts.timestamp
|
|
244
|
+
}) || this;
|
|
245
|
+
_this.borrowedAmount = ethers_1.BigNumber.from(opts.borrowedAmount);
|
|
246
|
+
_this.underlyingToken = opts.underlyingToken;
|
|
247
|
+
_this.creditManager = opts.creditManager;
|
|
248
|
+
_this.assets = opts.assets;
|
|
249
|
+
return _this;
|
|
250
|
+
}
|
|
251
|
+
TxOpenMultitokenAccount.prototype.toString = function (tokenData) {
|
|
252
|
+
var underlyingToken = tokenData[this.underlyingToken.toLowerCase()];
|
|
253
|
+
var assetSymbols = this.assets.reduce(function (acc, assetAddress) {
|
|
254
|
+
var token = tokenData[assetAddress.toLowerCase()];
|
|
255
|
+
if (token)
|
|
256
|
+
acc.push(token.symbol);
|
|
257
|
+
return acc;
|
|
258
|
+
}, []);
|
|
259
|
+
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": opening. Borrowed amount: ").concat((0, formatter_1.formatBN)(this.borrowedAmount, (underlyingToken === null || underlyingToken === void 0 ? void 0 : underlyingToken.decimals) || 18), " ").concat(underlyingToken === null || underlyingToken === void 0 ? void 0 : underlyingToken.symbol, "; assets: ").concat(assetSymbols.join(", "));
|
|
260
|
+
};
|
|
261
|
+
TxOpenMultitokenAccount.prototype.serialize = function () {
|
|
262
|
+
return {
|
|
263
|
+
type: "TxOpenMultitokenAccount",
|
|
264
|
+
content: JSON.stringify(this)
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
return TxOpenMultitokenAccount;
|
|
268
|
+
}(eventOrTx_1.EVMTx));
|
|
269
|
+
exports.TxOpenMultitokenAccount = TxOpenMultitokenAccount;
|
|
234
270
|
var TxRepayAccount = /** @class */ (function (_super) {
|
|
235
271
|
__extends(TxRepayAccount, _super);
|
|
236
272
|
function TxRepayAccount(opts) {
|
|
@@ -243,7 +279,7 @@ var TxRepayAccount = /** @class */ (function (_super) {
|
|
|
243
279
|
_this.creditManager = opts.creditManager;
|
|
244
280
|
return _this;
|
|
245
281
|
}
|
|
246
|
-
TxRepayAccount.prototype.toString = function (
|
|
282
|
+
TxRepayAccount.prototype.toString = function () {
|
|
247
283
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Repaying account");
|
|
248
284
|
};
|
|
249
285
|
TxRepayAccount.prototype.serialize = function () {
|
|
@@ -267,7 +303,7 @@ var TxCloseAccount = /** @class */ (function (_super) {
|
|
|
267
303
|
_this.creditManager = opts.creditManager;
|
|
268
304
|
return _this;
|
|
269
305
|
}
|
|
270
|
-
TxCloseAccount.prototype.toString = function (
|
|
306
|
+
TxCloseAccount.prototype.toString = function () {
|
|
271
307
|
return "Credit account ".concat((0, contractsRegister_1.getContractName)(this.creditManager), ": Closing account");
|
|
272
308
|
};
|
|
273
309
|
TxCloseAccount.prototype.serialize = function () {
|