8 Commits
Author SHA1 Message Date
EmberSpirit 7d1e7dcbf5 contract update 2023-10-24 06:31:01 +02:00
EmberSpirit cc3fb88d1e replace static 18n 2023-10-23 22:09:42 +02:00
EmberSpirit fcf6133a47 contract update 2023-10-23 22:00:09 +02:00
EmberSpirit 32db2d291c update bloodchart compact number 2023-10-23 21:58:54 +02:00
EmberSpirit 1b799b8825 Merge branch 'fix/simplifyUniswap' into development 2023-10-23 21:40:07 +02:00
EmberSpirit 99ff2cb166 merge pull request 2023-10-23 21:39:39 +02:00
butterscotch 74dd5b7e0a sacrifice.js getRewards fixes 2023-10-23 20:45:24 +03:00
butterscotch bc3b7eac67 simplified uniswap.js 2023-10-23 01:01:34 +03:00
13 changed files with 2480 additions and 2471 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "Bloodline", "contractName": "Bloodline",
"contractAddress": "0x51bF3df58D123e8EA43fb2189f18027FD36a08Af", "contractAddress": "0x16351Cd1f3F1eb010758ff9FCf7013f48B0f5495",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
+97 -1
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "LiquidityOwner", "contractName": "LiquidityOwner",
"contractAddress": "0xF8bc4Ce13263DD4e12070e3192be50310eF7C95a", "contractAddress": "0x460f41499B6dA662ce289b57ba62A75FBd753b5c",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
@@ -132,6 +132,35 @@
"stateMutability": "pure", "stateMutability": "pure",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "int24",
"name": "tick",
"type": "int24"
},
{
"internalType": "int24",
"name": "tickLower",
"type": "int24"
},
{
"internalType": "int24",
"name": "tickUpper",
"type": "int24"
}
],
"name": "_liquidityCanBeProvided",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -169,6 +198,54 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "int24",
"name": "tickCycle",
"type": "int24"
}
],
"name": "calculateTicksForRange1",
"outputs": [
{
"internalType": "int24",
"name": "tickLower",
"type": "int24"
},
{
"internalType": "int24",
"name": "tickUpper",
"type": "int24"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "int24",
"name": "tickCycle",
"type": "int24"
}
],
"name": "calculateTicksForRange2",
"outputs": [
{
"internalType": "int24",
"name": "tickLower",
"type": "int24"
},
{
"internalType": "int24",
"name": "tickUpper",
"type": "int24"
}
],
"stateMutability": "pure",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@@ -211,6 +288,25 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "cycleTicks",
"outputs": [
{
"internalType": "int24",
"name": "",
"type": "int24"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "memeAltar", "name": "memeAltar",
+46 -106
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "MemeAltar", "contractName": "MemeAltar",
"contractAddress": "0xE4F42F3f8B0E57b1054D457fe3b49a1A10B1aCEa", "contractAddress": "0xAa72C9dB8332c28b4ebcC36D927e967EFC98D78C",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
@@ -53,6 +53,11 @@
"name": "CycleCompletedRegistrationFailed", "name": "CycleCompletedRegistrationFailed",
"type": "error" "type": "error"
}, },
{
"inputs": [],
"name": "GoalCannotBeZero",
"type": "error"
},
{ {
"inputs": [], "inputs": [],
"name": "InsufficientOutputAmount", "name": "InsufficientOutputAmount",
@@ -215,42 +220,16 @@
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
{ {
"components": [ "indexed": true,
{ "internalType": "uint64",
"internalType": "uint40", "name": "b",
"name": "b1", "type": "uint64"
"type": "uint40" },
}, {
{ "indexed": true,
"internalType": "uint40", "internalType": "uint64",
"name": "m1", "name": "m",
"type": "uint40" "type": "uint64"
},
{
"internalType": "uint40",
"name": "b2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "b3",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m4",
"type": "uint40"
}
],
"indexed": false,
"internalType": "struct MemeAltar.BM",
"name": "_bm",
"type": "tuple"
} }
], ],
"name": "NewBM", "name": "NewBM",
@@ -309,41 +288,14 @@
{ {
"inputs": [ "inputs": [
{ {
"components": [ "internalType": "uint64",
{ "name": "newB",
"internalType": "uint40", "type": "uint64"
"name": "b1", },
"type": "uint40" {
}, "internalType": "uint64",
{ "name": "newM",
"internalType": "uint40", "type": "uint64"
"name": "m1",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "b2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "b3",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m4",
"type": "uint40"
}
],
"internalType": "struct MemeAltar.BM",
"name": "newBM",
"type": "tuple"
} }
], ],
"name": "adjustBM", "name": "adjustBM",
@@ -410,12 +362,12 @@
}, },
{ {
"inputs": [], "inputs": [],
"name": "bloodline", "name": "b",
"outputs": [ "outputs": [
{ {
"internalType": "contract Bloodline", "internalType": "uint64",
"name": "", "name": "",
"type": "address" "type": "uint64"
} }
], ],
"stateMutability": "view", "stateMutability": "view",
@@ -423,37 +375,12 @@
}, },
{ {
"inputs": [], "inputs": [],
"name": "bm", "name": "bloodline",
"outputs": [ "outputs": [
{ {
"internalType": "uint40", "internalType": "contract Bloodline",
"name": "b1", "name": "",
"type": "uint40" "type": "address"
},
{
"internalType": "uint40",
"name": "m1",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "b2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m2",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "b3",
"type": "uint40"
},
{
"internalType": "uint40",
"name": "m4",
"type": "uint40"
} }
], ],
"stateMutability": "view", "stateMutability": "view",
@@ -662,9 +589,9 @@
"name": "issuancePrice", "name": "issuancePrice",
"outputs": [ "outputs": [
{ {
"internalType": "uint256", "internalType": "uint128",
"name": "", "name": "",
"type": "uint256" "type": "uint128"
} }
], ],
"stateMutability": "view", "stateMutability": "view",
@@ -683,6 +610,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "m",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"contractName": "RewardLocker", "contractName": "RewardLocker",
"contractAddress": "0x2952253374973DE0ffbFe35269Ca13FaF28B935F", "contractAddress": "0x8b15b2CB5b019472C31aEf487BF700037c321F85",
"abi": [ "abi": [
{ {
"inputs": [ "inputs": [
File diff suppressed because one or more lines are too long
+5
View File
@@ -0,0 +1,5 @@
{
"contractName": "WETH",
"contractAddress": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
"contractAddressMainnet": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
+8 -3
View File
@@ -72,8 +72,13 @@
</div> </div>
</div> </div>
<div class="blood-chart-element-footer"> <div class="blood-chart-element-footer">
<div class="blood-chart-amount"> <div
{{ formatNumber(coin.amountInBLD, 10n ** tokenStore.memeToken.decimals) }} class="blood-chart-amount"
:title="formatBigIntDivision(coin.amountInBLD, 10n ** tokenStore.memeToken.decimals)"
>
{{
compactNumber(formatBigIntDivision(coin.amountInBLD, 10n ** tokenStore.memeToken.decimals))
}}
</div> </div>
<div>$BLOOD</div> <div>$BLOOD</div>
</div> </div>
@@ -96,7 +101,7 @@
<script setup> <script setup>
import { computed, ref, inject, onMounted } from "vue"; import { computed, ref, inject, onMounted } from "vue";
import { getPercentage, formatNumber } from "@/helper/helper.js"; import { getPercentage, formatNumber, compactNumber, formatBigIntDivision } from "@/helper/helper.js";
import { useCycleStore } from "@/stores/cycles"; import { useCycleStore } from "@/stores/cycles";
import { useMemeburnerStore } from "@/stores/memeburner"; import { useMemeburnerStore } from "@/stores/memeburner";
+1 -1
View File
@@ -36,7 +36,7 @@
<div class="connected-header-avatar"> <div class="connected-header-avatar">
<img :src="getblocky(walletStore.address)" alt="avatar" /> <img :src="getblocky(walletStore.address)" alt="avatar" />
</div> </div>
<div class="connected-header-address"> <div class="connected-header-address" :title="walletStore.address">
{{ getAddressShortName(walletStore.address) }} {{ getAddressShortName(walletStore.address) }}
</div> </div>
<div class="connected-header-logout" @click="disconnectWallet"> <div class="connected-header-logout" @click="disconnectWallet">
+1 -1
View File
@@ -30,7 +30,7 @@
:modelValue="sacrificeStore.sacrificeNumber / 10n ** activeToken.decimals" :modelValue="sacrificeStore.sacrificeNumber / 10n ** activeToken.decimals"
@input=" @input="
($event) => { ($event) => {
const value = BigInt($event.target.value) * 10n ** 18n; const value = BigInt($event.target.value) * 10n ** activeToken.decimals;
sacrificeStore.sacrificeNumber = value; sacrificeStore.sacrificeNumber = value;
processChange(value); processChange(value);
} }
+7
View File
@@ -3,6 +3,13 @@ export function getPercentage(amount, goal) {
return ((Number(amount) / Number(goal)) * 100).toFixed(2); return ((Number(amount) / Number(goal)) * 100).toFixed(2);
} }
export function compactNumber(number) {
return Intl.NumberFormat("en-US", {
notation: "compact",
maximumFractionDigits: 2,
}).format(number);
}
export function formatNumber(nominator, denominator) { export function formatNumber(nominator, denominator) {
let number = formatBigIntDivision(nominator, denominator); let number = formatBigIntDivision(nominator, denominator);
+9 -9
View File
@@ -149,15 +149,15 @@ export const useSacrificeStore = defineStore("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
*/ */
// in this case you should use eth_call, so you are showing exact reward in cases of completing cycles // in this case you should use eth_call, so you are showing exact reward in cases of completing cycles
const amountSacrifice = await readContract({ const amountSacrifice = await readContract({
address: memeburnerStore.contract.address, address: memeburnerStore.contract.address,
abi: memeburnerStore.contract.abi, abi: memeburnerStore.contract.abi,
functionName: "sacrificeMeme", functionName: "sacrificeMeme",
args: [token.contractAddress, amount.toString(), minETH.toString()], args: [token.contractAddress, amount.toString(), minETH.toString()],
account: walletStore.address, account: walletStore.address,
}); });
output = amountSacrifice; output = amountSacrifice;
} else if (walletStore.connected && variant === "buy" && token.allowance >= amount) { } else if (walletStore.connected && variant === "buy" && token.allowance >= amount) {
/** /**
* case 3 * case 3
+15 -59
View File
@@ -1,23 +1,17 @@
import { defineStore } from "pinia"; 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 WethJson from "@/assets/contracts/WETH.json";
import BloodlineJson from "@/assets/contracts/Bloodline.json"; import BloodlineJson from "@/assets/contracts/Bloodline.json";
import { useMemeburnerStore } from "@/stores/memeburner";
import { useTokenStore } from "@/stores/tokens";
import { getContract, multicall } from "@wagmi/core"; import { getContract, multicall } from "@wagmi/core";
export const useUniswapStore = defineStore("uniswap", { export const useUniswapStore = defineStore("uniswap", {
state: () => ({ state: () => ({
quoateV3Contract: {}, quoateV3Contract: {},
quoateV2Contract: {}, tokenIn: WethJson.contractAddress,
uniswapPoolContract: {}, tokenOut: BloodlineJson.contractAddress,
poolData: { fee: 10000n,
token0: null,
token1: null,
fee: null,
},
}), }),
getters: {}, getters: {},
actions: { actions: {
@@ -31,38 +25,25 @@ export const useUniswapStore = defineStore("uniswap", {
walletClient: walletStore.walletClient || walletStore.publicClient, walletClient: walletStore.walletClient || walletStore.publicClient,
}); });
this.uniswapPoolContract = getContract({
address: UniswapPoolJson.contractAddress,
abi: UniswapPoolJson.abi,
walletClient: walletStore.walletClient || walletStore.publicClient,
});
this.getPoolData();
}, },
async quoteExactInputSingle(amount, ethBase) { async quoteExactInputSingle(ethBase) {
try { try {
console.log("quoteExactInputSingle"); console.log("quoteExactInputSingle");
const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore();
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", {
tokenIn: tokenIn, // WETH tokenIn: this.tokenIn, // WETH
tokenOut: tokenOut, // BLOOD tokenOut: this.tokenOut, // BLOOD
fee: this.poolData.fee, fee: this.fee,
amountEthBase: ethBase, amountEthBase: ethBase,
pricelimit: 0, //sqrtPriceLimitX96 pricelimit: 0n, //sqrtPriceLimitX96
}); });
const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([ const quotedAmountOut = await this.quoateV3Contract.read.quoteExactInputSingle([
tokenIn, //weth this.tokenIn, //weth
tokenOut, //bloodline this.tokenOut, //bloodline
this.poolData.fee, this.fee,
ethBase, ethBase,
0, //sqrtPriceLimitX96 0n, //sqrtPriceLimitX96
]); ]);
console.log("quotedAmountOut", quotedAmountOut); console.log("quotedAmountOut", quotedAmountOut);
return {result: true, amount: quotedAmountOut}; return {result: true, amount: quotedAmountOut};
@@ -70,31 +51,6 @@ export const useUniswapStore = defineStore("uniswap", {
return { result: false, amount: null }; return { result: false, amount: null };
} }
}, }
async getPoolData() { }
console.log("getPoolData");
const contracts = [];
contracts.push(
{
...this.uniswapPoolContract,
functionName: "token0",
},
{
...this.uniswapPoolContract,
functionName: "token1",
},
{
...this.uniswapPoolContract,
functionName: "fee",
}
);
const data = await multicall({
contracts,
});
this.poolData.token0 = data[0].result;
this.poolData.token1 = data[1].result;
this.poolData.fee = data[2].result;
console.log("this.poolData", this.poolData);
},
},
}); });
+2288 -2288
View File
File diff suppressed because it is too large Load Diff