66 */
77
88import { ethers } from "hardhat" ;
9- import { IFirelightVaultInstance } from "../../typechain-types/contracts/firelight/IFirelightVault" ;
9+ import type { IFirelightVaultInstance } from "../../typechain-types/contracts/firelight/IFirelightVault" ;
10+ import type { ERC20Instance } from "../../typechain-types/@openzeppelin/contracts/token/ERC20/ERC20" ;
1011import { bnToBigInt } from "../utils/core" ;
1112
1213export const FIRELIGHT_VAULT_ADDRESS = "0x91Bfe6A68aB035DFebb6A770FFfB748C03C0E40B" ;
@@ -26,17 +27,17 @@ async function getAccount() {
2627async function getVaultAndAsset ( ) {
2728 const vault = await IFirelightVault . at ( FIRELIGHT_VAULT_ADDRESS ) as IFirelightVaultInstance ;
2829 const assetAddress = await vault . asset ( ) ;
29- const assetToken = await IERC20 . at ( assetAddress ) ;
30+ const assetToken = await IERC20 . at ( assetAddress ) as ERC20Instance ;
3031 return { vault, assetAddress, assetToken } ;
3132}
3233
33- async function getAssetInfo ( assetToken : any ) {
34+ async function getAssetInfo ( assetToken : ERC20Instance ) {
3435 const symbol = await assetToken . symbol ( ) ;
35- const assetDecimals = await assetToken . decimals ( ) ;
36+ const assetDecimals = ( await assetToken . decimals ( ) ) . toNumber ( ) ;
3637 return { symbol, assetDecimals } ;
3738}
3839
39- function logDepositInfo ( account : string , assetAddress : string , symbol : string , assetDecimals : any , amount : bigint ) {
40+ function logDepositInfo ( account : string , assetAddress : string , symbol : string , assetDecimals : number , amount : bigint ) {
4041 console . log ( "=== Deposit (ERC-4626) ===" ) ;
4142 console . log ( "Sender:" , account ) ;
4243 console . log ( "Vault:" , FIRELIGHT_VAULT_ADDRESS ) ;
@@ -53,13 +54,13 @@ async function validateDeposit(vault: IFirelightVaultInstance, account: string,
5354 }
5455}
5556
56- async function approveTokens ( assetToken : any , vault : any , amount : bigint , account : string ) {
57- const approveTx = await assetToken . approve ( vault . address , amount , { from : account } ) ;
57+ async function approveTokens ( assetToken : ERC20Instance , vault : IFirelightVaultInstance , amount : bigint , account : string ) {
58+ const approveTx = await assetToken . approve ( vault . address , amount . toString ( ) , { from : account } ) ;
5859 console . log ( "Approve tx:" , approveTx . tx ) ;
5960}
6061
61- async function executeDeposit ( vault : any , amount : bigint , account : string ) {
62- const depositTx = await vault . deposit ( amount , account , { from : account } ) ;
62+ async function executeDeposit ( vault : IFirelightVaultInstance , amount : bigint , account : string ) {
63+ const depositTx = await vault . deposit ( amount . toString ( ) , account , { from : account } ) ;
6364 console . log ( "Deposit tx:" , depositTx . tx ) ;
6465}
6566
@@ -74,7 +75,7 @@ async function main() {
7475 const { symbol, assetDecimals } = await getAssetInfo ( assetToken ) ;
7576
7677 // 4. Calculate the deposit amount
77- const depositAmount = BigInt ( tokensToDeposit * ( 10 ** Number ( assetDecimals ) ) ) ;
78+ const depositAmount = BigInt ( tokensToDeposit * ( 10 ** assetDecimals ) ) ;
7879
7980 // 5. Log deposit info
8081 logDepositInfo ( account , assetAddress , symbol , assetDecimals , depositAmount ) ;
0 commit comments