memeburner: use minETH and minBLOOD params in sacrifice functions.
This commit is contained in:
@@ -48,7 +48,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);
|
||||||
@@ -70,7 +70,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) {
|
||||||
@@ -79,11 +79,12 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
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([
|
var hash = await this.contract.write.sacrificeMeme([
|
||||||
tokenStore.activeToken.contractAddress,
|
tokenStore.activeToken.contractAddress,
|
||||||
amountDecimal.toString(),
|
amountDecimal.toString(),
|
||||||
0
|
minETH.toString()
|
||||||
]);
|
]);
|
||||||
return hash;
|
return hash;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -93,14 +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 * Math.pow(10, tokenStore.activeToken.decimals));
|
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,
|
||||||
amountDecimal.toString(),
|
amountDecimal.toString(),
|
||||||
0,
|
minBLOOD.toString()
|
||||||
]);
|
]);
|
||||||
return hash;
|
return hash;
|
||||||
},
|
},
|
||||||
@@ -111,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]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user