Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ routerPartialFallbackSteps: $ROUTER_PARTIAL_FALLBACK_STEPS
routerSecondaryRouteTry: $ROUTER_SECONDARY_ROUTE_TRY
dryrunGasCache: $DRYRUN_GAS_CACHE
dryrunGasCacheResetTime: $DRYRUN_GAS_CACHE_RESET_TIME
dustGasCostMultiplier: $DUST_GAS_COST_MULTIPLIER
dustUsdThreshold: $DUST_USD_THRESHOLD
dustOrderCheck: $DUST_ORDER_CHECK
strictMaxOwnerProfileCheck: $STRICT_MAX_OWNER_PROFILE_CHECK
strictMaxOwnerProfilePartialTradeSizeCheck: $STRICT_MAX_OWNER_PROFILE_PARTIAL_TRADE_SIZE_CHECK
gasBoostMultiplier: $GAS_BOOST_MULTIPLIER
Expand Down
21 changes: 18 additions & 3 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ flashblocks: false
# at the same time, taking the first accepted one, default is false
multiBroadcast: false

# Enables the halving backoff retries for router mode partial trades that get rejected onchain, default is true
# Adds the backoff sizes of the found trade size, three quarters of it and its halved sizes, to the router mode
# trade size batch that gets validated against the onchain dryrun concurrently, for every order, default is true
routerPartialFallback: true

# The number of halving backoff steps to run concurrently for router mode partial trades that get rejected onchain, default is 4
# The number of halved sizes in a router mode trade size batch, the three quarters size comes on top, default is 4
routerPartialFallbackSteps: 4

# Sets which orders get a secondary router mode try with the failing route dexes excluded after an onchain rejection,
Expand All @@ -150,10 +151,24 @@ dryrunGasCache: false
# Time (in minutes) between dryrun gas cache resets, default is 60
dryrunGasCacheResetTime: 60

# Multiplier of the trade tx gas cost below which a trade size counts as dust and gets skipped, since a trade
# worth less than its gas can never be profitable, 0 disables dust detection, default is 1
dustGasCostMultiplier: 1

# USD value below which a trade size counts as dust and gets skipped, when both dust checks are set a trade must fail
# both to count as dust, 0 disables the usd dust check, default is 0
dustUsdThreshold: 0

# Runs the dust check on each order's whole max output before any simulation and skips the dust ones for the round,
# the router mode partial trade size dust check is not affected, default is true
dustOrderCheck: true

# When true, zero output balance pairs of max profile owners go to round processing, when false, all zero output balance pairs are skipped, default is false
strictMaxOwnerProfileCheck: false

# When true, the router mode fallback partial trade backoff runs on any partial sim failure for orders of max profile owners, default is false
# When true, orders of max profile owners get the backoff sizes in their router mode trade size batch even with
# routerPartialFallback disabled, and a dust found trade size backs off from the full size for them instead of
# bailing out, default is false
strictMaxOwnerProfilePartialTradeSizeCheck: false

