From dfd208e075a4ab290e20be0bc84a7ef78043fc22 Mon Sep 17 00:00:00 2001 From: EmberSpirit Date: Fri, 8 Sep 2023 23:05:34 +0200 Subject: [PATCH] update profilepage --- public/assets/img/moon.png | Bin 0 -> 798 bytes src/App.vue | 52 +- src/assets/contracts/test.json | 992 ++++++++++++++++++++++++++++ src/assets/sass/base.sass | 23 - src/assets/sass/buttons.sass | 19 +- src/assets/sass/main.sass | 6 +- src/assets/sass/variables.sass | 42 ++ src/components/ClaimComponent.vue | 80 +++ src/components/ConnectWallet.vue | 59 +- src/components/SacrificeToken.vue | 87 ++- src/components/StakeComponent.vue | 96 ++- src/components/StakeComponentV1.vue | 122 ++++ src/components/StakeMenu.vue | 67 +- src/components/TokenClaim.vue | 13 +- src/components/TokenInput.vue | 1 - src/components/TokenNamePrice.vue | 8 +- src/helper/helper.js | 8 + src/main.js | 107 ++- src/router/index.js | 96 +-- src/stores/memeburner.js | 5 +- src/stores/rewardlocker.js | 90 ++- src/stores/rounds.js | 269 ++++---- src/stores/tokens.js | 12 +- src/stores/walletV2.js | 35 +- src/views/CycleView.vue | 34 +- src/views/ProfileView.vue | 432 ++++++------ 26 files changed, 2155 insertions(+), 600 deletions(-) create mode 100644 public/assets/img/moon.png create mode 100644 src/assets/contracts/test.json create mode 100644 src/components/ClaimComponent.vue create mode 100644 src/components/StakeComponentV1.vue diff --git a/public/assets/img/moon.png b/public/assets/img/moon.png new file mode 100644 index 0000000000000000000000000000000000000000..12b36e9784a05e69957fb4a72f87993e7b786d15 GIT binary patch literal 798 zcmV+(1L6FMP)VFs z0t=9IC-lu|>_Iwib$h$}_8=<3a=G-PXg!XiXohR7lAO{2%^`yweOBmmOjQl^L>LVb&P|MgFh<$fM#nHNl5EN1a zqy}<@z?ARH41|k4YJhA7EuW~|gjm5+&sQZ)Gh8W%%1`LJjv&LxjeD!D2FChi7%7Bx zMHP{<^M(uq1BFkOQ8#257)W(AUEj2u1p?%OC!&hr1?P_AT#_L;&D2uG$cKZcr$5GA z%`2!#1M78k+3WSR*JnwZuxQD@Lx*W>nV_nu2Bun)*tW6x4je% z%kTIN=q#uZUVQiblfteHXEZnh5kqPW6(&jYcDLFT7CF~-M@l8P)Bx<(myApA9UIK` z5qt8`A!aRL+yq*3RHUko$^?EZH0T%EYKEiZCgLe3S@0(E7@-*uX0~5 c#BZv}UnMd?$n|Af0{{R307*qoM6N<$g6D5xr~m)} literal 0 HcmV?d00001 diff --git a/src/App.vue b/src/App.vue index db1986e..b87ea99 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,6 +19,7 @@ import { watchNetwork, watchContractEvent, watchWalletClient, + watchPublicClient, getAccount, getNetwork, getPublicClient, @@ -85,19 +86,42 @@ onMounted(async () => { window.addEventListener("resize", handleWindowSizeChange); handleWindowSizeChange(); - // initContracts + const showPanel = ref(false); + const eventWatch = ref(null); + const netWorkEvent = ref(null); + const memeSacrificedEvent = ref(null); + const clientClientEvent = ref(null); + console.log("beforeEach"); + const tokenStore = useTokenStore(); + const memeBurnerStore = useMemeburnerStore(); + const rewardLockerStore = useRewardLockerStore(); + const roundsStore = useRoundsStore(); + const walletStore = useWalletStoreV2(); + console.log("walletStore.initialized", walletStore.initialized); + walletStore.initialized = true; + console.log("hier"); // await walletStore.init(); // await tokenStore.initV2(); // await memeBurnerStore.init(); // await rewardLockerStore.init(); // await memeBurnerStore.init(); - // await multiCallStore.init(); - //Memeburner Contract + console.log("init router"); + console.log("roundsStore.currentRound", roundsStore.currentRound); + if (!roundsStore.currentRound) { + roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); + console.log("roundsStore.currentRound", roundsStore.currentRound); + roundsStore.activeRound = roundsStore.currentRound; + } - //init - // roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); - // console.log("roundsStore.currentRound", roundsStore.currentRound); - // roundsStore.activeRound = roundsStore.currentRound; + const { chain, chains } = getNetwork(); + console.log("chain", chain?.id); + console.log("chains", chains); + + await roundsStore.fillRound(roundsStore.activeRound); + // await walletStore.loadWalletData(); + + // initContracts + //Memeburner Contract }); @@ -110,11 +134,8 @@ onMounted(async () => { -->
@@ -151,6 +172,7 @@ onMounted(async () => { .footer height: auto background-color: var(--midnight-black) + min-height: 72px @media (min-width: 992px) height: 450px min-height: 450px @@ -186,14 +208,14 @@ onMounted(async () => { height: 72px width: 100% padding: 16px 48px - border-radius: 24px 24px 0px 0px - background: var(--grey, #858585) + border-radius: 16px 16px 0px 0px + box-shadow: 0px -4px 6px 0px rgba(0, 0, 0, 0.25) + background: var(--midnight-black, #0F0F0F) bottom: -1px position: fixed display: flex justify-content: space-around align-items: center - color: black div font-size: 40px cursor: pointer diff --git a/src/assets/contracts/test.json b/src/assets/contracts/test.json new file mode 100644 index 0000000..3e6b270 --- /dev/null +++ b/src/assets/contracts/test.json @@ -0,0 +1,992 @@ +{ + "contractName": "OurUniV3Pool", + "contractAddress": "0xCc08EECAD5cE5c47bD7B51385b701d00c8Bdfa90", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "Collect", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "CollectProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid1", + "type": "uint256" + } + ], + "name": "Flash", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextOld", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextNew", + "type": "uint16" + } + ], + "name": "IncreaseObservationCardinalityNext", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Initialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0New", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1New", + "type": "uint8" + } + ], + "name": "SetFeeProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount1", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Swap", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collect", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collectProtocol", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fee", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal0X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal1X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "flash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + } + ], + "name": "increaseObservationCardinalityNext", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "liquidity", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLiquidityPerTick", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "observations", + "outputs": [ + { + "internalType": "uint32", + "name": "blockTimestamp", + "type": "uint32" + }, + { + "internalType": "int56", + "name": "tickCumulative", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityCumulativeX128", + "type": "uint160" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32[]", + "name": "secondsAgos", + "type": "uint32[]" + } + ], + "name": "observe", + "outputs": [ + { + "internalType": "int56[]", + "name": "tickCumulatives", + "type": "int56[]" + }, + { + "internalType": "uint160[]", + "name": "secondsPerLiquidityCumulativeX128s", + "type": "uint160[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "positions", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside0LastX128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside1LastX128", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "tokensOwed0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "tokensOwed1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFees", + "outputs": [ + { + "internalType": "uint128", + "name": "token0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "token1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "feeProtocol0", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "feeProtocol1", + "type": "uint8" + } + ], + "name": "setFeeProtocol", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "slot0", + "outputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "internalType": "int24", + "name": "tick", + "type": "int24" + }, + { + "internalType": "uint16", + "name": "observationIndex", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinality", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "feeProtocol", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "unlocked", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "name": "snapshotCumulativesInside", + "outputs": [ + { + "internalType": "int56", + "name": "tickCumulativeInside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityInsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsInside", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "int256", + "name": "amountSpecified", + "type": "int256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1", + "type": "int256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int16", + "name": "", + "type": "int16" + } + ], + "name": "tickBitmap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tickSpacing", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "name": "ticks", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidityGross", + "type": "uint128" + }, + { + "internalType": "int128", + "name": "liquidityNet", + "type": "int128" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside0X128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside1X128", + "type": "uint256" + }, + { + "internalType": "int56", + "name": "tickCumulativeOutside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityOutsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsOutside", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ] +} \ No newline at end of file diff --git a/src/assets/sass/base.sass b/src/assets/sass/base.sass index 4de94c4..b34b56d 100644 --- a/src/assets/sass/base.sass +++ b/src/assets/sass/base.sass @@ -1,7 +1,6 @@ .bloodline-devider font-size: 42px text-align: center - margin: 16px 0 @media (min-width: 992px) margin: 24px 0 @@ -33,28 +32,6 @@ &.grey background-color: var(--grey) -.card - display: block - overflow: hidden - overflow-wrap: break-word - position: relative - padding: 0 - text-decoration: none - transition-duration: .28s - transition-property: box-shadow,opacity,background - transition-timing-function: cubic-bezier(.4,0,.2,1) - z-index: 0 - border-color: rgba(var(--v-border-color),var(--v-border-opacity)) - border-style: solid - border-width: 0 - border-radius: 16px - box-shadow: 0 2px 1px -1px rgba(0, 0, 0, .2),0 1px 1px 0rgba(0, 0, 0, .14),0 1px 3px 0 rgba(0, 0, 0, .12) - background-color: $darkgrey - @media (min-width: 992px) - border-radius: 4px - &.card--variant1 - border-radius: 0 - .bloodline-token height: 50px width: 50px diff --git a/src/assets/sass/buttons.sass b/src/assets/sass/buttons.sass index 7196813..a7dea71 100644 --- a/src/assets/sass/buttons.sass +++ b/src/assets/sass/buttons.sass @@ -1,19 +1,18 @@ .btn + padding: 16px 24px + gap: 8px + border-radius: 14px + &.btn--disabled + background-color: #151515 + color: #808080 + cursor: not-allowed + &.black + background-color: var(--midnight-black) &.btn-immortal - background-color: $purple color: $button-color font-size: 24px - padding: 16px 24px - gap: 8px - border-radius: 14px &:hover,&:focus,&:active background-color: darken($purple, 10%), cursor: pointer - &.btn--disabled - background-color: #151515 - color: #808080 - cursor: not-allowed - &.black - background-color: var(--midnight-black) diff --git a/src/assets/sass/main.sass b/src/assets/sass/main.sass index 8851af5..7fc9d52 100644 --- a/src/assets/sass/main.sass +++ b/src/assets/sass/main.sass @@ -19,7 +19,7 @@ body font-family: 'Inter', sans-serif .main - padding-top: 120px + padding-top: 106px @media (min-width: 992px) padding-top: 208px html @@ -39,8 +39,8 @@ body .container margin-right: auto margin-left: auto - padding-right: 15px - padding-left: 15px + padding-right: 16px + padding-left: 16px @media (min-width: 992px) max-width: 800px diff --git a/src/assets/sass/variables.sass b/src/assets/sass/variables.sass index d56bc1e..175db05 100644 --- a/src/assets/sass/variables.sass +++ b/src/assets/sass/variables.sass @@ -16,6 +16,7 @@ $purple: #4B0082 $midnight-black: #0F0F0F $darkgrey: #202020 $grey2: #2D2D2D +$dark-grey: #2D2D2D $button-color: $white $button-background-color: $black @@ -32,14 +33,55 @@ $button-background-color: $black --white: #{#F9F9FA} --grey: #{#858585} --grey2: #{$grey2} + --dark-grey: #{$dark-grey} --purple: #{$purple} --blood-color: #{$red} --midnight-black: #{$midnight-black} --black: #{$midnight-black} --darkgrey: #{$darkgrey} + +//fonts +.low-mid-text + font-family: Inter + font-size: 16px + font-style: normal + font-weight: 400 + line-height: normal +.mid-mid-text + font-family: Inter + font-size: 18px + font-style: normal + font-weight: 400 + line-height: normal +.mid-text + font-family: Inter + font-size: 24px + font-style: normal + font-weight: 400 + line-height: normal +.small-text + font-family: Inter + font-size: 14px + font-style: normal + font-weight: 400 + line-height: normal +.number-mobile + font-family: Inter + font-size: 24px + font-style: normal + font-weight: 400 + line-height: normal + letter-spacing: 4.32px + // :root // --font-size-text: 16px // --font-size-title: 32px // @media (min-width: 992px) // --font-size-text: 24px // --font-size-title: 36px + +.text-center + text-align: center + +.transparent + background-color: transparent diff --git a/src/components/ClaimComponent.vue b/src/components/ClaimComponent.vue new file mode 100644 index 0000000..b292d2f --- /dev/null +++ b/src/components/ClaimComponent.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/components/ConnectWallet.vue b/src/components/ConnectWallet.vue index ec81a2c..52bebc0 100644 --- a/src/components/ConnectWallet.vue +++ b/src/components/ConnectWallet.vue @@ -38,14 +38,37 @@ :price="token.balanceOf" >
-
-
Sacrifice
+
+
+ Buy +
+
Sacrifice
- +
@@ -59,9 +82,12 @@ import TokenLogo from "./TokenLogo.vue"; import StakeComponent from "./StakeComponent.vue"; import TokenInput from "./TokenInput.vue"; import { getAddressShortName, getblocky } from "@/helper/helper.js"; +import { useRoute, useRouter } from "vue-router"; import { disconnect } from "@wagmi/core"; +const router = useRouter(); + const walletStore = useWalletStoreV2(); const tokenStore = useTokenStore(); @@ -85,6 +111,14 @@ async function disconnectWallet() { } } +function badgeClick(token) { + var tokenData = tokenStore.getToken(token.contractAddress); + tokenStore.activeToken = tokenData; + // router.push({ name: "home", hash: `#${tokenData.name}` }); + router.push({ name: "home" }); + instance.parent.emit("update:modelValue", false); +} + async function connectWallet(connector) { instance.parent.emit("update:modelValue", false); await walletStore.connectWallet(toRaw(connector)); @@ -149,23 +183,4 @@ async function connectWallet(connector) { padding: 4px 16px color: black font-size: 14px - -.connected-stake - .connected-stake-headline - margin-bottom: 8px - .connected-stake-subheadline - margin-bottom: 16px - .connected-stake-body - display: flex - gap: 16px - margin-bottom: 16px - .stake-reward - margin-left: auto - .connected-stake-buttons - display: flex - text-align: center - gap: 16px - div - flex: 1 1 50% - font-size: 18px diff --git a/src/components/SacrificeToken.vue b/src/components/SacrificeToken.vue index 6e4680c..3883ce2 100644 --- a/src/components/SacrificeToken.vue +++ b/src/components/SacrificeToken.vue @@ -1,7 +1,6 @@ diff --git a/src/components/TokenInput.vue b/src/components/TokenInput.vue index f3d2937..2c7f2cb 100644 --- a/src/components/TokenInput.vue +++ b/src/components/TokenInput.vue @@ -6,7 +6,6 @@ v-model="props.modelValue" :placeholder="0" /> -
diff --git a/src/components/TokenNamePrice.vue b/src/components/TokenNamePrice.vue index 968fb63..7b39c78 100644 --- a/src/components/TokenNamePrice.vue +++ b/src/components/TokenNamePrice.vue @@ -1,7 +1,7 @@ @@ -15,9 +15,5 @@ const props = defineProps({ diff --git a/src/helper/helper.js b/src/helper/helper.js index 2ae33fb..40179e2 100644 --- a/src/helper/helper.js +++ b/src/helper/helper.js @@ -25,6 +25,14 @@ export function getAddressShortName(address) { return addressBegin + "..." + addressEnd; } + +export function numberWithCommas(x) { + x = x.toString(); + var pattern = /(-?\d+)(\d{3})/; + while (pattern.test(x)) x = x.replace(pattern, "$1,$2"); + return x; +} + export function getblocky(address) { var blockiesData = blockies .create({ diff --git a/src/main.js b/src/main.js index bcb6b6f..e09ee4b 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,9 @@ import './assets/sass/main.sass' import { useWalletStoreV2 } from "@/stores/walletV2"; +import { useTokenStore } from "@/stores/tokens"; +import { useMemeburnerStore } from "@/stores/memeburner"; +import { useRewardLockerStore } from "@/stores/rewardlocker"; +import { useRoundsStore } from "@/stores/rounds"; import { createApp } from 'vue' import { createPinia } from 'pinia' @@ -8,12 +12,17 @@ import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; import { createConfig, configureChains, - getAccount, + getAccount, + getNetwork, getContract, connect, disconnect, InjectedConnector, - watchAccount, + watchAccount, + watchWalletClient, + watchPublicClient, + watchContractEvent, + watchNetwork, getWalletClient, fetchBalance, multicall, @@ -71,8 +80,12 @@ pinia.use(piniaPluginPersistedstate); app.use(pinia); - const walletStore = useWalletStoreV2(); +const tokenStore = useTokenStore(); +const memeBurnerStore = useMemeburnerStore(); +const rewardLockerStore = useRewardLockerStore(); +const roundsStore = useRoundsStore(); + const goerliKey = import.meta.env.VITE_GOERLI_KEY; const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5"; @@ -82,6 +95,7 @@ const { chains, publicClient, webSocketPublicClient } = configureChains( [alchemyProvider({ apiKey: goerliKey }), publicProvider()] ); + walletStore.config = createConfig({ autoConnect: true, connectors: [ @@ -111,6 +125,93 @@ walletStore.config = createConfig({ }); walletStore.publicClient = publicClient; +const networkId = getNetwork()?.chain?.id; + +watchWalletClient( + { + chainId: networkId, + }, + async (walletClient) => { + walletStore.walletClient = walletClient; + } +); + +watchPublicClient( + { + chainId: networkId, + }, + (publicClient) => console.log("publicClient", publicClient) +); + +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); + } +); + +watchAccount(async (account) => { + console.log("watchAccount", account); + + // {chainId: } + if (account.address) { + walletStore.address = account.address; + walletStore.connected = true; + let chainObject = walletStore.chain; + if (!walletStore.chain) { + const { chain, chains } = getNetwork(); + chainObject = chain; + } + // var walletClient = await getWalletClient({ + // account: account.address, + // chainId: chainObject.id, + // }); + + // walletStore.walletClient = walletClient; + + await memeBurnerStore.init(); + await tokenStore.initV2(); + await rewardLockerStore.init(); + await walletStore.loadWalletData(); + } else { + walletStore.address = null; + walletStore.connected = false; + walletStore.walletClient = null; + } +}); + +watchNetwork((network) => { + console.log("network123", network); + if (network.chain) { + walletStore.chain = network.chain; + } +}); + +watchContractEvent( + { + address: memeBurnerStore.config.contractAddress, + abi: memeBurnerStore.config.abi, + eventName: "MemeSacrificed", + }, + async (log) => { + console.log("memeSacrificedEvent", log); + const token = log[0].args.sacrificedToken; + await roundsStore.updateCurrentRound(token); + } + ); + +await walletStore.init(); +await tokenStore.initV2(); +await memeBurnerStore.init(); +await rewardLockerStore.init(); +await memeBurnerStore.init(); + app.use(router) app.component('font-awesome-icon', FontAwesomeIcon) app.mount('#app') diff --git a/src/router/index.js b/src/router/index.js index 05e42f1..babe28e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -68,102 +68,8 @@ const router = createRouter({ router.beforeEach(async (to, from) => { //init - const showPanel = ref(false); - const eventWatch = ref(null); - const netWorkEvent = ref(null); - const memeSacrificedEvent = ref(null); - const clientClientEvent = ref(null); - console.log("beforeEach"); - const tokenStore = useTokenStore(); - const memeBurnerStore = useMemeburnerStore(); - const rewardLockerStore = useRewardLockerStore(); - const roundsStore = useRoundsStore(); + const walletStore = useWalletStoreV2(); - console.log("walletStore.publicClient", walletStore.publicClient); - if (!walletStore.initialized) { - walletStore.initialized = true - console.log("hier"); - await walletStore.init(); - await tokenStore.initV2(); - await memeBurnerStore.init(); - await rewardLockerStore.init(); - await memeBurnerStore.init(); - console.log("init router"); - console.log("roundsStore.currentRound", roundsStore.currentRound); - if (!roundsStore.currentRound) { - roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); - console.log("roundsStore.currentRound", roundsStore.currentRound); - roundsStore.activeRound = roundsStore.currentRound; - } - - //events - eventWatch.value = watchAccount(async (account) => { - console.log("account123", account); - const publicClient = getPublicClient(); - console.log("publicClient", publicClient); - - // {chainId: } - console.log("walletClient", walletClient); - if (account.address) { - walletStore.address = account.address; - walletStore.connected = true; - let chainObject = walletStore.chain; - if (!walletStore.chain) { - const { chain, chains } = getNetwork(); - chainObject = chain; - } - var walletClient = await getWalletClient({ - account: account.address, - chainId: chainObject.id, - }); - walletStore.walletClient = walletClient; - - // walletStore.getTokenBalances() - - await memeBurnerStore.init(); - console.log("hierabc"); - await tokenStore.initV2(); - } else { - walletStore.address = null; - walletStore.connected = false; - walletStore.walletClient = null; - } - }); - - netWorkEvent.value = watchNetwork((network) => { - console.log("network123", network); - if (network.chain) { - walletStore.chain = network.chain; - - clientClientEvent.value = watchWalletClient( - { - chainId: network.chain.id, - }, - (walletClient) => { - walletStore.walletClient = walletClient; - console.log("wc123", walletClient); - } - ); - } - }); - - memeSacrificedEvent.value = 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 roundsStore.fillRound(roundsStore.activeRound); - await walletStore.loadWalletData(); - } - //middleware if (to.meta.middleware) { diff --git a/src/stores/memeburner.js b/src/stores/memeburner.js index e312611..26cafc7 100644 --- a/src/stores/memeburner.js +++ b/src/stores/memeburner.js @@ -79,9 +79,10 @@ export const useMemeburnerStore = defineStore("memeburner", { this.loading = true; const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals)); console.log("this.contract", this.contract); - console.log("amountDecimal", amountDecimal); + console.log("amountDecimal", amountDecimal.toString()); + console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress); var hash = await this.contract.write - .sacrificeMeme([tokenStore.activeToken.contractAddress, amountDecimal]) + .sacrificeMeme([tokenStore.activeToken.contractAddress, amountDecimal.toString()]) console.log("hash", hash); const data = await waitForTransaction({ hash: hash, diff --git a/src/stores/rewardlocker.js b/src/stores/rewardlocker.js index 8fa7d7c..68c2428 100644 --- a/src/stores/rewardlocker.js +++ b/src/stores/rewardlocker.js @@ -2,7 +2,9 @@ import { defineStore } from "pinia"; import RewardLockerJson from "@/assets/contracts/RewardLocker.json"; import { useTokenStore } from "./tokens"; import { useWalletStoreV2 } from "./walletV2"; -import { multicall, getContract } from "@wagmi/core"; +import { useRoundsStore } from "@/stores/rounds"; +import { createPermitObject, getSignatureRSV } from "@/helper/blockchain.js"; +import { multicall, getContract, signTypedData, getAccount, waitForTransaction } from "@wagmi/core"; export const useRewardLockerStore = defineStore("rewardlocker", { @@ -14,9 +16,9 @@ export const useRewardLockerStore = defineStore("rewardlocker", { getters: {}, actions: { async init() { - console.log("-----------init rewardlocker-------------"); - const walletStore = useWalletStoreV2(); - this.contract = getContract({ + console.log("-----------init rewardlocker-------------"); + const walletStore = useWalletStoreV2(); + this.contract = getContract({ address: this.config.contractAddress, abi: this.config.abi, walletClient: walletStore.walletClient || walletStore.publicClient, @@ -35,21 +37,21 @@ export const useRewardLockerStore = defineStore("rewardlocker", { console.log("getRewardsForAllToken"); const tokenStore = useTokenStore(); const walletStore = useWalletStoreV2(); - const contracts = []; + const contracts = []; 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)); contracts.push({ ...this.contract, functionName: "rewards", args: [walletStore.address, roundNumber, token.contractAddress], }); - } - const data = await multicall({ - contracts, - }); + } + const data = await multicall({ + contracts, + }); // const multicallStore = useMultiCallStore(); - return data + return data; }, async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) { return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]); @@ -57,19 +59,75 @@ export const useRewardLockerStore = defineStore("rewardlocker", { async lastCompletedRound() { return await this.contract.read.lastCompletedRound(); }, - async claim(round) { - console.log("claim"); + async claim(round) { + console.log("claim"); const walletStore = useWalletStoreV2(); // return await this.contract.methods.claim(round).call(); - console.log(this.contract.methods.claim(round)); - // return await this.contract.methods.claim(round).send({from: walletStore.address, to: this.contractAddress}); - return await this.contract.write.claim([round]); + console.log(this.contract.methods.claim(round)); + // return await this.contract.methods.claim(round).send({from: walletStore.address, to: this.contractAddress}); + return await this.contract.write.claim([round]); + }, + async claimAll() { + console.log("claimAll"); + const roundsStore = useRoundsStore(); + const account = getAccount(); + console.log("acocunt", account); + + const rounds = await roundsStore.getFinshedRoundNumbers(); + return await this.contract.write.claim([[1, 2]]); }, async getTotalRewardsOf(address, rounds) { return await this.contract.read.getTotalRewardsOf([address, rounds]); }, + async getTotalRewards(address) { + console.log("this.contract", this.contract); + const roundsStore = useRoundsStore(); + const rounds = await roundsStore.getFinshedRoundNumbers(); + return await this.contract.read.getTotalRewardsOf([address, rounds]); + }, async getStaked(address) { return await this.contract.read.staked([address]); }, + async orderUnstake() { + try { + return await this.contract.write.orderUnstake(); + } catch (error) { + return; + } + }, + async unstake(unstakeRound) { + return await this.contract.write.unstake([unstakeRound]); + }, + async stakeBloodline(tokenNumber) { + console.log("tokenNumber", tokenNumber); + const walletStore = useWalletStoreV2(); + const tokenStore = useTokenStore(); + + const fromAddress = walletStore.address; + const spender = this.config.contractAddress; + const deadline = Date.now() + 20 * 60; + const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals; + const value = (tokenNumber * Math.pow(10, decimals)).toString(); + const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]); + console.log("nonce", nonce); + const { types, message, domain, primaryType } = createPermitObject(fromAddress, spender, nonce, deadline, value); + + const signature = await signTypedData({ + domain: domain, + message: message, + primaryType: primaryType, + types: types, + }); + + const { r, s, v } = getSignatureRSV(signature); + + const hash = await this.contract.write.stakeToBeSecured([value, deadline, v, r, s]); + console.log("hash", hash); + + const data = await waitForTransaction({ + hash: hash, + }); + console.log("data", data); + } }, }); diff --git a/src/stores/rounds.js b/src/stores/rounds.js index b006d38..d77cc27 100644 --- a/src/stores/rounds.js +++ b/src/stores/rounds.js @@ -8,136 +8,165 @@ import { multicall } from "@wagmi/core"; export const useRoundsStore = defineStore("rounds", { state: () => ({ - rounds: [ - ], - activeRound: null, - currentRound: null + rounds: [], + activeRound: null, + currentRound: null, }), - getters: { - getRoundWinner() { - const goal = this.getCurrentRoundData?.goal; - 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(); + getters: { + getRoundWinner() { + const goal = this.getCurrentRoundData?.goal; + console.log("goal", goal); + if (!goal) { + return; + } + const winnerCoin = this.rounds[this.activeRound]?.token.find((token) => token.amount === goal); + if (winnerCoin) { + return winnerCoin; + } else { + return false; + } + }, + getCurrentRoundData() { + console.log("this.rounds", this.rounds); + 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({ + 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]], + args: [walletStore.address, [index + 1]], }); - } + } - const data = await multicall({ + const data = await multicall({ contracts, - }); - console.log("data123abc", data); - // 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] = {}; - } - this.rounds[index].round = index + 1 - this.rounds[index].rewards_total = element.result - } - }, - async updateCurrentRound(sacrificedToken) { - const tokenStore = useTokenStore(); - const memeBurnerStore = useMemeburnerStore(); - var data = await memeBurnerStore.getSacrificedRound(this.currentRound); - console.log("data123", data); - var tokenIndex = this.rounds[this.currentRound].token.findIndex((tokenData) => tokenData.contractAddress === sacrificedToken); - this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex].result[1]; + }); + console.log("data123abc", data); + // 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] = {}; + } + this.rounds[index].round = index + 1; + this.rounds[index].rewards_total = element.result; + } + }, + async updateCurrentRound(sacrificedToken) { + const tokenStore = useTokenStore(); + const memeBurnerStore = useMemeburnerStore(); + var data = await memeBurnerStore.getSacrificedRound(this.currentRound); + console.log("data123", data); + var tokenIndex = this.rounds[this.currentRound].token.findIndex( + (tokenData) => tokenData.contractAddress === sacrificedToken + ); + this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex].result[1]; + }, + async fillRound(roundNumber) { + console.log("fillRound"); + const memeBurnerStore = useMemeburnerStore(); + const tokenStore = useTokenStore(); + const walletStore = useWalletStoreV2(); + const rewardLockerStore = useRewardLockerStore(); - }, - async fillRound(roundNumber) { - 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) { + console.log("round not filled --> fill round"); + console.log("vor error"); + var data = await memeBurnerStore.getSacrificedRound(roundNumber); + let rewardData = null; + if (walletStore.connected) { + console.log("hier1"); + rewardData = await rewardLockerStore.getRewardsForAllToken(roundNumber); + console.log("hier2", rewardData); + } + console.log("rewardData123", rewardData); - // if (this.activeRound === this.currentRound) { - // console.log("activeRound is not completed"); - // } else - if (!this.rounds[roundNumber]?.goal) { - console.log("round not filled --> fill round"); - console.log("vor error"); - var data = await memeBurnerStore.getSacrificedRound(roundNumber) - let rewardData = null; - if (walletStore.connected) { - rewardData = await rewardLockerStore.getRewardsForAllToken(roundNumber); - } - console.log("rewardData123", rewardData); - - var goal = await memeBurnerStore.getGoal(roundNumber); - console.log("goal", goal); - var tokenArray = [] - var rewards_clan = 0 - var rewards_sacrifice = 0 - for (let index = 0; index < data.length; index++) { - var tokenData = {}; - const token = tokenStore.token[index]; - var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient(roundNumber, token.contractAddress); - - + var goal = await memeBurnerStore.getGoal(roundNumber); + console.log("goal", goal); + var tokenArray = []; + var rewards_clan = 0; + var rewards_sacrifice = 0; + for (let index = 0; index < data.length; index++) { + var tokenData = {}; + const token = tokenStore.token[index]; + var testcoef = await rewardLockerStore.getSacrificedTokenCoefficient( + roundNumber, + token.contractAddress + ); - 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.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress); - if (this.currentRound !== roundNumber && walletStore.connected) { - const clanwin = (Number(testcoef) / 10000 - 1) * Number(rewardData[index].result); - const sacrificeRewards = Number(rewardData[index].result) - clanwin; + 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.getAmountToReachGoal = await memeBurnerStore.getAmountToReachGoal(token.contractAddress); + if (this.currentRound !== roundNumber && walletStore.connected) { + const clanwin = (Number(testcoef) / 10000 - 1) * Number(rewardData[index].result); + const sacrificeRewards = Number(rewardData[index].result) - clanwin; - tokenData.rewards_ges = BigInt(rewardData[index].result); - tokenData.rewards_clan = BigInt(clanwin); - tokenData.rewards_sacrifice = BigInt(sacrificeRewards); + tokenData.rewards_ges = BigInt(rewardData[index].result); + tokenData.rewards_clan = BigInt(clanwin); + tokenData.rewards_sacrifice = BigInt(sacrificeRewards); - rewards_clan = rewards_clan + (clanwin / Math.pow(10, token.decimals)); - rewards_sacrifice = - rewards_sacrifice + sacrificeRewards / Math.pow(10, token.decimals); - } - tokenArray.push(tokenData); - } - const goalInBLD = await memeBurnerStore.getGoalInBLD(roundNumber); - this.rounds[roundNumber] = { - goal: goal[0], - goalInBLD: goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals)), - expirationTimestamp: goal[1], - rewards_clan: BigInt(rewards_clan), - rewards_sacrifice: BigInt(rewards_sacrifice), - rewards_total: BigInt(rewards_clan + rewards_sacrifice), - token: tokenArray, - }; - console.log("this.rounds[roundNumber]", this.rounds[roundNumber]); - } else { - console.log("round already filled"); - } - console.log("this.rounds123", this.rounds); - }, - }, + rewards_clan = rewards_clan + clanwin / Math.pow(10, token.decimals); + rewards_sacrifice = rewards_sacrifice + sacrificeRewards / Math.pow(10, token.decimals); + } + tokenArray.push(tokenData); + } + const goalInBLD = await memeBurnerStore.getGoalInBLD(roundNumber); + this.rounds[roundNumber] = { + goal: goal[0], + goalInBLD: goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals)), + expirationTimestamp: goal[1], + rewards_clan: BigInt(rewards_clan), + rewards_sacrifice: BigInt(rewards_sacrifice), + rewards_total: BigInt(rewards_clan + rewards_sacrifice), + token: tokenArray, + }; + console.log("this.rounds[roundNumber]", this.rounds[roundNumber]); + } else { + console.log("round already filled"); + } + console.log("this.rounds123", this.rounds); + }, + async getFinshedRoundNumbers() { + const array = []; + const rewardLockerStore = useRewardLockerStore(); + const lastCompletedRound = await rewardLockerStore.lastCompletedRound(); + for (let index = 1; index <= Number(lastCompletedRound) + 1; index++) { + array.push(index); + } + return array; + }, + /** + * function to get finished rounds, active round and the next round to check if there is a round the user called unstakeOrdered. + * with Backend it would be much easier because we could store the event data in the database + */ + async getRoundsNumberWithNext() { + const array = []; + const rewardLockerStore = useRewardLockerStore(); + const lastCompletedRound = await rewardLockerStore.lastCompletedRound(); + for (let index = 1; index <= Number(lastCompletedRound) + 1; index++) { + array.push(index); + } + return array; + }, + }, }); diff --git a/src/stores/tokens.js b/src/stores/tokens.js index d742a4f..4bec8a7 100644 --- a/src/stores/tokens.js +++ b/src/stores/tokens.js @@ -39,7 +39,7 @@ export const useTokenStore = defineStore("token", { { abi: MemeToken.abi, contractAddress: MemeToken.contractAddress, - logo: "/assets/img/token/bloodline.png", + logo: "/assets/img/token/bloodline.png", }, // { // name: "$ELON", @@ -159,7 +159,8 @@ export const useTokenStore = defineStore("token", { return allowance; }, async approveToken(amount) { - try { + try { + console.log("amount", amount); this.loading = true; const memeBurnerStore = useMemeburnerStore(); // var approve = await this.contract.methods @@ -168,12 +169,15 @@ export const useTokenStore = defineStore("token", { console.log("approve"); var approveHash = await this.activeToken.contract.write.approve([ memeBurnerStore.config.contractAddress, - amount, + 50000000000000000000, ]); + console.log("approveHash", approveHash); const data = await waitForTransaction({ hash: approveHash, - }); + }); + this.activeToken.allowance = await this.allowance(); + console.log("data", data); return data; } catch (error) { console.error(error); diff --git a/src/stores/walletV2.js b/src/stores/walletV2.js index 7a9e93e..e3aebaa 100644 --- a/src/stores/walletV2.js +++ b/src/stores/walletV2.js @@ -16,6 +16,7 @@ import { getWalletClient, fetchBalance, multicall, + getNetwork, } from "@wagmi/core"; import { WalletConnectConnector } from "@wagmi/core/connectors/walletConnect"; @@ -40,7 +41,7 @@ export const useWalletStoreV2 = defineStore("walletV2", { config: null, chain: null, token: [], - initialized: false + initialized1: false, }), getters: { sacrificeToken: (state) => state.token.filter((obj) => obj.contractAddress !== MemeToken.contractAddress), @@ -57,8 +58,9 @@ export const useWalletStoreV2 = defineStore("walletV2", { console.log("account123abc", account); if (account.address) { this.address = account.address; - this.connected = true; + this.connected = true; } + // await this.isConnected(); // const goerliKey = import.meta.env.VITE_GOERLI_KEY; // if (this.connected) { @@ -77,19 +79,23 @@ export const useWalletStoreV2 = defineStore("walletV2", { // } // }); - console.log("this.config", this.config); - const walletClient = await getWalletClient(); - console.log("walletClient", walletClient); }, async connectWallet(connector) { - console.log("connector.name", connector.name); - // if (!account.isConnected) { - const connection = await connect({ - chainId: goerli.id, - connector: connector, - }); + try { + console.log("connector.name", connector.name); + // if (!account.isConnected) { + const connection = await connect({ + chainId: goerli.id, + connector: connector, + }); - console.log("connection", connection); + console.log("connection", connection); + } catch (error) { + if (error.message.includes("Connector not found")) { + console.warn("Connector not found"); + } + console.error(error); + } // this.address = connection.account; }, async getTokenBalance(token) { @@ -100,7 +106,8 @@ export const useWalletStoreV2 = defineStore("walletV2", { }, async getTokenBalances() { - console.log("getTokenBalances"); + console.log("getTokenBalances"); + this.token = [] const tokenStore = useTokenStore(); console.log("tokenStore.token.length", tokenStore.token.length); var contracts = []; @@ -138,6 +145,8 @@ export const useWalletStoreV2 = defineStore("walletV2", { const staked = await rewardlockerStore.getStaked(this.address); console.log("staked", staked); this.memeToken.staked = Number(staked / BigInt(Math.pow(10, tokenStore.memeToken.decimals))); + const unclaimedRewards = await rewardlockerStore.getTotalRewards(this.address); + this.memeToken.unclaimedRewards = Number(unclaimedRewards/ BigInt(Math.pow(10, tokenStore.memeToken.decimals))) } }, diff --git a/src/views/CycleView.vue b/src/views/CycleView.vue index fa5dd5a..ce61675 100644 --- a/src/views/CycleView.vue +++ b/src/views/CycleView.vue @@ -21,7 +21,7 @@ />
-
+
@@ -103,7 +103,11 @@ import { inject, ref, onMounted, onBeforeUnmount } from "vue"; import BloodChart from "@/components/BloodChart.vue"; import TokenClaim from "@/components/TokenClaim.vue"; +import { useMemeburnerStore } from "@/stores/memeburner"; + import { useRoundsStore } from "@/stores/rounds"; +import { useRewardLockerStore } from "@/stores/rewardlocker"; + const roundsStore = useRoundsStore(); const days = ref(null); @@ -111,12 +115,25 @@ const hours = ref(null); const minutes = ref(null); const seconds = ref(null); const timer = ref(null); +const difference = ref(null); +const memeBurnerStore = useMemeburnerStore(); +const rewardLockerStore = useRewardLockerStore(); const isMobile = inject("isMobile"); -onMounted(() => { +onMounted(async () => { console.log("onmounted", roundsStore.activeRound); - console.log("blatest", roundsStore.getCurrentRoundData.expirationTimestamp); + console.log("roundsStore.activeRound123", roundsStore.activeRound); + // await memeBurnerStore.init(); + // await rewardLockerStore.init(); + + if (!roundsStore.currentRound) { + console.log("test"); + roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); + console.log("roundsStore.currentRound", roundsStore.currentRound); + roundsStore.activeRound = roundsStore.currentRound; + } + await roundsStore.fillRound(roundsStore.activeRound); const expirationTimestamp = roundsStore.getCurrentRoundData.expirationTimestamp; timer.value = setInterval(function () { timeBetweenDates(expirationTimestamp); @@ -146,12 +163,15 @@ function timeBetweenDates(expirationTimestamp) { const dateEntered = new Date(Number(expirationTimestamp) * 1000); if (dateEntered) { var now = new Date(); - var difference = dateEntered.getTime() - now.getTime(); - console.log("difference", difference); - if (difference <= 0) { + difference.value = dateEntered.getTime() - now.getTime(); + console.log("difference.value", difference.value); + if (difference.value <= 0) { clearInterval(timer.value); + days.value = "0d"; + hours.value = "0h"; + minutes.value = "0m"; } else { - var _seconds = Math.floor(difference / 1000); + var _seconds = Math.floor(difference.value / 1000); var _minutes = Math.floor(_seconds / 60); var _hours = Math.floor(_minutes / 60); var _days = Math.floor(_hours / 24); diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index a3bf66d..8f8644b 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -1,33 +1,47 @@ @@ -170,12 +184,18 @@ import { ref, onMounted, computed } from "vue"; import { useRoundsStore } from "@/stores/rounds"; import { useWalletStoreV2 } from "@/stores/walletV2"; -import { getblocky } from "@/helper/helper.js"; +import { getblocky, getAddressShortName } from "@/helper/helper.js"; import StakeComponent from "@/components/StakeComponent.vue"; +import StakeComponentV1 from "@/components/StakeComponentV1.vue"; +import ClaimComponent from "@/components/ClaimComponent.vue"; + +import { useMemeburnerStore } from "@/stores/memeburner"; +import { useRewardLockerStore } from "@/stores/rewardlocker"; const roundsStore = useRoundsStore(); - const walletStore = useWalletStoreV2(); +const rewardLockerStore = useRewardLockerStore(); +const memeBurnerStore = useMemeburnerStore(); const activeRound = ref(null); const openCycleElement = ref(false); @@ -189,13 +209,22 @@ function openRound(index) { } onMounted(async () => { + // await memeBurnerStore.init(); + // await rewardLockerStore.init(); + console.log("loadRounds"); + if (!roundsStore.currentRound) { + console.log("test"); + roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); + console.log("roundsStore.currentRound", roundsStore.currentRound); + roundsStore.activeRound = roundsStore.currentRound; + } await roundsStore.loadRewardsRounds(); console.log("roundsStore.rounds", roundsStore.rounds); }); -const rounds = computed(() => - roundsStore.rounds +const rounds = computed(() => { + var tetst = roundsStore.rounds .filter((round) => { if (round.round) { return true; @@ -203,187 +232,206 @@ const rounds = computed(() => return false; } }) - .reverse() -); + .reverse(); + return tetst; +});
Sacrifice: