comments + contract update +

smaller design issues
This commit is contained in:
EmberSpirit
2023-10-12 20:01:11 +02:00
parent 68cd720c59
commit b5c6f8af33
37 changed files with 714 additions and 1480 deletions
-12
View File
@@ -1,15 +1,3 @@
# vue-ethereum2
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 11 KiB

+14 -69
View File
@@ -6,59 +6,30 @@ import { useRoute, useRouter } from "vue-router";
import Navbar from "./components/Navbar.vue";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useTokenStore } from "@/stores/tokens";
import { useContractStore } from "@/stores/contracts";
import { useSacrificeStore } from "@/stores/sacrifice";
import { useMemeburnerStore } from "@/stores/memeburner";
import { useRewardLockerStore } from "@/stores/rewardlocker";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import SlideoutPanel from "./components/SlideoutPanel.vue";
import ConnectWallet from "./components/ConnectWallet.vue";
import CardComponent from "@/components/CardComponent.vue";
import {
watchAccount,
watchNetwork,
watchContractEvent,
watchWalletClient,
watchPublicClient,
getAccount,
getNetwork,
getPublicClient,
getWalletClient,
} from "@wagmi/core";
import { getNetwork } from "@wagmi/core";
const tokenStore = useTokenStore();
const contractStore = useContractStore();
const memeBurnerStore = useMemeburnerStore();
const rewardLockerStore = useRewardLockerStore();
const roundsStore = useRoundsStore();
const walletStore = useWalletStoreV2();
const { memeBurner, token } = storeToRefs(tokenStore);
const { list } = storeToRefs(contractStore);
const isMobile = ref(false);
const showPanel = ref(false);
const eventWatch = ref(null);
const netWorkEvent = ref(null);
const memeSacrificedEvent = ref(null);
const clientClientEvent = ref(null);
const router = useRouter();
const route = useRoute();
isMobile.value = isMobileFunc();
onUnmounted(() => {
window.removeEventListener("resize", handleWindowSizeChange);
eventWatch.value();
netWorkEvent.value();
memeSacrificedEvent.value();
clientClientEvent.value();
console.log("unsubscribe");
});
watch(showPanel, (newValue, oldValue) => {
console.log("document.body", document.body);
console.log("newValue", newValue);
if (newValue) {
document.body.classList.add("sideoutpanel-open");
} else {
@@ -71,10 +42,7 @@ const handleWindowSizeChange = () => {
// your code
};
function showPanelTest(bla) {
console.log("bla", bla);
}
//to have mobile breakpoint not only on sass side
function isMobileFunc() {
if (screen.width <= 760) {
return true;
@@ -84,8 +52,6 @@ function isMobileFunc() {
}
function changeRoute(name) {
console.log("route", route);
console.log("router", router);
router.push({
name: name,
});
@@ -94,44 +60,23 @@ provide("isMobile", isMobile);
provide("showPanel", showPanel);
onMounted(async () => {
console.log("onmounted");
window.addEventListener("resize", handleWindowSizeChange);
handleWindowSizeChange();
const showPanel = ref(false);
const eventWatch = ref(null);
const netWorkEvent = ref(null);
const memeSacrificedEvent = ref(null);
const clientClientEvent = ref(null);
console.log("beforeEach");
const tokenStore = useTokenStore();
const memeBurnerStore = useMemeburnerStore();
const rewardLockerStore = useRewardLockerStore();
const roundsStore = useRoundsStore();
const cycleStore = useCycleStore();
const walletStore = useWalletStoreV2();
walletStore.initialized = true;
// await walletStore.init();
// await tokenStore.initV2();
// await memeBurnerStore.init();
// await rewardLockerStore.init();
// await memeBurnerStore.init();
console.log("init router");
console.log("roundsStore.currentRound", roundsStore.currentRound);
if (!roundsStore.currentRound) {
roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound());
console.log("roundsStore.currentRound", roundsStore.currentRound);
roundsStore.activeRound = roundsStore.currentRound;
//check if it is necessary
if (!cycleStore.currentCycle) {
cycleStore.currentCycle = parseInt(await memeBurnerStore.getCurrentCycle());
console.log("cycleStore.currentCycle", cycleStore.currentCycle);
cycleStore.activeCycle = cycleStore.currentCycle;
}
const { chain, chains } = getNetwork();
console.log("chain", chain?.id);
console.log("chains", chains);
await roundsStore.fillRound(roundsStore.activeRound);
// await walletStore.loadWalletData();
// initContracts
//Memeburner Contract
await cycleStore.fillCycle(cycleStore.activeCycle);
});
</script>
@@ -221,7 +166,7 @@ onMounted(async () => {
margin-top: 82px
padding: 24px 0
@media (min-width: 992px)
margin-top: 96px
margin-top: 80px
padding: 80px 0
&.mobile
&.no-scroll
@@ -295,7 +240,7 @@ body::-webkit-scrollbar-track
background: #202020
body::-webkit-scrollbar-thumb
background: #202020
background: grey
body:hover::-webkit-scrollbar-thumb
background: grey
+1 -1
View File
@@ -1,6 +1,6 @@
{
"contractName": "Bloodline",
"contractAddress": "0xBd6bB82108D5F27E8A8f081723408bF26d665a8c",
"contractAddress": "0xB7d11da1922328A10cCb357F571125151e558aFe",
"abi": [
{
"inputs": [
+37 -22
View File
@@ -1,6 +1,6 @@
{
"contractName": "LiquidityOwner",
"contractAddress": "0xEb898F92F7db3bbF807513C847bfDeE846E1b5Ff",
"contractAddress": "0x6AE9254705216A0d96A4A8d601a9DDB94C234859",
"abi": [
{
"inputs": [
@@ -28,6 +28,11 @@
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "CallbackCanBeCalledOnlyByPool",
"type": "error"
},
{
"inputs": [],
"name": "CurrentPriceDisallowsToProvide",
@@ -38,11 +43,21 @@
"name": "NothingToProvide",
"type": "error"
},
{
"inputs": [],
"name": "OnlyMemeAltar",
"type": "error"
},
{
"inputs": [],
"name": "ProjectAlive",
"type": "error"
},
{
"inputs": [],
"name": "WrongSideOfPrice",
"type": "error"
},
{
"anonymous": false,
"inputs": [
@@ -167,7 +182,7 @@
"type": "int24"
}
],
"name": "collectDeveloperFees",
"name": "collectPositionFees",
"outputs": [
{
"internalType": "uint128",
@@ -255,7 +270,7 @@
},
{
"inputs": [],
"name": "previousBLDTotalSupply",
"name": "previousBDLTotalSupply",
"outputs": [
{
"internalType": "uint128",
@@ -266,6 +281,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint112",
"name": "collectedEthInCycle",
"type": "uint112"
}
],
"name": "provideLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "issuancePrice",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
@@ -313,25 +347,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint112",
"name": "collectedEthInRound",
"type": "uint112"
}
],
"name": "triggerRoundCompleted",
"outputs": [
{
"internalType": "uint256",
"name": "issuancePrice",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
+88 -63
View File
@@ -1,6 +1,6 @@
{
"contractName": "MemeAltar",
"contractAddress": "0x9fA80C0A942016A0a246402e97d30562CF93f5AE",
"contractAddress": "0x9612054A85502f2484c93C84eeCd14F65C6E4941",
"abi": [
{
"inputs": [
@@ -48,6 +48,11 @@
"name": "ArraysHaveDifferentLength",
"type": "error"
},
{
"inputs": [],
"name": "CycleCompletedRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "InsufficientOutputAmount",
@@ -65,7 +70,17 @@
},
{
"inputs": [],
"name": "NextRoundRegistrationFailed",
"name": "NextCycleRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "NotAdmin",
"type": "error"
},
{
"inputs": [],
"name": "NotExactInput",
"type": "error"
},
{
@@ -80,7 +95,12 @@
},
{
"inputs": [],
"name": "RoundCompletedRegistrationFailed",
"name": "SwapCallbackCanBeCalledOnlyByPool",
"type": "error"
},
{
"inputs": [],
"name": "SwapWithinZeroLiquidity",
"type": "error"
},
{
@@ -93,6 +113,11 @@
"name": "TokenIsNotInSacrificableList",
"type": "error"
},
{
"inputs": [],
"name": "TooLittleReceived",
"type": "error"
},
{
"inputs": [
{
@@ -110,7 +135,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -135,7 +160,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -237,11 +262,11 @@
{
"indexed": true,
"internalType": "uint256",
"name": "newDefaultGoal",
"name": "newDurationLimit",
"type": "uint256"
}
],
"name": "NewDefaultRoundGoal",
"name": "NewCycleDurationLimit",
"type": "event"
},
{
@@ -250,11 +275,11 @@
{
"indexed": true,
"internalType": "uint256",
"name": "newDurationLimit",
"name": "newDefaultGoal",
"type": "uint256"
}
],
"name": "NewRoundDurationLimit",
"name": "NewDefaultCycleGoal",
"type": "event"
},
{
@@ -335,12 +360,12 @@
{
"inputs": [
{
"internalType": "uint112",
"name": "newDefaultGoal",
"type": "uint112"
"internalType": "uint32",
"name": "newDurationLimit",
"type": "uint32"
}
],
"name": "adjustDefaultGoal",
"name": "adjustCycleDurationLimit",
"outputs": [
{
"internalType": "bool",
@@ -354,12 +379,12 @@
{
"inputs": [
{
"internalType": "uint32",
"name": "newDurationLimit",
"type": "uint32"
"internalType": "uint112",
"name": "newDefaultGoal",
"type": "uint112"
}
],
"name": "adjustRoundDurationLimit",
"name": "adjustDefaultGoal",
"outputs": [
{
"internalType": "bool",
@@ -436,7 +461,7 @@
},
{
"inputs": [],
"name": "currentRound",
"name": "currentCycle",
"outputs": [
{
"internalType": "uint112",
@@ -447,6 +472,48 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "cycleDurationLimit",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint112",
"name": "",
"type": "uint112"
}
],
"name": "cycles",
"outputs": [
{
"internalType": "uint112",
"name": "goal",
"type": "uint112"
},
{
"internalType": "uint112",
"name": "ethUsedToBuy",
"type": "uint112"
},
{
"internalType": "uint32",
"name": "expirationTimestamp",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "defaultGoal",
@@ -474,7 +541,7 @@
},
{
"internalType": "bool",
"name": "roundParticipant",
"name": "cycleParticipant",
"type": "bool"
}
],
@@ -517,7 +584,7 @@
"inputs": [
{
"internalType": "uint112",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint112"
}
],
@@ -565,7 +632,7 @@
"inputs": [
{
"internalType": "uint112",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint112"
},
{
@@ -686,48 +753,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "roundDurationLimit",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint112",
"name": "",
"type": "uint112"
}
],
"name": "rounds",
"outputs": [
{
"internalType": "uint112",
"name": "goal",
"type": "uint112"
},
{
"internalType": "uint112",
"name": "ethUsedToBuy",
"type": "uint112"
},
{
"internalType": "uint32",
"name": "expirationTimestamp",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
+122 -112
View File
@@ -1,6 +1,6 @@
{
"contractName": "RewardLocker",
"contractAddress": "0xC21568120adc35AB0aA7460A4A5E1C3D4f845269",
"contractAddress": "0x216d1477B7686a0388A8881061FAc9c66469fC9c",
"abi": [
{
"inputs": [
@@ -20,7 +20,17 @@
},
{
"inputs": [],
"name": "RoundIsNotCompletedYet",
"name": "CycleIsNotCompletedYet",
"type": "error"
},
{
"inputs": [],
"name": "NotMemeAltar",
"type": "error"
},
{
"inputs": [],
"name": "StakePartMoreThan100Percent",
"type": "error"
},
{
@@ -52,6 +62,44 @@
"name": "ClaimedReward",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "index",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "winnerToken",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "totalCycleRewards",
"type": "uint256"
}
],
"name": "CycleCompleted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "CycleStarted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
@@ -64,7 +112,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "stakedRound",
"name": "stakedCycle",
"type": "uint256"
},
{
@@ -89,7 +137,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "unstakeRound",
"name": "unstakeCycle",
"type": "uint256"
},
{
@@ -114,7 +162,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -133,44 +181,6 @@
"name": "Rewarded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "index",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "winnerToken",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "totalRoundRewards",
"type": "uint256"
}
],
"name": "RoundCompleted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "RoundStarted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
@@ -183,7 +193,7 @@
{
"indexed": true,
"internalType": "uint256",
"name": "unstakeRound",
"name": "unstakeCycle",
"type": "uint256"
},
{
@@ -213,7 +223,7 @@
"inputs": [
{
"internalType": "uint256[]",
"name": "_rounds",
"name": "_cycles",
"type": "uint256[]"
},
{
@@ -237,7 +247,7 @@
"inputs": [
{
"internalType": "uint256[]",
"name": "_rounds",
"name": "_cycles",
"type": "uint256[]"
}
],
@@ -256,7 +266,7 @@
"inputs": [
{
"internalType": "uint256[]",
"name": "_rounds",
"name": "_cycles",
"type": "uint256[]"
},
{
@@ -276,6 +286,35 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "cycles",
"outputs": [
{
"internalType": "uint32",
"name": "cycleCompletedTimestamp",
"type": "uint32"
},
{
"internalType": "uint224",
"name": "totalSacrificeCompetitionRewards",
"type": "uint224"
},
{
"internalType": "uint256",
"name": "totalStakeRewards",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -285,7 +324,7 @@
},
{
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -314,7 +353,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
}
],
@@ -333,7 +372,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -362,7 +401,7 @@
},
{
"internalType": "uint256[]",
"name": "roundNumbers",
"name": "cycleNumbers",
"type": "uint256[]"
}
],
@@ -386,7 +425,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "roundNumber",
"name": "cycleNumber",
"type": "uint256"
},
{
@@ -426,7 +465,7 @@
},
{
"inputs": [],
"name": "lastCompletedRound",
"name": "lastCompletedCycle",
"outputs": [
{
"internalType": "uint256",
@@ -456,7 +495,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "unstakeRound",
"name": "unstakeCycle",
"type": "uint256"
}
],
@@ -467,7 +506,31 @@
"inputs": [
{
"internalType": "uint256",
"name": "roundIndex",
"name": "cycleIndex",
"type": "uint256"
},
{
"internalType": "address",
"name": "winnerToken",
"type": "address"
}
],
"name": "registerCycleCompleted",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "cycleIndex",
"type": "uint256"
},
{
@@ -476,7 +539,7 @@
"type": "address[]"
}
],
"name": "registerNextRound",
"name": "registerNextCycle",
"outputs": [
{
"internalType": "bool",
@@ -516,59 +579,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "roundIndex",
"type": "uint256"
},
{
"internalType": "address",
"name": "winnerToken",
"type": "address"
}
],
"name": "registerRoundCompleted",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "rounds",
"outputs": [
{
"internalType": "uint32",
"name": "roundCompletedTimestamp",
"type": "uint32"
},
{
"internalType": "uint224",
"name": "totalSacrificeCompetitionRewards",
"type": "uint224"
},
{
"internalType": "uint256",
"name": "totalStakeRewards",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -578,7 +588,7 @@
},
{
"internalType": "uint256[]",
"name": "_rounds",
"name": "_cycles",
"type": "uint256[]"
},
{
@@ -646,7 +656,7 @@
"inputs": [
{
"internalType": "uint256[]",
"name": "_rounds",
"name": "_cycles",
"type": "uint256[]"
},
{
@@ -708,7 +718,7 @@
"inputs": [
{
"internalType": "uint256",
"name": "unstakeRound",
"name": "unstakeCycle",
"type": "uint256"
}
],
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -97,8 +97,8 @@ $button-background-color: $black
font-style: normal
font-weight: 400
line-height: normal
@media (min-width: 992px)
font-size: 30px
// @media (min-width: 992px)
// font-size: 30px
// :root
// --font-size-text: 16px
+14 -33
View File
@@ -20,7 +20,12 @@
<swiper-slide class="blood-chart-element" v-for="coin in token" :key="coin.name">
<div class="blood-chart-element-header">
<div class="blood-chart-coin">
<img :src="getImageUrl(coin.vamplogo)" alt="logo" />
<template v-if="cycleStore.getCycleWinner.contractAddress === coin.contractAddress">
<img :src="coin.vampwinner2" alt="logo" />
</template>
<template v-else>
<img :src="coin.vamplogo" alt="logo" />
</template>
</div>
<div class="blood-chart-coin-title low-mid-text">{{ coin.name }}</div>
</div>
@@ -67,8 +72,7 @@
</div>
<div class="blood-chart-element-footer">
<div class="blood-chart-amount">
<!-- {{ compactNumber(coin.amount) }} -->
{{ coin.amountInBLD.toFixed(2) }}
{{ formatNumber(coin.amountInBLD) }}
</div>
<div>$BLOOD</div>
</div>
@@ -91,7 +95,9 @@
<script setup>
import { computed, ref, inject, onMounted } from "vue";
import { getPercentage, compactNumber } from "@/helper/helper.js";
import { getPercentage, compactNumber, formatNumber } from "@/helper/helper.js";
import { useCycleStore } from "@/stores/cycles";
import { useMemeburnerStore } from "@/stores/memeburner";
import { Swiper, SwiperSlide } from "swiper/vue";
@@ -100,8 +106,7 @@ import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
// import required modules
const memeBurnerStore = useMemeburnerStore();
const cycleStore = useCycleStore();
const props = defineProps({
data: Object,
@@ -111,38 +116,15 @@ onMounted(() => {
console.log("bloodchart-data", props.data);
});
const isMobile = inject("isMobile");
const swiperInstance = ref();
function onSwiper(swiper) {
swiperInstance.value = swiper;
}
function getImageUrl(url) {
return new URL(url, import.meta.url).href;
}
const token = computed(() => props.data?.token);
// const dataPoints = [
// {
// name: "$PEPE",
// percentage: 62.2,
// icon: "/assets/img/token/pepevamp.png",
// },
// {
// name: "$SHIB",
// percentage: 31.2,
// icon: "/assets/img/token/shibvamp.png",
// },
// {
// name: "$ELON",
// percentage: 54.5,
// icon: "/assets/img/token/elonvamp.png",
// },
// ];
//start with visual 5% of the filled bar, because otherwise the percentage number is not visible
function getPercentageBloodChart(amount, goal) {
let returnNumber = 5;
if ((Number(amount) / Number(goal)) * 100 < 5) {
@@ -183,7 +165,6 @@ function getPercentageBloodChart(amount, goal) {
.blood-chart-element-header
flex: 0 0 100px
.blood-chart-coin
border-radius: 80px
margin-left: auto
margin-right: auto
position: relative
@@ -192,8 +173,8 @@ function getPercentageBloodChart(amount, goal) {
height: 80px
width: 80px
@media (min-width: 992px)
height: 60px
width: 60px
height: 72px
width: 72px
img
height: 100%
width: 100%
+1 -24
View File
@@ -1,4 +1,3 @@
<!-- zukünftig card component -->
<template>
<div
class="connected-stake bloodline-border card"
@@ -21,14 +20,6 @@
</div>
<slot name="actions"></slot>
<slot></slot>
<!-- <div class="connected-stake-buttons" v-if="!stakeMenu">
<div class="btn btn-immortal" @click="openStake">Stake</div>
<div v-if="walletStore.memeToken?.staked === 0 && !stakeonly" class="btn btn-immortal btn--disabled">
Unstake
</div>
<div v-else-if="!stakeonly" class="btn btn-immortal" @click="openUnstake">Unstake</div>
</div> -->
</div>
</template>
@@ -38,8 +29,6 @@ import { useWalletStoreV2 } from "@/stores/walletV2";
import { ref } from "vue";
import { useSlots } from "vue";
const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore();
const slots = useSlots();
const props = defineProps({
@@ -54,19 +43,6 @@ const props = defineProps({
default: false,
},
});
const stakeMenu = ref(false);
const stake = ref(null);
function openStake() {
stake.value = true;
stakeMenu.value = true;
}
function openUnstake() {
stake.value = false;
stakeMenu.value = true;
}
</script>
<style lang="sass">
@@ -100,6 +76,7 @@ function openUnstake() {
display: flex
text-align: center
gap: 16px
justify-content: center
// div
// flex: 1 1 50%
</style>
+11 -48
View File
@@ -37,7 +37,7 @@
<div
class="btn btn-immortal stake-button"
v-else-if="stateClaimComp === 1"
@click="stakeAndClaimAllRounds"
@click="stakeAndClaimAllCycles"
>
Stake & Claim Rest
</div>
@@ -55,7 +55,9 @@
</div>
</template>
<template v-slot:message-end>
<div class="input-balance">Balance: {{ walletStore.memeToken?.unclaimedRewards }}</div>
<div class="input-balance">
Balance: {{ formatNumber(walletStore.memeToken?.unclaimedRewards) }}
</div>
</template>
</stake-menu>
</Transition>
@@ -88,6 +90,8 @@ import { useTokenStore } from "@/stores/tokens";
import { useRewardLockerStore } from "@/stores/rewardlocker";
import { useRouter } from "vue-router";
import { useToast } from "vue-toastification";
import { formatNumber } from "@/helper/helper.js";
import { showSuccessToast } from "@/helper/toast.js";
const toast = useToast();
const rewardLockerStore = useRewardLockerStore();
@@ -121,17 +125,12 @@ function openStake() {
stakeMenu.value = true;
}
function openUnstake() {
stake.value = false;
stakeMenu.value = true;
}
async function stakeAndClaimAllRounds() {
async function stakeAndClaimAllCycles() {
try {
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards;
stateClaim.value = 2;
const coefficient = (10000 * tokenNumber.value) / unclaimedRewards;
var hash = await rewardLockerStore.stakeAndClaimAllRounds(coefficient);
var hash = await rewardLockerStore.stakeAndClaimAllCycles(coefficient);
stateClaim.value = 3;
const data = await waitForTransaction({
hash: hash,
@@ -147,7 +146,7 @@ async function stakeAndClaimAllRounds() {
//ClaimedReward (address staker, uint256 reward)
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just claimed and staked",
"Join the next cycle to increase your rewards and win with your clan"
@@ -178,7 +177,7 @@ async function claimAll() {
//ClaimedReward (address staker, uint256 reward)
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just claimed",
"Join the next cycle to increase your rewards and win with your clan."
@@ -220,42 +219,6 @@ const stateClaimComp = computed(() => {
}
return returnState;
});
function showSuccessToast(value, header, subheader, info) {
// Define the content object with the component, props and listeners
const content = {
component: StakeSuccessToast,
// Any prop can be passed, but don't expect them to be reactive
props: {
// counter: this.counter,
// value: tokenStore.activeToken.rewards?.toFixed(5),
value: value,
header: header,
subheader: subheader,
info: info,
},
// Listen and react to events using callbacks. In this case we listen for
// the "click" event emitted when clicking the toast button
listeners: {},
};
// Render the toast and its contents
toast(content, {
position: "top-center",
icon: false,
closeOnClick: false,
toastClassName: "modal-overlay",
closeButton: false,
hideProgressBar: true,
timeout: false,
});
}
</script>
<style lang="sass">
// .smooth-enter-active, .smooth-leave-active
// transition: opacity 0.1s
// .smooth-enter, .smooth-leave-to
// height: 0
</style>
<style lang="sass"></style>
+6 -15
View File
@@ -67,10 +67,8 @@
import { ref, toRaw, onMounted, onUnmounted, getCurrentInstance } from "vue";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useTokenStore } from "@/stores/tokens";
import Meme1Json from "@/assets/contracts/Meme1.json";
import TokenNamePrice from "./TokenNamePrice.vue";
import TokenLogo from "./TokenLogo.vue";
import TokenInput from "./TokenInput.vue";
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
import { getAddressShortName, getblocky } from "@/helper/helper.js";
@@ -83,21 +81,15 @@ const router = useRouter();
const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore();
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
const fromAddress = ref(null);
const accountSub = ref(null);
const metaMaskInstalled = ref(false);
const instance = getCurrentInstance();
async function disconnectWallet() {
console.log("disconnectWallet");
try {
instance.parent.emit("update:modelValue", false);
await disconnect();
// walletStore.connected = false;
// walletStore.address = null;
} catch (error) {
console.log("error", error);
}
@@ -112,10 +104,12 @@ function isMetaMaskInstalled() {
return false;
}
//go to the sacrifice-page and select the clicked token
//if contract === bloodline show buy
//we could also show buy, if there is no pepe
function badgeClick(token) {
var tokenData = tokenStore.getToken(token.contractAddress);
tokenStore.activeToken = tokenData;
// router.push({ name: "home", hash: `#${tokenData.name}` });
if (tokenStore.memeToken.contractAddress === token.contractAddress) {
//buy
window.open(
@@ -128,6 +122,7 @@ function badgeClick(token) {
}
}
//special case for metaMask, but I think that is the most used wallet
async function connectWallet(connector) {
if (connector.id === "metaMask" && !isMetaMaskInstalled()) {
window.open(" https://metamask.io/", "_blank");
@@ -136,10 +131,6 @@ async function connectWallet(connector) {
instance.parent.emit("update:modelValue", false);
await walletStore.connectWallet(toRaw(connector));
}
onMounted(async () => {
console.log("window.ethereum", window.ethereum);
});
</script>
<style lang="sass">
+4 -6
View File
@@ -26,9 +26,7 @@
</div>
</div>
<div v-if="!isMobile">
<!-- <div v-if="!connected" class="btn btn-immortal" @click="walletStore.connectWallet">connect</div> -->
<div v-if="!address" class="btn btn-immortal mid-text" @click="showPanel = true">connect</div>
<!-- <span v-else @click="showPanel = true"> test</span> -->
<div v-if="!address" class="btn btn-immortal mid-text" @click="showPanel = true">Connect</div>
<div class="login-icon-desktop mid-text" v-else @click="showPanel = true">
<img :src="getblocky(address)" alt="avatar" />
<div>{{ getAddressShortName(walletStore.address) }}</div>
@@ -58,7 +56,7 @@ import { useRoute, useRouter } from "vue-router";
const emit = defineEmits(["showPanel"]);
const walletStore = useWalletStoreV2();
const { connected, address } = storeToRefs(walletStore);
const { address } = storeToRefs(walletStore);
const isMobile = inject("isMobile");
const showPanel = inject("showPanel");
@@ -117,7 +115,7 @@ onBeforeUnmount(() => {
transition: transform .3s ease,visibility 0s .3s linear
height: 82px
@media (min-width: 992px)
height: 96px
height: 80px
// &.navbar--hidden
// transform: translate3d(0,-100%,0)
.navbar-inner
@@ -143,7 +141,7 @@ onBeforeUnmount(() => {
letter-spacing: 0.138em
line-height: 73.107px
@media (min-width: 992px)
font-size: 48px
font-size: 42px
a
text-decoration: none
color: white
+72 -239
View File
@@ -1,6 +1,5 @@
<template>
<div class="sacrifice-wrapper card card--glow bloodline-wrapper">
<!-- {{ activeToken.allowance }} -->
<div class="sacrifice-headline">Select Sacrifice</div>
<div class="sacrifice-select-tokens">
<div class="sacrifice-tokens">
@@ -35,11 +34,11 @@
}"
>
<token-input
:modelValue="tokenNumber"
:modelValue="sacrificeStore.sacrificeNumber"
@input="
($event) => {
tokenNumber = $event.target.value;
return processChange($event.target.value);
sacrificeStore.sacrificeNumber = $event.target.value;
processChange($event.target.value);
}
"
:max="activeWalletToken?.balanceOf"
@@ -50,7 +49,7 @@
<div class="sacrifice-adder-step bloodline-badge" @click="addTokens(100000000)">+100m</div>
<div class="sacrifice-adder-step bloodline-badge" @click="addTokens(1000000000)">+1b</div>
</template>
<template v-slot:message-end>
<template v-slot:message-end v-if="activeWalletToken?.balanceOf">
<div class="input-balance tiny-text">
Balance:
{{ activeWalletToken?.balanceOf }}
@@ -71,8 +70,8 @@
}"
>
<div class="sacrifice-to-body">
<token-name-price name="$BLOOD" :price="`≈${output?.toFixed(5)}`"></token-name-price>
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo>
<token-name-price name="$BLOOD" :price="`≈${formatNumber(output)}`"></token-name-price>
<token-logo :img="activeToken.vamp.logo" :size="64" :alt="activeToken.vamp.name"></token-logo>
</div>
<div class="sacrifice-staking-bonus">
@@ -84,7 +83,14 @@
}
"
>
<div class="mid-mid-text">+ Staking Bonus</div>
<div class="mid-mid-text" v-if="!walletStore.connected">+ Staking Bonus</div>
<div
class="mid-mid-text"
v-else-if="walletStore.memeToken?.staked === 0 || cycleStore.currentCycle === 1"
>
No Staking Bonus
</div>
<div class="mid-mid-text" v-else>+ TODO Staking Bonus</div>
<div class="icon">
<font-awesome-icon icon="chevron-down" />
</div>
@@ -106,7 +112,7 @@
<div
class="btn btn-immortal sub-header"
disabled
v-else-if="tokenNumber > activeWalletToken?.balanceOf"
v-else-if="sacrificeStore.sacrificeNumber > activeWalletToken?.balanceOf"
>
Insufficient Balance
</div>
@@ -114,25 +120,27 @@
class="btn btn-immortal sub-header"
v-else-if="
activeToken.allowance > 0 &&
activeToken.allowance >= tokenNumber &&
activeToken.allowance >= sacrificeStore.sacrificeNumber &&
(stateComputed === 1 || stateComputed === 4)
"
@click="sacrificeToken(tokenNumber)"
@click="sacrificeToken"
>
Sacrifice 🩸
</div>
<div
class="btn btn-immortal sub-header"
v-else-if="
(!activeToken.allowance || activeToken.allowance < tokenNumber) &&
(!activeToken.allowance || activeToken.allowance < sacrificeStore.sacrificeNumber) &&
(stateComputed === 1 || stateComputed === 4)
"
@click="approveToken(tokenNumber)"
@click="approveToken(sacrificeStore.sacrificeNumber)"
>
Approve Token
</div>
<div class="btn btn-immortal sub-header" disabled v-if="stateComputed === 2">Sign Transaction</div>
<div class="btn btn-immortal sub-header" disabled v-if="stateComputed === 3">
<div class="btn btn-immortal sub-header" disabled v-else-if="stateComputed === 2">
Sign Transaction
</div>
<div class="btn btn-immortal sub-header" disabled v-else-if="stateComputed === 3">
<loading-component></loading-component>
</div>
</template>
@@ -147,52 +155,42 @@
<script setup>
import { ref, defineProps, watch, inject, nextTick, onMounted, onBeforeUnmount, computed, markRaw } from "vue";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { useTokenStore } from "@/stores/tokens";
import { useMemeburnerStore } from "@/stores/memeburner";
import { useUniswapStore } from "@/stores/uniswap";
import { useSacrificeStore } from "@/stores/sacrifice";
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
import LoadingComponent from "@/components/LoadingComponent.vue";
import TokenInput from "@/components/TokenInput.vue";
import TokenNamePrice from "@/components/TokenNamePrice.vue";
import TokenLogo from "@/components/TokenLogo.vue";
import StakeSuccessToast from "@/components/toasts/StakeSuccessToast.vue";
import ApprovedToast from "@/components/toasts/ApprovedToast.vue";
import { useToast } from "vue-toastification";
const roundStore = useRoundsStore();
const toast = useToast();
import { storeToRefs } from "pinia";
import { waitForTransaction, readContract, watchBlockNumber, multicall } from "@wagmi/core";
import Helper from "@/utils/helper.js";
const cycleStore = useCycleStore();
const sacrificeStore = useSacrificeStore();
const toast = useToast();
import { debounce, formatNumber } from "@/helper/helper.js";
const isMobile = inject("isMobile");
const showPanel = inject("showPanel");
const walletStore = useWalletStoreV2();
// const { connected } = storeToRefs(walletStore);
const tokenStore = useTokenStore();
const { activeToken } = storeToRefs(tokenStore);
const memeburnerStore = useMemeburnerStore();
const uniswapStore = useUniswapStore();
const props = defineProps({
data: Array,
});
// watch(
// activeToken,
// () => {
// tokenNumber.value = null;
// },
// { deep: true }
// );
const tokenNumber = ref(null);
const output = ref(0);
const loading = ref(false);
const blockEvent = ref(null);
const approveToast = ref(null);
/**
* state 0 enter amount
* state 1 rdy to go
@@ -200,7 +198,6 @@ const blockEvent = ref(null);
* state 3 loading
* state 4 sacrificed
*/
const state = ref(0);
const showStakingMenu = ref(false);
const approvalData = ref(null);
@@ -214,18 +211,29 @@ const activeWalletToken = computed(() => {
const stateComputed = computed(() => {
let returnState = 0;
if (tokenNumber.value === null || tokenNumber.value === "" || tokenNumber.value === 0) {
if (
sacrificeStore.sacrificeNumber === null ||
sacrificeStore.sacrificeNumber === "" ||
sacrificeStore.sacrificeNumber === 0
) {
returnState = 0;
} else if (state.value === 2) {
} else if (sacrificeStore.sacrificeState === 2) {
returnState = 2;
} else if (state.value === 3) {
} else if (sacrificeStore.sacrificeState === 3) {
returnState = 3;
} else if (tokenNumber.value !== null || tokenNumber.value !== "" || tokenNumber.value > 0) {
} else if (
sacrificeStore.sacrificeNumber !== null ||
sacrificeStore.sacrificeNumber !== "" ||
sacrificeStore.sacrificeNumber > 0
) {
returnState = 1;
}
return returnState;
});
const processChange = Helper.debounce((value) => getRewardsFor(value));
const processChange = debounce(async (value) => {
const returnValue = await sacrificeStore.getRewardsFor(value, activeToken.value);
output.value = returnValue.output;
});
onMounted(() => {
blockEvent.value = watchBlockNumber(
@@ -234,37 +242,10 @@ onMounted(() => {
},
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);
// }
// }
//
var rewardValue = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value);
output.value = rewardValue.output;
}
);
console.log("blockEvent.value", blockEvent.value);
});
onBeforeUnmount(() => {
@@ -272,196 +253,42 @@ onBeforeUnmount(() => {
blockEvent.value();
});
async function sacrificeToken(amount) {
console.log("sacrificeToken");
try {
state.value = 2;
const getRewards = await getRewardsFor(amount);
let hash = null;
if (getRewards.variant === "sacrifice") {
console.log("sacrifice");
hash = await memeburnerStore.sacrificeMeme(amount);
console.log("hash", hash);
} else {
console.log("buy");
hash = await memeburnerStore.sacrificeMemeAndBuyBLOOD(amount);
console.log("hash", hash);
}
state.value = 3;
const data = await waitForTransaction({
hash: hash,
onReplaced: (transaction) => console.log("check transaction canceled", transaction),
});
console.log("data", data);
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee"
);
});
const outputSacrifice = Number(rewardData.data) / Math.pow(10, activeToken.value.decimals);
//activeToken is bad here, because it could change during async request
activeToken.value.allowance = await tokenStore.allowance();
state.value = 4;
console.log("state.value = 4");
showSuccessToast(
outputSacrifice?.toFixed(5),
"Success!",
"You turned your meme into:",
"You can claim once the current cycle is finished and your clan bonus was calculated."
);
await walletStore.loadWalletData();
await roundStore.fillRound(roundStore.currentRound, true);
} catch (error) {
state.value = 0;
console.error(error);
throw new Error(error);
}
}
async function approveToken(amount) {
try {
state.value = 2;
sacrificeStore.sacrificeState = 2;
const hash = await tokenStore.approveToken(amount);
state.value = 3;
sacrificeStore.sacrificeState = 3;
const data = await waitForTransaction({
hash: hash,
});
console.log("data", data);
activeToken.value.allowance = await tokenStore.allowance();
state.value = 1;
sacrificeStore.sacrificeState = 1;
approveToast.value = showApprovedToast();
} catch (error) {
console.error(error);
throw new Error(error);
} finally {
state.value = 0;
}
}
async function getRewardsFor(value) {
console.log("getRewardsFor", value);
loading.value = true;
let variant = null;
let newOutput = 0;
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))
);
// const rewardsForResultNumber = Number(rewardsForResult[0]) / Math.pow(10, tokenStore.activeToken.decimals) + Number(rewardsForResult[1]) / Math.pow(10, tokenStore.activeToken.decimals);
const rewardsForResultNumber = rewardsForResult.reduce((x, y) => {
return x + Number(y) / Math.pow(10, tokenStore.activeToken.decimals);
}, 0);
var quoteRewards = await uniswapStore.quoteExactInputSingle(
tokenNumber.value * Math.pow(10, tokenStore.activeToken.decimals)
);
console.log("quoteRewards", quoteRewards);
let variant = "sacrifice";
if (quoteRewards.result) {
console.log("quoteRewards", quoteRewards);
const quoteRewardsNumber = Number(quoteRewards.amount) / Math.pow(10, tokenStore.activeToken.decimals);
if (quoteRewardsNumber * 0.995 > rewardsForResultNumber) {
variant = "buy";
console.log("use Buy-function", { quoteRewardsNumber: quoteRewardsNumber, rewardsForResultNumber });
} else {
console.log("use sacrifice-function", {
quoteRewardsNumber: quoteRewardsNumber,
rewardsForResultNumber,
});
}
} else {
/**
* case 4
* quoter threw an error
*/
//
newOutput = rewardsForResultNumber;
}
console.log("variant", variant);
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,
});
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);
console.log("sacrificeMemeAndBuyBLOOD", amountBuyNumber);
console.log("sacrificeMeme", amountSacrificeNumber);
if (amountBuyNumber * 0.995 > amountSacrificeNumber) {
variant = "buy";
newOutput = amountBuyNumber;
console.log("use buy after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
} else {
variant = "sacrifice";
newOutput = amountSacrificeNumber;
console.log("use sacrifice after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
}
}
output.value = newOutput;
return { ouput: newOutput, variant: variant };
} catch (error) {
console.error("getRewardsFor", error);
} finally {
loading.value = false;
sacrificeStore.sacrificeState = 0;
}
}
async function addTokens(value) {
tokenNumber.value = Number(tokenNumber.value) + Number(value);
output.value = await getRewardsFor(tokenNumber.value).output;
sacrificeStore.sacrificeNumber = Number(sacrificeStore.sacrificeNumber) + Number(value);
output.value = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value).output;
}
async function addMaxTokens() {
tokenNumber.value = activeWalletToken.value.balanceOf;
output.value = await getRewardsFor(tokenNumber.value).output;
sacrificeStore.sacrificeNumber = activeWalletToken.value.balanceOf;
output.value = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, activeToken.value).output;
}
function showSuccessToast(value, header, subheader, info) {
function showApprovedToast(value, header, subheader, info) {
// Define the content object with the component, props and listeners
const content = {
component: StakeSuccessToast,
component: ApprovedToast,
// Any prop can be passed, but don't expect them to be reactive
props: {
// counter: this.counter,
// value: tokenStore.activeToken.rewards?.toFixed(5),
value: value,
header: header,
subheader: subheader,
@@ -473,16 +300,21 @@ function showSuccessToast(value, header, subheader, info) {
};
// Render the toast and its contents
toast(content, {
position: "top-center",
return toast(content, {
position: "top-right",
icon: false,
closeOnClick: false,
toastClassName: "modal-overlay",
closeButton: false,
// toastClassName: "modal-overlay",
hideProgressBar: true,
timeout: false,
toastClassName: "approve-toast toast-card",
});
}
//call function in the store and remove icon,
async function sacrificeToken() {
await sacrificeStore.sacrificeToken(sacrificeStore.sacrificeNumber, activeToken.value);
toast.dismiss(approveToast.value);
}
</script>
<style lang="sass">
@@ -654,6 +486,7 @@ function showSuccessToast(value, header, subheader, info) {
.input-max
color: var(--grey, #858585)
font-weight: bold
&:hover, &:active, &:focus
color: var(--grey-light, #858585)
cursor: pointer
+37 -46
View File
@@ -32,23 +32,47 @@
<slot name="body">
<token-name-price
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
:price="walletStore.memeToken?.staked"
:price="formatNumber(walletStore.memeToken?.staked)"
></token-name-price>
<token-logo img="/assets/img/token/bloodline.png" :alt="'^y '"></token-logo>
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline-token'"></token-logo>
<token-name-price class="stake-reward" name="Extra Reward" price="+25%"></token-name-price>
</slot>
</div>
<slot name="actions">
<div class="connected-stake-buttons" v-if="!stakeMenu">
<div class="btn btn-immortal mid-mid-text" disabled v-if="roundStore.currentRound === 1">Stake</div>
<div class="btn btn-immortal mid-mid-text" v-else @click="openStake">Stake</div>
<div class="mid-mid-text text-center" disabled v-if="!walletStore.connected">
Please Connect Your Wallet
</div>
<div
v-if="(walletStore.memeToken?.staked === 0 && !stakeonly) || roundStore.currentRound === 1"
class="btn btn-immortal mid-mid-text"
disabled
v-if="walletStore.connected && cycleStore.currentCycle === 1"
>
Stake
</div>
<div
class="btn btn-immortal mid-mid-text"
v-else-if="walletStore.connected && cycleStore.currentCycle > 1"
@click="openStake"
>
Stake
</div>
<div
v-if="
walletStore.connected &&
((walletStore.memeToken?.staked === 0 && !stakeonly) || cycleStore.currentCycle === 1)
"
class="btn btn-immortal btn--disabled mid-mid-text"
>
Unstake
</div>
<div v-else-if="!stakeonly" class="btn btn-immortal mid-mid-text" @click="openUnstake">Unstake</div>
<div
v-else-if="walletStore.connected && !stakeonly"
class="btn btn-immortal mid-mid-text"
@click="openUnstake"
>
Unstake
</div>
</div>
<Transition name="smooth">
<stake-menu
@@ -106,12 +130,9 @@
</div>
</div>
</Transition>
<div class="connected-stake-first-round small-text text-center" v-if="roundStore.currentRound === 0">
<div class="connected-stake-first-round small-text text-center" v-if="cycleStore.currentCycle === 0">
No $BLOOD on the market. Staking is activated after the first cycle is finished.
</div>
<div class="connected-stake-claim-info low-mid-text text-center">
You can claim your stake next cycle.
</div>
</slot>
<slot></slot>
</div>
@@ -120,25 +141,25 @@
<script setup>
import { ref, useSlots, computed } from "vue";
import CardComponent from "@/components/CardComponent.vue";
import StakeSuccessToast from "@/components/toasts/StakeSuccessToast.vue";
import StakeMenu from "@/components/StakeMenu.vue";
import TokenNamePrice from "@/components/TokenNamePrice.vue";
import TokenLogo from "@/components/TokenLogo.vue";
import { waitForTransaction } from "@wagmi/core";
import LoadingComponent from "@/components/LoadingComponent.vue";
import { showSuccessToast } from "@/helper/toast.js";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { useRewardLockerStore } from "@/stores/rewardlocker";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useTokenStore } from "@/stores/tokens";
import { useToast } from "vue-toastification";
import { formatNumber } from "@/helper/helper.js";
const toast = useToast();
const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore();
const rewardLockerStore = useRewardLockerStore();
const roundStore = useRoundsStore();
const cycleStore = useCycleStore();
const slots = useSlots();
const props = defineProps({
stakeonly: {
@@ -198,7 +219,7 @@ async function orderUnstake() {
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just unstaked",
"You can claim your stake next cycle."
@@ -232,7 +253,7 @@ async function stakeToken() {
state.value = 4;
await walletStore.loadWalletData();
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just staked",
"Your next sacrifice will get an extra staking bonus as a reward."
@@ -259,36 +280,6 @@ const stateStake = computed(() => {
}
return returnState;
});
function showSuccessToast(value, header, subheader, info) {
// Define the content object with the component, props and listeners
const content = {
component: StakeSuccessToast,
// Any prop can be passed, but don't expect them to be reactive
props: {
// counter: this.counter,
// value: tokenStore.activeToken.rewards?.toFixed(5),
value: value,
header: header,
subheader: subheader,
info: info,
},
// Listen and react to events using callbacks. In this case we listen for
// the "click" event emitted when clicking the toast button
listeners: {},
};
// Render the toast and its contents
toast(content, {
position: "top-center",
icon: false,
closeOnClick: false,
toastClassName: "modal-overlay",
closeButton: false,
hideProgressBar: true,
timeout: false,
});
}
</script>
<style lang="sass">
+17 -10
View File
@@ -60,31 +60,37 @@ async function addTokensPercent(value) {
}
async function unstakeBloodline() {
try {
const fromAddress = walletStore.address;
var test1 = await rewardLockerStore.contract.read.unstakeOrdered([4, fromAddress]);
console.log("test1", test1);
var test = true;
if (test) {
return;
}
var unstakedOrdered = await rewardLockerStore.contract.read.unstakeOrdered([4, fromAddress]);
//check if states needed here
var hash = await rewardLockerStore.contract.write.orderUnstake();
console.log("hash", hash);
const data = await waitForTransaction({
hash: hash,
});
console.log("data", data);
} catch (error) {
console.error("unstakeBloodline", error);
}
}
async function stakeBloodline() {
try {
const fromAddress = walletStore.address;
const spender = rewardLockerStore.config.contractAddress;
const deadline = Date.now() + 20 * 60;
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
const value = (tokenNumber.value * Math.pow(10, decimals)).toString();
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
console.log("nonce", nonce);
const { types, message, domain, primaryType } = createPermitObject(fromAddress, spender, nonce, deadline, value);
const { types, message, domain, primaryType } = createPermitObject(
fromAddress,
spender,
nonce,
deadline,
value
);
const signature = await signTypedData({
domain: domain,
@@ -96,8 +102,9 @@ async function stakeBloodline() {
const { r, s, v } = getSignatureRSV(signature);
var resultStake = await rewardLockerStore.contract.write.stakeToBeSecured([value, deadline, v, r, s]);
console.log("resultStake", resultStake);
} catch (error) {
console.error("stakeBloodline", error);
}
}
</script>
+80 -39
View File
@@ -1,12 +1,12 @@
<template>
<div class="claim bloodline-border bloodline-border__thin grey">
<div class="claim-headline sub-header">You Cycle Rewards</div>
<div class="claim-headline sub-header">Your Cycle Rewards</div>
<!-- <div class="rewards-wrapper" v-if="!isMobile">
<rewards-wrapper
title="Sacrafice Reward"
coin="$BLOOD"
:amount="getCurrentRoundData?.rewards_sacrifice"
:amount="getCurrentCycleData?.rewards_sacrifice"
image="/assets/img/vampir.png"
/>
<div class="rewards-divider bloodline-devider">
@@ -15,7 +15,7 @@
<rewards-wrapper
title="Clan Reward"
coin="$BLOOD"
:amount="getCurrentRoundData?.rewards_clan"
:amount="getCurrentCycleData?.rewards_clan"
image="/assets/img/vampir.png"
/>
</div> -->
@@ -23,46 +23,41 @@
<rewards-wrapper
title="Sacrafice Reward"
coin="$BLOOD"
:amount="getCurrentRoundData?.rewards_sacrifice.toFixed(2)"
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice)"
image="/assets/img/vampir.png"
/>
<rewards-wrapper
title="Staking Bonus"
coin="$BLOOD"
:amount="getCurrentRoundData?.rewards_staking.toFixed(2)"
:amount="formatNumber(getCurrentCycleData?.rewards_staking)"
info="max: 312m"
image="/assets/img/vampir.png"
/>
<rewards-wrapper
title="Clan Bonus"
coin="$BLOOD"
:amount="getCurrentRoundData?.rewards_clan.toFixed(2)"
:amount="formatNumber(getCurrentCycleData?.rewards_clan)"
image="/assets/img/vampir.png"
/>
</div>
<div class="rewards-total-wrapper">
<div class="rewards-total-headline low-mid-text">Total Reward</div>
<div class="rewards-total-headline sub-header">Total Reward</div>
<div class="rewards-total-inner bloodline-border bloodline-border--variant1">
<token-name-price
name="$BLOOD"
:price="getCurrentRoundData?.rewards_total?.toFixed(5)"
:price="formatNumber(getCurrentCycleData?.rewards_total)"
></token-name-price>
<token-logo img="/assets/img/vampir.png" :alt="'vampire'"></token-logo>
<!-- <div class="rewards-coin low-mid-text">$BLOOD</div>
<div class="rewards-amount header" v-if="activeRound === currentRound">0</div>
<div class="rewards-amount header" v-else>{{ getCurrentRoundData?.rewards_total.toFixed(5) }}</div> -->
<!-- </div> -->
<!-- <img class="bloodline-token" src="/assets/img/token/bloodline.png" alt="vampir" /> -->
</div>
</div>
<div class="claim-button">
<template v-if="!walletStore.connected">
<button class="btn btn-immortal sub-header" @click="showPanel = true">Connect</button>
</template>
<template v-else-if="activeRound === currentRound">
<template v-else-if="activeCycle === currentCycle">
<button class="btn btn-immortal sub-header" @click="router.push({ name: 'home' })">Sacrifice</button>
</template>
<template v-else-if="getCurrentRoundData?.rewards_total > 0">
<template v-else-if="getCurrentCycleData?.rewards_total > 0">
<Transition name="smooth">
<div class="stake-buttons" v-show="!stakeMenu">
<div class="btn btn-immortal" v-if="stateClaimedComp === 0" @click="claimRewards">Claim</div>
@@ -78,11 +73,28 @@
v-model="tokenNumber"
@close="stakeMenu = false"
:stake="stake"
:amount="getCurrentRoundData?.rewards_total"
:amount="getCurrentCycleData?.rewards_total"
v-if="stakeMenu"
>
<template v-slot:body>
<div class="btn btn-immortal stake-button" @click="stakeAndClaim">Stake & Claim Rest</div>
{{ stateStakeClaimComp }}
{{ stateStakeClaim }}
<div class="btn btn-immortal stake-button" disabled v-if="stateStakeClaimComp === 0">
Enter Amount
</div>
<div
class="btn btn-immortal stake-button"
v-else-if="stateStakeClaimComp === 1"
@click="stakeAndClaim"
>
Stake & Claim Rest
</div>
<div class="btn btn-immortal stake-button" disabled v-if="stateStakeClaimComp === 2">
Sign Transaction
</div>
<div class="btn btn-immortal stake-button" disabled v-if="stateStakeClaimComp === 3">
<loading-component></loading-component>
</div>
<div
class="btn transparent small-text cancel-button text-center"
@click="stakeMenu = false"
@@ -107,61 +119,71 @@ import { inject, ref, onMounted, computed } from "vue";
import { useRewardLockerStore } from "@/stores/rewardlocker";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { useTokenStore } from "@/stores/tokens";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { useRouter } from "vue-router";
import StakeMenu from "@/components/StakeMenu.vue";
import { waitForTransaction } from "@wagmi/core";
import LoadingComponent from "@/components/LoadingComponent.vue";
import TokenNamePrice from "@/components/TokenNamePrice.vue";
import TokenLogo from "@/components/TokenLogo.vue";
import { formatNumber } from "@/helper/helper.js";
import { showSuccessToast } from "@/helper/toast.js";
const clanRewards = ref(0);
const rewards = ref(0);
const isMobile = inject("isMobile");
const showPanel = inject("showPanel");
const rewardLockerStore = useRewardLockerStore();
const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore();
const roundStore = useRoundsStore();
const { address } = storeToRefs(walletStore);
const cycleStore = useCycleStore();
const router = useRouter();
const { activeRound, currentRound, getCurrentRoundData } = storeToRefs(roundStore);
const { activeCycle, currentCycle, getCurrentCycleData } = storeToRefs(cycleStore);
const stakeMenu = ref(false);
const stake = ref(null);
const tokenNumber = ref(null);
const stateClaim = ref(0);
const stateStakeClaim = ref(0);
async function stakeAndClaim() {
try {
console.log(tokenNumber.value);
console.log(getCurrentRoundData.value.rewards_total);
const coefficient = (10000 * tokenNumber.value) / getCurrentRoundData.value.rewards_total;
var hash = await rewardLockerStore.stakeAndClaimRound(coefficient, roundStore.activeRound);
console.log(getCurrentCycleData.value.rewards_total);
const coefficient = (10000 * tokenNumber.value) / getCurrentCycleData.value.rewards_total;
console.log("hier");
stateStakeClaim.value = 2;
console.log("hier2");
console.log("coefficient", coefficient);
console.log("cycleStore.activeCycle", cycleStore.activeCycle);
var hash = await rewardLockerStore.stakeAndClaimCycle(coefficient, cycleStore.activeCycle);
console.log("hash");
stateStakeClaim.value = 3;
const data = await waitForTransaction({
hash: hash,
});
console.log("data", data);
stateStakeClaim.value = 4;
//ClaimedReward (address staker, uint256 reward)
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xf86340d97020c624010a208b733db95795281fbc45cb6e6a40d161f91fa3e4a0"
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
);
});
//
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
const outputClaim = Number(rewardData?.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just claimed and staked",
"Join the next cycle to increase your rewards and win with your clan."
);
const walletStore = useWalletStoreV2();
await walletStore.loadWalletData();
} catch (error) {
console.error("stakeAndClaim", error);
} finally {
const walletStore = useWalletStoreV2();
await walletStore.loadWalletData();
stateStakeClaim.value = 1;
}
}
@@ -175,9 +197,9 @@ onMounted(async () => {});
async function claimRewards() {
try {
stateClaim.value = 2;
console.log("getCurrentRoundData", getCurrentRoundData);
console.log("activeRound.value", activeRound.value);
var hash = await rewardLockerStore.claim([activeRound.value]);
console.log("getCurrentCycleData", getCurrentCycleData);
console.log("activeCycle.value", activeCycle.value);
var hash = await rewardLockerStore.claim([activeCycle.value]);
stateClaim.value = 3;
console.log("hash", hash);
const data = await waitForTransaction({
@@ -195,18 +217,17 @@ async function claimRewards() {
const outputClaim = Number(rewardData.topics[2]) / Math.pow(10, tokenStore.memeToken.decimals);
showSuccessToast(
outputClaim.toFixed(5),
formatNumber(outputClaim),
"Success!",
"You just claimed",
"Join the next cycle to increase your rewards and win with your clan."
);
await roundStore.fillRound(activeRound.value, true);
await cycleStore.fillCycle(activeCycle.value, true);
await walletStore.loadWalletData();
} catch (error) {
stateClaim.value = 0;
console.error(error);
throw new Error(error);
throw Error(error);
}
}
@@ -219,6 +240,26 @@ const stateClaimedComp = computed(() => {
}
return returnState;
});
const stateStakeClaimComp = computed(() => {
let returnState = 0;
console.log("tokenNumber.value", tokenNumber.value);
if (
tokenNumber.value === null ||
tokenNumber.value === "" ||
tokenNumber.value === 0 ||
tokenNumber.value > walletStore.memeToken?.unclaimedRewards
) {
returnState = 0;
} else if (stateStakeClaim.value === 2) {
returnState = 2;
} else if (stateStakeClaim.value === 3) {
returnState = 3;
} else if (tokenNumber.value !== null || tokenNumber.value !== "" || tokenNumber.value > 0) {
returnState = 1;
}
return returnState;
});
</script>
<style lang="sass">
-4
View File
@@ -15,10 +15,6 @@
</div>
<div class="right-side">
<token-logo :img="props.logo" :alt="'vampir'"></token-logo>
<!-- <div class="sacrifice-logo" v-if="props.logo">
<img :src="props.logo" alt="vampir" />
</div> -->
</div>
</div>
</div>
+5 -3
View File
@@ -1,6 +1,6 @@
<template>
<div class="token-logo">
<img :src="props.img" :alt="props.alt" />
<img :src="props.img" :alt="props.alt" :style="{ height: `${size}px`, width: `${size}px` }" />
</div>
</template>
@@ -8,6 +8,10 @@
const props = defineProps({
img: String,
alt: Number,
size: {
type: Number,
default: 45,
},
});
</script>
@@ -15,8 +19,6 @@ const props = defineProps({
.token-logo
height: 100%
img
width: 45px
height: 45px
border-radius: 50%
pointer-events: none
@media (min-width: 992px)
-88
View File
@@ -1,88 +0,0 @@
<script>
export default {
name: `TransitionExpand`,
functional: true,
render(createElement, context) {
const data = {
props: {
name: `expand`,
},
on: {
afterEnter(element) {
// eslint-disable-next-line no-param-reassign
element.style.height = `auto`;
},
enter(element) {
const { width } = getComputedStyle(element);
/* eslint-disable no-param-reassign */
element.style.width = width;
element.style.position = `absolute`;
element.style.visibility = `hidden`;
element.style.height = `auto`;
/* eslint-enable */
const { height } = getComputedStyle(element);
/* eslint-disable no-param-reassign */
element.style.width = null;
element.style.position = null;
element.style.visibility = null;
element.style.height = 0;
/* eslint-enable */
// Force repaint to make sure the
// animation is triggered correctly.
// eslint-disable-next-line no-unused-expressions
getComputedStyle(element).height;
requestAnimationFrame(() => {
// eslint-disable-next-line no-param-reassign
element.style.height = height;
});
},
leave(element) {
const { height } = getComputedStyle(element);
// eslint-disable-next-line no-param-reassign
element.style.height = height;
// Force repaint to make sure the
// animation is triggered correctly.
// eslint-disable-next-line no-unused-expressions
getComputedStyle(element).height;
requestAnimationFrame(() => {
// eslint-disable-next-line no-param-reassign
element.style.height = 0;
});
},
},
};
return createElement(`transition`, data, context.children);
},
};
</script>
<style scoped>
* {
will-change: height;
transform: translateZ(0);
backface-visibility: hidden;
perspective: 1000px;
}
</style>
<style>
.expand-enter-active,
.expand-leave-active {
transition: height 1s ease-in-out;
overflow: hidden;
}
.expand-enter,
.expand-leave-to {
height: 0;
}
</style>
+34
View File
@@ -15,6 +15,20 @@ export function compactNumber(number) {
}).format(parseInt(number));
}
export function formatNumber(number) {
const options = {
style: "decimal",
minimumFractionDigits: 0,
maximumFractionDigits: 0,
};
if (!number) {
return 0
}
const formattedWithOptions = number.toLocaleString("en-US", options);
return formattedWithOptions;
}
export function getAddressShortName(address) {
// const address = "0x66422602B2f4885c57EE794174f98d9E4DDBBBC6";
const addressBegin = address.substring(0, 6);
@@ -41,3 +55,23 @@ export function getblocky(address) {
return blockiesData;
}
export function debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
return func.apply(this, args);
}, timeout);
};
}
export function createDebounce() {
let timeout = null;
return function (fnc, delayMs) {
clearTimeout(timeout);
timeout = setTimeout(() => {
fnc();
}, delayMs || 500);
};
}
+12 -48
View File
@@ -4,7 +4,7 @@ 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 { useCycleStore } from "@/stores/cycles";
import { createApp } from 'vue'
import { createPinia } from 'pinia'
@@ -13,19 +13,11 @@ import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
import {
createConfig,
configureChains,
getAccount,
getNetwork,
getContract,
connect,
disconnect,
watchAccount,
watchWalletClient,
watchPublicClient,
watchContractEvent,
watchNetwork,
getWalletClient,
fetchBalance,
multicall,
} from "@wagmi/core";
import { WalletConnectConnector } from "@wagmi/core/connectors/walletConnect";
import { MetaMaskConnector } from "@wagmi/core/connectors/metaMask";
@@ -86,7 +78,9 @@ app.use(pinia);
app.use(Toast, {});
app.use(Toast, {
transition: "Vue-Toastification__fade",
});
try {
@@ -94,7 +88,7 @@ try {
const tokenStore = useTokenStore();
const memeBurnerStore = useMemeburnerStore();
const rewardLockerStore = useRewardLockerStore();
const roundsStore = useRoundsStore();
const cycleStore = useCycleStore();
const uniswapStore = useUniswapStore();
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
@@ -135,25 +129,6 @@ try {
});
walletStore.publicClient = publicClient;
const networkId = getNetwork()?.chain?.id;
// watchWalletClient(
// {
// chainId: networkId,
// },
// async (walletClient) => {
// console.log("watchWalletClient", walletClient);
// walletStore.walletClient = walletClient;
// }
// );
// watchPublicClient(
// {
// chainId: networkId,
// },
// (publicClient) => console.log("publicClient", publicClient)
// );
watchContractEvent(
{
address: memeBurnerStore.config.contractAddress,
@@ -163,7 +138,7 @@ try {
async (log) => {
console.log("memeSacrificedEvent", log);
const token = log[0].args.sacrificedToken;
await roundsStore.updateCurrentRound(token);
await cycleStore.updateCurrentCycle(token);
}
);
@@ -171,13 +146,13 @@ try {
{
address: rewardLockerStore.config.contractAddress,
abi: rewardLockerStore.config.abi,
eventName: "RoundCompleted",
eventName: "CycleCompleted",
},
async (log) => {
console.log("roundCompleted", log);
await roundsStore.fillRound(roundsStore.currentRound);
roundsStore.currentRound++;
await roundsStore.fillRound(roundsStore.currentRound);
console.log("CycleCompleted", log);
await cycleStore.fillCycle(cycleStore.currentCycle);
cycleStore.currentCycle++;
await cycleStore.fillCycle(cycleStore.currentCycle);
}
);
@@ -204,6 +179,7 @@ try {
await tokenStore.initV2();
await rewardLockerStore.init();
await walletStore.loadWalletData();
await cycleStore.fillCycle(cycleStore.currentCycle);
await uniswapStore.init();
} else {
walletStore.address = null;
@@ -218,18 +194,6 @@ try {
}
});
// 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();
-12
View File
@@ -1,12 +0,0 @@
import { defineStore } from "pinia";
export const useContractStore = defineStore("contracts", {
state: () => ({
list: {
}
}),
getters: {
},
actions: {
}
});
+13 -14
View File
@@ -2,7 +2,7 @@ import { defineStore } from "pinia";
import MemeAltarJson from "@/assets/contracts/MemeAltar.json";
import { useTokenStore } from "./tokens";
import { useWalletStoreV2 } from "./walletV2";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { multicall, getContract, fetchToken, waitForTransaction, getWalletClient } from "@wagmi/core";
@@ -18,7 +18,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
async init() {
console.log("-----------init memeburner-------------");
const walletStore = useWalletStoreV2();
// const roundsStore = useRoundsStore();
// const cycleStore = useCycleStore();
console.log("walletStore.walletClient", walletStore.walletClient);
this.contract = getContract({
address: this.config.contractAddress,
@@ -37,30 +37,29 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("rewards", rewards);
return rewards;
},
async getCurrentRound() {
return await this.contract.read.currentRound();
async getCurrentCycle() {
return await this.contract.read.currentCycle();
},
async getGoal(roundnumber) {
return await this.contract.read.rounds([roundnumber]);
async getGoal(cycleNumber) {
return await this.contract.read.cycles([cycleNumber]);
},
//returns participated, amount achieved
async getSacrificedMeme(roundnumber, tokenAddress) {
return await this.contract.read.getSacrificedMeme([roundnumber, tokenAddress]);
async getSacrificedMeme(cycleNumber, tokenAddress) {
return await this.contract.read.getSacrificedMeme([cycleNumber, tokenAddress]);
},
async getAmountToReachGoal(tokenAddress) {
return await this.contract.read.getAmountToReachGoal([tokenAddress, 0]);
},
async getSacrificedRound(roundnumber) {
console.log("getSacrificedRound", roundnumber);
async getSacrificedCycle(cycleNumber) {
console.log("getSacrificedCycle", cycleNumber);
const tokenStore = useTokenStore();
const contracts = [];
for (let index = 0; index < tokenStore.sacrificeToken.length; index++) {
const token = tokenStore.sacrificeToken[index];
// contracts.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
contracts.push({
...this.contract,
functionName: "getSacrificedMeme",
args: [roundnumber, token.contractAddress],
args: [cycleNumber, token.contractAddress],
});
}
// console.log("this.contract", this.contract);
@@ -105,8 +104,8 @@ export const useMemeburnerStore = defineStore("memeburner", {
]);
return hash;
},
async getGoalInBLOOD(roundNumber) {
return await this.contract.read.getGoalInBLOOD([roundNumber]);
async getGoalInBLOOD(cycleNumber) {
return await this.contract.read.getGoalInBLOOD([cycleNumber]);
},
async getAmountETHBase(amount) {
console.log("getAmountETHBase");
+34 -74
View File
@@ -2,7 +2,7 @@ import { defineStore } from "pinia";
import RewardLockerJson from "@/assets/contracts/RewardLocker.json";
import { useTokenStore } from "./tokens";
import { useWalletStoreV2 } from "./walletV2";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { createPermitObject, getSignatureRSV } from "@/helper/blockchain.js";
import { multicall, getContract, signTypedData, getAccount, waitForTransaction } from "@wagmi/core";
@@ -26,49 +26,48 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
},
/*
* @param {*} walletAddress
* @param {*} roundNumber
* @param {*} cycleNumber
* @param {*} tokenAddress
* @returns Rewards for specific token and specific round
* @returns Rewards for specific token and specific cycle
*/
async getRewards(walletAddress, roundNumber, tokenAddress) {
async getRewards(walletAddress, cycleNumber, tokenAddress) {
try {
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
return await this.contract.read.rewards([walletAddress, cycleNumber, tokenAddress]);
} catch (error) {
console.error("getRewards", error);
}
},
async getRewardsForAllToken(roundNumber) {
async getRewardsForAllToken(cycleNumber) {
console.log("getRewardsForAllToken");
const tokenStore = useTokenStore();
const walletStore = useWalletStoreV2();
const contracts = [];
for (let index = 0; index < tokenStore.sacrificeToken.length; index++) {
const token = tokenStore.sacrificeToken[index];
// calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
// calls.push(this.contract.methods.rewards(walletStore.address, cycleNumber, token.contractAddress));
contracts.push({
...this.contract,
functionName: "getRewards",
args: [walletStore.address, roundNumber, token.contractAddress],
args: [walletStore.address, cycleNumber, token.contractAddress],
});
}
const data = await multicall({
contracts,
});
// const multicallStore = useMultiCallStore();
return data;
},
async getTotalSacrificeRewardsForAllToken(roundNumber) {
async getTotalSacrificeRewardsForAllToken(cycleNumber) {
try {
const tokenStore = useTokenStore();
const contracts = [];
for (let index = 0; index < tokenStore.sacrificeToken.length; index++) {
const token = tokenStore.sacrificeToken[index];
// calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
// calls.push(this.contract.methods.rewards(walletStore.address, cycleNumber, token.contractAddress));
contracts.push({
...this.contract,
functionName: "getTotalSacrificeRewardsForToken",
args: [roundNumber, token.contractAddress],
args: [cycleNumber, token.contractAddress],
});
}
const data = await multicall({
@@ -81,80 +80,41 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
throw new Error(error)
}
},
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
try {
return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]);
} catch (error) {
console.error("getSacrificedTokenCoefficient", error);
}
async getSacrificedTokenCoefficient(cycleNumber, sacrificedToken) {
return await this.contract.read.getSacrificedTokenCoefficient([cycleNumber, sacrificedToken]);
},
async lastCompletedRound() {
try {
return await this.contract.read.lastCompletedRound();
} catch (error) {
console.error("lastCompletedRound", error);
}
async lastCompletedCycle() {
return await this.contract.read.lastCompletedCycle();
},
async claim(round) {
try {
async claim(cycle) {
console.log("claim");
return await this.contract.write.claim([round]);
} catch (error) {
console.error("claim", error);
}
return await this.contract.write.claim([cycle]);
},
async claimAll() {
console.log("claimAll");
const roundsStore = useRoundsStore();
const cycleStore = useCycleStore();
const account = getAccount();
console.log("acocunt", account);
const rounds = await roundsStore.getFinshedRoundNumbers();
return await this.contract.write.claim([rounds]);
const cycles = await cycleStore.getFinshedCycleNumbers();
return await this.contract.write.claim([cycles]);
},
async getTotalRewardsOf(address, rounds) {
try {
return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewardsOf", error);
}
async getTotalRewardsOf(address, cycles) {
return await this.contract.read.getTotalRewardsOf([address, cycles]);
},
async getTotalRewards(address) {
try {
console.log("this.contract", this.contract);
const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers();
return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewards", error);
throw new Error(error);
}
const cycleStore = useCycleStore();
const cycles = await cycleStore.getFinshedCycleNumbers();
return await this.contract.read.getTotalRewardsOf([address, cycles]);
},
async getStaked(address) {
try {
return await this.contract.read.staked([address]);
} catch (error) {
console.error("getStaked", error);
throw new Error(error);
}
},
async orderUnstake() {
try {
return await this.contract.write.orderUnstake();
} catch (error) {
console.error("orderUnstake", error);
throw new Error(error)
}
},
async unstake(unstakeRound) {
try {
return await this.contract.write.unstake([unstakeRound]);
} catch (error) {
console.error("unstake", error);
throw new Error(error);
}
async unstake(unstakeCycle) {
return await this.contract.write.unstake([unstakeCycle]);
},
async stakeBloodline(tokenNumber) {
console.log("tokenNumber", tokenNumber);
@@ -189,24 +149,24 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return hash;
},
async stakeAndClaimRound(stakeCoefficient, round) {
async stakeAndClaimCycle(stakeCoefficient, cycle) {
// stakeCoefficient 25% = 2500, 50% = 5000
const tokenStore = useTokenStore();
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, [round], addresses]);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, [cycle], addresses]);
const data = await waitForTransaction({
hash: hash,
});
return hash;
},
async stakeAndClaimAllRounds(stakeCoefficient) {
console.log("stakeAndClaimAllRounds");
async stakeAndClaimAllCycles(stakeCoefficient) {
console.log("stakeAndClaimAllCycles");
const tokenStore = useTokenStore();
const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers();
const cycleStore = useCycleStore();
const cycles = await cycleStore.getFinshedCycleNumbers();
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
var stakeCoefficientInt = Math.round(stakeCoefficient);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, rounds, addresses]);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, cycles, addresses]);
return hash;
},
},
-206
View File
@@ -1,206 +0,0 @@
import { defineStore } from "pinia";
import { useMemeburnerStore } from "./memeburner";
import { useTokenStore } from "./tokens";
import { useRewardLockerStore } from "./rewardlocker";
import { useWalletStoreV2 } from "./walletV2";
import { multicall } from "@wagmi/core";
export const useRoundsStore = defineStore("rounds", {
state: () => ({
rounds: [],
activeRound: null,
currentRound: null,
}),
getters: {
getRoundWinner() {
const goal = this.getCurrentRoundData?.goal;
if (!goal) {
return;
}
const winnerCoin = this.rounds[this.activeRound]?.token.find((token) => token.amount === goal);
if (winnerCoin) {
return winnerCoin;
} else {
return false;
}
},
getCurrentRoundData() {
return this.rounds[this.activeRound];
},
},
actions: {
async init() {
//fill initial round
},
async loadRewardsRounds() {
const walletStore = useWalletStoreV2();
const rewardLockerStore = useRewardLockerStore();
console.log("this.currentRound", this.currentRound);
const contracts = [];
for (let index = 0; index < this.currentRound; index++) {
console.log("load round: " + index);
// await this.fillRound(index)
console.log({ index, address: walletStore.address });
contracts.push({
...rewardLockerStore.contract,
functionName: "getTotalRewardsOf",
args: [walletStore.address, [index + 1]],
});
}
const data = await multicall({
contracts,
});
// var test = await rewardLockerStore.getTotalRewardsOf(walletStore.address, rounds)
for (let index = 0; index < data.length; index++) {
const element = data[index];
if (!this.rounds[index]) {
this.rounds[index] = {};
}
console.log("vor Fehler");
// this.rounds[index].round = index + 1;
// this.rounds[index].rewards_total = element.result;
}
},
async updateCurrentRound(sacrificedToken) {
console.log("updateCurrentRound");
const tokenStore = useTokenStore();
const memeBurnerStore = useMemeburnerStore();
var data = await memeBurnerStore.getSacrificedRound(this.currentRound);
var tokenIndex = this.rounds[this.currentRound].token.findIndex(
(tokenData) => tokenData.contractAddress === sacrificedToken
);
const token = tokenStore.getToken(sacrificedToken);
// console.log(
// "this.rounds[this.currentRound].token[tokenIndex].amount",
// this.rounds[this.currentRound].token[tokenIndex].amount
// );
// console.log("Number(data[tokenIndex].result[1] / BigInt(Math.pow(10, token.decimals))", Number(data[tokenIndex].result[1] / BigInt(Math.pow(10, token.decimals))));
this.rounds[this.currentRound].token[tokenIndex].amount =
Number(data[tokenIndex].result[1]) / Math.pow(10, token.decimals)
},
async fillRound(roundNumber, refillRound = false) {
console.log("fillRound");
const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore();
const walletStore = useWalletStoreV2();
const rewardLockerStore = useRewardLockerStore();
// if (this.activeRound === this.currentRound) {
// console.log("activeRound is not completed");
// } else
if (!this.rounds[roundNumber]?.goal || refillRound) {
console.log("round not filled --> fill round");
var data = await memeBurnerStore.getSacrificedRound(roundNumber);
let rewardData = null;
if (walletStore.connected) {
rewardData = await rewardLockerStore.getRewardsForAllToken(roundNumber);
}
const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(roundNumber);
var goal = await memeBurnerStore.getGoal(roundNumber);
console.log("goal", goal);
var tokenArray = [];
var rewards_clan = 0;
var rewards_sacrifice = 0;
var rewards_staking = 0;
console.log("data", data);
for (let index = 0; index < data.length; index++) {
var tokenData = {};
const token = tokenStore.token[index];
var coefficent = await rewardLockerStore.getSacrificedTokenCoefficient(
roundNumber,
token.contractAddress
);
console.log("coefficent", coefficent);
tokenData.name = token.name;
tokenData.contractAddress = token.contractAddress;
tokenData.vamplogo = token.vamp.logo;
tokenData.vampname = token.vamp.name;
// tokenData.amount = data[index].result[1];
tokenData.amount = Number(data[index].result[1]) / Math.pow(10, token.decimals);
tokenData.amountInBLD = Number(tokenTotalSacrificed[index].result) / Math.pow(10, token.decimals);
// tokenData.getAmountToReachGoal =
// Number(await memeBurnerStore.getAmountToReachGoal(token.contractAddress)) /
// Math.pow(10, token.decimals);
if (walletStore.connected) {
const stakeReward = Number(rewardData[index].result[0]);
const sacrificeClanReward = Number(rewardData[index].result[1]);
let clanwin = 0;
if (roundNumber !== this.currentRound) {
clanwin = (Number(coefficent) / 10000 - 1) * sacrificeClanReward;
console.log("clanwin", clanwin);
}
const sacrificeRewards = Number(sacrificeClanReward);
tokenData.rewards_ges = Number(
rewardData[index].result[1] / BigInt(Math.pow(10, token.decimals)) +
rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals))
);
tokenData.rewards_clan = clanwin / Math.pow(10, token.decimals);
tokenData.rewards_staking = Number(
rewardData[index].result[0] / BigInt(Math.pow(10, token.decimals))
);
tokenData.rewards_sacrifice = sacrificeRewards / Math.pow(10, token.decimals);
rewards_clan = rewards_clan + tokenData.rewards_clan;
rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice;
rewards_staking = rewards_staking + tokenData.rewards_staking;
}
tokenArray.push(tokenData);
}
console.log("clanwin123", rewards_clan);
const goalInBLD = await memeBurnerStore.getGoalInBLOOD(roundNumber);
this.rounds[roundNumber] = {
goal: Number(goal[0]) / Math.pow(10, tokenStore.memeToken.decimals),
goalInBLD: Number(goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals))),
expirationTimestamp: Number(goal[2]),
rewards_clan: Number(rewards_clan),
rewards_staking: Number(rewards_staking),
rewards_sacrifice: Number(rewards_sacrifice),
rewards_total: Number(rewards_clan) + Number(rewards_sacrifice) + Number(rewards_staking),
token: tokenArray,
};
console.log("this.rounds[roundNumber]", this.rounds[roundNumber]);
} else {
console.log("round already filled");
}
},
async getFinshedRoundNumbers() {
const array = [];
const rewardLockerStore = useRewardLockerStore();
const lastCompletedRound = await rewardLockerStore.lastCompletedRound();
console.log("lastCompletedRound", lastCompletedRound);
for (let index = 0; index <= Number(lastCompletedRound); index++) {
array.push(index);
}
// for (let index = 1; index <= Number(lastCompletedRound) + 1; index++) {
// array.push(index);
// }
console.log("array", array);
return array;
},
/**
* function to get finished rounds, active round and the next round to check if there is a round the user called unstakeOrdered.
* with Backend it would be much easier because we could store the event data in the database
*/
async getRoundsNumberWithNext() {
const array = [];
const rewardLockerStore = useRewardLockerStore();
const lastCompletedRound = await rewardLockerStore.lastCompletedRound();
for (let index = 1; index <= Number(lastCompletedRound) + 1; index++) {
array.push(index);
}
return array;
},
},
});
+10 -14
View File
@@ -1,7 +1,6 @@
import { defineStore } from "pinia";
import { markRaw } from "vue";
import { useWalletStoreV2 } from "./walletV2";
import { useContractStore } from "./contracts";
import { useMemeburnerStore } from "./memeburner";
import Meme1Json from "@/assets/contracts/Meme1.json";
import Meme2Json from "@/assets/contracts/Meme2.json";
@@ -14,6 +13,7 @@ import { multicall, getContract, fetchToken, getWalletClient, waitForTransaction
export const useTokenStore = defineStore("token", {
state: () => ({
//some static data for the coin
token: [
{
name: "$PEPE",
@@ -22,6 +22,8 @@ export const useTokenStore = defineStore("token", {
vamp: {
logo: "/assets/img/token/pepevamp.png",
name: "$PEPE Vamp Token",
winner: "/assets/img/token/pepewinner.png",
winner2: "/assets/img/token/pepewinnerborder.png",
},
backgroundColor: "#4b8501",
abi: Meme1Json.abi,
@@ -34,6 +36,8 @@ export const useTokenStore = defineStore("token", {
vamp: {
logo: "/assets/img/token/shibvamp.png",
name: "$SHIBA Vamp Token",
winner: "/assets/img/token/shibwinner.png",
winner2: "/assets/img/token/shibwinnerborder.png",
},
abi: Meme2Json.abi,
contractAddress: Meme2Json.contractAddress,
@@ -45,6 +49,8 @@ export const useTokenStore = defineStore("token", {
vamp: {
logo: "/assets/img/token/elonvamp.png",
name: "$ELON Vamp Token",
winner: "/assets/img/token/elonwinner.png",
winner2: "/assets/img/token/elonwinnerborder.png",
},
abi: Meme3Json.abi,
contractAddress: Meme3Json.contractAddress,
@@ -56,6 +62,8 @@ export const useTokenStore = defineStore("token", {
// vamp: {
// logo: "/assets/img/token/bitcoin.png",
// name: "$ELON Vamp Token",
// winner: "/assets/img/token/bitcoinwinner.png"
// winner2: "/assets/img/token/bitcoinwinnerborder.png"
// },
// abi: Meme4Json.abi,
// contractAddress: Meme4Json.contractAddress,
@@ -125,7 +133,6 @@ export const useTokenStore = defineStore("token", {
} catch (error) {
console.error("initV2", error);
}
},
async changeActiveToken(token) {
console.log("changeActiveToken");
@@ -141,16 +148,10 @@ export const useTokenStore = defineStore("token", {
console.log("allowance");
const walletStore = useWalletStoreV2();
const memeBurnerStore = useMemeburnerStore();
// var allowance = await this.contract.methods
// .allowance(walletStore.address, memeBurnerStore.config.contractAddress)
// .call();
console.log("this.activeToken.contract", this.activeToken.contract);
var allowance = await this.activeToken.contract.read.allowance([
walletStore.address,
memeBurnerStore.config.contractAddress,
]);
// var decimals = await this.contract.methods.decimals().call();
// console.log("decimals", decimals);
const decimals = this.activeToken.decimals;
allowance = BigInt(allowance / BigInt(Math.pow(10, decimals)));
@@ -162,11 +163,6 @@ export const useTokenStore = defineStore("token", {
console.log("amount", amount);
this.loading = true;
const memeBurnerStore = useMemeburnerStore();
// var approve = await this.contract.methods
// .approve(memeBurnerStore.config.contractAddress, amount)
// .send({ from: walletStore.address});
console.log("approve");
console.log("this.activeToken.contract", this.activeToken.contract);
var approveHash = await this.activeToken.contract.write.approve([
memeBurnerStore.config.contractAddress,
amount * Math.pow(10, this.activeToken.decimals),
@@ -176,7 +172,7 @@ export const useTokenStore = defineStore("token", {
return approveHash;
} catch (error) {
console.error(error);
throw new Error(error)
throw new Error(error);
} finally {
this.loading = false;
}
+2 -2
View File
@@ -48,14 +48,14 @@ export const useUniswapStore = defineStore("uniswap", {
token0: this.poolData.token0,
token1: this.poolData.token1,
fee: this.poolData.fee,
amountEthBase: amountEthBase[1],
amountEthBase: amountEthBase[0],
pricelimit: 0, //sqrtPriceLimitX96
});
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
this.poolData.token0, //bloodline
this.poolData.token1, //weth
this.poolData.fee,
amountEthBase[1],
amountEthBase[0],
0, //sqrtPriceLimitX96
]);
return {result: true, amount: quotedAmountOut};
+1 -28
View File
@@ -39,7 +39,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
config: null,
chain: null,
token: [],
stateSacrifice: 0,
}),
getters: {
sacrificeToken: (state) => state.token.filter((obj) => {
@@ -57,7 +56,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
async init() {
console.log("wallet init");
const account = getAccount();
if (account.address) {
@@ -65,24 +63,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
this.connected = true;
}
// await this.isConnected();
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
// if (this.connected) {
// const web3 = new Web3(window.ethereum);
// this.web3 = markRaw(web3);
// console.log("hierabc");
// window.ethereum.on("accountsChanged", async (data) => {
// console.log("accountsChanged", data);
// console.log("data", data);
// if (data.length > 0) {
// this.address = data[0];
// this.connected = true;
// } else {
// this.address = null;
// this.connected = false;
// }
// });
},
async connectWallet(connector) {
try {
@@ -103,17 +83,13 @@ export const useWalletStoreV2 = defineStore("walletV2", {
// this.address = connection.account;
},
async getTokenBalance(token) {
console.log("token", token);
console.log("address", this.address);
const result = await token.contract.read.balanceOf([this.address]);
return result;
},
async getTokenBalances() {
console.log("getTokenBalances");
this.token = []
const tokenStore = useTokenStore();
console.log("tokenStore.token.length", tokenStore.token.length);
var contracts = [];
for (let index = 0; index < tokenStore.token.length; index++) {
const token = tokenStore.token[index];
@@ -123,11 +99,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
const data = await multicall({
contracts,
});
console.log("data", data);
for (let index = 0; index < tokenStore.token.length; index++) {
const token = tokenStore.token[index];
console.log("token", token);
console.log("data[index].result", data[index].result);
const balanceOfDecimal = data[index].result / BigInt(Math.pow(10, token.decimals));
this.token.push({
contractAddress: token.contractAddress,
@@ -153,5 +126,5 @@ export const useWalletStoreV2 = defineStore("walletV2", {
}
},
persist: true,
// persist: true,
});
-22
View File
@@ -1,22 +0,0 @@
export default class Helper {
static debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
};
}
static createDebounce() {
let timeout = null;
return function (fnc, delayMs) {
clearTimeout(timeout);
timeout = setTimeout(() => {
fnc();
}, delayMs || 500);
};
}
}
+53 -52
View File
@@ -8,13 +8,13 @@
</div>
<div class="slider-wrapper" :class="{ sticking: sticking }" ref="target">
<font-awesome-icon
:class="{ 'slider-prev': true, disabled: roundsStore.activeRound <= 1 }"
:class="{ 'slider-prev': true, disabled: cycleStore.activeCycle <= 1 }"
@click="prevSlide"
:icon="['fas', 'caret-left']"
/>
<div class="slider-text sub-header">Cycle {{ roundsStore.activeRound }}</div>
<div class="slider-text sub-header">Cycle {{ cycleStore.activeCycle }}</div>
<font-awesome-icon
:class="{ 'slider-next': true, disabled: roundsStore.currentRound === roundsStore.activeRound }"
:class="{ 'slider-next': true, disabled: cycleStore.currentCycle === cycleStore.activeCycle }"
@click="nextSlide"
:icon="['fas', 'caret-right']"
/>
@@ -22,37 +22,35 @@
<div class="cycle card card--glow container container--variant1 bloodline-wrapper">
<div
class="bloodline-border round-finish-info low-mid-text"
v-if="difference > 0 && roundsStore.currentRound === roundsStore.activeRound"
v-if="difference > 0 && cycleStore.currentCycle === cycleStore.activeCycle"
>
<!-- <div class="round-finish-info-element low-mid-text"> -->
<div class="round-finish-info-key">Sacrifice Goal:</div>
<div class="round-finish-info-value">{{ roundsStore.getCurrentRoundData?.goalInBLD }} $BDL</div>
<div class="round-finish-info-value">{{ cycleStore.getCurrentCycleData?.goalInBLD }} $BDL</div>
<!-- </div> -->
<!-- <div class="round-finish-info-element low-mid-text"> -->
<div class="round-finish-info-key">Time left:</div>
<div class="round-finish-info-value">{{ days }} {{ hours }} {{ minutes }}</div>
<!-- </div> -->
</div>
<template v-if="roundsStore.currentRound !== roundsStore.activeRound">
<div
class="bloodline-border bloodline-border__thin grey cycle-winner"
v-if="roundsStore.getRoundWinner"
>
<template v-if="cycleStore.currentCycle !== cycleStore.activeCycle">
<div class="bloodline-border bloodline-border purple cycle-winner" v-if="cycleStore.getCycleWinner">
<div class="cycle-winner-left">
<div class="cycle-winner-headline">Clan Winner</div>
<div class="cycle-winner-subheadline">+25% Clan Bonus</div>
</div>
<div class="cycle-winner-right">
<div class="cycle-winner-logo">
<img :src="roundsStore.getRoundWinner.vamplogo" alt="" />
<img :src="cycleStore.getCycleWinner.vampwinner" alt="" />
</div>
<div class="cycle-winner-name">{{ roundsStore.getRoundWinner.name }}</div>
<div class="cycle-winner-name">{{ cycleStore.getCycleWinner.name }}</div>
</div>
</div>
<div class="bloodline-border bloodline-border__thin grey cycle-winner" v-else>
<!-- <loading-component></loading-component> -->
<div class="cycle-winner-left">
<div class="cycle-winner-headline">No Clan Winner</div>
<div class="cycle-winner-subheadline">time limit reached or activeround</div>
<div class="cycle-winner-subheadline">time limit has been reached</div>
</div>
<div class="cycle-winner-right">
<div class="cycle-winner-logo inactive">
@@ -67,13 +65,13 @@
<div class="bloodline-clan">
<div class="sub-header">Bloodline Clan</div>
<p class="mid-text">
Win extra rewards for you and your clan. Increase the strength of your bloodline by sacrificing more
memes.
Claim extra rewards when your clan wins the cycle. Increase the strength of your bloodline by
sacrificing more memes.
</p>
<div class="bloodline-container">
<div class="bloodline-border purple">Get up to +25% Clan Bonus <br />on your sacrifice.</div>
<div class="bloodline-border purple">Get up to +25% Clan Bonus on your sacrifice.</div>
</div>
<blood-chart :data="roundsStore.rounds[roundsStore.activeRound]"></blood-chart>
<blood-chart :data="cycleStore.cycles[cycleStore.activeCycle]"></blood-chart>
</div>
</div>
</div>
@@ -85,12 +83,11 @@ import { inject, ref, onMounted, onBeforeUnmount } from "vue";
import BloodChart from "@/components/BloodChart.vue";
import TokenClaim from "@/components/TokenClaim.vue";
import { useMemeburnerStore } from "@/stores/memeburner";
import CardComponent from "@/components/CardComponent.vue";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { useRewardLockerStore } from "@/stores/rewardlocker";
const roundsStore = useRoundsStore();
const cycleStore = useCycleStore();
const days = ref(null);
const hours = ref(null);
@@ -104,36 +101,26 @@ const observer = ref(null);
const observerElement = ref(null);
const memeBurnerStore = useMemeburnerStore();
const rewardLockerStore = useRewardLockerStore();
const isMobile = inject("isMobile");
onMounted(async () => {
console.log("onmounted", roundsStore.activeRound);
// await memeBurnerStore.init();
// await rewardLockerStore.init();
if (!roundsStore.currentRound) {
roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound());
console.log("roundsStore.currentRound", roundsStore.currentRound);
roundsStore.activeRound = roundsStore.currentRound;
//check if that still needed or old stuff
if (!cycleStore.currentCycle) {
cycleStore.currentCycle = parseInt(await memeBurnerStore.getCurrentCycle());
console.log("cycleStore.currentCycle", cycleStore.currentCycle);
cycleStore.activeCycle = cycleStore.currentCycle;
}
await roundsStore.fillRound(roundsStore.activeRound);
console.log("roundsStore.getCurrentRoundData", roundsStore.getCurrentRoundData);
if (roundsStore.currentRound === roundsStore.activeRound) {
const expirationTimestamp = roundsStore.getCurrentRoundData.expirationTimestamp;
await cycleStore.fillCycle(cycleStore.activeCycle);
if (cycleStore.currentCycle === cycleStore.activeCycle) {
const expirationTimestamp = cycleStore.getCurrentCycleData.expirationTimestamp;
timer.value = setInterval(function () {
timeBetweenDates(expirationTimestamp);
}, 1000);
}
const headerEl = document.querySelector(".slider-wrapper");
//if cycle header is getting sticky than grey the background
const handler = (entries) => {
console.log(entries);
// entries is an array of observed dom nodes
// we're only interested in the first one at [0]
// because that's our .sentinal node.
// Here observe whether or not that node is in the viewport
if (!entries[0].isIntersecting) {
headerEl.classList.add("stuck");
} else {
@@ -143,14 +130,12 @@ onMounted(async () => {
// create the observer
observer.value = new window.IntersectionObserver(handler);
// give the observer some dom nodes to keep an eye on
if (observerElement.value) {
observer.value.observe(observerElement.value);
}
});
onBeforeUnmount(() => {
console.log("clear");
clearInterval(timer.value);
if (observer.value) {
observer.value.unobserve(observerElement.value);
@@ -158,17 +143,16 @@ onBeforeUnmount(() => {
});
async function prevSlide() {
console.log("blub1", roundsStore.activeRound);
if (roundsStore.activeRound > 1) {
roundsStore.activeRound--;
await roundsStore.fillRound(roundsStore.activeRound);
if (cycleStore.activeCycle > 1) {
cycleStore.activeCycle--;
await cycleStore.fillCycle(cycleStore.activeCycle);
}
}
async function nextSlide() {
if (roundsStore.activeRound < roundsStore.currentRound) {
roundsStore.activeRound++;
await roundsStore.fillRound(roundsStore.activeRound);
if (cycleStore.activeCycle < cycleStore.currentCycle) {
cycleStore.activeCycle++;
await cycleStore.fillCycle(cycleStore.activeCycle);
}
}
@@ -221,7 +205,7 @@ function timeBetweenDates(expirationTimestamp) {
&.stuck
background: #2D2D2D
@media (min-width: 992px)
top: 96px
top: 80px
.slider-text
margin: 0 24px
margin-top: auto
@@ -267,13 +251,30 @@ function timeBetweenDates(expirationTimestamp) {
.cycle-winner-subheadline
font-size: 12px
.cycle-winner-right
display: flex
flex-direction: column
justify-content: space-between
align-items: center
.cycle-winner-logo
height: 48px
width: 48px
position: relative
img
height: 49px
width: 49px
height: 72px
width: 72px
border-radius: 50%
position: absolute
left: 50%
top: 10px
transform: translate(-50%, -50%)
&.inactive
img
height: 100%
width: 100%
top: unset
left: unset
transform: unset
position: unset
opacity: 0.3
.cycle-winner-name
font-size: 16px
+1 -6
View File
@@ -37,19 +37,15 @@
</template>
<script setup>
import { ref, computed, inject, onMounted, onBeforeUnmount } from "vue";
import { ref, inject } from "vue";
import { storeToRefs } from "pinia";
import SacrificeToken from "@/components/SacrificeToken.vue";
import { Collapse } from "vue-collapsed";
// import { useWalletStore } from "@/stores/wallet";
import { useTokenStore } from "@/stores/tokens";
import { useRoundsStore } from "@/stores/rounds";
const tokenStore = useTokenStore();
const roundsStore = useRoundsStore();
const { getCurrentRoundData } = storeToRefs(roundsStore);
const { currentRound, activeRound, rounds } = storeToRefs(roundsStore);
const tutorialWrapper = ref(null);
const openTutorial = ref(false);
const isMobile = inject("isMobile");
@@ -58,7 +54,6 @@ function openTutorialFunc(e) {
openTutorial.value = !openTutorial.value;
setTimeout(function () {
let element = document.getElementById("section-header-container");
console.log("element", element);
element.scrollIntoView({ behavior: "smooth" });
}, 200);
}
+9 -132
View File
@@ -68,157 +68,34 @@
</div>
</div>
</template>
<!-- <div class="cycle-wrapper">
<div class="cycle-inner">
<div class="cycle-headline">Cycles</div>
<div class="cycle-header">
<div class="cycle-header-left">Cycle</div>
<div class="cycle-header-right">Reward</div>
</div>
<div class="cycle-rounds">
<div class="cycle-round" v-for="(round, index) in rounds" :key="index">
<template v-if="round">
<div class="cycle-round-inner">
<div class="cycle-round-number">{{ round.round }}</div>
<div class="cycle-round-badget" v-if="roundsStore.currentRound === round.round">
active
</div>
<div class="cycle-round-reward" v-if="roundsStore.currentRound === round.round">
todo
</div>
<div class="cycle-round-reward" v-else>
{{ Number(round.rewards_total / BigInt(Math.pow(10, 18))) }} $BDL
</div>
<div class="cycle-round-more" @click="openRound(index)">
<font-awesome-icon
v-if="openCycleElement && index === activeRound"
icon="chevron-up"
/>
<font-awesome-icon v-else icon="chevron-down" />
</div>
</div>
<div class="cycle-round-detail" v-if="openCycleElement && index === activeRound">
<div class="cycle-round-detail-inner">
<div class="sacrifice-reward-wrapper">
<div class="sacrifice-reward-inner">
<div class="sacrifice-reward-header">
<div class="sacrifice-reward-header-name">Sacrifice Reward</div>
<div class="sacrifice-reward-header-amount">+2,000 $BDL</div>
</div>
<table class="sacrifice-coins">
<tr class="sacrifice-coin">
<td>2b PEPE</td>
<td class="arrow"><font-awesome-icon icon="arrow-right" /></td>
<td>1,500 $BDL</td>
</tr>
<tr class="sacrifice-coin">
<td>10m SHIB</td>
<td class="arrow"><font-awesome-icon icon="arrow-right" /></td>
<td class="bloodline">500 $BDL</td>
</tr>
</table>
</div>
</div>
<div class="sacrifice-reward-wrapper">
<div class="sacrifice-reward-inner">
<div class="sacrifice-reward-header">
<div class="sacrifice-reward-header-name">Staking Bonus</div>
<div class="sacrifice-reward-header-amount">+1,000 $BDL</div>
</div>
<table class="sacrifice-coins">
<tr class="sacrifice-coin">
<td>Staked</td>
<td class="arrow"></td>
<td class="bloodline">1,000 $BDL</td>
</tr>
</table>
</div>
</div>
<div class="sacrifice-reward-wrapper">
<div class="sacrifice-reward-inner">
<div class="sacrifice-reward-header">
<div class="sacrifice-reward-header-name">Competition Bonus</div>
<div class="sacrifice-reward-header-amount">+200 $BDL</div>
</div>
<table class="sacrifice-coins">
<tr class="sacrifice-coin">
<td><img src="/assets/img/winner.png" alt="" /></td>
<td><img src="/assets/img/token/pepevamp.png" alt="" /></td>
<td>$PEPE</td>
<td class="arrow"></td>
<td class="bloodline">1,000 $BDL</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</template>
</div>
</div>
</div>
</div> -->
</div>
</template>
<script setup>
import { ref, onMounted, computed, inject } from "vue";
import { useRoundsStore } from "@/stores/rounds";
import { useCycleStore } from "@/stores/cycles";
import { useWalletStoreV2 } from "@/stores/walletV2";
import { getblocky, getAddressShortName } from "@/helper/helper.js";
import CardComponent from "@/components/CardComponent.vue";
import StakeComponentV1 from "@/components/StakeComponentV1.vue";
import ClaimComponent from "@/components/ClaimComponent.vue";
import { useMemeburnerStore } from "@/stores/memeburner";
import { useRewardLockerStore } from "@/stores/rewardlocker";
const roundsStore = useRoundsStore();
const cycleStore = useCycleStore();
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);
function openRound(index) {
if (activeRound.value === index && openCycleElement.value) {
openCycleElement.value = false;
} else {
openCycleElement.value = true;
}
activeRound.value = index;
}
onMounted(async () => {
// await memeBurnerStore.init();
// await rewardLockerStore.init();
console.log("loadRounds");
if (!roundsStore.currentRound) {
roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound());
console.log("roundsStore.currentRound", roundsStore.currentRound);
roundsStore.activeRound = roundsStore.currentRound;
//todo check that code, probably old stuff
if (!cycleStore.currentCycle) {
cycleStore.currentCycle = parseInt(await memeBurnerStore.getCurrentCycle());
console.log("cycleStore.currentCycle", cycleStore.currentCycle);
cycleStore.activeCycle = cycleStore.currentCycle;
}
//brauche ich das?
// await roundsStore.loadRewardsRounds();
console.log("roundsStore.rounds", roundsStore.rounds);
});
const rounds = computed(() => {
var tetst = roundsStore.rounds
.filter((round) => {
if (round.round) {
return true;
} else {
return false;
}
})
.reverse();
return tetst;
console.log("cycleStore.cycles", cycleStore.cycles);
});
</script>
@@ -364,7 +241,7 @@ const rounds = computed(() => {
justify-content: space-between
padding: 8px 16px
font-size: 18px
.cycle-rounds
.cycle-cycles
gap: 8px
display: flex
flex-direction: column
+1 -1
View File
@@ -152,7 +152,7 @@ async function mintToken() {
async function mintToken2() {
try {
var mint = await tokenStore.token[0].contract.write.mint(["100000000000000000000"]);
var mint = await tokenStore.token[1].contract.write.mint(["100000000000000000000000"]);
// .send({ from: web3.value.eth.Contract.defaultAccount });
console.log("mint", mint);
} catch (error) {