# Time (in minutes) to to check the operating wallet balances, 0 means dont ever check wallet balance, default is 15 mins
Expand Down
3 changes: 3 additions & 0 deletions src/cli/commands/sweep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export async function sweepFunds(opts: SweepOptions) {
routerSecondaryRouteTry: "max",
dryrunGasCache: false,
dryrunGasCacheResetTime: 60,
dustGasCostMultiplier: 1,
dustUsdThreshold: 0,
dustOrderCheck: true,
strictMaxOwnerProfileCheck: false,
strictMaxOwnerProfilePartialTradeSizeCheck: false,
timeout: 15_000,
Expand Down
9 changes: 9 additions & 0 deletions src/config/yaml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ routerPartialFallbackSteps: 6
routerSecondaryRouteTry: all
dryrunGasCache: true
dryrunGasCacheResetTime: 30
dustGasCostMultiplier: 1.5
dustUsdThreshold: 0.25
dustOrderCheck: false
strictMaxOwnerProfileCheck: true
strictMaxOwnerProfilePartialTradeSizeCheck: true
checkWalletBalanceTime: 30
Expand Down Expand Up @@ -183,6 +186,9 @@ orderbookTradeTypes:
routerSecondaryRouteTry: "all",
dryrunGasCache: true,
dryrunGasCacheResetTime: 30,
dustGasCostMultiplier: 1.5,
dustUsdThreshold: 0.25,
dustOrderCheck: false,
strictMaxOwnerProfileCheck: true,
strictMaxOwnerProfilePartialTradeSizeCheck: true,
checkWalletBalanceTime: 30,
Expand Down Expand Up @@ -405,6 +411,9 @@ orderbookTradeTypes:
assert.equal(result.routerSecondaryRouteTry, "max"); // should be default max
assert.equal(result.dryrunGasCache, false); // should be default false
assert.equal(result.dryrunGasCacheResetTime, 60); // should be default 60
assert.equal(result.dustGasCostMultiplier, 1); // should be default 1
assert.equal(result.dustUsdThreshold, 0); // should be default 0
assert.equal(result.dustOrderCheck, true); // should be default true
assert.equal(result.strictMaxOwnerProfileCheck, false); // should be default false
assert.equal(result.strictMaxOwnerProfilePartialTradeSizeCheck, false); // should be default false
assert.equal(result.checkWalletBalanceTime, 15); // should be default 15
Expand Down
41 changes: 38 additions & 3 deletions src/config/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,25 @@ export type AppOptions = {
flashblocks: boolean;
/** Broadcasts each signed transaction through all the configured write rpcs (or all rpcs when no write rpc is set) at the same time, taking the first accepted one, default is false */
multiBroadcast: boolean;
/** Enables the halving backoff retries for router mode partial trades that get rejected onchain, default is true */
/** Adds the backoff sizes of the found trade size, three quarters of it and its halved sizes, to the router mode trade size batch that gets validated against the onchain dryrun concurrently, for every order, default is true */
routerPartialFallback: boolean;
/** The number of halving backoff steps to run concurrently for router mode partial trades that get rejected onchain, default is 4 */
/** The number of halved sizes in a router mode trade size batch, the three quarters size comes on top, default is 4 */
routerPartialFallbackSteps: number;
/** Sets which orders get a secondary router mode try with the failing route dexes excluded after an onchain rejection, "all" for every order, "max" for orders of max profile owners only, "off" for none, default is "max" */
routerSecondaryRouteTry: "all" | "max" | "off";
/** Enables the dryrun gas cache that keeps an average gas limit per order pair for sushi route processor trades and skips the init dryrun once enough samples are in, default is false */
dryrunGasCache: boolean;
/** Time (in minutes) between dryrun gas cache resets, default is 60 */
dryrunGasCacheResetTime: number;
/** Multiplier of the trade tx gas cost below which a trade size counts as dust and gets skipped, 0 disables the gas cost dust check, default is 1 */
dustGasCostMultiplier: number;
/** USD value below which a trade size counts as dust and gets skipped, when both dust checks are set a trade must fail both to count as dust, 0 disables the usd dust check, default is 0 */
dustUsdThreshold: number;
/** Runs the dust check on each order's whole max output before any simulation and skips the dust ones for the round, the router mode partial trade size dust check is not affected, default is true */
dustOrderCheck: boolean;
/** When true, zero output balance pairs of max profile owners go to round processing, when false, all zero output balance pairs are skipped, default is false */
strictMaxOwnerProfileCheck: boolean;
/** When true, the router mode fallback partial trade backoff runs on any partial sim failure for orders of max profile owners, default is false */
/** When true, orders of max profile owners get the backoff sizes in their router mode trade size batch even with routerPartialFallback disabled, and a dust found trade size backs off from the full size for them instead of bailing out, default is false */
strictMaxOwnerProfilePartialTradeSizeCheck: boolean;
/** Time (in minutes) to to check the operating wallet balances, 0 means dont ever check wallet balance, default is 15 mins */
checkWalletBalanceTime: number;
Expand Down Expand Up @@ -459,6 +465,35 @@ export namespace AppOptions {
"invalid dryrunGasCacheResetTime value, must be an integer greater than 0",
),
),
dustGasCostMultiplier: Validator.resolveNumericValue(
input.dustGasCostMultiplier,
FLOAT_PATTERN,
"invalid dustGasCostMultiplier value, must be a number greater than or equal to 0",
"1",
undefined,
(dustGasCostMultiplier) =>
assert(
dustGasCostMultiplier >= 0,
"invalid dustGasCostMultiplier value, must be a number greater than or equal to 0",
),
),
dustUsdThreshold: Validator.resolveNumericValue(
input.dustUsdThreshold,
FLOAT_PATTERN,
"invalid dustUsdThreshold value, must be a number greater than or equal to 0",
"0",
undefined,
(dustUsdThreshold) =>
assert(
dustUsdThreshold >= 0,
"invalid dustUsdThreshold value, must be a number greater than or equal to 0",
),
),
dustOrderCheck: Validator.resolveBool(
input.dustOrderCheck,
"expected a boolean value for dustOrderCheck",
true,
),
strictMaxOwnerProfileCheck: Validator.resolveBool(
input.strictMaxOwnerProfileCheck,
"expected a boolean value for strictMaxOwnerProfileCheck",
Expand Down
4 changes: 4 additions & 0 deletions src/core/modes/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe("Test findBestTrade", () => {
args.toToken,
args.fromToken,
args.blockNumber,
args.outputToEthPrice,
);
expect(findBestIntraOrderbookTrade).not.toHaveBeenCalled();
expect(findBestInterOrderbookTrade).not.toHaveBeenCalled();
Expand Down Expand Up @@ -275,6 +276,7 @@ describe("Test findBestTrade", () => {
args.toToken,
args.fromToken,
args.blockNumber,
args.outputToEthPrice,
);
expect(findBestIntraOrderbookTrade).toHaveBeenCalledWith(
args.orderDetails,
Expand Down Expand Up @@ -344,6 +346,7 @@ describe("Test findBestTrade", () => {
args.toToken,
args.fromToken,
args.blockNumber,
args.outputToEthPrice,
);
expect(findBestIntraOrderbookTrade).toHaveBeenCalledWith(
args.orderDetails,
Expand Down Expand Up @@ -526,6 +529,7 @@ describe("Test findBestTrade", () => {
args.toToken,
args.fromToken,
args.blockNumber,
args.outputToEthPrice,
);
expect(findBestIntraOrderbookTrade).toHaveBeenCalledWith(
args.orderDetails,
Expand Down
1 change: 1 addition & 0 deletions src/core/modes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export async function findBestTrade(
toToken,
fromToken,
blockNumber,
outputToEthPrice,
),
findBestIntraOrderbookTradeFn?.call(
this,
Expand Down
Loading
Loading