Skip to content

Commit e0766eb

Browse files
committed
fix(shell): use bigint to calculate vesting periods amount correctly
1 parent 7edbefa commit e0766eb

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

libs/shell/services-pages/src/lib/create-vesting-account-page/create-vesting-account-page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ function CreateVestingAccountForm() {
343343
placeholder="Deposit amount in ISLM"
344344
value={amount.toString()}
345345
onChange={(value) => {
346-
const nextValue = !Number.isNaN(Number.parseInt(value))
347-
? Number.parseInt(value)
346+
const nextValue = !Number.isNaN(Number.parseFloat(value))
347+
? Number.parseFloat(value)
348348
: 0;
349349
setAmount(nextValue);
350350
}}
@@ -488,7 +488,7 @@ function Input({
488488
required
489489
id={id}
490490
name={id}
491-
value={value}
491+
defaultValue={value}
492492
onChange={(event) => {
493493
onChange(event.currentTarget.value);
494494
}}

libs/shell/services-pages/src/lib/use-vesting-actions/use-vesting-actions.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ export function useVestingActions() {
8080
const periods = vestingInDays;
8181
const denom = 'aISLM';
8282
const lockupPeriods = [];
83-
let restAmount = amount;
84-
let unlockAmount = Math.floor(amount / periods);
83+
const aislmAmount = BigInt(amount * 10 ** 18);
84+
let restAmount = aislmAmount;
85+
let unlockAmount = aislmAmount / BigInt(periods);
8586
let length: number = cliff;
8687

8788
for (let i = 0; i < periods; i++) {
@@ -91,7 +92,7 @@ export function useVestingActions() {
9192

9293
const unlockCoins = {
9394
denom: denom,
94-
amount: BigInt(unlockAmount * 10 ** 18).toString(),
95+
amount: unlockAmount.toString(),
9596
};
9697

9798
const period = {

0 commit comments

Comments
 (0)