@hyperbridge/simplex 0.16.7 → 0.16.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -14
- package/dist/bin/simplex.js +23907 -2147
- 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 +644 -340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +205 -104
- package/dist/index.d.ts +205 -104
- package/dist/index.js +515 -216
- package/dist/index.js.map +1 -1
- package/dist/sqlite.cjs +13 -1
- 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 +13 -1
- package/dist/sqlite.js.map +1 -1
- package/dist/{types-DUDABLPI.d.cts → types-B5zkFhxR.d.cts} +17 -5
- package/dist/{types-DUDABLPI.d.ts → types-B5zkFhxR.d.ts} +17 -5
- package/dist/ui/assets/{index-C3T-gubp.css → index-B_p2oQkc.css} +1 -1
- package/dist/ui/assets/{index-Be446eYK.js → index-CD2NZXpG.js} +35 -35
- package/dist/ui/index.html +2 -2
- package/package.json +13 -2
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';
|
|
@@ -546,7 +546,8 @@ interface MpcVaultSignerConfig {
|
|
|
546
546
|
declare enum SignerType {
|
|
547
547
|
PrivateKey = "privateKey",
|
|
548
548
|
MpcVault = "mpcVault",
|
|
549
|
-
Turnkey = "turnkey"
|
|
549
|
+
Turnkey = "turnkey",
|
|
550
|
+
SecretPhrase = "secretPhrase"
|
|
550
551
|
}
|
|
551
552
|
interface TurnkeySignerConfig {
|
|
552
553
|
organizationId: string;
|
|
@@ -557,6 +558,15 @@ interface TurnkeySignerConfig {
|
|
|
557
558
|
interface PrivateKeySignerConfig {
|
|
558
559
|
key: HexString;
|
|
559
560
|
}
|
|
561
|
+
interface SecretPhraseSignerConfig {
|
|
562
|
+
/** BIP-39 mnemonic from the English wordlist. */
|
|
563
|
+
phrase: string;
|
|
564
|
+
/**
|
|
565
|
+
* Which wallet under the phrase is the hot wallet: the last component of
|
|
566
|
+
* `m/44'/60'/0'/0/i`. Defaults to 0.
|
|
567
|
+
*/
|
|
568
|
+
accountIndex?: number;
|
|
569
|
+
}
|
|
560
570
|
/**
|
|
561
571
|
* The `[simplex.signer]` block of the TOML file the binary reads — a tagged
|
|
562
572
|
* union over the bundled backends. `createSigner` turns one into a {@link Signer};
|
|
@@ -568,7 +578,9 @@ type SignerConfig = ({
|
|
|
568
578
|
type: SignerType.MpcVault;
|
|
569
579
|
} & MpcVaultSignerConfig) | ({
|
|
570
580
|
type: SignerType.Turnkey;
|
|
571
|
-
} & TurnkeySignerConfig)
|
|
581
|
+
} & TurnkeySignerConfig) | ({
|
|
582
|
+
type: SignerType.SecretPhrase;
|
|
583
|
+
} & SecretPhraseSignerConfig);
|
|
572
584
|
/**
|
|
573
585
|
* A secp256k1 signature in split form, which is how EIP-7702 and raw digests
|
|
574
586
|
* consume it: `r` and `s` as 32-byte 0x-hex, and `yParity` strictly 0 or 1.
|
|
@@ -682,6 +694,16 @@ interface Signer {
|
|
|
682
694
|
*/
|
|
683
695
|
signTransaction(tx: SignerTransaction): Promise<HexString>;
|
|
684
696
|
}
|
|
697
|
+
/**
|
|
698
|
+
* A {@link Signer} backed by a key tree rather than a single key, so it can hand
|
|
699
|
+
* out signers for sibling wallets.
|
|
700
|
+
*/
|
|
701
|
+
interface DerivingSigner extends Signer {
|
|
702
|
+
/** Index of the wallet this signer itself signs with. */
|
|
703
|
+
readonly accountIndex: number;
|
|
704
|
+
/** The signer for the wallet at `index`, which may be this signer's own. */
|
|
705
|
+
derive(index: number): Signer;
|
|
706
|
+
}
|
|
685
707
|
/** The tuple an EIP-7702 authorization signature covers. */
|
|
686
708
|
interface AuthorizationRequest {
|
|
687
709
|
chainId: number;
|
|
@@ -745,6 +767,19 @@ declare function viemSigner(account: LocalAccount): Signer;
|
|
|
745
767
|
*/
|
|
746
768
|
declare function privateKeySigner(privateKey: HexString): Signer;
|
|
747
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Throws unless the phrase is a BIP-39 mnemonic from the English wordlist with a
|
|
772
|
+
* matching checksum. The errors name what is wrong and never quote the phrase.
|
|
773
|
+
*/
|
|
774
|
+
declare function validateSecretPhrase(phrase: string): void;
|
|
775
|
+
/**
|
|
776
|
+
* Signs with wallets derived from a BIP-39 phrase held in this process. The
|
|
777
|
+
* hot wallet is `m/44'/60'/0'/0/accountIndex`, and `derive` returns the signer
|
|
778
|
+
* for any sibling under the same parent.
|
|
779
|
+
*/
|
|
780
|
+
declare function secretPhraseSigner(config: SecretPhraseSignerConfig): DerivingSigner;
|
|
781
|
+
declare function canDerive(signer: Signer): signer is DerivingSigner;
|
|
782
|
+
|
|
748
783
|
/**
|
|
749
784
|
* Signs through MPCVault's signing ceremony.
|
|
750
785
|
*
|
|
@@ -1350,10 +1385,9 @@ interface BuiltinAssetResolver {
|
|
|
1350
1385
|
getAssetBySymbol(chain: string, symbol: string): HexString | undefined;
|
|
1351
1386
|
}
|
|
1352
1387
|
/**
|
|
1353
|
-
* Symbols pegged to 1 USD. They
|
|
1354
|
-
* from
|
|
1355
|
-
*
|
|
1356
|
-
* pricing never uses this as a price.
|
|
1388
|
+
* Symbols pegged to 1 USD. They are pinned at $1 when an order's USD value is
|
|
1389
|
+
* derived from the limit orders' rates (see `usdFactorsFrom`), which is what
|
|
1390
|
+
* sizes confirmation depth. Trade pricing never uses this as a price.
|
|
1357
1391
|
*/
|
|
1358
1392
|
declare const USD_STABLE_SYMBOLS: ReadonlySet<string>;
|
|
1359
1393
|
/** Normalises a symbol for lookups: trimmed, uppercased. "cNGN" ≡ "CNGN". */
|
|
@@ -1419,22 +1453,24 @@ declare class AssetRegistry {
|
|
|
1419
1453
|
*
|
|
1420
1454
|
* ```toml
|
|
1421
1455
|
* [[pairs]]
|
|
1422
|
-
* token0 = "USDC" #
|
|
1423
|
-
* token1 = "CNGN" #
|
|
1456
|
+
* token0 = "USDC" # the book's base — any symbol in the asset registry
|
|
1457
|
+
* token1 = "CNGN" # the book's quote — any symbol in the asset registry
|
|
1424
1458
|
* ```
|
|
1425
1459
|
*
|
|
1426
1460
|
* A pair declares that a market exists and nothing more. What the filler will
|
|
1427
1461
|
* pay on it comes from the operator's limit orders, which carry the rate and the
|
|
1428
1462
|
* size they are good for.
|
|
1429
1463
|
*
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1464
|
+
* The orientation follows the orderbook's books, which the setup wizard copies:
|
|
1465
|
+
* `token0` is the book's base and `token1` its quote, so the `USDC-cNGN` book
|
|
1466
|
+
* (priced in cNGN per USDC) becomes `token0 = "USDC"`, `token1 = "CNGN"`. One
|
|
1467
|
+
* orientation only: `A/B` and `B/A` are the same market and declaring both is
|
|
1468
|
+
* refused. `token0 == token1` is the same-asset cross-chain market.
|
|
1433
1469
|
*/
|
|
1434
1470
|
interface PairConfig {
|
|
1435
|
-
/**
|
|
1471
|
+
/** The book's base symbol (e.g. "USDC", "USDT"). Any symbol in the registry. */
|
|
1436
1472
|
token0: string;
|
|
1437
|
-
/**
|
|
1473
|
+
/** The book's quote symbol, which the book prices the base in (e.g. "CNGN"). Any symbol in the registry. */
|
|
1438
1474
|
token1: string;
|
|
1439
1475
|
}
|
|
1440
1476
|
/**
|
|
@@ -1709,18 +1745,21 @@ interface FillerTomlConfig {
|
|
|
1709
1745
|
*/
|
|
1710
1746
|
assets?: Record<string, AssetDefinition>;
|
|
1711
1747
|
/**
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1748
|
+
* Markets the operator dashboard lists, as `token0`/`token1` symbol pairs.
|
|
1749
|
+
* They carry no prices and do not gate matching: the filler prices every
|
|
1750
|
+
* fill from the operator's limit orders. Optional; the browser setup wizard
|
|
1751
|
+
* writes one per book the orderbook lists. Keys left over from the curve
|
|
1752
|
+
* era (`bidPriceCurve`, `askPriceCurve`, `maxOrderSize`, `referenceOnly`)
|
|
1753
|
+
* are ignored.
|
|
1716
1754
|
*/
|
|
1717
1755
|
pairs?: PairConfig[];
|
|
1718
1756
|
/**
|
|
1719
1757
|
* Per-chain confirmation policies for cross-chain orders, keyed by chain id.
|
|
1720
1758
|
* Merged over built-in defaults (ETH, BSC, Polygon, Base, Arbitrum,
|
|
1721
1759
|
* Unichain); every configured chain must be covered or startup fails. The
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
1760
|
+
* policy's amount axis is the order's USD value: USD stables count at $1 and
|
|
1761
|
+
* other tokens are valued through the open limit orders' rates. An order no
|
|
1762
|
+
* limit order connects to a dollar waits for the policy's maximum depth.
|
|
1724
1763
|
*/
|
|
1725
1764
|
confirmationPolicies?: Record<string, ChainConfirmationPolicy>;
|
|
1726
1765
|
simplex: {
|
|
@@ -1762,8 +1801,10 @@ interface FillerTomlConfig {
|
|
|
1762
1801
|
};
|
|
1763
1802
|
/**
|
|
1764
1803
|
* Overfill protection knobs. Defaults: maxOverfillBps=500, maxConsecutiveClamps=3.
|
|
1765
|
-
* `maxOverfillBps`
|
|
1766
|
-
*
|
|
1804
|
+
* `maxOverfillBps` is warn-only: FXFiller logs a limit order whose offer exceeds
|
|
1805
|
+
* the swapper's ask by more than this, and clamps nothing. `maxConsecutiveClamps`
|
|
1806
|
+
* is accepted but dormant: the clamp that fed it was for Uniswap V4 venue pricing,
|
|
1807
|
+
* which is gone, so FXFiller never halts.
|
|
1767
1808
|
*/
|
|
1768
1809
|
overfillProtection?: {
|
|
1769
1810
|
maxOverfillBps?: number;
|
|
@@ -1926,12 +1967,6 @@ declare class ActivityRecorder extends EventEmitter$1 {
|
|
|
1926
1967
|
walletTxs(limit?: number): Promise<WalletTx[]>;
|
|
1927
1968
|
}
|
|
1928
1969
|
|
|
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
1970
|
/** One market the engine serves, as the operator's market list shows it. */
|
|
1936
1971
|
interface AdminStrategy {
|
|
1937
1972
|
/** Stable identifier for the API. */
|
|
@@ -1952,6 +1987,15 @@ interface HaltControl {
|
|
|
1952
1987
|
resetHalt(): void;
|
|
1953
1988
|
}
|
|
1954
1989
|
|
|
1990
|
+
/** What a limit order may pay out over its whole life, as the fill chain enforces it. */
|
|
1991
|
+
interface LimitOrderBudget {
|
|
1992
|
+
budgetId: HexString;
|
|
1993
|
+
/** The order's whole size in the output token's own units. */
|
|
1994
|
+
cap: bigint;
|
|
1995
|
+
/** The token the order pays on its fill chain. */
|
|
1996
|
+
token: HexString;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1955
1999
|
interface SwapCall {
|
|
1956
2000
|
to: string;
|
|
1957
2001
|
data: string;
|
|
@@ -1983,6 +2027,8 @@ interface BidPlan {
|
|
|
1983
2027
|
fundingCalls: ERC7821Call[];
|
|
1984
2028
|
partialFill: boolean;
|
|
1985
2029
|
profit: number;
|
|
2030
|
+
/** That limit order's budget, which the bid settles against on the fill chain. */
|
|
2031
|
+
budget?: LimitOrderBudget;
|
|
1986
2032
|
}
|
|
1987
2033
|
declare class CacheService {
|
|
1988
2034
|
private cacheData;
|
|
@@ -2017,13 +2063,21 @@ declare class CacheService {
|
|
|
2017
2063
|
token: HexString;
|
|
2018
2064
|
amount: bigint;
|
|
2019
2065
|
}[] | null;
|
|
2066
|
+
/**
|
|
2067
|
+
* The budget of the limit order that priced the outputs cached for this order, or
|
|
2068
|
+
* null when no limit order did.
|
|
2069
|
+
*
|
|
2070
|
+
* Kept on the same entry as the outputs, so the two are replaced and expire
|
|
2071
|
+
* together: a bid can never sign one limit order's payout beside another's budget.
|
|
2072
|
+
*/
|
|
2073
|
+
getBidBudget(orderId: string): LimitOrderBudget | null;
|
|
2020
2074
|
setFillerOutputs(orderId: string, outputs: {
|
|
2021
2075
|
token: HexString;
|
|
2022
2076
|
amount: bigint;
|
|
2023
2077
|
}[], inputs?: {
|
|
2024
2078
|
token: HexString;
|
|
2025
2079
|
amount: bigint;
|
|
2026
|
-
}[]): void;
|
|
2080
|
+
}[], budget?: LimitOrderBudget): void;
|
|
2027
2081
|
/**
|
|
2028
2082
|
* The limit order this order was priced against, and the payout it allowed.
|
|
2029
2083
|
*
|
|
@@ -2070,6 +2124,12 @@ declare class CacheService {
|
|
|
2070
2124
|
setSolverSelection(chain: string, active: boolean): void;
|
|
2071
2125
|
}
|
|
2072
2126
|
|
|
2127
|
+
/** What a bid's batch needs to settle its limit order's budget. */
|
|
2128
|
+
interface BudgetSettlement {
|
|
2129
|
+
budget: LimitOrderBudget;
|
|
2130
|
+
/** The solver's account, which is the only caller `debitOrder` accepts. */
|
|
2131
|
+
solverAccount: HexString;
|
|
2132
|
+
}
|
|
2073
2133
|
declare class ContractInteractionService {
|
|
2074
2134
|
private clientManager;
|
|
2075
2135
|
private configService;
|
|
@@ -2113,13 +2173,14 @@ declare class ContractInteractionService {
|
|
|
2113
2173
|
}>;
|
|
2114
2174
|
/**
|
|
2115
2175
|
* The call gas a bid needs: the shared estimate plus room for the funding calls
|
|
2116
|
-
* this bid prepends.
|
|
2176
|
+
* this bid prepends and for settling its limit order's budget.
|
|
2117
2177
|
*
|
|
2118
2178
|
* Funding calls are not simulated (the V4 PositionManager's flash accounting does
|
|
2119
2179
|
* not resolve in the bundler's estimation context), so each one adds a fixed
|
|
2120
2180
|
* allowance for its modifyLiquidities + take. They differ between the bids on one
|
|
2121
2181
|
* order, since each draws on its own limit order and so on its own funding, which
|
|
2122
2182
|
* is why this is worked out per bid rather than baked into the cached estimate.
|
|
2183
|
+
* The estimate is of a lone fillOrder, so the budget call is not in it either.
|
|
2123
2184
|
*/
|
|
2124
2185
|
private callGasLimitFor;
|
|
2125
2186
|
/**
|
|
@@ -2163,6 +2224,15 @@ declare class ContractInteractionService {
|
|
|
2163
2224
|
*/
|
|
2164
2225
|
/** What `holder` holds of an ERC-20 on `chain`, in the token's own units. */
|
|
2165
2226
|
getTokenBalance(chain: string, token: HexString, holder: HexString): Promise<bigint>;
|
|
2227
|
+
/**
|
|
2228
|
+
* What the solver's account has tallied against a limit order's budget on `chain`, in
|
|
2229
|
+
* the paid token's own units, or null when it cannot be read.
|
|
2230
|
+
*
|
|
2231
|
+
* Null rather than a throw: an account whose implementation keeps no tally answers
|
|
2232
|
+
* with a revert or with no data, and the caller carries on without the figure either
|
|
2233
|
+
* way. Not retried, since that answer does not change on a second ask.
|
|
2234
|
+
*/
|
|
2235
|
+
limitOrderSpent(chain: string, budgetId: HexString): Promise<bigint | null>;
|
|
2166
2236
|
getSolverEntryPointBalance(chain: string): Promise<bigint>;
|
|
2167
2237
|
/**
|
|
2168
2238
|
* Deposits native tokens to the ERC-4337 EntryPoint on behalf of the solver account.
|
|
@@ -2275,8 +2345,13 @@ declare class ContractInteractionService {
|
|
|
2275
2345
|
* Same-chain fills release escrow locally with no Hyperbridge dispatch, so the
|
|
2276
2346
|
* gateway never pulls the fee token — its approval is skipped. Only cross-chain
|
|
2277
2347
|
* fills, which dispatch a RedeemEscrow message paid in the fee token, need it.
|
|
2348
|
+
*
|
|
2349
|
+
* A bid priced by a limit order ends with `debitOrder`, which takes the budget's id
|
|
2350
|
+
* as its `orderId`, works out what the fill paid from what is left of the allowance
|
|
2351
|
+
* and reverts the whole batch if the order's payouts would pass its size. It has to
|
|
2352
|
+
* come last, after the gateway has drawn on the allowance.
|
|
2278
2353
|
*/
|
|
2279
|
-
buildApprovalAndFillCalldata(order: Order, fillerOutputs: TokenInfo[], fillOptions: FillOptions, requiredFeeTokenAmount: bigint): Promise<HexString>;
|
|
2354
|
+
buildApprovalAndFillCalldata(order: Order, fillerOutputs: TokenInfo[], fillOptions: FillOptions, requiredFeeTokenAmount: bigint, settlement?: BudgetSettlement): Promise<HexString>;
|
|
2280
2355
|
}
|
|
2281
2356
|
|
|
2282
2357
|
/**
|
|
@@ -2775,12 +2850,18 @@ declare class OrderbookClient {
|
|
|
2775
2850
|
private request;
|
|
2776
2851
|
}
|
|
2777
2852
|
|
|
2853
|
+
/**
|
|
2854
|
+
* An operator error: the request itself is wrong, and retrying it unchanged will
|
|
2855
|
+
* fail the same way. The HTTP layer turns these into a 400.
|
|
2856
|
+
*/
|
|
2857
|
+
declare class LimitOrderValidationError extends Error {
|
|
2858
|
+
}
|
|
2778
2859
|
/**
|
|
2779
2860
|
* One limit order as the operator states it: what simplex takes in, and what it
|
|
2780
2861
|
* pays out for that.
|
|
2781
2862
|
*
|
|
2782
|
-
* "10000 USDC for
|
|
2783
|
-
* tokenOut: "CNGN", amountOut:
|
|
2863
|
+
* "10000 USDC for 15500000 CNGN" is `tokenIn: "USDC", amountIn: "10000",
|
|
2864
|
+
* tokenOut: "CNGN", amountOut: "15500000"`, in whole tokens. The rate and the side of the book
|
|
2784
2865
|
* follow from those, so the order is directional by construction: it prices
|
|
2785
2866
|
* USDC to CNGN swaps and never the reverse.
|
|
2786
2867
|
*/
|
|
@@ -3021,6 +3102,21 @@ declare class LimitOrderService {
|
|
|
3021
3102
|
* down because the solver cannot cover what it quoted.
|
|
3022
3103
|
*/
|
|
3023
3104
|
reconcile(now?: Date): Promise<ReconcileReport>;
|
|
3105
|
+
/**
|
|
3106
|
+
* Lowers every open order's `remaining` to what the solver's account will still
|
|
3107
|
+
* pay for it, and puts the order back on the book at that size.
|
|
3108
|
+
*
|
|
3109
|
+
* The account tallies each order's payouts on the fill chain and refuses a fill
|
|
3110
|
+
* that would take the tally past the order's size. A fill that never settled
|
|
3111
|
+
* here, or a store restored from an older copy, leaves `remaining` above that
|
|
3112
|
+
* room and the order posted at a size the account will refuse. A tally behind
|
|
3113
|
+
* the store changes nothing: `remaining` is never raised.
|
|
3114
|
+
*
|
|
3115
|
+
* Answers how many orders were lowered.
|
|
3116
|
+
*/
|
|
3117
|
+
reconcileTallies(): Promise<number>;
|
|
3118
|
+
/** The order as the store now holds it when its tally lowered it, null when it was left alone. */
|
|
3119
|
+
private clampToTally;
|
|
3024
3120
|
/**
|
|
3025
3121
|
* Withdraws every order that has outlived the operator's own `expiresAt`.
|
|
3026
3122
|
*
|
|
@@ -3131,6 +3227,13 @@ declare class IntentFiller {
|
|
|
3131
3227
|
*/
|
|
3132
3228
|
/** Hands the filler the service that keeps the orderbook in step with a fill. */
|
|
3133
3229
|
setLimitOrderService(service: LimitOrderService): void;
|
|
3230
|
+
/**
|
|
3231
|
+
* Brings the limit orders' `remaining` in line with their on-chain tallies.
|
|
3232
|
+
*
|
|
3233
|
+
* On the settlement queue, so the pass and a fill never resize the same order at
|
|
3234
|
+
* once. Resolves when the pass has run.
|
|
3235
|
+
*/
|
|
3236
|
+
reconcileLimitOrderTallies(): Promise<void>;
|
|
3134
3237
|
/** Whether the given chain id is configured for watch-only (monitor, never fill). */
|
|
3135
3238
|
private isChainWatchOnly;
|
|
3136
3239
|
/**
|
|
@@ -3275,8 +3378,8 @@ declare class IntentFiller {
|
|
|
3275
3378
|
*/
|
|
3276
3379
|
private claimExecutedBid;
|
|
3277
3380
|
/**
|
|
3278
|
-
* What this fill delivered of the token the limit order pays,
|
|
3279
|
-
*
|
|
3381
|
+
* What this fill delivered of the token the limit order pays, or null when the
|
|
3382
|
+
* fill names none of it.
|
|
3280
3383
|
*/
|
|
3281
3384
|
private deliveredAgainst;
|
|
3282
3385
|
/**
|
|
@@ -3321,48 +3424,47 @@ interface TradingPair {
|
|
|
3321
3424
|
token1: string;
|
|
3322
3425
|
}
|
|
3323
3426
|
/**
|
|
3324
|
-
* Strategy for swaps
|
|
3325
|
-
*
|
|
3326
|
-
* orders.
|
|
3427
|
+
* Strategy for swaps priced by the operator's limit orders. Supports both
|
|
3428
|
+
* same-chain and cross-chain orders.
|
|
3327
3429
|
*
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3330
|
-
*
|
|
3331
|
-
*
|
|
3332
|
-
*
|
|
3333
|
-
*
|
|
3334
|
-
*
|
|
3430
|
+
* Every leg is matched against the open limit orders (`matchLimitOrders`): an
|
|
3431
|
+
* order serves a leg when it fills on the destination chain, takes the leg's
|
|
3432
|
+
* input, pays out its output, accepts its source chain and, at its own rate,
|
|
3433
|
+
* pays at least what the swapper asked for. Each matching order gets its own
|
|
3434
|
+
* bid, best offer first, sized `min(offer, remaining)`; there is no fallback
|
|
3435
|
+
* price, so a leg nothing matches is not bid on. No external price feed is
|
|
3436
|
+
* consulted. Confirmation sizing is the only place a dollar value is needed,
|
|
3437
|
+
* and it is derived from the limit orders' own rates (see `usdFactorsFrom`).
|
|
3335
3438
|
*
|
|
3336
|
-
*
|
|
3337
|
-
* the
|
|
3338
|
-
*
|
|
3339
|
-
* - input = token1, output = token0 → the filler *buys* token1 at the bid.
|
|
3439
|
+
* Payouts are bounded by the filler's real balances plus funding-venue
|
|
3440
|
+
* withdrawals. Because the IntentGateway releases inputs proportionally to the
|
|
3441
|
+
* fraction of outputs provided, partial fills need no extra on-chain logic.
|
|
3340
3442
|
*
|
|
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.
|
|
3443
|
+
* `[[pairs]]` markets do not gate matching; they name the markets the operator
|
|
3444
|
+
* dashboard lists.
|
|
3347
3445
|
*/
|
|
3348
3446
|
declare class FXFiller implements FillerStrategy {
|
|
3349
3447
|
name: string;
|
|
3350
3448
|
private clientManager;
|
|
3351
3449
|
private contractService;
|
|
3352
3450
|
private configService;
|
|
3353
|
-
/**
|
|
3451
|
+
/** Markets the dashboard lists. Informational only: matching reads the limit orders. */
|
|
3354
3452
|
private pairs;
|
|
3355
3453
|
/** Symbol → per-chain address resolution (built-ins + curated + user `[assets]`). */
|
|
3356
3454
|
private registry;
|
|
3357
3455
|
private signer;
|
|
3358
3456
|
private logger;
|
|
3359
|
-
/**
|
|
3457
|
+
/**
|
|
3458
|
+
* Consecutive orders where the overfill clamp activated. Dormant: the clamp
|
|
3459
|
+
* existed for venue-priced legs, which went with Uniswap V4 pricing, so every
|
|
3460
|
+
* outcome is now recorded unclamped and this never climbs. See `recordOrderOutcome`.
|
|
3461
|
+
*/
|
|
3360
3462
|
private consecutiveClamps;
|
|
3361
|
-
/** Once set, the filler refuses all orders until
|
|
3463
|
+
/** Once set, the filler refuses all orders until reset. Unreachable while the clamp is dormant. */
|
|
3362
3464
|
private halted;
|
|
3363
|
-
/**
|
|
3465
|
+
/** Bps above the swapper's ask past which a limit order's offer is logged as suspicious. Warn only. */
|
|
3364
3466
|
private readonly maxOverfillBps;
|
|
3365
|
-
/** Consecutive clamped evaluations before halting.
|
|
3467
|
+
/** Consecutive clamped evaluations before halting. Dormant, as `consecutiveClamps` is. */
|
|
3366
3468
|
private readonly maxConsecutiveClamps;
|
|
3367
3469
|
confirmationPolicy?: {
|
|
3368
3470
|
getConfirmationBlocks: (chainId: number, amountUsd: number) => number;
|
|
@@ -3395,10 +3497,9 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3395
3497
|
*/
|
|
3396
3498
|
addPair(pair: TradingPair): void;
|
|
3397
3499
|
/**
|
|
3398
|
-
* Removes a market from the running engine.
|
|
3399
|
-
*
|
|
3400
|
-
*
|
|
3401
|
-
* rechecks of orders on the removed pair simply stop matching.
|
|
3500
|
+
* Removes a market from the running engine. At least one market must remain.
|
|
3501
|
+
* Matching reads the limit orders rather than the pairs, so removing a market
|
|
3502
|
+
* changes what the dashboard lists, not what the filler fills.
|
|
3402
3503
|
*/
|
|
3403
3504
|
removePair(pair: TradingPair): void;
|
|
3404
3505
|
/**
|
|
@@ -3408,22 +3509,20 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3408
3509
|
initialise(): Promise<void>;
|
|
3409
3510
|
canFill(order: Order): Promise<boolean>;
|
|
3410
3511
|
/**
|
|
3411
|
-
* Evaluates whether an order is profitable to fill
|
|
3412
|
-
*
|
|
3512
|
+
* Evaluates whether an order is profitable to fill against the operator's
|
|
3513
|
+
* limit orders and the filler's current token balances.
|
|
3413
3514
|
*
|
|
3414
3515
|
* High-level flow:
|
|
3415
|
-
* -
|
|
3416
|
-
* -
|
|
3417
|
-
*
|
|
3418
|
-
*
|
|
3419
|
-
*
|
|
3420
|
-
*
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3423
|
-
*
|
|
3424
|
-
*
|
|
3425
|
-
* Note: we may intentionally overfill relative to the user's requested
|
|
3426
|
-
* outputs if the pair pricing makes that attractive. This is how we stay competitive.
|
|
3516
|
+
* - Match each (input, output) leg against the open limit orders.
|
|
3517
|
+
* - Build one bid per matching order, best offer first, each paying the
|
|
3518
|
+
* order's whole offer for the input at its own rate, capped by what the
|
|
3519
|
+
* order has left. The gateway credits the swapper the ask and splits
|
|
3520
|
+
* anything above it between the swapper and the protocol.
|
|
3521
|
+
* - Treat a payout below the ask as a partial fill, which only orders
|
|
3522
|
+
* without output calldata and without an earlier partial fill allow.
|
|
3523
|
+
* - Cap each payout by the filler's balance plus funding-venue withdrawals,
|
|
3524
|
+
* then gate it on fees (full fills) and the same-asset spread.
|
|
3525
|
+
* - Cache the resulting bids for later use in `executeOrder`.
|
|
3427
3526
|
*/
|
|
3428
3527
|
calculateProfitability(order: Order): Promise<number>;
|
|
3429
3528
|
/**
|
|
@@ -3445,27 +3544,19 @@ declare class FXFiller implements FillerStrategy {
|
|
|
3445
3544
|
private submitBid;
|
|
3446
3545
|
/**
|
|
3447
3546
|
* Update consecutive-clamp counter after a successful order evaluation.
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3547
|
+
*
|
|
3548
|
+
* Dormant. Only venue-priced legs ever fed a clamped outcome here: a streak
|
|
3549
|
+
* of those meant a live market source had gone off (stale pool, manipulated
|
|
3550
|
+
* venue). Venue pricing went with Uniswap V4, and limit orders are prices the
|
|
3551
|
+
* operator set, so the only caller records `false` and the filler never
|
|
3552
|
+
* halts. `isHalted`, `resetHalt` and `[simplex.overfillProtection]
|
|
3553
|
+
* maxConsecutiveClamps` are kept so existing configs and the halt API still
|
|
3554
|
+
* load; they can go once nothing reads them.
|
|
3452
3555
|
*/
|
|
3453
3556
|
private recordOrderOutcome;
|
|
3454
3557
|
isHalted(): boolean;
|
|
3455
3558
|
/** Operator acknowledgement after investigating a self-halt; resumes filling. */
|
|
3456
3559
|
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
3560
|
/**
|
|
3470
3561
|
* Whether any solver has already delivered output against this order.
|
|
3471
3562
|
*
|
|
@@ -3617,17 +3708,17 @@ interface FillerRuntime {
|
|
|
3617
3708
|
*/
|
|
3618
3709
|
signerless: boolean;
|
|
3619
3710
|
/** The live confirmation policy the engine prices with; runtime chain adds install into it. */
|
|
3620
|
-
confirmationPolicy
|
|
3711
|
+
confirmationPolicy: ConfirmationPolicy;
|
|
3621
3712
|
/** This filler's logging destination. */
|
|
3622
3713
|
loggers: LoggerContext;
|
|
3623
3714
|
/** Symbol-to-address resolution for the configured chains (send options, balance labels). */
|
|
3624
3715
|
assetRegistry: AssetRegistry;
|
|
3625
3716
|
/** Creates and posts the operator's limit orders. */
|
|
3626
3717
|
limitOrders?: LimitOrderService;
|
|
3627
|
-
/** The live trading engine
|
|
3628
|
-
engine
|
|
3718
|
+
/** The live trading engine. It runs whether or not the config names any pairs. */
|
|
3719
|
+
engine: FXFiller;
|
|
3629
3720
|
/** The engine's live pair array (same instance), indexed 1:1 with config.pairs. */
|
|
3630
|
-
tradingPairs
|
|
3721
|
+
tradingPairs: TradingPair[];
|
|
3631
3722
|
/** BalanceProvider's live token1 map (chain name to exotic addresses); mutations apply on its next refresh. */
|
|
3632
3723
|
balanceTokens: Record<string, string[]>;
|
|
3633
3724
|
rebalancingService?: RebalancingService;
|
|
@@ -3659,7 +3750,8 @@ interface SimplexOptions {
|
|
|
3659
3750
|
* transaction it sends. Required unless every chain is watch-only.
|
|
3660
3751
|
*
|
|
3661
3752
|
* {@link Signer} is an interface, not a menu: `privateKeySigner`,
|
|
3662
|
-
* `turnkeySigner` and `mpcVaultSigner` are the
|
|
3753
|
+
* `secretPhraseSigner`, `turnkeySigner` and `mpcVaultSigner` are the
|
|
3754
|
+
* implementations that ship here,
|
|
3663
3755
|
* `viemSigner` adapts any viem account (a `toAccount` wrapper around an HSM or
|
|
3664
3756
|
* a remote signing service included), and anything else that satisfies the
|
|
3665
3757
|
* interface works the same way.
|
|
@@ -3775,12 +3867,20 @@ interface SimplexEvents {
|
|
|
3775
3867
|
"limit-order:cancelled": {
|
|
3776
3868
|
order: LimitOrder;
|
|
3777
3869
|
};
|
|
3778
|
-
/**
|
|
3870
|
+
/**
|
|
3871
|
+
* The order was worked down and went back on the book at its new size. A fill does
|
|
3872
|
+
* this, and so does a correction to the solver account's on-chain tally, for which
|
|
3873
|
+
* no fill is recorded. `delivered` is what the order went down by either way.
|
|
3874
|
+
*/
|
|
3779
3875
|
"limit-order:resized": {
|
|
3780
3876
|
order: LimitOrder;
|
|
3781
3877
|
delivered: string;
|
|
3782
3878
|
};
|
|
3783
|
-
/**
|
|
3879
|
+
/**
|
|
3880
|
+
* The order went under the orderbook's dust floor, so it is done. A fill takes it
|
|
3881
|
+
* there, and so does a correction to the solver account's on-chain tally, for which
|
|
3882
|
+
* no fill is recorded.
|
|
3883
|
+
*/
|
|
3784
3884
|
"limit-order:filled": {
|
|
3785
3885
|
order: LimitOrder;
|
|
3786
3886
|
};
|
|
@@ -4146,7 +4246,8 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4146
4246
|
* back from its own endpoints, which also proves they answer for one chain
|
|
4147
4247
|
* before a filler ever depends on them.
|
|
4148
4248
|
*
|
|
4149
|
-
* @throws if an endpoint set is invalid
|
|
4249
|
+
* @throws if an endpoint set is invalid, if none of a chain's endpoints answer,
|
|
4250
|
+
* if its endpoints disagree on the chain, if two entries resolve
|
|
4150
4251
|
* to the same chain, or if `scanIntervalSecs` is below the minimum.
|
|
4151
4252
|
*/
|
|
4152
4253
|
static create(options: OrderScannerOptions): Promise<OrderScanner>;
|
|
@@ -4174,4 +4275,4 @@ declare class OrderScanner implements OrderScanner$1 {
|
|
|
4174
4275
|
private closeNow;
|
|
4175
4276
|
}
|
|
4176
4277
|
|
|
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 };
|
|
4278
|
+
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 };
|