@defisaver/positions-sdk 2.1.96 → 2.1.98
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/cjs/aaveV3/index.js +3 -3
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +2 -1
- package/esm/aaveV3/index.js +3 -3
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +2 -1
- package/package.json +2 -2
- package/src/aaveV3/index.ts +3 -3
- package/src/services/utils.ts +8 -3
package/cjs/aaveV3/index.js
CHANGED
|
@@ -109,11 +109,11 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
109
109
|
const symbol = market.assets[i];
|
|
110
110
|
// eslint-disable-next-line guard-for-in
|
|
111
111
|
for (const eModeIndex in eModeCategoriesData) {
|
|
112
|
-
if ((0, utils_1.isEnabledOnBitmap)(
|
|
112
|
+
if ((0, utils_1.isEnabledOnBitmap)(eModeCategoriesData[eModeIndex].collateralBitmap, Number(tokenMarket.assetId)))
|
|
113
113
|
eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
|
|
114
|
-
if ((0, utils_1.isEnabledOnBitmap)(
|
|
114
|
+
if ((0, utils_1.isEnabledOnBitmap)(eModeCategoriesData[eModeIndex].borrowableBitmap, Number(tokenMarket.assetId)))
|
|
115
115
|
eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
|
|
116
|
-
if ((0, utils_1.isEnabledOnBitmap)(
|
|
116
|
+
if ((0, utils_1.isEnabledOnBitmap)(eModeCategoriesData[eModeIndex].ltvzeroBitmap, Number(tokenMarket.assetId)))
|
|
117
117
|
eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
|
|
118
118
|
}
|
|
119
119
|
const borrowCap = tokenMarket.borrowCap.toString();
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const bytesToString: (hex: string) => string;
|
|
|
16
16
|
* Map an input value from one range (minInput, maxInput) to a value in another range (minOutput, maxOutput)
|
|
17
17
|
*/
|
|
18
18
|
export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
|
|
19
|
-
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) =>
|
|
19
|
+
export declare const isEnabledOnBitmap: (bitmap: string | bigint | number, assetId: string | bigint | number) => boolean;
|
|
20
20
|
export declare const MAXUINT: string;
|
|
21
21
|
export declare const isMaxUint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
package/cjs/services/utils.js
CHANGED
|
@@ -47,8 +47,9 @@ const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
|
|
|
47
47
|
return new decimal_js_1.default(minOutput).plus(new decimal_js_1.default(slope).mul(new decimal_js_1.default(input).minus(minInput))).toDP(2).toNumber();
|
|
48
48
|
};
|
|
49
49
|
exports.mapRange = mapRange;
|
|
50
|
+
const isEnabledOnBitmap = (bitmap, assetId) => (
|
|
50
51
|
// eslint-disable-next-line no-bitwise
|
|
51
|
-
|
|
52
|
+
((BigInt(bitmap) >> BigInt(assetId)) & BigInt(1)) === BigInt(1));
|
|
52
53
|
exports.isEnabledOnBitmap = isEnabledOnBitmap;
|
|
53
54
|
exports.MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
54
55
|
const isMaxUint = (amount) => (0, exports.compareAddresses)(exports.MAXUINT, amount);
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -98,11 +98,11 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
98
98
|
const symbol = market.assets[i];
|
|
99
99
|
// eslint-disable-next-line guard-for-in
|
|
100
100
|
for (const eModeIndex in eModeCategoriesData) {
|
|
101
|
-
if (isEnabledOnBitmap(
|
|
101
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].collateralBitmap, Number(tokenMarket.assetId)))
|
|
102
102
|
eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
|
|
103
|
-
if (isEnabledOnBitmap(
|
|
103
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].borrowableBitmap, Number(tokenMarket.assetId)))
|
|
104
104
|
eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
|
|
105
|
-
if (isEnabledOnBitmap(
|
|
105
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].ltvzeroBitmap, Number(tokenMarket.assetId)))
|
|
106
106
|
eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
|
|
107
107
|
}
|
|
108
108
|
const borrowCap = tokenMarket.borrowCap.toString();
|
package/esm/services/utils.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const bytesToString: (hex: string) => string;
|
|
|
16
16
|
* Map an input value from one range (minInput, maxInput) to a value in another range (minOutput, maxOutput)
|
|
17
17
|
*/
|
|
18
18
|
export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
|
|
19
|
-
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) =>
|
|
19
|
+
export declare const isEnabledOnBitmap: (bitmap: string | bigint | number, assetId: string | bigint | number) => boolean;
|
|
20
20
|
export declare const MAXUINT: string;
|
|
21
21
|
export declare const isMaxUint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
package/esm/services/utils.js
CHANGED
|
@@ -28,8 +28,9 @@ export const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
|
|
|
28
28
|
// output = output_start + slope * (input - input_start)
|
|
29
29
|
return new Dec(minOutput).plus(new Dec(slope).mul(new Dec(input).minus(minInput))).toDP(2).toNumber();
|
|
30
30
|
};
|
|
31
|
+
export const isEnabledOnBitmap = (bitmap, assetId) => (
|
|
31
32
|
// eslint-disable-next-line no-bitwise
|
|
32
|
-
|
|
33
|
+
((BigInt(bitmap) >> BigInt(assetId)) & BigInt(1)) === BigInt(1));
|
|
33
34
|
export const MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
34
35
|
export const isMaxUint = (amount) => compareAddresses(MAXUINT, amount);
|
|
35
36
|
export const isMainnetNetwork = (network) => network === NetworkNumber.Eth;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.98",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@defisaver/tokens": "^1.7.
|
|
24
|
+
"@defisaver/tokens": "^1.7.35",
|
|
25
25
|
"@types/lodash": "^4.17.15",
|
|
26
26
|
"@types/memoizee": "^0.4.12",
|
|
27
27
|
"decimal.js": "^10.6.0",
|
package/src/aaveV3/index.ts
CHANGED
|
@@ -130,9 +130,9 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
130
130
|
|
|
131
131
|
// eslint-disable-next-line guard-for-in
|
|
132
132
|
for (const eModeIndex in eModeCategoriesData) {
|
|
133
|
-
if (isEnabledOnBitmap(
|
|
134
|
-
if (isEnabledOnBitmap(
|
|
135
|
-
if (isEnabledOnBitmap(
|
|
133
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].collateralBitmap!, Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].collateralAssets.push(symbol);
|
|
134
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].borrowableBitmap!, Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].borrowAssets.push(symbol);
|
|
135
|
+
if (isEnabledOnBitmap(eModeCategoriesData[eModeIndex].ltvzeroBitmap!, Number(tokenMarket.assetId))) eModeCategoriesData[eModeIndex].ltvZeroAssets.push(symbol);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const borrowCap = tokenMarket.borrowCap.toString();
|
package/src/services/utils.ts
CHANGED
|
@@ -44,8 +44,13 @@ export const mapRange = (input: number | string, minInput: number | string, maxI
|
|
|
44
44
|
return new Dec(minOutput).plus(new Dec(slope).mul(new Dec(input).minus(minInput))).toDP(2).toNumber();
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
export const isEnabledOnBitmap = (
|
|
48
|
+
bitmap: string | bigint | number,
|
|
49
|
+
assetId: string | bigint | number,
|
|
50
|
+
) => (
|
|
51
|
+
// eslint-disable-next-line no-bitwise
|
|
52
|
+
((BigInt(bitmap) >> BigInt(assetId)) & BigInt(1)) === BigInt(1)
|
|
53
|
+
);
|
|
49
54
|
|
|
50
55
|
export const MAXUINT:string = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
51
56
|
|
|
@@ -114,4 +119,4 @@ export const getNativeAssetFromWrapped = (symbol: string) => {
|
|
|
114
119
|
if (symbol === 'WETH') return 'ETH';
|
|
115
120
|
if (symbol === 'WXPL') return 'XPL';
|
|
116
121
|
return symbol;
|
|
117
|
-
};
|
|
122
|
+
};
|