@gearbox-protocol/sdk 1.26.1 → 1.26.2
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/apy/curveAPY.js +1 -1
- package/lib/apy/yearnAPY.js +1 -1
- package/lib/contracts/contracts.js +4 -2
- package/lib/contracts/contractsRegister.js +1 -1
- package/lib/core/creditSession.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -5
- package/lib/parsers/txParser.js +2 -2
- package/lib/tokens/token.js +7 -2
- package/lib/utils/mappers.d.ts +6 -5
- package/lib/utils/mappers.js +11 -12
- package/package.json +1 -1
package/lib/apy/curveAPY.js
CHANGED
|
@@ -52,7 +52,7 @@ async function getCurveAPY() {
|
|
|
52
52
|
...cryptoPoolData.map(p => [p.id, p]),
|
|
53
53
|
...factoryTricryptoPoolData.map(p => [p.id, p]),
|
|
54
54
|
]);
|
|
55
|
-
const curveAPY =
|
|
55
|
+
const curveAPY = mappers_1.TypedObjectUtils.entries(APY_DICTIONARY).reduce((acc, [curveSymbol, poolId]) => {
|
|
56
56
|
const { baseApy, crvApy } = apys[poolId] || {};
|
|
57
57
|
if (baseApy === undefined)
|
|
58
58
|
console.warn(`No base apy for: ${curveSymbol}, ${poolId}`);
|
package/lib/apy/yearnAPY.js
CHANGED
|
@@ -19,7 +19,7 @@ async function getYearnAPY() {
|
|
|
19
19
|
acc[d.symbol.toLowerCase()] = d;
|
|
20
20
|
return acc;
|
|
21
21
|
}, {});
|
|
22
|
-
const yearnAPY =
|
|
22
|
+
const yearnAPY = mappers_1.TypedObjectUtils.entries(yearn_1.yearnTokens).reduce((acc, [yearnSymbol]) => {
|
|
23
23
|
const { apy } = dataBySymbol[transformSymbol(yearnSymbol)] || {};
|
|
24
24
|
const { net_apy: netApy } = apy || {};
|
|
25
25
|
acc[yearnSymbol] = (0, formatter_1.toBN)((netApy / RESPONSE_DECIMALS).toString(), constants_1.WAD_DECIMALS_POW);
|
|
@@ -483,9 +483,11 @@ exports.contractParams = {
|
|
|
483
483
|
type: adapters_1.AdapterInterface.BALANCER_VAULT,
|
|
484
484
|
},
|
|
485
485
|
};
|
|
486
|
-
exports.contractsByAddress =
|
|
486
|
+
exports.contractsByAddress = mappers_1.TypedObjectUtils.entries(exports.contractsByNetwork).reduce((acc, [, contracts]) => ({
|
|
487
487
|
...acc,
|
|
488
|
-
...
|
|
488
|
+
...mappers_1.TypedObjectUtils.fromEntries(mappers_1.TypedObjectUtils.entries(contracts)
|
|
489
|
+
.map(([k, v]) => [v.toLowerCase(), k])
|
|
490
|
+
.filter(k => !!k)),
|
|
489
491
|
}), {});
|
|
490
492
|
const isSupportedContract = (t) => typeof t === "string" && !!exports.contractParams[t];
|
|
491
493
|
exports.isSupportedContract = isSupportedContract;
|
|
@@ -59,7 +59,7 @@ const contractNames = Object.entries(contracts_1.contractsByAddress).reduce((acc
|
|
|
59
59
|
return { ...acc, [addr]: params.name };
|
|
60
60
|
}, {});
|
|
61
61
|
const contractsFullList = {
|
|
62
|
-
...
|
|
62
|
+
...mappers_1.TypedObjectUtils.keyToLowercase(exports.deployedContracts),
|
|
63
63
|
...contractNames,
|
|
64
64
|
};
|
|
65
65
|
function getContractName(address) {
|
|
@@ -16,7 +16,7 @@ exports.CREDIT_SESSION_STATUS_BY_ID = {
|
|
|
16
16
|
4: "liquidateExpired",
|
|
17
17
|
5: "liquidatePaused",
|
|
18
18
|
};
|
|
19
|
-
exports.CREDIT_SESSION_ID_BY_STATUS =
|
|
19
|
+
exports.CREDIT_SESSION_ID_BY_STATUS = mappers_1.TypedObjectUtils.swapKeyValue(exports.CREDIT_SESSION_STATUS_BY_ID);
|
|
20
20
|
class CreditSession {
|
|
21
21
|
id;
|
|
22
22
|
status;
|
package/lib/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export { TokenType } from "./tokens/tokenType";
|
|
|
56
56
|
export * from "./tokens/yearn";
|
|
57
57
|
export * from "./utils/errors";
|
|
58
58
|
export { getPoolTokens, getUnderlyingToken } from "./utils/extracter";
|
|
59
|
-
export
|
|
59
|
+
export * from "./utils/mappers";
|
|
60
60
|
export * from "./utils/multicall";
|
|
61
61
|
export * from "./utils/price";
|
|
62
62
|
export { callRepeater } from "./utils/repeater";
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.callRepeater = exports.
|
|
17
|
+
exports.callRepeater = exports.getUnderlyingToken = exports.getPoolTokens = exports.TokenType = exports.AdapterInterface = void 0;
|
|
18
18
|
__exportStar(require("./contracts/contracts"), exports);
|
|
19
19
|
__exportStar(require("./contracts/protocols"), exports);
|
|
20
20
|
__exportStar(require("./core/adapter"), exports);
|
|
@@ -78,10 +78,7 @@ __exportStar(require("./utils/errors"), exports);
|
|
|
78
78
|
var extracter_1 = require("./utils/extracter");
|
|
79
79
|
Object.defineProperty(exports, "getPoolTokens", { enumerable: true, get: function () { return extracter_1.getPoolTokens; } });
|
|
80
80
|
Object.defineProperty(exports, "getUnderlyingToken", { enumerable: true, get: function () { return extracter_1.getUnderlyingToken; } });
|
|
81
|
-
|
|
82
|
-
Object.defineProperty(exports, "keyToLowercase", { enumerable: true, get: function () { return mappers_1.keyToLowercase; } });
|
|
83
|
-
Object.defineProperty(exports, "objectEntries", { enumerable: true, get: function () { return mappers_1.objectEntries; } });
|
|
84
|
-
Object.defineProperty(exports, "swapKeyValue", { enumerable: true, get: function () { return mappers_1.swapKeyValue; } });
|
|
81
|
+
__exportStar(require("./utils/mappers"), exports);
|
|
85
82
|
__exportStar(require("./utils/multicall"), exports);
|
|
86
83
|
__exportStar(require("./utils/price"), exports);
|
|
87
84
|
var repeater_1 = require("./utils/repeater");
|
package/lib/parsers/txParser.js
CHANGED
|
@@ -58,7 +58,7 @@ class TxParser {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
static addContracts(network) {
|
|
61
|
-
|
|
61
|
+
mappers_1.TypedObjectUtils.entries(contracts_1.contractParams).forEach(([contract, contractData]) => {
|
|
62
62
|
const address = contracts_1.contractsByNetwork[network][contract];
|
|
63
63
|
TxParser.chooseContractParser(address, contract, contractData.type, true);
|
|
64
64
|
if (contractData.type === adapters_1.AdapterInterface.CONVEX_V1_BASE_REWARD_POOL) {
|
|
@@ -77,7 +77,7 @@ class TxParser {
|
|
|
77
77
|
TxParser._addParser(creditFacade, new creditFacadeParser_1.CreditFacadeParser(underlying));
|
|
78
78
|
}
|
|
79
79
|
static addTokens(network) {
|
|
80
|
-
|
|
80
|
+
mappers_1.TypedObjectUtils.entries(token_1.tokenDataByNetwork[network]).forEach(([s, t]) => {
|
|
81
81
|
if (s === "STETH") {
|
|
82
82
|
TxParser._addParser(t, new lidoSTETHParser_1.LidoSTETHParser(s));
|
|
83
83
|
}
|
package/lib/tokens/token.js
CHANGED
|
@@ -222,9 +222,14 @@ exports.tokenDataByNetwork = {
|
|
|
222
222
|
GEAR: constants_1.NOT_DEPLOYED,
|
|
223
223
|
},
|
|
224
224
|
};
|
|
225
|
-
exports.tokenSymbolByAddress =
|
|
225
|
+
exports.tokenSymbolByAddress = mappers_1.TypedObjectUtils.entries(exports.tokenDataByNetwork).reduce((acc, [, tokens]) => ({
|
|
226
226
|
...acc,
|
|
227
|
-
...
|
|
227
|
+
...{
|
|
228
|
+
...acc,
|
|
229
|
+
...mappers_1.TypedObjectUtils.fromEntries(mappers_1.TypedObjectUtils.entries(tokens)
|
|
230
|
+
.map(([k, v]) => [v.toLowerCase(), k])
|
|
231
|
+
.filter(k => !!k)),
|
|
232
|
+
},
|
|
228
233
|
}), {});
|
|
229
234
|
const isSupportedToken = (t) => typeof t === "string" && !!exports.supportedTokens[t];
|
|
230
235
|
exports.isSupportedToken = isSupportedToken;
|
package/lib/utils/mappers.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type SupportedValue = string | number;
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare class TypedObjectUtils {
|
|
3
|
+
static entries: <K extends SupportedValue, T>(o: Record<K, T>) => [K, T][];
|
|
4
|
+
static fromEntries: <K extends SupportedValue, T>(o: [K, T][]) => Record<K, T>;
|
|
5
|
+
static swapKeyValue: <K extends SupportedValue, T extends SupportedValue>(o: Record<K, T>) => Record<T, K>;
|
|
6
|
+
static keyToLowercase: <K extends SupportedValue, T>(o: Record<K, T>) => Record<K, T>;
|
|
7
|
+
}
|
|
6
8
|
export type { SupportedValue };
|
|
7
|
-
export { filterEmptyKeys, keyToLowercase, objectEntries, swapKeyValue };
|
package/lib/utils/mappers.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, {});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.filterEmptyKeys = filterEmptyKeys;
|
|
3
|
+
exports.TypedObjectUtils = void 0;
|
|
4
|
+
class TypedObjectUtils {
|
|
5
|
+
static entries = (o) => Object.entries(o);
|
|
6
|
+
static fromEntries = (o) => Object.fromEntries(o);
|
|
7
|
+
static swapKeyValue = (o) => TypedObjectUtils.entries(o).reduce((acc, [key, value]) => ({ ...acc, [value]: key }), {});
|
|
8
|
+
static keyToLowercase = (o) => TypedObjectUtils.entries(o).reduce((acc, [key, value]) => {
|
|
9
|
+
const keyTransformed = typeof key === "string" ? key.toLowerCase() : key;
|
|
10
|
+
return { ...acc, [keyTransformed]: value };
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
exports.TypedObjectUtils = TypedObjectUtils;
|