Merge branch 'development' of http://gitea.loseyourip.com:4000/cindylouwho/ImmortalClanVue into development
This commit is contained in:
@@ -42,6 +42,7 @@
|
|||||||
return processChange($event.target.value);
|
return processChange($event.target.value);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
:max="activeWalletToken.balanceOf"
|
||||||
:logo="activeToken.logo"
|
:logo="activeToken.logo"
|
||||||
>
|
>
|
||||||
<template v-slot:message>
|
<template v-slot:message>
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
.balanceOf
|
.balanceOf
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-max tiny-text" @click="addMaxTokens">Max</div>
|
||||||
</template>
|
</template>
|
||||||
</token-input>
|
</token-input>
|
||||||
</div>
|
</div>
|
||||||
@@ -167,7 +169,7 @@ import { useToast } from "vue-toastification";
|
|||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { waitForTransaction, readContract, watchBlockNumber } from "@wagmi/core";
|
import { waitForTransaction, readContract, watchBlockNumber, multicall } from "@wagmi/core";
|
||||||
|
|
||||||
import Helper from "@/utils/helper.js";
|
import Helper from "@/utils/helper.js";
|
||||||
const isMobile = inject("isMobile");
|
const isMobile = inject("isMobile");
|
||||||
@@ -209,6 +211,14 @@ const state = ref(0);
|
|||||||
const showStakingMenu = ref(false);
|
const showStakingMenu = ref(false);
|
||||||
const approvalData = ref(null);
|
const approvalData = ref(null);
|
||||||
|
|
||||||
|
const activeWalletToken = computed(() => {
|
||||||
|
let returnedObject = {};
|
||||||
|
if (activeToken.value.contractAddress) {
|
||||||
|
returnedObject = walletStore.token.find((obj) => obj.contractAddress === activeToken.value.contractAddress);
|
||||||
|
}
|
||||||
|
return returnedObject;
|
||||||
|
});
|
||||||
|
|
||||||
const stateComputed = computed(() => {
|
const stateComputed = computed(() => {
|
||||||
let returnState = 0;
|
let returnState = 0;
|
||||||
if (tokenNumber.value === null || tokenNumber.value === "" || tokenNumber.value === 0) {
|
if (tokenNumber.value === null || tokenNumber.value === "" || tokenNumber.value === 0) {
|
||||||
@@ -363,46 +373,124 @@ async function getRewardsFor(value) {
|
|||||||
state.value = 0;
|
state.value = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value)) {
|
|
||||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||||
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
||||||
);
|
);
|
||||||
console.log("rewardsForResult", rewardsForResult);
|
|
||||||
const rewardsForResultNumber = Number(rewardsForResult) / Math.pow(10, tokenStore.activeToken.decimals);
|
const rewardsForResultNumber = Number(rewardsForResult) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
newOutput = rewardsForResultNumber;
|
|
||||||
variant = "sacrifice";
|
|
||||||
} else {
|
|
||||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
|
||||||
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
"tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)",
|
|
||||||
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
|
||||||
);
|
|
||||||
console.log("tokenNumber.value", tokenNumber.value);
|
|
||||||
var quoteRewards = await uniswapStore.quoteExactInputSingle(
|
var quoteRewards = await uniswapStore.quoteExactInputSingle(
|
||||||
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let variant = "sacrifice";
|
||||||
|
if (quoteRewards.result) {
|
||||||
console.log("quoteRewards", quoteRewards);
|
console.log("quoteRewards", quoteRewards);
|
||||||
const rewardsForResultNumber = Number(rewardsForResult) / Math.pow(10, tokenStore.activeToken.decimals);
|
const quoteRewardsNumber = Number(quoteRewards.amount) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
console.log("rewardsForResultNumber", rewardsForResultNumber);
|
|
||||||
const quoteRewardsNumber = Number(quoteRewards) / Math.pow(10, tokenStore.activeToken.decimals);
|
|
||||||
console.log("quoteRewardsNumber", quoteRewardsNumber);
|
|
||||||
if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
|
if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
|
||||||
//sacrificememe
|
|
||||||
newOutput = quoteRewardsNumber;
|
|
||||||
variant = "buy";
|
variant = "buy";
|
||||||
// const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/**
|
||||||
|
* case 4
|
||||||
|
* quoter threw an error
|
||||||
|
*/
|
||||||
|
//
|
||||||
newOutput = rewardsForResultNumber;
|
newOutput = rewardsForResultNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
const amountDecimal = BigInt(value * Math.pow(10, tokenStore.activeToken.decimals));
|
||||||
|
console.log("amountDecimal", amountDecimal);
|
||||||
|
if (!walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value)) {
|
||||||
|
/**
|
||||||
|
* case 1
|
||||||
|
* user is not logged in or Allowance is less than Input, then I show getRewardsForSacrifice Value
|
||||||
|
* variante not relevant
|
||||||
|
*/
|
||||||
|
newOutput = rewardsForResultNumber;
|
||||||
|
} else if (walletStore.connected && variant === "sacrifice") {
|
||||||
|
/**
|
||||||
|
* case 2
|
||||||
|
* user is logged in and allowance is greater or equal input and variant is sacrifice
|
||||||
|
*/
|
||||||
|
newOutput = rewardsForResultNumber;
|
||||||
|
} else if (walletStore.connected && variant === "buy") {
|
||||||
|
/**
|
||||||
|
* case 3
|
||||||
|
* user is logged in and allowance is greater or equal input and variant is buy
|
||||||
|
* compare sacrificeMeme-result and sacrificeMemeAndBuyBLOOD-result
|
||||||
|
*/
|
||||||
|
const amountSacrifice = await readContract({
|
||||||
|
address: memeburnerStore.contract.address,
|
||||||
|
abi: memeburnerStore.contract.abi,
|
||||||
|
functionName: "sacrificeMeme",
|
||||||
|
args: [tokenStore.activeToken.contractAddress, amountDecimal.toString(), 0],
|
||||||
|
account: walletStore.address,
|
||||||
|
});
|
||||||
|
console.log("amountSacrifice", amountSacrifice);
|
||||||
|
|
||||||
|
const amountBuy = await readContract({
|
||||||
|
address: memeburnerStore.contract.address,
|
||||||
|
abi: memeburnerStore.contract.abi,
|
||||||
|
functionName: "sacrificeMemeAndBuyBLOOD",
|
||||||
|
args: [tokenStore.activeToken.contractAddress, amountDecimal.toString(), 0],
|
||||||
|
account: walletStore.address,
|
||||||
|
});
|
||||||
|
const amountBuyNumber = Number(amountBuy) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
|
|
||||||
|
const amountSacrificeNumber = Number(amountSacrifice) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
|
if (amountBuyNumber * 0.995 > amountSacrificeNumber) {
|
||||||
|
variant = "buy";
|
||||||
|
newOutput = amountBuyNumber;
|
||||||
|
} else {
|
||||||
variant = "sacrifice";
|
variant = "sacrifice";
|
||||||
//sacrificeMemeAndBuyBLOOD
|
newOutput = amountSacrificeNumber;
|
||||||
// const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("variant", variant);
|
|
||||||
|
// if (!walletStore.connected && variant === "sacrifice") {
|
||||||
|
// newOutput = rewardsForResultNumber;
|
||||||
|
// } else if (!walletStore.connected && variant === "buy") {
|
||||||
|
// newOutput = rewardsForResultNumber;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value)) {
|
||||||
|
// //case 1
|
||||||
|
// // user is not logged in or Allowance is less than Input, then I show getRewardsForSacrifice Value
|
||||||
|
|
||||||
|
// newOutput = rewardsForResultNumber;
|
||||||
|
// variant = "sacrifice";
|
||||||
|
// } else {
|
||||||
|
// const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||||
|
// BigInt(value * Math.pow(10, activeToken.value.decimals))
|
||||||
|
// );
|
||||||
|
// console.log(
|
||||||
|
// "tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)",
|
||||||
|
// tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||||
|
// );
|
||||||
|
// console.log("tokenNumber.value", tokenNumber.value);
|
||||||
|
// var quoteRewards = await uniswapStore.quoteExactInputSingle(
|
||||||
|
// tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||||
|
// );
|
||||||
|
// console.log("quoteRewards", quoteRewards);
|
||||||
|
// const rewardsForResultNumber = Number(rewardsForResult[0]) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
|
// console.log("rewardsForResultNumber", rewardsForResultNumber);
|
||||||
|
// const quoteRewardsNumber = Number(quoteRewards) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||||
|
// console.log("quoteRewardsNumber", quoteRewardsNumber);
|
||||||
|
// if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
|
||||||
|
// //sacrificememe
|
||||||
|
// newOutput = quoteRewardsNumber;
|
||||||
|
// variant = "buy";
|
||||||
|
// // const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
||||||
|
// } else {
|
||||||
|
// newOutput = rewardsForResultNumber;
|
||||||
|
// variant = "sacrifice";
|
||||||
|
// //sacrificeMemeAndBuyBLOOD
|
||||||
|
// // const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// console.log("variant", variant);
|
||||||
|
// tokenStore.activeToken.rewards = newOutput;
|
||||||
output.value = newOutput;
|
output.value = newOutput;
|
||||||
tokenStore.activeToken.rewards = newOutput;
|
|
||||||
return { ouput: newOutput, variant: variant };
|
return { ouput: newOutput, variant: variant };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error", error);
|
console.log("error", error);
|
||||||
@@ -416,6 +504,11 @@ async function addTokens(value) {
|
|||||||
output.value = await getRewardsFor(tokenNumber.value).output;
|
output.value = await getRewardsFor(tokenNumber.value).output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addMaxTokens() {
|
||||||
|
tokenNumber.value = activeWalletToken.value.balanceOf;
|
||||||
|
output.value = await getRewardsFor(tokenNumber.value).output;
|
||||||
|
}
|
||||||
|
|
||||||
function showSuccessToast(value, header, subheader, info) {
|
function showSuccessToast(value, header, subheader, info) {
|
||||||
// Define the content object with the component, props and listeners
|
// Define the content object with the component, props and listeners
|
||||||
const content = {
|
const content = {
|
||||||
@@ -612,4 +705,10 @@ function showSuccessToast(value, header, subheader, info) {
|
|||||||
justify-content: space-between
|
justify-content: space-between
|
||||||
.icon
|
.icon
|
||||||
margin-left: auto
|
margin-left: auto
|
||||||
|
|
||||||
|
.input-max
|
||||||
|
color: var(--grey, #858585)
|
||||||
|
&:hover, &:active, &:focus
|
||||||
|
color: var(--grey-light, #858585)
|
||||||
|
cursor: pointer
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
@input="emit('update:modelValue', $event.target.value)"
|
@input="emit('update:modelValue', $event.target.value)"
|
||||||
:value="props.modelValue"
|
:value="props.modelValue"
|
||||||
:placeholder="0"
|
:placeholder="0"
|
||||||
|
type="number"
|
||||||
/>
|
/>
|
||||||
<div class="value-adder">
|
<div class="value-adder">
|
||||||
<slot class="value-adder" name="message"></slot>
|
<slot class="value-adder" name="message"></slot>
|
||||||
@@ -29,6 +30,7 @@ import TokenLogo from "@/components/TokenLogo.vue";
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: [String, Number],
|
modelValue: [String, Number],
|
||||||
logo: String,
|
logo: String,
|
||||||
|
max: Number,
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue"]);
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
@@ -50,6 +52,12 @@ const emit = defineEmits(["update:modelValue"]);
|
|||||||
font-size: 24px
|
font-size: 24px
|
||||||
border-radius: 16px
|
border-radius: 16px
|
||||||
padding: 0 16px
|
padding: 0 16px
|
||||||
|
&::-webkit-outer-spin-button,
|
||||||
|
&::-webkit-inner-spin-button
|
||||||
|
-webkit-appearance: none
|
||||||
|
margin: 0
|
||||||
|
&[type=number]
|
||||||
|
-moz-appearance: textfield
|
||||||
@media (min-width: 992px)
|
@media (min-width: 992px)
|
||||||
font-size: 24px
|
font-size: 24px
|
||||||
.value-adder
|
.value-adder
|
||||||
|
|||||||
+59
-60
@@ -89,24 +89,23 @@ app.use(pinia);
|
|||||||
app.use(Toast, {});
|
app.use(Toast, {});
|
||||||
|
|
||||||
|
|
||||||
const walletStore = useWalletStoreV2();
|
try {
|
||||||
const tokenStore = useTokenStore();
|
const walletStore = useWalletStoreV2();
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const tokenStore = useTokenStore();
|
||||||
const rewardLockerStore = useRewardLockerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
const roundsStore = useRoundsStore();
|
const rewardLockerStore = useRewardLockerStore();
|
||||||
const uniswapStore = useUniswapStore();
|
const roundsStore = useRoundsStore();
|
||||||
|
const uniswapStore = useUniswapStore();
|
||||||
|
|
||||||
|
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
|
||||||
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
|
console.log("hier chains");
|
||||||
console.log("hier chains");
|
const { chains, publicClient, webSocketPublicClient } = configureChains(
|
||||||
const { chains, publicClient, webSocketPublicClient } = configureChains(
|
|
||||||
[goerli, mainnet],
|
[goerli, mainnet],
|
||||||
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
walletStore.config = createConfig({
|
||||||
walletStore.config = createConfig({
|
|
||||||
autoConnect: true,
|
autoConnect: true,
|
||||||
connectors: [
|
connectors: [
|
||||||
new CoinbaseWalletConnector({
|
new CoinbaseWalletConnector({
|
||||||
@@ -132,29 +131,29 @@ walletStore.config = createConfig({
|
|||||||
],
|
],
|
||||||
publicClient,
|
publicClient,
|
||||||
webSocketPublicClient,
|
webSocketPublicClient,
|
||||||
});
|
});
|
||||||
walletStore.publicClient = publicClient;
|
walletStore.publicClient = publicClient;
|
||||||
|
|
||||||
const networkId = getNetwork()?.chain?.id;
|
const networkId = getNetwork()?.chain?.id;
|
||||||
|
|
||||||
// watchWalletClient(
|
// watchWalletClient(
|
||||||
// {
|
// {
|
||||||
// chainId: networkId,
|
// chainId: networkId,
|
||||||
// },
|
// },
|
||||||
// async (walletClient) => {
|
// async (walletClient) => {
|
||||||
// console.log("watchWalletClient", walletClient);
|
// console.log("watchWalletClient", walletClient);
|
||||||
// walletStore.walletClient = walletClient;
|
// walletStore.walletClient = walletClient;
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// watchPublicClient(
|
// watchPublicClient(
|
||||||
// {
|
// {
|
||||||
// chainId: networkId,
|
// chainId: networkId,
|
||||||
// },
|
// },
|
||||||
// (publicClient) => console.log("publicClient", publicClient)
|
// (publicClient) => console.log("publicClient", publicClient)
|
||||||
// );
|
// );
|
||||||
|
|
||||||
watchContractEvent(
|
watchContractEvent(
|
||||||
{
|
{
|
||||||
address: memeBurnerStore.config.contractAddress,
|
address: memeBurnerStore.config.contractAddress,
|
||||||
abi: memeBurnerStore.config.abi,
|
abi: memeBurnerStore.config.abi,
|
||||||
@@ -165,9 +164,9 @@ watchContractEvent(
|
|||||||
const token = log[0].args.sacrificedToken;
|
const token = log[0].args.sacrificedToken;
|
||||||
await roundsStore.updateCurrentRound(token);
|
await roundsStore.updateCurrentRound(token);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
watchContractEvent(
|
watchContractEvent(
|
||||||
{
|
{
|
||||||
address: rewardLockerStore.config.contractAddress,
|
address: rewardLockerStore.config.contractAddress,
|
||||||
abi: rewardLockerStore.config.abi,
|
abi: rewardLockerStore.config.abi,
|
||||||
@@ -178,11 +177,10 @@ watchContractEvent(
|
|||||||
await roundsStore.fillRound(roundsStore.currentRound);
|
await roundsStore.fillRound(roundsStore.currentRound);
|
||||||
roundsStore.currentRound++;
|
roundsStore.currentRound++;
|
||||||
await roundsStore.fillRound(roundsStore.currentRound);
|
await roundsStore.fillRound(roundsStore.currentRound);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
watchAccount(async (account) => {
|
watchAccount(async (account) => {
|
||||||
console.log("watchAccount", account);
|
console.log("watchAccount", account);
|
||||||
|
|
||||||
// {chainId: }
|
// {chainId: }
|
||||||
@@ -211,34 +209,35 @@ watchAccount(async (account) => {
|
|||||||
walletStore.connected = false;
|
walletStore.connected = false;
|
||||||
walletStore.walletClient = null;
|
walletStore.walletClient = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watchNetwork((network) => {
|
watchNetwork((network) => {
|
||||||
if (network.chain) {
|
if (network.chain) {
|
||||||
walletStore.chain = network.chain;
|
walletStore.chain = network.chain;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// watchContractEvent(
|
||||||
|
// {
|
||||||
|
// address: memeBurnerStore.config.contractAddress,
|
||||||
|
// abi: memeBurnerStore.config.abi,
|
||||||
|
// eventName: "MemeSacrificed",
|
||||||
|
// },
|
||||||
|
// async (log) => {
|
||||||
|
// console.log("memeSacrificedEvent", log);
|
||||||
|
// const token = log[0].args.sacrificedToken;
|
||||||
|
// await roundsStore.updateCurrentRound(token);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
await walletStore.init();
|
||||||
// watchContractEvent(
|
await tokenStore.initV2();
|
||||||
// {
|
await memeBurnerStore.init();
|
||||||
// address: memeBurnerStore.config.contractAddress,
|
await rewardLockerStore.init();
|
||||||
// abi: memeBurnerStore.config.abi,
|
await memeBurnerStore.init();
|
||||||
// eventName: "MemeSacrificed",
|
} catch (error) {
|
||||||
// },
|
console.error("main-init", error)
|
||||||
// async (log) => {
|
}
|
||||||
// console.log("memeSacrificedEvent", log);
|
|
||||||
// const token = log[0].args.sacrificedToken;
|
|
||||||
// await roundsStore.updateCurrentRound(token);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
|
|
||||||
await walletStore.init();
|
|
||||||
await tokenStore.initV2();
|
|
||||||
await memeBurnerStore.init();
|
|
||||||
await rewardLockerStore.init();
|
|
||||||
await memeBurnerStore.init();
|
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.component('font-awesome-icon', FontAwesomeIcon)
|
app.component('font-awesome-icon', FontAwesomeIcon)
|
||||||
|
|||||||
+4
-28
@@ -99,6 +99,7 @@ export const useTokenStore = defineStore("token", {
|
|||||||
},
|
},
|
||||||
async initV2() {
|
async initV2() {
|
||||||
console.log("-----------init token-------------");
|
console.log("-----------init token-------------");
|
||||||
|
try {
|
||||||
const walletStore = useWalletStoreV2();
|
const walletStore = useWalletStoreV2();
|
||||||
for (let index = 0; index < this.token.length; index++) {
|
for (let index = 0; index < this.token.length; index++) {
|
||||||
const contracts = [];
|
const contracts = [];
|
||||||
@@ -121,35 +122,10 @@ export const useTokenStore = defineStore("token", {
|
|||||||
token.symbol = data[2].result;
|
token.symbol = data[2].result;
|
||||||
token.totalSupply = data[3].result;
|
token.totalSupply = data[3].result;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("initV2", error);
|
||||||
|
}
|
||||||
|
|
||||||
// MemeToken init
|
|
||||||
// this.memeToken.contract = getContract({
|
|
||||||
// address: this.memeToken.config.contractAddress,
|
|
||||||
// abi: this.memeToken.config.abi,
|
|
||||||
// walletClient: walletStore.walletClient || walletStore.publicClient,
|
|
||||||
// });
|
|
||||||
// const contracts = [];
|
|
||||||
// contracts.push({ ...this.memeToken.contract, functionName: "decimals" });
|
|
||||||
// contracts.push({ ...this.memeToken.contract, functionName: "name" });
|
|
||||||
// contracts.push({ ...this.memeToken.contract, functionName: "symbol" });
|
|
||||||
// contracts.push({ ...this.memeToken.contract, functionName: "totalSupply" });
|
|
||||||
|
|
||||||
// const data = await multicall({
|
|
||||||
// contracts,
|
|
||||||
// });
|
|
||||||
// this.memeToken.decimals = data[0].result;
|
|
||||||
// this.memeToken.name = data[1].result;
|
|
||||||
// this.memeToken.symbol = data[2].result;
|
|
||||||
// this.memeToken.totalSupply = data[3].result;
|
|
||||||
// contracts.push({ ...this.memeToken.contract, functionName: "decimals" });
|
|
||||||
|
|
||||||
// //multicall decimal
|
|
||||||
// for (let index = 0; index < this.token.length; index++) {
|
|
||||||
// const token = this.token[index];
|
|
||||||
// token.decimals = data[index].result
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.memeToken.decimals = data[this.token.length].result;
|
|
||||||
},
|
},
|
||||||
async changeActiveToken(token) {
|
async changeActiveToken(token) {
|
||||||
console.log("changeActiveToken");
|
console.log("changeActiveToken");
|
||||||
|
|||||||
+11
-5
@@ -39,24 +39,29 @@ export const useUniswapStore = defineStore("uniswap", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async quoteExactInputSingle(amount) {
|
async quoteExactInputSingle(amount) {
|
||||||
|
try {
|
||||||
console.log("quoteExactInputSingle");
|
console.log("quoteExactInputSingle");
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount);
|
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount);
|
||||||
|
console.log("amountEthBase", amountEthBase);
|
||||||
console.log("123", {
|
console.log("123", {
|
||||||
token1: this.poolData.token1,
|
|
||||||
token0: this.poolData.token0,
|
token0: this.poolData.token0,
|
||||||
|
token1: this.poolData.token1,
|
||||||
fee: this.poolData.fee,
|
fee: this.poolData.fee,
|
||||||
amountEthBase,
|
amountEthBase: amountEthBase,
|
||||||
pricelimit: 0, //sqrtPriceLimitX96
|
pricelimit: 0, //sqrtPriceLimitX96
|
||||||
});
|
});
|
||||||
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
|
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
|
||||||
this.poolData.token1,
|
this.poolData.token0, //bloodline
|
||||||
this.poolData.token0,
|
this.poolData.token1, //weth
|
||||||
this.poolData.fee,
|
this.poolData.fee,
|
||||||
amountEthBase,
|
amountEthBase,
|
||||||
0, //sqrtPriceLimitX96
|
0, //sqrtPriceLimitX96
|
||||||
]);
|
]);
|
||||||
return quotedAmountOut;
|
return {result: true, amount: quotedAmountOut};
|
||||||
|
} catch (error) {
|
||||||
|
return { result: false, amount: null };
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async getPoolData() {
|
async getPoolData() {
|
||||||
console.log("getPoolData");
|
console.log("getPoolData");
|
||||||
@@ -81,6 +86,7 @@ export const useUniswapStore = defineStore("uniswap", {
|
|||||||
this.poolData.token0 = data[0].result;
|
this.poolData.token0 = data[0].result;
|
||||||
this.poolData.token1 = data[1].result;
|
this.poolData.token1 = data[1].result;
|
||||||
this.poolData.fee = data[2].result;
|
this.poolData.fee = data[2].result;
|
||||||
|
console.log("this.poolData", this.poolData);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ onMounted(async () => {
|
|||||||
amount,
|
amount,
|
||||||
true,
|
true,
|
||||||
]);
|
]);
|
||||||
console.log("amountETHBase", amountETHBase.value);
|
console.log("amountETHBase123", amountETHBase.value);
|
||||||
// web3.value = new Web3(window.ethereum);
|
// web3.value = new Web3(window.ethereum);
|
||||||
// // const contract = new web3.value.eth.Contract(Meme1Json.abi, Meme1Json.contractAddress);
|
// // const contract = new web3.value.eth.Contract(Meme1Json.abi, Meme1Json.contractAddress);
|
||||||
// console.log("web3", web3.value);
|
// console.log("web3", web3.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user