tax rate, version and compose (#70)
resolves #67 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/70
This commit is contained in:
parent
d8ca557eb6
commit
6cbb1781ce
40 changed files with 1243 additions and 213 deletions
|
|
@ -9,7 +9,7 @@ import { getNonce, nonce, getName } from '@/contracts/harb';
|
|||
import { useWallet } from '@/composables/useWallet';
|
||||
import { createPermitObject, getSignatureRSV } from '@/utils/blockchain';
|
||||
import { formatBigIntDivision, compactNumber } from '@/utils/helper';
|
||||
import { taxRates } from '@/composables/useAdjustTaxRates';
|
||||
import { getTaxRateOptionByIndex } from '@/composables/useAdjustTaxRates';
|
||||
import { useContractToast } from './useContractToast';
|
||||
const wallet = useWallet();
|
||||
const contractToast = useContractToast();
|
||||
|
|
@ -82,10 +82,13 @@ export function useStake() {
|
|||
|
||||
// const stakingAmountNumber = computed(() => return staking)
|
||||
|
||||
async function snatch(stakingAmount: bigint, taxRate: number, positions: Array<bigint> = []) {
|
||||
// console.log("snatch", { stakingAmount, taxRate, positions });
|
||||
async function snatch(stakingAmount: bigint, taxRateIndex: number, positions: Array<bigint> = []) {
|
||||
// console.log("snatch", { stakingAmount, taxRateIndex, positions });
|
||||
const account = getAccount(wagmiConfig);
|
||||
const taxRateObj = taxRates.find(obj => obj.year === taxRate);
|
||||
const taxRateOption = getTaxRateOptionByIndex(taxRateIndex);
|
||||
if (!taxRateOption) {
|
||||
throw new Error(`Invalid tax rate index: ${taxRateIndex}`);
|
||||
}
|
||||
|
||||
try {
|
||||
const assets: bigint = stakingAmount;
|
||||
|
|
@ -127,10 +130,9 @@ export function useStake() {
|
|||
|
||||
const { r, s, v } = getSignatureRSV(signature);
|
||||
loading.value = true;
|
||||
// console.log("permitAndSnatch", assets, account.address!, taxRateObj?.index!, positions, deadline, v, r, s);
|
||||
// console.log("permitAndSnatch", assets, account.address!, taxRateOption.index, positions, deadline, v, r, s);
|
||||
|
||||
const taxRateIndex = taxRateObj?.index ?? 0;
|
||||
const hash = await permitAndSnatch(assets, account.address!, taxRateIndex, positions, deadline, v, r, s);
|
||||
const hash = await permitAndSnatch(assets, account.address!, taxRateOption.index, positions, deadline, v, r, s);
|
||||
// console.log("hash", hash);
|
||||
loading.value = false;
|
||||
waiting.value = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue