diff --git a/README.md b/README.md index d8921a8..be1dc00 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/public/assets/img/token/elonvamp.png b/public/assets/img/token/elonvamp.png index baf3846..f4800a9 100644 Binary files a/public/assets/img/token/elonvamp.png and b/public/assets/img/token/elonvamp.png differ diff --git a/public/assets/img/token/pepevamp.png b/public/assets/img/token/pepevamp.png index f1dfc69..225281f 100644 Binary files a/public/assets/img/token/pepevamp.png and b/public/assets/img/token/pepevamp.png differ diff --git a/public/assets/img/token/shibvamp.png b/public/assets/img/token/shibvamp.png index 497e726..5c884c9 100644 Binary files a/public/assets/img/token/shibvamp.png and b/public/assets/img/token/shibvamp.png differ diff --git a/src/App.vue b/src/App.vue index 339d3b6..75f7985 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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); }); @@ -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 diff --git a/src/assets/contracts/Bloodline.json b/src/assets/contracts/Bloodline.json index e4a7386..e60ecfb 100644 --- a/src/assets/contracts/Bloodline.json +++ b/src/assets/contracts/Bloodline.json @@ -1,6 +1,6 @@ { "contractName": "Bloodline", - "contractAddress": "0xBd6bB82108D5F27E8A8f081723408bF26d665a8c", + "contractAddress": "0xB7d11da1922328A10cCb357F571125151e558aFe", "abi": [ { "inputs": [ diff --git a/src/assets/contracts/LiquidityOwner.json b/src/assets/contracts/LiquidityOwner.json index 0917e82..b5ecdd6 100644 --- a/src/assets/contracts/LiquidityOwner.json +++ b/src/assets/contracts/LiquidityOwner.json @@ -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": [ { diff --git a/src/assets/contracts/MemeAltar.json b/src/assets/contracts/MemeAltar.json index 147fee4..3c6797f 100644 --- a/src/assets/contracts/MemeAltar.json +++ b/src/assets/contracts/MemeAltar.json @@ -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": [ { diff --git a/src/assets/contracts/RewardLocker.json b/src/assets/contracts/RewardLocker.json index 611fb30..a8218e6 100644 --- a/src/assets/contracts/RewardLocker.json +++ b/src/assets/contracts/RewardLocker.json @@ -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" } ], diff --git a/src/assets/contracts/UniswapPool.json b/src/assets/contracts/UniswapPool.json index 47b29ee..1791b46 100644 --- a/src/assets/contracts/UniswapPool.json +++ b/src/assets/contracts/UniswapPool.json @@ -1,5 +1,5 @@ { "contractName": "OurUniV3Pool", - "contractAddress": "0xAAC69F9d8A960eeda4F8211CA9F17aD6151D8F25", + "contractAddress": "0xA82a55f15Ed9c4fcaf260A7fdDbc3ba8E35959fb", "abi": [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"int24","name":"tickLower","type":"int24"},{"indexed":true,"internalType":"int24","name":"tickUpper","type":"int24"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"int24","name":"tickLower","type":"int24"},{"indexed":true,"internalType":"int24","name":"tickUpper","type":"int24"},{"indexed":false,"internalType":"uint128","name":"amount0","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"amount1","type":"uint128"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount0","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"amount1","type":"uint128"}],"name":"CollectProtocol","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paid0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paid1","type":"uint256"}],"name":"Flash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"observationCardinalityNextOld","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"observationCardinalityNextNew","type":"uint16"}],"name":"IncreaseObservationCardinalityNext","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"indexed":false,"internalType":"int24","name":"tick","type":"int24"}],"name":"Initialize","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"int24","name":"tickLower","type":"int24"},{"indexed":true,"internalType":"int24","name":"tickUpper","type":"int24"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"feeProtocol0Old","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"feeProtocol1Old","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"feeProtocol0New","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"feeProtocol1New","type":"uint8"}],"name":"SetFeeProtocol","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"int256","name":"amount0","type":"int256"},{"indexed":false,"internalType":"int256","name":"amount1","type":"int256"},{"indexed":false,"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"int24","name":"tick","type":"int24"}],"name":"Swap","type":"event"},{"inputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"amount0Requested","type":"uint128"},{"internalType":"uint128","name":"amount1Requested","type":"uint128"}],"name":"collect","outputs":[{"internalType":"uint128","name":"amount0","type":"uint128"},{"internalType":"uint128","name":"amount1","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Requested","type":"uint128"},{"internalType":"uint128","name":"amount1Requested","type":"uint128"}],"name":"collectProtocol","outputs":[{"internalType":"uint128","name":"amount0","type":"uint128"},{"internalType":"uint128","name":"amount1","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeGrowthGlobal0X128","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeGrowthGlobal1X128","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"observationCardinalityNext","type":"uint16"}],"name":"increaseObservationCardinalityNext","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquidity","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLiquidityPerTick","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mint","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"observations","outputs":[{"internalType":"uint32","name":"blockTimestamp","type":"uint32"},{"internalType":"int56","name":"tickCumulative","type":"int56"},{"internalType":"uint160","name":"secondsPerLiquidityCumulativeX128","type":"uint160"},{"internalType":"bool","name":"initialized","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"secondsAgos","type":"uint32[]"}],"name":"observe","outputs":[{"internalType":"int56[]","name":"tickCumulatives","type":"int56[]"},{"internalType":"uint160[]","name":"secondsPerLiquidityCumulativeX128s","type":"uint160[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positions","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"feeGrowthInside0LastX128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthInside1LastX128","type":"uint256"},{"internalType":"uint128","name":"tokensOwed0","type":"uint128"},{"internalType":"uint128","name":"tokensOwed1","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFees","outputs":[{"internalType":"uint128","name":"token0","type":"uint128"},{"internalType":"uint128","name":"token1","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"feeProtocol0","type":"uint8"},{"internalType":"uint8","name":"feeProtocol1","type":"uint8"}],"name":"setFeeProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slot0","outputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"internalType":"int24","name":"tick","type":"int24"},{"internalType":"uint16","name":"observationIndex","type":"uint16"},{"internalType":"uint16","name":"observationCardinality","type":"uint16"},{"internalType":"uint16","name":"observationCardinalityNext","type":"uint16"},{"internalType":"uint8","name":"feeProtocol","type":"uint8"},{"internalType":"bool","name":"unlocked","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"name":"snapshotCumulativesInside","outputs":[{"internalType":"int56","name":"tickCumulativeInside","type":"int56"},{"internalType":"uint160","name":"secondsPerLiquidityInsideX128","type":"uint160"},{"internalType":"uint32","name":"secondsInside","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"int256","name":"amountSpecified","type":"int256"},{"internalType":"uint160","name":"sqrtPriceLimitX96","type":"uint160"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[{"internalType":"int256","name":"amount0","type":"int256"},{"internalType":"int256","name":"amount1","type":"int256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int16","name":"","type":"int16"}],"name":"tickBitmap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tickSpacing","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int24","name":"","type":"int24"}],"name":"ticks","outputs":[{"internalType":"uint128","name":"liquidityGross","type":"uint128"},{"internalType":"int128","name":"liquidityNet","type":"int128"},{"internalType":"uint256","name":"feeGrowthOutside0X128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthOutside1X128","type":"uint256"},{"internalType":"int56","name":"tickCumulativeOutside","type":"int56"},{"internalType":"uint160","name":"secondsPerLiquidityOutsideX128","type":"uint160"},{"internalType":"uint32","name":"secondsOutside","type":"uint32"},{"internalType":"bool","name":"initialized","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] } diff --git a/src/assets/sass/variables.sass b/src/assets/sass/variables.sass index b44e9ef..05b0a7d 100644 --- a/src/assets/sass/variables.sass +++ b/src/assets/sass/variables.sass @@ -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 diff --git a/src/components/BloodChart.vue b/src/components/BloodChart.vue index 3cbd270..8493409 100644 --- a/src/components/BloodChart.vue +++ b/src/components/BloodChart.vue @@ -20,7 +20,12 @@
- logo + +
{{ coin.name }}
@@ -67,8 +72,7 @@ @@ -91,7 +95,9 @@ diff --git a/src/components/ClaimComponent.vue b/src/components/ClaimComponent.vue index 5ce48cc..b5cd8c8 100644 --- a/src/components/ClaimComponent.vue +++ b/src/components/ClaimComponent.vue @@ -37,7 +37,7 @@
Stake & Claim Rest
@@ -55,7 +55,9 @@ @@ -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, - }); -} - + diff --git a/src/components/ConnectWallet.vue b/src/components/ConnectWallet.vue index 9fca2dc..abffc51 100644 --- a/src/components/ConnectWallet.vue +++ b/src/components/ConnectWallet.vue @@ -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); -}); - - diff --git a/src/helper/helper.js b/src/helper/helper.js index 0c90a6f..755e507 100644 --- a/src/helper/helper.js +++ b/src/helper/helper.js @@ -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); + }; +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index 668f63b..c05ca7e 100644 --- a/src/main.js +++ b/src/main.js @@ -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); } ); @@ -203,7 +178,8 @@ try { await memeBurnerStore.init(); await tokenStore.initV2(); await rewardLockerStore.init(); - await walletStore.loadWalletData(); + 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(); diff --git a/src/stores/contracts.js b/src/stores/contracts.js deleted file mode 100644 index 940ec16..0000000 --- a/src/stores/contracts.js +++ /dev/null @@ -1,12 +0,0 @@ -import { defineStore } from "pinia"; -export const useContractStore = defineStore("contracts", { - state: () => ({ - list: { - - } - }), - getters: { - }, - actions: { - } -}); diff --git a/src/stores/memeburner.js b/src/stores/memeburner.js index e0b6dd2..2f98a39 100644 --- a/src/stores/memeburner.js +++ b/src/stores/memeburner.js @@ -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"); diff --git a/src/stores/rewardlocker.js b/src/stores/rewardlocker.js index dd5be8c..bc1a3e9 100644 --- a/src/stores/rewardlocker.js +++ b/src/stores/rewardlocker.js @@ -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 { - console.log("claim"); - return await this.contract.write.claim([round]); - } catch (error) { - console.error("claim", error); - - } + async claim(cycle) { + console.log("claim"); + 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); - } + return await this.contract.read.staked([address]); }, async orderUnstake() { - try { - return await this.contract.write.orderUnstake(); - } catch (error) { - console.error("orderUnstake", error); - throw new Error(error) - } + return await this.contract.write.orderUnstake(); }, - 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; }, }, diff --git a/src/stores/rounds.js b/src/stores/rounds.js deleted file mode 100644 index 6bd2742..0000000 --- a/src/stores/rounds.js +++ /dev/null @@ -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; - }, - }, -}); diff --git a/src/stores/tokens.js b/src/stores/tokens.js index 37b768a..2bd835e 100644 --- a/src/stores/tokens.js +++ b/src/stores/tokens.js @@ -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"; @@ -13,7 +12,8 @@ import { multicall, getContract, fetchToken, getWalletClient, waitForTransaction export const useTokenStore = defineStore("token", { - state: () => ({ + 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, @@ -100,7 +108,7 @@ export const useTokenStore = defineStore("token", { async initV2() { console.log("-----------init token-------------"); try { - const walletStore = useWalletStoreV2(); + const walletStore = useWalletStoreV2(); for (let index = 0; index < this.token.length; index++) { const contracts = []; const token = this.token[index]; @@ -122,11 +130,10 @@ export const useTokenStore = defineStore("token", { token.symbol = data[2].result; token.totalSupply = data[3].result; } - } catch (error) { - console.error("initV2", error); - } - - }, + } catch (error) { + console.error("initV2", error); + } + }, async changeActiveToken(token) { console.log("changeActiveToken"); this.activeToken = token; @@ -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,21 +163,16 @@ 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), ]); console.log("approveHash", approveHash); - return approveHash; + return approveHash; } catch (error) { - console.error(error); - throw new Error(error) + console.error(error); + throw new Error(error); } finally { this.loading = false; } diff --git a/src/stores/uniswap.js b/src/stores/uniswap.js index 04cf4ba..eb4fd9b 100644 --- a/src/stores/uniswap.js +++ b/src/stores/uniswap.js @@ -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}; diff --git a/src/stores/walletV2.js b/src/stores/walletV2.js index 98b3eb3..5ffa0c8 100644 --- a/src/stores/walletV2.js +++ b/src/stores/walletV2.js @@ -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, }); diff --git a/src/utils/helper.js b/src/utils/helper.js deleted file mode 100644 index e316c01..0000000 --- a/src/utils/helper.js +++ /dev/null @@ -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); - }; - } -} diff --git a/src/views/CycleView.vue b/src/views/CycleView.vue index 7aa1d73..a840909 100644 --- a/src/views/CycleView.vue +++ b/src/views/CycleView.vue @@ -8,13 +8,13 @@
-
Cycle {{ roundsStore.activeRound }}
+
Cycle {{ cycleStore.activeCycle }}
@@ -22,37 +22,35 @@
Sacrifice Goal:
-
{{ roundsStore.getCurrentRoundData?.goalInBLD }} $BDL
+
{{ cycleStore.getCurrentCycleData?.goalInBLD }} $BDL
Time left:
{{ days }} {{ hours }} {{ minutes }}
-