@morpho-org/blue-sdk 1.5.9 → 1.5.10
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/types.d.ts +1 -1
- package/lib/vault/VaultUtils.d.ts +10 -8
- package/lib/vault/VaultUtils.js +6 -2
- package/package.json +5 -5
package/lib/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type Address = string;
|
|
|
11
11
|
export type MarketId = `0x${Hex64}` & {
|
|
12
12
|
__TYPE__: "marketId";
|
|
13
13
|
};
|
|
14
|
-
export type BigIntish = bigint | string;
|
|
14
|
+
export type BigIntish = bigint | string | number | boolean;
|
|
15
15
|
/**
|
|
16
16
|
* The possible transaction type on the Blue contract
|
|
17
17
|
*/
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { RoundingDirection } from "../maths";
|
|
2
|
+
import { BigIntish } from "../types";
|
|
2
3
|
export declare namespace VaultUtils {
|
|
3
4
|
const VIRTUAL_ASSETS = 1n;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function decimalsOffset(decimals: BigIntish): bigint;
|
|
6
|
+
function toAssets(shares: BigIntish, { totalAssets, totalSupply, }: {
|
|
7
|
+
totalAssets: BigIntish;
|
|
8
|
+
totalSupply: BigIntish;
|
|
7
9
|
}, { decimalsOffset }: {
|
|
8
|
-
decimalsOffset:
|
|
10
|
+
decimalsOffset: BigIntish;
|
|
9
11
|
}, rounding?: RoundingDirection): bigint;
|
|
10
|
-
function toShares(assets:
|
|
11
|
-
totalAssets:
|
|
12
|
-
totalSupply:
|
|
12
|
+
function toShares(assets: BigIntish, { totalAssets, totalSupply, }: {
|
|
13
|
+
totalAssets: BigIntish;
|
|
14
|
+
totalSupply: BigIntish;
|
|
13
15
|
}, { decimalsOffset }: {
|
|
14
|
-
decimalsOffset:
|
|
16
|
+
decimalsOffset: BigIntish;
|
|
15
17
|
}, rounding?: RoundingDirection): bigint;
|
|
16
18
|
}
|
package/lib/vault/VaultUtils.js
CHANGED
|
@@ -5,12 +5,16 @@ const maths_1 = require("../maths");
|
|
|
5
5
|
var VaultUtils;
|
|
6
6
|
(function (VaultUtils) {
|
|
7
7
|
VaultUtils.VIRTUAL_ASSETS = 1n;
|
|
8
|
+
function decimalsOffset(decimals) {
|
|
9
|
+
return maths_1.MathLib.zeroFloorSub(18n, decimals);
|
|
10
|
+
}
|
|
11
|
+
VaultUtils.decimalsOffset = decimalsOffset;
|
|
8
12
|
function toAssets(shares, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Down") {
|
|
9
|
-
return maths_1.MathLib.mulDiv(shares, totalAssets + VaultUtils.VIRTUAL_ASSETS, totalSupply + 10n ** decimalsOffset, rounding);
|
|
13
|
+
return maths_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
|
|
10
14
|
}
|
|
11
15
|
VaultUtils.toAssets = toAssets;
|
|
12
16
|
function toShares(assets, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Up") {
|
|
13
|
-
return maths_1.MathLib.mulDiv(assets, totalSupply + 10n ** decimalsOffset, totalAssets + VaultUtils.VIRTUAL_ASSETS, rounding);
|
|
17
|
+
return maths_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
|
|
14
18
|
}
|
|
15
19
|
VaultUtils.toShares = toShares;
|
|
16
20
|
})(VaultUtils || (exports.VaultUtils = VaultUtils = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/blue-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"author": "Morpho Association <contact@morpho.org>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"keccak256": "^1.0.6"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@morpho-org/morpho-test": "^1.5.
|
|
20
|
-
"@morpho-org/morpho-ts": "^1.5.
|
|
19
|
+
"@morpho-org/morpho-test": "^1.5.10",
|
|
20
|
+
"@morpho-org/morpho-ts": "^1.5.10",
|
|
21
21
|
"@types/jest": "^29.5.12",
|
|
22
22
|
"@types/node": "^22.1.0",
|
|
23
23
|
"jest": "^29.7.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"typescript": "^5.4.5"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@morpho-org/morpho-ts": "^1.5.
|
|
28
|
+
"@morpho-org/morpho-ts": "^1.5.10"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
],
|
|
50
50
|
"preset": "ts-jest"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "33eb208bc2d687120c062e3a2325af1982ad04b3"
|
|
53
53
|
}
|