quoter update + desktop update
This commit is contained in:
+3
-3
@@ -13,7 +13,7 @@ import { useRoundsStore } from "@/stores/rounds";
|
||||
|
||||
import SlideoutPanel from "./components/SlideoutPanel.vue";
|
||||
import ConnectWallet from "./components/ConnectWallet.vue";
|
||||
import StakeComponent from "@/components/StakeComponent.vue";
|
||||
import CardComponent from "@/components/CardComponent.vue";
|
||||
|
||||
import {
|
||||
watchAccount,
|
||||
@@ -145,7 +145,7 @@ onMounted(async () => {
|
||||
<connect-wallet></connect-wallet>
|
||||
</slideout-panel>
|
||||
<div class="modal-overlay" v-show="showModal">
|
||||
<stake-component class="modal-card">
|
||||
<card-component class="modal-card">
|
||||
<div class="body">
|
||||
<div class="header">
|
||||
<img alt="logo" class="logo" src="/assets/img/vampir.png" />
|
||||
@@ -163,7 +163,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn btn-immortal" @click="showModal = false">Okay</div>
|
||||
</stake-component>
|
||||
</card-component>
|
||||
</div>
|
||||
<div class="main" :class="{ 'no-scroll': showPanel, mobile: isMobile }">
|
||||
<RouterView />
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
{
|
||||
"contractName": "Quoter",
|
||||
"contractAddress": "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_factory",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_WETH9",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "WETH9",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "factory",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "path",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "quoteExactInput",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "tokenIn",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "tokenOut",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint24",
|
||||
"name": "fee",
|
||||
"type": "uint24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountIn",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceLimitX96",
|
||||
"type": "uint160"
|
||||
}
|
||||
],
|
||||
"name": "quoteExactInputSingle",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "path",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "quoteExactOutput",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "tokenIn",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "tokenOut",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint24",
|
||||
"name": "fee",
|
||||
"type": "uint24"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountOut",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint160",
|
||||
"name": "sqrtPriceLimitX96",
|
||||
"type": "uint160"
|
||||
}
|
||||
],
|
||||
"name": "quoteExactOutputSingle",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amountIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "int256",
|
||||
"name": "amount0Delta",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"internalType": "int256",
|
||||
"name": "amount1Delta",
|
||||
"type": "int256"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "path",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "uniswapV3SwapCallback",
|
||||
"outputs": [],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<stake-component>
|
||||
<card-component>
|
||||
<template v-slot:headline> Unclaimed </template>
|
||||
<template v-slot:body>
|
||||
<token-name-price
|
||||
@@ -48,12 +48,12 @@
|
||||
<div class="small-text text-center">Sacrifice to earn $BLOOD</div>
|
||||
</template>
|
||||
</template>
|
||||
</stake-component>
|
||||
</card-component>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import StakeComponent from "@/components/StakeComponent.vue";
|
||||
import CardComponent from "@/components/CardComponent.vue";
|
||||
import StakeMenu from "@/components/StakeMenu.vue";
|
||||
import TokenNamePrice from "@/components/TokenNamePrice.vue";
|
||||
import TokenLogo from "@/components/TokenLogo.vue";
|
||||
|
||||
@@ -63,7 +63,6 @@ import { useTokenStore } from "@/stores/tokens";
|
||||
import Meme1Json from "@/assets/contracts/Meme1.json";
|
||||
import TokenNamePrice from "./TokenNamePrice.vue";
|
||||
import TokenLogo from "./TokenLogo.vue";
|
||||
import StakeComponent from "./StakeComponent.vue";
|
||||
import TokenInput from "./TokenInput.vue";
|
||||
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
|
||||
|
||||
@@ -155,6 +154,8 @@ async function connectWallet(connector) {
|
||||
border-radius: 8px
|
||||
.connected-header-logout
|
||||
margin-left: auto
|
||||
&:hover, &:active, &:focus
|
||||
cursor: pointer
|
||||
svg
|
||||
font-size: 25px
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
@input="
|
||||
($event) => {
|
||||
tokenNumber = $event.target.value;
|
||||
return getRewardsFor($event.target.value);
|
||||
return processChange($event.target.value);
|
||||
}
|
||||
"
|
||||
:logo="activeToken.logo"
|
||||
@@ -65,9 +65,7 @@
|
||||
<div class="sarcrifice-to-input">
|
||||
<div class="sacrifice-to-output">
|
||||
<div class="sacrifice-to-output-coin">$BLOOD</div>
|
||||
<div class="sacrifice-to-output-rewards header">
|
||||
{{ output }}
|
||||
</div>
|
||||
<div class="sacrifice-to-output-rewards header">{{ output.toFixed(5) }}</div>
|
||||
</div>
|
||||
<div class="sacrifice-logo">
|
||||
<img :src="activeToken.vamp?.logo" :alt="activeToken.vamp.name" />
|
||||
@@ -90,8 +88,6 @@
|
||||
<stake-component-v1 :variant="1" v-if="showStakingMenu">
|
||||
<template v-slot:headline> {{ null }}</template>
|
||||
</stake-component-v1>
|
||||
|
||||
<!-- <stake-component v-if="showStakingMenu" stakeonly class="variant1"></stake-component> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="sacrificed-info" v-if="state === 4">
|
||||
@@ -150,16 +146,17 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps, watch, inject, nextTick } from "vue";
|
||||
import { ref, defineProps, watch, inject, nextTick, onMounted, onBeforeUnmount, computed } from "vue";
|
||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
import { useUniswapStore } from "@/stores/uniswap";
|
||||
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
|
||||
import LoadingComponent from "@/components/LoadingComponent.vue";
|
||||
import TokenInput from "@/components/TokenInput.vue";
|
||||
|
||||
import { storeToRefs } from "pinia";
|
||||
import { waitForTransaction } from "@wagmi/core";
|
||||
import { waitForTransaction, readContract, watchBlockNumber } from "@wagmi/core";
|
||||
|
||||
import Helper from "@/utils/helper.js";
|
||||
const isMobile = inject("isMobile");
|
||||
@@ -173,6 +170,7 @@ const tokenStore = useTokenStore();
|
||||
const { activeToken } = storeToRefs(tokenStore);
|
||||
|
||||
const memeburnerStore = useMemeburnerStore();
|
||||
const uniswapStore = useUniswapStore();
|
||||
|
||||
const props = defineProps({
|
||||
data: Array,
|
||||
@@ -189,6 +187,7 @@ const props = defineProps({
|
||||
const tokenNumber = ref(null);
|
||||
const output = ref(0);
|
||||
const loading = ref(false);
|
||||
const blockEvent = ref(null);
|
||||
/**
|
||||
* state 0 enter amount
|
||||
* state 1 rdy to go
|
||||
@@ -200,12 +199,66 @@ const state = ref(0);
|
||||
const showStakingMenu = ref(false);
|
||||
const approvalData = ref(null);
|
||||
|
||||
// const processChange = Helper.debounce((e) => getRewardsFor(e.target.value));
|
||||
const processChange = Helper.debounce((value) => getRewardsFor(value));
|
||||
|
||||
onMounted(() => {
|
||||
blockEvent.value = watchBlockNumber(
|
||||
{
|
||||
listen: true,
|
||||
},
|
||||
async (blockNumber) => {
|
||||
console.log("blockNumber", blockNumber);
|
||||
await getRewardsFor(tokenNumber.value);
|
||||
// if (tokenNumber.value && tokenNumber.value > 0) {
|
||||
// console.log("tokenNumber.value", tokenNumber.value);
|
||||
// var quoteRewards = await uniswapStore.quoteExactInputSingle(
|
||||
// tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||
// );
|
||||
// const quoteRewards1 = Number(quoteRewards) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||
// console.log("quoteRewards", quoteRewards);
|
||||
// const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||
// tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||
// );
|
||||
// const rewardsForResult1 = Number(rewardsForResult) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||
// console.log("rewardsForResult1", rewardsForResult1);
|
||||
// console.log("quoteRewards1", quoteRewards1);
|
||||
// console.log("compare", quoteRewards1 * 0.995);
|
||||
// console.log("ifcompare1", quoteRewards1 * 0.995 > rewardsForResult1);
|
||||
// //return bigger number
|
||||
// if (quoteRewards1 * 0.995 > rewardsForResult1) {
|
||||
// //sacrificememe
|
||||
// output.value = quoteRewards1;
|
||||
// // const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
||||
// } else {
|
||||
// output.value = rewardsForResult1;
|
||||
// //sacrificeMemeAndBuyBLOOD
|
||||
// // const hash = await memeburnerStore.sacrificeMeme(tokenNumber.value);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
}
|
||||
);
|
||||
console.log("blockEvent.value", blockEvent.value);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
console.log("blockEventunwatch", blockEvent.value);
|
||||
blockEvent.value();
|
||||
});
|
||||
|
||||
async function sacrificeToken(amount) {
|
||||
try {
|
||||
state.value = 2;
|
||||
const hash = await memeburnerStore.sacrificeMeme(amount);
|
||||
const getRewards = await getRewardsFor(amount);
|
||||
console.log("getRewards123", getRewards);
|
||||
let hash = null;
|
||||
if (getRewards.variant === "sacrifice") {
|
||||
console.log("sacrifice");
|
||||
hash = await memeburnerStore.sacrificeMeme(amount);
|
||||
} else {
|
||||
console.log("buy");
|
||||
hash = await memeburnerStore.sacrificeMemeAndBuyBLOOD(amount);
|
||||
}
|
||||
console.log("hash", hash);
|
||||
state.value = 3;
|
||||
const data = await waitForTransaction({
|
||||
@@ -241,20 +294,86 @@ async function approveToken(amount) {
|
||||
}
|
||||
|
||||
async function getRewardsFor(value) {
|
||||
console.log("getRewardsFor", value);
|
||||
loading.value = true;
|
||||
let variant = null;
|
||||
let newOutput = 0;
|
||||
// if (activeToken.value.allowance >= value) {
|
||||
// const amountDecimal = BigInt(value * Math.pow(10, tokenStore.activeToken.decimals));
|
||||
|
||||
// const hash = await readContract({
|
||||
// address: memeburnerStore.contract.address,
|
||||
// abi: memeburnerStore.contract.abi,
|
||||
// functionName: "sacrificeMeme",
|
||||
// args: [tokenStore.activeToken.contractAddress, amountDecimal.toString(), 0],
|
||||
// account: walletStore.address,
|
||||
// });
|
||||
// console.log("hash", hash);
|
||||
// // var hash = await memeburnerStore.contract.simulate.sacrificeMeme([
|
||||
// // tokenStore.activeToken.contractAddress,
|
||||
// // amountDecimal.toString(),
|
||||
// // 0,
|
||||
// // ]);
|
||||
// // console.log("hash", hash);
|
||||
// // state.value = 3;
|
||||
// // const data = await waitForTransaction({
|
||||
// // hash: hash,
|
||||
// // });
|
||||
// // console.log("datahash", data);
|
||||
// }
|
||||
try {
|
||||
if (!value || isNaN(value)) {
|
||||
output.value = 0;
|
||||
state.value = 0;
|
||||
return;
|
||||
}
|
||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
||||
);
|
||||
console.log("blablub", {
|
||||
allowance: activeToken.value.allowance,
|
||||
tokenNumber: tokenNumber.value,
|
||||
connected: walletStore.connected,
|
||||
check: walletStore.connected && activeToken.value.allowance >= tokenNumber.value,
|
||||
ges: !walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value),
|
||||
});
|
||||
if (!walletStore.connected || (walletStore.connected && activeToken.value.allowance < tokenNumber.value)) {
|
||||
console.log("hier");
|
||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
||||
);
|
||||
console.log("rewardsForResult", rewardsForResult);
|
||||
const rewardsForResultNumber = Number(rewardsForResult) / Math.pow(10, tokenStore.activeToken.decimals);
|
||||
newOutput = rewardsForResultNumber;
|
||||
variant = "sacrifice";
|
||||
} else {
|
||||
console.log("hier1");
|
||||
console.log("activeToken.allowance", activeToken.value.allowance);
|
||||
const rewardsForResult = await memeburnerStore.getRewardFor(
|
||||
BigInt(value * Math.pow(10, activeToken.value.decimals))
|
||||
);
|
||||
console.log("rewardsForResult", rewardsForResult);
|
||||
var quoteRewards = await uniswapStore.quoteExactInputSingle(
|
||||
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
|
||||
);
|
||||
const rewardsForResultNumber = Number(rewardsForResult) / 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);
|
||||
state.value = 1;
|
||||
output.value = rewardsForResult / BigInt(Math.pow(10, tokenStore.memeToken.decimals));
|
||||
tokenStore.activeToken.rewards = output.value;
|
||||
return output.value;
|
||||
output.value = newOutput;
|
||||
tokenStore.activeToken.rewards = newOutput;
|
||||
return { ouput: newOutput, variant: variant };
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
} finally {
|
||||
@@ -264,7 +383,7 @@ async function getRewardsFor(value) {
|
||||
|
||||
async function addTokens(value) {
|
||||
tokenNumber.value = Number(tokenNumber.value) + Number(value);
|
||||
output.value = await getRewardsFor(parseInt(tokenNumber.value));
|
||||
output.value = await getRewardsFor(tokenNumber.value).output;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, useSlots } from "vue";
|
||||
import StakeComponent from "@/components/StakeComponent.vue";
|
||||
import CardComponent from "@/components/CardComponent.vue";
|
||||
import StakeMenu from "@/components/StakeMenu.vue";
|
||||
import TokenNamePrice from "@/components/TokenNamePrice.vue";
|
||||
import TokenLogo from "@/components/TokenLogo.vue";
|
||||
@@ -201,6 +201,8 @@ async function orderUnstake() {
|
||||
.token-price
|
||||
font-size: 24px
|
||||
.connected-stake-buttons
|
||||
display: flex
|
||||
gap: 8px
|
||||
.btn
|
||||
font-size: 18px
|
||||
.connected-stake-first-round
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
</template>
|
||||
<template v-else-if="getCurrentRoundData?.rewards_total > 0">
|
||||
<Transition name="smooth">
|
||||
<div class="connected-stake-buttons" v-show="!stakeMenu">
|
||||
<div class="stake-buttons" v-show="!stakeMenu">
|
||||
<div class="btn btn-immortal" @click="claimRewards">Claim</div>
|
||||
<div class="btn btn-immortal" @click="openStake">Stake</div>
|
||||
</div>
|
||||
@@ -165,7 +165,9 @@ async function claimRewards() {
|
||||
.stake-buttons
|
||||
display: flex
|
||||
text-align: center
|
||||
gap: 32px
|
||||
gap: 8px
|
||||
@media (min-width: 992px)
|
||||
gap: 32px
|
||||
div
|
||||
flex: 1 1 50%
|
||||
.rewards-wrapper
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
<template>
|
||||
<div class="token-input">
|
||||
<div class="sarcrifice-from-input">
|
||||
<input
|
||||
@input="emit('update:modelValue', $event.target.value)"
|
||||
v-model="props.modelValue"
|
||||
:placeholder="0"
|
||||
/>
|
||||
<input @input="emit('update:modelValue', $event.target.value)" :value="props.modelValue" :placeholder="0" />
|
||||
<div class="sacrifice-logo" v-if="props.logo">
|
||||
<img :src="props.logo" alt="vampir" />
|
||||
</div>
|
||||
@@ -19,7 +15,7 @@
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
modelValue: Number,
|
||||
modelValue: [String, Number],
|
||||
logo: String,
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
name: String,
|
||||
price: Number,
|
||||
price: [Number, String],
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
+18
-13
@@ -3,6 +3,7 @@ import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
||||
import { useUniswapStore } from "@/stores/uniswap";
|
||||
import { useRoundsStore } from "@/stores/rounds";
|
||||
|
||||
import { createApp } from 'vue'
|
||||
@@ -85,6 +86,7 @@ const tokenStore = useTokenStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
const uniswapStore = useUniswapStore();
|
||||
|
||||
|
||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||
@@ -179,7 +181,8 @@ watchAccount(async (account) => {
|
||||
await memeBurnerStore.init();
|
||||
await tokenStore.initV2();
|
||||
await rewardLockerStore.init();
|
||||
await walletStore.loadWalletData();
|
||||
await walletStore.loadWalletData();
|
||||
await uniswapStore.init();
|
||||
} else {
|
||||
walletStore.address = null;
|
||||
walletStore.connected = false;
|
||||
@@ -193,18 +196,20 @@ watchNetwork((network) => {
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// 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();
|
||||
await tokenStore.initV2();
|
||||
|
||||
@@ -32,7 +32,9 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
const rewards = await this.contract.read.getRewardForSacrifice([
|
||||
tokenStore.activeToken.contractAddress,
|
||||
amount,
|
||||
]);
|
||||
]);
|
||||
console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress);
|
||||
console.log("amount", amount);
|
||||
console.log("rewards", rewards);
|
||||
return rewards;
|
||||
},
|
||||
@@ -97,9 +99,27 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
async sacrificeMemeAndBuyBLOOD(amount) {
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
|
||||
var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([
|
||||
tokenStore.activeToken.contractAddress,
|
||||
amountDecimal.toString(),
|
||||
0,
|
||||
]);
|
||||
return hash;
|
||||
},
|
||||
async getGoalInBLOOD(roundNumber) {
|
||||
return await this.contract.read.getGoalInBLOOD([roundNumber]);
|
||||
},
|
||||
},
|
||||
async getAmountETHBase(amount) {
|
||||
console.log("getAmountETHBase");
|
||||
const tokenStore = useTokenStore();
|
||||
return await this.contract.read.getAmountETHBase([tokenStore.activeToken.contract.address, amount, true]);
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ export const useTokenStore = defineStore("token", {
|
||||
if (walletStore.connected) {
|
||||
//TODO, wenn connected, dann all diese Daten laden?
|
||||
this.activeToken.balance = await walletStore.getTokenBalance(token);
|
||||
this.activeToken.allowance = await this.allowance();
|
||||
this.activeToken.allowance = Number(await this.allowance());
|
||||
}
|
||||
},
|
||||
async allowance() {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
import QuoterJson from "@/assets/contracts/Quoter.json";
|
||||
import UniswapPoolJson from "@/assets/contracts/UniswapPool.json";
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
|
||||
import { getContract, multicall } from "@wagmi/core";
|
||||
|
||||
export const useUniswapStore = defineStore("uniswap", {
|
||||
state: () => ({
|
||||
quoateV3Contract: {},
|
||||
quoateV2Contract: {},
|
||||
uniswapPoolContract: {},
|
||||
poolData: {
|
||||
token0: null,
|
||||
token1: null,
|
||||
fee: null,
|
||||
},
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
init() {
|
||||
console.log("init uniswap");
|
||||
const walletStore = useWalletStoreV2();
|
||||
|
||||
this.quoateV3Contract = getContract({
|
||||
address: QuoterJson.contractAddress,
|
||||
abi: QuoterJson.abi,
|
||||
walletClient: walletStore.walletClient || walletStore.publicClient,
|
||||
});
|
||||
|
||||
this.uniswapPoolContract = getContract({
|
||||
address: UniswapPoolJson.contractAddress,
|
||||
abi: UniswapPoolJson.abi,
|
||||
walletClient: walletStore.walletClient || walletStore.publicClient,
|
||||
});
|
||||
|
||||
this.getPoolData();
|
||||
},
|
||||
|
||||
async quoteExactInputSingle(amount) {
|
||||
console.log("quoteExactInputSingle");
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount);
|
||||
console.log("123", {
|
||||
token1: this.poolData.token1,
|
||||
token0: this.poolData.token0,
|
||||
fee: this.poolData.fee,
|
||||
amountEthBase,
|
||||
pricelimit: 0, //sqrtPriceLimitX96
|
||||
});
|
||||
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
|
||||
this.poolData.token1,
|
||||
this.poolData.token0,
|
||||
this.poolData.fee,
|
||||
amountEthBase,
|
||||
0, //sqrtPriceLimitX96
|
||||
]);
|
||||
return quotedAmountOut;
|
||||
},
|
||||
async getPoolData() {
|
||||
console.log("getPoolData");
|
||||
const contracts = [];
|
||||
contracts.push(
|
||||
{
|
||||
...this.uniswapPoolContract,
|
||||
functionName: "token0",
|
||||
},
|
||||
{
|
||||
...this.uniswapPoolContract,
|
||||
functionName: "token1",
|
||||
},
|
||||
{
|
||||
...this.uniswapPoolContract,
|
||||
functionName: "fee",
|
||||
}
|
||||
);
|
||||
const data = await multicall({
|
||||
contracts,
|
||||
});
|
||||
this.poolData.token0 = data[0].result;
|
||||
this.poolData.token1 = data[1].result;
|
||||
this.poolData.fee = data[2].result;
|
||||
},
|
||||
},
|
||||
});
|
||||
+66
-54
@@ -7,67 +7,67 @@
|
||||
<div class="mid-mid-text">{{ getAddressShortName(walletStore.address) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="total-rewards-wrapper">
|
||||
<div class="total-rewards-headline mid-text text-center">Total Rewards</div>
|
||||
<claim-component></claim-component>
|
||||
</div>
|
||||
<template v-if="!isMobile">
|
||||
<stake-component-v1 :variant="2"> </stake-component-v1>
|
||||
<template v-if="!walletStore.connected">
|
||||
<div class="profile-not-connected low-mid-text">
|
||||
Connect your wallet to see your profile.
|
||||
<div class="btn btn-immortal" @click="showPanel = true">Connect</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<stake-component-v1> </stake-component-v1>
|
||||
</template>
|
||||
<div class="profile-stake">
|
||||
<!-- <stake-component>
|
||||
<template v-slot:headline> Staked </template>
|
||||
<template v-slot:subheadline>
|
||||
Stake for a 25% bonus on your sacrifice. Upper limit is your stake.
|
||||
</template>
|
||||
</stake-component> -->
|
||||
</div>
|
||||
|
||||
<div class="most-sacrificed-wrapper" v-if="false">
|
||||
<div class="most-sacrificed-inner">
|
||||
<div class="most-sacrificed-left">
|
||||
<div class="most-sacrificed-header">Bloodline Clan</div>
|
||||
<div class="most-sacrificed-subheader">Most sacrificed</div>
|
||||
</div>
|
||||
<div class="most-sacrificed-right">
|
||||
<div class="most-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/pepevamp.png" alt="" />
|
||||
</div>
|
||||
<div class="most-sacrificed-coin-name">$PEPE</div>
|
||||
</div>
|
||||
<div class="total-rewards-wrapper">
|
||||
<div class="total-rewards-headline mid-text text-center">Total Rewards</div>
|
||||
<claim-component></claim-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-wrapper" v-if="false">
|
||||
<div class="total-sacrificed-inner">
|
||||
<div class="total-sacrificed-header">Total Sacrifice</div>
|
||||
<div class="total-sacrificed-coins">
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">1,2b</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<template v-if="!isMobile">
|
||||
<stake-component-v1 :variant="2"> </stake-component-v1>
|
||||
</template>
|
||||
<template v-else>
|
||||
<stake-component-v1> </stake-component-v1>
|
||||
</template>
|
||||
|
||||
<div class="most-sacrificed-wrapper" v-if="false">
|
||||
<div class="most-sacrificed-inner">
|
||||
<div class="most-sacrificed-left">
|
||||
<div class="most-sacrificed-header">Bloodline Clan</div>
|
||||
<div class="most-sacrificed-subheader">Most sacrificed</div>
|
||||
</div>
|
||||
<div class="most-sacrificed-right">
|
||||
<div class="most-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/pepevamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$PEPE</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">139m</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/shibvamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$SHIB</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">0</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/elonvamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$ELON</div>
|
||||
<div class="most-sacrificed-coin-name">$PEPE</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-wrapper" v-if="false">
|
||||
<div class="total-sacrificed-inner">
|
||||
<div class="total-sacrificed-header">Total Sacrifice</div>
|
||||
<div class="total-sacrificed-coins">
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">1,2b</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/pepevamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$PEPE</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">139m</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/shibvamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$SHIB</div>
|
||||
</div>
|
||||
<div class="total-sacrificed-coin">
|
||||
<div class="total-sacrificed-coin-amount">0</div>
|
||||
<div class="total-sacrificed-coin-logo">
|
||||
<img src="/assets/img/token/elonvamp.png" alt="" />
|
||||
</div>
|
||||
<div class="total-sacrificed-coin-name">$ELON</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- <div class="cycle-wrapper">
|
||||
<div class="cycle-inner">
|
||||
@@ -168,7 +168,7 @@ import { useRoundsStore } from "@/stores/rounds";
|
||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
|
||||
import { getblocky, getAddressShortName } from "@/helper/helper.js";
|
||||
import StakeComponent from "@/components/StakeComponent.vue";
|
||||
import CardComponent from "@/components/CardComponent.vue";
|
||||
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
|
||||
import ClaimComponent from "@/components/ClaimComponent.vue";
|
||||
|
||||
@@ -180,6 +180,7 @@ const walletStore = useWalletStoreV2();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const isMobile = inject("isMobile");
|
||||
const showPanel = inject("showPanel");
|
||||
|
||||
const activeRound = ref(null);
|
||||
const openCycleElement = ref(false);
|
||||
@@ -421,4 +422,15 @@ const rounds = computed(() => {
|
||||
.arrow
|
||||
width: 14px
|
||||
padding: 0 16px
|
||||
|
||||
|
||||
|
||||
.profile-not-connected
|
||||
border-radius: 16px
|
||||
padding: 16px
|
||||
gap: 16px
|
||||
display: flex
|
||||
flex-direction: column
|
||||
text-align: center
|
||||
background: var(--darkgrey, #202020)
|
||||
</style>
|
||||
|
||||
+79
-1
@@ -9,6 +9,7 @@
|
||||
<button @click="">unstake</button>
|
||||
<button @click="fetchBalance">fetchBalance</button>
|
||||
<button @click="claimView">claimview</button>
|
||||
<button @click="testQuoter(token0, token1, fee)">quoater</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -18,11 +19,14 @@ import Meme1Json from "@/assets/contracts/Meme1.json";
|
||||
import Meme2Json from "@/assets/contracts/Meme2.json";
|
||||
import MemeBurnerJson from "@/assets/contracts/Bloodline.json";
|
||||
import RewardLockerJson from "@/assets/contracts/RewardLocker.json";
|
||||
import QuoterJson from "@/assets/contracts/Quoter.json";
|
||||
import UniswapPoolJson from "@/assets/contracts/UniswapPool.json";
|
||||
import MemeAltarJson from "@/assets/contracts/MemeAltar.json";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
import { signTypedData } from "@wagmi/core";
|
||||
import { signTypedData, getContract } from "@wagmi/core";
|
||||
|
||||
const tokenStore = useTokenStore();
|
||||
const walletV2Store = useWalletStoreV2();
|
||||
@@ -39,8 +43,50 @@ const contractMeme1 = ref(null);
|
||||
const contractBurner = ref(null);
|
||||
const contractBloodline = ref(null);
|
||||
const rewardlocker = ref(null);
|
||||
const contractQuoter = ref(null);
|
||||
const poolContract = ref(null);
|
||||
const memeAltarContract = ref(null);
|
||||
const token0 = ref(null);
|
||||
const token1 = ref(null);
|
||||
const fee = ref(null);
|
||||
const amountETHBase = ref(null);
|
||||
const amount = 100 * Math.pow(10, 18);
|
||||
|
||||
onMounted(async () => {
|
||||
contractQuoter.value = getContract({
|
||||
address: QuoterJson.contractAddress,
|
||||
abi: QuoterJson.abi,
|
||||
walletClient: walletV2Store.walletClient || walletV2Store.publicClient,
|
||||
});
|
||||
|
||||
poolContract.value = getContract({
|
||||
address: UniswapPoolJson.contractAddress,
|
||||
abi: UniswapPoolJson.abi,
|
||||
walletClient: walletV2Store.walletClient || walletV2Store.publicClient,
|
||||
});
|
||||
|
||||
memeAltarContract.value = getContract({
|
||||
address: MemeAltarJson.contractAddress,
|
||||
abi: MemeAltarJson.abi,
|
||||
walletClient: walletV2Store.walletClient || walletV2Store.publicClient,
|
||||
});
|
||||
console.log("poolContract.value", poolContract.value);
|
||||
|
||||
token0.value = await poolContract.value.read.token0();
|
||||
token1.value = await poolContract.value.read.token1();
|
||||
fee.value = await poolContract.value.read.fee();
|
||||
|
||||
console.log("input-amountEthBASE", {
|
||||
memeToSacrifice: "0x4435ABC578136e2Eca50b5EFf950F17CAF42485b",
|
||||
amountToSacrifice: amount,
|
||||
roundParticipant: true,
|
||||
});
|
||||
amountETHBase.value = await memeAltarContract.value.read.getAmountETHBase([
|
||||
"0x4435ABC578136e2Eca50b5EFf950F17CAF42485b",
|
||||
amount,
|
||||
true,
|
||||
]);
|
||||
console.log("amountETHBase", amountETHBase.value);
|
||||
// web3.value = new Web3(window.ethereum);
|
||||
// // const contract = new web3.value.eth.Contract(Meme1Json.abi, Meme1Json.contractAddress);
|
||||
// console.log("web3", web3.value);
|
||||
@@ -53,6 +99,38 @@ onMounted(async () => {
|
||||
// );
|
||||
});
|
||||
|
||||
async function testQuoter(token0, token1, fee) {
|
||||
console.log("inputQuote", {
|
||||
token1: token1,
|
||||
token0: token0,
|
||||
fee: fee,
|
||||
amountETHBase: amountETHBase.value,
|
||||
sqrtPriceLimitX96: 0,
|
||||
});
|
||||
const quotedAmountOut = await contractQuoter.value.read.quoteExactInputSingle([
|
||||
token1,
|
||||
token0,
|
||||
fee,
|
||||
amountETHBase.value,
|
||||
0,
|
||||
]);
|
||||
//rewardsUniswap3
|
||||
//if getrewardforsacrifice 5% less than quoater amount
|
||||
//buy below issuanceprice
|
||||
//0 should be the issuanceprice (memealtar.issuanceprice)
|
||||
//if input 0 not allow sacrifice
|
||||
//before allowance just compare quoater with getrewardforsacrifice
|
||||
//after allowance eth_call sacrificememe and sacrificebuyblood
|
||||
//if error quoater --> usesacrificememe
|
||||
|
||||
//on sacrificememe calculate minEthAmount )
|
||||
//on bloodbuy calculate minBloodamount (quoatedAmount * 0,995) - 100
|
||||
//0,995 Schlupf (siehe app.uniswap (0,5%))
|
||||
//if the price move more like this Schlupf (0,5%), dann revert
|
||||
//uniswapv2 quoater for sacrificememe
|
||||
console.log("quotedAmountOut", quotedAmountOut);
|
||||
}
|
||||
|
||||
async function claimView() {
|
||||
var resultStake = await rewardLockerStore.contract.read.claim([[0, 1, 2]]);
|
||||
console.log("resultStake", resultStake);
|
||||
|
||||
Reference in New Issue
Block a user