Quoter: define tokenIn and tokenOut, use ethBase as a param.

This commit is contained in:
butterscotch
2023-10-16 22:04:16 +03:00
parent 2d35457076
commit 320cbb5c63
+14 -9
View File
@@ -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 };
}
},