@hyperbridge/simplex 0.16.12 → 0.16.13
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/dist/bin/simplex.js +966 -148
- package/dist/bin/simplex.js.map +1 -1
- package/dist/index.cjs +753 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -12
- package/dist/index.d.ts +168 -12
- package/dist/index.js +753 -64
- package/dist/index.js.map +1 -1
- package/dist/sqlite.cjs +59 -3
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +21 -2
- package/dist/sqlite.d.ts +21 -2
- package/dist/sqlite.js +58 -3
- package/dist/sqlite.js.map +1 -1
- package/dist/{types-B5zkFhxR.d.cts → types-BISgqJhM.d.cts} +57 -1
- package/dist/{types-B5zkFhxR.d.ts → types-BISgqJhM.d.ts} +57 -1
- package/dist/ui/assets/Novatica-Medium-CjNgGPEL.ttf +0 -0
- package/dist/ui/assets/index-CK8E6aPx.css +1 -0
- package/dist/ui/assets/index-DShjZe_c.js +106 -0
- package/dist/ui/index.html +2 -2
- package/package.json +4 -4
- package/dist/ui/assets/index-QU1Ik7IX.js +0 -106
- package/dist/ui/assets/index-XKHMOpY2.css +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { EventEmitter as EventEmitter$1 } from 'node:events';
|
|
|
2
2
|
import { HexString, ERC7821Call, ChainConfig, Order, TokenInfo, IntentsCoprocessor, ExecutionResult, IntentGateway, FillOptions, FillerConfig as FillerConfig$1 } from '@hyperbridge/sdk';
|
|
3
3
|
import { PublicClient, Hash, AbiEvent, BlockNumber, BlockTag, GetLogsParameters, GetLogsReturnType, WalletClient, Transport, Chain } from 'viem';
|
|
4
4
|
import { LocalAccount, Account } from 'viem/accounts';
|
|
5
|
-
import { L as LoggerContext, a as LogLevel, b as Logger, A as ActivityStore, c as ActivityInsert, d as ActivityEvent, O as OrderHistoryPage, W as WalletTx, e as LimitOrderStore, f as LimitOrder, g as LimitOrderFilter, B as BidStore, S as SimplexDataStore, h as LimitOrderFill, i as StoredBid, j as LogSink, k as BidStats, l as StateStore } from './types-
|
|
6
|
-
export { m as ActivityType, n as BidInsert, o as
|
|
5
|
+
import { L as LoggerContext, a as LogLevel, b as Logger, A as ActivityStore, c as ActivityInsert, d as ActivityEvent, O as OrderHistoryPage, W as WalletTx, e as LimitOrderStore, f as LimitOrder, g as LimitOrderFilter, B as BidStore, S as SimplexDataStore, h as LimitOrderFill, i as StoredBid, j as LogSink, k as BidStats, l as StateStore, I as InventoryStore } from './types-BISgqJhM.cjs';
|
|
6
|
+
export { m as ActivityType, n as BidInsert, o as InventorySnapshot, p as LimitOrderFillInsert, q as LimitOrderFillRecord, r as LimitOrderHold, s as LimitOrderInsert, t as LimitOrderPosting, u as LimitOrderSide, v as LimitOrderStatus, w as OperatorNotification, R as RuntimeState, x as WalletTxKind, y as addLogSink, z as configureLogger, C as getLogger } from './types-BISgqJhM.cjs';
|
|
7
7
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
@@ -1605,6 +1605,85 @@ declare class BalanceProvider extends EventEmitter$1 {
|
|
|
1605
1605
|
private trackHyperbridgeBalance;
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
|
+
/** The stretch of time a summary covers. Each is cut into buckets of one size. */
|
|
1609
|
+
type ProfitPeriod = "7d" | "30d" | "12w" | "12m" | "all";
|
|
1610
|
+
type ProfitBucket = "day" | "week" | "month" | "year";
|
|
1611
|
+
/** What a stretch of fills came to, in dollars at the latest rate. Unpriced tokens are left out. */
|
|
1612
|
+
interface ProfitFigures {
|
|
1613
|
+
/** What the stretch's fills added to inventory, less what they took out of it. */
|
|
1614
|
+
profitUsd: number;
|
|
1615
|
+
/** The inventory held when the stretch began. Null when nothing within reach of then records it. */
|
|
1616
|
+
startInventoryUsd: number | null;
|
|
1617
|
+
/** `profitUsd` over `startInventoryUsd`, as a percentage. Null without a starting inventory. */
|
|
1618
|
+
returnPct: number | null;
|
|
1619
|
+
/**
|
|
1620
|
+
* What moved in and out over the stretch other than through fills, net: deposits, withdrawals,
|
|
1621
|
+
* fees and vault yield. Null when the indexer has no reading for both ends of the stretch.
|
|
1622
|
+
*/
|
|
1623
|
+
transfersUsd: number | null;
|
|
1624
|
+
boughtUsd: number;
|
|
1625
|
+
soldUsd: number;
|
|
1626
|
+
buys: number;
|
|
1627
|
+
sells: number;
|
|
1628
|
+
}
|
|
1629
|
+
interface ProfitBucketFigures extends ProfitFigures {
|
|
1630
|
+
/** When the bucket starts, in milliseconds since the epoch. */
|
|
1631
|
+
start: number;
|
|
1632
|
+
}
|
|
1633
|
+
/** One book's buys against its sells over the period, in the book's own tokens. */
|
|
1634
|
+
interface BookProfit {
|
|
1635
|
+
book: string;
|
|
1636
|
+
base: string;
|
|
1637
|
+
quote: string;
|
|
1638
|
+
/** Base bought and sold in the period. */
|
|
1639
|
+
bought: number;
|
|
1640
|
+
sold: number;
|
|
1641
|
+
/** Quote per base, averaged over the period's buys and its sells. Null for a side with none. */
|
|
1642
|
+
averageBuy: number | null;
|
|
1643
|
+
averageSell: number | null;
|
|
1644
|
+
/** How far the average sell sits above the average buy, as a percentage. Null without both. */
|
|
1645
|
+
spreadPct: number | null;
|
|
1646
|
+
/** What the period's fills did to the base and the quote held: positive is more than before. */
|
|
1647
|
+
baseChange: number;
|
|
1648
|
+
quoteChange: number;
|
|
1649
|
+
/** The rate the book's tokens are valued at: midway between its latest buy and latest sell. */
|
|
1650
|
+
rate: number | null;
|
|
1651
|
+
/** Both changes in dollars. Null when the book's tokens have no dollar price. */
|
|
1652
|
+
profitUsd: number | null;
|
|
1653
|
+
}
|
|
1654
|
+
/** The inventory a period began with, token by token. */
|
|
1655
|
+
interface StartingInventory {
|
|
1656
|
+
/** The instant it describes, in milliseconds since the epoch. */
|
|
1657
|
+
at: number;
|
|
1658
|
+
/** A stored snapshot, or the balances as they stand now. Either is adjusted by what happened between. */
|
|
1659
|
+
source: "snapshot" | "balances";
|
|
1660
|
+
/** When that record was taken. */
|
|
1661
|
+
recordedAt: number;
|
|
1662
|
+
usd: number;
|
|
1663
|
+
tokens: Array<{
|
|
1664
|
+
symbol: string;
|
|
1665
|
+
amount: number;
|
|
1666
|
+
usd: number | null;
|
|
1667
|
+
}>;
|
|
1668
|
+
}
|
|
1669
|
+
interface Profitability {
|
|
1670
|
+
period: ProfitPeriod;
|
|
1671
|
+
bucket: ProfitBucket;
|
|
1672
|
+
/** The start of the first bucket and the moment the summary was taken, in milliseconds. */
|
|
1673
|
+
from: number;
|
|
1674
|
+
to: number;
|
|
1675
|
+
totals: ProfitFigures;
|
|
1676
|
+
/** One entry per bucket, oldest first, including buckets nothing happened in. */
|
|
1677
|
+
series: ProfitBucketFigures[];
|
|
1678
|
+
books: BookProfit[];
|
|
1679
|
+
/** Null when there is no snapshot, and the period began more than {@link BALANCES_REACH_MS} ago. */
|
|
1680
|
+
startInventory: StartingInventory | null;
|
|
1681
|
+
/** Fills in the period priced at their order's rate, because they kept no record of what they took in. */
|
|
1682
|
+
estimatedFills: number;
|
|
1683
|
+
/** Tokens the period touched that have no dollar price, and so are in none of the dollar figures. */
|
|
1684
|
+
unpricedTokens: string[];
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1608
1687
|
/**
|
|
1609
1688
|
* Wire contracts between the UI server and the browser bundle. The server
|
|
1610
1689
|
* types its response literals with these and `ui/src` imports them type-only,
|
|
@@ -2044,6 +2123,8 @@ interface BidPlan {
|
|
|
2044
2123
|
fillerOutputs: TokenInfo[];
|
|
2045
2124
|
/** The take signed beside each output: the escrow this bid's fill earns. */
|
|
2046
2125
|
fillerInputs: TokenInfo[];
|
|
2126
|
+
/** The decimals `fillerInputs[leg]` is counted in: the input token's, on the order's source chain. */
|
|
2127
|
+
inputDecimals?: number;
|
|
2047
2128
|
fundingCalls: ERC7821Call[];
|
|
2048
2129
|
partialFill: boolean;
|
|
2049
2130
|
profit: number;
|
|
@@ -2701,6 +2782,52 @@ interface Book {
|
|
|
2701
2782
|
base: string;
|
|
2702
2783
|
quote: string;
|
|
2703
2784
|
}
|
|
2785
|
+
/** Live price levels. All prices and sizes are decimal integer strings at 1e18. */
|
|
2786
|
+
interface OrderbookLevel {
|
|
2787
|
+
fillChain: string;
|
|
2788
|
+
priceBucket: string;
|
|
2789
|
+
price: string;
|
|
2790
|
+
worstPrice: string;
|
|
2791
|
+
baseSize: string;
|
|
2792
|
+
quoteSize: string;
|
|
2793
|
+
orderCount: number;
|
|
2794
|
+
solverCount: number;
|
|
2795
|
+
}
|
|
2796
|
+
interface OrderbookSnapshot extends Book {
|
|
2797
|
+
/** Best first: bids descending, asks ascending. */
|
|
2798
|
+
bids: OrderbookLevel[];
|
|
2799
|
+
asks: OrderbookLevel[];
|
|
2800
|
+
/** True backing liquidity, in quote for bids and base for asks. */
|
|
2801
|
+
bidLiquidity: string;
|
|
2802
|
+
askLiquidity: string;
|
|
2803
|
+
/** Price bucket width, quote per 1 base at 1e18; null when the orderbook does not report one. */
|
|
2804
|
+
granularity: string | null;
|
|
2805
|
+
}
|
|
2806
|
+
/** One solver's order inside a price level. Prices and sizes are decimal integer strings at 1e18. */
|
|
2807
|
+
interface OrderbookLevelOrder {
|
|
2808
|
+
solver: string;
|
|
2809
|
+
commitment: string;
|
|
2810
|
+
fillChain: string;
|
|
2811
|
+
price: string;
|
|
2812
|
+
/** What the order publishes as depth, in the token its side pays out: quote for bids, base for asks. */
|
|
2813
|
+
advertisedSize: string;
|
|
2814
|
+
/** The signed output before any balance cap, in the same token as `advertisedSize`. */
|
|
2815
|
+
quotedAmount: string;
|
|
2816
|
+
/** True when the solver's balance, not the quote, binds `advertisedSize`. */
|
|
2817
|
+
resized: boolean;
|
|
2818
|
+
expiresAt: string;
|
|
2819
|
+
acceptedSources: string[];
|
|
2820
|
+
}
|
|
2821
|
+
interface OrderbookLevelQuery {
|
|
2822
|
+
side: "BID" | "ASK";
|
|
2823
|
+
fillChain: string;
|
|
2824
|
+
priceBucket: string;
|
|
2825
|
+
sourceChain?: string;
|
|
2826
|
+
}
|
|
2827
|
+
interface OrderbookFilters {
|
|
2828
|
+
sourceChain?: string;
|
|
2829
|
+
fillChain?: string;
|
|
2830
|
+
}
|
|
2704
2831
|
interface TokenMinSize {
|
|
2705
2832
|
symbol: string;
|
|
2706
2833
|
size: string;
|
|
@@ -2851,6 +2978,14 @@ declare class OrderbookClient {
|
|
|
2851
2978
|
constructor(url: string, requestTimeoutMs: number, loggers?: LoggerContext);
|
|
2852
2979
|
/** The limits to validate against before posting, plus the books on offer. */
|
|
2853
2980
|
limits(): Promise<OrderbookLimits>;
|
|
2981
|
+
/** The public book across all solvers, restricted to the selected route. */
|
|
2982
|
+
snapshot(id: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
2983
|
+
/**
|
|
2984
|
+
* The orders behind one price level. The orderbook filters orders by side and route but not by
|
|
2985
|
+
* price bucket, so this walks the side's orders on the level's fill chain and keeps the bucket.
|
|
2986
|
+
* Null when the book does not exist.
|
|
2987
|
+
*/
|
|
2988
|
+
levelOrders(id: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
2854
2989
|
submitOrder(userOp: HexString): Promise<SubmitOrderResult>;
|
|
2855
2990
|
/**
|
|
2856
2991
|
* The entry this solver holds at `commitment`, or null when it holds none.
|
|
@@ -3025,6 +3160,10 @@ declare class LimitOrderService {
|
|
|
3025
3160
|
*/
|
|
3026
3161
|
private withdraw;
|
|
3027
3162
|
private signAndCancel;
|
|
3163
|
+
/** Public market levels read through the configured orderbook client. */
|
|
3164
|
+
orderbookSnapshot(book: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
3165
|
+
/** Every solver's order behind one public price level. */
|
|
3166
|
+
orderbookLevelOrders(book: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
3028
3167
|
/**
|
|
3029
3168
|
* The pairs an order can be written against, the smallest payout each token may carry, and
|
|
3030
3169
|
* the tokens the orderbook registers on each chain.
|
|
@@ -3769,6 +3908,10 @@ interface FillerRuntime {
|
|
|
3769
3908
|
rebalancingService?: RebalancingService;
|
|
3770
3909
|
resolvedChains: ResolvedChainConfig[];
|
|
3771
3910
|
fillerAddress: HexString;
|
|
3911
|
+
/** The indexer this filler reads history from: order details, and what it held at past moments. */
|
|
3912
|
+
indexerUrl: string;
|
|
3913
|
+
/** A token's registry symbol and on-chain decimals, where either can be had. */
|
|
3914
|
+
describeToken: TokenDescriber;
|
|
3772
3915
|
watchOnly?: Record<number, boolean>;
|
|
3773
3916
|
config: FillerTomlConfig;
|
|
3774
3917
|
/** Where the config came from, when it came from a file. */
|
|
@@ -3977,6 +4120,7 @@ interface SimplexStatus {
|
|
|
3977
4120
|
declare class LimitOrderController {
|
|
3978
4121
|
private runtime;
|
|
3979
4122
|
private emit;
|
|
4123
|
+
private indexed?;
|
|
3980
4124
|
constructor(runtime: FillerRuntime, emit: LimitOrderEmitter);
|
|
3981
4125
|
private get service();
|
|
3982
4126
|
list(filter?: LimitOrderFilter): Promise<LimitOrder[]>;
|
|
@@ -3993,12 +4137,32 @@ declare class LimitOrderController {
|
|
|
3993
4137
|
fills: LimitOrderFill[];
|
|
3994
4138
|
bids: StoredBid[];
|
|
3995
4139
|
} | null>;
|
|
4140
|
+
/**
|
|
4141
|
+
* What the operator's buys and sells earned over `period`, bucketed on a clock
|
|
4142
|
+
* `tzOffsetMinutes` behind UTC.
|
|
4143
|
+
*
|
|
4144
|
+
* Profit is the change the period's fills made to what the solver holds, and
|
|
4145
|
+
* it is compared with the inventory the period began with. That inventory
|
|
4146
|
+
* comes from the stored snapshots and, when the balances have been read in
|
|
4147
|
+
* full, from what is held now, each carried to the period's start by what
|
|
4148
|
+
* moved between. The indexer says what moved, deposits and withdrawals
|
|
4149
|
+
* included, wherever it has followed the solver; elsewhere the fills and
|
|
4150
|
+
* sends on record stand in. It answers whether or not an orderbook is
|
|
4151
|
+
* configured, and whether or not the indexer does.
|
|
4152
|
+
*/
|
|
4153
|
+
profitability(period: ProfitPeriod, tzOffsetMinutes?: number): Promise<Profitability>;
|
|
4154
|
+
/** One reader for the life of the filler, so the readings it has already fetched are kept. */
|
|
4155
|
+
private indexerInventory;
|
|
3996
4156
|
/** The pairs the orderbook lists, the smallest payout each token may carry, and its tokens per chain. */
|
|
3997
4157
|
books(): Promise<{
|
|
3998
4158
|
books: Book[];
|
|
3999
4159
|
minOrderSizes: TokenMinSize[];
|
|
4000
4160
|
chains: ChainInfo[];
|
|
4001
4161
|
}>;
|
|
4162
|
+
/** Public bids and asks across solvers, optionally restricted to a route. */
|
|
4163
|
+
orderbookSnapshot(book: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
4164
|
+
/** Every solver's order behind one public price level. */
|
|
4165
|
+
orderbookLevelOrders(book: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
4002
4166
|
/** Creates the order, posts it, and reports what the orderbook made of it. */
|
|
4003
4167
|
create(request: CreateLimitOrderRequest): Promise<PostedLimitOrder>;
|
|
4004
4168
|
cancel(id: string): Promise<CancelledLimitOrder>;
|
|
@@ -4240,20 +4404,12 @@ declare class Simplex extends EventEmitter$1 {
|
|
|
4240
4404
|
get internals(): FillerRuntime;
|
|
4241
4405
|
}
|
|
4242
4406
|
|
|
4243
|
-
/**
|
|
4244
|
-
* Process-local data store — the default when `Simplex.start` is given no
|
|
4245
|
-
* `data` option.
|
|
4246
|
-
*
|
|
4247
|
-
* Nothing survives the process. That is fine for tests, short-lived embedded
|
|
4248
|
-
* fillers and watch-only observers, but a filler that submits bids should use a
|
|
4249
|
-
* durable store: a lost bid record is a Hyperbridge deposit nobody retracts.
|
|
4250
|
-
* Settled rows are evicted past a cap; live bids (deposits still reclaimable) are never dropped.
|
|
4251
|
-
*/
|
|
4252
4407
|
declare class MemoryDataStore implements SimplexDataStore {
|
|
4253
4408
|
readonly bids: BidStore;
|
|
4254
4409
|
readonly activity: ActivityStore;
|
|
4255
4410
|
readonly state: StateStore;
|
|
4256
4411
|
readonly limitOrders: LimitOrderStore;
|
|
4412
|
+
readonly inventory: InventoryStore;
|
|
4257
4413
|
}
|
|
4258
4414
|
|
|
4259
4415
|
/**
|
|
@@ -4320,4 +4476,4 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4320
4476
|
private closeNow;
|
|
4321
4477
|
}
|
|
4322
4478
|
|
|
4323
|
-
export { ActivityEvent, ActivityInsert, ActivityStore, type AllowlistConfig, type AssetBalanceRow, AssetController, type AssetDefinition, type AuthorizationRequest, type BalanceIssue, type BalanceSnapshot, BidStats, BidStore, type BinanceConfig, type CancelledLimitOrder, type ChainBalanceRow, type ChainConfirmationPolicy, ChainController, type ChainInput, type ChainView, type CreateLimitOrderRequest, type CurveConfig, type CurvePoint, type DerivingSigner, type Eip7702Authorization$1 as Eip7702Authorization, type FillerConfigFile, type FillerTomlConfig, type HyperbridgeBalance, LimitOrder, LimitOrderController, LimitOrderFill, LimitOrderFilter, LimitOrderStore, LimitOrderValidationError, LogLevel, LogSink, Logger, LoggerContext, MemoryDataStore, type MpcVaultSignerConfig, OrderScanner, type OrderScanner$1 as OrderScannerContract, type OrderScannerHandlers, type OrderScannerOptions, type PairConfig, PairController, type PairView, type PostedLimitOrder, type PostingOutcome, type PrivateKeySignerConfig, type QueueConfig, RebalanceController, type RebalancingConfig, type ResolvedChainConfig, type ScannedFill, type ScannedOrder, type ScannerChainConfig, type SecretPhraseSignerConfig, type Signature, type Signer, type SignerConfig, type SignerTransaction, SignerType, Simplex, type SimplexConfig, SimplexDataStore, type SimplexEvents, type SimplexOptions, type SimplexStatus, type SolverWork, StateStore, StoredBid, type Subscription, type TurnkeySignerConfig, type TypedDataPayload, USD_STABLE_SYMBOLS, type UserProvidedChainConfig, type VaultBalanceRow, VaultController, type VaultSweepDeposit, type VaultSweepResult, type VaultSweepSkip, type VaultSweepSkipReason, type VaultSweepSubmission, type VaultToml, type VaultTomlConfig, WalletController, WalletTx, assertConfirmationCoverage, canDerive, createSigner, digestSigner, formatChainKey, isRegistrySymbol, mpcVaultSigner, normalizeSymbol, parseChainKey, pickAnchorStable, privateKeySigner, registrySymbols, secretPhraseSigner, turnkeySigner, validateAssetDefinitions, validateConfig, validatePairConfigs, validateSecretPhrase, validateSignerConfig, validateVaultToml, viemSigner };
|
|
4479
|
+
export { ActivityEvent, ActivityInsert, ActivityStore, type AllowlistConfig, type AssetBalanceRow, AssetController, type AssetDefinition, type AuthorizationRequest, type BalanceIssue, type BalanceSnapshot, BidStats, BidStore, type BinanceConfig, type BookProfit, type CancelledLimitOrder, type ChainBalanceRow, type ChainConfirmationPolicy, ChainController, type ChainInput, type ChainView, type CreateLimitOrderRequest, type CurveConfig, type CurvePoint, type DerivingSigner, type Eip7702Authorization$1 as Eip7702Authorization, type FillerConfigFile, type FillerTomlConfig, type HyperbridgeBalance, InventoryStore, LimitOrder, LimitOrderController, LimitOrderFill, LimitOrderFilter, LimitOrderStore, LimitOrderValidationError, LogLevel, LogSink, Logger, LoggerContext, MemoryDataStore, type MpcVaultSignerConfig, OrderScanner, type OrderScanner$1 as OrderScannerContract, type OrderScannerHandlers, type OrderScannerOptions, type PairConfig, PairController, type PairView, type PostedLimitOrder, type PostingOutcome, type PrivateKeySignerConfig, type ProfitBucket, type ProfitBucketFigures, type ProfitFigures, type ProfitPeriod, type Profitability, type QueueConfig, RebalanceController, type RebalancingConfig, type ResolvedChainConfig, type ScannedFill, type ScannedOrder, type ScannerChainConfig, type SecretPhraseSignerConfig, type Signature, type Signer, type SignerConfig, type SignerTransaction, SignerType, Simplex, type SimplexConfig, SimplexDataStore, type SimplexEvents, type SimplexOptions, type SimplexStatus, type SolverWork, type StartingInventory, StateStore, StoredBid, type Subscription, type TurnkeySignerConfig, type TypedDataPayload, USD_STABLE_SYMBOLS, type UserProvidedChainConfig, type VaultBalanceRow, VaultController, type VaultSweepDeposit, type VaultSweepResult, type VaultSweepSkip, type VaultSweepSkipReason, type VaultSweepSubmission, type VaultToml, type VaultTomlConfig, WalletController, WalletTx, assertConfirmationCoverage, canDerive, createSigner, digestSigner, formatChainKey, isRegistrySymbol, mpcVaultSigner, normalizeSymbol, parseChainKey, pickAnchorStable, privateKeySigner, registrySymbols, secretPhraseSigner, turnkeySigner, validateAssetDefinitions, validateConfig, validatePairConfigs, validateSecretPhrase, validateSignerConfig, validateVaultToml, viemSigner };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { EventEmitter as EventEmitter$1 } from 'node:events';
|
|
|
2
2
|
import { HexString, ERC7821Call, ChainConfig, Order, TokenInfo, IntentsCoprocessor, ExecutionResult, IntentGateway, FillOptions, FillerConfig as FillerConfig$1 } from '@hyperbridge/sdk';
|
|
3
3
|
import { PublicClient, Hash, AbiEvent, BlockNumber, BlockTag, GetLogsParameters, GetLogsReturnType, WalletClient, Transport, Chain } from 'viem';
|
|
4
4
|
import { LocalAccount, Account } from 'viem/accounts';
|
|
5
|
-
import { L as LoggerContext, a as LogLevel, b as Logger, A as ActivityStore, c as ActivityInsert, d as ActivityEvent, O as OrderHistoryPage, W as WalletTx, e as LimitOrderStore, f as LimitOrder, g as LimitOrderFilter, B as BidStore, S as SimplexDataStore, h as LimitOrderFill, i as StoredBid, j as LogSink, k as BidStats, l as StateStore } from './types-
|
|
6
|
-
export { m as ActivityType, n as BidInsert, o as
|
|
5
|
+
import { L as LoggerContext, a as LogLevel, b as Logger, A as ActivityStore, c as ActivityInsert, d as ActivityEvent, O as OrderHistoryPage, W as WalletTx, e as LimitOrderStore, f as LimitOrder, g as LimitOrderFilter, B as BidStore, S as SimplexDataStore, h as LimitOrderFill, i as StoredBid, j as LogSink, k as BidStats, l as StateStore, I as InventoryStore } from './types-BISgqJhM.js';
|
|
6
|
+
export { m as ActivityType, n as BidInsert, o as InventorySnapshot, p as LimitOrderFillInsert, q as LimitOrderFillRecord, r as LimitOrderHold, s as LimitOrderInsert, t as LimitOrderPosting, u as LimitOrderSide, v as LimitOrderStatus, w as OperatorNotification, R as RuntimeState, x as WalletTxKind, y as addLogSink, z as configureLogger, C as getLogger } from './types-BISgqJhM.js';
|
|
7
7
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
@@ -1605,6 +1605,85 @@ declare class BalanceProvider extends EventEmitter$1 {
|
|
|
1605
1605
|
private trackHyperbridgeBalance;
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
|
+
/** The stretch of time a summary covers. Each is cut into buckets of one size. */
|
|
1609
|
+
type ProfitPeriod = "7d" | "30d" | "12w" | "12m" | "all";
|
|
1610
|
+
type ProfitBucket = "day" | "week" | "month" | "year";
|
|
1611
|
+
/** What a stretch of fills came to, in dollars at the latest rate. Unpriced tokens are left out. */
|
|
1612
|
+
interface ProfitFigures {
|
|
1613
|
+
/** What the stretch's fills added to inventory, less what they took out of it. */
|
|
1614
|
+
profitUsd: number;
|
|
1615
|
+
/** The inventory held when the stretch began. Null when nothing within reach of then records it. */
|
|
1616
|
+
startInventoryUsd: number | null;
|
|
1617
|
+
/** `profitUsd` over `startInventoryUsd`, as a percentage. Null without a starting inventory. */
|
|
1618
|
+
returnPct: number | null;
|
|
1619
|
+
/**
|
|
1620
|
+
* What moved in and out over the stretch other than through fills, net: deposits, withdrawals,
|
|
1621
|
+
* fees and vault yield. Null when the indexer has no reading for both ends of the stretch.
|
|
1622
|
+
*/
|
|
1623
|
+
transfersUsd: number | null;
|
|
1624
|
+
boughtUsd: number;
|
|
1625
|
+
soldUsd: number;
|
|
1626
|
+
buys: number;
|
|
1627
|
+
sells: number;
|
|
1628
|
+
}
|
|
1629
|
+
interface ProfitBucketFigures extends ProfitFigures {
|
|
1630
|
+
/** When the bucket starts, in milliseconds since the epoch. */
|
|
1631
|
+
start: number;
|
|
1632
|
+
}
|
|
1633
|
+
/** One book's buys against its sells over the period, in the book's own tokens. */
|
|
1634
|
+
interface BookProfit {
|
|
1635
|
+
book: string;
|
|
1636
|
+
base: string;
|
|
1637
|
+
quote: string;
|
|
1638
|
+
/** Base bought and sold in the period. */
|
|
1639
|
+
bought: number;
|
|
1640
|
+
sold: number;
|
|
1641
|
+
/** Quote per base, averaged over the period's buys and its sells. Null for a side with none. */
|
|
1642
|
+
averageBuy: number | null;
|
|
1643
|
+
averageSell: number | null;
|
|
1644
|
+
/** How far the average sell sits above the average buy, as a percentage. Null without both. */
|
|
1645
|
+
spreadPct: number | null;
|
|
1646
|
+
/** What the period's fills did to the base and the quote held: positive is more than before. */
|
|
1647
|
+
baseChange: number;
|
|
1648
|
+
quoteChange: number;
|
|
1649
|
+
/** The rate the book's tokens are valued at: midway between its latest buy and latest sell. */
|
|
1650
|
+
rate: number | null;
|
|
1651
|
+
/** Both changes in dollars. Null when the book's tokens have no dollar price. */
|
|
1652
|
+
profitUsd: number | null;
|
|
1653
|
+
}
|
|
1654
|
+
/** The inventory a period began with, token by token. */
|
|
1655
|
+
interface StartingInventory {
|
|
1656
|
+
/** The instant it describes, in milliseconds since the epoch. */
|
|
1657
|
+
at: number;
|
|
1658
|
+
/** A stored snapshot, or the balances as they stand now. Either is adjusted by what happened between. */
|
|
1659
|
+
source: "snapshot" | "balances";
|
|
1660
|
+
/** When that record was taken. */
|
|
1661
|
+
recordedAt: number;
|
|
1662
|
+
usd: number;
|
|
1663
|
+
tokens: Array<{
|
|
1664
|
+
symbol: string;
|
|
1665
|
+
amount: number;
|
|
1666
|
+
usd: number | null;
|
|
1667
|
+
}>;
|
|
1668
|
+
}
|
|
1669
|
+
interface Profitability {
|
|
1670
|
+
period: ProfitPeriod;
|
|
1671
|
+
bucket: ProfitBucket;
|
|
1672
|
+
/** The start of the first bucket and the moment the summary was taken, in milliseconds. */
|
|
1673
|
+
from: number;
|
|
1674
|
+
to: number;
|
|
1675
|
+
totals: ProfitFigures;
|
|
1676
|
+
/** One entry per bucket, oldest first, including buckets nothing happened in. */
|
|
1677
|
+
series: ProfitBucketFigures[];
|
|
1678
|
+
books: BookProfit[];
|
|
1679
|
+
/** Null when there is no snapshot, and the period began more than {@link BALANCES_REACH_MS} ago. */
|
|
1680
|
+
startInventory: StartingInventory | null;
|
|
1681
|
+
/** Fills in the period priced at their order's rate, because they kept no record of what they took in. */
|
|
1682
|
+
estimatedFills: number;
|
|
1683
|
+
/** Tokens the period touched that have no dollar price, and so are in none of the dollar figures. */
|
|
1684
|
+
unpricedTokens: string[];
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1608
1687
|
/**
|
|
1609
1688
|
* Wire contracts between the UI server and the browser bundle. The server
|
|
1610
1689
|
* types its response literals with these and `ui/src` imports them type-only,
|
|
@@ -2044,6 +2123,8 @@ interface BidPlan {
|
|
|
2044
2123
|
fillerOutputs: TokenInfo[];
|
|
2045
2124
|
/** The take signed beside each output: the escrow this bid's fill earns. */
|
|
2046
2125
|
fillerInputs: TokenInfo[];
|
|
2126
|
+
/** The decimals `fillerInputs[leg]` is counted in: the input token's, on the order's source chain. */
|
|
2127
|
+
inputDecimals?: number;
|
|
2047
2128
|
fundingCalls: ERC7821Call[];
|
|
2048
2129
|
partialFill: boolean;
|
|
2049
2130
|
profit: number;
|
|
@@ -2701,6 +2782,52 @@ interface Book {
|
|
|
2701
2782
|
base: string;
|
|
2702
2783
|
quote: string;
|
|
2703
2784
|
}
|
|
2785
|
+
/** Live price levels. All prices and sizes are decimal integer strings at 1e18. */
|
|
2786
|
+
interface OrderbookLevel {
|
|
2787
|
+
fillChain: string;
|
|
2788
|
+
priceBucket: string;
|
|
2789
|
+
price: string;
|
|
2790
|
+
worstPrice: string;
|
|
2791
|
+
baseSize: string;
|
|
2792
|
+
quoteSize: string;
|
|
2793
|
+
orderCount: number;
|
|
2794
|
+
solverCount: number;
|
|
2795
|
+
}
|
|
2796
|
+
interface OrderbookSnapshot extends Book {
|
|
2797
|
+
/** Best first: bids descending, asks ascending. */
|
|
2798
|
+
bids: OrderbookLevel[];
|
|
2799
|
+
asks: OrderbookLevel[];
|
|
2800
|
+
/** True backing liquidity, in quote for bids and base for asks. */
|
|
2801
|
+
bidLiquidity: string;
|
|
2802
|
+
askLiquidity: string;
|
|
2803
|
+
/** Price bucket width, quote per 1 base at 1e18; null when the orderbook does not report one. */
|
|
2804
|
+
granularity: string | null;
|
|
2805
|
+
}
|
|
2806
|
+
/** One solver's order inside a price level. Prices and sizes are decimal integer strings at 1e18. */
|
|
2807
|
+
interface OrderbookLevelOrder {
|
|
2808
|
+
solver: string;
|
|
2809
|
+
commitment: string;
|
|
2810
|
+
fillChain: string;
|
|
2811
|
+
price: string;
|
|
2812
|
+
/** What the order publishes as depth, in the token its side pays out: quote for bids, base for asks. */
|
|
2813
|
+
advertisedSize: string;
|
|
2814
|
+
/** The signed output before any balance cap, in the same token as `advertisedSize`. */
|
|
2815
|
+
quotedAmount: string;
|
|
2816
|
+
/** True when the solver's balance, not the quote, binds `advertisedSize`. */
|
|
2817
|
+
resized: boolean;
|
|
2818
|
+
expiresAt: string;
|
|
2819
|
+
acceptedSources: string[];
|
|
2820
|
+
}
|
|
2821
|
+
interface OrderbookLevelQuery {
|
|
2822
|
+
side: "BID" | "ASK";
|
|
2823
|
+
fillChain: string;
|
|
2824
|
+
priceBucket: string;
|
|
2825
|
+
sourceChain?: string;
|
|
2826
|
+
}
|
|
2827
|
+
interface OrderbookFilters {
|
|
2828
|
+
sourceChain?: string;
|
|
2829
|
+
fillChain?: string;
|
|
2830
|
+
}
|
|
2704
2831
|
interface TokenMinSize {
|
|
2705
2832
|
symbol: string;
|
|
2706
2833
|
size: string;
|
|
@@ -2851,6 +2978,14 @@ declare class OrderbookClient {
|
|
|
2851
2978
|
constructor(url: string, requestTimeoutMs: number, loggers?: LoggerContext);
|
|
2852
2979
|
/** The limits to validate against before posting, plus the books on offer. */
|
|
2853
2980
|
limits(): Promise<OrderbookLimits>;
|
|
2981
|
+
/** The public book across all solvers, restricted to the selected route. */
|
|
2982
|
+
snapshot(id: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
2983
|
+
/**
|
|
2984
|
+
* The orders behind one price level. The orderbook filters orders by side and route but not by
|
|
2985
|
+
* price bucket, so this walks the side's orders on the level's fill chain and keeps the bucket.
|
|
2986
|
+
* Null when the book does not exist.
|
|
2987
|
+
*/
|
|
2988
|
+
levelOrders(id: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
2854
2989
|
submitOrder(userOp: HexString): Promise<SubmitOrderResult>;
|
|
2855
2990
|
/**
|
|
2856
2991
|
* The entry this solver holds at `commitment`, or null when it holds none.
|
|
@@ -3025,6 +3160,10 @@ declare class LimitOrderService {
|
|
|
3025
3160
|
*/
|
|
3026
3161
|
private withdraw;
|
|
3027
3162
|
private signAndCancel;
|
|
3163
|
+
/** Public market levels read through the configured orderbook client. */
|
|
3164
|
+
orderbookSnapshot(book: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
3165
|
+
/** Every solver's order behind one public price level. */
|
|
3166
|
+
orderbookLevelOrders(book: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
3028
3167
|
/**
|
|
3029
3168
|
* The pairs an order can be written against, the smallest payout each token may carry, and
|
|
3030
3169
|
* the tokens the orderbook registers on each chain.
|
|
@@ -3769,6 +3908,10 @@ interface FillerRuntime {
|
|
|
3769
3908
|
rebalancingService?: RebalancingService;
|
|
3770
3909
|
resolvedChains: ResolvedChainConfig[];
|
|
3771
3910
|
fillerAddress: HexString;
|
|
3911
|
+
/** The indexer this filler reads history from: order details, and what it held at past moments. */
|
|
3912
|
+
indexerUrl: string;
|
|
3913
|
+
/** A token's registry symbol and on-chain decimals, where either can be had. */
|
|
3914
|
+
describeToken: TokenDescriber;
|
|
3772
3915
|
watchOnly?: Record<number, boolean>;
|
|
3773
3916
|
config: FillerTomlConfig;
|
|
3774
3917
|
/** Where the config came from, when it came from a file. */
|
|
@@ -3977,6 +4120,7 @@ interface SimplexStatus {
|
|
|
3977
4120
|
declare class LimitOrderController {
|
|
3978
4121
|
private runtime;
|
|
3979
4122
|
private emit;
|
|
4123
|
+
private indexed?;
|
|
3980
4124
|
constructor(runtime: FillerRuntime, emit: LimitOrderEmitter);
|
|
3981
4125
|
private get service();
|
|
3982
4126
|
list(filter?: LimitOrderFilter): Promise<LimitOrder[]>;
|
|
@@ -3993,12 +4137,32 @@ declare class LimitOrderController {
|
|
|
3993
4137
|
fills: LimitOrderFill[];
|
|
3994
4138
|
bids: StoredBid[];
|
|
3995
4139
|
} | null>;
|
|
4140
|
+
/**
|
|
4141
|
+
* What the operator's buys and sells earned over `period`, bucketed on a clock
|
|
4142
|
+
* `tzOffsetMinutes` behind UTC.
|
|
4143
|
+
*
|
|
4144
|
+
* Profit is the change the period's fills made to what the solver holds, and
|
|
4145
|
+
* it is compared with the inventory the period began with. That inventory
|
|
4146
|
+
* comes from the stored snapshots and, when the balances have been read in
|
|
4147
|
+
* full, from what is held now, each carried to the period's start by what
|
|
4148
|
+
* moved between. The indexer says what moved, deposits and withdrawals
|
|
4149
|
+
* included, wherever it has followed the solver; elsewhere the fills and
|
|
4150
|
+
* sends on record stand in. It answers whether or not an orderbook is
|
|
4151
|
+
* configured, and whether or not the indexer does.
|
|
4152
|
+
*/
|
|
4153
|
+
profitability(period: ProfitPeriod, tzOffsetMinutes?: number): Promise<Profitability>;
|
|
4154
|
+
/** One reader for the life of the filler, so the readings it has already fetched are kept. */
|
|
4155
|
+
private indexerInventory;
|
|
3996
4156
|
/** The pairs the orderbook lists, the smallest payout each token may carry, and its tokens per chain. */
|
|
3997
4157
|
books(): Promise<{
|
|
3998
4158
|
books: Book[];
|
|
3999
4159
|
minOrderSizes: TokenMinSize[];
|
|
4000
4160
|
chains: ChainInfo[];
|
|
4001
4161
|
}>;
|
|
4162
|
+
/** Public bids and asks across solvers, optionally restricted to a route. */
|
|
4163
|
+
orderbookSnapshot(book: string, filters?: OrderbookFilters): Promise<OrderbookSnapshot | null>;
|
|
4164
|
+
/** Every solver's order behind one public price level. */
|
|
4165
|
+
orderbookLevelOrders(book: string, level: OrderbookLevelQuery): Promise<OrderbookLevelOrder[] | null>;
|
|
4002
4166
|
/** Creates the order, posts it, and reports what the orderbook made of it. */
|
|
4003
4167
|
create(request: CreateLimitOrderRequest): Promise<PostedLimitOrder>;
|
|
4004
4168
|
cancel(id: string): Promise<CancelledLimitOrder>;
|
|
@@ -4240,20 +4404,12 @@ declare class Simplex extends EventEmitter$1 {
|
|
|
4240
4404
|
get internals(): FillerRuntime;
|
|
4241
4405
|
}
|
|
4242
4406
|
|
|
4243
|
-
/**
|
|
4244
|
-
* Process-local data store — the default when `Simplex.start` is given no
|
|
4245
|
-
* `data` option.
|
|
4246
|
-
*
|
|
4247
|
-
* Nothing survives the process. That is fine for tests, short-lived embedded
|
|
4248
|
-
* fillers and watch-only observers, but a filler that submits bids should use a
|
|
4249
|
-
* durable store: a lost bid record is a Hyperbridge deposit nobody retracts.
|
|
4250
|
-
* Settled rows are evicted past a cap; live bids (deposits still reclaimable) are never dropped.
|
|
4251
|
-
*/
|
|
4252
4407
|
declare class MemoryDataStore implements SimplexDataStore {
|
|
4253
4408
|
readonly bids: BidStore;
|
|
4254
4409
|
readonly activity: ActivityStore;
|
|
4255
4410
|
readonly state: StateStore;
|
|
4256
4411
|
readonly limitOrders: LimitOrderStore;
|
|
4412
|
+
readonly inventory: InventoryStore;
|
|
4257
4413
|
}
|
|
4258
4414
|
|
|
4259
4415
|
/**
|
|
@@ -4320,4 +4476,4 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4320
4476
|
private closeNow;
|
|
4321
4477
|
}
|
|
4322
4478
|
|
|
4323
|
-
export { ActivityEvent, ActivityInsert, ActivityStore, type AllowlistConfig, type AssetBalanceRow, AssetController, type AssetDefinition, type AuthorizationRequest, type BalanceIssue, type BalanceSnapshot, BidStats, BidStore, type BinanceConfig, type CancelledLimitOrder, type ChainBalanceRow, type ChainConfirmationPolicy, ChainController, type ChainInput, type ChainView, type CreateLimitOrderRequest, type CurveConfig, type CurvePoint, type DerivingSigner, type Eip7702Authorization$1 as Eip7702Authorization, type FillerConfigFile, type FillerTomlConfig, type HyperbridgeBalance, LimitOrder, LimitOrderController, LimitOrderFill, LimitOrderFilter, LimitOrderStore, LimitOrderValidationError, LogLevel, LogSink, Logger, LoggerContext, MemoryDataStore, type MpcVaultSignerConfig, OrderScanner, type OrderScanner$1 as OrderScannerContract, type OrderScannerHandlers, type OrderScannerOptions, type PairConfig, PairController, type PairView, type PostedLimitOrder, type PostingOutcome, type PrivateKeySignerConfig, type QueueConfig, RebalanceController, type RebalancingConfig, type ResolvedChainConfig, type ScannedFill, type ScannedOrder, type ScannerChainConfig, type SecretPhraseSignerConfig, type Signature, type Signer, type SignerConfig, type SignerTransaction, SignerType, Simplex, type SimplexConfig, SimplexDataStore, type SimplexEvents, type SimplexOptions, type SimplexStatus, type SolverWork, StateStore, StoredBid, type Subscription, type TurnkeySignerConfig, type TypedDataPayload, USD_STABLE_SYMBOLS, type UserProvidedChainConfig, type VaultBalanceRow, VaultController, type VaultSweepDeposit, type VaultSweepResult, type VaultSweepSkip, type VaultSweepSkipReason, type VaultSweepSubmission, type VaultToml, type VaultTomlConfig, WalletController, WalletTx, assertConfirmationCoverage, canDerive, createSigner, digestSigner, formatChainKey, isRegistrySymbol, mpcVaultSigner, normalizeSymbol, parseChainKey, pickAnchorStable, privateKeySigner, registrySymbols, secretPhraseSigner, turnkeySigner, validateAssetDefinitions, validateConfig, validatePairConfigs, validateSecretPhrase, validateSignerConfig, validateVaultToml, viemSigner };
|
|
4479
|
+
export { ActivityEvent, ActivityInsert, ActivityStore, type AllowlistConfig, type AssetBalanceRow, AssetController, type AssetDefinition, type AuthorizationRequest, type BalanceIssue, type BalanceSnapshot, BidStats, BidStore, type BinanceConfig, type BookProfit, type CancelledLimitOrder, type ChainBalanceRow, type ChainConfirmationPolicy, ChainController, type ChainInput, type ChainView, type CreateLimitOrderRequest, type CurveConfig, type CurvePoint, type DerivingSigner, type Eip7702Authorization$1 as Eip7702Authorization, type FillerConfigFile, type FillerTomlConfig, type HyperbridgeBalance, InventoryStore, LimitOrder, LimitOrderController, LimitOrderFill, LimitOrderFilter, LimitOrderStore, LimitOrderValidationError, LogLevel, LogSink, Logger, LoggerContext, MemoryDataStore, type MpcVaultSignerConfig, OrderScanner, type OrderScanner$1 as OrderScannerContract, type OrderScannerHandlers, type OrderScannerOptions, type PairConfig, PairController, type PairView, type PostedLimitOrder, type PostingOutcome, type PrivateKeySignerConfig, type ProfitBucket, type ProfitBucketFigures, type ProfitFigures, type ProfitPeriod, type Profitability, type QueueConfig, RebalanceController, type RebalancingConfig, type ResolvedChainConfig, type ScannedFill, type ScannedOrder, type ScannerChainConfig, type SecretPhraseSignerConfig, type Signature, type Signer, type SignerConfig, type SignerTransaction, SignerType, Simplex, type SimplexConfig, SimplexDataStore, type SimplexEvents, type SimplexOptions, type SimplexStatus, type SolverWork, type StartingInventory, StateStore, StoredBid, type Subscription, type TurnkeySignerConfig, type TypedDataPayload, USD_STABLE_SYMBOLS, type UserProvidedChainConfig, type VaultBalanceRow, VaultController, type VaultSweepDeposit, type VaultSweepResult, type VaultSweepSkip, type VaultSweepSkipReason, type VaultSweepSubmission, type VaultToml, type VaultTomlConfig, WalletController, WalletTx, assertConfirmationCoverage, canDerive, createSigner, digestSigner, formatChainKey, isRegistrySymbol, mpcVaultSigner, normalizeSymbol, parseChainKey, pickAnchorStable, privateKeySigner, registrySymbols, secretPhraseSigner, turnkeySigner, validateAssetDefinitions, validateConfig, validatePairConfigs, validateSecretPhrase, validateSignerConfig, validateVaultToml, viemSigner };
|