@hyperbridge/simplex 0.16.7 → 0.16.8
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 +195 -69
- package/dist/bin/simplex.js.map +1 -1
- package/dist/index.cjs +56 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +56 -57
- package/dist/index.js.map +1 -1
- package/dist/sqlite.cjs +1 -1
- package/dist/sqlite.cjs.map +1 -1
- package/dist/sqlite.d.cts +1 -1
- package/dist/sqlite.d.ts +1 -1
- package/dist/sqlite.js +1 -1
- package/dist/sqlite.js.map +1 -1
- package/dist/{types-DUDABLPI.d.cts → types-C7rnnKWn.d.cts} +6 -4
- package/dist/{types-DUDABLPI.d.ts → types-C7rnnKWn.d.ts} +6 -4
- package/dist/ui/assets/{index-Be446eYK.js → index-BQu6BMxc.js} +28 -28
- package/dist/ui/index.html +1 -1
- package/package.json +2 -2
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 OperatorNotification, R as RuntimeState, p as WalletTxKind, q as addLogSink, r as configureLogger, s as getLogger } from './types-
|
|
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-C7rnnKWn.cjs';
|
|
6
|
+
export { m as ActivityType, n as BidInsert, o as OperatorNotification, R as RuntimeState, p as WalletTxKind, q as addLogSink, r as configureLogger, s as getLogger } from './types-C7rnnKWn.cjs';
|
|
7
7
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
@@ -3617,17 +3617,17 @@ interface FillerRuntime {
|
|
|
3617
3617
|
*/
|
|
3618
3618
|
signerless: boolean;
|
|
3619
3619
|
/** The live confirmation policy the engine prices with; runtime chain adds install into it. */
|
|
3620
|
-
confirmationPolicy
|
|
3620
|
+
confirmationPolicy: ConfirmationPolicy;
|
|
3621
3621
|
/** This filler's logging destination. */
|
|
3622
3622
|
loggers: LoggerContext;
|
|
3623
3623
|
/** Symbol-to-address resolution for the configured chains (send options, balance labels). */
|
|
3624
3624
|
assetRegistry: AssetRegistry;
|
|
3625
3625
|
/** Creates and posts the operator's limit orders. */
|
|
3626
3626
|
limitOrders?: LimitOrderService;
|
|
3627
|
-
/** The live trading engine
|
|
3628
|
-
engine
|
|
3627
|
+
/** The live trading engine. It runs whether or not the config names any pairs. */
|
|
3628
|
+
engine: FXFiller;
|
|
3629
3629
|
/** The engine's live pair array (same instance), indexed 1:1 with config.pairs. */
|
|
3630
|
-
tradingPairs
|
|
3630
|
+
tradingPairs: TradingPair[];
|
|
3631
3631
|
/** BalanceProvider's live token1 map (chain name to exotic addresses); mutations apply on its next refresh. */
|
|
3632
3632
|
balanceTokens: Record<string, string[]>;
|
|
3633
3633
|
rebalancingService?: RebalancingService;
|
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, p as WalletTxKind, q as addLogSink, r as configureLogger, s as getLogger } from './types-
|
|
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-C7rnnKWn.js';
|
|
6
|
+
export { m as ActivityType, n as BidInsert, o as OperatorNotification, R as RuntimeState, p as WalletTxKind, q as addLogSink, r as configureLogger, s as getLogger } from './types-C7rnnKWn.js';
|
|
7
7
|
import { ChannelCredentials } from '@grpc/grpc-js';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import Decimal$1, { Decimal } from 'decimal.js';
|
|
@@ -3617,17 +3617,17 @@ interface FillerRuntime {
|
|
|
3617
3617
|
*/
|
|
3618
3618
|
signerless: boolean;
|
|
3619
3619
|
/** The live confirmation policy the engine prices with; runtime chain adds install into it. */
|
|
3620
|
-
confirmationPolicy
|
|
3620
|
+
confirmationPolicy: ConfirmationPolicy;
|
|
3621
3621
|
/** This filler's logging destination. */
|
|
3622
3622
|
loggers: LoggerContext;
|
|
3623
3623
|
/** Symbol-to-address resolution for the configured chains (send options, balance labels). */
|
|
3624
3624
|
assetRegistry: AssetRegistry;
|
|
3625
3625
|
/** Creates and posts the operator's limit orders. */
|
|
3626
3626
|
limitOrders?: LimitOrderService;
|
|
3627
|
-
/** The live trading engine
|
|
3628
|
-
engine
|
|
3627
|
+
/** The live trading engine. It runs whether or not the config names any pairs. */
|
|
3628
|
+
engine: FXFiller;
|
|
3629
3629
|
/** The engine's live pair array (same instance), indexed 1:1 with config.pairs. */
|
|
3630
|
-
tradingPairs
|
|
3630
|
+
tradingPairs: TradingPair[];
|
|
3631
3631
|
/** BalanceProvider's live token1 map (chain name to exotic addresses); mutations apply on its next refresh. */
|
|
3632
3632
|
balanceTokens: Record<string, string[]>;
|
|
3633
3633
|
rebalancingService?: RebalancingService;
|
package/dist/index.js
CHANGED
|
@@ -18630,20 +18630,32 @@ var ContractInteractionService = class {
|
|
|
18630
18630
|
} else {
|
|
18631
18631
|
this.logger.warn({ reason: pmResult.reason }, "No paymaster for bid UserOp; relying on EntryPoint deposit");
|
|
18632
18632
|
}
|
|
18633
|
-
const
|
|
18634
|
-
order,
|
|
18635
|
-
fillOptions,
|
|
18633
|
+
const bidGas = {
|
|
18636
18634
|
solverAccount: solverAccountAddress,
|
|
18637
|
-
solverSigner: sdkSigningAccount(this.signer),
|
|
18638
18635
|
nonce,
|
|
18639
18636
|
entryPointAddress,
|
|
18640
18637
|
callGasLimit,
|
|
18641
18638
|
verificationGasLimit: cachedEstimate.verificationGasLimit,
|
|
18642
|
-
preVerificationGas: cachedEstimate.preVerificationGas,
|
|
18643
18639
|
maxFeePerGas: cachedEstimate.maxFeePerGas,
|
|
18644
18640
|
maxPriorityFeePerGas: cachedEstimate.maxPriorityFeePerGas,
|
|
18645
18641
|
callData,
|
|
18646
18642
|
paymasterAndData
|
|
18643
|
+
};
|
|
18644
|
+
let preVerificationGas = cachedEstimate.preVerificationGas;
|
|
18645
|
+
try {
|
|
18646
|
+
preVerificationGas = await sdkHelper.estimateBidPreVerificationGas(bidGas);
|
|
18647
|
+
} catch (err) {
|
|
18648
|
+
this.logger.warn(
|
|
18649
|
+
{ orderId: order.id, err, preVerificationGas: preVerificationGas.toString() },
|
|
18650
|
+
"Could not estimate the bid's preVerificationGas; using the fill estimate's"
|
|
18651
|
+
);
|
|
18652
|
+
}
|
|
18653
|
+
const userOp = await sdkHelper.prepareSubmitBid({
|
|
18654
|
+
...bidGas,
|
|
18655
|
+
order,
|
|
18656
|
+
fillOptions,
|
|
18657
|
+
solverSigner: sdkSigningAccount(this.signer),
|
|
18658
|
+
preVerificationGas
|
|
18647
18659
|
});
|
|
18648
18660
|
const encodedUserOp = encodeUserOpScale(userOp);
|
|
18649
18661
|
this.logger.info(
|
|
@@ -18652,6 +18664,7 @@ var ContractInteractionService = class {
|
|
|
18652
18664
|
solverAccount: solverAccountAddress,
|
|
18653
18665
|
nonce: nonce.toString(),
|
|
18654
18666
|
callGasLimit: callGasLimit.toString(),
|
|
18667
|
+
preVerificationGas: preVerificationGas.toString(),
|
|
18655
18668
|
maxFeePerGas: cachedEstimate.maxFeePerGas.toString()
|
|
18656
18669
|
},
|
|
18657
18670
|
"Prepared bid UserOp"
|
|
@@ -21776,10 +21789,6 @@ import { Decimal as Decimal6 } from "decimal.js";
|
|
|
21776
21789
|
function limitOrderLegs(order) {
|
|
21777
21790
|
return order.side === "BID" ? { input: order.base, output: order.quote } : { input: order.quote, output: order.base };
|
|
21778
21791
|
}
|
|
21779
|
-
function availableOn(order) {
|
|
21780
|
-
const available = BigInt(order.remaining) - BigInt(order.reserved);
|
|
21781
|
-
return available > 0n ? available : 0n;
|
|
21782
|
-
}
|
|
21783
21792
|
function matchLimitOrders(orders, incoming, resolve, now = /* @__PURE__ */ new Date()) {
|
|
21784
21793
|
const qualifying = orders.filter((order) => serves(order, incoming, resolve, now)).map((order) => {
|
|
21785
21794
|
const offer = offerFor({
|
|
@@ -21788,7 +21797,7 @@ function matchLimitOrders(orders, incoming, resolve, now = /* @__PURE__ */ new D
|
|
|
21788
21797
|
price: BigInt(order.price),
|
|
21789
21798
|
outputDecimals: incoming.outputDecimals
|
|
21790
21799
|
});
|
|
21791
|
-
const available =
|
|
21800
|
+
const available = BigInt(order.remaining);
|
|
21792
21801
|
return { order, offer, available, payout: offer < available ? offer : available };
|
|
21793
21802
|
}).filter((candidate) => candidate.offer >= incoming.requestedOutput && candidate.payout > 0n).sort(byBestOfferFirst);
|
|
21794
21803
|
return qualifying;
|
|
@@ -23675,48 +23684,42 @@ async function bootFiller(config, options) {
|
|
|
23675
23684
|
assertPairSymbolsResolve(config.pairs, assetRegistry, configuredChainNames);
|
|
23676
23685
|
}
|
|
23677
23686
|
const adminStrategies = [];
|
|
23678
|
-
const
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
|
|
23685
|
-
|
|
23686
|
-
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
token1: pair.token1,
|
|
23691
|
-
sameToken: normalizeSymbol(pair.token0) === normalizeSymbol(pair.token1)
|
|
23692
|
-
});
|
|
23687
|
+
const tradingPairs = (config.pairs ?? []).map((pair) => ({
|
|
23688
|
+
token0: pair.token0,
|
|
23689
|
+
token1: pair.token1
|
|
23690
|
+
}));
|
|
23691
|
+
tradingPairs.forEach((pair, pairIndex) => {
|
|
23692
|
+
adminStrategies.push({
|
|
23693
|
+
index: pairIndex,
|
|
23694
|
+
pairIndex,
|
|
23695
|
+
exotic: `${pair.token0}/${pair.token1}`,
|
|
23696
|
+
token0: pair.token0,
|
|
23697
|
+
token1: pair.token1,
|
|
23698
|
+
sameToken: normalizeSymbol(pair.token0) === normalizeSymbol(pair.token1)
|
|
23693
23699
|
});
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
)
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23709
|
-
|
|
23710
|
-
|
|
23711
|
-
|
|
23700
|
+
});
|
|
23701
|
+
const confirmationPolicy = assertConfirmationCoverage(
|
|
23702
|
+
config.confirmationPolicies,
|
|
23703
|
+
resolvedChains.map((c) => c.chainId)
|
|
23704
|
+
);
|
|
23705
|
+
const fundingVenues = vaultVenue ? [vaultVenue] : [];
|
|
23706
|
+
const engine = new FXFiller(
|
|
23707
|
+
runtimeSigner,
|
|
23708
|
+
configService,
|
|
23709
|
+
chainClientManager,
|
|
23710
|
+
contractService,
|
|
23711
|
+
tradingPairs,
|
|
23712
|
+
assetRegistry,
|
|
23713
|
+
{ confirmationPolicy, fundingVenues, limitOrders: options.data.limitOrders }
|
|
23714
|
+
);
|
|
23715
|
+
logger.info("Hydrating funding venue state...");
|
|
23716
|
+
await engine.initialise();
|
|
23717
|
+
const strategies = [engine];
|
|
23712
23718
|
const haltControls = strategies.map((engine2, index) => ({
|
|
23713
23719
|
index,
|
|
23714
23720
|
isHalted: () => engine2.isHalted(),
|
|
23715
23721
|
resetHalt: () => engine2.resetHalt()
|
|
23716
23722
|
}));
|
|
23717
|
-
if (vaultVenue) {
|
|
23718
|
-
await vaultVenue.initialise(runtimeSigner.address);
|
|
23719
|
-
}
|
|
23720
23723
|
let rebalancingService;
|
|
23721
23724
|
const rebalancingConfig = configService.getRebalancingConfig();
|
|
23722
23725
|
if (rebalancingConfig?.triggerPercentage !== void 0 && rebalancingConfig?.baseBalances) {
|
|
@@ -24233,8 +24236,8 @@ var MemoryLimitOrderStore = class {
|
|
|
24233
24236
|
async reserve(id, amount) {
|
|
24234
24237
|
const order = this.orders.get(id);
|
|
24235
24238
|
if (!order || order.status !== "open") return false;
|
|
24239
|
+
if (BigInt(amount) > BigInt(order.remaining)) return false;
|
|
24236
24240
|
const reserved = BigInt(order.reserved) + BigInt(amount);
|
|
24237
|
-
if (reserved > BigInt(order.remaining)) return false;
|
|
24238
24241
|
this.patch(id, { reserved: reserved.toString() });
|
|
24239
24242
|
return true;
|
|
24240
24243
|
}
|
|
@@ -24986,10 +24989,7 @@ var PairController = class {
|
|
|
24986
24989
|
* the pair's symbols have to resolve before the market can be hydrated.
|
|
24987
24990
|
*/
|
|
24988
24991
|
async add(pair, options) {
|
|
24989
|
-
const { engine,
|
|
24990
|
-
if (!engine || !tradingPairs) {
|
|
24991
|
-
throw new Error("No trading engine is running \u2014 this filler was started without pairs");
|
|
24992
|
-
}
|
|
24992
|
+
const { engine, assetRegistry, adminStrategies, balanceTokens, config } = this.runtime;
|
|
24993
24993
|
const assets = options?.assets;
|
|
24994
24994
|
const nextAssets = { ...config.assets ?? {}, ...assets ?? {} };
|
|
24995
24995
|
const nextPairs = [...this.pairs, pair];
|
|
@@ -25028,7 +25028,6 @@ var PairController = class {
|
|
|
25028
25028
|
/** Closes a market. Orders already in flight against it still complete. */
|
|
25029
25029
|
async remove(index) {
|
|
25030
25030
|
const { engine, tradingPairs, adminStrategies, config } = this.runtime;
|
|
25031
|
-
if (!engine || !tradingPairs) throw new Error("No trading engine is running");
|
|
25032
25031
|
if (index < 0 || index >= this.pairs.length) throw new Error(`Unknown pair ${index}`);
|
|
25033
25032
|
engine.removePair(tradingPairs[index]);
|
|
25034
25033
|
config.pairs = this.pairs.filter((_, i) => i !== index);
|
|
@@ -25040,7 +25039,7 @@ var PairController = class {
|
|
|
25040
25039
|
await this.persist();
|
|
25041
25040
|
}
|
|
25042
25041
|
livePair(index) {
|
|
25043
|
-
const pair = this.runtime.tradingPairs
|
|
25042
|
+
const pair = this.runtime.tradingPairs[index];
|
|
25044
25043
|
if (!pair) throw new Error(`Unknown pair ${index}`);
|
|
25045
25044
|
return pair;
|
|
25046
25045
|
}
|
|
@@ -25132,9 +25131,9 @@ var ChainController = class {
|
|
|
25132
25131
|
throw error;
|
|
25133
25132
|
}
|
|
25134
25133
|
const curve = confirmationPolicies[String(chainId)];
|
|
25135
|
-
if (curve) this.runtime.confirmationPolicy
|
|
25136
|
-
else if (!this.runtime.confirmationPolicy
|
|
25137
|
-
this.runtime.confirmationPolicy
|
|
25134
|
+
if (curve) this.runtime.confirmationPolicy.add(chainId, curve);
|
|
25135
|
+
else if (!this.runtime.confirmationPolicy.has(chainId)) {
|
|
25136
|
+
this.runtime.confirmationPolicy.adopt(chainId, resolvedPolicy);
|
|
25138
25137
|
}
|
|
25139
25138
|
this.runtime.resolvedChains.push(resolved);
|
|
25140
25139
|
config.chains = [...config.chains, { rpcUrls: chain.rpcUrls, bundlerUrl: chain.bundlerUrl }];
|
|
@@ -25162,7 +25161,7 @@ var ChainController = class {
|
|
|
25162
25161
|
await intentFiller.removeChain(chainId);
|
|
25163
25162
|
if (this.ownsScanner) await this.scanner.removeChain(chainId);
|
|
25164
25163
|
configService.removeChain(chainId);
|
|
25165
|
-
this.runtime.confirmationPolicy
|
|
25164
|
+
this.runtime.confirmationPolicy.remove(chainId);
|
|
25166
25165
|
this.runtime.chainClientManager.invalidate(chainKey);
|
|
25167
25166
|
this.runtime.resolvedChains.splice(index, 1);
|
|
25168
25167
|
config.chains = config.chains.filter((_, i) => i !== index);
|