@hyperbridge/simplex 0.16.8 → 0.16.12
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 +31 -14
- package/dist/bin/simplex.js +23880 -2112
- package/dist/bin/simplex.js.map +1 -1
- package/dist/config-storage.cjs +186 -0
- package/dist/config-storage.cjs.map +1 -0
- package/dist/config-storage.d.cts +28 -0
- package/dist/config-storage.d.ts +28 -0
- package/dist/config-storage.js +163 -0
- package/dist/config-storage.js.map +1 -0
- package/dist/index.cjs +704 -295
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +246 -100
- package/dist/index.d.ts +246 -100
- package/dist/index.js +579 -175
- package/dist/index.js.map +1 -1
- package/dist/sqlite.cjs +12 -0
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +2 -1
- package/dist/sqlite.d.ts +2 -1
- package/dist/sqlite.js +12 -0
- package/dist/sqlite.js.map +1 -1
- package/dist/{types-C7rnnKWn.d.cts → types-B5zkFhxR.d.cts} +11 -1
- package/dist/{types-C7rnnKWn.d.ts → types-B5zkFhxR.d.ts} +11 -1
- package/dist/ui/assets/{index-BQu6BMxc.js → index-QU1Ik7IX.js} +35 -35
- package/dist/ui/assets/{index-C3T-gubp.css → index-XKHMOpY2.css} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +15 -3
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 OperatorNotification, R as RuntimeState,
|
|
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-B5zkFhxR.js';
|
|
6
|
+
export { m as ActivityType, n as BidInsert, o as LimitOrderFillInsert, p as LimitOrderHold, q as LimitOrderInsert, r as LimitOrderPosting, s as LimitOrderSide, t as LimitOrderStatus, u as OperatorNotification, R as RuntimeState, v as WalletTxKind, w as addLogSink, x as configureLogger, y as getLogger } from './types-B5zkFhxR.js';
|
|
7
7
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
@@ -158,6 +158,11 @@ interface FillerConfig {
|
|
|
158
158
|
* See `bidValiditySeconds` in filler-toml for why this bound matters.
|
|
159
159
|
*/
|
|
160
160
|
bidValiditySeconds?: number;
|
|
161
|
+
/**
|
|
162
|
+
* Order size in USD below which `order.fees` must cover the execution cost.
|
|
163
|
+
* Defaults to 20. See `minOrderSizeUsd` in filler-toml.
|
|
164
|
+
*/
|
|
165
|
+
minOrderSizeUsd?: number;
|
|
161
166
|
/**
|
|
162
167
|
* Overfill protection knobs. If omitted, defaults are used
|
|
163
168
|
* (maxOverfillBps=500, maxConsecutiveClamps=3).
|
|
@@ -343,6 +348,11 @@ declare class FillerConfigService {
|
|
|
343
348
|
* Hyperbridge-side retraction does not reach the destination chain.
|
|
344
349
|
*/
|
|
345
350
|
getBidValiditySeconds(): number;
|
|
351
|
+
/**
|
|
352
|
+
* The order size, in USD, below which `order.fees` must cover the execution cost.
|
|
353
|
+
* Defaults to 20. An order at or above it is filled whatever fees it carries.
|
|
354
|
+
*/
|
|
355
|
+
getMinOrderSizeUsd(): number;
|
|
346
356
|
/** Ceiling bps above user-requested output. Default 500 (5%). */
|
|
347
357
|
getMaxOverfillBps(): bigint;
|
|
348
358
|
/** Consecutive clamped evaluations before the strategy halts. Default 3. */
|
|
@@ -546,7 +556,8 @@ interface MpcVaultSignerConfig {
|
|
|
546
556
|
declare enum SignerType {
|
|
547
557
|
PrivateKey = "privateKey",
|
|
548
558
|
MpcVault = "mpcVault",
|
|
549
|
-
Turnkey = "turnkey"
|
|
559
|
+
Turnkey = "turnkey",
|
|
560
|
+
SecretPhrase = "secretPhrase"
|
|
550
561
|
}
|
|
551
562
|
interface TurnkeySignerConfig {
|
|
552
563
|
organizationId: string;
|
|
@@ -557,6 +568,15 @@ interface TurnkeySignerConfig {
|
|
|
557
568
|
interface PrivateKeySignerConfig {
|
|
558
569
|
key: HexString;
|
|
559
570
|
}
|
|
571
|
+
interface SecretPhraseSignerConfig {
|
|
572
|
+
/** BIP-39 mnemonic from the English wordlist. */
|
|
573
|
+
phrase: string;
|
|
574
|
+
/**
|
|
575
|
+
* Which wallet under the phrase is the hot wallet: the last component of
|
|
576
|
+
* `m/44'/60'/0'/0/i`. Defaults to 0.
|
|
577
|
+
*/
|
|
578
|
+
accountIndex?: number;
|
|
579
|
+
}
|
|
560
580
|
/**
|
|
561
581
|
* The `[simplex.signer]` block of the TOML file the binary reads — a tagged
|
|
562
582
|
* union over the bundled backends. `createSigner` turns one into a {@link Signer};
|
|
@@ -568,7 +588,9 @@ type SignerConfig = ({
|
|
|
568
588
|
type: SignerType.MpcVault;
|
|
569
589
|
} & MpcVaultSignerConfig) | ({
|
|
570
590
|
type: SignerType.Turnkey;
|
|
571
|
-
} & TurnkeySignerConfig)
|
|
591
|
+
} & TurnkeySignerConfig) | ({
|
|
592
|
+
type: SignerType.SecretPhrase;
|
|
593
|
+
} & SecretPhraseSignerConfig);
|
|
572
594
|
/**
|
|
573
595
|
* A secp256k1 signature in split form, which is how EIP-7702 and raw digests
|
|
574
596
|
* consume it: `r` and `s` as 32-byte 0x-hex, and `yParity` strictly 0 or 1.
|
|
@@ -682,6 +704,16 @@ interface Signer {
|
|
|
682
704
|
*/
|
|
683
705
|
signTransaction(tx: SignerTransaction): Promise<HexString>;
|
|
684
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* A {@link Signer} backed by a key tree rather than a single key, so it can hand
|
|
709
|
+
* out signers for sibling wallets.
|
|
710
|
+
*/
|
|
711
|
+
interface DerivingSigner extends Signer {
|
|
712
|
+
/** Index of the wallet this signer itself signs with. */
|
|
713
|
+
readonly accountIndex: number;
|
|
714
|
+
/** The signer for the wallet at `index`, which may be this signer's own. */
|
|
715
|
+
derive(index: number): Signer;
|
|
716
|
+
}
|
|
685
717
|
/** The tuple an EIP-7702 authorization signature covers. */
|
|
686
718
|
interface AuthorizationRequest {
|
|
687
719
|
chainId: number;
|
|
@@ -745,6 +777,19 @@ declare function viemSigner(account: LocalAccount): Signer;
|
|
|
745
777
|
*/
|
|
746
778
|
declare function privateKeySigner(privateKey: HexString): Signer;
|
|
747
779
|
|
|
780
|
+
/**
|
|
781
|
+
* Throws unless the phrase is a BIP-39 mnemonic from the English wordlist with a
|
|
782
|
+
* matching checksum. The errors name what is wrong and never quote the phrase.
|
|
783
|
+
*/
|
|
784
|
+
declare function validateSecretPhrase(phrase: string): void;
|
|
785
|
+
/**
|
|
786
|
+
* Signs with wallets derived from a BIP-39 phrase held in this process. The
|
|
787
|
+
* hot wallet is `m/44'/60'/0'/0/accountIndex`, and `derive` returns the signer
|
|
788
|
+
* for any sibling under the same parent.
|
|
789
|
+
*/
|
|
790
|
+
declare function secretPhraseSigner(config: SecretPhraseSignerConfig): DerivingSigner;
|
|
791
|
+
declare function canDerive(signer: Signer): signer is DerivingSigner;
|
|
792
|
+
|
|
748
793
|
/**
|
|
749
794
|
* Signs through MPCVault's signing ceremony.
|
|
750
795
|
*
|
|
@@ -1350,10 +1395,9 @@ interface BuiltinAssetResolver {
|
|
|
1350
1395
|
getAssetBySymbol(chain: string, symbol: string): HexString | undefined;
|
|
1351
1396
|
}
|
|
1352
1397
|
/**
|
|
1353
|
-
* Symbols pegged to 1 USD. They
|
|
1354
|
-
* from
|
|
1355
|
-
*
|
|
1356
|
-
* pricing never uses this as a price.
|
|
1398
|
+
* Symbols pegged to 1 USD. They are pinned at $1 when an order's USD value is
|
|
1399
|
+
* derived from the limit orders' rates (see `usdFactorsFrom`), which is what
|
|
1400
|
+
* sizes confirmation depth. Trade pricing never uses this as a price.
|
|
1357
1401
|
*/
|
|
1358
1402
|
declare const USD_STABLE_SYMBOLS: ReadonlySet<string>;
|
|
1359
1403
|
/** Normalises a symbol for lookups: trimmed, uppercased. "cNGN" ≡ "CNGN". */
|
|
@@ -1419,22 +1463,24 @@ declare class AssetRegistry {
|
|
|
1419
1463
|
*
|
|
1420
1464
|
* ```toml
|
|
1421
1465
|
* [[pairs]]
|
|
1422
|
-
* token0 = "USDC" #
|
|
1423
|
-
* token1 = "CNGN" #
|
|
1466
|
+
* token0 = "USDC" # the book's base — any symbol in the asset registry
|
|
1467
|
+
* token1 = "CNGN" # the book's quote — any symbol in the asset registry
|
|
1424
1468
|
* ```
|
|
1425
1469
|
*
|
|
1426
1470
|
* A pair declares that a market exists and nothing more. What the filler will
|
|
1427
1471
|
* pay on it comes from the operator's limit orders, which carry the rate and the
|
|
1428
1472
|
* size they are good for.
|
|
1429
1473
|
*
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1474
|
+
* The orientation follows the orderbook's books, which the setup wizard copies:
|
|
1475
|
+
* `token0` is the book's base and `token1` its quote, so the `USDC-cNGN` book
|
|
1476
|
+
* (priced in cNGN per USDC) becomes `token0 = "USDC"`, `token1 = "CNGN"`. One
|
|
1477
|
+
* orientation only: `A/B` and `B/A` are the same market and declaring both is
|
|
1478
|
+
* refused. `token0 == token1` is the same-asset cross-chain market.
|
|
1433
1479
|
*/
|
|
1434
1480
|
interface PairConfig {
|
|
1435
|
-
/**
|
|
1481
|
+
/** The book's base symbol (e.g. "USDC", "USDT"). Any symbol in the registry. */
|
|
1436
1482
|
token0: string;
|
|
1437
|
-
/**
|
|
1483
|
+
/** The book's quote symbol, which the book prices the base in (e.g. "CNGN"). Any symbol in the registry. */
|
|
1438
1484
|
token1: string;
|
|
1439
1485
|
}
|
|
1440
1486
|
/**
|
|
@@ -1709,18 +1755,21 @@ interface FillerTomlConfig {
|
|
|
1709
1755
|
*/
|
|
1710
1756
|
assets?: Record<string, AssetDefinition>;
|
|
1711
1757
|
/**
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1758
|
+
* Markets the operator dashboard lists, as `token0`/`token1` symbol pairs.
|
|
1759
|
+
* They carry no prices and do not gate matching: the filler prices every
|
|
1760
|
+
* fill from the operator's limit orders. Optional; the browser setup wizard
|
|
1761
|
+
* writes one per book the orderbook lists. Keys left over from the curve
|
|
1762
|
+
* era (`bidPriceCurve`, `askPriceCurve`, `maxOrderSize`, `referenceOnly`)
|
|
1763
|
+
* are ignored.
|
|
1716
1764
|
*/
|
|
1717
1765
|
pairs?: PairConfig[];
|
|
1718
1766
|
/**
|
|
1719
1767
|
* Per-chain confirmation policies for cross-chain orders, keyed by chain id.
|
|
1720
1768
|
* Merged over built-in defaults (ETH, BSC, Polygon, Base, Arbitrum,
|
|
1721
1769
|
* Unichain); every configured chain must be covered or startup fails. The
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1770
|
+
* policy's amount axis is the order's USD value: USD stables count at $1 and
|
|
1771
|
+
* other tokens are valued through the open limit orders' rates. An order no
|
|
1772
|
+
* limit order connects to a dollar waits for the policy's maximum depth.
|
|
1724
1773
|
*/
|
|
1725
1774
|
confirmationPolicies?: Record<string, ChainConfirmationPolicy>;
|
|
1726
1775
|
simplex: {
|
|
@@ -1762,8 +1811,10 @@ interface FillerTomlConfig {
|
|
|
1762
1811
|
};
|
|
1763
1812
|
/**
|
|
1764
1813
|
* Overfill protection knobs. Defaults: maxOverfillBps=500, maxConsecutiveClamps=3.
|
|
1765
|
-
* `maxOverfillBps`
|
|
1766
|
-
*
|
|
1814
|
+
* `maxOverfillBps` is warn-only: FXFiller logs a limit order whose offer exceeds
|
|
1815
|
+
* the swapper's ask by more than this, and clamps nothing. `maxConsecutiveClamps`
|
|
1816
|
+
* is accepted but dormant: the clamp that fed it was for Uniswap V4 venue pricing,
|
|
1817
|
+
* which is gone, so FXFiller never halts.
|
|
1767
1818
|
*/
|
|
1768
1819
|
overfillProtection?: {
|
|
1769
1820
|
maxOverfillBps?: number;
|
|
@@ -1781,6 +1832,16 @@ interface FillerTomlConfig {
|
|
|
1781
1832
|
* Configured in seconds but written on-chain in blocks, converted per destination chain.
|
|
1782
1833
|
*/
|
|
1783
1834
|
bidValiditySeconds?: number;
|
|
1835
|
+
/**
|
|
1836
|
+
* The order size, in USD, below which `order.fees` must cover the execution cost
|
|
1837
|
+
* (fill gas plus, cross-chain, the relayer fee). Defaults to 20.
|
|
1838
|
+
*
|
|
1839
|
+
* An order worth at least this much is filled whatever fees it carries: the margin
|
|
1840
|
+
* in the limit order that prices it pays for the gas. On a smaller order that
|
|
1841
|
+
* margin is too thin to, so the fees have to. Set to 0 to never check fees. An
|
|
1842
|
+
* order nothing can put a dollar figure on is treated as below it.
|
|
1843
|
+
*/
|
|
1844
|
+
minOrderSizeUsd?: number;
|
|
1784
1845
|
/**
|
|
1785
1846
|
* Remote access: an outbound SSH tunnel to a rendezvous relay so a phone's
|
|
1786
1847
|
* SSH client can reach the local web UI. Off unless `enabled = true`; the
|
|
@@ -1926,12 +1987,6 @@ declare class ActivityRecorder extends EventEmitter$1 {
|
|
|
1926
1987
|
walletTxs(limit?: number): Promise<WalletTx[]>;
|
|
1927
1988
|
}
|
|
1928
1989
|
|
|
1929
|
-
/**
|
|
1930
|
-
* One curve-priced trading pair's editable price curves. The policies are the
|
|
1931
|
-
* same instances the running engine prices with, so `replacePoints` takes
|
|
1932
|
-
* effect on the next order evaluation. A side is absent when it cannot be
|
|
1933
|
-
* edited: disabled (one-sided LP) or venue-priced (both sides absent).
|
|
1934
|
-
*/
|
|
1935
1990
|
/** One market the engine serves, as the operator's market list shows it. */
|
|
1936
1991
|
interface AdminStrategy {
|
|
1937
1992
|
/** Stable identifier for the API. */
|
|
@@ -1952,6 +2007,15 @@ interface HaltControl {
|
|
|
1952
2007
|
resetHalt(): void;
|
|
1953
2008
|
}
|
|
1954
2009
|
|
|
2010
|
+
/** What a limit order may pay out over its whole life, as the fill chain enforces it. */
|
|
2011
|
+
interface LimitOrderBudget {
|
|
2012
|
+
budgetId: HexString;
|
|
2013
|
+
/** The order's whole size in the output token's own units. */
|
|
2014
|
+
cap: bigint;
|
|
2015
|
+
/** The token the order pays on its fill chain. */
|
|
2016
|
+
token: HexString;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
1955
2019
|
interface SwapCall {
|
|
1956
2020
|
to: string;
|
|
1957
2021
|
data: string;
|
|
@@ -1983,6 +2047,8 @@ interface BidPlan {
|
|
|
1983
2047
|
fundingCalls: ERC7821Call[];
|
|
1984
2048
|
partialFill: boolean;
|
|
1985
2049
|
profit: number;
|
|
2050
|
+
/** That limit order's budget, which the bid settles against on the fill chain. */
|
|
2051
|
+
budget?: LimitOrderBudget;
|
|
1986
2052
|
}
|
|
1987
2053
|
declare class CacheService {
|
|
1988
2054
|
private cacheData;
|
|
@@ -2017,13 +2083,21 @@ declare class CacheService {
|
|
|
2017
2083
|
token: HexString;
|
|
2018
2084
|
amount: bigint;
|
|
2019
2085
|
}[] | null;
|
|
2086
|
+
/**
|
|
2087
|
+
* The budget of the limit order that priced the outputs cached for this order, or
|
|
2088
|
+
* null when no limit order did.
|
|
2089
|
+
*
|
|
2090
|
+
* Kept on the same entry as the outputs, so the two are replaced and expire
|
|
2091
|
+
* together: a bid can never sign one limit order's payout beside another's budget.
|
|
2092
|
+
*/
|
|
2093
|
+
getBidBudget(orderId: string): LimitOrderBudget | null;
|
|
2020
2094
|
setFillerOutputs(orderId: string, outputs: {
|
|
2021
2095
|
token: HexString;
|
|
2022
2096
|
amount: bigint;
|
|
2023
2097
|
}[], inputs?: {
|
|
2024
2098
|
token: HexString;
|
|
2025
2099
|
amount: bigint;
|
|
2026
|
-
}[]): void;
|
|
2100
|
+
}[], budget?: LimitOrderBudget): void;
|
|
2027
2101
|
/**
|
|
2028
2102
|
* The limit order this order was priced against, and the payout it allowed.
|
|
2029
2103
|
*
|
|
@@ -2059,6 +2133,17 @@ declare class CacheService {
|
|
|
2059
2133
|
isPartialFill(orderId: string): boolean;
|
|
2060
2134
|
setPartialFill(orderId: string, partial: boolean): void;
|
|
2061
2135
|
clearPartialFill(orderId: string): void;
|
|
2136
|
+
/**
|
|
2137
|
+
* Whether the strategy's completed evaluation let a bid through without holding
|
|
2138
|
+
* `order.fees` to the execution cost, because the order is at or above the
|
|
2139
|
+
* operator's minimum size.
|
|
2140
|
+
*
|
|
2141
|
+
* Written and cleared the way {@link isPartialFill} is, for the same reason: the
|
|
2142
|
+
* caller exempts such an order from its profit floor.
|
|
2143
|
+
*/
|
|
2144
|
+
isFeeCheckWaived(orderId: string): boolean;
|
|
2145
|
+
setFeeCheckWaived(orderId: string, waived: boolean): void;
|
|
2146
|
+
clearFeeCheckWaived(orderId: string): void;
|
|
2062
2147
|
getFeeTokenWithDecimals(chain: string): {
|
|
2063
2148
|
address: HexString;
|
|
2064
2149
|
decimals: number;
|
|
@@ -2070,6 +2155,12 @@ declare class CacheService {
|
|
|
2070
2155
|
setSolverSelection(chain: string, active: boolean): void;
|
|
2071
2156
|
}
|
|
2072
2157
|
|
|
2158
|
+
/** What a bid's batch needs to settle its limit order's budget. */
|
|
2159
|
+
interface BudgetSettlement {
|
|
2160
|
+
budget: LimitOrderBudget;
|
|
2161
|
+
/** The solver's account, which is the only caller `debitOrder` accepts. */
|
|
2162
|
+
solverAccount: HexString;
|
|
2163
|
+
}
|
|
2073
2164
|
declare class ContractInteractionService {
|
|
2074
2165
|
private clientManager;
|
|
2075
2166
|
private configService;
|
|
@@ -2113,13 +2204,14 @@ declare class ContractInteractionService {
|
|
|
2113
2204
|
}>;
|
|
2114
2205
|
/**
|
|
2115
2206
|
* The call gas a bid needs: the shared estimate plus room for the funding calls
|
|
2116
|
-
* this bid prepends.
|
|
2207
|
+
* this bid prepends and for settling its limit order's budget.
|
|
2117
2208
|
*
|
|
2118
2209
|
* Funding calls are not simulated (the V4 PositionManager's flash accounting does
|
|
2119
2210
|
* not resolve in the bundler's estimation context), so each one adds a fixed
|
|
2120
2211
|
* allowance for its modifyLiquidities + take. They differ between the bids on one
|
|
2121
2212
|
* order, since each draws on its own limit order and so on its own funding, which
|
|
2122
2213
|
* is why this is worked out per bid rather than baked into the cached estimate.
|
|
2214
|
+
* The estimate is of a lone fillOrder, so the budget call is not in it either.
|
|
2123
2215
|
*/
|
|
2124
2216
|
private callGasLimitFor;
|
|
2125
2217
|
/**
|
|
@@ -2163,6 +2255,15 @@ declare class ContractInteractionService {
|
|
|
2163
2255
|
*/
|
|
2164
2256
|
/** What `holder` holds of an ERC-20 on `chain`, in the token's own units. */
|
|
2165
2257
|
getTokenBalance(chain: string, token: HexString, holder: HexString): Promise<bigint>;
|
|
2258
|
+
/**
|
|
2259
|
+
* What the solver's account has tallied against a limit order's budget on `chain`, in
|
|
2260
|
+
* the paid token's own units, or null when it cannot be read.
|
|
2261
|
+
*
|
|
2262
|
+
* Null rather than a throw: an account whose implementation keeps no tally answers
|
|
2263
|
+
* with a revert or with no data, and the caller carries on without the figure either
|
|
2264
|
+
* way. Not retried, since that answer does not change on a second ask.
|
|
2265
|
+
*/
|
|
2266
|
+
limitOrderSpent(chain: string, budgetId: HexString): Promise<bigint | null>;
|
|
2166
2267
|
getSolverEntryPointBalance(chain: string): Promise<bigint>;
|
|
2167
2268
|
/**
|
|
2168
2269
|
* Deposits native tokens to the ERC-4337 EntryPoint on behalf of the solver account.
|
|
@@ -2275,8 +2376,13 @@ declare class ContractInteractionService {
|
|
|
2275
2376
|
* Same-chain fills release escrow locally with no Hyperbridge dispatch, so the
|
|
2276
2377
|
* gateway never pulls the fee token — its approval is skipped. Only cross-chain
|
|
2277
2378
|
* fills, which dispatch a RedeemEscrow message paid in the fee token, need it.
|
|
2379
|
+
*
|
|
2380
|
+
* A bid priced by a limit order ends with `debitOrder`, which takes the budget's id
|
|
2381
|
+
* as its `orderId`, works out what the fill paid from what is left of the allowance
|
|
2382
|
+
* and reverts the whole batch if the order's payouts would pass its size. It has to
|
|
2383
|
+
* come last, after the gateway has drawn on the allowance.
|
|
2278
2384
|
*/
|
|
2279
|
-
buildApprovalAndFillCalldata(order: Order, fillerOutputs: TokenInfo[], fillOptions: FillOptions, requiredFeeTokenAmount: bigint): Promise<HexString>;
|
|
2385
|
+
buildApprovalAndFillCalldata(order: Order, fillerOutputs: TokenInfo[], fillOptions: FillOptions, requiredFeeTokenAmount: bigint, settlement?: BudgetSettlement): Promise<HexString>;
|
|
2280
2386
|
}
|
|
2281
2387
|
|
|
2282
2388
|
/**
|
|
@@ -2775,12 +2881,18 @@ declare class OrderbookClient {
|
|
|
2775
2881
|
private request;
|
|
2776
2882
|
}
|
|
2777
2883
|
|
|
2884
|
+
/**
|
|
2885
|
+
* An operator error: the request itself is wrong, and retrying it unchanged will
|
|
2886
|
+
* fail the same way. The HTTP layer turns these into a 400.
|
|
2887
|
+
*/
|
|
2888
|
+
declare class LimitOrderValidationError extends Error {
|
|
2889
|
+
}
|
|
2778
2890
|
/**
|
|
2779
2891
|
* One limit order as the operator states it: what simplex takes in, and what it
|
|
2780
2892
|
* pays out for that.
|
|
2781
2893
|
*
|
|
2782
|
-
* "10000 USDC for
|
|
2783
|
-
* tokenOut: "CNGN", amountOut:
|
|
2894
|
+
* "10000 USDC for 15500000 CNGN" is `tokenIn: "USDC", amountIn: "10000",
|
|
2895
|
+
* tokenOut: "CNGN", amountOut: "15500000"`, in whole tokens. The rate and the side of the book
|
|
2784
2896
|
* follow from those, so the order is directional by construction: it prices
|
|
2785
2897
|
* USDC to CNGN swaps and never the reverse.
|
|
2786
2898
|
*/
|
|
@@ -3021,6 +3133,21 @@ declare class LimitOrderService {
|
|
|
3021
3133
|
* down because the solver cannot cover what it quoted.
|
|
3022
3134
|
*/
|
|
3023
3135
|
reconcile(now?: Date): Promise<ReconcileReport>;
|
|
3136
|
+
/**
|
|
3137
|
+
* Lowers every open order's `remaining` to what the solver's account will still
|
|
3138
|
+
* pay for it, and puts the order back on the book at that size.
|
|
3139
|
+
*
|
|
3140
|
+
* The account tallies each order's payouts on the fill chain and refuses a fill
|
|
3141
|
+
* that would take the tally past the order's size. A fill that never settled
|
|
3142
|
+
* here, or a store restored from an older copy, leaves `remaining` above that
|
|
3143
|
+
* room and the order posted at a size the account will refuse. A tally behind
|
|
3144
|
+
* the store changes nothing: `remaining` is never raised.
|
|
3145
|
+
*
|
|
3146
|
+
* Answers how many orders were lowered.
|
|
3147
|
+
*/
|
|
3148
|
+
reconcileTallies(): Promise<number>;
|
|
3149
|
+
/** The order as the store now holds it when its tally lowered it, null when it was left alone. */
|
|
3150
|
+
private clampToTally;
|
|
3024
3151
|
/**
|
|
3025
3152
|
* Withdraws every order that has outlived the operator's own `expiresAt`.
|
|
3026
3153
|
*
|
|
@@ -3131,6 +3258,13 @@ declare class IntentFiller {
|
|
|
3131
3258
|
*/
|
|
3132
3259
|
/** Hands the filler the service that keeps the orderbook in step with a fill. */
|
|
3133
3260
|
setLimitOrderService(service: LimitOrderService): void;
|
|
3261
|
+
/**
|
|
3262
|
+
* Brings the limit orders' `remaining` in line with their on-chain tallies.
|
|
3263
|
+
*
|
|
3264
|
+
* On the settlement queue, so the pass and a fill never resize the same order at
|
|
3265
|
+
* once. Resolves when the pass has run.
|
|
3266
|
+
*/
|
|
3267
|
+
reconcileLimitOrderTallies(): Promise<void>;
|
|
3134
3268
|
/** Whether the given chain id is configured for watch-only (monitor, never fill). */
|
|
3135
3269
|
private isChainWatchOnly;
|
|
3136
3270
|
/**
|
|
@@ -3217,6 +3351,13 @@ declare class IntentFiller {
|
|
|
3217
3351
|
private verifyOrderOnSource;
|
|
3218
3352
|
private handleNewOrder;
|
|
3219
3353
|
private evaluateOrder;
|
|
3354
|
+
/**
|
|
3355
|
+
* The destination chain's latest block number, the clock `order.deadline` is read on.
|
|
3356
|
+
*
|
|
3357
|
+
* Null when the read fails. That is not an answer about the order, so evaluation goes
|
|
3358
|
+
* on: the gas estimate simulates the same deadline check and refuses an expired order.
|
|
3359
|
+
*/
|
|
3360
|
+
private destinationHead;
|
|
3220
3361
|
/**
|
|
3221
3362
|
* Whether the strategy's evaluation concluded in a deliberate partial fill.
|
|
3222
3363
|
*
|
|
@@ -3227,6 +3368,12 @@ declare class IntentFiller {
|
|
|
3227
3368
|
* and filled them.
|
|
3228
3369
|
*/
|
|
3229
3370
|
private fillsPartially;
|
|
3371
|
+
/**
|
|
3372
|
+
* Whether the strategy's evaluation let a bid through without the fee check, because
|
|
3373
|
+
* the order is at or above the operator's minimum size. Read from a flag the strategy
|
|
3374
|
+
* sets only once it has an answer, as {@link fillsPartially} is.
|
|
3375
|
+
*/
|
|
3376
|
+
private feeCheckWaived;
|
|
3230
3377
|
private executeOrder;
|
|
3231
3378
|
private handleOrderFilledOnChain;
|
|
3232
3379
|
/**
|
|
@@ -3275,8 +3422,8 @@ declare class IntentFiller {
|
|
|
3275
3422
|
*/
|
|
3276
3423
|
private claimExecutedBid;
|
|
3277
3424
|
/**
|
|
3278
|
-
* What this fill delivered of the token the limit order pays,
|
|
3279
|
-
*
|
|
3425
|
+
* What this fill delivered of the token the limit order pays, or null when the
|
|
3426
|
+
* fill names none of it.
|
|
3280
3427
|
*/
|
|
3281
3428
|
private deliveredAgainst;
|
|
3282
3429
|
/**
|
|
@@ -3321,48 +3468,47 @@ interface TradingPair {
|
|
|
3321
3468
|
token1: string;
|
|
3322
3469
|
}
|
|
3323
3470
|
/**
|
|
3324
|
-
* Strategy for swaps
|
|
3325
|
-
*
|
|
3326
|
-
* orders.
|
|
3471
|
+
* Strategy for swaps priced by the operator's limit orders. Supports both
|
|
3472
|
+
* same-chain and cross-chain orders.
|
|
3327
3473
|
*
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3330
|
-
*
|
|
3331
|
-
*
|
|
3332
|
-
*
|
|
3333
|
-
*
|
|
3334
|
-
*
|
|
3474
|
+
* Every leg is matched against the open limit orders (`matchLimitOrders`): an
|
|
3475
|
+
* order serves a leg when it fills on the destination chain, takes the leg's
|
|
3476
|
+
* input, pays out its output, accepts its source chain and, at its own rate,
|
|
3477
|
+
* pays at least what the swapper asked for. Each matching order gets its own
|
|
3478
|
+
* bid, best offer first, sized `min(offer, remaining)`; there is no fallback
|
|
3479
|
+
* price, so a leg nothing matches is not bid on. No external price feed is
|
|
3480
|
+
* consulted. Confirmation sizing is the only place a dollar value is needed,
|
|
3481
|
+
* and it is derived from the limit orders' own rates (see `usdFactorsFrom`).
|
|
3335
3482
|
*
|
|
3336
|
-
*
|
|
3337
|
-
* the
|
|
3338
|
-
*
|
|
3339
|
-
* - input = token1, output = token0 → the filler *buys* token1 at the bid.
|
|
3483
|
+
* Payouts are bounded by the filler's real balances plus funding-venue
|
|
3484
|
+
* withdrawals. Because the IntentGateway releases inputs proportionally to the
|
|
3485
|
+
* fraction of outputs provided, partial fills need no extra on-chain logic.
|
|
3340
3486
|
*
|
|
3341
|
-
*
|
|
3342
|
-
*
|
|
3343
|
-
* leg with its pair's curve (or venue), and bounds outputs by the filler's
|
|
3344
|
-
* real balances plus funding-venue withdrawals. Because the IntentGateway
|
|
3345
|
-
* releases inputs proportionally to the fraction of outputs provided, partial
|
|
3346
|
-
* fills (and overfills) need no extra on-chain logic.
|
|
3487
|
+
* `[[pairs]]` markets do not gate matching; they name the markets the operator
|
|
3488
|
+
* dashboard lists.
|
|
3347
3489
|
*/
|
|
3348
3490
|
declare class FXFiller implements FillerStrategy {
|
|
3349
3491
|
name: string;
|
|
3350
3492
|
private clientManager;
|
|
3351
3493
|
private contractService;
|
|
3352
3494
|
private configService;
|
|
3353
|
-
/**
|
|
3495
|
+
/** Markets the dashboard lists. Informational only: matching reads the limit orders. */
|
|
3354
3496
|
private pairs;
|
|
3355
3497
|
/** Symbol → per-chain address resolution (built-ins + curated + user `[assets]`). */
|
|
3356
3498
|
private registry;
|
|
3357
3499
|
private signer;
|
|
3358
3500
|
private logger;
|
|
3359
|
-
/**
|
|
3501
|
+
/**
|
|
3502
|
+
* Consecutive orders where the overfill clamp activated. Dormant: the clamp
|
|
3503
|
+
* existed for venue-priced legs, which went with Uniswap V4 pricing, so every
|
|
3504
|
+
* outcome is now recorded unclamped and this never climbs. See `recordOrderOutcome`.
|
|
3505
|
+
*/
|
|
3360
3506
|
private consecutiveClamps;
|
|
3361
|
-
/** Once set, the filler refuses all orders until
|
|
3507
|
+
/** Once set, the filler refuses all orders until reset. Unreachable while the clamp is dormant. */
|
|
3362
3508
|
private halted;
|
|
3363
|
-
/**
|
|
3509
|
+
/** Bps above the swapper's ask past which a limit order's offer is logged as suspicious. Warn only. */
|
|
3364
3510
|
private readonly maxOverfillBps;
|
|
3365
|
-
/** Consecutive clamped evaluations before halting.
|
|
3511
|
+
/** Consecutive clamped evaluations before halting. Dormant, as `consecutiveClamps` is. */
|
|
3366
3512
|
private readonly maxConsecutiveClamps;
|
|
3367
3513
|
confirmationPolicy?: {
|
|
3368
3514
|
getConfirmationBlocks: (chainId: number, amountUsd: number) => number;
|
|
@@ -3395,10 +3541,9 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3395
3541
|
*/
|
|
3396
3542
|
addPair(pair: TradingPair): void;
|
|
3397
3543
|
/**
|
|
3398
|
-
* Removes a market from the running engine.
|
|
3399
|
-
*
|
|
3400
|
-
*
|
|
3401
|
-
* rechecks of orders on the removed pair simply stop matching.
|
|
3544
|
+
* Removes a market from the running engine. At least one market must remain.
|
|
3545
|
+
* Matching reads the limit orders rather than the pairs, so removing a market
|
|
3546
|
+
* changes what the dashboard lists, not what the filler fills.
|
|
3402
3547
|
*/
|
|
3403
3548
|
removePair(pair: TradingPair): void;
|
|
3404
3549
|
/**
|
|
@@ -3408,22 +3553,21 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3408
3553
|
initialise(): Promise<void>;
|
|
3409
3554
|
canFill(order: Order): Promise<boolean>;
|
|
3410
3555
|
/**
|
|
3411
|
-
* Evaluates whether an order is profitable to fill
|
|
3412
|
-
*
|
|
3556
|
+
* Evaluates whether an order is profitable to fill against the operator's
|
|
3557
|
+
* limit orders and the filler's current token balances.
|
|
3413
3558
|
*
|
|
3414
3559
|
* High-level flow:
|
|
3415
|
-
* -
|
|
3416
|
-
* -
|
|
3417
|
-
*
|
|
3418
|
-
*
|
|
3419
|
-
*
|
|
3420
|
-
*
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3423
|
-
*
|
|
3424
|
-
*
|
|
3425
|
-
*
|
|
3426
|
-
* outputs if the pair pricing makes that attractive. This is how we stay competitive.
|
|
3560
|
+
* - Match each (input, output) leg against the open limit orders.
|
|
3561
|
+
* - Build one bid per matching order, best offer first, each paying the
|
|
3562
|
+
* order's whole offer for the input at its own rate, capped by what the
|
|
3563
|
+
* order has left. The gateway credits the swapper the ask and splits
|
|
3564
|
+
* anything above it between the swapper and the protocol.
|
|
3565
|
+
* - Treat a payout below the ask as a partial fill, which only orders
|
|
3566
|
+
* without output calldata and without an earlier partial fill allow.
|
|
3567
|
+
* - Cap each payout by the filler's balance plus funding-venue withdrawals,
|
|
3568
|
+
* then gate it on fees (full fills of orders below `minOrderSizeUsd`) and the
|
|
3569
|
+
* same-asset spread.
|
|
3570
|
+
* - Cache the resulting bids for later use in `executeOrder`.
|
|
3427
3571
|
*/
|
|
3428
3572
|
calculateProfitability(order: Order): Promise<number>;
|
|
3429
3573
|
/**
|
|
@@ -3445,27 +3589,19 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3445
3589
|
private submitBid;
|
|
3446
3590
|
/**
|
|
3447
3591
|
* Update consecutive-clamp counter after a successful order evaluation.
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3592
|
+
*
|
|
3593
|
+
* Dormant. Only venue-priced legs ever fed a clamped outcome here: a streak
|
|
3594
|
+
* of those meant a live market source had gone off (stale pool, manipulated
|
|
3595
|
+
* venue). Venue pricing went with Uniswap V4, and limit orders are prices the
|
|
3596
|
+
* operator set, so the only caller records `false` and the filler never
|
|
3597
|
+
* halts. `isHalted`, `resetHalt` and `[simplex.overfillProtection]
|
|
3598
|
+
* maxConsecutiveClamps` are kept so existing configs and the halt API still
|
|
3599
|
+
* load; they can go once nothing reads them.
|
|
3452
3600
|
*/
|
|
3453
3601
|
private recordOrderOutcome;
|
|
3454
3602
|
isHalted(): boolean;
|
|
3455
3603
|
/** Operator acknowledgement after investigating a self-halt; resumes filling. */
|
|
3456
3604
|
resetHalt(): void;
|
|
3457
|
-
/**
|
|
3458
|
-
* Given a single (input, output) leg and the remaining token0 budget of its
|
|
3459
|
-
* pair, computes how much token0 notional to allocate to this leg and the
|
|
3460
|
-
* corresponding maximum output amount at the pair's rate.
|
|
3461
|
-
*
|
|
3462
|
-
* `rate` is **token1 per 1 token0**:
|
|
3463
|
-
* - token0 input → token1 output: token0 × rate → token1 amount.
|
|
3464
|
-
* - token1 input → token0 output: token1 ÷ rate → token0 amount.
|
|
3465
|
-
*
|
|
3466
|
-
* Returns `null` when this leg cannot consume any of the pair's remaining
|
|
3467
|
-
* budget (e.g. the cap has already been exhausted).
|
|
3468
|
-
*/
|
|
3469
3605
|
/**
|
|
3470
3606
|
* Whether any solver has already delivered output against this order.
|
|
3471
3607
|
*
|
|
@@ -3659,7 +3795,8 @@ interface SimplexOptions {
|
|
|
3659
3795
|
* transaction it sends. Required unless every chain is watch-only.
|
|
3660
3796
|
*
|
|
3661
3797
|
* {@link Signer} is an interface, not a menu: `privateKeySigner`,
|
|
3662
|
-
* `turnkeySigner` and `mpcVaultSigner` are the
|
|
3798
|
+
* `secretPhraseSigner`, `turnkeySigner` and `mpcVaultSigner` are the
|
|
3799
|
+
* implementations that ship here,
|
|
3663
3800
|
* `viemSigner` adapts any viem account (a `toAccount` wrapper around an HSM or
|
|
3664
3801
|
* a remote signing service included), and anything else that satisfies the
|
|
3665
3802
|
* interface works the same way.
|
|
@@ -3775,12 +3912,20 @@ interface SimplexEvents {
|
|
|
3775
3912
|
"limit-order:cancelled": {
|
|
3776
3913
|
order: LimitOrder;
|
|
3777
3914
|
};
|
|
3778
|
-
/**
|
|
3915
|
+
/**
|
|
3916
|
+
* The order was worked down and went back on the book at its new size. A fill does
|
|
3917
|
+
* this, and so does a correction to the solver account's on-chain tally, for which
|
|
3918
|
+
* no fill is recorded. `delivered` is what the order went down by either way.
|
|
3919
|
+
*/
|
|
3779
3920
|
"limit-order:resized": {
|
|
3780
3921
|
order: LimitOrder;
|
|
3781
3922
|
delivered: string;
|
|
3782
3923
|
};
|
|
3783
|
-
/**
|
|
3924
|
+
/**
|
|
3925
|
+
* The order went under the orderbook's dust floor, so it is done. A fill takes it
|
|
3926
|
+
* there, and so does a correction to the solver account's on-chain tally, for which
|
|
3927
|
+
* no fill is recorded.
|
|
3928
|
+
*/
|
|
3784
3929
|
"limit-order:filled": {
|
|
3785
3930
|
order: LimitOrder;
|
|
3786
3931
|
};
|
|
@@ -4146,7 +4291,8 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4146
4291
|
* back from its own endpoints, which also proves they answer for one chain
|
|
4147
4292
|
* before a filler ever depends on them.
|
|
4148
4293
|
*
|
|
4149
|
-
* @throws if an endpoint set is invalid
|
|
4294
|
+
* @throws if an endpoint set is invalid, if none of a chain's endpoints answer,
|
|
4295
|
+
* if its endpoints disagree on the chain, if two entries resolve
|
|
4150
4296
|
* to the same chain, or if `scanIntervalSecs` is below the minimum.
|
|
4151
4297
|
*/
|
|
4152
4298
|
static create(options: OrderScannerOptions): Promise<OrderScanner>;
|
|
@@ -4174,4 +4320,4 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4174
4320
|
private closeNow;
|
|
4175
4321
|
}
|
|
4176
4322
|
|
|
4177
|
-
export { ActivityEvent, ActivityInsert, ActivityStore, type AllowlistConfig, type AssetBalanceRow, AssetController, type AssetDefinition, type AuthorizationRequest, type BalanceIssue, type BalanceSnapshot, BidStats, BidStore, type BinanceConfig, type ChainBalanceRow, type ChainConfirmationPolicy, ChainController, type ChainInput, type ChainView, type CurveConfig, type CurvePoint, type Eip7702Authorization$1 as Eip7702Authorization, type FillerConfigFile, type FillerTomlConfig, type HyperbridgeBalance, LogLevel, LogSink, Logger, LoggerContext, MemoryDataStore, type MpcVaultSignerConfig, OrderScanner, type OrderScanner$1 as OrderScannerContract, type OrderScannerHandlers, type OrderScannerOptions, type PairConfig, PairController, type PairView, type PrivateKeySignerConfig, type QueueConfig, RebalanceController, type RebalancingConfig, type ResolvedChainConfig, type ScannedFill, type ScannedOrder, type ScannerChainConfig, 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, createSigner, digestSigner, formatChainKey, isRegistrySymbol, mpcVaultSigner, normalizeSymbol, parseChainKey, pickAnchorStable, privateKeySigner, registrySymbols, turnkeySigner, validateAssetDefinitions, validateConfig, validatePairConfigs, validateSignerConfig, validateVaultToml, viemSigner };
|
|
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 };
|