@morpho-org/blue-sdk 1.10.1-alpha.1 → 1.10.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.
@@ -1,4 +1,4 @@
1
- import { Address, BigIntish } from "../types";
1
+ import { Address } from "../types";
2
2
  export declare const ERC20_ALLOWANCE_RECIPIENTS: readonly ["morpho", "permit2", "bundler"];
3
3
  export declare const PERMIT2_ALLOWANCE_RECIPIENTS: readonly ["morpho", "bundler"];
4
4
  export type Erc20AllowanceRecipient = (typeof ERC20_ALLOWANCE_RECIPIENTS)[number];
@@ -8,11 +8,6 @@ export interface Permit2Allowance {
8
8
  expiration: bigint;
9
9
  nonce: bigint;
10
10
  }
11
- export interface InputPermit2Allowance {
12
- amount: BigIntish;
13
- expiration: BigIntish;
14
- nonce: BigIntish;
15
- }
16
11
  export interface InputHolding {
17
12
  user: Address;
18
13
  token: Address;
@@ -20,7 +15,7 @@ export interface InputHolding {
20
15
  [key in Erc20AllowanceRecipient]: bigint;
21
16
  };
22
17
  permit2Allowances: {
23
- [key in Permit2AllowanceRecipient]: InputPermit2Allowance;
18
+ [key in Permit2AllowanceRecipient]: Permit2Allowance;
24
19
  };
25
20
  erc2612Nonce?: bigint;
26
21
  canTransfer?: boolean;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Holding = exports.PERMIT2_ALLOWANCE_RECIPIENTS = exports.ERC20_ALLOWANCE_RECIPIENTS = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ const addresses_1 = require("../addresses");
5
6
  exports.ERC20_ALLOWANCE_RECIPIENTS = [
6
7
  "morpho",
7
8
  "permit2",
@@ -41,27 +42,16 @@ class Holding {
41
42
  * `undefined` if the token does not support ERC-2612.
42
43
  */
43
44
  erc2612Nonce;
44
- constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer, }) {
45
+ constructor({ user, token, erc20Allowances, permit2Allowances, balance, erc2612Nonce, canTransfer = true, }) {
45
46
  this.user = user;
46
47
  this.token = token;
47
48
  this.balance = balance;
48
- this.canTransfer = canTransfer;
49
+ this.canTransfer = token === addresses_1.NATIVE_ADDRESS || canTransfer;
49
50
  this.erc20Allowances = (0, morpho_ts_1.fromEntries)((0, morpho_ts_1.entries)(erc20Allowances).map(([address, allowance]) => [
50
51
  address,
51
52
  allowance,
52
53
  ]));
53
- this.permit2Allowances = {
54
- morpho: {
55
- amount: BigInt(permit2Allowances.morpho.amount),
56
- expiration: BigInt(permit2Allowances.morpho.expiration),
57
- nonce: BigInt(permit2Allowances.morpho.nonce),
58
- },
59
- bundler: {
60
- amount: BigInt(permit2Allowances.bundler.amount),
61
- expiration: BigInt(permit2Allowances.bundler.expiration),
62
- nonce: BigInt(permit2Allowances.bundler.nonce),
63
- },
64
- };
54
+ this.permit2Allowances = permit2Allowances;
65
55
  if (erc2612Nonce != null)
66
56
  this.erc2612Nonce = erc2612Nonce;
67
57
  }
@@ -1,10 +1,11 @@
1
1
  import { RoundingDirection } from "../maths";
2
- import { Address, BigIntish } from "../types";
2
+ import { Address } from "../types";
3
3
  import { InputToken } from "./Token";
4
4
  import { WrappedToken } from "./WrappedToken";
5
5
  export declare class ConstantWrappedToken extends WrappedToken {
6
- readonly underlyingDecimals: bigint;
7
- constructor(token: InputToken, underlying: Address, underlyingDecimals?: BigIntish);
6
+ readonly underlying: Address;
7
+ private readonly _underlyingDecimals;
8
+ constructor(token: InputToken, underlying: Address, _underlyingDecimals?: number);
8
9
  toWrappedExactAmountIn(unwrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
9
10
  /** The amount of unwrappedTokens that should be wrapped to receive `wrappedAmount` */
10
11
  toWrappedExactAmountOut(wrappedAmount: bigint, _slippage?: bigint, rounding?: RoundingDirection): bigint;
@@ -4,10 +4,12 @@ exports.ConstantWrappedToken = void 0;
4
4
  const maths_1 = require("../maths");
5
5
  const WrappedToken_1 = require("./WrappedToken");
6
6
  class ConstantWrappedToken extends WrappedToken_1.WrappedToken {
7
- underlyingDecimals;
8
- constructor(token, underlying, underlyingDecimals = 18n) {
7
+ underlying;
8
+ _underlyingDecimals;
9
+ constructor(token, underlying, _underlyingDecimals = 18) {
9
10
  super(token, underlying);
10
- this.underlyingDecimals = BigInt(underlyingDecimals);
11
+ this.underlying = underlying;
12
+ this._underlyingDecimals = _underlyingDecimals;
11
13
  }
12
14
  toWrappedExactAmountIn(unwrappedAmount, _slippage, rounding = "Down") {
13
15
  return super.toWrappedExactAmountIn(unwrappedAmount, 0n, rounding);
@@ -25,10 +27,10 @@ class ConstantWrappedToken extends WrappedToken_1.WrappedToken {
25
27
  return super.toUnwrappedExactAmountOut(unwrappedAmount, 0n, rounding);
26
28
  }
27
29
  _wrap(amount) {
28
- return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this.decimals), 10n ** this.underlyingDecimals);
30
+ return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this.decimals), 10n ** BigInt(this._underlyingDecimals));
29
31
  }
30
32
  _unwrap(amount) {
31
- return maths_1.MathLib.mulDivDown(amount, 10n ** this.underlyingDecimals, 10n ** BigInt(this.decimals));
33
+ return maths_1.MathLib.mulDivDown(amount, 10n ** BigInt(this._underlyingDecimals), 10n ** BigInt(this.decimals));
32
34
  }
33
35
  }
34
36
  exports.ConstantWrappedToken = ConstantWrappedToken;
@@ -1,9 +1,9 @@
1
1
  import { ChainId } from "../chain";
2
2
  import { RoundingDirection } from "../maths";
3
- import { Address, BigIntish } from "../types";
3
+ import { Address } from "../types";
4
4
  export interface InputToken {
5
5
  address: Address;
6
- decimals: BigIntish;
6
+ decimals: number;
7
7
  symbol: string;
8
8
  name?: string;
9
9
  }
@@ -27,7 +27,7 @@ class Token {
27
27
  name;
28
28
  constructor({ address, decimals, symbol, name }) {
29
29
  this.address = address;
30
- this.decimals = Number(decimals);
30
+ this.decimals = decimals;
31
31
  this.symbol = symbol;
32
32
  this.name = name ?? symbol;
33
33
  }
@@ -11,7 +11,7 @@ class VaultToken extends WrappedToken_1.WrappedToken {
11
11
  super(config, config.asset);
12
12
  this.totalAssets = totalAssets;
13
13
  this.totalSupply = totalSupply;
14
- this.decimalsOffset = BigInt(config.decimalsOffset);
14
+ this.decimalsOffset = config.decimalsOffset;
15
15
  }
16
16
  _wrap(amount, rounding) {
17
17
  return VaultUtils_1.VaultUtils.toShares(amount, this, this, rounding);
@@ -1,9 +1,9 @@
1
1
  import { ChainId } from "../chain";
2
- import { Address, BigIntish } from "../types";
2
+ import { Address } from "../types";
3
3
  export interface InputVaultConfig {
4
4
  address: Address;
5
- decimals: BigIntish;
6
- decimalsOffset: BigIntish;
5
+ decimals: number;
6
+ decimalsOffset: bigint;
7
7
  symbol: string;
8
8
  name: string;
9
9
  asset: Address;
@@ -20,8 +20,8 @@ class VaultConfig {
20
20
  constructor({ address, decimals, decimalsOffset, symbol, name, asset, }, chainId) {
21
21
  this.chainId = chainId;
22
22
  this.address = address;
23
- this.decimals = Number(decimals);
24
- this.decimalsOffset = BigInt(decimalsOffset);
23
+ this.decimals = decimals;
24
+ this.decimalsOffset = decimalsOffset;
25
25
  this.symbol = symbol;
26
26
  this.name = name;
27
27
  this.asset = asset;
@@ -8,7 +8,7 @@ export declare class VaultMarketAllocation implements InputVaultMarketAllocation
8
8
  /**
9
9
  * The vault's configuration on the corresponding market.
10
10
  */
11
- readonly config: VaultMarketConfig;
11
+ config: VaultMarketConfig;
12
12
  /**
13
13
  * The vault's position on the corresponding market.
14
14
  */
@@ -8,17 +8,17 @@ export interface InputVaultMarketConfig {
8
8
  pendingCap: Pending<bigint>;
9
9
  removableAt: bigint;
10
10
  enabled: boolean;
11
- publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
11
+ publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
12
12
  }
13
13
  export declare class VaultMarketConfig implements InputVaultMarketConfig {
14
14
  /**
15
15
  * The vault's address.
16
16
  */
17
- readonly vault: Address;
17
+ vault: Address;
18
18
  /**
19
19
  * The market's id.
20
20
  */
21
- readonly marketId: MarketId;
21
+ marketId: MarketId;
22
22
  /**
23
23
  * The maximum amount of tokens that can be allocated to this market.
24
24
  */
@@ -38,6 +38,6 @@ export declare class VaultMarketConfig implements InputVaultMarketConfig {
38
38
  /**
39
39
  * The vault's PublicAllocator configuration on the corresponding market.
40
40
  */
41
- readonly publicAllocatorConfig: VaultMarketPublicAllocatorConfig;
41
+ publicAllocatorConfig?: VaultMarketPublicAllocatorConfig;
42
42
  constructor({ vault, marketId, cap, pendingCap, removableAt, enabled, publicAllocatorConfig, }: InputVaultMarketConfig);
43
43
  }
@@ -12,11 +12,11 @@ export declare class VaultMarketPublicAllocatorConfig implements InputVaultMarke
12
12
  /**
13
13
  * The vault's address.
14
14
  */
15
- readonly vault: Address;
15
+ vault: Address;
16
16
  /**
17
17
  * The market's id.
18
18
  */
19
- readonly marketId: MarketId;
19
+ marketId: MarketId;
20
20
  /**
21
21
  * The maximum amount of tokens that can be allocated to this market by the vault via the PublicAllocator.
22
22
  */
@@ -3,5 +3,4 @@ export * from "./VaultConfig";
3
3
  export * from "./VaultMarketAllocation";
4
4
  export * from "./VaultMarketConfig";
5
5
  export * from "./VaultMarketPublicAllocatorConfig";
6
- export * from "./VaultUser";
7
6
  export * from "./Vault";
@@ -19,5 +19,4 @@ __exportStar(require("./VaultConfig"), exports);
19
19
  __exportStar(require("./VaultMarketAllocation"), exports);
20
20
  __exportStar(require("./VaultMarketConfig"), exports);
21
21
  __exportStar(require("./VaultMarketPublicAllocatorConfig"), exports);
22
- __exportStar(require("./VaultUser"), exports);
23
22
  __exportStar(require("./Vault"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
- "version": "1.10.1-alpha.1",
3
+ "version": "1.10.2",
4
4
  "author": "Morpho Association <contact@morpho.org>",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -16,16 +16,16 @@
16
16
  "keccak256": "^1.0.6"
17
17
  },
18
18
  "devDependencies": {
19
- "@morpho-org/morpho-test": "^1.10.1-alpha.1",
20
- "@morpho-org/morpho-ts": "^1.10.1-alpha.1",
19
+ "@morpho-org/morpho-test": "^1.10.2",
20
+ "@morpho-org/morpho-ts": "^1.10.2",
21
21
  "@types/jest": "^29.5.12",
22
22
  "@types/node": "^22.1.0",
23
23
  "jest": "^29.7.0",
24
24
  "ts-jest": "^29.2.4",
25
- "typescript": "^5.6.2"
25
+ "typescript": "^5.4.5"
26
26
  },
27
27
  "peerDependencies": {
28
- "@morpho-org/morpho-ts": "^1.10.1-alpha.1"
28
+ "@morpho-org/morpho-ts": "^1.10.2"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
@@ -49,5 +49,5 @@
49
49
  ],
50
50
  "preset": "ts-jest"
51
51
  },
52
- "gitHead": "6681280b3518b5d46a6121430426a8dd6a3734da"
52
+ "gitHead": "0e850938a9365f171d71dd2d455ca6ebe0342cac"
53
53
  }
@@ -1,26 +0,0 @@
1
- import { Address } from "../types";
2
- export interface InputVaultUser {
3
- vault: Address;
4
- user: Address;
5
- isAllocator: boolean;
6
- allowance: bigint;
7
- }
8
- export declare class VaultUser implements InputVaultUser {
9
- /**
10
- * The vault's address.
11
- */
12
- readonly vault: Address;
13
- /**
14
- * The user's address.
15
- */
16
- readonly user: Address;
17
- /**
18
- * Whether the user is an allocator of the vault.
19
- */
20
- isAllocator: boolean;
21
- /**
22
- * The allowance of the vault over the user's underlying assets.
23
- */
24
- allowance: bigint;
25
- constructor({ vault, user, isAllocator, allowance }: InputVaultUser);
26
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VaultUser = void 0;
4
- class VaultUser {
5
- /**
6
- * The vault's address.
7
- */
8
- vault;
9
- /**
10
- * The user's address.
11
- */
12
- user;
13
- /**
14
- * Whether the user is an allocator of the vault.
15
- */
16
- isAllocator;
17
- /**
18
- * The allowance of the vault over the user's underlying assets.
19
- */
20
- allowance;
21
- constructor({ vault, user, isAllocator, allowance }) {
22
- this.vault = vault;
23
- this.user = user;
24
- this.isAllocator = isAllocator;
25
- this.allowance = allowance;
26
- }
27
- }
28
- exports.VaultUser = VaultUser;