@morpho-org/blue-sdk 4.0.0-next.1 → 4.0.0-next.3

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.
@@ -335,6 +335,19 @@ declare const _addressesRegistry: {
335
335
  readonly preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841";
336
336
  readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
337
337
  };
338
+ readonly 747474: {
339
+ readonly morpho: "0xD50F2DffFd62f94Ee4AEd9ca05C61d0753268aBc";
340
+ readonly bundler3: {
341
+ readonly bundler3: "0xA8C5e23C9C0DF2b6fF716486c6bBEBB6661548C8";
342
+ readonly generalAdapter1: "0x916Aa175C36E845db45fF6DDB886AE437d403B61";
343
+ };
344
+ readonly adaptiveCurveIrm: "0x4F708C0ae7deD3d74736594C2109C2E3c065B428";
345
+ readonly publicAllocator: "0x39EB6Da5e88194C82B13491Df2e8B3E213eD2412";
346
+ readonly metaMorphoFactory: "0x1c8De6889acee12257899BFeAa2b7e534de32E16";
347
+ readonly chainlinkOracleFactory: "0x7D047fB910Bc187C18C81a69E30Fa164f8c536eC";
348
+ readonly preLiquidationFactory: "0x678EB53A3bB79111263f47B84989d16D81c36D85";
349
+ readonly wNative: "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62";
350
+ };
338
351
  };
339
352
  export type AddressLabel = DottedKeys<(typeof _addressesRegistry)[ChainId]>;
340
353
  export declare const getChainAddresses: (chainId: number) => ChainAddresses;
@@ -649,6 +662,19 @@ export declare let addressesRegistry: {
649
662
  readonly preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841";
650
663
  readonly wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b";
651
664
  };
665
+ readonly 747474: {
666
+ readonly morpho: "0xD50F2DffFd62f94Ee4AEd9ca05C61d0753268aBc";
667
+ readonly bundler3: {
668
+ readonly bundler3: "0xA8C5e23C9C0DF2b6fF716486c6bBEBB6661548C8";
669
+ readonly generalAdapter1: "0x916Aa175C36E845db45fF6DDB886AE437d403B61";
670
+ };
671
+ readonly adaptiveCurveIrm: "0x4F708C0ae7deD3d74736594C2109C2E3c065B428";
672
+ readonly publicAllocator: "0x39EB6Da5e88194C82B13491Df2e8B3E213eD2412";
673
+ readonly metaMorphoFactory: "0x1c8De6889acee12257899BFeAa2b7e534de32E16";
674
+ readonly chainlinkOracleFactory: "0x7D047fB910Bc187C18C81a69E30Fa164f8c536eC";
675
+ readonly preLiquidationFactory: "0x678EB53A3bB79111263f47B84989d16D81c36D85";
676
+ readonly wNative: "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62";
677
+ };
652
678
  };
653
679
  export declare let addresses: Record<number, ChainAddresses>;
654
680
  export declare let unwrappedTokensMapping: Record<number, Record<`0x${string}`, `0x${string}`>>;
package/lib/addresses.js CHANGED
@@ -317,6 +317,19 @@ const _addressesRegistry = {
317
317
  preLiquidationFactory: "0x6C0155CC30f760DC49138B389F5B69F56eD08841",
318
318
  wNative: "0x1aE9c40eCd2DD6ad5858E5430A556d7aff28A44b",
319
319
  },
320
+ [chain_js_1.ChainId.KatanaMainnet]: {
321
+ morpho: "0xD50F2DffFd62f94Ee4AEd9ca05C61d0753268aBc",
322
+ bundler3: {
323
+ bundler3: "0xA8C5e23C9C0DF2b6fF716486c6bBEBB6661548C8",
324
+ generalAdapter1: "0x916Aa175C36E845db45fF6DDB886AE437d403B61",
325
+ },
326
+ adaptiveCurveIrm: "0x4F708C0ae7deD3d74736594C2109C2E3c065B428",
327
+ publicAllocator: "0x39EB6Da5e88194C82B13491Df2e8B3E213eD2412",
328
+ metaMorphoFactory: "0x1c8De6889acee12257899BFeAa2b7e534de32E16",
329
+ chainlinkOracleFactory: "0x7D047fB910Bc187C18C81a69E30Fa164f8c536eC",
330
+ preLiquidationFactory: "0x678EB53A3bB79111263f47B84989d16D81c36D85",
331
+ wNative: "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62",
332
+ },
320
333
  };
