Skip to content

Commit 7d24ba3

Browse files
authored
[Bridging] Make $50-$100 deposits slow to not pay fees (#3087)
1 parent e8fdff8 commit 7d24ba3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

indexer/services/comlink/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export const configSchema = {
125125
BASE_WEBHOOK_ID: parseString({ default: 'wh_lpjn5gnwj0ll0gap' }),
126126
OPTIMISM_WEBHOOK_ID: parseString({ default: 'wh_7eo900bsg8rkvo6z' }),
127127
SOLANA_WEBHOOK_ID: parseString({ default: 'wh_eqxyotjv478gscpo' }),
128+
// minimum threshold we need to hit for go fast to be free.
129+
ETHEREUM_GO_FAST_FREE_MINIMUM: parseInteger({ default: 100 }),
128130
};
129131

130132
////////////////////////////////////////////////////////////////////////////////

indexer/services/comlink/src/helpers/skip-helper.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import { decode, fromWords } from 'bech32';
1414
import bs58 from 'bs58';
1515
import { encodeFunctionData, type Hex } from 'viem';
1616
import type { EntryPointVersion, SmartAccountImplementation } from 'viem/account-abstraction';
17-
import { avalanche } from 'viem/chains';
17+
import { avalanche, mainnet } from 'viem/chains';
1818

1919
import config from '../config';
2020
import {
2121
dydxChainId,
2222
entryPoint,
23+
ETH_USDC_QUANTUM,
2324
ethDenomByChainId, usdcAddressByChainId,
2425
} from '../lib/smart-contract-constants';
2526
import { getAddress, publicClients } from './alchemy-helpers';
@@ -44,6 +45,7 @@ export async function buildUserAddresses(
4445
);
4546
}
4647
const nobleForwardingModule = 'https://api.noble.xyz/noble/forwarding/v1/address/channel';
48+
const ethereumGoFastFreeMinimumUSDC = config.ETHEREUM_GO_FAST_FREE_MINIMUM * ETH_USDC_QUANTUM;
4749
const skipMessagesTimeoutSeconds = '60';
4850
const dydxNobleChannel = 33;
4951
const slippageTolerancePercent = config.SKIP_SLIPPAGE_TOLERANCE_PERCENTAGE;
@@ -60,6 +62,12 @@ export async function getSkipCallData(
6062
if (amount.startsWith('0x')) {
6163
amountToUse = parseInt(amount, 16).toString();
6264
}
65+
66+
let goFast = true;
67+
if (chainId === mainnet.id.toString() &&
68+
parseInt(amountToUse, 10) < ethereumGoFastFreeMinimumUSDC) {
69+
goFast = false;
70+
}
6371
const routeResult = await route({
6472
amountIn: amountToUse, // Desired amount in smallest denomination (e.g., uatom)
6573
sourceAssetDenom,
@@ -73,7 +81,7 @@ export async function getSkipCallData(
7381
evmSwaps: true, // needed for native eth bridging.
7482
},
7583
allowUnsafe: false,
76-
goFast: true,
84+
goFast,
7785
});
7886
logger.info({
7987
at: 'skip-helper#getSkipCallData',

0 commit comments

Comments
 (0)