Compare commits

7 Commits
21 changed files with 326 additions and 212 deletions
+27 -1
View File
@@ -23,7 +23,8 @@
"vue": "^3.3.2", "vue": "^3.3.2",
"vue-collapsed": "^1.2.8", "vue-collapsed": "^1.2.8",
"vue-router": "^4.2.0", "vue-router": "^4.2.0",
"vue-toastification": "^2.0.0-rc.5" "vue-toastification": "^2.0.0-rc.5",
"vue3-lottie": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
@@ -3941,6 +3942,11 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true "dev": true
}, },
"node_modules/lodash-es": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
},
"node_modules/lodash.isequal": { "node_modules/lodash.isequal": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
@@ -3964,6 +3970,11 @@
"loose-envify": "cli.js" "loose-envify": "cli.js"
} }
}, },
"node_modules/lottie-web": {
"version": "5.12.2",
"resolved": "https://registry.npmjs.org/lottie-web/-/lottie-web-5.12.2.tgz",
"integrity": "sha512-uvhvYPC8kGPjXT3MyKMrL3JitEAmDMp30lVkuq/590Mw9ok6pWcFCwXJveo0t5uqYw1UREQHofD+jVpdjBv8wg=="
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@@ -5822,6 +5833,21 @@
"vue": "^3.0.2" "vue": "^3.0.2"
} }
}, },
"node_modules/vue3-lottie": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/vue3-lottie/-/vue3-lottie-3.2.0.tgz",
"integrity": "sha512-PtNXbv7iD4XGmK8CXd71aLWmILIR6P6VzLMDw6ZzmDAeuJZuJ0MdOVnn50LOARgq+cOFJsn/2z+7tZh0F9T9qw==",
"dependencies": {
"lodash-es": "^4.17.21",
"lottie-web": "5.12.2"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"vue": "^3.2"
}
},
"node_modules/web3-eth-abi": { "node_modules/web3-eth-abi": {
"version": "1.10.1", "version": "1.10.1",
"resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.1.tgz", "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.1.tgz",
+2 -1
View File
@@ -24,7 +24,8 @@
"vue": "^3.3.2", "vue": "^3.3.2",
"vue-collapsed": "^1.2.8", "vue-collapsed": "^1.2.8",
"vue-router": "^4.2.0", "vue-router": "^4.2.0",
"vue-toastification": "^2.0.0-rc.5" "vue-toastification": "^2.0.0-rc.5",
"vue3-lottie": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
+6
View File
@@ -260,4 +260,10 @@ body:hover::-webkit-scrollbar-thumb
.toast-header, .toast-body .toast-header, .toast-body
font-size: 16px font-size: 16px
.Vue-Toastification__container
&.bloodline-toast-container
&.top-right
@media (min-width: 992px)
top: 100px
</style> </style>
File diff suppressed because one or more lines are too long
+6 -10
View File
@@ -4,12 +4,12 @@
<template v-slot:body> <template v-slot:body>
<token-name-price <token-name-price
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name" :name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
:price="walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals" :price="formatNumber(walletStore.unclaimedRewards)"
></token-name-price> ></token-name-price>
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo> <token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline logo'"></token-logo>
</template> </template>
<template v-slot:actions> <template v-slot:actions>
<template v-if="walletStore.memeToken?.unclaimedRewards > 0"> <template v-if="walletStore.unclaimedRewards > 0">
<Transition name="smooth"> <Transition name="smooth">
<div class="connected-stake-buttons" v-show="!stakeMenu"> <div class="connected-stake-buttons" v-show="!stakeMenu">
<div class="btn btn-immortal mid-mid-text" @click="claimAll" v-if="stateStake === 0">Claim</div> <div class="btn btn-immortal mid-mid-text" @click="claimAll" v-if="stateStake === 0">Claim</div>
@@ -26,9 +26,9 @@
<stake-menu <stake-menu
v-model="tokenNumber" v-model="tokenNumber"
@close="stakeMenu = false" @close="stakeMenu = false"
:amount="walletStore.memeToken?.unclaimedRewards" :amount="walletStore.unclaimedRewards"
:stake="stake" :stake="stake"
v-if="stakeMenu && walletStore.memeToken?.unclaimedRewards" v-if="stakeMenu"
> >
<template v-slot:body> <template v-slot:body>
<div class="btn btn-immortal stake-button" disabled v-if="stateClaimComp === 0"> <div class="btn btn-immortal stake-button" disabled v-if="stateClaimComp === 0">
@@ -55,13 +55,9 @@
</div> </div>
</template> </template>
<template v-slot:message-end> <template v-slot:message-end>
<div class="input-balance" v-if="walletStore.memeToken?.unclaimedRewards"> <div class="input-balance">
Balance: Balance:
{{ {{ formatNumber(walletStore.unclaimedRewards) }}
formatNumber(
walletStore.memeToken?.unclaimedRewards / 10n ** tokenStore.memeToken.decimals
)
}}
</div> </div>
</template> </template>
</stake-menu> </stake-menu>
+1 -1
View File
@@ -120,7 +120,7 @@ function badgeClick(token) {
if (tokenStore.memeToken.contractAddress === token.contractAddress) { if (tokenStore.memeToken.contractAddress === token.contractAddress) {
//buy //buy
window.open( window.open(
"https://app.uniswap.org/swap?inputCurrency=ETH&outputCurrency=0x00E5DAd5dA0FC4Da0baB7f0D99E28C07d8A88ee4&chain=goerli", `https://app.uniswap.org/swap?inputCurrency=ETH&outputCurrency=${token.contractAddress}&chain=goerli`,
"_blank" "_blank"
); );
} else { } else {
+2 -2
View File
@@ -358,8 +358,8 @@ async function changeActiveToken(token) {
console.log("changeActiveToken"); console.log("changeActiveToken");
tokenStore.activeToken = token; tokenStore.activeToken = token;
if (walletStore.connected) { if (walletStore.connected) {
//TODO, wenn connected, dann all diese Daten laden? // //TODO, wenn connected, dann all diese Daten laden?
tokenStore.activeToken.balance = await walletStore.getTokenBalance(token); // tokenStore.activeToken.balance = await walletStore.getTokenBalance(token);
tokenStore.activeToken.allowance = Number(await tokenStore.allowance()); tokenStore.activeToken.allowance = Number(await tokenStore.allowance());
} }
var rewards = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, token); var rewards = await sacrificeStore.getRewardsFor(sacrificeStore.sacrificeNumber, token);
+13 -4
View File
@@ -80,7 +80,7 @@
v-model="tokenNumber" v-model="tokenNumber"
@close="stakeMenu = false" @close="stakeMenu = false"
:stake="stake" :stake="stake"
:amount="walletStore.memeToken?.balanceOf" :amount="balanceOf"
v-if="stakeMenu & !unstakeMenu" v-if="stakeMenu & !unstakeMenu"
> >
<template v-slot:body> <template v-slot:body>
@@ -104,9 +104,7 @@
</div> </div>
</template> </template>
<template v-slot:message-end> <template v-slot:message-end>
<div class="input-balance"> <div class="input-balance">Balance: {{ formatNumber(balanceOf) }}</div>
Balance: {{ walletStore.memeToken?.balanceOf / 10n ** tokenStore.memeToken.decimals }}
</div>
</template> </template>
</stake-menu> </stake-menu>
<div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu"> <div class="unstake-menu" v-else-if="stakeMenu & unstakeMenu">
@@ -136,6 +134,9 @@
<div class="connected-stake-first-round small-text text-center" v-if="cycleStore.currentCycle === 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-first-round small-text text-center" v-else>
You can claim your stake next cycle
</div>
</slot> </slot>
<slot></slot> <slot></slot>
</div> </div>
@@ -276,6 +277,14 @@ async function stakeToken() {
} }
} }
const balanceOf = computed(() => {
if (!walletStore.memeToken?.balanceOf) {
return 0n;
} else {
return walletStore.memeToken?.balanceOf / 10n ** tokenStore.memeToken.decimals;
}
});
const stateStake = computed(() => { const stateStake = computed(() => {
let returnState = 0; let returnState = 0;
if (state.value === 2) { if (state.value === 2) {
+5 -6
View File
@@ -39,8 +39,8 @@ const tokenStore = useTokenStore();
const props = defineProps({ const props = defineProps({
stake: Boolean, stake: Boolean,
modelValue: Number, modelValue: [Number, BigInt],
amount: Number, amount: [Number, BigInt],
}); });
const emit = defineEmits(["close", "update:modelValue"]); const emit = defineEmits(["close", "update:modelValue"]);
@@ -48,15 +48,14 @@ const emit = defineEmits(["close", "update:modelValue"]);
async function addTokensPercent(value) { async function addTokensPercent(value) {
console.log("value", value); console.log("value", value);
console.log("props.amount", props.amount); console.log("props.amount", props.amount);
console.log(walletStore.memeToken.balanceOf / 10n ** tokenStore.memeToken.decimals);
let amount; let amount;
if (props.amount !== undefined || props.amount !== null) { if (props.amount !== undefined || props.amount !== null) {
console.log("props.amount", props.amount); console.log("props.amount", props.amount);
amount = ((props.amount / 10n ** tokenStore.memeToken.decimals) * value) / 100n; amount = (props.amount * value) / 100n;
} else if (props.stake) { } else if (props.stake) {
amount = ((walletStore.memeToken.balanceOf / 10n ** tokenStore.memeToken.decimals) * value) / 100n; amount = (walletStore.memeToken.balanceOf * value) / 100n;
} else { } else {
amount = ((walletStore.memeToken.staked / 10n ** tokenStore.memeToken.decimals) * value) / 100n; amount = (walletStore.memeToken.staked * value) / 100n;
} }
console.log("amount", amount); console.log("amount", amount);
emit("update:modelValue", Number(amount)); emit("update:modelValue", Number(amount));
+31 -30
View File
@@ -21,36 +21,31 @@
</div> --> </div> -->
<div class="rewards-list"> <div class="rewards-list">
<rewards-wrapper <rewards-wrapper
v-if="getCurrentCycleData?.rewards_sacrifice !== undefined"
title="Sacrafice Reward" title="Sacrafice Reward"
coin="$BLOOD" coin="$BLOOD"
:amount="formatNumber(getCurrentCycleData?.rewards_sacrifice / 10n ** tokenStore.memeToken.decimals)" :amount="formatNumber(rewardsSacrifice)"
image="/assets/img/vampir.png" image="/assets/img/vampir.png"
/> />
<rewards-wrapper <rewards-wrapper
v-if="getCurrentCycleData?.rewards_staking !== undefined"
title="Staking Bonus" title="Staking Bonus"
coin="$BLOOD" coin="$BLOOD"
:amount="formatNumber(getCurrentCycleData?.rewards_staking / 10n ** tokenStore.memeToken.decimals)" :amount="formatNumber(rewardsStaking)"
info="max: 312m"
image="/assets/img/vampir.png" image="/assets/img/vampir.png"
/> />
<rewards-wrapper <rewards-wrapper
v-if="getCurrentCycleData?.rewards_clan !== undefined"
title="Clan Bonus" title="Clan Bonus"
coin="$BLOOD" coin="$BLOOD"
:amount="formatNumber(getCurrentCycleData?.rewards_clan / 10n ** tokenStore.memeToken.decimals)" :amount="formatNumber(rewardsClan)"
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 sub-header">Total Reward</div> <div class="rewards-total-headline sub-header">Total Reward</div>
<div class="rewards-total-inner bloodline-border bloodline-border--variant1"> <div
<token-name-price class="rewards-total-inner bloodline-border bloodline-border--variant1"
v-if="getCurrentCycleData?.rewards_total !== undefined" :class="{ purple: rewardsTotal > 0 && activeCycle !== currentCycle }"
name="$BLOOD" >
:price="formatNumber(getCurrentCycleData?.rewards_total / 10n ** tokenStore.memeToken.decimals)" <token-name-price name="$BLOOD" :price="formatNumber(rewardsTotal)"></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> </div>
</div> </div>
@@ -61,7 +56,7 @@
<template v-else-if="activeCycle === currentCycle"> <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="getCurrentCycleData?.rewards_total > 0"> <template v-else-if="rewardsTotal > 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>
@@ -77,7 +72,7 @@
v-model="tokenNumber" v-model="tokenNumber"
@close="stakeMenu = false" @close="stakeMenu = false"
:stake="stake" :stake="stake"
:amount="getCurrentCycleData?.rewards_total" :amount="rewardsTotal"
v-if="stakeMenu" v-if="stakeMenu"
> >
<template v-slot:body> <template v-slot:body>
@@ -139,7 +134,8 @@ const tokenStore = useTokenStore();
const cycleStore = useCycleStore(); const cycleStore = useCycleStore();
const router = useRouter(); const router = useRouter();
const { activeCycle, currentCycle, getCurrentCycleData } = storeToRefs(cycleStore); const { activeCycle, currentCycle, getCurrentCycleData, rewardsSacrifice, rewardsStaking, rewardsClan, rewardsTotal } =
storeToRefs(cycleStore);
const stakeMenu = ref(false); const stakeMenu = ref(false);
const stake = ref(null); const stake = ref(null);
@@ -149,13 +145,16 @@ const stateStakeClaim = ref(0);
async function stakeAndClaim() { async function stakeAndClaim() {
try { try {
console.log("stakeAndClaim");
console.log(tokenNumber.value); console.log(tokenNumber.value);
console.log(getCurrentCycleData.value.rewards_total); console.log(rewardsTotal.value);
const coefficient = (10000 * tokenNumber.value) / getCurrentCycleData.value.rewards_total;
stateStakeClaim.value = 2; stateStakeClaim.value = 2;
console.log("hier1");
const coefficient = (10000n * BigInt(tokenNumber.value)) / rewardsTotal.value;
var hash = await rewardLockerStore.stakeAndClaimCycle(coefficient, cycleStore.activeCycle); var hash = await rewardLockerStore.stakeAndClaimCycle(coefficient, cycleStore.activeCycle);
console.log("hash"); console.log("hier2");
stateStakeClaim.value = 3; stateStakeClaim.value = 3;
console.log("hash");
const data = await waitForTransaction({ const data = await waitForTransaction({
hash: hash, hash: hash,
}); });
@@ -176,8 +175,8 @@ async function stakeAndClaim() {
// //
console.log("rewardData", rewardData); console.log("rewardData", rewardData);
console.log("stakeData", stakeData); console.log("stakeData", stakeData);
const outputClaim = Number(rewardData?.topics[2]) / 10 ** tokenStore.memeToken.decimals; const outputClaim = BigInt(rewardData?.topics[2]) / 10n ** tokenStore.memeToken.decimals;
const outputStaked = Number(stakeData?.topics[3]) / 10 ** tokenStore.memeToken.decimals; const outputStaked = BigInt(stakeData?.topics[3]) / 10n ** tokenStore.memeToken.decimals;
showSuccessToast( showSuccessToast(
formatNumber(outputClaim + outputStaked), formatNumber(outputClaim + outputStaked),
"Success!", "Success!",
@@ -186,13 +185,15 @@ async function stakeAndClaim() {
); );
tokenNumber.value = 0; tokenNumber.value = 0;
stakeMenu.value = false; stakeMenu.value = false;
await cycleStore.fillCycle(activeCycle.value, true);
await walletStore.loadWalletData(); await walletStore.loadWalletData();
} catch (error) { } catch (error) {
console.error("stakeAndClaim", error); console.error("stakeAndClaim", error);
} finally { } finally {
const walletStore = useWalletStoreV2(); const walletStore = useWalletStoreV2();
await walletStore.loadWalletData(); await walletStore.loadWalletData();
console.log("finally1");
await cycleStore.fillCycle(activeCycle.value, true);
console.log("finally2");
stateStakeClaim.value = 1; stateStakeClaim.value = 1;
} }
} }
@@ -254,19 +255,19 @@ const stateClaimedComp = computed(() => {
const stateStakeClaimComp = computed(() => { const stateStakeClaimComp = computed(() => {
console.log("stateStakeClaimComp"); console.log("stateStakeClaimComp");
let returnState = 0; let returnState = 0;
if ( if (stateStakeClaim.value === 2) {
tokenNumber.value === null ||
tokenNumber.value === "" ||
tokenNumber.value === 0 ||
tokenNumber.value > walletStore.memeToken?.unclaimedRewards
) {
returnState = 0;
} else if (stateStakeClaim.value === 2) {
returnState = 2; returnState = 2;
} else if (stateStakeClaim.value === 3) { } else if (stateStakeClaim.value === 3) {
returnState = 3; returnState = 3;
} else if (tokenNumber.value !== null || tokenNumber.value !== "" || tokenNumber.value > 0) { } else if (tokenNumber.value !== null || tokenNumber.value !== "" || tokenNumber.value > 0) {
returnState = 1; returnState = 1;
} else if (
tokenNumber.value === null ||
tokenNumber.value === "" ||
tokenNumber.value === 0 ||
tokenNumber.value > walletStore.unclaimedRewards
) {
returnState = 0;
} }
return returnState; return returnState;
}); });
+1 -1
View File
@@ -14,7 +14,7 @@
</div> </div>
</div> </div>
<div class="right-side"> <div class="right-side">
<token-logo :img="props.logo" :alt="'vampir'"></token-logo> <token-logo img="/assets/img/vampir.png" :alt="'vampir'"></token-logo>
</div> </div>
</div> </div>
</div> </div>
+3 -2
View File
@@ -91,6 +91,7 @@ app.use(pinia);
app.use(Toast, { app.use(Toast, {
transition: "Vue-Toastification__fade", transition: "Vue-Toastification__fade",
containerClassName: "bloodline-toast-container",
}); });
@@ -164,9 +165,9 @@ try {
}, },
async (log) => { async (log) => {
console.log("CycleCompleted", log); console.log("CycleCompleted", log);
await cycleStore.fillCycle(cycleStore.currentCycle); await cycleStore.fillCycle(cycleStore.currentCycle, true);
cycleStore.currentCycle++; cycleStore.currentCycle++;
await cycleStore.fillCycle(cycleStore.currentCycle); await cycleStore.fillCycle(cycleStore.currentCycle, true);
} }
); );
+71 -47
View File
@@ -12,9 +12,9 @@ export const useCycleStore = defineStore("cycles", {
activeCycle: null, activeCycle: null,
currentCycle: null, currentCycle: null,
}), }),
getters: { getters: {
//cycle winner is the token who reached the goal //cycle winner is the token who reached the goal
//todo winner is now in the cycle object, no reason for that function anymore //todo winner is now in the cycle object, no reason for that function anymore
getCycleWinner() { getCycleWinner() {
const goal = this.getCurrentCycleData?.goal; const goal = this.getCurrentCycleData?.goal;
if (!goal) { if (!goal) {
@@ -30,9 +30,37 @@ export const useCycleStore = defineStore("cycles", {
getCurrentCycleData() { getCurrentCycleData() {
return this.cycles[this.activeCycle]; return this.cycles[this.activeCycle];
}, },
rewardsSacrifice() {
const tokenStore = useTokenStore();
if (!this.cycles[this.activeCycle]?.rewards_sacrifice) {
return 0n;
}
return this.cycles[this.activeCycle]?.rewards_sacrifice / 10n ** tokenStore.memeToken.decimals;
},
rewardsStaking() {
const tokenStore = useTokenStore();
if (!this.cycles[this.activeCycle]?.rewards_staking) {
return 0n;
}
return this.cycles[this.activeCycle]?.rewards_staking / 10n ** tokenStore.memeToken.decimals;
},
rewardsClan() {
const tokenStore = useTokenStore();
if (!this.cycles[this.activeCycle]?.rewards_clan) {
return 0n;
}
return this.cycles[this.activeCycle]?.rewards_clan / 10n ** tokenStore.memeToken.decimals;
},
rewardsTotal() {
const tokenStore = useTokenStore();
if (!this.cycles[this.activeCycle]?.rewards_total) {
return 0n;
}
return this.cycles[this.activeCycle]?.rewards_total / 10n ** tokenStore.memeToken.decimals;
},
}, },
actions: { actions: {
//todo check if still needed //todo check if still needed
// async loadRewardsCycles() { // async loadRewardsCycles() {
// const walletStore = useWalletStoreV2(); // const walletStore = useWalletStoreV2();
// const rewardLockerStore = useRewardLockerStore(); // const rewardLockerStore = useRewardLockerStore();
@@ -56,29 +84,27 @@ export const useCycleStore = defineStore("cycles", {
// const element = data[index]; // const element = data[index];
// if (!this.cycles[index]) { // if (!this.cycles[index]) {
// this.cycles[index] = {}; // this.cycles[index] = {};
// } // }
// } // }
// }, // },
//todo check if needed, or use fillcycle //todo check if needed, or use fillcycle
async updateCurrentCycle(sacrificedToken) { async updateCurrentCycle(sacrificedToken) {
console.log("updateCurrentCycle"); console.log("updateCurrentCycle");
const memeBurnerStore = useMemeburnerStore(); const memeBurnerStore = useMemeburnerStore();
var data = await memeBurnerStore.getSacrificedCycle(this.currentCycle); var data = await memeBurnerStore.getSacrificedCycle(this.currentCycle);
console.log("this.currentCycle", this.currentCycle); console.log("this.currentCycle", this.currentCycle);
console.log("this.cycles", this.cycles); console.log("this.cycles", this.cycles);
if (this.cycles[this.currentCycle]) { if (this.cycles[this.currentCycle]) {
var tokenIndex = this.cycles[this.currentCycle].token.findIndex( var tokenIndex = this.cycles[this.currentCycle].token.findIndex(
(tokenData) => tokenData.contractAddress === sacrificedToken (tokenData) => tokenData.contractAddress === sacrificedToken
); );
this.cycles[this.currentCycle].token[tokenIndex].amount = this.cycles[this.currentCycle].token[tokenIndex].amount = data[tokenIndex].result[1];
data[tokenIndex].result[1]; }
} },
/**
}, * main function to fill a round, will not be filled when already loaded
/** * you can use the refillcycle to overwrite information, because if you claim or stake the values will change
* main function to fill a round, will not be filled when already loaded */
* you can use the refillcycle to overwrite information, because if you claim or stake the values will change
*/
async fillCycle(cycleNumber, refillCycle = false) { async fillCycle(cycleNumber, refillCycle = false) {
console.log("fillCycle", cycleNumber); console.log("fillCycle", cycleNumber);
const memeBurnerStore = useMemeburnerStore(); const memeBurnerStore = useMemeburnerStore();
@@ -97,22 +123,22 @@ export const useCycleStore = defineStore("cycles", {
rewardData = await rewardLockerStore.getRewardsForAllToken(cycleNumber); rewardData = await rewardLockerStore.getRewardsForAllToken(cycleNumber);
} }
console.log("hier"); console.log("hier");
//getTotalSacrificeRewardsForToken multicall for all tokens //getTotalSacrificeRewardsForToken multicall for all tokens
const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(cycleNumber); const tokenTotalSacrificed = await rewardLockerStore.getTotalSacrificeRewardsForAllToken(cycleNumber);
console.log("hier1"); console.log("hier1");
var goal = await memeBurnerStore.getGoal(cycleNumber); var goal = await memeBurnerStore.getGoal(cycleNumber);
console.log("hier123"); console.log("hier123");
var tokenArray = []; var tokenArray = [];
var rewards_clan = 0n; var rewards_clan = 0n;
var rewards_sacrifice = 0n; var rewards_sacrifice = 0n;
var rewards_staking = 0n; var rewards_staking = 0n;
console.log("hier123"); console.log("hier123");
for (let index = 0; index < data.length; index++) { for (let index = 0; index < data.length; index++) {
var tokenData = {}; var tokenData = {};
const token = tokenStore.token[index]; const token = tokenStore.token[index];
//why no multicall? todo //why no multicall? todo
var coefficent = await rewardLockerStore.getSacrificedTokenCoefficient( var coefficent = await rewardLockerStore.getSacrificedTokenCoefficient(
cycleNumber, cycleNumber,
token.contractAddress token.contractAddress
@@ -124,11 +150,11 @@ export const useCycleStore = defineStore("cycles", {
tokenData.vampwinner = token.vamp.winner; tokenData.vampwinner = token.vamp.winner;
tokenData.vampwinner2 = token.vamp.winner2; tokenData.vampwinner2 = token.vamp.winner2;
tokenData.vampname = token.vamp.name; tokenData.vampname = token.vamp.name;
tokenData.amount = data[index].result[1] tokenData.amount = data[index].result[1];
tokenData.amountInBLD = tokenTotalSacrificed[index].result tokenData.amountInBLD = tokenTotalSacrificed[index].result;
if (walletStore.connected) { if (walletStore.connected) {
//if user is connected fill user specific data for the token //if user is connected fill user specific data for the token
const sacrificeClanReward = rewardData[index].result[1]; const sacrificeClanReward = rewardData[index].result[1];
let clanwin = 0n; let clanwin = 0n;
if (cycleNumber !== this.currentCycle) { if (cycleNumber !== this.currentCycle) {
@@ -137,18 +163,16 @@ export const useCycleStore = defineStore("cycles", {
} }
const sacrificeRewards = sacrificeClanReward; const sacrificeRewards = sacrificeClanReward;
tokenData.rewards_ges = tokenData.rewards_ges = rewardData[index].result[1] + rewardData[index].result[0];
rewardData[index].result[1] +
rewardData[index].result[0]
tokenData.rewards_clan = clanwin tokenData.rewards_clan = clanwin;
tokenData.rewards_staking = rewardData[index].result[0] tokenData.rewards_staking = rewardData[index].result[0];
tokenData.rewards_sacrifice = sacrificeRewards tokenData.rewards_sacrifice = sacrificeRewards;
console.log("rewards_clan", rewards_clan); console.log("rewards_clan", rewards_clan);
console.log("tokenData.rewards_clan", tokenData.rewards_clan); console.log("tokenData.rewards_clan", tokenData.rewards_clan);
console.log("tokenData.rewards_sacrifice", tokenData.rewards_sacrifice); console.log("tokenData.rewards_sacrifice", tokenData.rewards_sacrifice);
rewards_clan = rewards_clan + tokenData.rewards_clan; rewards_clan = rewards_clan + tokenData.rewards_clan;
rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice; rewards_sacrifice = rewards_sacrifice + tokenData.rewards_sacrifice;
rewards_staking = rewards_staking + tokenData.rewards_staking; rewards_staking = rewards_staking + tokenData.rewards_staking;
@@ -156,10 +180,10 @@ export const useCycleStore = defineStore("cycles", {
tokenArray.push(tokenData); tokenArray.push(tokenData);
} }
const goalDecimal = goal[0] const goalDecimal = goal[0];
const winner = tokenArray.find((token) => token.amount === goalDecimal); const winner = tokenArray.find((token) => token.amount === goalDecimal);
const goalInBLD = await memeBurnerStore.getGoalInBLOOD(cycleNumber); const goalInBLD = await memeBurnerStore.getGoalInBLOOD(cycleNumber);
//replace vamplogo cause it will automatically change the token for the cycle view (new design) //replace vamplogo cause it will automatically change the token for the cycle view (new design)
if (winner) { if (winner) {
winner.vamplogo = winner.vampwinner; winner.vamplogo = winner.vampwinner;
} }
@@ -183,10 +207,10 @@ export const useCycleStore = defineStore("cycles", {
async getFinshedCycleNumbers() { async getFinshedCycleNumbers() {
const array = []; const array = [];
const rewardLockerStore = useRewardLockerStore(); const rewardLockerStore = useRewardLockerStore();
const lastCompletedCycle = await rewardLockerStore.lastCompletedCycle(); const lastCompletedCycle = await rewardLockerStore.lastCompletedCycle();
for (let index = 0; index <= Number(lastCompletedCycle); index++) { for (let index = 0; index <= Number(lastCompletedCycle); index++) {
array.push(index); array.push(index);
} }
return array; return array;
}, },
}, },
+10 -8
View File
@@ -49,7 +49,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
return await this.contract.read.getSacrificedMeme([cycleNumber, 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]);
}, },
async getSacrificedCycle(cycleNumber) { async getSacrificedCycle(cycleNumber) {
console.log("getSacrificedCycle", cycleNumber); console.log("getSacrificedCycle", cycleNumber);
@@ -71,7 +71,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
}); });
return data; return data;
}, },
async sacrificeMeme(amount) { async sacrificeMeme(amount, minETH) {
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
try { try {
if (!amount || amount == 0) { if (!amount || amount == 0) {
@@ -80,10 +80,11 @@ export const useMemeburnerStore = defineStore("memeburner", {
return; return;
} }
this.loading = true; this.loading = true;
var hash = await this.contract.write.sacrificeMeme([ var hash = await this.contract.write.sacrificeMeme([
tokenStore.activeToken.contractAddress, tokenStore.activeToken.contractAddress,
amount, amount,
0, minETH
]); ]);
return hash; return hash;
} catch (error) { } catch (error) {
@@ -93,13 +94,14 @@ export const useMemeburnerStore = defineStore("memeburner", {
this.loading = false; this.loading = false;
} }
}, },
async sacrificeMemeAndBuyBLOOD(amount) { async sacrificeMemeAndBuyBLOOD(amount, minBLOOD) {
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
const amountDecimal = BigInt(amount) * 10n ** BigInt(tokenStore.activeToken.decimals);
var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([ var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([
tokenStore.activeToken.contractAddress, tokenStore.activeToken.contractAddress,
amount, amountDecimal.toString(),
0, minBLOOD.toString()
]); ]);
return hash; return hash;
}, },
@@ -110,7 +112,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("getAmountETHBase"); console.log("getAmountETHBase");
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
return await this.contract.read.getAmountETHBase([tokenStore.activeToken.contract.address, amount, true]); return await this.contract.read.getAmountETHBase([tokenStore.activeToken.contract.address, amount, true]);
} }
}, },
-3
View File
@@ -160,9 +160,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
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, [cycle], addresses]); const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, [cycle], addresses]);
const data = await waitForTransaction({
hash: hash,
});
return hash; return hash;
}, },
async stakeAndClaimAllCycles(stakeCoefficient) { async stakeAndClaimAllCycles(stakeCoefficient) {
+47 -37
View File
@@ -25,20 +25,22 @@ export const useSacrificeStore = defineStore("sacrifice", {
const walletStore = useWalletStoreV2(); const walletStore = useWalletStoreV2();
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
const cycleStore = useCycleStore(); const cycleStore = useCycleStore();
try { try {
this.sacrificeState = 2; this.sacrificeState = 2;
console.log("hier");
const getRewards = await this.getRewardsFor(amount, token); const getRewards = await this.getRewardsFor(amount, token);
console.log("hier1");
console.log("getRewards", getRewards); console.log("getRewards", getRewards);
let hash = null; let hash = null;
if (getRewards.variant === "sacrifice") { if (getRewards.variant === "sacrifice") {
console.log("sacrifice"); console.log("sacrifice");
hash = await memeburnerStore.sacrificeMeme(amount); hash = await memeburnerStore.sacrificeMeme(amount, getRewards.minETH);
console.log("hash", hash); console.log("hash", hash);
} else { } else {
console.log("buy"); console.log("buy");
hash = await memeburnerStore.sacrificeMemeAndBuyBLOOD(amount); hash = await memeburnerStore.sacrificeMemeAndBuyBLOOD(amount, getRewards.minBLOOD);
console.log("hash", hash); console.log("hash", hash);
} }
@@ -54,7 +56,7 @@ export const useSacrificeStore = defineStore("sacrifice", {
// (topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee" // (topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee"
// ); // );
// }); // });
var rewardData = data.logs.filter((logObject) => { var rewardData = data.logs.filter((logObject) => {
return logObject.topics.find( return logObject.topics.find(
(topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee" (topic) => topic === "0x5e60ccd3c81486143d815dce24867a494d7fee585a0a44282cf479b19a5186ee"
@@ -86,40 +88,46 @@ export const useSacrificeStore = defineStore("sacrifice", {
this.sacrificeState = 0; this.sacrificeState = 0;
} }
}, },
async getRewardsFor(value, token) { async getRewardsFor(amount, token) {
console.log("getRewardsFor", {value, token}); console.log("getRewardsFor", {amount, token});
const memeburnerStore = useMemeburnerStore(); const memeburnerStore = useMemeburnerStore();
const uniswapStore = useUniswapStore(); const uniswapStore = useUniswapStore();
const walletStore = useWalletStoreV2(); const walletStore = useWalletStoreV2();
const rewardLockerStore = useRewardLockerStore(); const rewardLockerStore = useRewardLockerStore();
let output = 0; let output = 0;
let minBLOOD;
try { try {
if (!value) {
if (!amount) {
this.sacrificeState = 0; this.sacrificeState = 0;
return output; return output;
} }
const rewardsForResult = await memeburnerStore.getRewardFor(value); const amountETHBase = await memeburnerStore.getAmountETHBase(amount);
console.log("rewardsForResult", rewardsForResult); // take 99.5% of amount ETH got for selling meme, 0.5% allowed slippage
const rewardsForResultNumber = rewardsForResult.reduce((x, y) => { const minETH = (amountETHBase[1] * 995n) / 1000n;
return x + y
}, 0n); const rewardsForResult = await memeburnerStore.getRewardFor(amount);
var quoteRewards = await uniswapStore.quoteExactInputSingle(value); const rewardsForResultSum = rewardsForResult[0] + rewardsForResult[1];
// quote blood amount against ETH base amount
let variant = "sacrifice"; var quoteRewards = await uniswapStore.quoteExactInputSingle(amount, amountETHBase[0]);
let variant = "sacrifice";
if (quoteRewards.result) { if (quoteRewards.result) {
const quoteRewardsNumber = quoteRewards.amount; // take 99.5% of quoted amount, 0.5% allowed slippage
if ((quoteRewardsNumber * 995n) / 1000n > rewardsForResultNumber) { minBLOOD = quoteRewards.amount * 995n / 1000n;
if (quoteRewards.amount * 95n / 100n > rewardsForResultSum) {
variant = "buy"; variant = "buy";
console.log("use Buy-function", { console.log("use Buy-function", {
quoteRewardsNumber: quoteRewardsNumber, quoteRewardsNumber: quoteRewards.amount,
rewardsForResultNumber, rewardsForResultSum,
}); });
} else { } else {
console.log("use sacrifice-function", { console.log("use sacrifice-function", {
quoteRewardsNumber: quoteRewardsNumber, quoteRewardsNumber: quoteRewards.amount,
rewardsForResultNumber, rewardsForResultSum,
}); });
} }
} else { } else {
@@ -128,22 +136,26 @@ export const useSacrificeStore = defineStore("sacrifice", {
* quoter threw an error * quoter threw an error
*/ */
// //
output = rewardsForResultNumber; output = rewardsForResultSum;
} }
console.log("variant", variant); console.log("variant", variant);
if (!walletStore.connected || (walletStore.connected && token.allowance < value)) { console.log("amount", amount);
if (!walletStore.connected || (walletStore.connected && token.allowance < amount)) {
/** /**
* case 1 * case 1
* user is not logged in or Allowance is less than Input, then I show getRewardsForSacrifice Value * user is not logged in or Allowance is less than Input, then I show getRewardsForSacrifice Value
* variante not relevant * variante not relevant
*/ */
output = rewardsForResultNumber; output = rewardsForResultSum;
if (variant === "buy") {
output = quoteRewards.amount
}
} else if (walletStore.connected && variant === "sacrifice") { } else if (walletStore.connected && variant === "sacrifice") {
/** /**
* case 2 * case 2
* user is logged in and allowance is greater or equal input and variant is sacrifice * user is logged in and allowance is greater or equal input and variant is sacrifice
*/ */
output = rewardsForResultNumber; output = rewardsForResultSum;
} else if (walletStore.connected && variant === "buy") { } else if (walletStore.connected && variant === "buy") {
/** /**
* case 3 * case 3
@@ -154,7 +166,7 @@ export const useSacrificeStore = defineStore("sacrifice", {
address: memeburnerStore.contract.address, address: memeburnerStore.contract.address,
abi: memeburnerStore.contract.abi, abi: memeburnerStore.contract.abi,
functionName: "sacrificeMeme", functionName: "sacrificeMeme",
args: [token.contractAddress, amountDecimal.toString(), 0], args: [token.contractAddress, amount.toString(), minETH.toString()],
account: walletStore.address, account: walletStore.address,
}); });
@@ -162,19 +174,17 @@ export const useSacrificeStore = defineStore("sacrifice", {
address: memeburnerStore.contract.address, address: memeburnerStore.contract.address,
abi: memeburnerStore.contract.abi, abi: memeburnerStore.contract.abi,
functionName: "sacrificeMemeAndBuyBLOOD", functionName: "sacrificeMemeAndBuyBLOOD",
args: [token.contractAddress, amountDecimal.toString(), 0], args: [token.contractAddress, amount.toString(), minBLOOD.toString()],
account: walletStore.address, account: walletStore.address,
}); });
const amountBuyNumber = amountBuy
const amountSacrificeNumber = amountSacrifice
if (amountBuyNumber * 0.995 > amountSacrificeNumber) { if (amountBuy * 95n / 100n > amountSacrifice) {
variant = "buy"; variant = "buy";
output = amountBuyNumber; output = amountBuy;
console.log("use buy after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme"); console.log("use buy after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
} else { } else {
variant = "sacrifice"; variant = "sacrifice";
output = amountSacrificeNumber; output = amountSacrifice;
console.log("use sacrifice after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme"); console.log("use sacrifice after comparison sacrificeMemeAndBuyBLOOD and sacrificeMeme");
} }
} }
@@ -188,7 +198,7 @@ export const useSacrificeStore = defineStore("sacrifice", {
stakingRewardsNumber = stakingReward / 10n ** token.decimals stakingRewardsNumber = stakingReward / 10n ** token.decimals
} }
const outputNumber = output / 10n ** BigInt(token.decimals); const outputNumber = output / 10n ** BigInt(token.decimals);
return { output: outputNumber, variant: variant, staking: stakingRewardsNumber }; return { output: outputNumber, variant: variant, minETH: minETH, minBLOOD: minBLOOD, staking: stakingRewardsNumber };
} catch (error) { } catch (error) {
console.error("getRewardsFor", error); console.error("getRewardsFor", error);
} }
+6 -5
View File
@@ -121,7 +121,8 @@ export const useTokenStore = defineStore("token", {
// abi: Meme5Json.abi, // abi: Meme5Json.abi,
// contractAddress: Meme5Json.contractAddress, // contractAddress: Meme5Json.contractAddress,
// }, // },
{ {
name: "$BLOOD",
abi: BloodlineJson.abi, abi: BloodlineJson.abi,
contractAddress: BloodlineJson.contractAddress, contractAddress: BloodlineJson.contractAddress,
logo: "/assets/img/token/bloodline.png", logo: "/assets/img/token/bloodline.png",
@@ -161,16 +162,16 @@ export const useTokenStore = defineStore("token", {
}); });
contracts.push({ ...token.contract, functionName: "decimals" }); contracts.push({ ...token.contract, functionName: "decimals" });
contracts.push({ ...token.contract, functionName: "name" }); // contracts.push({ ...token.contract, functionName: "name" });
contracts.push({ ...token.contract, functionName: "symbol" }); contracts.push({ ...token.contract, functionName: "symbol" });
contracts.push({ ...token.contract, functionName: "totalSupply" }); contracts.push({ ...token.contract, functionName: "totalSupply" });
const data = await multicall({ const data = await multicall({
contracts, contracts,
}); });
token.decimals = BigInt(data[0].result); token.decimals = BigInt(data[0].result);
token.name = data[1].result; // token.name = data[1].result;
token.symbol = data[2].result; token.symbol = data[1].result;
token.totalSupply = data[3].result; token.totalSupply = data[2].result;
} }
} catch (error) { } catch (error) {
console.error("initV2", error); console.error("initV2", error);
+17 -10
View File
@@ -2,7 +2,9 @@ import { defineStore } from "pinia";
import { useWalletStoreV2 } from "@/stores/walletV2"; import { useWalletStoreV2 } from "@/stores/walletV2";
import QuoterJson from "@/assets/contracts/Quoter.json"; import QuoterJson from "@/assets/contracts/Quoter.json";
import UniswapPoolJson from "@/assets/contracts/UniswapPool.json"; import UniswapPoolJson from "@/assets/contracts/UniswapPool.json";
import BloodlineJson from "@/assets/contracts/Bloodline.json";
import { useMemeburnerStore } from "@/stores/memeburner"; import { useMemeburnerStore } from "@/stores/memeburner";
import { useTokenStore } from "@/stores/tokens";
import { getContract, multicall } from "@wagmi/core"; import { getContract, multicall } from "@wagmi/core";
@@ -38,29 +40,34 @@ export const useUniswapStore = defineStore("uniswap", {
this.getPoolData(); this.getPoolData();
}, },
async quoteExactInputSingle(amount) { async quoteExactInputSingle(amount, ethBase) {
try { try {
console.log("quoteExactInputSingle"); console.log("quoteExactInputSingle");
const memeBurnerStore = useMemeburnerStore(); const memeBurnerStore = useMemeburnerStore();
var amountEthBase = await memeBurnerStore.getAmountETHBase(amount); const tokenStore = useTokenStore();
console.log("amountEthBase", amountEthBase);
const tokenOut = tokenStore.memeToken.contractAddress;
// tokenIn - WETH
const tokenIn = BigInt(this.poolData.token0) == BigInt(tokenOut) ? this.poolData.token1 : this.poolData.token0;
console.log("quoteExactInputSingle-parameter", { console.log("quoteExactInputSingle-parameter", {
token0: this.poolData.token0, tokenIn: tokenIn, // WETH
token1: this.poolData.token1, tokenOut: tokenOut, // BLOOD
fee: this.poolData.fee, fee: this.poolData.fee,
amountEthBase: amountEthBase[0], amountEthBase: ethBase,
pricelimit: 0, //sqrtPriceLimitX96 pricelimit: 0, //sqrtPriceLimitX96
}); });
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([ const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
this.poolData.token0, //bloodline tokenIn, //weth
this.poolData.token1, //weth tokenOut, //bloodline
this.poolData.fee, this.poolData.fee,
amountEthBase[0], ethBase,
0, //sqrtPriceLimitX96 0, //sqrtPriceLimitX96
]); ]);
console.log("quotedAmountOut", quotedAmountOut); console.log("quotedAmountOut", quotedAmountOut);
return {result: true, amount: quotedAmountOut}; return {result: true, amount: quotedAmountOut};
} catch (error) { } catch (error) {
return { result: false, amount: null }; return { result: false, amount: null };
} }
}, },
+49 -42
View File
@@ -38,35 +38,43 @@ export const useWalletStoreV2 = defineStore("walletV2", {
walletClient: null, walletClient: null,
config: null, config: null,
chain: null, chain: null,
token: [], token: [],
}), }),
getters: { getters: {
sacrificeToken: (state) => state.token.filter((obj) => { sacrificeToken: (state) =>
const tokenStore = useTokenStore(); state.token.filter((obj) => {
const tokenStore = useTokenStore();
return obj.contractAddress !== tokenStore.memeToken.contractAddress;
}), return obj.contractAddress !== tokenStore.memeToken.contractAddress;
memeToken: (state) => state.token.find((obj) => { }),
const tokenStore = useTokenStore(); memeToken: (state) =>
state.token.find((obj) => {
return obj.contractAddress === tokenStore.memeToken.contractAddress; const tokenStore = useTokenStore();
}),
return obj.contractAddress === tokenStore.memeToken.contractAddress;
}),
unclaimedRewards() {
const tokenStore = useTokenStore();
if (!this.memeToken?.unclaimedRewards) {
return 0n;
}
return this.memeToken.unclaimedRewards / 10n ** tokenStore.memeToken.decimals;
},
}, },
actions: { actions: {
async init() { async init() {
console.log("wallet init"); console.log("wallet init");
const account = getAccount();
if (account.address) { const account = getAccount();
this.address = account.address;
this.connected = true; if (account.address) {
} this.address = account.address;
this.connected = true;
}
}, },
async connectWallet(connector) { async connectWallet(connector) {
try { try {
console.log("connector.name", connector.name); console.log("connector.name", connector.name);
// if (!account.isConnected) { // if (!account.isConnected) {
const connection = await connect({ const connection = await connect({
chainId: goerli.id, chainId: goerli.id,
@@ -74,12 +82,12 @@ export const useWalletStoreV2 = defineStore("walletV2", {
}); });
console.log("connection", connection); console.log("connection", connection);
} catch (error) { } catch (error) {
if (error.message.includes("Connector not found")) { if (error.message.includes("Connector not found")) {
console.warn("Connector not found"); console.warn("Connector not found");
} }
console.error(error); console.error(error);
} }
// this.address = connection.account; // this.address = connection.account;
}, },
async getTokenBalance(token) { async getTokenBalance(token) {
@@ -87,8 +95,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
return result; return result;
}, },
async getTokenBalances() { async getTokenBalances() {
console.log("getTokenBalances"); console.log("getTokenBalances");
this.token = [] this.token = [];
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
var contracts = []; var contracts = [];
for (let index = 0; index < tokenStore.token.length; index++) { for (let index = 0; index < tokenStore.token.length; index++) {
@@ -100,29 +108,28 @@ export const useWalletStoreV2 = defineStore("walletV2", {
contracts, 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];
this.token.push({ this.token.push({
contractAddress: token.contractAddress, contractAddress: token.contractAddress,
balanceOf: data[index].result balanceOf: data[index].result,
}); });
} }
}, },
async loadWalletData() { async loadWalletData() {
if (!this.connected) { if (!this.connected) {
return return;
} }
console.log("loadWalletData"); console.log("loadWalletData");
const rewardlockerStore = useRewardLockerStore(); const rewardlockerStore = useRewardLockerStore();
await this.getTokenBalances();
//MemeToken Staked
const tokenStore = useTokenStore();
this.memeToken.staked = await rewardlockerStore.getStaked(this.address);
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
this.memeToken.unclaimedRewards = unclaimedRewards
} await this.getTokenBalances();
//MemeToken Staked
const tokenStore = useTokenStore();
this.memeToken.staked = await rewardlockerStore.getStaked(this.address);
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
this.memeToken.unclaimedRewards = unclaimedRewards;
},
}, },
// persist: true, // persist: true,
}); });
+9 -1
View File
@@ -79,7 +79,12 @@
<div class="bloodline-container"> <div class="bloodline-container">
<div class="bloodline-border purple">Get up to +25% Clan Bonus on your sacrifice.</div> <div class="bloodline-border purple">Get up to +25% Clan Bonus on your sacrifice.</div>
</div> </div>
<blood-chart :data="cycleStore.cycles[cycleStore.activeCycle]"></blood-chart> <template v-if="!cycleStore.cycles[cycleStore.activeCycle]">
<Vue3Lottie :animationData="ChartLoading" :height="400" :width="400" />
</template>
<template v-else>
<blood-chart :data="cycleStore.cycles[cycleStore.activeCycle]"></blood-chart>
</template>
</div> </div>
</div> </div>
</div> </div>
@@ -98,6 +103,9 @@ import LoadingComponent from "@/components/LoadingComponent.vue";
import { useCycleStore } from "@/stores/cycles"; import { useCycleStore } from "@/stores/cycles";
import { useRewardLockerStore } from "@/stores/rewardlocker"; import { useRewardLockerStore } from "@/stores/rewardlocker";
import { Vue3Lottie } from "vue3-lottie";
import ChartLoading from "@/assets/lottie/ChartLoading.json";
const cycleStore = useCycleStore(); const cycleStore = useCycleStore();
const tokenStore = useTokenStore(); const tokenStore = useTokenStore();
+19 -1
View File
@@ -2415,6 +2415,11 @@
dependencies: dependencies:
"p-locate" "^5.0.0" "p-locate" "^5.0.0"
"lodash-es@^4.17.21":
"integrity" "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
"resolved" "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz"
"version" "4.17.21"
"lodash.isequal@4.5.0": "lodash.isequal@4.5.0":
"integrity" "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" "integrity" "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ=="
"resolved" "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz" "resolved" "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz"
@@ -2437,6 +2442,11 @@
dependencies: dependencies:
"js-tokens" "^3.0.0 || ^4.0.0" "js-tokens" "^3.0.0 || ^4.0.0"
"lottie-web@5.12.2":
"integrity" "sha512-uvhvYPC8kGPjXT3MyKMrL3JitEAmDMp30lVkuq/590Mw9ok6pWcFCwXJveo0t5uqYw1UREQHofD+jVpdjBv8wg=="
"resolved" "https://registry.npmjs.org/lottie-web/-/lottie-web-5.12.2.tgz"
"version" "5.12.2"
"lru-cache@^6.0.0": "lru-cache@^6.0.0":
"integrity" "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==" "integrity" "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA=="
"resolved" "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz" "resolved" "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz"
@@ -3288,7 +3298,7 @@
"resolved" "https://registry.npmjs.org/vue-toastification/-/vue-toastification-2.0.0-rc.5.tgz" "resolved" "https://registry.npmjs.org/vue-toastification/-/vue-toastification-2.0.0-rc.5.tgz"
"version" "2.0.0-rc.5" "version" "2.0.0-rc.5"
"vue@^2.6.14 || ^3.3.0", "vue@^3.0.0-0 || ^2.6.0", "vue@^3.0.2", "vue@^3.2.0", "vue@^3.2.25", "vue@^3.3.2", "vue@>= 3.0.0 < 4", "vue@3.3.4": "vue@^2.6.14 || ^3.3.0", "vue@^3.0.0-0 || ^2.6.0", "vue@^3.0.2", "vue@^3.2", "vue@^3.2.0", "vue@^3.2.25", "vue@^3.3.2", "vue@>= 3.0.0 < 4", "vue@3.3.4":
"integrity" "sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw==" "integrity" "sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw=="
"resolved" "https://registry.npmjs.org/vue/-/vue-3.3.4.tgz" "resolved" "https://registry.npmjs.org/vue/-/vue-3.3.4.tgz"
"version" "3.3.4" "version" "3.3.4"
@@ -3299,6 +3309,14 @@
"@vue/server-renderer" "3.3.4" "@vue/server-renderer" "3.3.4"
"@vue/shared" "3.3.4" "@vue/shared" "3.3.4"
"vue3-lottie@^3.2.0":
"integrity" "sha512-PtNXbv7iD4XGmK8CXd71aLWmILIR6P6VzLMDw6ZzmDAeuJZuJ0MdOVnn50LOARgq+cOFJsn/2z+7tZh0F9T9qw=="
"resolved" "https://registry.npmjs.org/vue3-lottie/-/vue3-lottie-3.2.0.tgz"
"version" "3.2.0"
dependencies:
"lodash-es" "^4.17.21"
"lottie-web" "5.12.2"
"web3-eth-abi@^1.2.1": "web3-eth-abi@^1.2.1":
"integrity" "sha512-hk5NyeGweJYTjes7lBW7gtG7iYoN6HLt6E4FQDrHPdwZjwNmvzaOH9N8zMTCxNFXUlg0bzeTOzWwMA717a+4eg==" "integrity" "sha512-hk5NyeGweJYTjes7lBW7gtG7iYoN6HLt6E4FQDrHPdwZjwNmvzaOH9N8zMTCxNFXUlg0bzeTOzWwMA717a+4eg=="
"resolved" "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.1.tgz" "resolved" "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.10.1.tgz"