Skip to content

Commit

Permalink
[CoW AMM Deployer] Calculate cow quote amount in based on minTradedTo…
Browse files Browse the repository at this point in the history
…ken0 amount (#635)
  • Loading branch information
yvesfracari authored Mar 20, 2024
1 parent 5a61df4 commit 5efec23
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/cow-amm-deployer/src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ export const ammFormSchema = z
return !path.length;
})
.superRefine((data, ctx) => {
// validate if route exists
// hardcoded value since we're just checking if the route exists or not
// we're using 100 times the minTradedToken0 to cover high gas price (mainly for mainnet)
const amountIn = data.minTradedToken0 * 100 ** data.token0.decimals;
return fetchCowQuote({
tokenIn: data.token0,
tokenOut: data.token1,
amountIn: 1e18, // hardcoded value since we're just checking if the route exists or not
amountIn,
chainId: data.chainId as ChainId,
priceQuality: "fast",
}).then((res) => {
Expand Down

0 comments on commit 5efec23

Please sign in to comment.