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