@morpho-dev/router 0.3.0 → 0.4.1
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/README.md +67 -71
- package/dist/cli.js +3209 -1252
- package/dist/drizzle/migrations/0017_dusty_the_hunter.sql +1 -0
- package/dist/drizzle/migrations/0018_add_chain_collector_constraints.sql +3 -0
- package/dist/drizzle/migrations/0019_add-obligation-units-shares.sql +2 -0
- package/dist/drizzle/migrations/0020_add-session.sql +1 -0
- package/dist/drizzle/migrations/0021_drop_chain_collector_epoch_indexes.sql +2 -0
- package/dist/drizzle/migrations/0021_migrate-rate-to-price.sql +15 -0
- package/dist/drizzle/migrations/0022_consolidate-price.sql +15 -0
- package/dist/drizzle/migrations/meta/0017_snapshot.json +1525 -0
- package/dist/drizzle/migrations/meta/0018_snapshot.json +1572 -0
- package/dist/drizzle/migrations/meta/0019_snapshot.json +1586 -0
- package/dist/drizzle/migrations/meta/_journal.json +42 -0
- package/dist/evm/bytecode/erc20.txt +1 -0
- package/dist/evm/bytecode/factory.txt +1 -0
- package/dist/evm/bytecode/mempool.txt +1 -0
- package/dist/evm/bytecode/morpho.txt +1 -0
- package/dist/evm/bytecode/multicall3.txt +1 -0
- package/dist/evm/bytecode/oracle.txt +1 -0
- package/dist/evm/bytecode/terms.txt +1 -0
- package/dist/evm/bytecode/vault.txt +1 -0
- package/dist/evm/bytecode/vaultV1.txt +1 -0
- package/dist/index.browser.d.mts +1327 -816
- package/dist/index.browser.d.mts.map +1 -1
- package/dist/index.browser.d.ts +1358 -847
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +2209 -1668
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +2173 -1632
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.mts +1885 -1222
- package/dist/index.node.d.mts.map +1 -1
- package/dist/index.node.d.ts +1885 -1222
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +1984 -1016
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +1963 -1014
- package/dist/index.node.mjs.map +1 -1
- package/docs/integrator.md +78 -0
- package/package.json +11 -5
package/dist/index.node.d.mts
CHANGED
|
@@ -274,7 +274,7 @@ declare const Morpho: readonly [{
|
|
|
274
274
|
readonly stateMutability: "view";
|
|
275
275
|
}];
|
|
276
276
|
declare namespace Callback_d_exports {
|
|
277
|
-
export { BuyVaultV1CallbackData, CallbackType, SellERC20CallbackData, decode$
|
|
277
|
+
export { BuyVaultV1CallbackData, CallbackType, SellERC20CallbackData, decode$2 as decode, decodeBuyVaultV1Callback, decodeSellERC20Callback, encode$2 as encode, encodeBuyVaultV1Callback, encodeSellERC20Callback, isEmptyCallback };
|
|
278
278
|
}
|
|
279
279
|
declare enum CallbackType {
|
|
280
280
|
BuyWithEmptyCallback = "buy_with_empty_callback",
|
|
@@ -282,7 +282,7 @@ declare enum CallbackType {
|
|
|
282
282
|
SellERC20Callback = "sell_erc20_callback",
|
|
283
283
|
}
|
|
284
284
|
declare const isEmptyCallback: (offer: Offer) => boolean;
|
|
285
|
-
declare function decode$
|
|
285
|
+
declare function decode$2(type: CallbackType, data: Hex): {
|
|
286
286
|
contract: Address;
|
|
287
287
|
amount: bigint;
|
|
288
288
|
}[];
|
|
@@ -294,8 +294,8 @@ type SellERC20CallbackData = {
|
|
|
294
294
|
collaterals: Address[];
|
|
295
295
|
amounts: bigint[];
|
|
296
296
|
};
|
|
297
|
-
declare function encode$
|
|
298
|
-
declare function encode$
|
|
297
|
+
declare function encode$2(type: CallbackType.BuyVaultV1Callback, data: BuyVaultV1CallbackData): Hex;
|
|
298
|
+
declare function encode$2(type: CallbackType.SellERC20Callback, data: SellERC20CallbackData): Hex;
|
|
299
299
|
declare function decodeBuyVaultV1Callback(data: Hex): Array<{
|
|
300
300
|
contract: Address;
|
|
301
301
|
amount: bigint;
|
|
@@ -347,7 +347,7 @@ declare class ReorgError extends BaseError {
|
|
|
347
347
|
declare namespace Chain_d_exports {
|
|
348
348
|
export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name$1 as Name, chainIds, chainNames, chains$2 as chains, getChain, getWhitelistedChains, streamLogs };
|
|
349
349
|
}
|
|
350
|
-
type Chain$1 = Compute<Chain<ChainFormatters, {
|
|
350
|
+
type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
|
|
351
351
|
morpho: ChainContract;
|
|
352
352
|
morphoBlue: ChainContract;
|
|
353
353
|
mempool: ChainContract;
|
|
@@ -357,9 +357,20 @@ type Chain$1 = Compute<Chain<ChainFormatters, {
|
|
|
357
357
|
v1_1: ChainContract;
|
|
358
358
|
};
|
|
359
359
|
};
|
|
360
|
-
}> & {
|
|
360
|
+
}>, "custom"> & {
|
|
361
361
|
id: Id;
|
|
362
362
|
name: Name$1;
|
|
363
|
+
custom: {
|
|
364
|
+
morpho: ChainContract;
|
|
365
|
+
morphoBlue: ChainContract;
|
|
366
|
+
mempool: ChainContract;
|
|
367
|
+
vaults: {
|
|
368
|
+
factories: {
|
|
369
|
+
v1_0: ChainContract;
|
|
370
|
+
v1_1: ChainContract;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
};
|
|
363
374
|
}>;
|
|
364
375
|
declare const ChainId: {
|
|
365
376
|
readonly ETHEREUM: 1;
|
|
@@ -405,6 +416,14 @@ declare class MissingBlockNumberError extends BaseError {
|
|
|
405
416
|
name: string;
|
|
406
417
|
constructor();
|
|
407
418
|
}
|
|
419
|
+
declare namespace ChainRegistry_d_exports {
|
|
420
|
+
export { ChainRegistry, create$6 as create };
|
|
421
|
+
}
|
|
422
|
+
type ChainRegistry = {
|
|
423
|
+
getById: (chainId: Id) => Chain$1 | undefined;
|
|
424
|
+
list: () => Chain$1[];
|
|
425
|
+
};
|
|
426
|
+
declare function create$6(chains: Chain$1[]): ChainRegistry;
|
|
408
427
|
//#endregion
|
|
409
428
|
//#region src/core/types.d.ts
|
|
410
429
|
/** Combines members of an intersection into a readable type. */
|
|
@@ -414,7 +433,7 @@ type Brand<in out ID extends string | symbol> = {
|
|
|
414
433
|
readonly [BrandTypeId]: { readonly [id in ID]: ID };
|
|
415
434
|
};
|
|
416
435
|
declare namespace LLTV_d_exports {
|
|
417
|
-
export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$
|
|
436
|
+
export { InvalidLLTVError, InvalidOptionError$1 as InvalidOptionError, LLTV, LLTVSchema, Options, from$16 as from };
|
|
418
437
|
}
|
|
419
438
|
type LLTV = bigint & Brand<"LLTV">;
|
|
420
439
|
declare const Options: readonly [0.385, 0.5, 0.625, 0.77, 0.86, 0.915, 0.945, 0.965, 0.98];
|
|
@@ -424,8 +443,8 @@ type Options = (typeof Options)[number];
|
|
|
424
443
|
* @param lltv - The LLTV option or the scaled LLTV.
|
|
425
444
|
* @returns The LLTV.
|
|
426
445
|
*/
|
|
427
|
-
declare function from$
|
|
428
|
-
declare namespace from$
|
|
446
|
+
declare function from$16(lltv: Options | bigint): LLTV;
|
|
447
|
+
declare namespace from$16 {
|
|
429
448
|
type ErrorType = InvalidOptionError$1 | InvalidLLTVError;
|
|
430
449
|
}
|
|
431
450
|
declare class InvalidOptionError$1 extends BaseError {
|
|
@@ -438,7 +457,7 @@ declare class InvalidLLTVError extends BaseError {
|
|
|
438
457
|
}
|
|
439
458
|
declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
440
459
|
declare namespace Collateral_d_exports {
|
|
441
|
-
export { Collateral, CollateralSchema, CollateralsSchema, from$
|
|
460
|
+
export { Collateral, CollateralSchema, CollateralsSchema, from$15 as from, random$3 as random };
|
|
442
461
|
}
|
|
443
462
|
type Collateral = {
|
|
444
463
|
/** Asset being used as collateral. */
|
|
@@ -458,8 +477,8 @@ declare const CollateralsSchema: z$1.ZodArray<z$1.ZodObject<{
|
|
|
458
477
|
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
459
478
|
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
460
479
|
}, z$1.core.$strip>>;
|
|
461
|
-
declare const from$
|
|
462
|
-
declare namespace from$
|
|
480
|
+
declare const from$15: (parameters: from$15.Parameters) => from$15.ReturnType;
|
|
481
|
+
declare namespace from$15 {
|
|
463
482
|
type Parameters = {
|
|
464
483
|
asset: Address;
|
|
465
484
|
lltv: Options | bigint;
|
|
@@ -568,35 +587,127 @@ declare class DenominatorIsZeroError extends BaseError {
|
|
|
568
587
|
readonly name = "ERC4626.DenominatorIsZeroError";
|
|
569
588
|
constructor();
|
|
570
589
|
}
|
|
571
|
-
declare namespace
|
|
572
|
-
export {
|
|
590
|
+
declare namespace Liquidity_d_exports {
|
|
591
|
+
export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateBuyVaultCallbackPoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateSellERC20CallbackPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
|
|
573
592
|
}
|
|
574
|
-
/** The snake case representation of a type with bigint values stringified. */
|
|
575
|
-
type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
|
|
576
|
-
/** Make arrays/tuples and object props mutable, deeply. */
|
|
577
|
-
type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
|
|
578
|
-
/** Stringifies bigint values to strings and preserves branded primitives. */
|
|
579
|
-
type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
|
|
580
|
-
/** Key remapping that also preserves branded primitives. */
|
|
581
|
-
type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
|
|
582
|
-
type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
|
|
583
593
|
/**
|
|
584
|
-
*
|
|
585
|
-
* Preserves ethereum addresses as is.
|
|
586
|
-
* Converts ethereum addresses to checksummed if used as values.
|
|
587
|
-
* Stringifies bigint values to strings.
|
|
594
|
+
* Represents a liquidity pool with a unique ID and amount.
|
|
588
595
|
*/
|
|
589
|
-
|
|
596
|
+
type LiquidityPool = {
|
|
597
|
+
id: string;
|
|
598
|
+
amount: bigint;
|
|
599
|
+
};
|
|
590
600
|
/**
|
|
591
|
-
*
|
|
592
|
-
* Preserves ethereum addresses as is.
|
|
593
|
-
* Converts checksummed ethereum addresses to lowercase if used as values.
|
|
594
|
-
* @warning Does not unstringify bigint values.
|
|
601
|
+
* Represents a hierarchical relationship between two liquidity pools.
|
|
595
602
|
*/
|
|
596
|
-
|
|
597
|
-
|
|
603
|
+
type LiquidityLink = {
|
|
604
|
+
parentPoolId: string;
|
|
605
|
+
childPoolId: string;
|
|
606
|
+
priority: number;
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Represents the connection between an offer and its liquidity pools.
|
|
610
|
+
*/
|
|
611
|
+
type OfferLiquidityPool = {
|
|
612
|
+
offerHash: Hex;
|
|
613
|
+
poolId: string;
|
|
614
|
+
/**
|
|
615
|
+
* The available capacity/liquidity from this pool for this offer.
|
|
616
|
+
* Meaning varies by pool type:
|
|
617
|
+
* - BuyWithEmptyCallback: Matches allowance amount from pool bellow
|
|
618
|
+
* - SellERC20Callback: Sell Callback/Predeposited -> Maximum debt capacity calculated from collateral (collateralAmount * oraclePrice * lltv)
|
|
619
|
+
* - SellERC20Callback: Existing debt as negative value (reduces available capacity)
|
|
620
|
+
*/
|
|
621
|
+
amount: bigint;
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* Calculate maximum debt capacity from collateral amount.
|
|
625
|
+
* @param amount - Collateral amount
|
|
626
|
+
* @param oraclePrice - Oracle price (scaled to 36 decimals)
|
|
627
|
+
* @param lltv - Loan-to-value ratio (scaled to 18 decimals)
|
|
628
|
+
* @returns Maximum debt capacity
|
|
629
|
+
*/
|
|
630
|
+
declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
|
|
631
|
+
/**
|
|
632
|
+
* Generate pool ID for balance pools.
|
|
633
|
+
*/
|
|
634
|
+
declare function generateBalancePoolId(parameters: {
|
|
635
|
+
user: Address;
|
|
636
|
+
chainId: Id;
|
|
637
|
+
token: Address;
|
|
638
|
+
}): string;
|
|
639
|
+
/**
|
|
640
|
+
* Generate pool ID for allowance pools.
|
|
641
|
+
*/
|
|
642
|
+
declare function generateAllowancePoolId(parameters: {
|
|
643
|
+
user: Address;
|
|
644
|
+
chainId: Id;
|
|
645
|
+
token: Address;
|
|
646
|
+
}): string;
|
|
647
|
+
/**
|
|
648
|
+
* Generate pool ID for sell ERC20 callback pools.
|
|
649
|
+
* Each offer has its own callback pool to prevent liquidity conflicts.
|
|
650
|
+
*/
|
|
651
|
+
declare function generateSellERC20CallbackPoolId(parameters: {
|
|
652
|
+
user: Address;
|
|
653
|
+
chainId: Id;
|
|
654
|
+
obligationId: Hex;
|
|
655
|
+
token: Address;
|
|
656
|
+
offerHash: Hex;
|
|
657
|
+
}): string;
|
|
658
|
+
/**
|
|
659
|
+
* Generate pool ID for obligation collateral pools.
|
|
660
|
+
* Obligation collateral pools represent collateral already deposited in the obligation.
|
|
661
|
+
* These pools are shared across all offers with the same obligation.
|
|
662
|
+
*/
|
|
663
|
+
declare function generateObligationCollateralPoolId(parameters: {
|
|
664
|
+
user: Address;
|
|
665
|
+
chainId: Id;
|
|
666
|
+
obligationId: Hex;
|
|
667
|
+
token: Address;
|
|
668
|
+
}): string;
|
|
669
|
+
/**
|
|
670
|
+
* Generate pool ID for buy vault callback pools.
|
|
671
|
+
*/
|
|
672
|
+
declare function generateBuyVaultCallbackPoolId(parameters: {
|
|
673
|
+
user: Address;
|
|
674
|
+
chainId: Id;
|
|
675
|
+
vault: Address;
|
|
676
|
+
offerHash: Hex;
|
|
677
|
+
}): string;
|
|
678
|
+
/**
|
|
679
|
+
* Generate pool ID for debt pools.
|
|
680
|
+
*/
|
|
681
|
+
declare function generateDebtPoolId(parameters: {
|
|
682
|
+
user: Address;
|
|
683
|
+
chainId: Id;
|
|
684
|
+
obligationId: Hex;
|
|
685
|
+
}): string;
|
|
686
|
+
/**
|
|
687
|
+
* Generate pool ID for user position in a vault.
|
|
688
|
+
*/
|
|
689
|
+
declare function generateUserVaultPositionPoolId(parameters: {
|
|
690
|
+
user: Address;
|
|
691
|
+
chainId: Id;
|
|
692
|
+
vault: Address;
|
|
693
|
+
}): string;
|
|
694
|
+
/**
|
|
695
|
+
* Generate pool ID for vault position in a market.
|
|
696
|
+
*/
|
|
697
|
+
declare function generateVaultPositionPoolId(parameters: {
|
|
698
|
+
vault: Address;
|
|
699
|
+
chainId: Id;
|
|
700
|
+
marketId: string;
|
|
701
|
+
}): string;
|
|
702
|
+
/**
|
|
703
|
+
* Generate pool ID for market total liquidity.
|
|
704
|
+
*/
|
|
705
|
+
declare function generateMarketLiquidityPoolId(parameters: {
|
|
706
|
+
chainId: Id;
|
|
707
|
+
marketId: string;
|
|
708
|
+
}): string;
|
|
598
709
|
declare namespace Maturity_d_exports {
|
|
599
|
-
export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$
|
|
710
|
+
export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$14 as from };
|
|
600
711
|
}
|
|
601
712
|
/**
|
|
602
713
|
* Maturity is a number that represents a date in seconds.
|
|
@@ -626,8 +737,8 @@ type MaturityOptions = keyof typeof MaturityOptions;
|
|
|
626
737
|
* @throws {InvalidDateError} If the maturity is in seconds but not a valid date.
|
|
627
738
|
* @throws {InvalidOptionError} If the maturity is not a valid option.
|
|
628
739
|
*/
|
|
629
|
-
declare function from$
|
|
630
|
-
declare namespace from$
|
|
740
|
+
declare function from$14(ts: from$14.Parameters): Maturity;
|
|
741
|
+
declare namespace from$14 {
|
|
631
742
|
type Parameters = number | MaturityOptions;
|
|
632
743
|
type ErrorType = InvalidFormatError | InvalidDateError | InvalidOptionError;
|
|
633
744
|
}
|
|
@@ -643,72 +754,47 @@ declare class InvalidOptionError extends BaseError {
|
|
|
643
754
|
readonly name = "Maturity.InvalidOptionError";
|
|
644
755
|
constructor(input: string);
|
|
645
756
|
}
|
|
646
|
-
declare namespace
|
|
647
|
-
export {
|
|
757
|
+
declare namespace Format_d_exports {
|
|
758
|
+
export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
|
|
648
759
|
}
|
|
649
|
-
type
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
/** The exact set of collaterals required to borrow the loan token. */
|
|
676
|
-
readonly collaterals: readonly Collateral[];
|
|
677
|
-
/** The optional callback data to retrieve the maker funds. */
|
|
678
|
-
readonly callback: {
|
|
679
|
-
readonly address: Address;
|
|
680
|
-
readonly data: Hex;
|
|
681
|
-
readonly gasLimit: bigint;
|
|
682
|
-
};
|
|
683
|
-
/** The amount of assets consumed from the offer. */
|
|
684
|
-
consumed: bigint;
|
|
685
|
-
/** The hash of the offer. */
|
|
686
|
-
readonly hash: Hex;
|
|
687
|
-
/** The block number at which the offer was created. */
|
|
688
|
-
readonly blockNumber: number;
|
|
689
|
-
/** The signature of the offer. */
|
|
690
|
-
signature?: Hex;
|
|
691
|
-
};
|
|
692
|
-
declare enum Status {
|
|
693
|
-
VALID = "VALID",
|
|
694
|
-
SIMULATION_ERROR = "SIMULATION_ERROR",
|
|
760
|
+
/** The snake case representation of a type with bigint values stringified. */
|
|
761
|
+
type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
|
|
762
|
+
/** Make arrays/tuples and object props mutable, deeply. */
|
|
763
|
+
type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
|
|
764
|
+
/** Stringifies bigint values to strings and preserves branded primitives. */
|
|
765
|
+
type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
|
|
766
|
+
/** Key remapping that also preserves branded primitives. */
|
|
767
|
+
type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
|
|
768
|
+
type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
|
|
769
|
+
/**
|
|
770
|
+
* Formats object keys to snake case.
|
|
771
|
+
* Preserves ethereum addresses as is.
|
|
772
|
+
* Converts ethereum addresses to checksummed if used as values.
|
|
773
|
+
* Stringifies bigint values to strings.
|
|
774
|
+
*/
|
|
775
|
+
declare function toSnakeCase$1<T>(obj: T): Snake<T>;
|
|
776
|
+
/**
|
|
777
|
+
* Formats a snake case object to its camel case type.
|
|
778
|
+
* Preserves ethereum addresses as is.
|
|
779
|
+
* Converts checksummed ethereum addresses to lowercase if used as values.
|
|
780
|
+
* @warning Does not unstringify bigint values.
|
|
781
|
+
*/
|
|
782
|
+
declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
|
|
783
|
+
declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
|
|
784
|
+
declare namespace Obligation_d_exports {
|
|
785
|
+
export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$13 as from, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
|
|
695
786
|
}
|
|
696
|
-
type
|
|
697
|
-
|
|
698
|
-
|
|
787
|
+
type Obligation = {
|
|
788
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
789
|
+
chainId: Id;
|
|
790
|
+
/** The token that is being borrowed for this obligation. */
|
|
791
|
+
loanToken: Address;
|
|
792
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
793
|
+
collaterals: Collateral[];
|
|
794
|
+
/** The maturity of the obligation. */
|
|
795
|
+
maturity: Maturity;
|
|
699
796
|
};
|
|
700
|
-
declare const
|
|
701
|
-
declare const OfferSchema: (parameters?: {
|
|
702
|
-
omitHash?: boolean;
|
|
703
|
-
}) => z$1.ZodObject<{
|
|
704
|
-
offering: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
705
|
-
assets: z$1.ZodBigInt;
|
|
706
|
-
rate: z$1.ZodBigInt;
|
|
707
|
-
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
708
|
-
expiry: z$1.ZodNumber;
|
|
709
|
-
start: z$1.ZodNumber;
|
|
710
|
-
nonce: z$1.ZodBigInt;
|
|
711
|
-
buy: z$1.ZodBoolean;
|
|
797
|
+
declare const ObligationSchema: z$1.ZodObject<{
|
|
712
798
|
chainId: z$1.ZodNumber;
|
|
713
799
|
loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
714
800
|
collaterals: z$1.ZodArray<z$1.ZodObject<{
|
|
@@ -716,36 +802,220 @@ declare const OfferSchema: (parameters?: {
|
|
|
716
802
|
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
717
803
|
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
718
804
|
}, z$1.core.$strip>>;
|
|
719
|
-
|
|
720
|
-
address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
721
|
-
data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
722
|
-
gasLimit: z$1.ZodBigInt;
|
|
723
|
-
}, z$1.core.$strip>;
|
|
724
|
-
signature: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
725
|
-
consumed: z$1.ZodOptional<z$1.ZodBigInt>;
|
|
726
|
-
takeable: z$1.ZodOptional<z$1.ZodBigInt>;
|
|
727
|
-
blockNumber: z$1.ZodOptional<z$1.ZodNumber>;
|
|
805
|
+
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
728
806
|
}, z$1.core.$strip>;
|
|
729
807
|
/**
|
|
730
|
-
* Creates an
|
|
731
|
-
* @
|
|
732
|
-
* @param
|
|
733
|
-
* @returns The created
|
|
808
|
+
* Creates an obligation from the given parameters.
|
|
809
|
+
* @constructor
|
|
810
|
+
* @param parameters - {@link from.Parameters}
|
|
811
|
+
* @returns The created obligation. {@link Obligation}
|
|
812
|
+
* @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```ts
|
|
816
|
+
* const obligation = Obligation.from({
|
|
817
|
+
* chainId: 1,
|
|
818
|
+
* loanToken: privateKeyToAccount(generatePrivateKey()).address,
|
|
819
|
+
* collaterals: [
|
|
820
|
+
* Collateral.from({
|
|
821
|
+
* asset: privateKeyToAccount(generatePrivateKey()).address,
|
|
822
|
+
* oracle: privateKeyToAccount(generatePrivateKey()).address,
|
|
823
|
+
* lltv: 0.965
|
|
824
|
+
* }),
|
|
825
|
+
* ],
|
|
826
|
+
* maturity: Maturity.from("end_of_next_quarter"),
|
|
827
|
+
* });
|
|
828
|
+
* ```
|
|
734
829
|
*/
|
|
735
|
-
declare function from$
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
830
|
+
declare function from$13(parameters: from$13.Parameters): from$13.ReturnType;
|
|
831
|
+
declare namespace from$13 {
|
|
832
|
+
type Parameters = {
|
|
833
|
+
/** The chain id where the liquidity for this obligation is located. */
|
|
834
|
+
chainId: number;
|
|
835
|
+
/** The token that is being borrowed for this obligation. */
|
|
836
|
+
loanToken: Address;
|
|
837
|
+
/** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
|
|
838
|
+
collaterals: from$15.Parameters[] | readonly from$15.Parameters[];
|
|
839
|
+
/** The maturity of the obligation. */
|
|
840
|
+
maturity: from$14.Parameters;
|
|
841
|
+
};
|
|
842
|
+
type ReturnType = Obligation;
|
|
843
|
+
type ErrorType = InvalidObligationError;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Creates an obligation from a snake case object.
|
|
847
|
+
* @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
|
|
848
|
+
* @param input - {@link fromSnakeCase.Parameters}
|
|
849
|
+
* @returns The created obligation. {@link fromSnakeCase.ReturnType}
|
|
850
|
+
*/
|
|
851
|
+
declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
|
|
852
|
+
declare namespace fromSnakeCase$2 {
|
|
853
|
+
type Parameters = Snake<Omit<Obligation, "chainId"> & {
|
|
854
|
+
chainId: number;
|
|
855
|
+
}>;
|
|
856
|
+
type ReturnType = Obligation;
|
|
857
|
+
type ErrorType = InvalidObligationError;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Calculates the obligation id based on the smart contract's Obligation struct.
|
|
861
|
+
* The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
|
|
862
|
+
* @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
|
|
863
|
+
* @param parameters - {@link id.Parameters}
|
|
864
|
+
* @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```ts
|
|
868
|
+
* const obligation = Obligation.random();
|
|
869
|
+
* const id = Obligation.id(obligation);
|
|
870
|
+
* console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
|
|
871
|
+
* ```
|
|
872
|
+
*/
|
|
873
|
+
declare function id(parameters: id.Parameters): id.ReturnType;
|
|
874
|
+
declare namespace id {
|
|
875
|
+
type Parameters = {
|
|
876
|
+
chainId: number;
|
|
877
|
+
loanToken: Address;
|
|
878
|
+
collaterals: {
|
|
879
|
+
asset: Address;
|
|
880
|
+
lltv: bigint;
|
|
881
|
+
oracle: Address;
|
|
882
|
+
}[];
|
|
883
|
+
maturity: number;
|
|
884
|
+
};
|
|
885
|
+
type ReturnType = Hex;
|
|
886
|
+
type ErrorType = CollateralsAreNotSortedError;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Generates a random obligation.
|
|
890
|
+
* @returns A randomly generated obligation. {@link random.ReturnType}
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```ts
|
|
894
|
+
* const obligation = Obligation.random();
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
declare function random$2(): random$2.ReturnType;
|
|
898
|
+
declare namespace random$2 {
|
|
899
|
+
type ReturnType = Obligation;
|
|
900
|
+
}
|
|
901
|
+
declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
|
|
902
|
+
readonly name = "Obligation.InvalidObligationError";
|
|
903
|
+
constructor(error: z$1.ZodError | Error);
|
|
904
|
+
}
|
|
905
|
+
declare class CollateralsAreNotSortedError extends BaseError {
|
|
906
|
+
readonly name = "Obligation.CollateralsAreNotSortedError";
|
|
907
|
+
constructor();
|
|
908
|
+
}
|
|
909
|
+
declare namespace Offer_d_exports {
|
|
910
|
+
export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, domain, encode$1 as encode, from$12 as from, fromSnakeCase$1 as fromSnakeCase, hash, obligationId, random$1 as random, serialize, sign, signatureMsg, toSnakeCase, types };
|
|
911
|
+
}
|
|
912
|
+
type Offer = {
|
|
913
|
+
/** The address that made the offer. */
|
|
914
|
+
readonly maker: Address;
|
|
915
|
+
/** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
|
|
916
|
+
readonly assets: bigint;
|
|
917
|
+
/** The max debt units to trade. Mutually exclusive with assets and obligationShares. */
|
|
918
|
+
readonly obligationUnits: bigint;
|
|
919
|
+
/** The max lending shares to trade. Mutually exclusive with assets and obligationUnits. */
|
|
920
|
+
readonly obligationShares: bigint;
|
|
921
|
+
/** The price (18 decimals). */
|
|
922
|
+
readonly price: bigint;
|
|
923
|
+
/** The date at which all interests will be paid. */
|
|
924
|
+
readonly maturity: Maturity;
|
|
925
|
+
/** The date at which the offer will expire. */
|
|
926
|
+
readonly expiry: number;
|
|
927
|
+
/** The date at which the offer will start. */
|
|
928
|
+
readonly start: number;
|
|
929
|
+
/** The group. Used for OCO (One-Cancelled-Other) mechanism. */
|
|
930
|
+
readonly group: Hex;
|
|
931
|
+
/** The session. Used for session-based offer management. */
|
|
932
|
+
readonly session: Hex;
|
|
933
|
+
/** The side of the offer. `true` for buy, `false` for sell. */
|
|
934
|
+
readonly buy: boolean;
|
|
935
|
+
/** The chain id where the liquidity for this offer is located. */
|
|
936
|
+
readonly chainId: Id;
|
|
937
|
+
/** The token that is being borrowed. */
|
|
938
|
+
readonly loanToken: Address;
|
|
939
|
+
/** The exact set of collaterals required to borrow the loan token. */
|
|
940
|
+
readonly collaterals: readonly Collateral[];
|
|
941
|
+
/** The optional callback data to retrieve the maker funds. */
|
|
942
|
+
readonly callback: {
|
|
943
|
+
readonly address: Address;
|
|
944
|
+
readonly data: Hex;
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
declare enum Status {
|
|
948
|
+
VALID = "VALID",
|
|
949
|
+
SIMULATION_ERROR = "SIMULATION_ERROR",
|
|
950
|
+
}
|
|
951
|
+
type Validation = {
|
|
952
|
+
offerHash: Hex;
|
|
953
|
+
status: Status;
|
|
954
|
+
};
|
|
955
|
+
declare const OfferSchema: () => z$1.ZodObject<{
|
|
956
|
+
maker: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
957
|
+
assets: z$1.ZodBigInt;
|
|
958
|
+
obligationUnits: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBigInt>>;
|
|
959
|
+
obligationShares: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBigInt>>;
|
|
960
|
+
price: z$1.ZodBigInt;
|
|
961
|
+
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
962
|
+
expiry: z$1.ZodNumber;
|
|
963
|
+
start: z$1.ZodNumber;
|
|
964
|
+
group: z$1.ZodPipe<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
|
|
965
|
+
session: z$1.ZodPipe<z$1.ZodDefault<z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>>>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
|
|
966
|
+
buy: z$1.ZodBoolean;
|
|
967
|
+
chainId: z$1.ZodNumber;
|
|
968
|
+
loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
969
|
+
collaterals: z$1.ZodArray<z$1.ZodObject<{
|
|
970
|
+
asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
971
|
+
oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
972
|
+
lltv: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
|
|
973
|
+
}, z$1.core.$strip>>;
|
|
974
|
+
callback: z$1.ZodObject<{
|
|
975
|
+
address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
976
|
+
data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
977
|
+
}, z$1.core.$strip>;
|
|
978
|
+
}, z$1.core.$strip>;
|
|
979
|
+
/**
|
|
980
|
+
* Input type for creating offers. Accepts flexible group types that will be coerced to Hex.
|
|
981
|
+
*
|
|
982
|
+
* The `group` field accepts multiple input formats:
|
|
983
|
+
* - **Hex string** (`0x...`): Padded to 32 bytes if needed
|
|
984
|
+
* - **Numeric string**: Converted to hex (e.g., `"123"` -> `"0x...7b"`)
|
|
985
|
+
* - **Number**: Non-negative safe integer, converted to hex
|
|
986
|
+
* - **BigInt**: Non-negative, must fit in bytes32
|
|
987
|
+
*
|
|
988
|
+
* All values validated to be non-negative and within bytes32 range.
|
|
989
|
+
*/
|
|
990
|
+
type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares"> & {
|
|
991
|
+
chainId: number;
|
|
992
|
+
group: Hex | bigint | number | string;
|
|
993
|
+
/** Optional: defaults to zero bytes32. */
|
|
994
|
+
session?: Hex | bigint | number | string;
|
|
995
|
+
/** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
|
|
996
|
+
obligationUnits?: bigint;
|
|
997
|
+
/** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
|
|
998
|
+
obligationShares?: bigint;
|
|
999
|
+
}>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Creates an offer from a plain object.
|
|
1002
|
+
* @throws {InvalidOfferError} If the offer is invalid.
|
|
1003
|
+
* @param input - The offer to create.
|
|
1004
|
+
* @returns The created offer.
|
|
1005
|
+
*/
|
|
1006
|
+
declare function from$12(input: OfferInput): Offer;
|
|
1007
|
+
declare namespace from$12 {
|
|
1008
|
+
type ErrorType = InvalidOfferError;
|
|
740
1009
|
}
|
|
741
1010
|
/**
|
|
742
1011
|
* Creates an offer from a snake case object.
|
|
743
1012
|
* @throws {InvalidOfferError} If the offer is invalid.
|
|
744
1013
|
* @param input - The offer to create.
|
|
745
|
-
* @returns The created offer
|
|
1014
|
+
* @returns The created offer.
|
|
746
1015
|
*/
|
|
747
|
-
declare function fromSnakeCase$
|
|
1016
|
+
declare function fromSnakeCase$1(input: Snake<Omit<Offer, "chainId" | "session"> & {
|
|
748
1017
|
chainId: number;
|
|
1018
|
+
session: string;
|
|
749
1019
|
}>): Offer;
|
|
750
1020
|
/**
|
|
751
1021
|
* Converts an offer to a snake case object.
|
|
@@ -761,13 +1031,16 @@ declare function toSnakeCase(offer: Offer): Snake<Offer>;
|
|
|
761
1031
|
* @returns JSON-serializable offer object
|
|
762
1032
|
*/
|
|
763
1033
|
declare const serialize: (offer: Offer) => {
|
|
764
|
-
|
|
1034
|
+
maker: `0x${string}`;
|
|
765
1035
|
assets: string;
|
|
766
|
-
|
|
1036
|
+
obligationUnits: string;
|
|
1037
|
+
obligationShares: string;
|
|
1038
|
+
price: string;
|
|
767
1039
|
maturity: number;
|
|
768
1040
|
expiry: number;
|
|
769
1041
|
start: number;
|
|
770
|
-
|
|
1042
|
+
group: `0x${string}`;
|
|
1043
|
+
session: `0x${string}`;
|
|
771
1044
|
buy: boolean;
|
|
772
1045
|
chainId: Id;
|
|
773
1046
|
loanToken: `0x${string}`;
|
|
@@ -779,9 +1052,7 @@ declare const serialize: (offer: Offer) => {
|
|
|
779
1052
|
callback: {
|
|
780
1053
|
address: `0x${string}`;
|
|
781
1054
|
data: `0x${string}`;
|
|
782
|
-
gasLimit: string;
|
|
783
1055
|
};
|
|
784
|
-
signature: `0x${string}` | undefined;
|
|
785
1056
|
hash: `0x${string}`;
|
|
786
1057
|
};
|
|
787
1058
|
type RandomConfig = {
|
|
@@ -791,22 +1062,20 @@ type RandomConfig = {
|
|
|
791
1062
|
assetsDecimals?: Record<Address, number>;
|
|
792
1063
|
buy?: boolean;
|
|
793
1064
|
assets?: bigint;
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
1065
|
+
obligationUnits?: bigint;
|
|
1066
|
+
obligationShares?: bigint;
|
|
1067
|
+
maker?: Address;
|
|
797
1068
|
maturity?: Maturity;
|
|
798
1069
|
start?: number;
|
|
799
1070
|
expiry?: number;
|
|
800
|
-
|
|
801
|
-
|
|
1071
|
+
group?: Hex | bigint | number | string;
|
|
1072
|
+
session?: Hex | bigint | number | string;
|
|
1073
|
+
price?: bigint;
|
|
802
1074
|
callback?: {
|
|
803
1075
|
address: Address;
|
|
804
1076
|
data: Hex;
|
|
805
|
-
gasLimit: bigint;
|
|
806
1077
|
};
|
|
807
1078
|
collaterals?: readonly Collateral[];
|
|
808
|
-
signature?: Hex;
|
|
809
|
-
blockNumber?: number;
|
|
810
1079
|
};
|
|
811
1080
|
/**
|
|
812
1081
|
* Generates a random Offer.
|
|
@@ -814,7 +1083,7 @@ type RandomConfig = {
|
|
|
814
1083
|
* @warning The generated Offer should not be used for production usage.
|
|
815
1084
|
* @returns {Offer} A randomly generated Offer object.
|
|
816
1085
|
*/
|
|
817
|
-
declare function random$
|
|
1086
|
+
declare function random$1(config?: RandomConfig): Offer;
|
|
818
1087
|
/**
|
|
819
1088
|
* Creates an EIP-712 domain object.
|
|
820
1089
|
* @param chainId - The chain ID.
|
|
@@ -838,13 +1107,19 @@ declare const types: {
|
|
|
838
1107
|
readonly type: "address";
|
|
839
1108
|
}];
|
|
840
1109
|
readonly Offer: readonly [{
|
|
841
|
-
readonly name: "
|
|
1110
|
+
readonly name: "maker";
|
|
842
1111
|
readonly type: "address";
|
|
843
1112
|
}, {
|
|
844
1113
|
readonly name: "assets";
|
|
845
1114
|
readonly type: "uint256";
|
|
846
1115
|
}, {
|
|
847
|
-
readonly name: "
|
|
1116
|
+
readonly name: "obligationUnits";
|
|
1117
|
+
readonly type: "uint256";
|
|
1118
|
+
}, {
|
|
1119
|
+
readonly name: "obligationShares";
|
|
1120
|
+
readonly type: "uint256";
|
|
1121
|
+
}, {
|
|
1122
|
+
readonly name: "price";
|
|
848
1123
|
readonly type: "uint256";
|
|
849
1124
|
}, {
|
|
850
1125
|
readonly name: "maturity";
|
|
@@ -853,8 +1128,11 @@ declare const types: {
|
|
|
853
1128
|
readonly name: "expiry";
|
|
854
1129
|
readonly type: "uint256";
|
|
855
1130
|
}, {
|
|
856
|
-
readonly name: "
|
|
857
|
-
readonly type: "
|
|
1131
|
+
readonly name: "group";
|
|
1132
|
+
readonly type: "bytes32";
|
|
1133
|
+
}, {
|
|
1134
|
+
readonly name: "session";
|
|
1135
|
+
readonly type: "bytes32";
|
|
858
1136
|
}, {
|
|
859
1137
|
readonly name: "buy";
|
|
860
1138
|
readonly type: "bool";
|
|
@@ -884,9 +1162,6 @@ declare const types: {
|
|
|
884
1162
|
}, {
|
|
885
1163
|
readonly name: "data";
|
|
886
1164
|
readonly type: "bytes";
|
|
887
|
-
}, {
|
|
888
|
-
readonly name: "gasLimit";
|
|
889
|
-
readonly type: "uint256";
|
|
890
1165
|
}];
|
|
891
1166
|
};
|
|
892
1167
|
/**
|
|
@@ -898,7 +1173,7 @@ declare const types: {
|
|
|
898
1173
|
*/
|
|
899
1174
|
declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
|
|
900
1175
|
declare function signatureMsg(offers: Offer[]): Hex;
|
|
901
|
-
declare function hash(offer:
|
|
1176
|
+
declare function hash(offer: Offer): Hex;
|
|
902
1177
|
/**
|
|
903
1178
|
* Calculates the obligation id for an offer based on the smart contract's Obligation struct.
|
|
904
1179
|
* The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
|
|
@@ -906,32 +1181,32 @@ declare function hash(offer: Omit<Offer, "hash">): Hex;
|
|
|
906
1181
|
* @returns The obligation id as a 32-byte hex string.
|
|
907
1182
|
*/
|
|
908
1183
|
declare function obligationId(offer: Offer): Hex;
|
|
909
|
-
declare function encode$
|
|
910
|
-
declare function decode$
|
|
1184
|
+
declare function encode$1(offer: Offer): `0x${string}`;
|
|
1185
|
+
declare function decode$1(data: Hex): Offer;
|
|
911
1186
|
type OfferConsumed = {
|
|
912
1187
|
id: string;
|
|
913
1188
|
chainId: Id;
|
|
914
|
-
|
|
915
|
-
|
|
1189
|
+
maker: Address;
|
|
1190
|
+
group: Hex;
|
|
916
1191
|
amount: bigint;
|
|
917
1192
|
blockNumber: number;
|
|
918
1193
|
};
|
|
919
1194
|
/**
|
|
920
|
-
* ABI for the
|
|
1195
|
+
* ABI for the Consume event emitted by the Obligation contract.
|
|
921
1196
|
*/
|
|
922
1197
|
declare const consumedEvent: {
|
|
923
1198
|
readonly type: "event";
|
|
924
|
-
readonly name: "
|
|
1199
|
+
readonly name: "Consume";
|
|
925
1200
|
readonly inputs: readonly [{
|
|
926
1201
|
readonly name: "user";
|
|
927
1202
|
readonly type: "address";
|
|
928
1203
|
readonly indexed: true;
|
|
929
1204
|
readonly internalType: "address";
|
|
930
1205
|
}, {
|
|
931
|
-
readonly name: "
|
|
932
|
-
readonly type: "
|
|
1206
|
+
readonly name: "group";
|
|
1207
|
+
readonly type: "bytes32";
|
|
933
1208
|
readonly indexed: true;
|
|
934
|
-
readonly internalType: "
|
|
1209
|
+
readonly internalType: "bytes32";
|
|
935
1210
|
}, {
|
|
936
1211
|
readonly name: "amount";
|
|
937
1212
|
readonly type: "uint256";
|
|
@@ -959,463 +1234,228 @@ declare class AccountNotSetError extends BaseError {
|
|
|
959
1234
|
readonly name = "Offer.AccountNotSetError";
|
|
960
1235
|
constructor();
|
|
961
1236
|
}
|
|
962
|
-
declare namespace
|
|
963
|
-
export {
|
|
1237
|
+
declare namespace Oracle_d_exports {
|
|
1238
|
+
export { Conversion, Oracle, from$11 as from };
|
|
964
1239
|
}
|
|
965
1240
|
/**
|
|
966
|
-
*
|
|
1241
|
+
* An oracle contract that provides price information for assets.
|
|
967
1242
|
*/
|
|
968
|
-
type
|
|
969
|
-
id
|
|
970
|
-
|
|
1243
|
+
type Oracle = {
|
|
1244
|
+
/** The chain id where the oracle is deployed. */
|
|
1245
|
+
readonly chainId: Id;
|
|
1246
|
+
/** The address of the oracle contract. */
|
|
1247
|
+
readonly address: Address;
|
|
1248
|
+
/** The price returned by the oracle (in the oracle's native units), null if no price available. */
|
|
1249
|
+
readonly price: bigint | null;
|
|
1250
|
+
/** The block number at which the price was fetched. */
|
|
1251
|
+
readonly blockNumber: number;
|
|
971
1252
|
};
|
|
972
1253
|
/**
|
|
973
|
-
*
|
|
1254
|
+
* Create an Oracle from a plain object.
|
|
1255
|
+
* @param data - The data to create the oracle from.
|
|
1256
|
+
* @returns The created oracle.
|
|
974
1257
|
*/
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1258
|
+
declare function from$11(data: from$11.Parameters): from$11.ReturnType;
|
|
1259
|
+
declare namespace from$11 {
|
|
1260
|
+
type Parameters = {
|
|
1261
|
+
chainId: Id;
|
|
1262
|
+
address: Address;
|
|
1263
|
+
price: string | null;
|
|
1264
|
+
blockNumber: number;
|
|
1265
|
+
};
|
|
1266
|
+
type ReturnType = Oracle;
|
|
1267
|
+
}
|
|
980
1268
|
/**
|
|
981
|
-
*
|
|
1269
|
+
* Conversion utilities for converting between collateral and loan token amounts
|
|
1270
|
+
* using oracle prices and LLTV
|
|
982
1271
|
*/
|
|
983
|
-
|
|
984
|
-
offerHash: Offer["hash"];
|
|
985
|
-
poolId: string;
|
|
1272
|
+
declare namespace Conversion {
|
|
986
1273
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* -
|
|
1274
|
+
* Converts a collateral amount to loan token
|
|
1275
|
+
* Uses the formula: (amount * price / 10^36) * lltv / 10^18
|
|
1276
|
+
*
|
|
1277
|
+
* @param amount - The collateral amount to convert
|
|
1278
|
+
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1279
|
+
* @returns The equivalent loan token amount
|
|
992
1280
|
*/
|
|
993
|
-
amount: bigint
|
|
1281
|
+
function collateralToLoan(amount: bigint, params: {
|
|
1282
|
+
price: bigint;
|
|
1283
|
+
lltv: bigint;
|
|
1284
|
+
}): bigint;
|
|
1285
|
+
/**
|
|
1286
|
+
* Converts a loan token amount to collateral
|
|
1287
|
+
* Uses the inverse formula: (amount * 10^36 / price) * 10^18 / lltv
|
|
1288
|
+
* Returns 0n if price or lltv is zero (invalid conversion).
|
|
1289
|
+
*
|
|
1290
|
+
* @param amount - The loan token amount to convert
|
|
1291
|
+
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1292
|
+
* @returns The equivalent collateral amount, or 0n if conversion is invalid
|
|
1293
|
+
*/
|
|
1294
|
+
function loanToCollateral(amount: bigint, params: {
|
|
1295
|
+
price: bigint;
|
|
1296
|
+
lltv: bigint;
|
|
1297
|
+
}): bigint;
|
|
1298
|
+
}
|
|
1299
|
+
declare namespace Position_d_exports {
|
|
1300
|
+
export { Position, Type, from$10 as from };
|
|
1301
|
+
}
|
|
1302
|
+
type Position = {
|
|
1303
|
+
/** The chain id. */
|
|
1304
|
+
chainId: Id;
|
|
1305
|
+
/** The contract address from which the position is called.
|
|
1306
|
+
* While balances are obviously tracked on ERC20 contracts, we prefer to track which contract is called to know the balance.
|
|
1307
|
+
* For example, when depositing into a vault, we would specify the vault contract address as the contract not the underlying vault's ERC20 token address.
|
|
1308
|
+
*/
|
|
1309
|
+
contract: Address;
|
|
1310
|
+
/** The user address. */
|
|
1311
|
+
user: Address;
|
|
1312
|
+
/** The type of position. */
|
|
1313
|
+
type: Type;
|
|
1314
|
+
/** The balance of the position. */
|
|
1315
|
+
balance?: bigint;
|
|
1316
|
+
/** The underlying asset of the position.
|
|
1317
|
+
* For ERC20 positions, this equals the contract address.
|
|
1318
|
+
* For vault positions, this is the vault's underlying asset.
|
|
1319
|
+
*/
|
|
1320
|
+
asset?: Address;
|
|
1321
|
+
/** The block number at which the position was last updated. */
|
|
1322
|
+
blockNumber: number;
|
|
994
1323
|
};
|
|
1324
|
+
declare enum Type {
|
|
1325
|
+
ERC20 = "erc20",
|
|
1326
|
+
VAULT_V1 = "vault_v1",
|
|
1327
|
+
}
|
|
995
1328
|
/**
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
* @param
|
|
999
|
-
* @
|
|
1000
|
-
* @returns Maximum debt capacity
|
|
1001
|
-
*/
|
|
1002
|
-
declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
|
|
1003
|
-
/**
|
|
1004
|
-
* Generate pool ID for balance pools.
|
|
1329
|
+
* @constructor
|
|
1330
|
+
* Creates a Position.
|
|
1331
|
+
* @param parameters - {@link from.Parameters}
|
|
1332
|
+
* @returns The created Position. {@link from.ReturnType}
|
|
1005
1333
|
*/
|
|
1006
|
-
declare function
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}): string;
|
|
1019
|
-
/**
|
|
1020
|
-
* Generate pool ID for sell ERC20 callback pools.
|
|
1021
|
-
* Each offer has its own callback pool to prevent liquidity conflicts.
|
|
1022
|
-
*/
|
|
1023
|
-
declare function generateSellERC20CallbackPoolId(parameters: {
|
|
1024
|
-
user: Address;
|
|
1025
|
-
chainId: Id;
|
|
1026
|
-
obligationId: Hex;
|
|
1027
|
-
token: Address;
|
|
1028
|
-
offerHash: Hex;
|
|
1029
|
-
}): string;
|
|
1030
|
-
/**
|
|
1031
|
-
* Generate pool ID for obligation collateral pools.
|
|
1032
|
-
* Obligation collateral pools represent collateral already deposited in the obligation.
|
|
1033
|
-
* These pools are shared across all offers with the same obligation.
|
|
1034
|
-
*/
|
|
1035
|
-
declare function generateObligationCollateralPoolId(parameters: {
|
|
1036
|
-
user: Address;
|
|
1037
|
-
chainId: Id;
|
|
1038
|
-
obligationId: Hex;
|
|
1039
|
-
token: Address;
|
|
1040
|
-
}): string;
|
|
1041
|
-
/**
|
|
1042
|
-
* Generate pool ID for buy vault callback pools.
|
|
1043
|
-
*/
|
|
1044
|
-
declare function generateBuyVaultCallbackPoolId(parameters: {
|
|
1045
|
-
user: Address;
|
|
1046
|
-
chainId: Id;
|
|
1047
|
-
vault: Address;
|
|
1048
|
-
offerHash: Hex;
|
|
1049
|
-
}): string;
|
|
1050
|
-
/**
|
|
1051
|
-
* Generate pool ID for debt pools.
|
|
1052
|
-
*/
|
|
1053
|
-
declare function generateDebtPoolId(parameters: {
|
|
1054
|
-
user: Address;
|
|
1055
|
-
chainId: Id;
|
|
1056
|
-
obligationId: Hex;
|
|
1057
|
-
}): string;
|
|
1058
|
-
/**
|
|
1059
|
-
* Generate pool ID for user position in a vault.
|
|
1060
|
-
*/
|
|
1061
|
-
declare function generateUserVaultPositionPoolId(parameters: {
|
|
1062
|
-
user: Address;
|
|
1063
|
-
chainId: Id;
|
|
1064
|
-
vault: Address;
|
|
1065
|
-
}): string;
|
|
1066
|
-
/**
|
|
1067
|
-
* Generate pool ID for vault position in a market.
|
|
1068
|
-
*/
|
|
1069
|
-
declare function generateVaultPositionPoolId(parameters: {
|
|
1070
|
-
vault: Address;
|
|
1071
|
-
chainId: Id;
|
|
1072
|
-
marketId: string;
|
|
1073
|
-
}): string;
|
|
1074
|
-
/**
|
|
1075
|
-
* Generate pool ID for market total liquidity.
|
|
1076
|
-
*/
|
|
1077
|
-
declare function generateMarketLiquidityPoolId(parameters: {
|
|
1078
|
-
chainId: Id;
|
|
1079
|
-
marketId: string;
|
|
1080
|
-
}): string;
|
|
1081
|
-
declare namespace Obligation_d_exports {
|
|
1082
|
-
export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$11 as from, fromSnakeCase$1 as fromSnakeCase, id, random$1 as random };
|
|
1334
|
+
declare function from$10(parameters: from$10.Parameters): from$10.ReturnType;
|
|
1335
|
+
declare namespace from$10 {
|
|
1336
|
+
type Parameters = {
|
|
1337
|
+
chainId: Id;
|
|
1338
|
+
contract: Address;
|
|
1339
|
+
user: Address;
|
|
1340
|
+
type: Type;
|
|
1341
|
+
balance?: bigint;
|
|
1342
|
+
asset?: Address;
|
|
1343
|
+
blockNumber: number;
|
|
1344
|
+
};
|
|
1345
|
+
type ReturnType = Position;
|
|
1083
1346
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1347
|
+
declare namespace Quote_d_exports {
|
|
1348
|
+
export { InvalidQuoteError, Quote, QuoteSchema, from$9 as from, fromSnakeCase, random };
|
|
1349
|
+
}
|
|
1350
|
+
type Quote = {
|
|
1351
|
+
/** The obligation id. */
|
|
1352
|
+
obligationId: Hex;
|
|
1353
|
+
ask: {
|
|
1354
|
+
/** The ask price for the obligation. (18 decimals). */
|
|
1355
|
+
price: bigint;
|
|
1356
|
+
};
|
|
1357
|
+
bid: {
|
|
1358
|
+
/** The bid price for the obligation. (18 decimals). */
|
|
1359
|
+
price: bigint;
|
|
1360
|
+
};
|
|
1093
1361
|
};
|
|
1094
|
-
declare const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
}, z$1.core.$strip
|
|
1102
|
-
maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
|
|
1362
|
+
declare const QuoteSchema: z$1.ZodObject<{
|
|
1363
|
+
obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1364
|
+
ask: z$1.ZodObject<{
|
|
1365
|
+
price: z$1.ZodBigInt;
|
|
1366
|
+
}, z$1.core.$strip>;
|
|
1367
|
+
bid: z$1.ZodObject<{
|
|
1368
|
+
price: z$1.ZodBigInt;
|
|
1369
|
+
}, z$1.core.$strip>;
|
|
1103
1370
|
}, z$1.core.$strip>;
|
|
1104
1371
|
/**
|
|
1105
|
-
* Creates
|
|
1372
|
+
* Creates a quote for a given obligation.
|
|
1106
1373
|
* @constructor
|
|
1107
1374
|
* @param parameters - {@link from.Parameters}
|
|
1108
|
-
* @returns The created
|
|
1109
|
-
* @throws If the
|
|
1375
|
+
* @returns The created quote. {@link Quote}
|
|
1376
|
+
* @throws If the quote is invalid. {@link InvalidQuoteError}
|
|
1110
1377
|
*
|
|
1111
1378
|
* @example
|
|
1112
1379
|
* ```ts
|
|
1113
|
-
* const
|
|
1114
|
-
* chainId: 1,
|
|
1115
|
-
* loanToken: privateKeyToAccount(generatePrivateKey()).address,
|
|
1116
|
-
* collaterals: [
|
|
1117
|
-
* Collateral.from({
|
|
1118
|
-
* asset: privateKeyToAccount(generatePrivateKey()).address,
|
|
1119
|
-
* oracle: privateKeyToAccount(generatePrivateKey()).address,
|
|
1120
|
-
* lltv: 0.965
|
|
1121
|
-
* }),
|
|
1122
|
-
* ],
|
|
1123
|
-
* maturity: Maturity.from("end_of_next_quarter"),
|
|
1124
|
-
* });
|
|
1380
|
+
* const quote = Quote.from({ obligationId: "0x123", ask: { price: 100n }, bid: { price: 100n } });
|
|
1125
1381
|
* ```
|
|
1126
1382
|
*/
|
|
1127
|
-
declare function from$
|
|
1128
|
-
declare namespace from$
|
|
1129
|
-
type Parameters =
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
/** The token that is being borrowed for this obligation. */
|
|
1133
|
-
loanToken: Address;
|
|
1134
|
-
/** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
|
|
1135
|
-
collaterals: from$14.Parameters[] | readonly from$14.Parameters[];
|
|
1136
|
-
/** The maturity of the obligation. */
|
|
1137
|
-
maturity: from$13.Parameters;
|
|
1138
|
-
};
|
|
1139
|
-
type ReturnType = Obligation;
|
|
1140
|
-
type ErrorType = InvalidObligationError;
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Creates an obligation from a snake case object.
|
|
1144
|
-
* @throws If the obligation is invalid. {@link fromSnakeCase.ErrorType}
|
|
1145
|
-
* @param input - {@link fromSnakeCase.Parameters}
|
|
1146
|
-
* @returns The created obligation. {@link fromSnakeCase.ReturnType}
|
|
1147
|
-
*/
|
|
1148
|
-
declare function fromSnakeCase$1(input: fromSnakeCase$1.Parameters): fromSnakeCase$1.ReturnType;
|
|
1149
|
-
declare namespace fromSnakeCase$1 {
|
|
1150
|
-
type Parameters = Snake<Omit<Obligation, "chainId"> & {
|
|
1151
|
-
chainId: number;
|
|
1152
|
-
}>;
|
|
1153
|
-
type ReturnType = Obligation;
|
|
1154
|
-
type ErrorType = InvalidObligationError;
|
|
1383
|
+
declare function from$9(parameters: from$9.Parameters): from$9.ReturnType;
|
|
1384
|
+
declare namespace from$9 {
|
|
1385
|
+
type Parameters = Quote;
|
|
1386
|
+
type ReturnType = Quote;
|
|
1387
|
+
type ErrorType = InvalidQuoteError;
|
|
1155
1388
|
}
|
|
1156
1389
|
/**
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
* @
|
|
1160
|
-
* @
|
|
1161
|
-
* @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
|
|
1162
|
-
*
|
|
1163
|
-
* @example
|
|
1164
|
-
* ```ts
|
|
1165
|
-
* const obligation = Obligation.random();
|
|
1166
|
-
* const id = Obligation.id(obligation);
|
|
1167
|
-
* console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
|
|
1168
|
-
* ```
|
|
1390
|
+
* Creates a quote from a snake case object.
|
|
1391
|
+
* @throws If the quote is invalid. {@link InvalidQuoteError}
|
|
1392
|
+
* @param snake - {@link fromSnakeCase.Parameters}
|
|
1393
|
+
* @returns The created quote. {@link fromSnakeCase.ReturnType}
|
|
1169
1394
|
*/
|
|
1170
|
-
declare function
|
|
1171
|
-
declare namespace
|
|
1172
|
-
type Parameters =
|
|
1173
|
-
type ReturnType =
|
|
1174
|
-
type ErrorType =
|
|
1395
|
+
declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
|
|
1396
|
+
declare namespace fromSnakeCase {
|
|
1397
|
+
type Parameters = Snake<Quote>;
|
|
1398
|
+
type ReturnType = Quote;
|
|
1399
|
+
type ErrorType = from$9.ErrorType;
|
|
1175
1400
|
}
|
|
1176
1401
|
/**
|
|
1177
|
-
* Generates a random
|
|
1178
|
-
* @returns A randomly generated
|
|
1402
|
+
* Generates a random quote.
|
|
1403
|
+
* @returns A randomly generated quote. {@link random.ReturnType}
|
|
1179
1404
|
*
|
|
1180
1405
|
* @example
|
|
1181
1406
|
* ```ts
|
|
1182
|
-
* const
|
|
1407
|
+
* const quote = Quote.random();
|
|
1183
1408
|
* ```
|
|
1184
1409
|
*/
|
|
1185
|
-
declare function random
|
|
1186
|
-
declare namespace random
|
|
1187
|
-
type
|
|
1410
|
+
declare function random(): random.ReturnType;
|
|
1411
|
+
declare namespace random {
|
|
1412
|
+
type Parameters = never;
|
|
1413
|
+
type ReturnType = Quote;
|
|
1414
|
+
type ErrorType = from$9.ErrorType;
|
|
1188
1415
|
}
|
|
1189
|
-
declare class
|
|
1190
|
-
readonly name = "
|
|
1416
|
+
declare class InvalidQuoteError extends BaseError<z$1.ZodError | Error> {
|
|
1417
|
+
readonly name = "Quote.InvalidQuoteError";
|
|
1191
1418
|
constructor(error: z$1.ZodError | Error);
|
|
1192
1419
|
}
|
|
1193
|
-
declare
|
|
1194
|
-
|
|
1195
|
-
constructor();
|
|
1196
|
-
}
|
|
1197
|
-
declare namespace Oracle_d_exports {
|
|
1198
|
-
export { Conversion, Oracle, from$10 as from };
|
|
1420
|
+
declare namespace Transfer_d_exports {
|
|
1421
|
+
export { Transfer, from$8 as from };
|
|
1199
1422
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
/** The price returned by the oracle (in the oracle's native units), null if no price available. */
|
|
1209
|
-
readonly price: bigint | null;
|
|
1210
|
-
/** The block number at which the price was fetched. */
|
|
1211
|
-
readonly blockNumber: number;
|
|
1423
|
+
type Transfer = {
|
|
1424
|
+
id: string;
|
|
1425
|
+
chainId: Id;
|
|
1426
|
+
contract: Address;
|
|
1427
|
+
from: Address;
|
|
1428
|
+
to: Address;
|
|
1429
|
+
value: bigint;
|
|
1430
|
+
blockNumber: number;
|
|
1212
1431
|
};
|
|
1213
1432
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1433
|
+
* @constructor
|
|
1434
|
+
*
|
|
1435
|
+
* Creates a {@link Transfer}.
|
|
1436
|
+
* @param parameters - {@link from.Parameters}
|
|
1437
|
+
* @returns The created Transfer. {@link from.ReturnType}
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* const transfer = Transfer.from({ id: "1", chainId: 1, contract: "0x123", from: "0x456", to: "0x789", value: 100n, blockNumber: 100n });
|
|
1442
|
+
* ```
|
|
1217
1443
|
*/
|
|
1218
|
-
declare function from$
|
|
1219
|
-
declare namespace from$
|
|
1444
|
+
declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
|
|
1445
|
+
declare namespace from$8 {
|
|
1220
1446
|
type Parameters = {
|
|
1447
|
+
id: string;
|
|
1221
1448
|
chainId: Id;
|
|
1222
|
-
|
|
1223
|
-
|
|
1449
|
+
contract: Address;
|
|
1450
|
+
from: Address;
|
|
1451
|
+
to: Address;
|
|
1452
|
+
value: bigint;
|
|
1224
1453
|
blockNumber: number;
|
|
1225
1454
|
};
|
|
1226
|
-
type ReturnType =
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
* using oracle prices and LLTV
|
|
1231
|
-
*/
|
|
1232
|
-
declare namespace Conversion {
|
|
1233
|
-
/**
|
|
1234
|
-
* Converts a collateral amount to loan token
|
|
1235
|
-
* Uses the formula: (amount * price / 10^36) * lltv / 10^18
|
|
1236
|
-
*
|
|
1237
|
-
* @param amount - The collateral amount to convert
|
|
1238
|
-
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1239
|
-
* @returns The equivalent loan token amount
|
|
1240
|
-
*/
|
|
1241
|
-
function collateralToLoan(amount: bigint, params: {
|
|
1242
|
-
price: bigint;
|
|
1243
|
-
lltv: bigint;
|
|
1244
|
-
}): bigint;
|
|
1245
|
-
/**
|
|
1246
|
-
* Converts a loan token amount to collateral
|
|
1247
|
-
* Uses the inverse formula: (amount * 10^36 / price) * 10^18 / lltv
|
|
1248
|
-
* Returns 0n if price or lltv is zero (invalid conversion).
|
|
1249
|
-
*
|
|
1250
|
-
* @param amount - The loan token amount to convert
|
|
1251
|
-
* @param params - Conversion parameters containing price (36 decimals) and lltv (18 decimals)
|
|
1252
|
-
* @returns The equivalent collateral amount, or 0n if conversion is invalid
|
|
1253
|
-
*/
|
|
1254
|
-
function loanToCollateral(amount: bigint, params: {
|
|
1255
|
-
price: bigint;
|
|
1256
|
-
lltv: bigint;
|
|
1257
|
-
}): bigint;
|
|
1258
|
-
}
|
|
1259
|
-
declare namespace Position_d_exports {
|
|
1260
|
-
export { Position, Type, from$9 as from };
|
|
1261
|
-
}
|
|
1262
|
-
type Position = {
|
|
1263
|
-
/** The chain id. */
|
|
1264
|
-
chainId: Id;
|
|
1265
|
-
/** The contract address from which the position is called.
|
|
1266
|
-
* While balances are obviously tracked on ERC20 contracts, we prefer to track which contract is called to know the balance.
|
|
1267
|
-
* For example, when depositing into a vault, we would specify the vault contract address as the contract not the underlying vault's ERC20 token address.
|
|
1268
|
-
*/
|
|
1269
|
-
contract: Address;
|
|
1270
|
-
/** The user address. */
|
|
1271
|
-
user: Address;
|
|
1272
|
-
/** The type of position. */
|
|
1273
|
-
type: Type;
|
|
1274
|
-
/** The balance of the position. */
|
|
1275
|
-
balance?: bigint;
|
|
1276
|
-
/** The underlying asset of the position.
|
|
1277
|
-
* For ERC20 positions, this equals the contract address.
|
|
1278
|
-
* For vault positions, this is the vault's underlying asset.
|
|
1279
|
-
*/
|
|
1280
|
-
asset?: Address;
|
|
1281
|
-
/** The block number at which the position was last updated. */
|
|
1282
|
-
blockNumber: number;
|
|
1283
|
-
};
|
|
1284
|
-
declare enum Type {
|
|
1285
|
-
ERC20 = "erc20",
|
|
1286
|
-
VAULT_V1 = "vault_v1",
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* @constructor
|
|
1290
|
-
* Creates a Position.
|
|
1291
|
-
* @param parameters - {@link from.Parameters}
|
|
1292
|
-
* @returns The created Position. {@link from.ReturnType}
|
|
1293
|
-
*/
|
|
1294
|
-
declare function from$9(parameters: from$9.Parameters): from$9.ReturnType;
|
|
1295
|
-
declare namespace from$9 {
|
|
1296
|
-
type Parameters = {
|
|
1297
|
-
chainId: Id;
|
|
1298
|
-
contract: Address;
|
|
1299
|
-
user: Address;
|
|
1300
|
-
type: Type;
|
|
1301
|
-
balance?: bigint;
|
|
1302
|
-
asset?: Address;
|
|
1303
|
-
blockNumber: number;
|
|
1304
|
-
};
|
|
1305
|
-
type ReturnType = Position;
|
|
1306
|
-
}
|
|
1307
|
-
declare namespace Quote_d_exports {
|
|
1308
|
-
export { InvalidQuoteError, Quote, QuoteSchema, from$8 as from, fromSnakeCase, random };
|
|
1309
|
-
}
|
|
1310
|
-
type Quote = {
|
|
1311
|
-
/** The obligation id. */
|
|
1312
|
-
obligationId: Hex;
|
|
1313
|
-
ask: {
|
|
1314
|
-
/** The highest interest rate the seller will accept to pay for the obligation. (18 decimals). */
|
|
1315
|
-
rate: bigint;
|
|
1316
|
-
};
|
|
1317
|
-
bid: {
|
|
1318
|
-
/** The lowest interest rate a buyer is willing to be paid for the obligation. (18 decimals). */
|
|
1319
|
-
rate: bigint;
|
|
1320
|
-
};
|
|
1321
|
-
};
|
|
1322
|
-
declare const QuoteSchema: z$1.ZodObject<{
|
|
1323
|
-
obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
1324
|
-
ask: z$1.ZodObject<{
|
|
1325
|
-
rate: z$1.ZodBigInt;
|
|
1326
|
-
}, z$1.core.$strip>;
|
|
1327
|
-
bid: z$1.ZodObject<{
|
|
1328
|
-
rate: z$1.ZodBigInt;
|
|
1329
|
-
}, z$1.core.$strip>;
|
|
1330
|
-
}, z$1.core.$strip>;
|
|
1331
|
-
/**
|
|
1332
|
-
* Creates a quote for a given obligation.
|
|
1333
|
-
* @constructor
|
|
1334
|
-
* @param parameters - {@link from.Parameters}
|
|
1335
|
-
* @returns The created quote. {@link Quote}
|
|
1336
|
-
* @throws If the quote is invalid. {@link InvalidQuoteError}
|
|
1337
|
-
*
|
|
1338
|
-
* @example
|
|
1339
|
-
* ```ts
|
|
1340
|
-
* const quote = Quote.from({ obligationId: "0x123", ask: { assets: 100n, rate: 100n }, bid: { assets: 100n, rate: 100n } });
|
|
1341
|
-
* ```
|
|
1342
|
-
*/
|
|
1343
|
-
declare function from$8(parameters: from$8.Parameters): from$8.ReturnType;
|
|
1344
|
-
declare namespace from$8 {
|
|
1345
|
-
type Parameters = Quote;
|
|
1346
|
-
type ReturnType = Quote;
|
|
1347
|
-
type ErrorType = InvalidQuoteError;
|
|
1348
|
-
}
|
|
1349
|
-
/**
|
|
1350
|
-
* Creates a quote from a snake case object.
|
|
1351
|
-
* @throws If the quote is invalid. {@link InvalidQuoteError}
|
|
1352
|
-
* @param snake - {@link fromSnakeCase.Parameters}
|
|
1353
|
-
* @returns The created quote. {@link fromSnakeCase.ReturnType}
|
|
1354
|
-
*/
|
|
1355
|
-
declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
|
|
1356
|
-
declare namespace fromSnakeCase {
|
|
1357
|
-
type Parameters = Snake<Quote>;
|
|
1358
|
-
type ReturnType = Quote;
|
|
1359
|
-
type ErrorType = from$8.ErrorType;
|
|
1360
|
-
}
|
|
1361
|
-
/**
|
|
1362
|
-
* Generates a random quote.
|
|
1363
|
-
* @returns A randomly generated quote. {@link random.ReturnType}
|
|
1364
|
-
*
|
|
1365
|
-
* @example
|
|
1366
|
-
* ```ts
|
|
1367
|
-
* const quote = Quote.random();
|
|
1368
|
-
* ```
|
|
1369
|
-
*/
|
|
1370
|
-
declare function random(): random.ReturnType;
|
|
1371
|
-
declare namespace random {
|
|
1372
|
-
type Parameters = never;
|
|
1373
|
-
type ReturnType = Quote;
|
|
1374
|
-
type ErrorType = from$8.ErrorType;
|
|
1375
|
-
}
|
|
1376
|
-
declare class InvalidQuoteError extends BaseError<z$1.ZodError | Error> {
|
|
1377
|
-
readonly name = "Quote.InvalidQuoteError";
|
|
1378
|
-
constructor(error: z$1.ZodError | Error);
|
|
1379
|
-
}
|
|
1380
|
-
declare namespace Transfer_d_exports {
|
|
1381
|
-
export { Transfer, from$7 as from };
|
|
1382
|
-
}
|
|
1383
|
-
type Transfer = {
|
|
1384
|
-
id: string;
|
|
1385
|
-
chainId: Id;
|
|
1386
|
-
contract: Address;
|
|
1387
|
-
from: Address;
|
|
1388
|
-
to: Address;
|
|
1389
|
-
value: bigint;
|
|
1390
|
-
blockNumber: number;
|
|
1391
|
-
};
|
|
1392
|
-
/**
|
|
1393
|
-
* @constructor
|
|
1394
|
-
*
|
|
1395
|
-
* Creates a {@link Transfer}.
|
|
1396
|
-
* @param parameters - {@link from.Parameters}
|
|
1397
|
-
* @returns The created Transfer. {@link from.ReturnType}
|
|
1398
|
-
*
|
|
1399
|
-
* @example
|
|
1400
|
-
* ```ts
|
|
1401
|
-
* const transfer = Transfer.from({ id: "1", chainId: 1, contract: "0x123", from: "0x456", to: "0x789", value: 100n, blockNumber: 100n });
|
|
1402
|
-
* ```
|
|
1403
|
-
*/
|
|
1404
|
-
declare function from$7(parameters: from$7.Parameters): from$7.ReturnType;
|
|
1405
|
-
declare namespace from$7 {
|
|
1406
|
-
type Parameters = {
|
|
1407
|
-
id: string;
|
|
1408
|
-
chainId: Id;
|
|
1409
|
-
contract: Address;
|
|
1410
|
-
from: Address;
|
|
1411
|
-
to: Address;
|
|
1412
|
-
value: bigint;
|
|
1413
|
-
blockNumber: number;
|
|
1414
|
-
};
|
|
1415
|
-
type ReturnType = Transfer;
|
|
1416
|
-
}
|
|
1417
|
-
declare namespace Tree_d_exports {
|
|
1418
|
-
export { DecodeError, EncodeError, Proof, Tree, TreeError, VERSION$1 as VERSION, decode$1 as decode, encode$1 as encode, encodeUnsigned, from$6 as from, proofs };
|
|
1455
|
+
type ReturnType = Transfer;
|
|
1456
|
+
}
|
|
1457
|
+
declare namespace Tree_d_exports {
|
|
1458
|
+
export { DecodeError, EncodeError, Proof, Tree, TreeError, VERSION$1 as VERSION, decode, encode, encodeUnsigned, from$7 as from, proofs };
|
|
1419
1459
|
}
|
|
1420
1460
|
/**
|
|
1421
1461
|
* A merkle tree of offers built from offer hashes.
|
|
@@ -1445,7 +1485,7 @@ declare const VERSION$1 = 1;
|
|
|
1445
1485
|
* @returns A `StandardMerkleTree` of `bytes32` leaves representing the offers.
|
|
1446
1486
|
* @throws {TreeError} If tree building fails due to offer inconsistencies.
|
|
1447
1487
|
*/
|
|
1448
|
-
declare const from$
|
|
1488
|
+
declare const from$7: (offers: Offer[]) => Tree;
|
|
1449
1489
|
/**
|
|
1450
1490
|
* Generates merkle proofs for all offers in a tree.
|
|
1451
1491
|
*
|
|
@@ -1490,7 +1530,7 @@ declare const proofs: (tree: Tree) => Proof[];
|
|
|
1490
1530
|
* @returns Hex-encoded calldata ready for onchain broadcast
|
|
1491
1531
|
* @throws {EncodeError} If signature verification fails or root mismatch
|
|
1492
1532
|
*/
|
|
1493
|
-
declare const encode
|
|
1533
|
+
declare const encode: (tree: Tree, signature: Hex) => Promise<Hex>;
|
|
1494
1534
|
/**
|
|
1495
1535
|
* Encodes a merkle tree without a signature into hex payload for client-side signing.
|
|
1496
1536
|
*
|
|
@@ -1528,7 +1568,7 @@ declare const encodeUnsigned: (tree: Tree) => Hex;
|
|
|
1528
1568
|
* @returns Validated tree, signature, and recovered signer address
|
|
1529
1569
|
* @throws {DecodeError} If version invalid, signature invalid, or root mismatch
|
|
1530
1570
|
*/
|
|
1531
|
-
declare const decode
|
|
1571
|
+
declare const decode: (encoded: Hex) => Promise<{
|
|
1532
1572
|
tree: Tree;
|
|
1533
1573
|
signature: Hex;
|
|
1534
1574
|
signer: Address;
|
|
@@ -1542,380 +1582,266 @@ declare class TreeError extends BaseError {
|
|
|
1542
1582
|
constructor(reason: string);
|
|
1543
1583
|
}
|
|
1544
1584
|
/**
|
|
1545
|
-
* Error thrown during tree encoding.
|
|
1546
|
-
* Indicates validation failures (signature, root mismatch, mixed makers).
|
|
1547
|
-
*/
|
|
1548
|
-
declare class EncodeError extends BaseError {
|
|
1549
|
-
name: string;
|
|
1550
|
-
constructor(reason: string);
|
|
1551
|
-
}
|
|
1552
|
-
/**
|
|
1553
|
-
* Error thrown during tree decoding.
|
|
1554
|
-
* Indicates payload corruption, version mismatch, or validation failures.
|
|
1555
|
-
*/
|
|
1556
|
-
declare class DecodeError extends BaseError {
|
|
1557
|
-
name: string;
|
|
1558
|
-
constructor(reason: string);
|
|
1559
|
-
}
|
|
1560
|
-
declare namespace Logger_d_exports {
|
|
1561
|
-
export { LogEntry, LogFn, LogLevel, LogLevelValues, Logger, defaultLogger, getLogger, runWithLogger, silentLogger };
|
|
1562
|
-
}
|
|
1563
|
-
declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
|
|
1564
|
-
type LogLevel = (typeof LogLevelValues)[number];
|
|
1565
|
-
type LogEntry = Compute<{
|
|
1566
|
-
msg: string;
|
|
1567
|
-
} & Record<string, unknown>>;
|
|
1568
|
-
type LogFn = (entry: LogEntry) => void;
|
|
1569
|
-
type Logger = {
|
|
1570
|
-
trace: LogFn;
|
|
1571
|
-
debug: LogFn;
|
|
1572
|
-
info: LogFn;
|
|
1573
|
-
warn: LogFn;
|
|
1574
|
-
error: LogFn;
|
|
1575
|
-
fatal: LogFn;
|
|
1576
|
-
};
|
|
1577
|
-
declare function defaultLogger(minLevel?: LogLevel, pretty?: boolean): Logger;
|
|
1578
|
-
declare function silentLogger(): Logger;
|
|
1579
|
-
declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
|
|
1580
|
-
declare function getLogger(): Logger;
|
|
1581
|
-
//#endregion
|
|
1582
|
-
//#region src/database/domains/Book.d.ts
|
|
1583
|
-
type BookDomain = {
|
|
1584
|
-
/** Get aggregated book levels for a given obligation side. */
|
|
1585
|
-
get: (parameters: get$4.Parameters) => Promise<get$4.ReturnType>;
|
|
1586
|
-
/** Get all offers for a given obligation side with cross-invalidation. */
|
|
1587
|
-
getOffers: (parameters: getOffers$2.Parameters) => Promise<getOffers$2.ReturnType>;
|
|
1588
|
-
};
|
|
1589
|
-
declare namespace get$4 {
|
|
1590
|
-
type Parameters = {
|
|
1591
|
-
/** The side of the offer. */
|
|
1592
|
-
side: "buy" | "sell";
|
|
1593
|
-
/** The obligationId of the offer. */
|
|
1594
|
-
obligationId: Hex;
|
|
1595
|
-
/** Cursor string returned by a previous call, for pagination */
|
|
1596
|
-
cursor?: string;
|
|
1597
|
-
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
1598
|
-
limit?: number;
|
|
1599
|
-
};
|
|
1600
|
-
type Level = {
|
|
1601
|
-
/** The interest rate for this level */
|
|
1602
|
-
rate: bigint;
|
|
1603
|
-
/** Sum of takeable amounts at this rate */
|
|
1604
|
-
assets: bigint;
|
|
1605
|
-
/** Number of offers at this rate */
|
|
1606
|
-
count: number;
|
|
1607
|
-
};
|
|
1608
|
-
type ReturnType = {
|
|
1609
|
-
levels: Level[];
|
|
1610
|
-
nextCursor: string | null;
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
declare namespace getOffers$2 {
|
|
1614
|
-
type Parameters = {
|
|
1615
|
-
/** The side of the offer. */
|
|
1616
|
-
side: "buy" | "sell";
|
|
1617
|
-
/** The obligationId of the offer. */
|
|
1618
|
-
obligationId: Hex;
|
|
1619
|
-
/** Cursor string returned by a previous call, for pagination */
|
|
1620
|
-
cursor?: string;
|
|
1621
|
-
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
1622
|
-
limit?: number;
|
|
1623
|
-
};
|
|
1624
|
-
type ReturnType = {
|
|
1625
|
-
offers: Offer[];
|
|
1626
|
-
nextCursor: string | null;
|
|
1627
|
-
};
|
|
1628
|
-
}
|
|
1629
|
-
//#endregion
|
|
1630
|
-
//#region src/database/domains/Chains.d.ts
|
|
1631
|
-
type ChainsDomain = {
|
|
1632
|
-
/** Get the latest block number processed by a given chain alongside its epoch. */
|
|
1633
|
-
getBlockNumber: (chainId: Id) => Promise<{
|
|
1634
|
-
blockNumber: number;
|
|
1635
|
-
epoch: bigint;
|
|
1636
|
-
}>;
|
|
1637
|
-
/** Get the latest block number processed for all chains, optionally filtered by chain id. */
|
|
1638
|
-
getBlockNumbers: (parameters?: {
|
|
1639
|
-
chainId?: Id;
|
|
1640
|
-
}) => Promise<Array<{
|
|
1641
|
-
chainId: Id;
|
|
1642
|
-
blockNumber: number;
|
|
1643
|
-
epoch: bigint;
|
|
1644
|
-
updatedAt: Date;
|
|
1645
|
-
}>>;
|
|
1646
|
-
/** Save the latest block number processed for a given chain alongside its epoch.*/
|
|
1647
|
-
saveBlockNumber: (parameters: {
|
|
1648
|
-
chainId: Id;
|
|
1649
|
-
blockNumber: number;
|
|
1650
|
-
epoch: bigint;
|
|
1651
|
-
}) => Promise<void>;
|
|
1652
|
-
};
|
|
1653
|
-
//#endregion
|
|
1654
|
-
//#region src/indexer/collectors/Collector.d.ts
|
|
1655
|
-
declare const names: readonly ["offers", "consumed_events", "positions", "prices"];
|
|
1656
|
-
type Name = (typeof names)[number];
|
|
1657
|
-
/** A general collector interface. */
|
|
1658
|
-
type Collector<name extends Name = Name, chain extends Chain$1 = Chain$1> = {
|
|
1659
|
-
/** The name of the collector. */
|
|
1660
|
-
readonly name: name;
|
|
1661
|
-
/** The chain the collector is running on. */
|
|
1662
|
-
readonly chain: chain;
|
|
1663
|
-
/** Start collecting data from external sources.
|
|
1664
|
-
* @yields The last block number processed by the collector.
|
|
1665
|
-
*/
|
|
1666
|
-
collect: () => AsyncGenerator<number, void, void>;
|
|
1667
|
-
};
|
|
1668
|
-
declare namespace Gate_d_exports {
|
|
1669
|
-
export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* A validation rule.
|
|
1673
|
-
*/
|
|
1674
|
-
type Rule<T, Name$2 extends string = string> = {
|
|
1675
|
-
kind: "single";
|
|
1676
|
-
name: Name$2;
|
|
1677
|
-
description: string;
|
|
1678
|
-
run: Single<T, Name$2>;
|
|
1679
|
-
} | {
|
|
1680
|
-
kind: "batch";
|
|
1681
|
-
name: Name$2;
|
|
1682
|
-
description: string;
|
|
1683
|
-
run: Batch<T, Name$2>;
|
|
1684
|
-
};
|
|
1685
|
-
type RuleNames<Rules$1 extends readonly {
|
|
1686
|
-
name: string;
|
|
1687
|
-
}[]> = Rules$1[number]["name"];
|
|
1688
|
-
/**
|
|
1689
|
-
* A single item validation rule.
|
|
1690
|
-
* @param item - The item to validate.
|
|
1691
|
-
* @returns The issue that was found. If the item is valid, this will be undefined.
|
|
1692
|
-
*/
|
|
1693
|
-
type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
|
|
1694
|
-
/**
|
|
1695
|
-
* A batch item validation rule.
|
|
1696
|
-
* @param items - The items to validate.
|
|
1697
|
-
* @returns A map of the items to the issue that was found.
|
|
1698
|
-
*/
|
|
1699
|
-
type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
|
|
1700
|
-
/**
|
|
1701
|
-
* Create a validation rule iterating over a single item at a time.
|
|
1702
|
-
* @param name - The name of the rule.
|
|
1703
|
-
* @param description - A human-readable description of the rule.
|
|
1704
|
-
* @param run - The function that validates the rule.
|
|
1705
|
-
* @returns The created rule.
|
|
1706
|
-
*/
|
|
1707
|
-
declare function single<Name$2 extends string, T>(name: Name$2, description: string, run: Single<T, Name$2>): Rule<T, Name$2>;
|
|
1708
|
-
/**
|
|
1709
|
-
* Create a validation rule iterating over a batch of items at a time.
|
|
1710
|
-
* @param name - The name of the rule.
|
|
1711
|
-
* @param description - A human-readable description of the rule.
|
|
1712
|
-
* @param run - The function that validates the rule.
|
|
1713
|
-
* @returns The created rule.
|
|
1714
|
-
*/
|
|
1715
|
-
declare function batch$1<Name$2 extends string, T>(name: Name$2, description: string, run: Batch<T, Name$2>): Rule<T, Name$2>;
|
|
1716
|
-
/**
|
|
1717
|
-
* A validation issue.
|
|
1718
|
-
*/
|
|
1719
|
-
type Issue<T, RuleName extends string = string> = {
|
|
1720
|
-
/** The name of the rule that caused the issue. */
|
|
1721
|
-
ruleName: RuleName;
|
|
1722
|
-
/** The message of the issue. */
|
|
1723
|
-
message: string;
|
|
1724
|
-
/** The item that was not valid. */
|
|
1725
|
-
item: T;
|
|
1726
|
-
};
|
|
1727
|
-
/**
|
|
1728
|
-
* The result of a validation.
|
|
1729
|
-
*/
|
|
1730
|
-
type Result<T, RuleName extends string = string> = {
|
|
1731
|
-
/** The items that were valid. */
|
|
1732
|
-
valid: T[];
|
|
1733
|
-
/** The reports of the failed validations. */
|
|
1734
|
-
issues: Issue<T, RuleName>[];
|
|
1735
|
-
};
|
|
1736
|
-
declare function run<T, Name$2 extends string, Rules$1 extends readonly Rule<T, Name$2>[]>(parameters: {
|
|
1737
|
-
items: T[];
|
|
1738
|
-
rules: Rules$1;
|
|
1739
|
-
chunkSize?: number;
|
|
1740
|
-
}): Promise<Result<T, RuleNames<Rules$1>>>;
|
|
1741
|
-
declare namespace Gatekeeper_d_exports {
|
|
1742
|
-
export { Gatekeeper, Rules, create$5 as create };
|
|
1743
|
-
}
|
|
1744
|
-
type Rules = readonly Rule<Offer, string>[];
|
|
1745
|
-
type Gatekeeper = {
|
|
1746
|
-
rules: Rules;
|
|
1747
|
-
isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
|
|
1748
|
-
};
|
|
1749
|
-
type GatekeeperParameters = {
|
|
1750
|
-
rules: Rules;
|
|
1751
|
-
};
|
|
1752
|
-
declare function create$5(parameters: GatekeeperParameters): Gatekeeper;
|
|
1753
|
-
declare namespace GateConfig_d_exports {
|
|
1754
|
-
export { CallbackConfig, GateConfig, assets$1 as assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
|
|
1755
|
-
}
|
|
1756
|
-
type GateConfig = {
|
|
1757
|
-
callbacks?: CallbackConfig[];
|
|
1758
|
-
maturities?: MaturityType[];
|
|
1759
|
-
};
|
|
1760
|
-
type CallbackConfig = {
|
|
1761
|
-
type: CallbackType.BuyVaultV1Callback;
|
|
1762
|
-
addresses: Address[];
|
|
1763
|
-
vaultFactories: Address[];
|
|
1764
|
-
} | {
|
|
1765
|
-
type: CallbackType.SellERC20Callback;
|
|
1766
|
-
addresses: Address[];
|
|
1767
|
-
} | {
|
|
1768
|
-
type: CallbackType.BuyWithEmptyCallback;
|
|
1769
|
-
};
|
|
1770
|
-
declare function getCallback(chain: Name$1, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
|
|
1771
|
-
type: CallbackType.BuyVaultV1Callback;
|
|
1772
|
-
}> | undefined;
|
|
1773
|
-
declare function getCallback(chain: Name$1, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
|
|
1774
|
-
type: CallbackType.SellERC20Callback;
|
|
1775
|
-
}> | undefined;
|
|
1776
|
-
declare function getCallback(chain: Name$1, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
|
|
1777
|
-
type: CallbackType.BuyWithEmptyCallback;
|
|
1778
|
-
}> | undefined;
|
|
1779
|
-
declare function getCallback(chain: Name$1, type: CallbackType): CallbackConfig | undefined;
|
|
1780
|
-
/**
|
|
1781
|
-
* Attempts to infer the configured callback type from a callback address on a chain.
|
|
1782
|
-
* Skips the empty callback type as it does not carry addresses.
|
|
1783
|
-
*
|
|
1784
|
-
* @param chain - Chain name for which to infer the callback type
|
|
1785
|
-
* @param address - Callback contract address
|
|
1786
|
-
* @returns The callback type when found, otherwise undefined
|
|
1787
|
-
*/
|
|
1788
|
-
declare function getCallbackType(chain: Name$1, address: Address): CallbackType | undefined;
|
|
1789
|
-
/**
|
|
1790
|
-
* Returns the callback addresses for a given chain and callback type, if it exists.
|
|
1791
|
-
* @param chain - Chain name for which to read the validation configuration
|
|
1792
|
-
* @param type - Callback type to retrieve
|
|
1793
|
-
* @returns The matching callback addresses or an empty array if not configured
|
|
1794
|
-
*/
|
|
1795
|
-
declare function getCallbackTypeAddresses(chain: Name$1, type: CallbackType): Address[];
|
|
1796
|
-
/**
|
|
1797
|
-
* Returns the list of allowed non-empty callback addresses for a chain.
|
|
1798
|
-
*
|
|
1799
|
-
* @param chain - Chain name
|
|
1800
|
-
* @returns Array of allowed callback addresses (lowercased). Empty when none configured
|
|
1801
|
-
*/
|
|
1802
|
-
declare const getCallbackAddresses: (chain: Name$1) => Address[];
|
|
1803
|
-
declare const assets$1: Record<string, Address[]>;
|
|
1804
|
-
declare const configs: Record<Name$1, GateConfig>;
|
|
1805
|
-
//#endregion
|
|
1806
|
-
//#region src/gatekeeper/morphoRules.d.ts
|
|
1807
|
-
declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token"> | Rule<Offer, "mixed_maker">)[];
|
|
1808
|
-
declare namespace Rules_d_exports {
|
|
1809
|
-
export { ValidityParameters, callback, chains$1 as chains, maturity, sameMaker, token, validity };
|
|
1810
|
-
}
|
|
1811
|
-
type ValidityParameters = {
|
|
1812
|
-
client: PublicClient<Transport, Chain$1>;
|
|
1813
|
-
};
|
|
1814
|
-
/**
|
|
1815
|
-
* set of rules to validate offers.
|
|
1816
|
-
*
|
|
1817
|
-
* @param parameters - Validity parameters with chain and client
|
|
1818
|
-
* @returns Array of validation rules to evaluate against offers
|
|
1819
|
-
*/
|
|
1820
|
-
declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
|
|
1821
|
-
declare const chains$1: ({
|
|
1822
|
-
chains: chains$1
|
|
1823
|
-
}: {
|
|
1824
|
-
chains: Chain$1[];
|
|
1825
|
-
}) => Rule<Offer, "chain_ids">;
|
|
1826
|
-
declare const maturity: ({
|
|
1827
|
-
maturities
|
|
1828
|
-
}: {
|
|
1829
|
-
maturities: MaturityType[];
|
|
1830
|
-
}) => Rule<Offer, "maturity">;
|
|
1831
|
-
declare const callback: ({
|
|
1832
|
-
callbacks,
|
|
1833
|
-
allowedAddresses
|
|
1834
|
-
}: {
|
|
1835
|
-
callbacks: CallbackType[];
|
|
1836
|
-
allowedAddresses: Address[];
|
|
1837
|
-
}) => Rule<Offer, "callback">;
|
|
1838
|
-
/**
|
|
1839
|
-
* A validation rule that checks if the offer's token is allowed.
|
|
1840
|
-
* @param offer - The offer to validate.
|
|
1841
|
-
* @returns The issue that was found. If the offer is valid, this will be undefined.
|
|
1585
|
+
* Error thrown during tree encoding.
|
|
1586
|
+
* Indicates validation failures (signature, root mismatch, mixed makers).
|
|
1842
1587
|
*/
|
|
1843
|
-
declare
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
}) => Rule<Offer, "token">;
|
|
1588
|
+
declare class EncodeError extends BaseError {
|
|
1589
|
+
name: string;
|
|
1590
|
+
constructor(reason: string);
|
|
1591
|
+
}
|
|
1848
1592
|
/**
|
|
1849
|
-
*
|
|
1850
|
-
*
|
|
1851
|
-
* This rule is signing-agnostic; signer verification is handled at the collector level.
|
|
1593
|
+
* Error thrown during tree decoding.
|
|
1594
|
+
* Indicates payload corruption, version mismatch, or validation failures.
|
|
1852
1595
|
*/
|
|
1853
|
-
declare
|
|
1854
|
-
|
|
1855
|
-
|
|
1596
|
+
declare class DecodeError extends BaseError {
|
|
1597
|
+
name: string;
|
|
1598
|
+
constructor(reason: string);
|
|
1856
1599
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
type
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1600
|
+
//#endregion
|
|
1601
|
+
//#region src/indexer/collectors/Collector.d.ts
|
|
1602
|
+
declare const names: readonly ["offers", "consumed_events", "positions", "prices"];
|
|
1603
|
+
type Name = (typeof names)[number];
|
|
1604
|
+
/** A general collector interface. */
|
|
1605
|
+
type Collector<name extends Name = Name, client extends PublicClient<Transport, Chain$1> = PublicClient<Transport, Chain$1>> = {
|
|
1606
|
+
/** The name of the collector. */
|
|
1607
|
+
readonly name: name;
|
|
1608
|
+
/** The chain the collector is running on. */
|
|
1609
|
+
readonly chain: client["chain"];
|
|
1610
|
+
/** The public client used to query chain head. */
|
|
1611
|
+
readonly client: client;
|
|
1612
|
+
/** The database connection for collector metadata. */
|
|
1613
|
+
readonly db: Database;
|
|
1614
|
+
/** The normal polling interval (ms) for this collector. */
|
|
1615
|
+
readonly interval: number;
|
|
1616
|
+
/** Start collecting data from external sources.
|
|
1617
|
+
* @yields The last block number processed by the collector.
|
|
1618
|
+
*/
|
|
1619
|
+
collect: () => AsyncGenerator<number, void, void>;
|
|
1872
1620
|
};
|
|
1873
|
-
declare function from$5<client extends PublicClient<Transport, Chain$1, Account | undefined>>(config: IndexerConfig<client>): Indexer;
|
|
1874
|
-
declare function create$4<client extends PublicClient<Transport, Chain$1, Account | undefined>>(params: {
|
|
1875
|
-
db: Database;
|
|
1876
|
-
collectors: Collector[];
|
|
1877
|
-
client: client;
|
|
1878
|
-
interval: number;
|
|
1879
|
-
}): Indexer;
|
|
1880
1621
|
//#endregion
|
|
1881
|
-
//#region src/database/domains/
|
|
1882
|
-
type
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1622
|
+
//#region src/database/domains/Blocks.d.ts
|
|
1623
|
+
type ChainState = {
|
|
1624
|
+
chainId: Id;
|
|
1625
|
+
blockNumber: number;
|
|
1626
|
+
epoch: bigint;
|
|
1627
|
+
};
|
|
1628
|
+
type CollectorState = {
|
|
1629
|
+
collectorName: Name;
|
|
1630
|
+
chainId: Id;
|
|
1631
|
+
blockNumber: number;
|
|
1632
|
+
epoch: bigint;
|
|
1633
|
+
};
|
|
1634
|
+
type ChainSnapshot = ChainState & {
|
|
1635
|
+
updatedAt: Date;
|
|
1636
|
+
};
|
|
1637
|
+
type CollectorSnapshot = CollectorState & {
|
|
1638
|
+
updatedAt: Date;
|
|
1639
|
+
};
|
|
1640
|
+
type InitParameters = {
|
|
1641
|
+
chainId: Id;
|
|
1642
|
+
collectorName: Name;
|
|
1643
|
+
};
|
|
1644
|
+
type AdvanceChainParameters = {
|
|
1645
|
+
chainId: Id;
|
|
1646
|
+
blockNumber: number;
|
|
1647
|
+
epoch: bigint;
|
|
1648
|
+
};
|
|
1649
|
+
type AdvanceCollectorParameters = {
|
|
1650
|
+
collectorName: Name;
|
|
1651
|
+
chainId: Id;
|
|
1652
|
+
blockNumber: number;
|
|
1653
|
+
epoch: bigint;
|
|
1654
|
+
};
|
|
1655
|
+
type HandleReorgParameters = {
|
|
1656
|
+
chainId: Id;
|
|
1657
|
+
blockNumber: number;
|
|
1658
|
+
epoch: bigint;
|
|
1659
|
+
collectorNames?: Name[];
|
|
1660
|
+
};
|
|
1661
|
+
type BlocksDomain = {
|
|
1662
|
+
/** Initialize and return chain + collector state, seeding rows when missing. */
|
|
1663
|
+
init: (parameters: InitParameters) => Promise<{
|
|
1664
|
+
chain: ChainState;
|
|
1665
|
+
collector: CollectorState;
|
|
1890
1666
|
}>;
|
|
1891
|
-
/**
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
getBlockNumbers: (parameters?: {
|
|
1896
|
-
chainId?: Id;
|
|
1897
|
-
}) => Promise<Array<{
|
|
1898
|
-
collectorName: Name;
|
|
1667
|
+
/** Return chain state, failing if it has not been initialized yet. */
|
|
1668
|
+
getChain: (chainId: Id) => Promise<ChainState>;
|
|
1669
|
+
/** Return collector state, failing if it has not been initialized yet. */
|
|
1670
|
+
getCollector: (parameters: {
|
|
1899
1671
|
chainId: Id;
|
|
1900
|
-
blockNumber: number;
|
|
1901
|
-
epoch: bigint;
|
|
1902
|
-
updatedAt: Date;
|
|
1903
|
-
}>>;
|
|
1904
|
-
/** Save the latest block number processed by a collector for a given chain.*/
|
|
1905
|
-
saveBlockNumber: (parameters: {
|
|
1906
1672
|
collectorName: Name;
|
|
1673
|
+
}) => Promise<CollectorState>;
|
|
1674
|
+
/** Return chain state rows, optionally filtered by chain id. */
|
|
1675
|
+
getChains: (parameters?: {
|
|
1676
|
+
chainId?: Id;
|
|
1677
|
+
}) => Promise<ChainSnapshot[]>;
|
|
1678
|
+
/** Return collector state rows, optionally filtered by chain id. */
|
|
1679
|
+
getCollectors: (parameters?: {
|
|
1680
|
+
chainId?: Id;
|
|
1681
|
+
}) => Promise<CollectorSnapshot[]>;
|
|
1682
|
+
/** Persist chain block state updates. */
|
|
1683
|
+
advanceChain: (parameters: AdvanceChainParameters) => Promise<void>;
|
|
1684
|
+
/** Persist collector block state updates and enforce invariants via storage CAS. */
|
|
1685
|
+
advanceCollector: (parameters: AdvanceCollectorParameters) => Promise<void>;
|
|
1686
|
+
/** Apply a reorg by advancing the chain epoch and fencing collectors. */
|
|
1687
|
+
handleReorg: (parameters: HandleReorgParameters) => Promise<void>;
|
|
1688
|
+
};
|
|
1689
|
+
declare namespace Logger_d_exports {
|
|
1690
|
+
export { LogEntry, LogFn, LogLevel, LogLevelValues, Logger, defaultLogger, getLogger, runWithLogger, silentLogger };
|
|
1691
|
+
}
|
|
1692
|
+
declare const LogLevelValues: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
|
|
1693
|
+
type LogLevel = (typeof LogLevelValues)[number];
|
|
1694
|
+
type LogEntry = Compute<{
|
|
1695
|
+
msg: string;
|
|
1696
|
+
} & Record<string, unknown>>;
|
|
1697
|
+
type LogFn = (entry: LogEntry) => void;
|
|
1698
|
+
type Logger = {
|
|
1699
|
+
trace: LogFn;
|
|
1700
|
+
debug: LogFn;
|
|
1701
|
+
info: LogFn;
|
|
1702
|
+
warn: LogFn;
|
|
1703
|
+
error: LogFn;
|
|
1704
|
+
fatal: LogFn;
|
|
1705
|
+
};
|
|
1706
|
+
declare function defaultLogger(minLevel?: LogLevel, pretty?: boolean): Logger;
|
|
1707
|
+
declare function silentLogger(): Logger;
|
|
1708
|
+
declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
|
|
1709
|
+
declare function getLogger(): Logger;
|
|
1710
|
+
//#endregion
|
|
1711
|
+
//#region src/database/domains/Offers.d.ts
|
|
1712
|
+
type CreateBatch = Readonly<{
|
|
1713
|
+
blockNumber: number;
|
|
1714
|
+
offers: Offer[];
|
|
1715
|
+
}>;
|
|
1716
|
+
/**
|
|
1717
|
+
* Raw row returned by database queries.
|
|
1718
|
+
* Built from primitives; no domain constructors in the DB layer.
|
|
1719
|
+
*/
|
|
1720
|
+
type Row = {
|
|
1721
|
+
hash: Hex;
|
|
1722
|
+
maker: Address;
|
|
1723
|
+
assets: bigint;
|
|
1724
|
+
obligationUnits: bigint;
|
|
1725
|
+
obligationShares: bigint;
|
|
1726
|
+
price: bigint;
|
|
1727
|
+
maturity: Maturity;
|
|
1728
|
+
expiry: number;
|
|
1729
|
+
start: number;
|
|
1730
|
+
group: Hex;
|
|
1731
|
+
session: Hex;
|
|
1732
|
+
buy: boolean;
|
|
1733
|
+
chainId: Id;
|
|
1734
|
+
loanToken: Address;
|
|
1735
|
+
collaterals: Collateral[];
|
|
1736
|
+
callback: {
|
|
1737
|
+
address: Address;
|
|
1738
|
+
data: Hex;
|
|
1739
|
+
};
|
|
1740
|
+
consumed: bigint;
|
|
1741
|
+
available: bigint;
|
|
1742
|
+
takeable: bigint;
|
|
1743
|
+
blockNumber: number;
|
|
1744
|
+
};
|
|
1745
|
+
type OffersDomain = {
|
|
1746
|
+
/** Create multiple offers. */
|
|
1747
|
+
create: (batches: CreateBatch[]) => Promise<Hex[]>;
|
|
1748
|
+
/** Delete multiple offers by hashes or block number greater than or equal to the given value on a given chain.
|
|
1749
|
+
* @returns the number of offers deleted.
|
|
1750
|
+
*/
|
|
1751
|
+
delete: (parameters: {
|
|
1752
|
+
hashes: Hex[];
|
|
1753
|
+
} | {
|
|
1754
|
+
blockNumberGte: number;
|
|
1907
1755
|
chainId: Id;
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1756
|
+
}) => Promise<number>;
|
|
1757
|
+
/** Get all offers. */
|
|
1758
|
+
get: (parameters?: GetOffersParams) => Promise<{
|
|
1759
|
+
rows: Row[];
|
|
1760
|
+
nextCursor: string | null;
|
|
1761
|
+
}>;
|
|
1762
|
+
/** Get obligations */
|
|
1763
|
+
getObligations: (parameters?: {
|
|
1764
|
+
ids?: Hex[];
|
|
1765
|
+
chainId?: Id;
|
|
1766
|
+
loanToken?: Address;
|
|
1767
|
+
collateralToken?: Address;
|
|
1768
|
+
maturity?: number;
|
|
1769
|
+
cursor?: string;
|
|
1770
|
+
limit?: number;
|
|
1771
|
+
}) => Promise<{
|
|
1772
|
+
obligations: Obligation[];
|
|
1773
|
+
nextCursor: string | null;
|
|
1774
|
+
}>;
|
|
1775
|
+
/** Get quotes for given obligations. */
|
|
1776
|
+
getQuotes: (parameters: {
|
|
1777
|
+
obligationIds: Hex[];
|
|
1778
|
+
}) => Promise<Quote[]>;
|
|
1779
|
+
};
|
|
1780
|
+
type PaginationParams$1 = {
|
|
1781
|
+
/** Cursor string returned by a previous call, for pagination */
|
|
1782
|
+
cursor?: string;
|
|
1783
|
+
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
1784
|
+
limit?: number;
|
|
1785
|
+
};
|
|
1786
|
+
type GetOffersParams = {
|
|
1787
|
+
/** Filter by maker address */
|
|
1788
|
+
maker?: Address;
|
|
1789
|
+
} & PaginationParams$1;
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region src/database/domains/Book.d.ts
|
|
1792
|
+
type BookDomain = {
|
|
1793
|
+
/** Get aggregated book levels for a given obligation side. */
|
|
1794
|
+
get: (parameters: get$4.Parameters) => Promise<get$4.ReturnType>;
|
|
1795
|
+
/** Get all offers for a given obligation side with cross-invalidation. */
|
|
1796
|
+
getOffers: (parameters: getOffers$2.Parameters) => Promise<getOffers$2.ReturnType>;
|
|
1911
1797
|
};
|
|
1798
|
+
declare namespace get$4 {
|
|
1799
|
+
type Parameters = {
|
|
1800
|
+
/** The side of the offer. */
|
|
1801
|
+
side: "buy" | "sell";
|
|
1802
|
+
/** The obligationId of the offer. */
|
|
1803
|
+
obligationId: Hex;
|
|
1804
|
+
/** Cursor string returned by a previous call, for pagination */
|
|
1805
|
+
cursor?: string;
|
|
1806
|
+
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
1807
|
+
limit?: number;
|
|
1808
|
+
};
|
|
1809
|
+
type Level = {
|
|
1810
|
+
/** The computed price for this level (interpolated at query time) */
|
|
1811
|
+
price: bigint;
|
|
1812
|
+
/** Sum of takeable amounts at this price */
|
|
1813
|
+
assets: bigint;
|
|
1814
|
+
/** Number of offers at this price */
|
|
1815
|
+
count: number;
|
|
1816
|
+
};
|
|
1817
|
+
type ReturnType = {
|
|
1818
|
+
levels: Level[];
|
|
1819
|
+
nextCursor: string | null;
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
declare namespace getOffers$2 {
|
|
1823
|
+
type Parameters = {
|
|
1824
|
+
/** The side of the offer. */
|
|
1825
|
+
side: "buy" | "sell";
|
|
1826
|
+
/** The obligationId of the offer. */
|
|
1827
|
+
obligationId: Hex;
|
|
1828
|
+
/** Cursor string returned by a previous call, for pagination */
|
|
1829
|
+
cursor?: string;
|
|
1830
|
+
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
1831
|
+
limit?: number;
|
|
1832
|
+
};
|
|
1833
|
+
type ReturnType = {
|
|
1834
|
+
rows: Row[];
|
|
1835
|
+
nextCursor: string | null;
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1912
1838
|
//#endregion
|
|
1913
1839
|
//#region src/database/domains/Consumed.d.ts
|
|
1914
1840
|
type Event = {
|
|
1915
1841
|
id: string;
|
|
1916
1842
|
chainId: Id;
|
|
1917
1843
|
maker: Address;
|
|
1918
|
-
group:
|
|
1844
|
+
group: Hex;
|
|
1919
1845
|
amount: bigint;
|
|
1920
1846
|
blockNumber: number;
|
|
1921
1847
|
};
|
|
@@ -1945,13 +1871,13 @@ type LotsDomain = {
|
|
|
1945
1871
|
* For each (position, group), keeps only the biggest offer by assets.
|
|
1946
1872
|
* If lot exists and new offer is bigger, grows the lot and shifts higher lots.
|
|
1947
1873
|
*/
|
|
1948
|
-
create: (parameters: create$
|
|
1874
|
+
create: (parameters: create$5.Parameters) => Promise<void>;
|
|
1949
1875
|
/**
|
|
1950
1876
|
* Get lots with optional filtering.
|
|
1951
1877
|
*/
|
|
1952
1878
|
get: (parameters?: get$3.Parameters) => Promise<Lot[]>;
|
|
1953
1879
|
};
|
|
1954
|
-
declare namespace create$
|
|
1880
|
+
declare namespace create$5 {
|
|
1955
1881
|
type OfferLotInfo = {
|
|
1956
1882
|
positionChainId: Id;
|
|
1957
1883
|
positionContract: Address;
|
|
@@ -1960,62 +1886,18 @@ declare namespace create$3 {
|
|
|
1960
1886
|
size: bigint;
|
|
1961
1887
|
};
|
|
1962
1888
|
type Parameters = OfferLotInfo[];
|
|
1963
|
-
type ReturnType = undefined;
|
|
1964
|
-
}
|
|
1965
|
-
declare namespace get$3 {
|
|
1966
|
-
type Parameters = {
|
|
1967
|
-
chainId?: Id;
|
|
1968
|
-
user?: Address;
|
|
1969
|
-
contract?: Address;
|
|
1970
|
-
group?: string;
|
|
1971
|
-
};
|
|
1972
|
-
type ReturnType = Lot[];
|
|
1973
|
-
}
|
|
1974
|
-
declare function create$
|
|
1975
|
-
//#endregion
|
|
1976
|
-
//#region src/database/domains/Offers.d.ts
|
|
1977
|
-
type OffersDomain = {
|
|
1978
|
-
/** Create multiple offer. */
|
|
1979
|
-
create: (offers: Offer[]) => Promise<Hex[]>;
|
|
1980
|
-
/** Delete multiple offers by hashes or block number greater than or equal to the given value on a given chain.
|
|
1981
|
-
* @returns the number of offers deleted.
|
|
1982
|
-
*/
|
|
1983
|
-
delete: (parameters: {
|
|
1984
|
-
hashes: Hex[];
|
|
1985
|
-
} | {
|
|
1986
|
-
blockNumberGte: number;
|
|
1987
|
-
chainId: Id;
|
|
1988
|
-
}) => Promise<number>;
|
|
1989
|
-
/** Get all offers. */
|
|
1990
|
-
get: (parameters?: GetOffersParams) => Promise<{
|
|
1991
|
-
offers: Offer[];
|
|
1992
|
-
nextCursor: string | null;
|
|
1993
|
-
}>;
|
|
1994
|
-
/** Get obligations */
|
|
1995
|
-
getObligations: (parameters?: {
|
|
1996
|
-
ids?: Hex[];
|
|
1997
|
-
chainId?: Id;
|
|
1998
|
-
cursor?: string;
|
|
1999
|
-
limit?: number;
|
|
2000
|
-
}) => Promise<{
|
|
2001
|
-
obligations: Obligation[];
|
|
2002
|
-
nextCursor: string | null;
|
|
2003
|
-
}>;
|
|
2004
|
-
/** Get quotes for given obligations. */
|
|
2005
|
-
getQuotes: (parameters: {
|
|
2006
|
-
obligationIds: Hex[];
|
|
2007
|
-
}) => Promise<Quote[]>;
|
|
2008
|
-
};
|
|
2009
|
-
type PaginationParams$1 = {
|
|
2010
|
-
/** Cursor string returned by a previous call, for pagination */
|
|
2011
|
-
cursor?: string;
|
|
2012
|
-
/** Page size; defaults to {@link DEFAULT_LIMIT} */
|
|
2013
|
-
limit?: number;
|
|
2014
|
-
};
|
|
2015
|
-
type GetOffersParams = {
|
|
2016
|
-
/** Filter by offering address */
|
|
2017
|
-
offering?: Address;
|
|
2018
|
-
} & PaginationParams$1;
|
|
1889
|
+
type ReturnType = undefined;
|
|
1890
|
+
}
|
|
1891
|
+
declare namespace get$3 {
|
|
1892
|
+
type Parameters = {
|
|
1893
|
+
chainId?: Id;
|
|
1894
|
+
user?: Address;
|
|
1895
|
+
contract?: Address;
|
|
1896
|
+
group?: string;
|
|
1897
|
+
};
|
|
1898
|
+
type ReturnType = Lot[];
|
|
1899
|
+
}
|
|
1900
|
+
declare function create$5(db: Core): LotsDomain;
|
|
2019
1901
|
//#endregion
|
|
2020
1902
|
//#region src/database/domains/Offsets.d.ts
|
|
2021
1903
|
type Offset = {
|
|
@@ -2081,6 +1963,12 @@ type PositionsDomain = {
|
|
|
2081
1963
|
* @returns The positions. {@link get.ReturnType}
|
|
2082
1964
|
*/
|
|
2083
1965
|
get: (parameters?: get$1.Parameters) => Promise<get$1.ReturnType>;
|
|
1966
|
+
/**
|
|
1967
|
+
* Returns positions for a specific user with remaining balance calculation.
|
|
1968
|
+
* @param parameters - {@link getByUser.Parameters}
|
|
1969
|
+
* @returns The user's positions with remaining balances. {@link getByUser.ReturnType}
|
|
1970
|
+
*/
|
|
1971
|
+
getByUser: (parameters: getByUser.Parameters) => Promise<getByUser.ReturnType>;
|
|
2084
1972
|
/**
|
|
2085
1973
|
* Set all positions to empty after a given block number (inclusive), deletes all transfers linked to the positions.
|
|
2086
1974
|
* @param parameters - {@link setEmptyAfter.Parameters}
|
|
@@ -2106,6 +1994,24 @@ declare namespace get$1 {
|
|
|
2106
1994
|
nextCursor: string | null;
|
|
2107
1995
|
};
|
|
2108
1996
|
}
|
|
1997
|
+
declare namespace getByUser {
|
|
1998
|
+
type Parameters = PaginationParams & {
|
|
1999
|
+
/** The user address to get positions for. */
|
|
2000
|
+
user: Address;
|
|
2001
|
+
};
|
|
2002
|
+
type PositionWithReserved = {
|
|
2003
|
+
chainId: Id;
|
|
2004
|
+
contract: Address;
|
|
2005
|
+
user: Address;
|
|
2006
|
+
blockNumber: number;
|
|
2007
|
+
/** The amount reserved by active offers: max(lot.upper) - offset - consumed */
|
|
2008
|
+
reserved: bigint;
|
|
2009
|
+
};
|
|
2010
|
+
type ReturnType = {
|
|
2011
|
+
positions: PositionWithReserved[];
|
|
2012
|
+
nextCursor: string | null;
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2109
2015
|
declare namespace setEmptyAfter {
|
|
2110
2016
|
type Parameters = {
|
|
2111
2017
|
/** The chain id . */
|
|
@@ -2123,108 +2029,324 @@ type TransfersDomain = {
|
|
|
2123
2029
|
* @param transfers - {@link create.Parameters}
|
|
2124
2030
|
* @returns The number of transfers created. {@link create.ReturnType}
|
|
2125
2031
|
*/
|
|
2126
|
-
create: (transfers: create$
|
|
2032
|
+
create: (transfers: create$4.Parameters) => Promise<create$4.ReturnType>;
|
|
2127
2033
|
};
|
|
2128
|
-
declare namespace create$
|
|
2034
|
+
declare namespace create$4 {
|
|
2129
2035
|
type Parameters = Transfer[];
|
|
2130
2036
|
type ReturnType = number;
|
|
2131
2037
|
}
|
|
2132
|
-
declare const create$
|
|
2038
|
+
declare const create$4: (db: Core) => TransfersDomain;
|
|
2133
2039
|
//#endregion
|
|
2134
2040
|
//#region src/database/domains/Trees.d.ts
|
|
2135
2041
|
/**
|
|
2136
|
-
* Attestation data for a single offer, containing the merkle root, signature, and proof.
|
|
2042
|
+
* Attestation data for a single offer, containing the merkle root, signature, and proof.
|
|
2043
|
+
*/
|
|
2044
|
+
type Attestation = {
|
|
2045
|
+
root: Hex;
|
|
2046
|
+
signature: Hex;
|
|
2047
|
+
proof: Hex[];
|
|
2048
|
+
};
|
|
2049
|
+
/**
|
|
2050
|
+
* Input for creating trees with their signatures.
|
|
2051
|
+
*/
|
|
2052
|
+
type CreateInput = {
|
|
2053
|
+
tree: Tree;
|
|
2054
|
+
signature: Hex;
|
|
2055
|
+
blockNumber: number;
|
|
2056
|
+
};
|
|
2057
|
+
type TreesDomain = {
|
|
2058
|
+
/**
|
|
2059
|
+
* Creates trees, offers, and attestation links in a single transaction.
|
|
2060
|
+
*
|
|
2061
|
+
* @param trees - Array of decoded trees with signatures (batch insertion)
|
|
2062
|
+
* @returns Array of tree roots that were created/upserted
|
|
2063
|
+
*/
|
|
2064
|
+
create: (trees: CreateInput[]) => Promise<Hex[]>;
|
|
2065
|
+
/**
|
|
2066
|
+
* Retrieves merkle attestations for execution flow.
|
|
2067
|
+
*
|
|
2068
|
+
* @param hashes - Array of offer hashes to look up
|
|
2069
|
+
* @returns Map of offer hash to attestation (only entries with attestations are included)
|
|
2070
|
+
*/
|
|
2071
|
+
getAttestations: (hashes: Hex[]) => Promise<Map<Hex, Attestation>>;
|
|
2072
|
+
};
|
|
2073
|
+
//#endregion
|
|
2074
|
+
//#region src/database/domains/Validations.d.ts
|
|
2075
|
+
type GetParams = {
|
|
2076
|
+
status?: Status;
|
|
2077
|
+
cursor?: string;
|
|
2078
|
+
limit?: number;
|
|
2079
|
+
};
|
|
2080
|
+
type ValidationsDomain = {
|
|
2081
|
+
/**
|
|
2082
|
+
* Get validation statuses with optional filtering and pagination.
|
|
2083
|
+
*
|
|
2084
|
+
* @param params - Optional parameters for filtering and pagination
|
|
2085
|
+
* @returns Array of validation statuses and next cursor for pagination
|
|
2086
|
+
*/
|
|
2087
|
+
get: (params?: GetParams) => Promise<{
|
|
2088
|
+
validations: Validation[];
|
|
2089
|
+
nextCursor: string | null;
|
|
2090
|
+
}>;
|
|
2091
|
+
/**
|
|
2092
|
+
* Upsert validations
|
|
2093
|
+
*
|
|
2094
|
+
* @param validations - Array of validations to upsert
|
|
2095
|
+
*/
|
|
2096
|
+
upsert: (validations: Validation[]) => Promise<void>;
|
|
2097
|
+
};
|
|
2098
|
+
declare namespace Database_d_exports {
|
|
2099
|
+
export { Core, Database, Driver, WithDomains, connect$2 as connect };
|
|
2100
|
+
}
|
|
2101
|
+
type Driver = ReturnType<typeof drizzle> | ReturnType<typeof drizzle$1>;
|
|
2102
|
+
type Domains = {
|
|
2103
|
+
book: BookDomain;
|
|
2104
|
+
blocks: BlocksDomain;
|
|
2105
|
+
offers: OffersDomain;
|
|
2106
|
+
consumed: ConsumedDomain;
|
|
2107
|
+
lots: LotsDomain;
|
|
2108
|
+
offsets: OffsetsDomain;
|
|
2109
|
+
oracles: OraclesDomain;
|
|
2110
|
+
trees: TreesDomain;
|
|
2111
|
+
validations: ValidationsDomain;
|
|
2112
|
+
positions: PositionsDomain;
|
|
2113
|
+
transfers: TransfersDomain;
|
|
2114
|
+
};
|
|
2115
|
+
type WithDomains<D extends Driver> = D & Domains;
|
|
2116
|
+
type Core = Omit<WithDomains<Driver>, "transaction"> & {
|
|
2117
|
+
transaction<T>(fn: (tx: WithDomains<Driver>) => Promise<T>): Promise<T>;
|
|
2118
|
+
};
|
|
2119
|
+
type Database = Core & {
|
|
2120
|
+
name: "pg" | "pglite";
|
|
2121
|
+
pool: Pool | PGlite;
|
|
2122
|
+
applyMigrations: (folderPath: string) => Promise<void>;
|
|
2123
|
+
clean: () => Promise<void>;
|
|
2124
|
+
};
|
|
2125
|
+
/**
|
|
2126
|
+
* Connect to the database.
|
|
2127
|
+
* @notice If no connection string is provided, an in-process PGLite database is created.
|
|
2128
|
+
* @param {string=} [connectionString] - The optional connection string for the Postgres database.
|
|
2129
|
+
* @returns The database client {@link connect.ReturnType}
|
|
2130
|
+
*/
|
|
2131
|
+
declare function connect$2(chainRegistry: ChainRegistry, connectionString?: string): Database;
|
|
2132
|
+
declare namespace Gate_d_exports {
|
|
2133
|
+
export { Batch, Issue, Result, Rule, RuleNames, Single, batch$1 as batch, run, single };
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* A validation rule.
|
|
2137
|
+
*/
|
|
2138
|
+
type Rule<T, Name$2 extends string = string> = {
|
|
2139
|
+
kind: "single";
|
|
2140
|
+
name: Name$2;
|
|
2141
|
+
description: string;
|
|
2142
|
+
run: Single<T, Name$2>;
|
|
2143
|
+
} | {
|
|
2144
|
+
kind: "batch";
|
|
2145
|
+
name: Name$2;
|
|
2146
|
+
description: string;
|
|
2147
|
+
run: Batch<T, Name$2>;
|
|
2148
|
+
};
|
|
2149
|
+
type RuleNames<Rules$1 extends readonly {
|
|
2150
|
+
name: string;
|
|
2151
|
+
}[]> = Rules$1[number]["name"];
|
|
2152
|
+
/**
|
|
2153
|
+
* A single item validation rule.
|
|
2154
|
+
* @param item - The item to validate.
|
|
2155
|
+
* @returns The issue that was found. If the item is valid, this will be undefined.
|
|
2156
|
+
*/
|
|
2157
|
+
type Single<T, RuleName extends string> = (item: T) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
|
|
2158
|
+
/**
|
|
2159
|
+
* A batch item validation rule.
|
|
2160
|
+
* @param items - The items to validate.
|
|
2161
|
+
* @returns A map of the items to the issue that was found.
|
|
2162
|
+
*/
|
|
2163
|
+
type Batch<T, RuleName extends string> = (items: T[]) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
|
|
2164
|
+
/**
|
|
2165
|
+
* Create a validation rule iterating over a single item at a time.
|
|
2166
|
+
* @param name - The name of the rule.
|
|
2167
|
+
* @param description - A human-readable description of the rule.
|
|
2168
|
+
* @param run - The function that validates the rule.
|
|
2169
|
+
* @returns The created rule.
|
|
2170
|
+
*/
|
|
2171
|
+
declare function single<Name$2 extends string, T>(name: Name$2, description: string, run: Single<T, Name$2>): Rule<T, Name$2>;
|
|
2172
|
+
/**
|
|
2173
|
+
* Create a validation rule iterating over a batch of items at a time.
|
|
2174
|
+
* @param name - The name of the rule.
|
|
2175
|
+
* @param description - A human-readable description of the rule.
|
|
2176
|
+
* @param run - The function that validates the rule.
|
|
2177
|
+
* @returns The created rule.
|
|
2178
|
+
*/
|
|
2179
|
+
declare function batch$1<Name$2 extends string, T>(name: Name$2, description: string, run: Batch<T, Name$2>): Rule<T, Name$2>;
|
|
2180
|
+
/**
|
|
2181
|
+
* A validation issue.
|
|
2182
|
+
*/
|
|
2183
|
+
type Issue<T, RuleName extends string = string> = {
|
|
2184
|
+
/** The name of the rule that caused the issue. */
|
|
2185
|
+
ruleName: RuleName;
|
|
2186
|
+
/** The message of the issue. */
|
|
2187
|
+
message: string;
|
|
2188
|
+
/** The item that was not valid. */
|
|
2189
|
+
item: T;
|
|
2190
|
+
};
|
|
2191
|
+
/**
|
|
2192
|
+
* The result of a validation.
|
|
2193
|
+
*/
|
|
2194
|
+
type Result<T, RuleName extends string = string> = {
|
|
2195
|
+
/** The items that were valid. */
|
|
2196
|
+
valid: T[];
|
|
2197
|
+
/** The reports of the failed validations. */
|
|
2198
|
+
issues: Issue<T, RuleName>[];
|
|
2199
|
+
};
|
|
2200
|
+
declare function run<T, Name$2 extends string, Rules$1 extends readonly Rule<T, Name$2>[]>(parameters: {
|
|
2201
|
+
items: T[];
|
|
2202
|
+
rules: Rules$1;
|
|
2203
|
+
chunkSize?: number;
|
|
2204
|
+
}): Promise<Result<T, RuleNames<Rules$1>>>;
|
|
2205
|
+
declare namespace Gatekeeper_d_exports {
|
|
2206
|
+
export { Gatekeeper, Rules, create$3 as create };
|
|
2207
|
+
}
|
|
2208
|
+
type Rules = readonly Rule<Offer, string>[];
|
|
2209
|
+
type Gatekeeper = {
|
|
2210
|
+
rules: Rules;
|
|
2211
|
+
isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
|
|
2212
|
+
};
|
|
2213
|
+
type GatekeeperParameters = {
|
|
2214
|
+
rules: Rules;
|
|
2215
|
+
};
|
|
2216
|
+
declare function create$3(parameters: GatekeeperParameters): Gatekeeper;
|
|
2217
|
+
declare namespace GateConfig_d_exports {
|
|
2218
|
+
export { CallbackConfig, GateConfig, assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
|
|
2219
|
+
}
|
|
2220
|
+
type GateConfig = {
|
|
2221
|
+
callbacks?: CallbackConfig[];
|
|
2222
|
+
maturities?: MaturityType[];
|
|
2223
|
+
};
|
|
2224
|
+
type CallbackConfig = {
|
|
2225
|
+
type: CallbackType.BuyVaultV1Callback;
|
|
2226
|
+
addresses: Address[];
|
|
2227
|
+
vaultFactories: Address[];
|
|
2228
|
+
} | {
|
|
2229
|
+
type: CallbackType.SellERC20Callback;
|
|
2230
|
+
addresses: Address[];
|
|
2231
|
+
} | {
|
|
2232
|
+
type: CallbackType.BuyWithEmptyCallback;
|
|
2233
|
+
};
|
|
2234
|
+
declare function getCallback(chain: Name$1, type: CallbackType.BuyVaultV1Callback): Extract<CallbackConfig, {
|
|
2235
|
+
type: CallbackType.BuyVaultV1Callback;
|
|
2236
|
+
}> | undefined;
|
|
2237
|
+
declare function getCallback(chain: Name$1, type: CallbackType.SellERC20Callback): Extract<CallbackConfig, {
|
|
2238
|
+
type: CallbackType.SellERC20Callback;
|
|
2239
|
+
}> | undefined;
|
|
2240
|
+
declare function getCallback(chain: Name$1, type: CallbackType.BuyWithEmptyCallback): Extract<CallbackConfig, {
|
|
2241
|
+
type: CallbackType.BuyWithEmptyCallback;
|
|
2242
|
+
}> | undefined;
|
|
2243
|
+
declare function getCallback(chain: Name$1, type: CallbackType): CallbackConfig | undefined;
|
|
2244
|
+
/**
|
|
2245
|
+
* Attempts to infer the configured callback type from a callback address on a chain.
|
|
2246
|
+
* Skips the empty callback type as it does not carry addresses.
|
|
2247
|
+
*
|
|
2248
|
+
* @param chain - Chain name for which to infer the callback type
|
|
2249
|
+
* @param address - Callback contract address
|
|
2250
|
+
* @returns The callback type when found, otherwise undefined
|
|
2251
|
+
*/
|
|
2252
|
+
declare function getCallbackType(chain: Name$1, address: Address): CallbackType | undefined;
|
|
2253
|
+
/**
|
|
2254
|
+
* Returns the callback addresses for a given chain and callback type, if it exists.
|
|
2255
|
+
* @param chain - Chain name for which to read the validation configuration
|
|
2256
|
+
* @param type - Callback type to retrieve
|
|
2257
|
+
* @returns The matching callback addresses or an empty array if not configured
|
|
2258
|
+
*/
|
|
2259
|
+
declare function getCallbackTypeAddresses(chain: Name$1, type: CallbackType): Address[];
|
|
2260
|
+
/**
|
|
2261
|
+
* Returns the list of allowed non-empty callback addresses for a chain.
|
|
2262
|
+
*
|
|
2263
|
+
* @param chain - Chain name
|
|
2264
|
+
* @returns Array of allowed callback addresses (lowercased). Empty when none configured
|
|
2265
|
+
*/
|
|
2266
|
+
declare const getCallbackAddresses: (chain: Name$1) => Address[];
|
|
2267
|
+
declare const assets: Record<string, Address[]>;
|
|
2268
|
+
declare const configs: Record<Name$1, GateConfig>;
|
|
2269
|
+
//#endregion
|
|
2270
|
+
//#region src/gatekeeper/morphoRules.d.ts
|
|
2271
|
+
declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "token"> | Rule<Offer, "mixed_maker"> | Rule<Offer, "amount_mutual_exclusivity">)[];
|
|
2272
|
+
declare namespace Rules_d_exports {
|
|
2273
|
+
export { ValidityParameters, amountMutualExclusivity, callback, chains$1 as chains, maturity, sameMaker, token, validity };
|
|
2274
|
+
}
|
|
2275
|
+
type ValidityParameters = {
|
|
2276
|
+
client: PublicClient<Transport, Chain$1>;
|
|
2277
|
+
};
|
|
2278
|
+
/**
|
|
2279
|
+
* set of rules to validate offers.
|
|
2280
|
+
*
|
|
2281
|
+
* @param parameters - Validity parameters with chain and client
|
|
2282
|
+
* @returns Array of validation rules to evaluate against offers
|
|
2283
|
+
*/
|
|
2284
|
+
declare function validity(parameters: ValidityParameters): (Rule<Offer, "expiry"> | Rule<Offer, "sell_erc20_callback_invalid"> | Rule<Offer, "buy_offers_callback_vault_invalid">)[];
|
|
2285
|
+
declare const chains$1: ({
|
|
2286
|
+
chains: chains$1
|
|
2287
|
+
}: {
|
|
2288
|
+
chains: Chain$1[];
|
|
2289
|
+
}) => Rule<Offer, "chain_ids">;
|
|
2290
|
+
declare const maturity: ({
|
|
2291
|
+
maturities
|
|
2292
|
+
}: {
|
|
2293
|
+
maturities: MaturityType[];
|
|
2294
|
+
}) => Rule<Offer, "maturity">;
|
|
2295
|
+
declare const callback: ({
|
|
2296
|
+
callbacks,
|
|
2297
|
+
allowedAddresses
|
|
2298
|
+
}: {
|
|
2299
|
+
callbacks: CallbackType[];
|
|
2300
|
+
allowedAddresses: Address[];
|
|
2301
|
+
}) => Rule<Offer, "callback">;
|
|
2302
|
+
/**
|
|
2303
|
+
* A validation rule that checks if the offer's tokens are allowed for its chain.
|
|
2304
|
+
* @param assetsByChainId - Allowed assets indexed by chain id.
|
|
2305
|
+
* @returns The issue that was found. If the offer is valid, this will be undefined.
|
|
2137
2306
|
*/
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2307
|
+
declare const token: ({
|
|
2308
|
+
assetsByChainId
|
|
2309
|
+
}: {
|
|
2310
|
+
assetsByChainId: Partial<Record<Id, Address[]>>;
|
|
2311
|
+
}) => Rule<Offer, "token">;
|
|
2143
2312
|
/**
|
|
2144
|
-
*
|
|
2313
|
+
* A batch validation rule that ensures all offers in a tree have the same maker address.
|
|
2314
|
+
* Returns an issue only for the first non-conforming offer.
|
|
2315
|
+
* This rule is signing-agnostic; signer verification is handled at the collector level.
|
|
2145
2316
|
*/
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
* @returns Array of tree roots that were created/upserted
|
|
2156
|
-
*/
|
|
2157
|
-
create: (trees: CreateInput[]) => Promise<Hex[]>;
|
|
2158
|
-
/**
|
|
2159
|
-
* Retrieves merkle attestations for execution flow.
|
|
2160
|
-
*
|
|
2161
|
-
* @param hashes - Array of offer hashes to look up
|
|
2162
|
-
* @returns Map of offer hash to attestation (only entries with attestations are included)
|
|
2163
|
-
*/
|
|
2164
|
-
getAttestations: (hashes: Hex[]) => Promise<Map<Hex, Attestation>>;
|
|
2165
|
-
};
|
|
2166
|
-
//#endregion
|
|
2167
|
-
//#region src/database/domains/Validations.d.ts
|
|
2168
|
-
type GetParams = {
|
|
2169
|
-
status?: Status;
|
|
2170
|
-
cursor?: string;
|
|
2171
|
-
limit?: number;
|
|
2172
|
-
};
|
|
2173
|
-
type ValidationsDomain = {
|
|
2174
|
-
/**
|
|
2175
|
-
* Get validation statuses with optional filtering and pagination.
|
|
2176
|
-
*
|
|
2177
|
-
* @param params - Optional parameters for filtering and pagination
|
|
2178
|
-
* @returns Array of validation statuses and next cursor for pagination
|
|
2179
|
-
*/
|
|
2180
|
-
get: (params?: GetParams) => Promise<{
|
|
2181
|
-
validations: Validation[];
|
|
2182
|
-
nextCursor: string | null;
|
|
2183
|
-
}>;
|
|
2184
|
-
/**
|
|
2185
|
-
* Upsert validations
|
|
2186
|
-
*
|
|
2187
|
-
* @param validations - Array of validations to upsert
|
|
2188
|
-
*/
|
|
2189
|
-
upsert: (validations: Validation[]) => Promise<void>;
|
|
2190
|
-
};
|
|
2191
|
-
declare namespace Database_d_exports {
|
|
2192
|
-
export { Core, Database, Driver, WithDomains, connect$2 as connect };
|
|
2317
|
+
declare const sameMaker: () => Rule<Offer, "mixed_maker">;
|
|
2318
|
+
/**
|
|
2319
|
+
* A validation rule that ensures mutual exclusivity of offer amount fields.
|
|
2320
|
+
* At most one of (assets, obligationUnits, obligationShares) can be non-zero.
|
|
2321
|
+
* Matches contract requirement: `atMostOneNonZero(offer.assets, offer.obligationUnits, offer.obligationShares)`.
|
|
2322
|
+
*/
|
|
2323
|
+
declare const amountMutualExclusivity: () => Rule<Offer, "amount_mutual_exclusivity">;
|
|
2324
|
+
declare namespace Indexer_d_exports {
|
|
2325
|
+
export { Indexer, IndexerConfig, create$2 as create, from$6 as from };
|
|
2193
2326
|
}
|
|
2194
|
-
type
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
offers: OffersDomain;
|
|
2199
|
-
chains: ChainsDomain;
|
|
2200
|
-
consumed: ConsumedDomain;
|
|
2201
|
-
lots: LotsDomain;
|
|
2202
|
-
offsets: OffsetsDomain;
|
|
2203
|
-
oracles: OraclesDomain;
|
|
2204
|
-
trees: TreesDomain;
|
|
2205
|
-
validations: ValidationsDomain;
|
|
2206
|
-
positions: PositionsDomain;
|
|
2207
|
-
transfers: TransfersDomain;
|
|
2208
|
-
};
|
|
2209
|
-
type WithDomains<D extends Driver> = D & Domains;
|
|
2210
|
-
type Core = Omit<WithDomains<Driver>, "transaction"> & {
|
|
2211
|
-
transaction<T>(fn: (tx: WithDomains<Driver>) => Promise<T>): Promise<T>;
|
|
2327
|
+
type Indexer = {
|
|
2328
|
+
start: () => () => void;
|
|
2329
|
+
next: () => Promise<void>;
|
|
2330
|
+
return: () => Promise<void>;
|
|
2212
2331
|
};
|
|
2213
|
-
type
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2332
|
+
type IndexerConfig<client extends PublicClient<Transport, Chain$1, Account | undefined>> = {
|
|
2333
|
+
client: client;
|
|
2334
|
+
db: Database;
|
|
2335
|
+
gatekeeper: Gatekeeper;
|
|
2336
|
+
interval?: number;
|
|
2337
|
+
maxBatchSize?: number;
|
|
2338
|
+
maxBlockNumber?: number;
|
|
2339
|
+
blockWindow?: number;
|
|
2340
|
+
retryAttempts?: number;
|
|
2341
|
+
retryDelayMs?: number;
|
|
2218
2342
|
};
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
*/
|
|
2225
|
-
declare function connect$2(connectionString?: string): Database;
|
|
2343
|
+
declare function from$6<client extends PublicClient<Transport, Chain$1, Account | undefined>>(config: IndexerConfig<client>): Indexer;
|
|
2344
|
+
declare function create$2<client extends PublicClient<Transport, Chain$1, Account | undefined>>(params: {
|
|
2345
|
+
collectors: Collector[];
|
|
2346
|
+
client: client;
|
|
2347
|
+
}): Indexer;
|
|
2226
2348
|
declare namespace Health_d_exports {
|
|
2227
|
-
export { ChainHealth$1 as ChainHealth, CollectorHealth$1 as CollectorHealth, CollectorHealthStatus, HealthService, HealthServiceParameters, RouterStatus, create$1 as create };
|
|
2349
|
+
export { ChainHealth$1 as ChainHealth, CollectorHealth$1 as CollectorHealth, CollectorHealthStatus, HealthService, HealthServiceParameters, MissingCollector, RouterHealth, RouterStatus, create$1 as create };
|
|
2228
2350
|
}
|
|
2229
2351
|
type CollectorHealthStatus = "live" | "lagging" | "unknown";
|
|
2230
2352
|
type RouterStatus = "live" | "syncing";
|
|
@@ -2235,16 +2357,29 @@ type CollectorHealth$1 = {
|
|
|
2235
2357
|
updatedAt: string | null;
|
|
2236
2358
|
lag: number | null;
|
|
2237
2359
|
status: CollectorHealthStatus;
|
|
2360
|
+
initialized: boolean;
|
|
2238
2361
|
};
|
|
2239
2362
|
type ChainHealth$1 = {
|
|
2240
2363
|
chainId: Id;
|
|
2241
|
-
localBlockNumber: number;
|
|
2364
|
+
localBlockNumber: number | null;
|
|
2242
2365
|
remoteBlockNumber: number | null;
|
|
2243
|
-
epoch: string;
|
|
2244
|
-
updatedAt: string;
|
|
2366
|
+
epoch: string | null;
|
|
2367
|
+
updatedAt: string | null;
|
|
2368
|
+
initialized: boolean;
|
|
2369
|
+
};
|
|
2370
|
+
type MissingCollector = {
|
|
2371
|
+
chainId: Id;
|
|
2372
|
+
name: Name;
|
|
2373
|
+
};
|
|
2374
|
+
type RouterHealth = {
|
|
2375
|
+
status: RouterStatus;
|
|
2376
|
+
initialized: boolean;
|
|
2377
|
+
missingChains: Id[];
|
|
2378
|
+
missingCollectors: MissingCollector[];
|
|
2245
2379
|
};
|
|
2246
2380
|
type HealthService = {
|
|
2247
|
-
|
|
2381
|
+
getSnapshot: () => Promise<Snapshot>;
|
|
2382
|
+
getStatus: () => Promise<RouterHealth>;
|
|
2248
2383
|
getCollectors: () => Promise<CollectorHealth$1[]>;
|
|
2249
2384
|
getChains: () => Promise<ChainHealth$1[]>;
|
|
2250
2385
|
};
|
|
@@ -2254,6 +2389,16 @@ type HealthServiceParameters = {
|
|
|
2254
2389
|
maxAllowedLag?: number;
|
|
2255
2390
|
/** Map of chainId to client for fetching remote block numbers. */
|
|
2256
2391
|
healthClients?: Map<Id, Client>;
|
|
2392
|
+
/** Chain registry for deriving expected initialization state. */
|
|
2393
|
+
chainRegistry?: ChainRegistry;
|
|
2394
|
+
};
|
|
2395
|
+
type Snapshot = {
|
|
2396
|
+
status: RouterStatus;
|
|
2397
|
+
initialized: boolean;
|
|
2398
|
+
missingChains: Id[];
|
|
2399
|
+
missingCollectors: MissingCollector[];
|
|
2400
|
+
collectors: CollectorHealth$1[];
|
|
2401
|
+
chains: ChainHealth$1[];
|
|
2257
2402
|
};
|
|
2258
2403
|
/**
|
|
2259
2404
|
* Create a health service that exposes collector and chain block numbers.
|
|
@@ -2268,24 +2413,26 @@ type ApiConfig = {
|
|
|
2268
2413
|
db: Database;
|
|
2269
2414
|
gatekeeper: Gatekeeper;
|
|
2270
2415
|
port: number;
|
|
2416
|
+
chainRegistry: ChainRegistry;
|
|
2271
2417
|
};
|
|
2272
|
-
declare function from$
|
|
2418
|
+
declare function from$5(config: ApiConfig): RouterApi;
|
|
2273
2419
|
type CreateParameters = {
|
|
2274
2420
|
db: Database;
|
|
2275
2421
|
gatekeeper: Gatekeeper;
|
|
2276
2422
|
port: number;
|
|
2423
|
+
chainRegistry: ChainRegistry;
|
|
2277
2424
|
};
|
|
2278
2425
|
declare function create(params: CreateParameters): RouterApi;
|
|
2279
2426
|
declare namespace BookResponse_d_exports {
|
|
2280
|
-
export { BookLevelResponse, from$
|
|
2427
|
+
export { BookLevelResponse, from$4 as from };
|
|
2281
2428
|
}
|
|
2282
2429
|
type BookLevelResponse = {
|
|
2283
|
-
|
|
2430
|
+
price: string;
|
|
2284
2431
|
assets: string;
|
|
2285
2432
|
count: number;
|
|
2286
2433
|
};
|
|
2287
|
-
declare function from$
|
|
2288
|
-
|
|
2434
|
+
declare function from$4(level: {
|
|
2435
|
+
price: bigint;
|
|
2289
2436
|
assets: bigint;
|
|
2290
2437
|
count: number;
|
|
2291
2438
|
}): BookLevelResponse;
|
|
@@ -2302,6 +2449,7 @@ declare const CollectorHealth: z.ZodObject<{
|
|
|
2302
2449
|
live: "live";
|
|
2303
2450
|
lagging: "lagging";
|
|
2304
2451
|
}>;
|
|
2452
|
+
initialized: z.ZodBoolean;
|
|
2305
2453
|
}, z.core.$strip>;
|
|
2306
2454
|
declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
|
|
2307
2455
|
name: z.ZodString;
|
|
@@ -2314,24 +2462,33 @@ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
|
|
|
2314
2462
|
live: "live";
|
|
2315
2463
|
lagging: "lagging";
|
|
2316
2464
|
}>;
|
|
2465
|
+
initialized: z.ZodBoolean;
|
|
2317
2466
|
}, z.core.$strip>>;
|
|
2318
2467
|
declare const ChainHealth: z.ZodObject<{
|
|
2319
2468
|
chain_id: z.ZodNumber;
|
|
2320
|
-
local_block_number: z.ZodNumber
|
|
2469
|
+
local_block_number: z.ZodNullable<z.ZodNumber>;
|
|
2321
2470
|
remote_block_number: z.ZodNullable<z.ZodNumber>;
|
|
2322
|
-
updated_at: z.ZodString
|
|
2471
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
2472
|
+
initialized: z.ZodBoolean;
|
|
2323
2473
|
}, z.core.$strip>;
|
|
2324
2474
|
declare const ChainsHealthResponse: z.ZodArray<z.ZodObject<{
|
|
2325
2475
|
chain_id: z.ZodNumber;
|
|
2326
|
-
local_block_number: z.ZodNumber
|
|
2476
|
+
local_block_number: z.ZodNullable<z.ZodNumber>;
|
|
2327
2477
|
remote_block_number: z.ZodNullable<z.ZodNumber>;
|
|
2328
|
-
updated_at: z.ZodString
|
|
2478
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
2479
|
+
initialized: z.ZodBoolean;
|
|
2329
2480
|
}, z.core.$strip>>;
|
|
2330
2481
|
declare const RouterStatusResponse: z.ZodObject<{
|
|
2331
2482
|
status: z.ZodEnum<{
|
|
2332
2483
|
live: "live";
|
|
2333
2484
|
syncing: "syncing";
|
|
2334
2485
|
}>;
|
|
2486
|
+
initialized: z.ZodBoolean;
|
|
2487
|
+
missing_chains: z.ZodArray<z.ZodNumber>;
|
|
2488
|
+
missing_collectors: z.ZodArray<z.ZodObject<{
|
|
2489
|
+
chain_id: z.ZodNumber;
|
|
2490
|
+
name: z.ZodString;
|
|
2491
|
+
}, z.core.$strip>>;
|
|
2335
2492
|
}, z.core.$strip>;
|
|
2336
2493
|
type CollectorsHealthResponse = z.infer<typeof CollectorsHealthResponse>;
|
|
2337
2494
|
type ChainsHealthResponse = z.infer<typeof ChainsHealthResponse>;
|
|
@@ -2353,13 +2510,13 @@ interface paths {
|
|
|
2353
2510
|
};
|
|
2354
2511
|
/**
|
|
2355
2512
|
* Get aggregated book
|
|
2356
|
-
* @description Returns aggregated book data for a given obligation and side. Offers are grouped by
|
|
2513
|
+
* @description Returns aggregated book data for a given obligation and side. Offers are grouped by computed price with summed takeable amounts. Book levels are sorted by price (ascending for buy side, descending for sell side).
|
|
2357
2514
|
*/
|
|
2358
2515
|
get: {
|
|
2359
2516
|
parameters: {
|
|
2360
2517
|
query?: {
|
|
2361
2518
|
/**
|
|
2362
|
-
* @description Maximum number of
|
|
2519
|
+
* @description Maximum number of price levels to return.
|
|
2363
2520
|
* @example 10
|
|
2364
2521
|
*/
|
|
2365
2522
|
limit?: number;
|
|
@@ -2370,7 +2527,18 @@ interface paths {
|
|
|
2370
2527
|
cursor?: string;
|
|
2371
2528
|
};
|
|
2372
2529
|
header?: never;
|
|
2373
|
-
path
|
|
2530
|
+
path: {
|
|
2531
|
+
/**
|
|
2532
|
+
* @description Book side (buy or sell).
|
|
2533
|
+
* @example buy
|
|
2534
|
+
*/
|
|
2535
|
+
side: "buy" | "sell";
|
|
2536
|
+
/**
|
|
2537
|
+
* @description Obligation id.
|
|
2538
|
+
* @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67
|
|
2539
|
+
*/
|
|
2540
|
+
obligationId: string;
|
|
2541
|
+
};
|
|
2374
2542
|
cookie?: never;
|
|
2375
2543
|
};
|
|
2376
2544
|
requestBody?: never;
|
|
@@ -2403,6 +2571,45 @@ interface paths {
|
|
|
2403
2571
|
patch?: never;
|
|
2404
2572
|
trace?: never;
|
|
2405
2573
|
};
|
|
2574
|
+
"/v1/config": {
|
|
2575
|
+
parameters: {
|
|
2576
|
+
query?: never;
|
|
2577
|
+
header?: never;
|
|
2578
|
+
path?: never;
|
|
2579
|
+
cookie?: never;
|
|
2580
|
+
};
|
|
2581
|
+
/**
|
|
2582
|
+
* Get router configuration
|
|
2583
|
+
* @description Returns chain configurations including contract addresses and supported maturity timestamps.
|
|
2584
|
+
*/
|
|
2585
|
+
get: {
|
|
2586
|
+
parameters: {
|
|
2587
|
+
query?: never;
|
|
2588
|
+
header?: never;
|
|
2589
|
+
path?: never;
|
|
2590
|
+
cookie?: never;
|
|
2591
|
+
};
|
|
2592
|
+
requestBody?: never;
|
|
2593
|
+
responses: {
|
|
2594
|
+
/** @description Success */
|
|
2595
|
+
200: {
|
|
2596
|
+
headers: {
|
|
2597
|
+
[name: string]: unknown;
|
|
2598
|
+
};
|
|
2599
|
+
content: {
|
|
2600
|
+
"application/json": components["schemas"]["ConfigSuccessResponse"];
|
|
2601
|
+
};
|
|
2602
|
+
};
|
|
2603
|
+
};
|
|
2604
|
+
};
|
|
2605
|
+
put?: never;
|
|
2606
|
+
post?: never;
|
|
2607
|
+
delete?: never;
|
|
2608
|
+
options?: never;
|
|
2609
|
+
head?: never;
|
|
2610
|
+
patch?: never;
|
|
2611
|
+
trace?: never;
|
|
2612
|
+
};
|
|
2406
2613
|
"/v1/offers": {
|
|
2407
2614
|
parameters: {
|
|
2408
2615
|
query?: never;
|
|
@@ -2412,7 +2619,7 @@ interface paths {
|
|
|
2412
2619
|
};
|
|
2413
2620
|
/**
|
|
2414
2621
|
* List all offers
|
|
2415
|
-
* @description Returns offers. Provide either `obligation_id` + `side` (order book) or `
|
|
2622
|
+
* @description Returns offers. Provide either `obligation_id` + `side` (order book) or `maker` (by maker address).
|
|
2416
2623
|
*/
|
|
2417
2624
|
get: {
|
|
2418
2625
|
parameters: {
|
|
@@ -2431,9 +2638,9 @@ interface paths {
|
|
|
2431
2638
|
* @description Maker address to filter offers by. Alternative to obligation_id + side.
|
|
2432
2639
|
* @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
|
|
2433
2640
|
*/
|
|
2434
|
-
|
|
2641
|
+
maker?: string;
|
|
2435
2642
|
/**
|
|
2436
|
-
* @description Obligation id used to filter offers. Required when not using
|
|
2643
|
+
* @description Obligation id used to filter offers. Required when not using maker.
|
|
2437
2644
|
* @example 0x1234567890123456789012345678901234567890123456789012345678901234
|
|
2438
2645
|
*/
|
|
2439
2646
|
obligation_id?: string;
|
|
@@ -2491,9 +2698,35 @@ interface paths {
|
|
|
2491
2698
|
get: {
|
|
2492
2699
|
parameters: {
|
|
2493
2700
|
query?: {
|
|
2494
|
-
/**
|
|
2701
|
+
/**
|
|
2702
|
+
* @description Filter by exact maturity timestamp (unix seconds).
|
|
2703
|
+
* @example 1761922800
|
|
2704
|
+
*/
|
|
2705
|
+
maturity?: number;
|
|
2706
|
+
/**
|
|
2707
|
+
* @description Filter by collateral token (matches any collateral in the obligation).
|
|
2708
|
+
* @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751
|
|
2709
|
+
*/
|
|
2710
|
+
collateral_token?: string;
|
|
2711
|
+
/**
|
|
2712
|
+
* @description Filter by loan token address.
|
|
2713
|
+
* @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078
|
|
2714
|
+
*/
|
|
2715
|
+
loan_token?: string;
|
|
2716
|
+
/**
|
|
2717
|
+
* @description Filter by chain ID.
|
|
2718
|
+
* @example 1
|
|
2719
|
+
*/
|
|
2720
|
+
chain?: number;
|
|
2721
|
+
/**
|
|
2722
|
+
* @description Maximum number of obligations to return.
|
|
2723
|
+
* @example 10
|
|
2724
|
+
*/
|
|
2495
2725
|
limit?: number;
|
|
2496
|
-
/**
|
|
2726
|
+
/**
|
|
2727
|
+
* @description Obligation id cursor for pagination.
|
|
2728
|
+
* @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc
|
|
2729
|
+
*/
|
|
2497
2730
|
cursor?: string;
|
|
2498
2731
|
};
|
|
2499
2732
|
header?: never;
|
|
@@ -2545,7 +2778,13 @@ interface paths {
|
|
|
2545
2778
|
parameters: {
|
|
2546
2779
|
query?: never;
|
|
2547
2780
|
header?: never;
|
|
2548
|
-
path
|
|
2781
|
+
path: {
|
|
2782
|
+
/**
|
|
2783
|
+
* @description Obligation id.
|
|
2784
|
+
* @example 0x12590ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9f67
|
|
2785
|
+
*/
|
|
2786
|
+
obligationId: string;
|
|
2787
|
+
};
|
|
2549
2788
|
cookie?: never;
|
|
2550
2789
|
};
|
|
2551
2790
|
requestBody?: never;
|
|
@@ -2591,7 +2830,13 @@ interface paths {
|
|
|
2591
2830
|
*/
|
|
2592
2831
|
get: {
|
|
2593
2832
|
parameters: {
|
|
2594
|
-
query?:
|
|
2833
|
+
query?: {
|
|
2834
|
+
/**
|
|
2835
|
+
* @description Fail the request if initialization is incomplete.
|
|
2836
|
+
* @example true
|
|
2837
|
+
*/
|
|
2838
|
+
strict?: boolean;
|
|
2839
|
+
};
|
|
2595
2840
|
header?: never;
|
|
2596
2841
|
path?: never;
|
|
2597
2842
|
cookie?: never;
|
|
@@ -2630,7 +2875,13 @@ interface paths {
|
|
|
2630
2875
|
*/
|
|
2631
2876
|
get: {
|
|
2632
2877
|
parameters: {
|
|
2633
|
-
query?:
|
|
2878
|
+
query?: {
|
|
2879
|
+
/**
|
|
2880
|
+
* @description Fail the request if initialization is incomplete.
|
|
2881
|
+
* @example true
|
|
2882
|
+
*/
|
|
2883
|
+
strict?: boolean;
|
|
2884
|
+
};
|
|
2634
2885
|
header?: never;
|
|
2635
2886
|
path?: never;
|
|
2636
2887
|
cookie?: never;
|
|
@@ -2669,9 +2920,71 @@ interface paths {
|
|
|
2669
2920
|
*/
|
|
2670
2921
|
get: {
|
|
2671
2922
|
parameters: {
|
|
2672
|
-
query?:
|
|
2923
|
+
query?: {
|
|
2924
|
+
/**
|
|
2925
|
+
* @description Fail the request if initialization is incomplete.
|
|
2926
|
+
* @example true
|
|
2927
|
+
*/
|
|
2928
|
+
strict?: boolean;
|
|
2929
|
+
};
|
|
2930
|
+
header?: never;
|
|
2931
|
+
path?: never;
|
|
2932
|
+
cookie?: never;
|
|
2933
|
+
};
|
|
2934
|
+
requestBody?: never;
|
|
2935
|
+
responses: {
|
|
2936
|
+
/** @description Success */
|
|
2937
|
+
200: {
|
|
2938
|
+
headers: {
|
|
2939
|
+
[name: string]: unknown;
|
|
2940
|
+
};
|
|
2941
|
+
content: {
|
|
2942
|
+
"application/json": components["schemas"]["ChainsHealthSuccessResponse"];
|
|
2943
|
+
};
|
|
2944
|
+
};
|
|
2945
|
+
};
|
|
2946
|
+
};
|
|
2947
|
+
put?: never;
|
|
2948
|
+
post?: never;
|
|
2949
|
+
delete?: never;
|
|
2950
|
+
options?: never;
|
|
2951
|
+
head?: never;
|
|
2952
|
+
patch?: never;
|
|
2953
|
+
trace?: never;
|
|
2954
|
+
};
|
|
2955
|
+
"/v1/users/{userAddress}/positions": {
|
|
2956
|
+
parameters: {
|
|
2957
|
+
query?: never;
|
|
2958
|
+
header?: never;
|
|
2959
|
+
path?: never;
|
|
2960
|
+
cookie?: never;
|
|
2961
|
+
};
|
|
2962
|
+
/**
|
|
2963
|
+
* Get user positions
|
|
2964
|
+
* @description Returns positions for a user with reserved balance. The reserved balance is the amount locked by active offers (max lot upper - offset - consumed).
|
|
2965
|
+
*/
|
|
2966
|
+
get: {
|
|
2967
|
+
parameters: {
|
|
2968
|
+
query?: {
|
|
2969
|
+
/**
|
|
2970
|
+
* @description Maximum number of positions to return.
|
|
2971
|
+
* @example 10
|
|
2972
|
+
*/
|
|
2973
|
+
limit?: number;
|
|
2974
|
+
/**
|
|
2975
|
+
* @description Pagination cursor in base64url-encoded format.
|
|
2976
|
+
* @example eyJvZmZzZXQiOjEwMH0
|
|
2977
|
+
*/
|
|
2978
|
+
cursor?: string;
|
|
2979
|
+
};
|
|
2673
2980
|
header?: never;
|
|
2674
|
-
path
|
|
2981
|
+
path: {
|
|
2982
|
+
/**
|
|
2983
|
+
* @description User address to get positions for.
|
|
2984
|
+
* @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401
|
|
2985
|
+
*/
|
|
2986
|
+
userAddress: string;
|
|
2987
|
+
};
|
|
2675
2988
|
cookie?: never;
|
|
2676
2989
|
};
|
|
2677
2990
|
requestBody?: never;
|
|
@@ -2682,7 +2995,16 @@ interface paths {
|
|
|
2682
2995
|
[name: string]: unknown;
|
|
2683
2996
|
};
|
|
2684
2997
|
content: {
|
|
2685
|
-
"application/json": components["schemas"]["
|
|
2998
|
+
"application/json": components["schemas"]["PositionListResponse"];
|
|
2999
|
+
};
|
|
3000
|
+
};
|
|
3001
|
+
/** @description Bad Request */
|
|
3002
|
+
400: {
|
|
3003
|
+
headers: {
|
|
3004
|
+
[name: string]: unknown;
|
|
3005
|
+
};
|
|
3006
|
+
content: {
|
|
3007
|
+
"application/json": components["schemas"]["BadRequestResponse"];
|
|
2686
3008
|
};
|
|
2687
3009
|
};
|
|
2688
3010
|
};
|
|
@@ -2710,11 +3032,12 @@ interface paths {
|
|
|
2710
3032
|
*
|
|
2711
3033
|
* **Available validation rules:**
|
|
2712
3034
|
* - **parse_error**: Returns when an offer fails to parse due to invalid format or missing required fields
|
|
2713
|
-
* - **mixed_maker**: Validates that all offers in a batch have the same maker
|
|
3035
|
+
* - **mixed_maker**: Validates that all offers in a batch have the same maker address
|
|
3036
|
+
* - **amount_mutual_exclusivity**: Validates that at most one of (assets, obligationUnits, obligationShares) is non-zero
|
|
2714
3037
|
* - **chain_ids**: Validates that offer chain is one of: [109111114]
|
|
2715
3038
|
* - **maturity**: Validates that offer maturity is one of: [end_of_month, end_of_next_month]
|
|
2716
3039
|
* - **callback**: Validates callbacks: buy empty callback is allowed; sell offers must use a non-empty callback; non-empty callbacks must target one of [0x3333333333333333333333333333333333333333, 0x4444444444444444444444444444444444444444, 0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222]
|
|
2717
|
-
* - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list
|
|
3040
|
+
* - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list for the offer chain
|
|
2718
3041
|
*/
|
|
2719
3042
|
post: {
|
|
2720
3043
|
parameters: {
|
|
@@ -2762,7 +3085,7 @@ interface components {
|
|
|
2762
3085
|
meta: components["schemas"]["Meta"];
|
|
2763
3086
|
/** @example eyJvZmZzZXQiOjEwMH0 */
|
|
2764
3087
|
cursor: string | null;
|
|
2765
|
-
/** @description Aggregated book levels grouped by
|
|
3088
|
+
/** @description Aggregated book levels grouped by computed price. */
|
|
2766
3089
|
data: components["schemas"]["BookLevelResponse"][];
|
|
2767
3090
|
};
|
|
2768
3091
|
Meta: {
|
|
@@ -2771,7 +3094,7 @@ interface components {
|
|
|
2771
3094
|
};
|
|
2772
3095
|
BookLevelResponse: {
|
|
2773
3096
|
/** @example 2750000000000000000 */
|
|
2774
|
-
|
|
3097
|
+
price: string;
|
|
2775
3098
|
/** @example 369216000000000000000000 */
|
|
2776
3099
|
assets: string;
|
|
2777
3100
|
/** @example 5 */
|
|
@@ -2799,6 +3122,56 @@ interface components {
|
|
|
2799
3122
|
*/
|
|
2800
3123
|
details: Record<string, never>;
|
|
2801
3124
|
};
|
|
3125
|
+
ConfigSuccessResponse: {
|
|
3126
|
+
meta: components["schemas"]["Meta"];
|
|
3127
|
+
/** @example null */
|
|
3128
|
+
cursor: string | null;
|
|
3129
|
+
/**
|
|
3130
|
+
* @description Array of chain configurations for all indexed chains.
|
|
3131
|
+
* @example [
|
|
3132
|
+
* {
|
|
3133
|
+
* "chain_id": 505050505,
|
|
3134
|
+
* "contracts": {
|
|
3135
|
+
* "mempool": "0xD946246695A9259F3B33a78629026F61B3Ab40aF"
|
|
3136
|
+
* },
|
|
3137
|
+
* "maturities": {
|
|
3138
|
+
* "end_of_month": 1738335600,
|
|
3139
|
+
* "end_of_next_month": 1740754800
|
|
3140
|
+
* }
|
|
3141
|
+
* }
|
|
3142
|
+
* ]
|
|
3143
|
+
*/
|
|
3144
|
+
data: components["schemas"]["ConfigDataResponse"][];
|
|
3145
|
+
};
|
|
3146
|
+
ConfigDataResponse: {
|
|
3147
|
+
/** @example 505050505 */
|
|
3148
|
+
chain_id: number;
|
|
3149
|
+
contracts: components["schemas"]["ConfigContractsResponse"];
|
|
3150
|
+
/**
|
|
3151
|
+
* @description Supported maturity timestamps. Offers must use one of these values.
|
|
3152
|
+
* @example {
|
|
3153
|
+
* "end_of_month": 1738335600,
|
|
3154
|
+
* "end_of_next_month": 1740754800
|
|
3155
|
+
* }
|
|
3156
|
+
*/
|
|
3157
|
+
maturities: components["schemas"]["MaturitiesResponse"];
|
|
3158
|
+
};
|
|
3159
|
+
ConfigContractsResponse: {
|
|
3160
|
+
/** @example 0xD946246695A9259F3B33a78629026F61B3Ab40aF */
|
|
3161
|
+
mempool: string;
|
|
3162
|
+
};
|
|
3163
|
+
MaturitiesResponse: {
|
|
3164
|
+
/**
|
|
3165
|
+
* @description Unix timestamp for end of current month maturity (last Friday 15:00 UTC).
|
|
3166
|
+
* @example 1738335600
|
|
3167
|
+
*/
|
|
3168
|
+
end_of_month: number;
|
|
3169
|
+
/**
|
|
3170
|
+
* @description Unix timestamp for end of next month maturity (last Friday 15:00 UTC).
|
|
3171
|
+
* @example 1740754800
|
|
3172
|
+
*/
|
|
3173
|
+
end_of_next_month: number;
|
|
3174
|
+
};
|
|
2802
3175
|
OfferListResponse: {
|
|
2803
3176
|
meta: components["schemas"]["Meta"];
|
|
2804
3177
|
/** @example eyJvZmZzZXQiOjEwMH0 */
|
|
@@ -2807,29 +3180,34 @@ interface components {
|
|
|
2807
3180
|
* @description Offers matching the provided filters.
|
|
2808
3181
|
* @example [
|
|
2809
3182
|
* {
|
|
2810
|
-
* "
|
|
2811
|
-
*
|
|
2812
|
-
*
|
|
2813
|
-
*
|
|
2814
|
-
*
|
|
2815
|
-
*
|
|
2816
|
-
*
|
|
2817
|
-
*
|
|
2818
|
-
*
|
|
2819
|
-
*
|
|
2820
|
-
*
|
|
2821
|
-
*
|
|
2822
|
-
*
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2826
|
-
*
|
|
2827
|
-
*
|
|
2828
|
-
*
|
|
2829
|
-
* "
|
|
2830
|
-
* "
|
|
2831
|
-
* "
|
|
3183
|
+
* "offer": {
|
|
3184
|
+
* "obligation": {
|
|
3185
|
+
* "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
|
|
3186
|
+
* "collaterals": [
|
|
3187
|
+
* {
|
|
3188
|
+
* "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
3189
|
+
* "lltv": "860000000000000000",
|
|
3190
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
|
|
3191
|
+
* }
|
|
3192
|
+
* ],
|
|
3193
|
+
* "maturity": 1761922799
|
|
3194
|
+
* },
|
|
3195
|
+
* "buy": false,
|
|
3196
|
+
* "maker": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
3197
|
+
* "assets": "369216000000000000000000",
|
|
3198
|
+
* "obligation_units": "0",
|
|
3199
|
+
* "obligation_shares": "0",
|
|
3200
|
+
* "start": 1761922790,
|
|
3201
|
+
* "expiry": 1761922799,
|
|
3202
|
+
* "price": "2750000000000000000",
|
|
3203
|
+
* "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
|
|
3204
|
+
* "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
3205
|
+
* "callback": "0x1111111111111111111111111111111111111111",
|
|
3206
|
+
* "callback_data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
|
|
2832
3207
|
* },
|
|
3208
|
+
* "offer_hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
|
|
3209
|
+
* "obligation_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc",
|
|
3210
|
+
* "chain_id": 1,
|
|
2833
3211
|
* "consumed": "0",
|
|
2834
3212
|
* "takeable": "369216000000000000000000",
|
|
2835
3213
|
* "block_number": 2942933377146801,
|
|
@@ -2845,50 +3223,44 @@ interface components {
|
|
|
2845
3223
|
data: components["schemas"]["OfferListItemResponse"][];
|
|
2846
3224
|
};
|
|
2847
3225
|
OfferListItemResponse: {
|
|
2848
|
-
/** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
|
|
2849
|
-
hash: string;
|
|
2850
|
-
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
2851
|
-
offering: string;
|
|
2852
|
-
/** @example 369216000000000000000000 */
|
|
2853
|
-
assets: string;
|
|
2854
|
-
/** @example 2750000000000000000 */
|
|
2855
|
-
rate: string;
|
|
2856
|
-
/** @example 1761922799 */
|
|
2857
|
-
maturity: number;
|
|
2858
|
-
/** @example 1761922799 */
|
|
2859
|
-
expiry: number;
|
|
2860
|
-
/** @example 1761922790 */
|
|
2861
|
-
start: number;
|
|
2862
|
-
/** @example 571380 */
|
|
2863
|
-
nonce: string;
|
|
2864
|
-
/** @example false */
|
|
2865
|
-
buy: boolean;
|
|
2866
|
-
/** @example 1 */
|
|
2867
|
-
chain_id: number;
|
|
2868
|
-
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
2869
|
-
loan_token: string;
|
|
2870
|
-
/**
|
|
2871
|
-
* @example [
|
|
2872
|
-
* {
|
|
2873
|
-
* "asset": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
2874
|
-
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
2875
|
-
* "lltv": "860000000000000000"
|
|
2876
|
-
* }
|
|
2877
|
-
* ]
|
|
2878
|
-
*/
|
|
2879
|
-
collaterals: components["schemas"]["CollateralResponse"][];
|
|
2880
3226
|
/**
|
|
2881
3227
|
* @example {
|
|
2882
|
-
* "
|
|
2883
|
-
*
|
|
2884
|
-
*
|
|
3228
|
+
* "obligation": {
|
|
3229
|
+
* "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
|
|
3230
|
+
* "collaterals": [
|
|
3231
|
+
* {
|
|
3232
|
+
* "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
3233
|
+
* "lltv": "860000000000000000",
|
|
3234
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
|
|
3235
|
+
* }
|
|
3236
|
+
* ],
|
|
3237
|
+
* "maturity": 1761922799
|
|
3238
|
+
* },
|
|
3239
|
+
* "buy": false,
|
|
3240
|
+
* "maker": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
3241
|
+
* "assets": "369216000000000000000000",
|
|
3242
|
+
* "obligation_units": "0",
|
|
3243
|
+
* "obligation_shares": "0",
|
|
3244
|
+
* "start": 1761922790,
|
|
3245
|
+
* "expiry": 1761922799,
|
|
3246
|
+
* "price": "2750000000000000000",
|
|
3247
|
+
* "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
|
|
3248
|
+
* "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
3249
|
+
* "callback": "0x1111111111111111111111111111111111111111",
|
|
3250
|
+
* "callback_data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
|
|
2885
3251
|
* }
|
|
2886
3252
|
*/
|
|
2887
|
-
|
|
2888
|
-
/** @example
|
|
2889
|
-
|
|
3253
|
+
offer: components["schemas"]["OfferDataResponse"];
|
|
3254
|
+
/** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
|
|
3255
|
+
offer_hash: string;
|
|
3256
|
+
/** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
|
|
3257
|
+
obligation_id: string;
|
|
3258
|
+
/** @example 1 */
|
|
3259
|
+
chain_id: number;
|
|
2890
3260
|
/** @example 0 */
|
|
2891
3261
|
consumed: string;
|
|
3262
|
+
/** @example 369216000000000000000000 */
|
|
3263
|
+
takeable: string;
|
|
2892
3264
|
/** @example 2942933377146801 */
|
|
2893
3265
|
block_number: number;
|
|
2894
3266
|
/** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef */
|
|
@@ -2903,21 +3275,69 @@ interface components {
|
|
|
2903
3275
|
/** @example 0x1234567890123456789012345678901234567890123456789012345678901234123456789012345678901234567890123456789012345678901234567890123400 */
|
|
2904
3276
|
signature: string | null;
|
|
2905
3277
|
};
|
|
3278
|
+
OfferDataResponse: {
|
|
3279
|
+
/**
|
|
3280
|
+
* @example {
|
|
3281
|
+
* "loan_token": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
|
|
3282
|
+
* "collaterals": [
|
|
3283
|
+
* {
|
|
3284
|
+
* "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
3285
|
+
* "lltv": "860000000000000000",
|
|
3286
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
|
|
3287
|
+
* }
|
|
3288
|
+
* ],
|
|
3289
|
+
* "maturity": 1761922799
|
|
3290
|
+
* }
|
|
3291
|
+
*/
|
|
3292
|
+
obligation: components["schemas"]["ObligationOfferResponse"];
|
|
3293
|
+
/** @example false */
|
|
3294
|
+
buy: boolean;
|
|
3295
|
+
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
3296
|
+
maker: string;
|
|
3297
|
+
/** @example 369216000000000000000000 */
|
|
3298
|
+
assets: string;
|
|
3299
|
+
/** @example 0 */
|
|
3300
|
+
obligation_units: string;
|
|
3301
|
+
/** @example 0 */
|
|
3302
|
+
obligation_shares: string;
|
|
3303
|
+
/** @example 1761922790 */
|
|
3304
|
+
start: number;
|
|
3305
|
+
/** @example 1761922799 */
|
|
3306
|
+
expiry: number;
|
|
3307
|
+
/** @example 2750000000000000000 */
|
|
3308
|
+
price: string;
|
|
3309
|
+
/** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
|
|
3310
|
+
group: string;
|
|
3311
|
+
/** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
|
|
3312
|
+
session: string;
|
|
3313
|
+
/** @example 0x1111111111111111111111111111111111111111 */
|
|
3314
|
+
callback: string;
|
|
3315
|
+
/** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
|
|
3316
|
+
callback_data: string;
|
|
3317
|
+
};
|
|
3318
|
+
ObligationOfferResponse: {
|
|
3319
|
+
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
3320
|
+
loan_token: string;
|
|
3321
|
+
/**
|
|
3322
|
+
* @example [
|
|
3323
|
+
* {
|
|
3324
|
+
* "token": "0x34Cf890dB685FC536E05652FB41f02090c3fb751",
|
|
3325
|
+
* "lltv": "860000000000000000",
|
|
3326
|
+
* "oracle": "0x45093658BE7f90B63D7c359e8f408e503c2D9401"
|
|
3327
|
+
* }
|
|
3328
|
+
* ]
|
|
3329
|
+
*/
|
|
3330
|
+
collaterals: components["schemas"]["CollateralResponse"][];
|
|
3331
|
+
/** @example 1761922799 */
|
|
3332
|
+
maturity: number;
|
|
3333
|
+
};
|
|
2906
3334
|
CollateralResponse: {
|
|
2907
3335
|
/** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
|
|
2908
|
-
|
|
2909
|
-
/** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
2910
|
-
oracle: string;
|
|
3336
|
+
token: string;
|
|
2911
3337
|
/** @example 860000000000000000 */
|
|
2912
3338
|
lltv: string;
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
/** @example 0x1111111111111111111111111111111111111111 */
|
|
2916
|
-
address: string;
|
|
2917
|
-
/** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
|
|
2918
|
-
data: string;
|
|
2919
|
-
/** @example 500000 */
|
|
2920
|
-
gas_limit: string;
|
|
3339
|
+
/** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
3340
|
+
oracle: string;
|
|
2921
3341
|
};
|
|
2922
3342
|
ObligationListResponse: {
|
|
2923
3343
|
meta: components["schemas"]["Meta"];
|
|
@@ -2941,11 +3361,11 @@ interface components {
|
|
|
2941
3361
|
};
|
|
2942
3362
|
AskResponse: {
|
|
2943
3363
|
/** @example 1000000000000000000 */
|
|
2944
|
-
|
|
3364
|
+
price: string;
|
|
2945
3365
|
};
|
|
2946
3366
|
BidResponse: {
|
|
2947
3367
|
/** @example 1000000000000000000 */
|
|
2948
|
-
|
|
3368
|
+
price: string;
|
|
2949
3369
|
};
|
|
2950
3370
|
ObligationSingleSuccessResponse: {
|
|
2951
3371
|
meta: components["schemas"]["Meta"];
|
|
@@ -2959,7 +3379,10 @@ interface components {
|
|
|
2959
3379
|
/**
|
|
2960
3380
|
* @description Aggregated router status.
|
|
2961
3381
|
* @example {
|
|
2962
|
-
* "status": "live"
|
|
3382
|
+
* "status": "live",
|
|
3383
|
+
* "initialized": true,
|
|
3384
|
+
* "missing_chains": [],
|
|
3385
|
+
* "missing_collectors": []
|
|
2963
3386
|
* }
|
|
2964
3387
|
*/
|
|
2965
3388
|
data: components["schemas"]["RouterStatusDataResponse"];
|
|
@@ -2970,6 +3393,24 @@ interface components {
|
|
|
2970
3393
|
* @enum {string}
|
|
2971
3394
|
*/
|
|
2972
3395
|
status: "live" | "syncing";
|
|
3396
|
+
/** @example true */
|
|
3397
|
+
initialized: boolean;
|
|
3398
|
+
/**
|
|
3399
|
+
* @description Configured chain ids missing initialization rows.
|
|
3400
|
+
* @example []
|
|
3401
|
+
*/
|
|
3402
|
+
missing_chains: number[];
|
|
3403
|
+
/**
|
|
3404
|
+
* @description Collectors missing initialization rows.
|
|
3405
|
+
* @example []
|
|
3406
|
+
*/
|
|
3407
|
+
missing_collectors: components["schemas"]["MissingCollectorResponse"][];
|
|
3408
|
+
};
|
|
3409
|
+
MissingCollectorResponse: {
|
|
3410
|
+
/** @example 1 */
|
|
3411
|
+
chain_id: number;
|
|
3412
|
+
/** @example offers */
|
|
3413
|
+
name: string;
|
|
2973
3414
|
};
|
|
2974
3415
|
CollectorsHealthSuccessResponse: {
|
|
2975
3416
|
meta: components["schemas"]["Meta"];
|
|
@@ -2982,7 +3423,8 @@ interface components {
|
|
|
2982
3423
|
* "block_number": 21345678,
|
|
2983
3424
|
* "updated_at": "2024-01-01T12:00:00.000Z",
|
|
2984
3425
|
* "lag": 0,
|
|
2985
|
-
* "status": "live"
|
|
3426
|
+
* "status": "live",
|
|
3427
|
+
* "initialized": true
|
|
2986
3428
|
* }
|
|
2987
3429
|
* ]
|
|
2988
3430
|
*/
|
|
@@ -3004,6 +3446,8 @@ interface components {
|
|
|
3004
3446
|
* @enum {string}
|
|
3005
3447
|
*/
|
|
3006
3448
|
status: "live" | "lagging" | "unknown";
|
|
3449
|
+
/** @example true */
|
|
3450
|
+
initialized: boolean;
|
|
3007
3451
|
};
|
|
3008
3452
|
ChainsHealthSuccessResponse: {
|
|
3009
3453
|
meta: components["schemas"]["Meta"];
|
|
@@ -3014,7 +3458,8 @@ interface components {
|
|
|
3014
3458
|
* "chain_id": 1,
|
|
3015
3459
|
* "local_block_number": 21345678,
|
|
3016
3460
|
* "remote_block_number": 21345690,
|
|
3017
|
-
* "updated_at": "2024-01-01T12:00:00.000Z"
|
|
3461
|
+
* "updated_at": "2024-01-01T12:00:00.000Z",
|
|
3462
|
+
* "initialized": true
|
|
3018
3463
|
* }
|
|
3019
3464
|
* ]
|
|
3020
3465
|
*/
|
|
@@ -3024,11 +3469,43 @@ interface components {
|
|
|
3024
3469
|
/** @example 1 */
|
|
3025
3470
|
chain_id: number;
|
|
3026
3471
|
/** @example 21345678 */
|
|
3027
|
-
local_block_number: number;
|
|
3472
|
+
local_block_number: number | null;
|
|
3028
3473
|
/** @example 21345690 */
|
|
3029
3474
|
remote_block_number: number | null;
|
|
3030
3475
|
/** @example 2024-01-01T12:00:00.000Z */
|
|
3031
|
-
updated_at: string;
|
|
3476
|
+
updated_at: string | null;
|
|
3477
|
+
/** @example true */
|
|
3478
|
+
initialized: boolean;
|
|
3479
|
+
};
|
|
3480
|
+
PositionListResponse: {
|
|
3481
|
+
meta: components["schemas"]["Meta"];
|
|
3482
|
+
/** @example eyJvZmZzZXQiOjEwMH0 */
|
|
3483
|
+
cursor: string | null;
|
|
3484
|
+
/**
|
|
3485
|
+
* @description User positions with reserved balances from active offers.
|
|
3486
|
+
* @example [
|
|
3487
|
+
* {
|
|
3488
|
+
* "chain_id": 1,
|
|
3489
|
+
* "contract": "0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078",
|
|
3490
|
+
* "user": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401",
|
|
3491
|
+
* "reserved": "200000000000000000000",
|
|
3492
|
+
* "block_number": 21345678
|
|
3493
|
+
* }
|
|
3494
|
+
* ]
|
|
3495
|
+
*/
|
|
3496
|
+
data: components["schemas"]["PositionListItemResponse"][];
|
|
3497
|
+
};
|
|
3498
|
+
PositionListItemResponse: {
|
|
3499
|
+
/** @example 1 */
|
|
3500
|
+
chain_id: number;
|
|
3501
|
+
/** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
|
|
3502
|
+
contract: string;
|
|
3503
|
+
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
3504
|
+
user: string;
|
|
3505
|
+
/** @example 200000000000000000000 */
|
|
3506
|
+
reserved: string;
|
|
3507
|
+
/** @example 21345678 */
|
|
3508
|
+
block_number: number;
|
|
3032
3509
|
};
|
|
3033
3510
|
ValidateOffersRequest: {
|
|
3034
3511
|
/** @description Array of offers in snake_case format. Required, non-empty. */
|
|
@@ -3036,19 +3513,25 @@ interface components {
|
|
|
3036
3513
|
};
|
|
3037
3514
|
ValidateOfferRequest: {
|
|
3038
3515
|
/** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
3039
|
-
|
|
3516
|
+
maker: string;
|
|
3040
3517
|
/** @example 369216000000000000000000 */
|
|
3041
3518
|
assets: string;
|
|
3519
|
+
/** @example 0 */
|
|
3520
|
+
obligation_units?: string;
|
|
3521
|
+
/** @example 0 */
|
|
3522
|
+
obligation_shares?: string;
|
|
3042
3523
|
/** @example 2750000000000000000 */
|
|
3043
|
-
|
|
3524
|
+
price: string;
|
|
3044
3525
|
/** @example 1761922799 */
|
|
3045
3526
|
maturity: number;
|
|
3046
3527
|
/** @example 1761922799 */
|
|
3047
3528
|
expiry: number;
|
|
3048
3529
|
/** @example 1761922790 */
|
|
3049
3530
|
start: number;
|
|
3050
|
-
/** @example
|
|
3051
|
-
|
|
3531
|
+
/** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
|
|
3532
|
+
group: string;
|
|
3533
|
+
/** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
|
|
3534
|
+
session: string;
|
|
3052
3535
|
/** @example false */
|
|
3053
3536
|
buy: boolean;
|
|
3054
3537
|
/** @example 1 */
|
|
@@ -3064,15 +3547,28 @@ interface components {
|
|
|
3064
3547
|
* }
|
|
3065
3548
|
* ]
|
|
3066
3549
|
*/
|
|
3067
|
-
collaterals: components["schemas"]["
|
|
3550
|
+
collaterals: components["schemas"]["ValidateCollateralRequest"][];
|
|
3068
3551
|
/**
|
|
3069
3552
|
* @example {
|
|
3070
3553
|
* "address": "0x1111111111111111111111111111111111111111",
|
|
3071
|
-
* "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
|
|
3072
|
-
* "gas_limit": "500000"
|
|
3554
|
+
* "data": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000"
|
|
3073
3555
|
* }
|
|
3074
3556
|
*/
|
|
3075
|
-
callback: components["schemas"]["
|
|
3557
|
+
callback: components["schemas"]["ValidateCallbackRequest"];
|
|
3558
|
+
};
|
|
3559
|
+
ValidateCollateralRequest: {
|
|
3560
|
+
/** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */
|
|
3561
|
+
asset: string;
|
|
3562
|
+
/** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
|
|
3563
|
+
oracle: string;
|
|
3564
|
+
/** @example 860000000000000000 */
|
|
3565
|
+
lltv: string;
|
|
3566
|
+
};
|
|
3567
|
+
ValidateCallbackRequest: {
|
|
3568
|
+
/** @example 0x1111111111111111111111111111111111111111 */
|
|
3569
|
+
address: string;
|
|
3570
|
+
/** @example 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000034cf890db685fc536e05652fb41f02090c3fb751000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000108e644e3ab01184155270aa92a00000000000 */
|
|
3571
|
+
data: string;
|
|
3076
3572
|
};
|
|
3077
3573
|
ValidationSuccessResponse: {
|
|
3078
3574
|
meta: components["schemas"]["Meta"];
|
|
@@ -3101,7 +3597,7 @@ interface components {
|
|
|
3101
3597
|
pathItems: never;
|
|
3102
3598
|
}
|
|
3103
3599
|
declare namespace ObligationResponse_d_exports {
|
|
3104
|
-
export { ObligationResponse, from$
|
|
3600
|
+
export { ObligationResponse, from$3 as from };
|
|
3105
3601
|
}
|
|
3106
3602
|
type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
|
|
3107
3603
|
/**
|
|
@@ -3110,19 +3606,49 @@ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["c
|
|
|
3110
3606
|
* @param obligation - {@link Obligation}
|
|
3111
3607
|
* @returns The created `ObligationResponse`. {@link ObligationResponse}
|
|
3112
3608
|
*/
|
|
3113
|
-
declare function from$
|
|
3609
|
+
declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
|
|
3114
3610
|
declare namespace OfferResponse_d_exports {
|
|
3115
|
-
export { OfferResponse, from$
|
|
3611
|
+
export { Input, OfferResponse, from$2 as from };
|
|
3116
3612
|
}
|
|
3117
3613
|
type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
|
|
3614
|
+
type Input = Readonly<{
|
|
3615
|
+
hash: Hex;
|
|
3616
|
+
maker: Address;
|
|
3617
|
+
assets: bigint;
|
|
3618
|
+
obligationUnits: bigint;
|
|
3619
|
+
obligationShares: bigint;
|
|
3620
|
+
price: bigint;
|
|
3621
|
+
maturity: number;
|
|
3622
|
+
expiry: number;
|
|
3623
|
+
start: number;
|
|
3624
|
+
group: Hex;
|
|
3625
|
+
session: Hex;
|
|
3626
|
+
buy: boolean;
|
|
3627
|
+
chainId: number;
|
|
3628
|
+
loanToken: Address;
|
|
3629
|
+
collaterals: Readonly<{
|
|
3630
|
+
asset: Address;
|
|
3631
|
+
lltv: bigint;
|
|
3632
|
+
oracle: Address;
|
|
3633
|
+
}[]>;
|
|
3634
|
+
callback: {
|
|
3635
|
+
address: Address;
|
|
3636
|
+
data: Hex;
|
|
3637
|
+
};
|
|
3638
|
+
root?: Hex | undefined;
|
|
3639
|
+
proof?: Hex[] | undefined;
|
|
3640
|
+
signature?: Hex | undefined;
|
|
3641
|
+
consumed: bigint;
|
|
3642
|
+
takeable: bigint;
|
|
3643
|
+
blockNumber: number;
|
|
3644
|
+
}>;
|
|
3118
3645
|
/**
|
|
3119
|
-
* Creates an `OfferResponse`
|
|
3646
|
+
* Creates an `OfferResponse` matching the Solidity Offer struct layout.
|
|
3120
3647
|
* @constructor
|
|
3121
|
-
* @param
|
|
3122
|
-
* @param attestation - {@link Attestation}
|
|
3648
|
+
* @param input - {@link Input}
|
|
3123
3649
|
* @returns The created `OfferResponse`. {@link OfferResponse}
|
|
3124
3650
|
*/
|
|
3125
|
-
declare function from$
|
|
3651
|
+
declare function from$2(input: Input): OfferResponse;
|
|
3126
3652
|
//#endregion
|
|
3127
3653
|
//#region src/api/Schema/openapi.d.ts
|
|
3128
3654
|
declare class BooksController {
|
|
@@ -3139,10 +3665,16 @@ declare class HealthController {
|
|
|
3139
3665
|
getCollectorsHealth(): Promise<void>;
|
|
3140
3666
|
getChainsHealth(): Promise<void>;
|
|
3141
3667
|
}
|
|
3668
|
+
declare class ConfigController {
|
|
3669
|
+
getConfig(): Promise<void>;
|
|
3670
|
+
}
|
|
3142
3671
|
declare class ObligationsController {
|
|
3143
3672
|
getObligations(): Promise<void>;
|
|
3144
3673
|
getObligation(): Promise<void>;
|
|
3145
3674
|
}
|
|
3675
|
+
declare class UsersController {
|
|
3676
|
+
getUserPositions(): Promise<void>;
|
|
3677
|
+
}
|
|
3146
3678
|
type RuleInfo = {
|
|
3147
3679
|
name: string;
|
|
3148
3680
|
description: string;
|
|
@@ -3151,21 +3683,66 @@ type OpenApiOptions = {
|
|
|
3151
3683
|
rules?: RuleInfo[];
|
|
3152
3684
|
};
|
|
3153
3685
|
declare const OpenApi: (options?: OpenApiOptions) => Promise<OpenAPIDocument>;
|
|
3686
|
+
declare namespace PositionResponse_d_exports {
|
|
3687
|
+
export { PositionResponse, PositionWithReserved$1 as PositionWithReserved, from$1 as from };
|
|
3688
|
+
}
|
|
3689
|
+
type PositionResponse = {
|
|
3690
|
+
chain_id: Id;
|
|
3691
|
+
contract: Address;
|
|
3692
|
+
user: Address;
|
|
3693
|
+
reserved: string;
|
|
3694
|
+
block_number: number;
|
|
3695
|
+
};
|
|
3696
|
+
type PositionWithReserved$1 = getByUser.PositionWithReserved;
|
|
3697
|
+
/**
|
|
3698
|
+
* Creates a `PositionResponse` from a `PositionWithReserved`.
|
|
3699
|
+
* @param position - {@link PositionWithReserved}
|
|
3700
|
+
* @returns The created `PositionResponse`. {@link PositionResponse}
|
|
3701
|
+
*/
|
|
3702
|
+
declare function from$1(position: PositionWithReserved$1): PositionResponse;
|
|
3154
3703
|
//#endregion
|
|
3155
3704
|
//#region src/api/Schema/requests.d.ts
|
|
3156
3705
|
declare const schemas: {
|
|
3706
|
+
readonly get_health: z$1.ZodObject<{
|
|
3707
|
+
strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
|
|
3708
|
+
0: "0";
|
|
3709
|
+
1: "1";
|
|
3710
|
+
true: "true";
|
|
3711
|
+
false: "false";
|
|
3712
|
+
}>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
|
|
3713
|
+
}, z$1.core.$strip>;
|
|
3714
|
+
readonly get_health_collectors: z$1.ZodObject<{
|
|
3715
|
+
strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
|
|
3716
|
+
0: "0";
|
|
3717
|
+
1: "1";
|
|
3718
|
+
true: "true";
|
|
3719
|
+
false: "false";
|
|
3720
|
+
}>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
|
|
3721
|
+
}, z$1.core.$strip>;
|
|
3722
|
+
readonly get_health_chains: z$1.ZodObject<{
|
|
3723
|
+
strict: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodEnum<{
|
|
3724
|
+
0: "0";
|
|
3725
|
+
1: "1";
|
|
3726
|
+
true: "true";
|
|
3727
|
+
false: "false";
|
|
3728
|
+
}>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
|
|
3729
|
+
}, z$1.core.$strip>;
|
|
3157
3730
|
readonly get_offers: z$1.ZodObject<{
|
|
3158
3731
|
side: z$1.ZodOptional<z$1.ZodEnum<{
|
|
3159
3732
|
buy: "buy";
|
|
3160
3733
|
sell: "sell";
|
|
3161
3734
|
}>>;
|
|
3162
3735
|
obligation_id: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
3163
|
-
|
|
3736
|
+
maker: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
3164
3737
|
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
3165
3738
|
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
3166
3739
|
}, z$1.core.$strip>;
|
|
3167
3740
|
readonly get_obligations: z$1.ZodObject<{
|
|
3168
3741
|
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
3742
|
+
chain: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>;
|
|
3743
|
+
loan_token: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
3744
|
+
collateral_token: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
|
|
3745
|
+
maturity: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>;
|
|
3169
3746
|
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
3170
3747
|
}, z$1.core.$strip>;
|
|
3171
3748
|
readonly get_obligation: z$1.ZodObject<{
|
|
@@ -3183,6 +3760,11 @@ declare const schemas: {
|
|
|
3183
3760
|
readonly validate_offers: z$1.ZodObject<{
|
|
3184
3761
|
offers: z$1.ZodArray<z$1.ZodUnknown>;
|
|
3185
3762
|
}, z$1.core.$strict>;
|
|
3763
|
+
readonly get_user_positions: z$1.ZodObject<{
|
|
3764
|
+
user_address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
|
|
3765
|
+
cursor: z$1.ZodOptional<z$1.ZodString>;
|
|
3766
|
+
limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
|
|
3767
|
+
}, z$1.core.$strip>;
|
|
3186
3768
|
};
|
|
3187
3769
|
type Action = keyof typeof schemas;
|
|
3188
3770
|
declare function parse<A extends Action>(action: A, query: unknown): z$1.infer<(typeof schemas)[A]>;
|
|
@@ -3225,6 +3807,25 @@ type Payload<T> = SuccessPayload<T> | ErrorPayload;
|
|
|
3225
3807
|
//#region src/api/Controllers/getBook.d.ts
|
|
3226
3808
|
declare function getBook(params: object, db: Database): Promise<Payload<BookLevelResponse[]>>;
|
|
3227
3809
|
//#endregion
|
|
3810
|
+
//#region src/api/Controllers/getConfig.d.ts
|
|
3811
|
+
type MaturitiesConfig = {
|
|
3812
|
+
end_of_month: number;
|
|
3813
|
+
end_of_next_month: number;
|
|
3814
|
+
};
|
|
3815
|
+
type ChainConfig = {
|
|
3816
|
+
chain_id: Id;
|
|
3817
|
+
contracts: {
|
|
3818
|
+
mempool: string;
|
|
3819
|
+
};
|
|
3820
|
+
maturities: MaturitiesConfig;
|
|
3821
|
+
};
|
|
3822
|
+
/**
|
|
3823
|
+
* Returns the configuration for all chains the router is indexing.
|
|
3824
|
+
* @param chainRegistry - The chain registry instance. {@link ChainRegistry.ChainRegistry}
|
|
3825
|
+
* @returns The configuration for all chains the router is indexing. {@link ApiPayload.Payload<ChainConfig[]>}
|
|
3826
|
+
*/
|
|
3827
|
+
declare function getConfig(chainRegistry: ChainRegistry): Promise<Payload<ChainConfig[]>>;
|
|
3828
|
+
//#endregion
|
|
3228
3829
|
//#region src/api/Controllers/getDocs.d.ts
|
|
3229
3830
|
declare function getSwaggerJson({
|
|
3230
3831
|
gatekeeper
|
|
@@ -3236,11 +3837,16 @@ declare function getDocsHtml({
|
|
|
3236
3837
|
}: {
|
|
3237
3838
|
gatekeeper: Gatekeeper;
|
|
3238
3839
|
}): Promise<string>;
|
|
3840
|
+
/**
|
|
3841
|
+
* Renders the integrator documentation as HTML.
|
|
3842
|
+
* @returns HTML page with the rendered markdown documentation.
|
|
3843
|
+
*/
|
|
3844
|
+
declare function getIntegratorDocsHtml(): Promise<string>;
|
|
3239
3845
|
//#endregion
|
|
3240
3846
|
//#region src/api/Controllers/getHealth.d.ts
|
|
3241
|
-
declare function getHealth(db: Database): Promise<Payload<paths["/v1/health"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
|
|
3242
|
-
declare function getHealthChains(db: Database, healthClients?: Map<Id, Client
|
|
3243
|
-
declare function getHealthCollectors(db: Database): Promise<Payload<paths["/v1/health/collectors"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
|
|
3847
|
+
declare function getHealth(query: unknown, db: Database, chainRegistry?: ChainRegistry): Promise<Payload<paths["/v1/health"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
|
|
3848
|
+
declare function getHealthChains(query: unknown, db: Database, healthClients?: Map<Id, Client>, chainRegistry?: ChainRegistry): Promise<Payload<paths["/v1/health/chains"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
|
|
3849
|
+
declare function getHealthCollectors(query: unknown, db: Database, chainRegistry?: ChainRegistry): Promise<Payload<paths["/v1/health/collectors"]["get"]["responses"]["200"]["content"]["application/json"]["data"]>>;
|
|
3244
3850
|
//#endregion
|
|
3245
3851
|
//#region src/api/Controllers/getObligation.d.ts
|
|
3246
3852
|
declare function getObligation(params: object, db: Database): Promise<Payload<ObligationResponse>>;
|
|
@@ -3251,6 +3857,15 @@ declare function getObligations$1(queryParameters: object, db: Database): Promis
|
|
|
3251
3857
|
//#region src/api/Controllers/getOffers.d.ts
|
|
3252
3858
|
declare function getOffers$1(queryParameters: object, db: Database): Promise<Payload<OfferResponse[]>>;
|
|
3253
3859
|
//#endregion
|
|
3860
|
+
//#region src/api/Controllers/getUserPositions.d.ts
|
|
3861
|
+
/**
|
|
3862
|
+
* Get positions for a user with remaining balance calculation.
|
|
3863
|
+
* @param queryParameters - Request parameters including user address and pagination.
|
|
3864
|
+
* @param db - Database instance.
|
|
3865
|
+
* @returns Paginated list of positions with remaining balances.
|
|
3866
|
+
*/
|
|
3867
|
+
declare function getUserPositions(queryParameters: object, db: Database): Promise<Payload<PositionResponse[]>>;
|
|
3868
|
+
//#endregion
|
|
3254
3869
|
//#region src/api/Controllers/validateOffers.d.ts
|
|
3255
3870
|
type ValidationIssue = {
|
|
3256
3871
|
index: number;
|
|
@@ -3267,10 +3882,10 @@ type ValidateOffersIssuesPayload = SuccessPayload<{
|
|
|
3267
3882
|
type ValidateOffersResponse = ValidateOffersSuccessPayload | ValidateOffersIssuesPayload;
|
|
3268
3883
|
declare function validateOffers(body: object, gatekeeper: Gatekeeper): Promise<ValidateOffersResponse | ErrorPayload>;
|
|
3269
3884
|
declare namespace index_d_exports$4 {
|
|
3270
|
-
export { ValidationIssue, getBook, getDocsHtml, getHealth, getHealthChains, getHealthCollectors, getObligation, getObligations$1 as getObligations, getOffers$1 as getOffers, getSwaggerJson, validateOffers };
|
|
3885
|
+
export { ChainConfig, MaturitiesConfig, ValidationIssue, getBook, getConfig, getDocsHtml, getHealth, getHealthChains, getHealthCollectors, getIntegratorDocsHtml, getObligation, getObligations$1 as getObligations, getOffers$1 as getOffers, getSwaggerJson, getUserPositions, validateOffers };
|
|
3271
3886
|
}
|
|
3272
3887
|
declare namespace RouterApi_d_exports {
|
|
3273
|
-
export { ApiConfig, BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, index_d_exports$4 as Controllers, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, RouterApi, RouterStatusResponse, RuleInfo, ValidateController, create, from$
|
|
3888
|
+
export { ApiConfig, BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigController, index_d_exports$4 as Controllers, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, PositionResponse_d_exports as PositionResponse, RouterApi, RouterStatusResponse, RuleInfo, UsersController, ValidateController, create, from$5 as from, parse, safeParse };
|
|
3274
3889
|
}
|
|
3275
3890
|
declare namespace Client_d_exports {
|
|
3276
3891
|
export { Client$3 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
|
|
@@ -3352,10 +3967,17 @@ declare namespace getOffers {
|
|
|
3352
3967
|
};
|
|
3353
3968
|
type ReturnType = {
|
|
3354
3969
|
offers: Compute<Offer & {
|
|
3970
|
+
hash: Hex;
|
|
3971
|
+
blockNumber: number;
|
|
3972
|
+
consumed: bigint;
|
|
3973
|
+
takeable: bigint;
|
|
3974
|
+
} & {
|
|
3355
3975
|
/** 32-byte merkle root. */
|
|
3356
3976
|
root?: Hex;
|
|
3357
3977
|
/** Sibling hashes for the merkle proof. */
|
|
3358
3978
|
proof?: Hex[];
|
|
3979
|
+
/** Offer signature from the Merkle tree. */
|
|
3980
|
+
signature?: Hex;
|
|
3359
3981
|
}>[];
|
|
3360
3982
|
/** The pagination cursor. */
|
|
3361
3983
|
cursor: string | null;
|
|
@@ -3369,6 +3991,14 @@ declare namespace getObligations {
|
|
|
3369
3991
|
cursor?: Hex;
|
|
3370
3992
|
/** Maximum number of obligations to return. @default 20 */
|
|
3371
3993
|
limit?: number;
|
|
3994
|
+
/** Filter by chain ID. */
|
|
3995
|
+
chainId?: number;
|
|
3996
|
+
/** Filter by loan token address. */
|
|
3997
|
+
loanToken?: Address;
|
|
3998
|
+
/** Filter by collateral token (matches any collateral in the obligation). */
|
|
3999
|
+
collateralToken?: Address;
|
|
4000
|
+
/** Filter by exact maturity timestamp (unix seconds). */
|
|
4001
|
+
maturity?: number;
|
|
3372
4002
|
};
|
|
3373
4003
|
type ReturnType = {
|
|
3374
4004
|
obligations: Compute<{
|
|
@@ -4052,8 +4682,42 @@ declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
|
|
|
4052
4682
|
identity: undefined;
|
|
4053
4683
|
generated: undefined;
|
|
4054
4684
|
}, {}, {}>;
|
|
4055
|
-
|
|
4056
|
-
name: "
|
|
4685
|
+
obligationUnits: drizzle_orm_pg_core0.PgColumn<{
|
|
4686
|
+
name: "obligation_units";
|
|
4687
|
+
tableName: EnumTableName.OFFERS;
|
|
4688
|
+
dataType: "string";
|
|
4689
|
+
columnType: "PgNumeric";
|
|
4690
|
+
data: string;
|
|
4691
|
+
driverParam: string;
|
|
4692
|
+
notNull: true;
|
|
4693
|
+
hasDefault: true;
|
|
4694
|
+
isPrimaryKey: false;
|
|
4695
|
+
isAutoincrement: false;
|
|
4696
|
+
hasRuntimeDefault: false;
|
|
4697
|
+
enumValues: undefined;
|
|
4698
|
+
baseColumn: never;
|
|
4699
|
+
identity: undefined;
|
|
4700
|
+
generated: undefined;
|
|
4701
|
+
}, {}, {}>;
|
|
4702
|
+
obligationShares: drizzle_orm_pg_core0.PgColumn<{
|
|
4703
|
+
name: "obligation_shares";
|
|
4704
|
+
tableName: EnumTableName.OFFERS;
|
|
4705
|
+
dataType: "string";
|
|
4706
|
+
columnType: "PgNumeric";
|
|
4707
|
+
data: string;
|
|
4708
|
+
driverParam: string;
|
|
4709
|
+
notNull: true;
|
|
4710
|
+
hasDefault: true;
|
|
4711
|
+
isPrimaryKey: false;
|
|
4712
|
+
isAutoincrement: false;
|
|
4713
|
+
hasRuntimeDefault: false;
|
|
4714
|
+
enumValues: undefined;
|
|
4715
|
+
baseColumn: never;
|
|
4716
|
+
identity: undefined;
|
|
4717
|
+
generated: undefined;
|
|
4718
|
+
}, {}, {}>;
|
|
4719
|
+
price: drizzle_orm_pg_core0.PgColumn<{
|
|
4720
|
+
name: "price";
|
|
4057
4721
|
tableName: EnumTableName.OFFERS;
|
|
4058
4722
|
dataType: "string";
|
|
4059
4723
|
columnType: "PgNumeric";
|
|
@@ -4177,8 +4841,8 @@ declare const offers: drizzle_orm_pg_core0.PgTableWithColumns<{
|
|
|
4177
4841
|
}, {}, {
|
|
4178
4842
|
length: 66;
|
|
4179
4843
|
}>;
|
|
4180
|
-
|
|
4181
|
-
name: "
|
|
4844
|
+
session: drizzle_orm_pg_core0.PgColumn<{
|
|
4845
|
+
name: "session";
|
|
4182
4846
|
tableName: EnumTableName.OFFERS;
|
|
4183
4847
|
dataType: "string";
|
|
4184
4848
|
columnType: "PgVarchar";
|
|
@@ -5413,22 +6077,6 @@ declare const merklePaths: drizzle_orm_pg_core0.PgTableWithColumns<{
|
|
|
5413
6077
|
declare namespace index_d_exports$2 {
|
|
5414
6078
|
export { PositionTypes, StatusCode, TABLE_NAMES, TableName, VERSION, VERSIONED_TABLE_NAMES, VersionedTableName, callbacks$1 as callbacks, chains, collectors, consumedEvents, groups, lots, merklePaths, obligationCollateralsV2, obligations, offers, offersCallbacks, offsets, oracles, positionTypes, positions, status, transfers, trees, validations };
|
|
5415
6079
|
}
|
|
5416
|
-
declare namespace Cursor_d_exports {
|
|
5417
|
-
export { Cursor, decode, encode, validate };
|
|
5418
|
-
}
|
|
5419
|
-
type Cursor = {
|
|
5420
|
-
sort: "rate" | "maturity" | "expiry" | "amount";
|
|
5421
|
-
dir: "asc" | "desc";
|
|
5422
|
-
rate?: string;
|
|
5423
|
-
maturity?: number;
|
|
5424
|
-
expiry?: number;
|
|
5425
|
-
assets?: string;
|
|
5426
|
-
hash: string;
|
|
5427
|
-
page?: number;
|
|
5428
|
-
};
|
|
5429
|
-
declare function validate(cursor: unknown): cursor is Cursor;
|
|
5430
|
-
declare function encode(c: Cursor): string;
|
|
5431
|
-
declare function decode(token?: string): Cursor | null;
|
|
5432
6080
|
//#endregion
|
|
5433
6081
|
//#region src/mempool/MempoolEVMClient.d.ts
|
|
5434
6082
|
type MempoolEVMClientConfig = {
|
|
@@ -5481,7 +6129,7 @@ declare class ChainIdMismatchError extends BaseError {
|
|
|
5481
6129
|
}
|
|
5482
6130
|
//#endregion
|
|
5483
6131
|
//#region src/mempool/MempoolClient.d.ts
|
|
5484
|
-
type AddParameters = Compute<Omit<Offer, "
|
|
6132
|
+
type AddParameters = Compute<Omit<Offer, "createdAt">[]>;
|
|
5485
6133
|
type GetParameters = {
|
|
5486
6134
|
/** The block number to get offers from. */
|
|
5487
6135
|
blockNumberGte?: number;
|
|
@@ -5539,6 +6187,12 @@ declare namespace index_d_exports$1 {
|
|
|
5539
6187
|
//#region src/utils/BigMath.d.ts
|
|
5540
6188
|
declare function max$1(a: bigint, b: bigint): bigint;
|
|
5541
6189
|
declare function min(a: bigint, b: bigint): bigint;
|
|
6190
|
+
/**
|
|
6191
|
+
* Checks if at most one of the given values is non-zero.
|
|
6192
|
+
* @param values - The bigint values to check.
|
|
6193
|
+
* @returns True if zero or one value is non-zero, false if two or more are non-zero.
|
|
6194
|
+
*/
|
|
6195
|
+
declare function atMostOneNonZero(...values: bigint[]): boolean;
|
|
5542
6196
|
//#endregion
|
|
5543
6197
|
//#region src/utils/batch.d.ts
|
|
5544
6198
|
/**
|
|
@@ -5576,6 +6230,15 @@ declare function batchMulticall<TResult>(parameters: {
|
|
|
5576
6230
|
retryDelayMs: number;
|
|
5577
6231
|
blockNumber?: bigint;
|
|
5578
6232
|
}): Promise<TResult[]>;
|
|
6233
|
+
declare namespace Group_d_exports {
|
|
6234
|
+
export { fromNumber };
|
|
6235
|
+
}
|
|
6236
|
+
/**
|
|
6237
|
+
* Creates a bytes32 group identifier from a number.
|
|
6238
|
+
* @param n - A non-negative integer.
|
|
6239
|
+
* @throws {Error} If n is negative or not an integer.
|
|
6240
|
+
*/
|
|
6241
|
+
declare const fromNumber: (n: number) => Hex;
|
|
5579
6242
|
//#endregion
|
|
5580
6243
|
//#region src/utils/lazy.d.ts
|
|
5581
6244
|
/**
|
|
@@ -5650,8 +6313,8 @@ declare function max(): number;
|
|
|
5650
6313
|
//#region src/utils/wait.d.ts
|
|
5651
6314
|
declare function wait(time: number): Promise<unknown>;
|
|
5652
6315
|
declare namespace index_d_exports$3 {
|
|
5653
|
-
export { BaseError, GlobalErrorType, Random_d_exports as Random, ReorgError, Snake, time_d_exports as Time, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
|
|
6316
|
+
export { BaseError, GlobalErrorType, Group_d_exports as Group, Random_d_exports as Random, ReorgError, Snake, time_d_exports as Time, atMostOneNonZero, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
|
|
5654
6317
|
}
|
|
5655
6318
|
//#endregion
|
|
5656
|
-
export { index_d_exports as Abi, BookResponse_d_exports as BookResponse, BooksController, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainHealth, ChainsHealthResponse, Collateral_d_exports as Collateral, CollectorHealth, CollectorsHealthResponse, Compute,
|
|
6319
|
+
export { index_d_exports as Abi, BookResponse_d_exports as BookResponse, BooksController, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainHealth, ChainRegistry_d_exports as ChainRegistry, ChainsHealthResponse, Collateral_d_exports as Collateral, CollectorHealth, CollectorsHealthResponse, Compute, ConfigController, Database_d_exports as Database, ERC4626_d_exports as ERC4626, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, Health_d_exports as Health, HealthController, Indexer_d_exports as Indexer, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Logger_d_exports as Logger, Maturity_d_exports as Maturity, index_d_exports$1 as Mempool, Obligation_d_exports as Obligation, ObligationResponse_d_exports as ObligationResponse, ObligationsController, Offer_d_exports as Offer, OfferResponse_d_exports as OfferResponse, OffersController, index_d_exports$2 as OffersSchema, OpenApi, OpenApiOptions, Oracle_d_exports as Oracle, Position_d_exports as Position, PositionResponse_d_exports as PositionResponse, Quote_d_exports as Quote, RouterApi_d_exports as RouterApi, Client_d_exports as RouterClient, RouterStatusResponse, RuleInfo, Rules_d_exports as Rules, time_d_exports as Time, Transfer_d_exports as Transfer, Tree_d_exports as Tree, UsersController, index_d_exports$3 as Utils, ValidateController, Gate_d_exports as Validation, morphoRules, parse, safeParse };
|
|
5657
6320
|
//# sourceMappingURL=index.node.d.mts.map
|