@morpho-org/blue-sdk 1.0.0-integ-650.0

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.
Files changed (86) hide show
  1. package/README.md +106 -0
  2. package/lib/addresses.d.ts +113 -0
  3. package/lib/addresses.js +162 -0
  4. package/lib/chain.d.ts +29 -0
  5. package/lib/chain.js +289 -0
  6. package/lib/chain.test.d.ts +1 -0
  7. package/lib/chain.test.js +21 -0
  8. package/lib/constants.d.ts +29 -0
  9. package/lib/constants.js +33 -0
  10. package/lib/errors.d.ts +58 -0
  11. package/lib/errors.js +119 -0
  12. package/lib/helpers/format/format.d.ts +122 -0
  13. package/lib/helpers/format/format.js +286 -0
  14. package/lib/helpers/format/format.test.d.ts +1 -0
  15. package/lib/helpers/format/format.test.js +255 -0
  16. package/lib/helpers/format/index.d.ts +1 -0
  17. package/lib/helpers/format/index.js +17 -0
  18. package/lib/helpers/index.d.ts +2 -0
  19. package/lib/helpers/index.js +18 -0
  20. package/lib/helpers/locale.d.ts +46 -0
  21. package/lib/helpers/locale.js +96 -0
  22. package/lib/holding/AssetBalances.d.ts +48 -0
  23. package/lib/holding/AssetBalances.js +42 -0
  24. package/lib/holding/Holding.d.ts +59 -0
  25. package/lib/holding/Holding.js +59 -0
  26. package/lib/holding/index.d.ts +2 -0
  27. package/lib/holding/index.js +18 -0
  28. package/lib/index.d.ts +25 -0
  29. package/lib/index.js +54 -0
  30. package/lib/market/Market.d.ts +329 -0
  31. package/lib/market/Market.js +460 -0
  32. package/lib/market/MarketConfig.d.ts +52 -0
  33. package/lib/market/MarketConfig.js +76 -0
  34. package/lib/market/MarketUtils.d.ts +232 -0
  35. package/lib/market/MarketUtils.js +263 -0
  36. package/lib/market/MarketUtils.test.d.ts +1 -0
  37. package/lib/market/MarketUtils.test.js +38 -0
  38. package/lib/market/index.d.ts +3 -0
  39. package/lib/market/index.js +19 -0
  40. package/lib/maths/AdaptiveCurveIrmLib.d.ts +39 -0
  41. package/lib/maths/AdaptiveCurveIrmLib.js +134 -0
  42. package/lib/maths/MathLib.d.ts +114 -0
  43. package/lib/maths/MathLib.js +175 -0
  44. package/lib/maths/SharesMath.d.ts +12 -0
  45. package/lib/maths/SharesMath.js +21 -0
  46. package/lib/maths/index.d.ts +3 -0
  47. package/lib/maths/index.js +19 -0
  48. package/lib/position/Position.d.ts +126 -0
  49. package/lib/position/Position.js +203 -0
  50. package/lib/position/index.d.ts +1 -0
  51. package/lib/position/index.js +17 -0
  52. package/lib/tests/mocks/markets.d.ts +19 -0
  53. package/lib/tests/mocks/markets.js +121 -0
  54. package/lib/token/ConstantWrappedToken.d.ts +18 -0
  55. package/lib/token/ConstantWrappedToken.js +36 -0
  56. package/lib/token/ExchangeRateWrappedToken.d.ts +11 -0
  57. package/lib/token/ExchangeRateWrappedToken.js +21 -0
  58. package/lib/token/Token.d.ts +46 -0
  59. package/lib/token/Token.js +64 -0
  60. package/lib/token/VaultToken.d.ts +14 -0
  61. package/lib/token/VaultToken.js +23 -0
  62. package/lib/token/WrappedToken.d.ts +17 -0
  63. package/lib/token/WrappedToken.js +33 -0
  64. package/lib/token/index.d.ts +5 -0
  65. package/lib/token/index.js +21 -0
  66. package/lib/types.d.ts +30 -0
  67. package/lib/types.js +22 -0
  68. package/lib/user/User.d.ts +20 -0
  69. package/lib/user/User.js +23 -0
  70. package/lib/user/index.d.ts +1 -0
  71. package/lib/user/index.js +17 -0
  72. package/lib/vault/Vault.d.ts +166 -0
  73. package/lib/vault/Vault.js +234 -0
  74. package/lib/vault/VaultConfig.d.ts +22 -0
  75. package/lib/vault/VaultConfig.js +32 -0
  76. package/lib/vault/VaultMarketAllocation.d.ts +20 -0
  77. package/lib/vault/VaultMarketAllocation.js +30 -0
  78. package/lib/vault/VaultMarketConfig.d.ts +43 -0
  79. package/lib/vault/VaultMarketConfig.js +43 -0
  80. package/lib/vault/VaultMarketPublicAllocatorConfig.d.ts +29 -0
  81. package/lib/vault/VaultMarketPublicAllocatorConfig.js +28 -0
  82. package/lib/vault/VaultUtils.d.ts +18 -0
  83. package/lib/vault/VaultUtils.js +20 -0
  84. package/lib/vault/index.d.ts +6 -0
  85. package/lib/vault/index.js +22 -0
  86. package/package.json +53 -0