321
334
  const getChainAddresses = (chainId) => {
322
335
  const chainAddresses = exports.addresses[chainId];
@@ -384,6 +397,9 @@ const _unwrappedTokensMapping = {
384
397
  [chain_js_1.ChainId.CampMainnet]: {
385
398
  [_addressesRegistry[chain_js_1.ChainId.CampMainnet].wNative]: exports.NATIVE_ADDRESS,
386
399
  },
400
+ [chain_js_1.ChainId.KatanaMainnet]: {
401
+ [_addressesRegistry[chain_js_1.ChainId.KatanaMainnet].wNative]: exports.NATIVE_ADDRESS,
402
+ },
387
403
  };
388
404
  function getUnwrappedToken(wrappedToken, chainId) {
389
405
  return exports.unwrappedTokensMapping[chainId]?.[wrappedToken];
package/lib/chain.d.ts CHANGED
@@ -14,7 +14,8 @@ export declare enum ChainId {
14
14
  ModeMainnet = 34443,
15
15
  CornMainnet = 21000000,
16
16
  PlumeMainnet = 98866,
17
- CampMainnet = 123420001114
17
+ CampMainnet = 123420001114,
18
+ KatanaMainnet = 747474
18
19
  }
19
20
  export interface ChainMetadata {
20
21
  readonly name: string;
package/lib/chain.js CHANGED
@@ -19,6 +19,7 @@ var ChainId;
19
19
  ChainId[ChainId["CornMainnet"] = 21000000] = "CornMainnet";
20
20
  ChainId[ChainId["PlumeMainnet"] = 98866] = "PlumeMainnet";
21
21
  ChainId[ChainId["CampMainnet"] = 123420001114] = "CampMainnet";
22
+ ChainId[ChainId["KatanaMainnet"] = 747474] = "KatanaMainnet";
22
23
  })(ChainId || (exports.ChainId = ChainId = {}));
23
24
  var ChainUtils;
24
25
  (function (ChainUtils) {
@@ -144,8 +145,15 @@ var ChainUtils;
144
145
  name: "Camp",
145
146
  id: ChainId.CampMainnet,
146
147
  nativeCurrency: { name: "Camp", symbol: "CAMP", decimals: 18 },
147
- explorerUrl: "https://basecamp.cloud.blockscout.com/",
148
+ explorerUrl: "https://basecamp.cloud.blockscout.com",
148
149
  identifier: "camp",
149
150
  },
151
+ [ChainId.KatanaMainnet]: {
152
+ name: "Katana",
153
+ id: ChainId.KatanaMainnet,
154
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
155
+ explorerUrl: "https://explorer.katana.network",
156
+ identifier: "katana",
157
+ },
150
158
  };
151
159
  })(ChainUtils || (exports.ChainUtils = ChainUtils = {}));
package/lib/errors.d.ts CHANGED
@@ -38,7 +38,9 @@ export declare namespace BlueErrors {
38
38
  constructor(marketId: MarketId, timestamp: bigint, lastUpdate: bigint);
39
39
  }
40
40
  class InconsistentInput extends Error {
41
- constructor();
41
+ readonly assets: bigint;
42
+ readonly shares: bigint;
43
+ constructor(assets: bigint, shares: bigint);
42
44
  }
43
45
  class InsufficientLiquidity extends Error {
44
46
  readonly marketId: MarketId;
@@ -58,6 +60,10 @@ export declare namespace BlueErrors {
58
60
  readonly marketId: MarketId;
59
61
  constructor(user: Address, marketId: MarketId);
60
62
  }
63
+ class ExpiredSignature extends Error {
64
+ readonly deadline: bigint;
65
+ constructor(deadline: bigint);
66
+ }
61
67
  }
62
68
  export interface ErrorClass<E extends Error> {
63
69
  new (...args: any[]): E;
package/lib/errors.js CHANGED
@@ -79,8 +79,12 @@ var BlueErrors;
79
79
  }
80
80
  BlueErrors.InvalidInterestAccrual = InvalidInterestAccrual;
81
81
  class InconsistentInput extends Error {
82
- constructor() {
83
- super(`inconsistent input: assets & shares cannot both be zero`);
82
+ assets;
83
+ shares;
84
+ constructor(assets, shares) {
85
+ super(`inconsistent input assets "${assets}" and shares "${shares}"`);
86
+ this.assets = assets;
87
+ this.shares = shares;
84
88
  }
85
89
  }
86
90
  BlueErrors.InconsistentInput = InconsistentInput;
@@ -120,6 +124,14 @@ var BlueErrors;
120
124
  }
121
125
  }
122
126
  BlueErrors.InsufficientCollateral = InsufficientCollateral;
