From 2d35457076b67974562e6a90b3c32afd3fca43ce Mon Sep 17 00:00:00 2001 From: butterscotch Date: Mon, 16 Oct 2023 22:03:22 +0300 Subject: [PATCH] memeburner: use minETH and minBLOOD params in sacrifice functions. --- src/stores/memeburner.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/stores/memeburner.js b/src/stores/memeburner.js index 2f98a39..27a4df3 100644 --- a/src/stores/memeburner.js +++ b/src/stores/memeburner.js @@ -48,7 +48,7 @@ export const useMemeburnerStore = defineStore("memeburner", { return await this.contract.read.getSacrificedMeme([cycleNumber, tokenAddress]); }, async getAmountToReachGoal(tokenAddress) { - return await this.contract.read.getAmountToReachGoal([tokenAddress, 0]); + return await this.contract.read.getAmountToReachGoal([tokenAddress]); }, async getSacrificedCycle(cycleNumber) { console.log("getSacrificedCycle", cycleNumber); @@ -70,7 +70,7 @@ export const useMemeburnerStore = defineStore("memeburner", { }); return data; }, - async sacrificeMeme(amount) { + async sacrificeMeme(amount, minETH) { const tokenStore = useTokenStore(); try { if (!amount || amount == 0) { @@ -79,11 +79,12 @@ export const useMemeburnerStore = defineStore("memeburner", { return; } this.loading = true; - const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals)); + // TODO: store all integer values as one type: BigInt + const amountDecimal = BigInt(amount) * 10n ** BigInt(tokenStore.activeToken.decimals); var hash = await this.contract.write.sacrificeMeme([ tokenStore.activeToken.contractAddress, amountDecimal.toString(), - 0 + minETH.toString() ]); return hash; } catch (error) { @@ -93,14 +94,14 @@ export const useMemeburnerStore = defineStore("memeburner", { this.loading = false; } }, - async sacrificeMemeAndBuyBLOOD(amount) { + async sacrificeMemeAndBuyBLOOD(amount, minBLOOD) { const tokenStore = useTokenStore(); - const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals)); + const amountDecimal = BigInt(amount) * 10n ** BigInt(tokenStore.activeToken.decimals); var hash = await this.contract.write.sacrificeMemeAndBuyBLOOD([ tokenStore.activeToken.contractAddress, amountDecimal.toString(), - 0, + minBLOOD.toString() ]); return hash; }, @@ -111,7 +112,7 @@ export const useMemeburnerStore = defineStore("memeburner", { console.log("getAmountETHBase"); const tokenStore = useTokenStore(); return await this.contract.read.getAmountETHBase([tokenStore.activeToken.contract.address, amount, true]); - + } },