merged pull request

This commit is contained in:
EmberSpirit
2023-10-17 18:17:18 +02:00
4 changed files with 73 additions and 52 deletions
+17 -10
View File
@@ -2,7 +2,9 @@ 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 { useTokenStore } from "@/stores/tokens";
import { getContract, multicall } from "@wagmi/core";
@@ -38,29 +40,34 @@ 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);
const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore();
const tokenOut = tokenStore.memeToken.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
]);
console.log("quotedAmountOut", quotedAmountOut);
return {result: true, amount: quotedAmountOut};
} catch (error) {
return { result: false, amount: null };
}
},