127
+ class ExpiredSignature extends Error {
128
+ deadline;
129
+ constructor(deadline) {
130
+ super(`expired signature deadline "${deadline}"`);
131
+ this.deadline = deadline;
132
+ }
133
+ }
134
+ BlueErrors.ExpiredSignature = ExpiredSignature;
123
135
  })(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
124
136
  function _try(accessor, ...errorClasses) {
125
137
  const maybeCatchError = (error) => {
@@ -1,6 +1,6 @@
1
1
  import { type RoundingDirection } from "../math/index.js";
2
2
  import type { BigIntish } from "../types.js";
3
- import type { MarketParams } from "./MarketParams.js";
3
+ import { type IMarketParams, MarketParams } from "./MarketParams.js";
4
4
  export declare enum CapacityLimitReason {
5
5
  liquidity = "Liquidity",
6
6
  balance = "Balance",
@@ -27,7 +27,7 @@ export interface MaxPositionCapacities {
27
27
  withdrawCollateral: CapacityLimit | undefined;
28
28
  }
29
29
  export interface IMarket {
30
- params: MarketParams;
30
+ params: IMarketParams;
31
31
  totalSupplyAssets: bigint;
32
32
  totalBorrowAssets: bigint;
33
33
  totalSupplyShares: bigint;
@@ -4,6 +4,7 @@ exports.Market = exports.CapacityLimitReason = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const errors_js_1 = require("../errors.js");
6
6
  const index_js_1 = require("../math/index.js");
7
+ const MarketParams_js_1 = require("./MarketParams.js");
7
8
  const MarketUtils_js_1 = require("./MarketUtils.js");
8
9
  var CapacityLimitReason;
9
10
  (function (CapacityLimitReason) {
@@ -56,7 +57,7 @@ class Market {
56
57
  */
57
58
  rateAtTarget;
58
59
  constructor({ params, totalSupplyAssets, totalBorrowAssets, totalSupplyShares, totalBorrowShares, lastUpdate, fee, price, rateAtTarget, }) {
59
- this.params = params;
60
+ this.params = new MarketParams_js_1.MarketParams(params);
60
61
  this.totalSupplyAssets = totalSupplyAssets;
61
62
  this.totalBorrowAssets = totalBorrowAssets;
62
63
  this.totalSupplyShares = totalSupplyShares;
@@ -211,8 +212,8 @@ class Market {
211
212
  });
212
213
  }
213
214
  supply(assets, shares, timestamp) {
214
- if (assets === 0n && shares === 0n)
215
- throw new errors_js_1.BlueErrors.InconsistentInput();
215
+ if ((assets === 0n) === (shares === 0n))
216
+ throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
216
217
  const market = this.accrueInterest(timestamp);
217
218
  if (shares === 0n)
218
219
  shares = market.toSupplyShares(assets, "Down");
@@ -223,8 +224,8 @@ class Market {
223
224
  return { market, assets, shares };
224
225
  }
225
226
  withdraw(assets, shares, timestamp) {
226
- if (assets === 0n && shares === 0n)
227
- throw new errors_js_1.BlueErrors.InconsistentInput();
227
+ if ((assets === 0n) === (shares === 0n))
228
+ throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
228
229
  const market = this.accrueInterest(timestamp);
229
230
  if (shares === 0n)
230
231
  shares = market.toSupplyShares(assets, "Up");
@@ -237,8 +238,8 @@ class Market {
237
238
  return { market, assets, shares };
238
239
  }
239
240
  borrow(assets, shares, timestamp) {
240
- if (assets === 0n && shares === 0n)
241
- throw new errors_js_1.BlueErrors.InconsistentInput();
241
+ if ((assets === 0n) === (shares === 0n))
242
+ throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
242
243
  const market = this.accrueInterest(timestamp);
243
244
  if (shares === 0n)
244
245
  shares = market.toBorrowShares(assets, "Up");
@@ -251,8 +252,8 @@ class Market {
251
252
  return { market, assets, shares };
252
253
  }
253
254
  repay(assets, shares, timestamp) {
254
- if (assets === 0n && shares === 0n)
255
- throw new errors_js_1.BlueErrors.InconsistentInput();
255
+ if ((assets === 0n) === (shares === 0n))
256
+ throw new errors_js_1.BlueErrors.InconsistentInput(assets, shares);
256
257
  const market = this.accrueInterest(timestamp);
257
258
  if (shares === 0n)
258
259
  shares = market.toBorrowShares(assets, "Down");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
3
  "description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
4
- "version": "4.0.0-next.1",
4
+ "version": "4.0.0-next.3",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -31,8 +31,8 @@
31
31
  "typescript": "^5.7.2",
32
32
  "viem": "^2.23.0",
33
33
  "vitest": "^3.0.5",
34
- "@morpho-org/morpho-ts": "^2.3.0",
35
- "@morpho-org/test": "^2.1.3"
34
+ "@morpho-org/test": "^2.1.3",
35
+ "@morpho-org/morpho-ts": "^2.3.0"
36
36
  },
37
37
  "scripts": {
38
38
  "prepublish": "$npm_execpath build",