Skip to content

Commit

Permalink
chore: snx fill time overrides + routes gen fix (#1427)
Browse files Browse the repository at this point in the history
* fix: override snx fill time

* fix: routes gen script

* fixup

* fixup

* fixup
  • Loading branch information
dohaki authored Feb 5, 2025
1 parent 1e488cb commit ebc7614
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 27 deletions.
13 changes: 12 additions & 1 deletion api/_timings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ const fillTimeOverrides: {
[symbol: string]: number;
};
};
} = {};
} = {
"1": {
"10": {
SNX: 2 * 60 * 60, // 2 hours
},
},
"10": {
"1": {
SNX: 2 * 60 * 60, // 2 hours
},
},
};

const rebalanceTimeOverrides: {
[dstId: string]: number;
Expand Down
74 changes: 48 additions & 26 deletions scripts/generate-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ function transformChainConfigs(
const tokens = processTokenRoutes(chainConfig, toChainConfig);

// Handle USDC swap tokens
const usdcSwapTokens = chainConfig.enableCCTP
? getUsdcSwapTokens(fromChainId, toChainId)
: [];
const usdcSwapTokens =
chainConfig.enableCCTP && hasBridgedUsdc(fromChainId)
? getUsdcSwapTokens(fromChainId, toChainId)
: [];

const toChain = {
chainId: toChainId,
Expand Down Expand Up @@ -330,16 +331,26 @@ function processTokenRoutes(
// Handle bridged USDC -> native/bridged USDC routes
if (sdkUtils.isBridgedUsdc(tokenSymbol)) {
if (toConfig.enableCCTP) {
return [
{
inputTokenSymbol: tokenSymbol,
outputTokenSymbol: "USDC",
},
{
inputTokenSymbol: tokenSymbol,
outputTokenSymbol: getBridgedUsdcSymbol(toChainId),
},
];
// Some chains only have native CCTP USDC
if (hasBridgedUsdc(toConfig.chainId)) {
return [
{
inputTokenSymbol: tokenSymbol,
outputTokenSymbol: "USDC",
},
{
inputTokenSymbol: tokenSymbol,
outputTokenSymbol: getBridgedUsdcSymbol(toChainId),
},
];
} else {
return [
{
inputTokenSymbol: tokenSymbol,
outputTokenSymbol: "USDC",
},
];
}
} else if (toConfig.tokens.includes("USDC")) {
return [
{
Expand All @@ -350,7 +361,8 @@ function processTokenRoutes(
} else if (
toConfig.tokens.find(
(token) => typeof token === "string" && sdkUtils.isBridgedUsdc(token)
)
) &&
hasBridgedUsdc(toChainId)
) {
return [
{
Expand Down Expand Up @@ -674,18 +686,28 @@ function getTokenBySymbol(

function getUsdcSwapTokens(fromChainId: number, toChainId: number) {
const swapInputTokenSymbol = getBridgedUsdcSymbol(fromChainId);
return [
{
swapInputTokenSymbol,
acrossInputTokenSymbol: "USDC",
acrossOutputTokenSymbol: "USDC",
},
{
swapInputTokenSymbol,
acrossInputTokenSymbol: "USDC",
acrossOutputTokenSymbol: getBridgedUsdcSymbol(toChainId),
},
];
if (hasBridgedUsdc(toChainId)) {
return [
{
swapInputTokenSymbol,
acrossInputTokenSymbol: "USDC",
acrossOutputTokenSymbol: "USDC",
},
{
swapInputTokenSymbol,
acrossInputTokenSymbol: "USDC",
acrossOutputTokenSymbol: getBridgedUsdcSymbol(toChainId),
},
];
} else {
return [
{
swapInputTokenSymbol,
acrossInputTokenSymbol: "USDC",
acrossOutputTokenSymbol: "USDC",
},
];
}
}

function getBridgedUsdcSymbol(chainId: number) {
Expand Down

0 comments on commit ebc7614

Please sign in to comment.