@@ -0,0 +1,43 @@
1
+ import { Address, MarketId } from "../types";
2
+ import { Pending } from "./Vault";
3
+ import { VaultMarketPublicAllocatorConfig } from "./VaultMarketPublicAllocatorConfig";
4
+ export interface InputVaultMarketConfig {
5
+ vault: Address;
6
+ marketId: MarketId;
7
+ cap: bigint;
8
+ pendingCap: Pending<bigint>;
9
+ removableAt: bigint;
10
+ enabled: boolean;
11
+ publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
12
+ }
13
+ export declare class VaultMarketConfig implements InputVaultMarketConfig {
14
+ /**
15
+ * The vault's address.
16
+ */
17
+ vault: Address;
18
+ /**
19
+ * The market's id.
20
+ */
21
+ marketId: MarketId;
22
+ /**
23
+ * The maximum amount of tokens that can be allocated to this market.
24
+ */
25
+ cap: bigint;
26
+ /**
27
+ * The pending maximum amount of tokens that can be allocated to this market.
28
+ */
29
+ pendingCap: Pending<bigint>;
30
+ /**
31
+ * The timestamp at which the market can be removed from the withdraw queue.
32
+ */
33
+ removableAt: bigint;
34
+ /**
35
+ * Whether this market is enabled, i.e. whether additional tokens can be allocated to it.
36
+ */
37
+ enabled: boolean;
38
+ /**
39
+ * The vault's PublicAllocator configuration on the corresponding market.
40
+ */
41
+ publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
42
+ constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: InputVaultMarketConfig);
43
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultMarketConfig = void 0;
4
+ class VaultMarketConfig {
5
+ /**
6
+ * The vault's address.
7
+ */
8
+ vault;
9
+ /**
10
+ * The market's id.
11
+ */
12
+ marketId;
13
+ /**
14
+ * The maximum amount of tokens that can be allocated to this market.
15
+ */
16
+ cap;
17
+ /**
18
+ * The pending maximum amount of tokens that can be allocated to this market.
19
+ */
20
+ pendingCap;
21
+ /**
22
+ * The timestamp at which the market can be removed from the withdraw queue.
23
+ */
24
+ removableAt;
25
+ /**
26
+ * Whether this market is enabled, i.e. whether additional tokens can be allocated to it.
27
+ */
28
+ enabled;
29
+ /**
30
+ * The vault's PublicAllocator configuration on the corresponding market.
31
+ */
32
+ publicAllocatorConfig;
33
+ constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }) {
34
+ this.vault = vault;
35
+ this.marketId = marketId;
36
+ this.cap = cap;
37
+ this.pendingCap = pendingCap;
38
+ this.removableAt = removableAt;
39
+ this.enabled = enabled;
40
+ this.publicAllocatorConfig = publicAllocatorConfig;
41
+ }
42
+ }
43
+ exports.VaultMarketConfig = VaultMarketConfig;
@@ -0,0 +1,29 @@
1
+ import { Address, MarketId } from "../types";
2
+ /**
3
+ * The vault's configuration of a market on the PublicAllocator.
4
+ */
5
+ export interface InputVaultMarketPublicAllocatorConfig {
6
+ vault: Address;
7
+ marketId: MarketId;
8
+ maxIn: bigint;
9
+ maxOut: bigint;
10
+ }
11
+ export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarketPublicAllocatorConfig {
12
+ /**
13
+ * The vault's address.
14
+ */
15
+ vault: Address;
16
+ /**
17
+ * The market's id.
18
+ */
19
+ marketId: MarketId;
20
+ /**
21
+ * The maximum amount of tokens that can be allocated to this market by the vault via the PublicAllocator.
22
+ */
23
+ maxIn: bigint;
24
+ /**
25
+ * The maximum amount of tokens that can be allocated out of this market by the vault via the PublicAllocator.
26
+ */
27
+ maxOut: bigint;
28
+ constructor({ vault, marketId, maxIn, maxOut, }: InputVaultMarketPublicAllocatorConfig);
29
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultMarketPublicAllocatorConfig = void 0;
4
+ class VaultMarketPublicAllocatorConfig {
5
+ /**
6
+ * The vault's address.
7
+ */
8
+ vault;
9
+ /**
10
+ * The market's id.
11
+ */
12
+ marketId;
13
+ /**
14
+ * The maximum amount of tokens that can be allocated to this market by the vault via the PublicAllocator.
15
+ */
16
+ maxIn;
17
+ /**
18
+ * The maximum amount of tokens that can be allocated out of this market by the vault via the PublicAllocator.
19
+ */
20
+ maxOut;
21
+ constructor({ vault, marketId, maxIn, maxOut, }) {
22
+ this.vault = vault;
23
+ this.marketId = marketId;
24
+ this.maxIn = maxIn;
25
+ this.maxOut = maxOut;
26
+ }
27
+ }
28
+ exports.VaultMarketPublicAllocatorConfig = VaultMarketPublicAllocatorConfig;
@@ -0,0 +1,18 @@
1
+ import { RoundingDirection } from "../maths";
2
+ import { BigIntish } from "../types";
3
+ export declare namespace VaultUtils {
4
+ const VIRTUAL_ASSETS = 1n;
5
+ function decimalsOffset(decimals: BigIntish): bigint;
6
+ function toAssets(shares: BigIntish, { totalAssets, totalSupply, }: {
7
+ totalAssets: BigIntish;
8
+ totalSupply: BigIntish;
9
+ }, { decimalsOffset }: {
10
+ decimalsOffset: BigIntish;
11
+ }, rounding?: RoundingDirection): bigint;
12
+ function toShares(assets: BigIntish, { totalAssets, totalSupply, }: {
13
+ totalAssets: BigIntish;
14
+ totalSupply: BigIntish;
15
+ }, { decimalsOffset }: {
16
+ decimalsOffset: BigIntish;
17
+ }, rounding?: RoundingDirection): bigint;
18
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VaultUtils = void 0;
4
+ const maths_1 = require("../maths");
5
+ var VaultUtils;
6
+ (function (VaultUtils) {
7
+ VaultUtils.VIRTUAL_ASSETS = 1n;
8
+ function decimalsOffset(decimals) {
9
+ return maths_1.MathLib.zeroFloorSub(18n, decimals);
10
+ }
11
+ VaultUtils.decimalsOffset = decimalsOffset;
12
+ function toAssets(shares, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Down") {
13
+ return maths_1.MathLib.mulDiv(shares, BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), rounding);
14
+ }
15
+ VaultUtils.toAssets = toAssets;
16
+ function toShares(assets, { totalAssets, totalSupply, }, { decimalsOffset }, rounding = "Up") {
17
+ return maths_1.MathLib.mulDiv(assets, BigInt(totalSupply) + 10n ** BigInt(decimalsOffset), BigInt(totalAssets) + VaultUtils.VIRTUAL_ASSETS, rounding);
18
+ }
19
+ VaultUtils.toShares = toShares;
20
+ })(VaultUtils || (exports.VaultUtils = VaultUtils = {}));
@@ -0,0 +1,6 @@
1
+ export * from "./VaultUtils";
2
+ export * from "./VaultConfig";
3
+ export * from "./VaultMarketAllocation";
4
+ export * from "./VaultMarketConfig";
5
+ export * from "./VaultMarketPublicAllocatorConfig";
6
+ export * from "./Vault";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./VaultUtils"), exports);
18
+ __exportStar(require("./VaultConfig"), exports);
19
+ __exportStar(require("./VaultMarketAllocation"), exports);
20
+ __exportStar(require("./VaultMarketConfig"), exports);
21
+ __exportStar(require("./VaultMarketPublicAllocatorConfig"), exports);
22
+ __exportStar(require("./Vault"), exports);
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@morpho-org/blue-sdk",
3
+ "version": "1.0.0-integ-650.0",
4
+ "author": "Morpho Association <contact@morpho.org>",
5
+ "license": "MIT",
6
+ "main": "lib/index.js",
7
+ "files": [
8
+ "lib"
9
+ ],
10
+ "scripts": {
11
+ "prepublish": "yarn build",
12
+ "build": "tsc --build tsconfig.build.json",
13
+ "test": "jest"
14
+ },
15
+ "dependencies": {
16
+ "keccak256": "^1.0.6"
17
+ },
18
+ "devDependencies": {
19
+ "@morpho-org/morpho-test": "^1.0.0-integ-650.0",
20
+ "@morpho-org/morpho-ts": "^1.0.0-integ-650.0",
21
+ "@types/jest": "^29.5.12",
22
+ "@types/node": "^22.1.0",
23
+ "jest": "^29.7.0",
24
+ "ts-jest": "^29.2.4",
25
+ "typescript": "^5.4.5"
26
+ },
27
+ "peerDependencies": {
28
+ "@morpho-org/morpho-ts": "^1.0.0-integ-650.0"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "jest": {
34
+ "verbose": true,
35
+ "testTimeout": 15000,
36
+ "maxWorkers": 1,
37
+ "transform": {
38
+ "^.+\\.tsx?$": [
39
+ "ts-jest",
40
+ {
41
+ "tsconfig": "tsconfig.json"
42
+ }
43
+ ]
44
+ },
45
+ "testRegex": "(/src/.*|(\\.|/)(test|spec)+)\\.test\\.(jsx?|tsx?)$",
46
+ "moduleFileExtensions": [
47
+ "js",
48
+ "ts"
49
+ ],
50
+ "preset": "ts-jest"
51
+ },
52
+ "gitHead": "dcbf95368923403757853f60b8380ee861273562"
53
+ }