sacrifice.js getRewards fixes
This commit is contained in:
+13
-10
@@ -115,6 +115,8 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
||||
var quoteRewards = await uniswapStore.quoteExactInputSingle(amountETHBase[0]);
|
||||
|
||||
let variant = "sacrifice";
|
||||
// here you are setting only variant, let's show by default rewardsForResultSum
|
||||
output = rewardsForResultSum;
|
||||
if (quoteRewards.result) {
|
||||
// take 99.5% of quoted amount, 0.5% allowed slippage
|
||||
minBLOOD = quoteRewards.amount * 995n / 1000n;
|
||||
@@ -131,13 +133,6 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
||||
rewardsForResultSum,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* case 4
|
||||
* quoter threw an error
|
||||
*/
|
||||
//
|
||||
output = rewardsForResultSum;
|
||||
}
|
||||
console.log("variant", variant);
|
||||
console.log("amount", amount);
|
||||
@@ -151,13 +146,21 @@ export const useSacrificeStore = defineStore("sacrifice", {
|
||||
if (variant === "buy") {
|
||||
output = quoteRewards.amount
|
||||
}
|
||||
} else if (walletStore.connected && variant === "sacrifice") {
|
||||
} else if (walletStore.connected && variant === "sacrifice" && token.allowance >= amount) {
|
||||
/**
|
||||
* case 2
|
||||
* user is logged in and allowance is greater or equal input and variant is sacrifice
|
||||
*/
|
||||
output = rewardsForResultSum;
|
||||
} else if (walletStore.connected && variant === "buy") {
|
||||
// in this case you should use eth_call, so you are showing exact reward in cases of completing cycles
|
||||
const amountSacrifice = await readContract({
|
||||
address: memeburnerStore.contract.address,
|
||||
abi: memeburnerStore.contract.abi,
|
||||
functionName: "sacrificeMeme",
|
||||
args: [token.contractAddress, amount.toString(), minETH.toString()],
|
||||
account: walletStore.address,
|
||||
});
|
||||
output = amountSacrifice;
|
||||
} else if (walletStore.connected && variant === "buy" && token.allowance >= amount) {
|
||||
/**
|
||||
* case 3
|
||||
* user is logged in and allowance is greater or equal input and variant is buy
|
||||
|
||||
Reference in New Issue
Block a user