Quoter: define tokenIn and tokenOut, use ethBase as a param.
This commit is contained in:
+14
-9
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
|||||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||||
import QuoterJson from "@/assets/contracts/Quoter.json";
|
import QuoterJson from "@/assets/contracts/Quoter.json";
|
||||||
import UniswapPoolJson from "@/assets/contracts/UniswapPool.json";
|
import UniswapPoolJson from "@/assets/contracts/UniswapPool.json";
|
||||||
|
import BloodlineJson from "@/assets/contracts/Bloodline.json";
|
||||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||||
|
|
||||||
import { getContract, multicall } from "@wagmi/core";
|
import { getContract, multicall } from "@wagmi/core";
|
||||||
@@ -38,28 +39,32 @@ export const useUniswapStore = defineStore("uniswap", {
|
|||||||
this.getPoolData();
|
this.getPoolData();
|
||||||
},
|
},
|
||||||
|
|
||||||
async quoteExactInputSingle(amount) {
|
async quoteExactInputSingle(amount, ethBase) {
|
||||||
try {
|
try {
|
||||||
console.log("quoteExactInputSingle");
|
console.log("quoteExactInputSingle");
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount);
|
// TODO: change it in your style
|
||||||
console.log("amountEthBase", amountEthBase);
|
const tokenOut = BloodlineJson.contractAddress;
|
||||||
|
// tokenIn - WETH
|
||||||
|
const tokenIn = BigInt(this.poolData.token0) == BigInt(tokenOut) ? this.poolData.token1 : this.poolData.token0;
|
||||||
console.log("quoteExactInputSingle-parameter", {
|
console.log("quoteExactInputSingle-parameter", {
|
||||||
token0: this.poolData.token0,
|
tokenIn: tokenIn, // WETH
|
||||||
token1: this.poolData.token1,
|
tokenOut: tokenOut, // BLOOD
|
||||||
fee: this.poolData.fee,
|
fee: this.poolData.fee,
|
||||||
amountEthBase: amountEthBase[0],
|
amountEthBase: ethBase,
|
||||||
pricelimit: 0, //sqrtPriceLimitX96
|
pricelimit: 0, //sqrtPriceLimitX96
|
||||||
});
|
});
|
||||||
|
|
||||||
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
|
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
|
||||||
this.poolData.token0, //bloodline
|
tokenIn, //weth
|
||||||
this.poolData.token1, //weth
|
tokenOut, //bloodline
|
||||||
this.poolData.fee,
|
this.poolData.fee,
|
||||||
amountEthBase[0],
|
ethBase,
|
||||||
0, //sqrtPriceLimitX96
|
0, //sqrtPriceLimitX96
|
||||||
]);
|
]);
|
||||||
return {result: true, amount: quotedAmountOut};
|
return {result: true, amount: quotedAmountOut};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
return { result: false, amount: null };
|
return { result: false, amount: null };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user