Skip to content

Commit

Permalink
fix test to include transfer_fee calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
urieltan committed Oct 23, 2024
1 parent b7c06d9 commit 17cd1b1
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions tests/locker_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,27 +587,31 @@ export async function cancelVestingPlan(
.signers([signer])
.rpc();

const feeConfig = getTransferFeeConfig(
await getMint(
program.provider.connection,
escrowState.tokenMint,
undefined,
TOKEN_2022_PROGRAM_ID
)
);
const epoch = BigInt(await getCurrentEpoch(program.provider.connection));
const creator_fee = feeConfig
? Number(
calculateEpochFee(
feeConfig,
epoch,
BigInt(total_amount - claimable_amount)
)
let creator_fee = 0;
let claimer_fee = 0;
if (tokenProgram == TOKEN_2022_PROGRAM_ID) {
const feeConfig = getTransferFeeConfig(
await getMint(
program.provider.connection,
escrowState.tokenMint,
undefined,
TOKEN_2022_PROGRAM_ID
)
: 0;
const claimer_fee = feeConfig
? Number(calculateEpochFee(feeConfig, epoch, BigInt(claimable_amount)))
: 0;
);
const epoch = BigInt(await getCurrentEpoch(program.provider.connection));
creator_fee = feeConfig
? Number(
calculateEpochFee(
feeConfig,
epoch,
BigInt(total_amount - claimable_amount)
)
)
: 0;
claimer_fee = feeConfig
? Number(calculateEpochFee(feeConfig, epoch, BigInt(claimable_amount)))
: 0;
}

if (isAssertion) {
const escrowState = await program.account.vestingEscrow.fetch(escrow);
Expand Down

0 comments on commit 17cd1b1

Please sign in to comment.