import { HardhatRuntimeEnvironment } from "hardhat/types" ; import { DeployFunction } from "hardhat-deploy/types" ; const func = async function ( hre ) { const { deployments , getNamedAccounts } = hre ; const { execute , deploy , get , getOrNull , log , read , save } = deployments ; const { deployer } = await getNamedAccounts ( ) ; const saddleTBTCMetaPool = await getOrNull ( "SaddleTBTCMetaPool" ) ; if ( saddleTBTCMetaPool ) { log ( `reusing "SaddleTBTCMetaPool" at ${ saddleTBTCMetaPool . address }` ) ; } else { const TOKEN_ADDRESSES = [ ( await get ( "TBTCv2" ) ) . address , ( await get ( "SaddleBTCPoolV2LPToken" ) ) . address , ] ; const TOKEN_DECIMALS = [ 18 , 18 ] ; const LP_TOKEN_NAME = "Saddle tBTCv2/saddleWRenSBTC" ; const LP_TOKEN_SYMBOL = "saddletBTC" ; const INITIAL_A = 100 ; const SWAP_FEE = 4e6 ; const ADMIN_FEE = 0 ; const receipt = await execute ( "SwapDeployer" , { from : deployer , log : true , } , "deployMetaSwap" , ( await get ( "SaddleSUSDMetaPool" ) ) . address , TOKEN_ADDRESSES , TOKEN_DECIMALS , LP_TOKEN_NAME , LP_TOKEN_SYMBOL , INITIAL_A , SWAP_FEE , ADMIN_FEE , ( await get ( "LPToken" ) ) . address , ( await get ( "SaddleBTCPoolV2" ) ) . address ) ; const newPoolEvent = receipt ?. events ?. find ( ( e ) => e [ "event" ] == "NewSwapPool" ) ; const btcSwapAddress = newPoolEvent [ "args" ] [ "swapAddress" ] ; log ( `deployed TBTC meta pool (targeting "MetaSwap") at ${ btcSwapAddress }` ) ; await save ( "SaddleTBTCMetaPool" , { abi : ( await get ( "SaddleSUSDMetaPool" ) ) . abi , address : btcSwapAddress , } ) ; } const lpTokenAddress = ( await read ( "SaddleTBTCMetaPool" , "swapStorage" ) ) . lpToken ; log ( `Saddle tBTC v2 MetaSwap LP Token at ${ lpTokenAddress }` ) ; await save ( "SaddleTBTCMetaPoolLPToken" , { abi : ( await get ( "LPToken" ) ) . abi , address : lpTokenAddress , } ) ; } ; export default func ; func . tags = [ "TBTCMetaPool" ] ; func . dependencies = [ "LPToken" , "USDMetaPool" , "TBTCMetaPoolTokens" , "BTCPoolV2" , ] ;