@gearbox-protocol/sdk 1.20.3 → 1.20.4
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/creditManager.d.ts +12 -3
- package/lib/core/creditManager.js +46 -9
- package/lib/core/pool.d.ts +12 -4
- package/lib/core/pool.js +59 -1
- package/lib/payload/creditManager.d.ts +34 -14
- package/lib/payload/pool.d.ts +44 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber, ethers, Signer } from "ethers";
|
|
2
2
|
import { MultiCall } from "../pathfinder/core";
|
|
3
|
-
import {
|
|
3
|
+
import { ChartsCreditManagerPayload, CreditManagerDataPayload } from "../payload/creditManager";
|
|
4
4
|
import { ICreditManager } from "../types";
|
|
5
5
|
import { Asset } from "./assets";
|
|
6
6
|
export declare class CreditManagerData {
|
|
@@ -42,7 +42,7 @@ export declare class CreditManagerData {
|
|
|
42
42
|
protected validateOpenAccountV2(debt: BigNumber): true;
|
|
43
43
|
get id(): string;
|
|
44
44
|
}
|
|
45
|
-
export declare class
|
|
45
|
+
export declare class ChartsCreditManagerData extends CreditManagerData {
|
|
46
46
|
readonly uniqueUsers: number;
|
|
47
47
|
readonly openedAccountsCount: number;
|
|
48
48
|
readonly totalOpenedAccounts: number;
|
|
@@ -54,7 +54,16 @@ export declare class CreditManagerStat extends CreditManagerData {
|
|
|
54
54
|
readonly totalRepaid: BigNumber;
|
|
55
55
|
readonly totalProfit: BigNumber;
|
|
56
56
|
readonly totalLosses: BigNumber;
|
|
57
|
-
|
|
57
|
+
readonly totalBorrowedInUSD: number;
|
|
58
|
+
readonly totalLossesInUSD: number;
|
|
59
|
+
readonly totalProfitInUSD: number;
|
|
60
|
+
readonly totalRepaidInUSD: number;
|
|
61
|
+
readonly availableLiquidityInUSD: number;
|
|
62
|
+
readonly openedAccountsCountChange: number;
|
|
63
|
+
readonly totalOpenedAccountsChange: number;
|
|
64
|
+
readonly totalClosedAccountsChange: number;
|
|
65
|
+
readonly totalLiquidatedAccountsChange: number;
|
|
66
|
+
constructor(payload: ChartsCreditManagerPayload);
|
|
58
67
|
}
|
|
59
68
|
export interface CalcHealthFactorProps {
|
|
60
69
|
assets: Array<Asset>;
|
|
@@ -26,7 +26,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.calcHealthFactor = exports.
|
|
29
|
+
exports.calcHealthFactor = exports.ChartsCreditManagerData = exports.CreditManagerData = void 0;
|
|
30
30
|
var ethers_1 = require("ethers");
|
|
31
31
|
var txParser_1 = require("../parsers/txParser");
|
|
32
32
|
var decimals_1 = require("../tokens/decimals");
|
|
@@ -154,26 +154,63 @@ var CreditManagerData = /** @class */ (function () {
|
|
|
154
154
|
return CreditManagerData;
|
|
155
155
|
}());
|
|
156
156
|
exports.CreditManagerData = CreditManagerData;
|
|
157
|
-
var
|
|
158
|
-
__extends(
|
|
159
|
-
function
|
|
160
|
-
var _this = _super.call(this,
|
|
161
|
-
|
|
157
|
+
var ChartsCreditManagerData = /** @class */ (function (_super) {
|
|
158
|
+
__extends(ChartsCreditManagerData, _super);
|
|
159
|
+
function ChartsCreditManagerData(payload) {
|
|
160
|
+
var _this = _super.call(this, {
|
|
161
|
+
canBorrow: true,
|
|
162
|
+
adapters: [],
|
|
163
|
+
liquidationThresholds: [],
|
|
164
|
+
collateralTokens: [],
|
|
165
|
+
creditFacade: "",
|
|
166
|
+
creditConfigurator: "",
|
|
167
|
+
isDegenMode: false,
|
|
168
|
+
degenNFT: "",
|
|
169
|
+
isIncreaseDebtForbidden: false,
|
|
170
|
+
forbiddenTokenMask: ethers_1.BigNumber.from(0),
|
|
171
|
+
maxEnabledTokensLength: 12,
|
|
172
|
+
feeInterest: payload.feeInterest,
|
|
173
|
+
feeLiquidation: payload.feeLiquidation,
|
|
174
|
+
liquidationDiscount: 0,
|
|
175
|
+
feeLiquidationExpired: payload.feeLiquidationExpired,
|
|
176
|
+
liquidationDiscountExpired: 0,
|
|
177
|
+
pool: payload.poolAddress,
|
|
178
|
+
version: payload.version,
|
|
179
|
+
addr: payload.addr,
|
|
180
|
+
isWETH: payload.isWeth,
|
|
181
|
+
availableLiquidity: ethers_1.BigNumber.from(payload.availableLiquidity || 0),
|
|
182
|
+
borrowRate: ethers_1.BigNumber.from(payload.borrowRate || 0),
|
|
183
|
+
maxAmount: ethers_1.BigNumber.from(payload.maxAmount || 0),
|
|
184
|
+
minAmount: ethers_1.BigNumber.from(payload.minAmount || 0),
|
|
185
|
+
maxLeverageFactor: ethers_1.BigNumber.from(payload.maxLeverageFactor || 0),
|
|
186
|
+
underlying: payload.underlyingToken,
|
|
187
|
+
}) || this;
|
|
188
|
+
_this.uniqueUsers = 0;
|
|
162
189
|
_this.openedAccountsCount = payload.openedAccountsCount || 0;
|
|
163
190
|
_this.totalOpenedAccounts = payload.totalOpenedAccounts || 0;
|
|
164
191
|
_this.totalClosedAccounts = payload.totalClosedAccounts || 0;
|
|
165
192
|
_this.totalRepaidAccounts = payload.totalRepaidAccounts || 0;
|
|
166
193
|
_this.totalLiquidatedAccounts = payload.totalLiquidatedAccounts || 0;
|
|
167
194
|
_this.totalBorrowed = ethers_1.BigNumber.from(payload.totalBorrowed || 0);
|
|
168
|
-
_this.cumulativeBorrowed = ethers_1.BigNumber.from(
|
|
195
|
+
_this.cumulativeBorrowed = ethers_1.BigNumber.from(0);
|
|
169
196
|
_this.totalRepaid = ethers_1.BigNumber.from(payload.totalRepaid || 0);
|
|
170
197
|
_this.totalProfit = ethers_1.BigNumber.from(payload.totalProfit || 0);
|
|
171
198
|
_this.totalLosses = ethers_1.BigNumber.from(payload.totalLosses || 0);
|
|
199
|
+
_this.totalBorrowedInUSD = payload.totalBorrowedInUSD || 0;
|
|
200
|
+
_this.totalLossesInUSD = payload.totalLossesInUSD || 0;
|
|
201
|
+
_this.totalProfitInUSD = payload.totalProfitInUSD || 0;
|
|
202
|
+
_this.totalRepaidInUSD = payload.totalRepaidInUSD || 0;
|
|
203
|
+
_this.availableLiquidityInUSD = payload.availableLiquidityInUSD || 0;
|
|
204
|
+
_this.openedAccountsCountChange = payload.openedAccountsCountChange || 0;
|
|
205
|
+
_this.totalOpenedAccountsChange = payload.totalOpenedAccountsChange || 0;
|
|
206
|
+
_this.totalClosedAccountsChange = payload.totalClosedAccountsChange || 0;
|
|
207
|
+
_this.totalLiquidatedAccountsChange =
|
|
208
|
+
payload.totalLiquidatedAccountsChange || 0;
|
|
172
209
|
return _this;
|
|
173
210
|
}
|
|
174
|
-
return
|
|
211
|
+
return ChartsCreditManagerData;
|
|
175
212
|
}(CreditManagerData));
|
|
176
|
-
exports.
|
|
213
|
+
exports.ChartsCreditManagerData = ChartsCreditManagerData;
|
|
177
214
|
function calcHealthFactor(_a) {
|
|
178
215
|
var assets = _a.assets, prices = _a.prices, liquidationThresholds = _a.liquidationThresholds, underlyingToken = _a.underlyingToken, borrowed = _a.borrowed;
|
|
179
216
|
var assetLTMoney = assets.reduce(function (acc, _a) {
|
package/lib/core/pool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber, Signer } from "ethers";
|
|
2
|
-
import { PoolDataPayload } from "../payload/pool";
|
|
2
|
+
import { ChartsPoolDataPayload, PoolDataPayload } from "../payload/pool";
|
|
3
3
|
import { IPoolService } from "../types";
|
|
4
4
|
export declare class PoolData {
|
|
5
5
|
readonly id: string;
|
|
@@ -23,7 +23,15 @@ export declare class PoolData {
|
|
|
23
23
|
constructor(payload: PoolDataPayload);
|
|
24
24
|
getContractETH(signer: Signer): IPoolService;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export declare class ChartsPoolData extends PoolData {
|
|
27
|
+
readonly expectedLiquidityInUSD: number;
|
|
28
|
+
readonly expectedLiquidityLimitInUSD: number;
|
|
29
|
+
readonly availableLiquidityInUSD: number;
|
|
30
|
+
readonly caLockedValueInUSD: number;
|
|
31
|
+
readonly totalBorrowedInUSD: number;
|
|
32
|
+
readonly uniqueLPs: number;
|
|
33
|
+
readonly depositAPY7D: number;
|
|
34
|
+
readonly depositAPY30D: number;
|
|
35
|
+
readonly lmAPY: number;
|
|
36
|
+
constructor({ expectedLiquidityInUSD, expectedLiquidityLimitInUSD, availableLiquidityInUSD, totalBorrowedInUSD, caLockedValueInUSD, uniqueLPs, dieselAPY7D, dieselAPY30D, lmAPY, ...restPayload }: ChartsPoolDataPayload);
|
|
29
37
|
}
|
package/lib/core/pool.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
29
|
+
var t = {};
|
|
30
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
31
|
+
t[p] = s[p];
|
|
32
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
33
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
34
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
35
|
+
t[p[i]] = s[p[i]];
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
};
|
|
2
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PoolData = void 0;
|
|
40
|
+
exports.ChartsPoolData = exports.PoolData = void 0;
|
|
4
41
|
var ethers_1 = require("ethers");
|
|
5
42
|
var types_1 = require("../types");
|
|
6
43
|
var formatter_1 = require("../utils/formatter");
|
|
@@ -33,3 +70,24 @@ var PoolData = /** @class */ (function () {
|
|
|
33
70
|
return PoolData;
|
|
34
71
|
}());
|
|
35
72
|
exports.PoolData = PoolData;
|
|
73
|
+
var ChartsPoolData = /** @class */ (function (_super) {
|
|
74
|
+
__extends(ChartsPoolData, _super);
|
|
75
|
+
function ChartsPoolData(_a) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var expectedLiquidityInUSD = _a.expectedLiquidityInUSD, expectedLiquidityLimitInUSD = _a.expectedLiquidityLimitInUSD, availableLiquidityInUSD = _a.availableLiquidityInUSD, totalBorrowedInUSD = _a.totalBorrowedInUSD, caLockedValueInUSD = _a.caLockedValueInUSD, uniqueLPs = _a.uniqueLPs, _b = _a.dieselAPY7D, dieselAPY7D = _b === void 0 ? 0 : _b, _c = _a.dieselAPY30D, dieselAPY30D = _c === void 0 ? 0 : _c, lmAPY = _a.lmAPY, restPayload = __rest(_a, ["expectedLiquidityInUSD", "expectedLiquidityLimitInUSD", "availableLiquidityInUSD", "totalBorrowedInUSD", "caLockedValueInUSD", "uniqueLPs", "dieselAPY7D", "dieselAPY30D", "lmAPY"]);
|
|
78
|
+
var _d = restPayload.underlying, underlying = _d === void 0 ? restPayload.underlyingToken : _d, _e = restPayload.linearCumulativeIndex, linearCumulativeIndex = _e === void 0 ? 0 : _e, _f = restPayload.cumulativeIndex_RAY, cumulativeIndexRAY = _f === void 0 ? 0 : _f, _g = restPayload.timestampLU, timestampLU = _g === void 0 ? 0 : _g, _h = restPayload.version, version = _h === void 0 ? 1 : _h, v1Props = __rest(restPayload, ["underlying", "linearCumulativeIndex", "cumulativeIndex_RAY", "timestampLU", "version"]);
|
|
79
|
+
_this = _super.call(this, __assign(__assign({}, v1Props), { underlying: underlying, linearCumulativeIndex: linearCumulativeIndex, cumulativeIndex_RAY: cumulativeIndexRAY, timestampLU: timestampLU, version: version })) || this;
|
|
80
|
+
_this.expectedLiquidityInUSD = expectedLiquidityInUSD;
|
|
81
|
+
_this.expectedLiquidityLimitInUSD = expectedLiquidityLimitInUSD;
|
|
82
|
+
_this.availableLiquidityInUSD = availableLiquidityInUSD;
|
|
83
|
+
_this.totalBorrowedInUSD = totalBorrowedInUSD;
|
|
84
|
+
_this.uniqueLPs = uniqueLPs;
|
|
85
|
+
_this.depositAPY7D = dieselAPY7D / constants_1.PERCENTAGE_DECIMALS;
|
|
86
|
+
_this.depositAPY30D = dieselAPY30D / constants_1.PERCENTAGE_DECIMALS;
|
|
87
|
+
_this.caLockedValueInUSD = caLockedValueInUSD;
|
|
88
|
+
_this.lmAPY = lmAPY / constants_1.PERCENTAGE_FACTOR;
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
return ChartsPoolData;
|
|
92
|
+
}(PoolData));
|
|
93
|
+
exports.ChartsPoolData = ChartsPoolData;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumberish } from "ethers";
|
|
2
1
|
import { CreditManagerDataStructOutput } from "../types/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor";
|
|
3
2
|
import { ExcludeArrayProps } from "../utils/types";
|
|
4
3
|
export interface AdapterPayload {
|
|
@@ -6,17 +5,38 @@ export interface AdapterPayload {
|
|
|
6
5
|
adapter: string;
|
|
7
6
|
}
|
|
8
7
|
export declare type CreditManagerDataPayload = ExcludeArrayProps<CreditManagerDataStructOutput>;
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
totalLosses
|
|
8
|
+
export interface ChartsCreditManagerPayload {
|
|
9
|
+
addr: string;
|
|
10
|
+
availableLiquidity: string;
|
|
11
|
+
borrowRate: string;
|
|
12
|
+
isWeth: boolean;
|
|
13
|
+
maxAmount: string;
|
|
14
|
+
maxLeverageFactor: number;
|
|
15
|
+
minAmount: string;
|
|
16
|
+
openedAccountsCount: number;
|
|
17
|
+
totalBorrowed: string;
|
|
18
|
+
totalClosedAccounts: number;
|
|
19
|
+
totalLiquidatedAccounts: number;
|
|
20
|
+
totalLosses: string;
|
|
21
|
+
totalOpenedAccounts: number;
|
|
22
|
+
totalProfit: string;
|
|
23
|
+
totalRepaid: string;
|
|
24
|
+
totalRepaidAccounts: number;
|
|
25
|
+
poolAddress: string;
|
|
26
|
+
underlyingToken: string;
|
|
27
|
+
availableLiquidityInUSD: number;
|
|
28
|
+
totalBorrowedInUSD: number;
|
|
29
|
+
totalLossesInUSD: number;
|
|
30
|
+
totalProfitInUSD: number;
|
|
31
|
+
totalRepaidInUSD: number;
|
|
32
|
+
openedAccountsCountChange: number;
|
|
33
|
+
totalOpenedAccountsChange: number;
|
|
34
|
+
totalClosedAccountsChange: number;
|
|
35
|
+
totalLiquidatedAccountsChange: number;
|
|
36
|
+
feeInterest: number;
|
|
37
|
+
feeLiquidation: number;
|
|
38
|
+
feeLiquidationExpired: number;
|
|
39
|
+
liquidationPremium: number;
|
|
40
|
+
liquidationPremiumExpired: number;
|
|
41
|
+
version: number;
|
|
22
42
|
}
|
package/lib/payload/pool.d.ts
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
import { BigNumberish } from "ethers";
|
|
1
2
|
import { PoolDataStruct } from "../types/@gearbox-protocol/core-v2/contracts/interfaces/IDataCompressor.sol/IDataCompressor";
|
|
2
3
|
import { ExcludeArrayProps } from "../utils/types";
|
|
3
4
|
export declare type PoolDataPayload = ExcludeArrayProps<PoolDataStruct>;
|
|
5
|
+
export interface ChartsPoolDataPayload {
|
|
6
|
+
addr: string;
|
|
7
|
+
underlyingToken: string;
|
|
8
|
+
dieselToken: string;
|
|
9
|
+
isWETH: boolean;
|
|
10
|
+
expectedLiquidity: string;
|
|
11
|
+
expectedLiquidityLimit: string;
|
|
12
|
+
availableLiquidity: string;
|
|
13
|
+
totalBorrowed: string;
|
|
14
|
+
depositAPY_RAY: string;
|
|
15
|
+
borrowAPY_RAY: string;
|
|
16
|
+
dieselRate_RAY: string;
|
|
17
|
+
withdrawFee: number;
|
|
18
|
+
lmAPY: number;
|
|
19
|
+
underlying: string;
|
|
20
|
+
linearCumulativeIndex: BigNumberish;
|
|
21
|
+
cumulativeIndex_RAY: BigNumberish;
|
|
22
|
+
timestampLU: BigNumberish;
|
|
23
|
+
version: number;
|
|
24
|
+
expectedLiquidityInUSD: number;
|
|
25
|
+
expectedLiquidityLimitInUSD: number;
|
|
26
|
+
availableLiquidityInUSD: number;
|
|
27
|
+
totalBorrowedInUSD: number;
|
|
28
|
+
uniqueLPs: number;
|
|
29
|
+
dieselAPY7D?: number;
|
|
30
|
+
dieselAPY30D?: number;
|
|
31
|
+
addLiqCount: number;
|
|
32
|
+
addedLiquidity: number;
|
|
33
|
+
caLockedValue: number;
|
|
34
|
+
caLockedValueInUSD: number;
|
|
35
|
+
earned7D: number;
|
|
36
|
+
earned7DInUSD: number;
|
|
37
|
+
expectedLiqWeekAgo: number;
|
|
38
|
+
removeLiqCount: number;
|
|
39
|
+
removedLiquidity: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ChartsAggregatedStats {
|
|
42
|
+
uniqueLPs: number;
|
|
43
|
+
earned7D: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ChartsAggregatedPoolPayload extends ChartsAggregatedStats {
|
|
46
|
+
pools: Array<ChartsPoolDataPayload>;
|
|
47
|
+
}
|