@morpho-dev/router 0.1.9 → 0.1.11

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.
@@ -276,6 +276,7 @@ type LiquidityQueue = {
276
276
  queueId: string;
277
277
  availableLiquidityPoolId: string;
278
278
  index: number;
279
+ callbackAmount: string;
279
280
  updatedAt: Date;
280
281
  };
281
282
  type LiquidityPool = {
@@ -298,7 +299,7 @@ declare function fetch(parameters: {
298
299
  type: CallbackType;
299
300
  pairs: Array<{
300
301
  user: Address;
301
- contract: Address;
302
+ loanToken: Address;
302
303
  }>;
303
304
  options?: {
304
305
  batchSize?: number;
@@ -322,25 +323,56 @@ declare namespace Liquidity$1 {
322
323
  }
323
324
 
324
325
  declare enum CallbackType {
325
- BuyWithEmptyCallback = "buy_with_empty_callback"
326
+ BuyWithEmptyCallback = "buy_with_empty_callback",
327
+ SellWithdrawFromWallet = "sell_withdraw_from_wallet"
326
328
  }
327
- declare function buildLiquidity(parameters: {
328
- type: CallbackType;
329
- user: string;
330
- contract: string;
331
- chainId: bigint;
332
- amount: string | bigint;
329
+ declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
330
+ type BuildLiquidityParameters = {
331
+ type: CallbackType.BuyWithEmptyCallback;
332
+ user: Address;
333
+ loanToken: Address;
334
+ chainId: Chain.Id;
335
+ amount: bigint;
336
+ index?: number;
337
+ updatedAt?: Date;
338
+ } | {
339
+ type: CallbackType.SellWithdrawFromWallet;
340
+ user: Address;
341
+ termId: string;
342
+ chainId: Chain.Id;
343
+ amount: bigint;
344
+ collaterals: Array<{
345
+ collateralAddress: Address;
346
+ balance: bigint;
347
+ callbackAmount: bigint;
348
+ }>;
333
349
  index?: number;
334
350
  updatedAt?: Date;
335
- }): Liquidity;
351
+ };
352
+ declare function buildLiquidity(parameters: BuildLiquidityParameters): Liquidity;
336
353
  declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
354
+ declare function decode$1(parameters: {
355
+ type: CallbackType;
356
+ data: Hex;
357
+ }): Array<{
358
+ collateral: Address;
359
+ amount: bigint;
360
+ }>;
361
+ declare function encode$1(parameters: {
362
+ type: CallbackType;
363
+ data: {
364
+ collaterals: Address[];
365
+ amounts: bigint[];
366
+ };
367
+ }): Hex;
337
368
 
338
369
  type Callback_CallbackType = CallbackType;
339
370
  declare const Callback_CallbackType: typeof CallbackType;
371
+ declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
340
372
  declare const Callback_buildLiquidity: typeof buildLiquidity;
341
373
  declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
342
374
  declare namespace Callback {
343
- export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
375
+ export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_buildLiquidity as buildLiquidity, decode$1 as decode, encode$1 as encode, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
344
376
  }
345
377
 
346
378
  type PgDB = ReturnType<typeof drizzle> & {
@@ -570,6 +602,7 @@ declare function createChainReorgsCollector(parameters: {
570
602
  options?: {
571
603
  maxBatchSize?: number;
572
604
  interval?: number;
605
+ maxBlockNumber?: number;
573
606
  };
574
607
  }): Collector<"chain_reorgs">;
575
608
 
@@ -628,7 +661,7 @@ declare namespace Cursor$1 {
628
661
  export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
629
662
  }
630
663
 
631
- declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
664
+ declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
632
665
  type LogLevel = (typeof LogLevelValues)[number];
633
666
  type LogEntry = Compute<{
634
667
  msg: string;
@@ -1470,6 +1503,23 @@ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1470
1503
  identity: undefined;
1471
1504
  generated: undefined;
1472
1505
  }, {}, {}>;
1506
+ callbackAmount: drizzle_orm_pg_core.PgColumn<{
1507
+ name: "callback_amount";
1508
+ tableName: "available_liquidity_queues";
1509
+ dataType: "string";
1510
+ columnType: "PgNumeric";
1511
+ data: string;
1512
+ driverParam: string;
1513
+ notNull: true;
1514
+ hasDefault: true;
1515
+ isPrimaryKey: false;
1516
+ isAutoincrement: false;
1517
+ hasRuntimeDefault: false;
1518
+ enumValues: undefined;
1519
+ baseColumn: never;
1520
+ identity: undefined;
1521
+ generated: undefined;
1522
+ }, {}, {}>;
1473
1523
  updatedAt: drizzle_orm_pg_core.PgColumn<{
1474
1524
  name: "updated_at";
1475
1525
  tableName: "available_liquidity_queues";
@@ -2068,7 +2118,103 @@ declare function morpho(): (Rule<{
2068
2118
  readonly hash: viem.Hex;
2069
2119
  signature?: viem.Hex;
2070
2120
  createdAt?: number;
2071
- }, "empty_callback", MorphoContext>)[];
2121
+ }, "sell_offers_empty_callback", MorphoContext> | Rule<{
2122
+ readonly offering: Address;
2123
+ readonly assets: bigint;
2124
+ readonly rate: bigint;
2125
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2126
+ readonly expiry: number;
2127
+ readonly nonce: bigint;
2128
+ readonly buy: boolean;
2129
+ readonly chainId: bigint;
2130
+ readonly loanToken: Address;
2131
+ readonly start: number;
2132
+ readonly collaterals: readonly {
2133
+ asset: Address;
2134
+ oracle: Address;
2135
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2136
+ }[];
2137
+ readonly callback: {
2138
+ readonly address: Address;
2139
+ readonly data: viem.Hex;
2140
+ readonly gasLimit: bigint;
2141
+ };
2142
+ readonly hash: viem.Hex;
2143
+ signature?: viem.Hex;
2144
+ createdAt?: number;
2145
+ }, "buy_offers_non_empty_callback", MorphoContext> | Rule<{
2146
+ readonly offering: Address;
2147
+ readonly assets: bigint;
2148
+ readonly rate: bigint;
2149
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2150
+ readonly expiry: number;
2151
+ readonly nonce: bigint;
2152
+ readonly buy: boolean;
2153
+ readonly chainId: bigint;
2154
+ readonly loanToken: Address;
2155
+ readonly start: number;
2156
+ readonly collaterals: readonly {
2157
+ asset: Address;
2158
+ oracle: Address;
2159
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2160
+ }[];
2161
+ readonly callback: {
2162
+ readonly address: Address;
2163
+ readonly data: viem.Hex;
2164
+ readonly gasLimit: bigint;
2165
+ };
2166
+ readonly hash: viem.Hex;
2167
+ signature?: viem.Hex;
2168
+ createdAt?: number;
2169
+ }, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<{
2170
+ readonly offering: Address;
2171
+ readonly assets: bigint;
2172
+ readonly rate: bigint;
2173
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2174
+ readonly expiry: number;
2175
+ readonly nonce: bigint;
2176
+ readonly buy: boolean;
2177
+ readonly chainId: bigint;
2178
+ readonly loanToken: Address;
2179
+ readonly start: number;
2180
+ readonly collaterals: readonly {
2181
+ asset: Address;
2182
+ oracle: Address;
2183
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2184
+ }[];
2185
+ readonly callback: {
2186
+ readonly address: Address;
2187
+ readonly data: viem.Hex;
2188
+ readonly gasLimit: bigint;
2189
+ };
2190
+ readonly hash: viem.Hex;
2191
+ signature?: viem.Hex;
2192
+ createdAt?: number;
2193
+ }, "sell_offers_callback_data_invalid", MorphoContext> | Rule<{
2194
+ readonly offering: Address;
2195
+ readonly assets: bigint;
2196
+ readonly rate: bigint;
2197
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2198
+ readonly expiry: number;
2199
+ readonly nonce: bigint;
2200
+ readonly buy: boolean;
2201
+ readonly chainId: bigint;
2202
+ readonly loanToken: Address;
2203
+ readonly start: number;
2204
+ readonly collaterals: readonly {
2205
+ asset: Address;
2206
+ oracle: Address;
2207
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2208
+ }[];
2209
+ readonly callback: {
2210
+ readonly address: Address;
2211
+ readonly data: viem.Hex;
2212
+ readonly gasLimit: bigint;
2213
+ };
2214
+ readonly hash: viem.Hex;
2215
+ signature?: viem.Hex;
2216
+ createdAt?: number;
2217
+ }, "sell_offers_callback_collateral_invalid", MorphoContext>)[];
2072
2218
 
2073
2219
  type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
2074
2220
  type ValidationRule_MorphoContext = MorphoContext;
@@ -276,6 +276,7 @@ type LiquidityQueue = {
276
276
  queueId: string;
277
277
  availableLiquidityPoolId: string;
278
278
  index: number;
279
+ callbackAmount: string;
279
280
  updatedAt: Date;
280
281
  };
281
282
  type LiquidityPool = {
@@ -298,7 +299,7 @@ declare function fetch(parameters: {
298
299
  type: CallbackType;
299
300
  pairs: Array<{
300
301
  user: Address;
301
- contract: Address;
302
+ loanToken: Address;
302
303
  }>;
303
304
  options?: {
304
305
  batchSize?: number;
@@ -322,25 +323,56 @@ declare namespace Liquidity$1 {
322
323
  }
323
324
 
324
325
  declare enum CallbackType {
325
- BuyWithEmptyCallback = "buy_with_empty_callback"
326
+ BuyWithEmptyCallback = "buy_with_empty_callback",
327
+ SellWithdrawFromWallet = "sell_withdraw_from_wallet"
326
328
  }
327
- declare function buildLiquidity(parameters: {
328
- type: CallbackType;
329
- user: string;
330
- contract: string;
331
- chainId: bigint;
332
- amount: string | bigint;
329
+ declare const WhitelistedCallbackAddresses: Record<CallbackType, readonly string[]>;
330
+ type BuildLiquidityParameters = {
331
+ type: CallbackType.BuyWithEmptyCallback;
332
+ user: Address;
333
+ loanToken: Address;
334
+ chainId: Chain.Id;
335
+ amount: bigint;
336
+ index?: number;
337
+ updatedAt?: Date;
338
+ } | {
339
+ type: CallbackType.SellWithdrawFromWallet;
340
+ user: Address;
341
+ termId: string;
342
+ chainId: Chain.Id;
343
+ amount: bigint;
344
+ collaterals: Array<{
345
+ collateralAddress: Address;
346
+ balance: bigint;
347
+ callbackAmount: bigint;
348
+ }>;
333
349
  index?: number;
334
350
  updatedAt?: Date;
335
- }): Liquidity;
351
+ };
352
+ declare function buildLiquidity(parameters: BuildLiquidityParameters): Liquidity;
336
353
  declare function getCallbackIdForOffer(offer: Offer.Offer): string | null;
354
+ declare function decode$1(parameters: {
355
+ type: CallbackType;
356
+ data: Hex;
357
+ }): Array<{
358
+ collateral: Address;
359
+ amount: bigint;
360
+ }>;
361
+ declare function encode$1(parameters: {
362
+ type: CallbackType;
363
+ data: {
364
+ collaterals: Address[];
365
+ amounts: bigint[];
366
+ };
367
+ }): Hex;
337
368
 
338
369
  type Callback_CallbackType = CallbackType;
339
370
  declare const Callback_CallbackType: typeof CallbackType;
371
+ declare const Callback_WhitelistedCallbackAddresses: typeof WhitelistedCallbackAddresses;
340
372
  declare const Callback_buildLiquidity: typeof buildLiquidity;
341
373
  declare const Callback_getCallbackIdForOffer: typeof getCallbackIdForOffer;
342
374
  declare namespace Callback {
343
- export { Callback_CallbackType as CallbackType, Callback_buildLiquidity as buildLiquidity, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
375
+ export { Callback_CallbackType as CallbackType, Callback_WhitelistedCallbackAddresses as WhitelistedCallbackAddresses, Callback_buildLiquidity as buildLiquidity, decode$1 as decode, encode$1 as encode, Callback_getCallbackIdForOffer as getCallbackIdForOffer };
344
376
  }
345
377
 
346
378
  type PgDB = ReturnType<typeof drizzle> & {
@@ -570,6 +602,7 @@ declare function createChainReorgsCollector(parameters: {
570
602
  options?: {
571
603
  maxBatchSize?: number;
572
604
  interval?: number;
605
+ maxBlockNumber?: number;
573
606
  };
574
607
  }): Collector<"chain_reorgs">;
575
608
 
@@ -628,7 +661,7 @@ declare namespace Cursor$1 {
628
661
  export { type Cursor$1_Cursor as Cursor, Cursor$1_decode as decode, Cursor$1_encode as encode, Cursor$1_validate as validate };
629
662
  }
630
663
 
631
- declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
664
+ declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
632
665
  type LogLevel = (typeof LogLevelValues)[number];
633
666
  type LogEntry = Compute<{
634
667
  msg: string;
@@ -1470,6 +1503,23 @@ declare const availableLiquidityQueues: drizzle_orm_pg_core.PgTableWithColumns<{
1470
1503
  identity: undefined;
1471
1504
  generated: undefined;
1472
1505
  }, {}, {}>;
1506
+ callbackAmount: drizzle_orm_pg_core.PgColumn<{
1507
+ name: "callback_amount";
1508
+ tableName: "available_liquidity_queues";
1509
+ dataType: "string";
1510
+ columnType: "PgNumeric";
1511
+ data: string;
1512
+ driverParam: string;
1513
+ notNull: true;
1514
+ hasDefault: true;
1515
+ isPrimaryKey: false;
1516
+ isAutoincrement: false;
1517
+ hasRuntimeDefault: false;
1518
+ enumValues: undefined;
1519
+ baseColumn: never;
1520
+ identity: undefined;
1521
+ generated: undefined;
1522
+ }, {}, {}>;
1473
1523
  updatedAt: drizzle_orm_pg_core.PgColumn<{
1474
1524
  name: "updated_at";
1475
1525
  tableName: "available_liquidity_queues";
@@ -2068,7 +2118,103 @@ declare function morpho(): (Rule<{
2068
2118
  readonly hash: viem.Hex;
2069
2119
  signature?: viem.Hex;
2070
2120
  createdAt?: number;
2071
- }, "empty_callback", MorphoContext>)[];
2121
+ }, "sell_offers_empty_callback", MorphoContext> | Rule<{
2122
+ readonly offering: Address;
2123
+ readonly assets: bigint;
2124
+ readonly rate: bigint;
2125
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2126
+ readonly expiry: number;
2127
+ readonly nonce: bigint;
2128
+ readonly buy: boolean;
2129
+ readonly chainId: bigint;
2130
+ readonly loanToken: Address;
2131
+ readonly start: number;
2132
+ readonly collaterals: readonly {
2133
+ asset: Address;
2134
+ oracle: Address;
2135
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2136
+ }[];
2137
+ readonly callback: {
2138
+ readonly address: Address;
2139
+ readonly data: viem.Hex;
2140
+ readonly gasLimit: bigint;
2141
+ };
2142
+ readonly hash: viem.Hex;
2143
+ signature?: viem.Hex;
2144
+ createdAt?: number;
2145
+ }, "buy_offers_non_empty_callback", MorphoContext> | Rule<{
2146
+ readonly offering: Address;
2147
+ readonly assets: bigint;
2148
+ readonly rate: bigint;
2149
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2150
+ readonly expiry: number;
2151
+ readonly nonce: bigint;
2152
+ readonly buy: boolean;
2153
+ readonly chainId: bigint;
2154
+ readonly loanToken: Address;
2155
+ readonly start: number;
2156
+ readonly collaterals: readonly {
2157
+ asset: Address;
2158
+ oracle: Address;
2159
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2160
+ }[];
2161
+ readonly callback: {
2162
+ readonly address: Address;
2163
+ readonly data: viem.Hex;
2164
+ readonly gasLimit: bigint;
2165
+ };
2166
+ readonly hash: viem.Hex;
2167
+ signature?: viem.Hex;
2168
+ createdAt?: number;
2169
+ }, "sell_offers_non_whitelisted_callback", MorphoContext> | Rule<{
2170
+ readonly offering: Address;
2171
+ readonly assets: bigint;
2172
+ readonly rate: bigint;
2173
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2174
+ readonly expiry: number;
2175
+ readonly nonce: bigint;
2176
+ readonly buy: boolean;
2177
+ readonly chainId: bigint;
2178
+ readonly loanToken: Address;
2179
+ readonly start: number;
2180
+ readonly collaterals: readonly {
2181
+ asset: Address;
2182
+ oracle: Address;
2183
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2184
+ }[];
2185
+ readonly callback: {
2186
+ readonly address: Address;
2187
+ readonly data: viem.Hex;
2188
+ readonly gasLimit: bigint;
2189
+ };
2190
+ readonly hash: viem.Hex;
2191
+ signature?: viem.Hex;
2192
+ createdAt?: number;
2193
+ }, "sell_offers_callback_data_invalid", MorphoContext> | Rule<{
2194
+ readonly offering: Address;
2195
+ readonly assets: bigint;
2196
+ readonly rate: bigint;
2197
+ readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
2198
+ readonly expiry: number;
2199
+ readonly nonce: bigint;
2200
+ readonly buy: boolean;
2201
+ readonly chainId: bigint;
2202
+ readonly loanToken: Address;
2203
+ readonly start: number;
2204
+ readonly collaterals: readonly {
2205
+ asset: Address;
2206
+ oracle: Address;
2207
+ lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
2208
+ }[];
2209
+ readonly callback: {
2210
+ readonly address: Address;
2211
+ readonly data: viem.Hex;
2212
+ readonly gasLimit: bigint;
2213
+ };
2214
+ readonly hash: viem.Hex;
2215
+ signature?: viem.Hex;
2216
+ createdAt?: number;
2217
+ }, "sell_offers_callback_collateral_invalid", MorphoContext>)[];
2072
2218
 
2073
2219
  type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
2074
2220
  type ValidationRule_MorphoContext = MorphoContext;