new contracts + visual improvements + cyle end

This commit is contained in:
EmberSpirit
2023-07-20 20:28:21 +02:00
parent cb85a47a94
commit 994c440e2f
13 changed files with 398 additions and 128 deletions
-1
View File
@@ -41,7 +41,6 @@ provide("isMobile", isMobile);
onMounted(async () => {
window.addEventListener("resize", handleWindowSizeChange);
handleWindowSizeChange();
// initContracts
await walletStore.init();
await tokenStore.init();
+30 -1
View File
@@ -1,6 +1,6 @@
{
"contractName": "LiquidityOwner",
"contractAddress": "0xa162bb56eD85f1BEb6f9AdB1DFFecBa01eA51d50",
"contractAddress": "0x88E69D5CE691644F7cE151a2b085798194DAFEa1",
"abi": [
{
"inputs": [
@@ -440,6 +440,35 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "payForGas",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "memeAltarGasPrice",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "consumedGasByMemeAltar",
"type": "uint256"
}
],
"name": "triggeredByMemeAltar",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "uniV3Pool",
+224 -23
View File
@@ -1,6 +1,6 @@
{
"contractName": "MemeBurner",
"contractAddress": "0xf6e6ffAb831eCC42aBDD1c068DC83b89b9CF8386",
"contractAddress": "0xc9cC73C414f122f85EfE20382EB753d29C5a0351",
"abi": [
{
"inputs": [
@@ -43,11 +43,6 @@
"internalType": "uint256[]",
"name": "roundGoals",
"type": "uint256[]"
},
{
"internalType": "uint256",
"name": "_liquidityAmountLimit",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
@@ -68,16 +63,36 @@
"name": "LiquidityOwnerAlreadyInitialized",
"type": "error"
},
{
"inputs": [],
"name": "LiquidityOwnerTriggerFailed",
"type": "error"
},
{
"inputs": [],
"name": "MemeIsNotInAList",
"type": "error"
},
{
"inputs": [],
"name": "NextRoundRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "NothingToSacrifice",
"type": "error"
},
{
"inputs": [],
"name": "RewardRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "RoundCompletedRegistrationFailed",
"type": "error"
},
{
"inputs": [],
"name": "TokenIsNotInSacrificableList",
@@ -176,6 +191,51 @@
"name": "NewAdmin",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"components": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"indexed": true,
"internalType": "struct MemeBurner.BM",
"name": "_bm",
"type": "tuple"
}
],
"name": "NewBM",
"type": "event"
},
{
"anonymous": false,
"inputs": [
@@ -189,6 +249,19 @@
"name": "NewDefaultRoundGoal",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "newDurationLimit",
"type": "uint256"
}
],
"name": "NewRoundDurationLimit",
"type": "event"
},
{
"inputs": [
{
@@ -213,6 +286,57 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"internalType": "struct MemeBurner.BM",
"name": "newBM",
"type": "tuple"
}
],
"name": "adjustBM",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
@@ -232,6 +356,25 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "newDurationLimit",
"type": "uint256"
}
],
"name": "adjustRoundDurationLimit",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "admin",
@@ -245,6 +388,44 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "bm",
"outputs": [
{
"internalType": "uint8",
"name": "b1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m1",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m2",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "b3",
"type": "uint8"
},
{
"internalType": "uint8",
"name": "m4",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentRound",
@@ -290,6 +471,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "roundNumber",
"type": "uint256"
}
],
"name": "getGoalInBLD",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -343,19 +543,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "liquidityAmountLimit",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "liquidityOwner",
@@ -439,6 +626,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "roundDurationLimit",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
@@ -453,6 +653,11 @@
"internalType": "uint256",
"name": "goal",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "expirationTimestamp",
"type": "uint256"
}
],
"stateMutability": "view",
@@ -526,10 +731,6 @@
],
"stateMutability": "view",
"type": "function"
},
{
"stateMutability": "payable",
"type": "receive"
}
]
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"contractName": "MemeToken",
"contractAddress": "0x2052cCA2b50f5F609a450f2C055E53e969E56587",
"contractAddress": "0x9dcD7Cd83ED0Fe69DDfE3c2A265a1207F2Bc3219",
"abi": [
{
"inputs": [
+4 -4
View File
@@ -1,6 +1,6 @@
{
"contractName": "RewardLocker",
"contractAddress": "0xb2f281CDa06E17Eefc4cf0A485C43a8310012d8B",
"contractAddress": "0x7C3D5a19878d550D0c6c2b0BFC884ef410F6e440",
"abi": [
{
"inputs": [
@@ -580,9 +580,9 @@
"name": "rounds",
"outputs": [
{
"internalType": "bool",
"name": "roundCompleted",
"type": "bool"
"internalType": "uint256",
"name": "roundCompletedTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
+4
View File
@@ -14,3 +14,7 @@
background-color: lighten($button-background-color, 10%),
color: darken($button-color, 10%),
cursor: pointer
&.btn--disabled
background-color: #151515
color: #808080
cursor: not-allowed
+33 -13
View File
@@ -8,7 +8,13 @@
<div class="sacrifice-tokens">
<div
class="sacrifice-token"
:class="[{ 'sacrifice-token--active': token.contractAddress === activeToken.contractAddress }]"
:class="[
{
'sacrifice-token--active': token.contractAddress === activeToken.contractAddress,
'bloodline-border': token.contractAddress === activeToken.contractAddress,
'bloodline-border--variant1': token.contractAddress === activeToken.contractAddress,
},
]"
v-for="token in props.data"
:key="token.contractAddress"
@click="tokenStore.changeActiveToken(token)"
@@ -22,7 +28,14 @@
</div>
</div>
<div class="sacrifice-from-to-wrapper" v-if="activeToken.contractAddress">
<div class="sacrifice-from-wrapper bloodline-border bloodline-border--variant1">
<div
:class="{
'sacrifice-from-wrapper': true,
'bloodline-border': true,
'bloodline-border--variant1': true,
purple: isMobile,
}"
>
<div class="sarcrifice-from-input">
<input @input="processChange" v-model="tokenNumber" :placeholder="0" />
<div class="sacrifice-logo">
@@ -42,7 +55,14 @@
<div class="sacrifice-divider bloodline-devider">
<font-awesome-icon :icon="['fas', 'arrow-down']" />
</div>
<div class="sacrifice-to-wrapper bloodline-border bloodline-border--variant1">
<div
:class="{
'sacrifice-from-wrapper': true,
'bloodline-border': true,
'bloodline-border--variant1': true,
purple: isMobile && output && output > 0,
}"
>
<div class="sarcrifice-from-input">
<div class="sacrifice-to-output">
<div class="sacrifice-to-output-coin">$BLOOD</div>
@@ -94,7 +114,7 @@
</template>
<script setup>
import { ref, defineProps, watch, inject } from "vue";
import { ref, defineProps, watch, inject, computed } from "vue";
import { useWalletStore } from "@/stores/wallet";
import { useTokenStore } from "@/stores/tokens";
import { useMemeburnerStore } from "@/stores/memeBurner";
@@ -129,7 +149,7 @@ const approvalData = ref(null);
const processChange = Helper.debounce((e) => getRewardsFor(e));
async function getRewardsFor(e) {
if (!e.target.value) {
if (!e.target.value || isNaN(e.target.value)) {
output.value = 0;
return;
}
@@ -186,15 +206,15 @@ async function addTokens(value) {
cursor: pointer
background-color: #0F0F0F
text-align: center
@media (min-width: 992px)
padding: 0
background-color: unset
&:hover,
&:active,
&:focus
background-color: var(--tertiary-dark)
// @media (min-width: 992px)
// padding: 0
// background-color: unset
&.sacrifice-token--active
background-color: var(--tertiary-dark)
padding: 10px
border-color: var(--purple)
@media (min-width: 992px)
border-color: var(--blood-color)
.sacrifice-token-name
padding: 5px 26px
font-size: 16px
+6 -2
View File
@@ -35,7 +35,11 @@
<rewards-wrapper title="Total Reward" coin="$BLOOD" amount="0" image="/src/assets/img/vampir.png" />
</div>
<div class="claim-button">
<div class="btn btn-immortal" @click="claimRewards">Claim</div>
<div v-if="activeRound === currentRound" class="btn btn-immortal btn--disabled">Cycle Active</div>
<div v-else-if="getCurrentRoundData?.rewards_total > 0" class="btn btn-immortal" @click="claimRewards">
Claim
</div>
<div v-else class="btn btn-immortal btn--disabled">Nothing to claim</div>
</div>
</div>
</template>
@@ -54,7 +58,7 @@ const rewardLockerStore = useRewardLockerStore();
const walletStore = useWalletStore();
const roundStore = useRoundsStore();
const { address } = storeToRefs(walletStore);
const { activeRound, getCurrentRoundData } = storeToRefs(roundStore);
const { activeRound, currentRound, getCurrentRoundData } = storeToRefs(roundStore);
onMounted(async () => {});
+5 -1
View File
@@ -67,7 +67,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("token.contractAddress", token.contractAddress);
console.log("roundnumber", roundnumber);
var test = await this.getSacrificedMeme(roundnumber, token.contractAddress);
console.log("test", test);
console.log(token.name, test);
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
}
@@ -97,5 +97,9 @@ export const useMemeburnerStore = defineStore("memeburner", {
this.loading = false;
}
},
async getGoalInBLD(roundNumber) {
return await this.contract.methods.getGoalInBLD(roundNumber).call();
}
},
});
-2
View File
@@ -34,8 +34,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
const calls = [];
for (let index = 0; index < tokenStore.token.length; index++) {
const token = tokenStore.token[index];
var test = this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress);
console.log("test123", test);
calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
}
const multicallStore = useMultiCallStore();
+19 -22
View File
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import { useMemeburnerStore } from "./memeburner";
import { useTokenStore } from "./tokens";
import { useRewardLockerStore } from "./rewardlocker";
import { useWalletStore } from "./wallet";
export const useRoundsStore = defineStore("rounds", {
@@ -33,6 +34,7 @@ export const useRoundsStore = defineStore("rounds", {
console.log("fillRound");
const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore();
const walletStore = useWalletStore();
const rewardLockerStore = useRewardLockerStore();
// if (this.activeRound === this.currentRound) {
@@ -42,13 +44,12 @@ export const useRoundsStore = defineStore("rounds", {
console.log("round not filled --> fill round");
console.log("vor error");
var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
var rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
let rewardData = null;
if (await walletStore.isConnected()) {
rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
}
var goal = await memeBurnerStore.getGoal(this.activeRound);
console.log("goal", goal);
console.log("this.activeRound", this.activeRound);
console.log("dataabc", data);
console.log("rewardData", rewardData);
console.log("pepecoin-rewards", rewardData[0]);
var tokenArray = []
var rewards_clan = BigInt(0);
@@ -56,41 +57,37 @@ export const useRoundsStore = defineStore("rounds", {
for (let index = 0; index < data.length; index++) {
var tokenData = {};
const token = tokenStore.token[index];
console.log("testabcv", token);
console.log("123abc", token.contractAddress);
var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(this.activeRound, token.contractAddress);
console.log("testcoef",);
console.log(`rewards ${token.name}`, BigInt(rewardData[index]));
console.log(`clanwin multiplier ${token.name}`, (testcoef / 10000));
const clanwin = BigInt((testcoef / 10000 -1) * rewardData[index]);
console.log(`clanwin ${token.name}`, clanwin);
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
console.log(`sacrifice rewards`, sacrificeRewards);
console.log("token", token);
tokenData.name = token.name;
tokenData.contractAddress = token.contractAddress;
tokenData.vamplogo = token.vamp.logo;
tokenData.vampname = token.vamp.name;
tokenData.amount = data[index][1];
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
if (this.currentRound !== this.activeRound && await walletStore.isConnected()) {
const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
tokenData.rewards_ges = rewardData[index];
if (this.currentRound !== this.activeRound) {
tokenData.rewards_clan = clanwin;
console.log("clanwin", clanwin);
tokenData.rewards_sacrifice = sacrificeRewards;
rewards_clan = rewards_clan + BigInt(clanwin / BigInt(Math.pow(10, token.decimals)));
rewards_sacrifice =
rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));;
rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));
}
tokenArray.push(tokenData);
}
console.log("Math.pow(10, tokenStore.memeToken.decimals)", Math.pow(10, tokenStore.memeToken.decimals));
console.log("goal", goal);
const goalInBLD = await memeBurnerStore.getGoalInBLD(this.activeRound);
this.rounds[this.activeRound] = {
goal: goal,
goal: goal.goal,
goalInBLD: goalInBLD /Math.pow(10, tokenStore.memeToken.decimals),
expirationTimestamp: goal.expirationTimestamp,
rewards_clan: rewards_clan,
rewards_sacrifice: rewards_sacrifice,
rewards_total: rewards_clan + rewards_sacrifice,
token: tokenArray,
};
} else {
+17 -3
View File
@@ -15,10 +15,26 @@ export const useWalletStore = defineStore("wallet", {
},
actions: {
async init() {
console.log("wallet init");
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;
}
});
// provider = new ethers.BrowserProvider(window.ethereum);
} else {
const url = `https://eth-goerli.g.alchemy.com/v2/${goerliKey}`;
@@ -31,9 +47,6 @@ export const useWalletStore = defineStore("wallet", {
new Web3.providers.WebsocketProvider(`wss://eth-goerli.g.alchemy.com/v2/${goerliKey}`)
);
},
increment() {
this.count++;
},
connectWallet() {
const tokenStore = useTokenStore();
// if (window.ethereum) {
@@ -43,6 +56,7 @@ export const useWalletStore = defineStore("wallet", {
console.log("data", data);
this.address = data[0];
this.connected = true;
this.init();
})
.catch((error) => {
if (error.code === 4001) {
+42 -42
View File
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, inject, onMounted } from "vue";
import { ref, computed, inject, onMounted, onBeforeUnmount } from "vue";
import { storeToRefs } from "pinia";
import SacrificeToken from "@/components/SacrificeToken.vue";
import BloodChart from "@/components/BloodChart.vue";
@@ -15,17 +15,13 @@ const { getCurrentRoundData } = storeToRefs(roundsStore);
const { currentRound, activeRound, rounds } = storeToRefs(roundsStore);
// Import Swiper Vue.js components
const swiperInstance = ref();
import { Navigation } from "swiper";
import { Swiper, SwiperSlide } from "swiper/vue";
import "swiper/css";
import "swiper/css/navigation";
const days = ref(null);
const hours = ref(null);
const minutes = ref(null);
const seconds = ref(null);
const timer = ref(null);
const modules = [Navigation];
const isMobile = inject("isMobile");
function onSwiper(swiper) {
swiperInstance.value = swiper;
}
async function prevSlide() {
if (activeRound.value > 1) {
@@ -43,16 +39,40 @@ async function nextSlide() {
onMounted(() => {
console.log("getCurrentRoundData", getCurrentRoundData);
timer.value = setInterval(function () {
timeBetweenDates();
}, 1000);
});
// const computedRounds = computed(() => {
// if()
// return ""
// })
onBeforeUnmount(() => {
clearInterval(timer.value);
});
// let web3 = new Web3(
// "https://eth-goerli.g.alchemy.com/v2/0-W9tOm6v_QP1PfRV8RuBCpWr-qoEbkN"
// );
function timeBetweenDates() {
const dateEntered = new Date(getCurrentRoundData.value?.expirationTimestamp * 1000);
if (dateEntered) {
var now = new Date();
var difference = dateEntered.getTime() - now.getTime();
if (difference <= 0) {
clearInterval(timer.value);
} else {
var _seconds = Math.floor(difference / 1000);
var _minutes = Math.floor(_seconds / 60);
var _hours = Math.floor(_minutes / 60);
var _days = Math.floor(_hours / 24);
days.value = _days;
hours.value = _hours % 24;
minutes.value = _minutes % 60;
seconds.value = _seconds % 60;
days.value = ("0" + days.value).slice(-2) + "d";
hours.value = ("0" + hours.value).slice(-2) + "h";
minutes.value = ("0" + minutes.value).slice(-2) + "m";
}
}
}
</script>
<template>
@@ -74,20 +94,6 @@ onMounted(() => {
each cycle's end.
</div>
<section id="cycle-section" class="container">
<swiper
:slides-per-view="1"
:navigation="true"
:space-between="50"
@swiper="onSwiper"
:modules="modules"
class="cycle-slider"
>
<swiper-slide>Cycle 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
</swiper>
<div class="slider-wrapper">
<font-awesome-icon
:class="{ 'slider-prev': true, disabled: roundsStore.activeRound <= 1 }"
@@ -142,18 +148,18 @@ onMounted(() => {
<div class="cycle-end-text">A cycle ends when only one of these goals is reached.</div>
<div class="bloodline-border">
<table>
{{
getCurrentRoundData?.goal
}}
<tr>
<td>Sacrifice:</td>
<td class="divider"></td>
<td>200b $BLOOD</td>
<td>{{ getCurrentRoundData?.goalInBLD?.toFixed(2) }} $BDL</td>
</tr>
<tr>
<td>Time left:</td>
<td class="divider"></td>
<td>23h 59m</td>
<td v-if="currentRound === roundsStore.activeRound">
{{ days }} {{ hours }} {{ minutes }}
</td>
<td v-else>0</td>
</tr>
</table>
</div>
@@ -249,12 +255,6 @@ onMounted(() => {
text-align: center
padding-top: 10px
.cycle-slider
text-align: center
.swiper-button-next
right: 30%
.swiper-button-prev
left: 30%
.slider-wrapper
display: flex