Skip to content

Commit a59fe4b

Browse files
committed
feat(scripts): add withdrawal claim check function and usage instructions to Firelight script
1 parent ea86dbf commit a59fe4b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/developer-hub-javascript/firelight-claim.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*
44
* This script claims pending withdrawals from the FirelightVault.
55
* Withdrawals must be requested first using withdraw/redeem, then claimed after the period ends.
6+
*
7+
* Usage:
8+
* yarn hardhat run scripts/firelight/claim.ts --network coston2
69
*/
710

811
import { ethers } from "hardhat";
@@ -76,6 +79,25 @@ async function getClaimableAssets(
7679
}
7780
}
7881

82+
/**
83+
* Checks if a withdrawal for a specific period has been claimed.
84+
*
85+
* @param vault - The FirelightVault instance
86+
* @param period - The period number to check
87+
* @param account - The account address to check
88+
* @returns true if the withdrawal has been claimed (no pending withdrawals), false if still pending
89+
*/
90+
export async function isWithdrawClaimed(
91+
vault: IFirelightVaultInstance,
92+
period: bigint,
93+
account: string,
94+
): Promise<boolean> {
95+
const withdrawals = bnToBigInt(
96+
await vault.withdrawalsOf(period.toString(), account),
97+
);
98+
return withdrawals === 0n;
99+
}
100+
79101
async function findClaimablePeriods(
80102
vault: IFirelightVaultInstance,
81103
account: string,

0 commit comments

Comments
 (0)