From 320cbb5c63ab53b494ee32f135f1a9a6418e8422 Mon Sep 17 00:00:00 2001 From: butterscotch Date: Mon, 16 Oct 2023 22:04:16 +0300 Subject: [PATCH] Quoter: define tokenIn and tokenOut, use ethBase as a param. --- src/stores/uniswap.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/stores/uniswap.js b/src/stores/uniswap.js index eb4fd9b..1b76597 100644 --- a/src/stores/uniswap.js +++ b/src/stores/uniswap.js @@ -2,6 +2,7 @@ import { defineStore } from "pinia"; import { useWalletStoreV2 } from "@/stores/walletV2"; import QuoterJson from "@/assets/contracts/Quoter.json"; import UniswapPoolJson from "@/assets/contracts/UniswapPool.json"; +import BloodlineJson from "@/assets/contracts/Bloodline.json"; import { useMemeburnerStore } from "@/stores/memeburner"; import { getContract, multicall } from "@wagmi/core"; @@ -38,28 +39,32 @@ export const useUniswapStore = defineStore("uniswap", { this.getPoolData(); }, - async quoteExactInputSingle(amount) { + async quoteExactInputSingle(amount, ethBase) { try { console.log("quoteExactInputSingle"); const memeBurnerStore = useMemeburnerStore(); - var amountEthBase = await memeBurnerStore.getAmountETHBase(amount); - console.log("amountEthBase", amountEthBase); + // TODO: change it in your style + const tokenOut = BloodlineJson.contractAddress; + // tokenIn - WETH + const tokenIn = BigInt(this.poolData.token0) == BigInt(tokenOut) ? this.poolData.token1 : this.poolData.token0; console.log("quoteExactInputSingle-parameter", { - token0: this.poolData.token0, - token1: this.poolData.token1, + tokenIn: tokenIn, // WETH + tokenOut: tokenOut, // BLOOD fee: this.poolData.fee, - amountEthBase: amountEthBase[0], + amountEthBase: ethBase, pricelimit: 0, //sqrtPriceLimitX96 }); + const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([ - this.poolData.token0, //bloodline - this.poolData.token1, //weth + tokenIn, //weth + tokenOut, //bloodline this.poolData.fee, - amountEthBase[0], + ethBase, 0, //sqrtPriceLimitX96 ]); return {result: true, amount: quotedAmountOut}; } catch (error) { + return { result: false, amount: null }; } },