11import dotenv from "dotenv" ;
22dotenv . config ( ) ;
33import hre from "hardhat" ;
4- import { MaxUint256 , isAddress } from "ethers" ;
4+ import { MaxUint256 } from "ethers" ;
55import { toBytes32 , resolveProxyXAddress , resolveXAddress , getContractAt , resolveXAddresses } from "../test/helpers" ;
66import {
77 getVerifier , deployProxyX , getHardhatNetworkConfig , getNetworkConfig , percentsToBps ,
@@ -10,18 +10,21 @@ import {
1010import {
1111 assert , isSet , ProviderSolidity , DomainSolidity , DEFAULT_ADMIN_ROLE , ZERO_ADDRESS ,
1212 sameAddress ,
13+ assertAddress ,
1314} from "./common" ;
1415import {
1516 SprinterUSDCLPShare , LiquidityHub , SprinterLiquidityMining ,
1617 Rebalancer , Repayer , LiquidityPool , LiquidityPoolAave , LiquidityPoolStablecoin , LiquidityPoolAaveLongTerm ,
17- ProxyAdmin ,
18+ ProxyAdmin , PublicLiquidityPool , ERC4626Adapter ,
1819} from "../typechain-types" ;
1920import {
2021 Network , Provider , NetworkConfig ,
2122 LiquidityPoolAaveUSDCVersions ,
2223 LiquidityPoolAaveUSDCLongTermVersions ,
2324 LiquidityPoolUSDCVersions ,
2425 LiquidityPoolUSDCStablecoinVersions ,
26+ LiquidityPoolPublicUSDCVersions ,
27+ ERC4626AdapterUSDCVersions ,
2528} from "../network.config" ;
2629
2730export async function main ( ) {
@@ -32,6 +35,7 @@ export async function main() {
3235 const PAUSER_ROLE = toBytes32 ( "PAUSER_ROLE" ) ;
3336 const BORROW_LONG_TERM_ROLE = toBytes32 ( "BORROW_LONG_TERM_ROLE" ) ;
3437 const REPAYER_ROLE = toBytes32 ( "REPAYER_ROLE" ) ;
38+ const FEE_SETTER_ROLE = toBytes32 ( "FEE_SETTER_ROLE" ) ;
3539
3640 assert ( isSet ( process . env . DEPLOY_ID ) , "DEPLOY_ID must be set" ) ;
3741 const verifier = getVerifier ( process . env . DEPLOY_ID ) ;
@@ -47,15 +51,15 @@ export async function main() {
4751
4852 assert ( config . AavePool ! || config . AavePoolLongTerm ! || config . USDCPool ! || config . USDCStablecoinPool ! ,
4953 "At least one pool should be present." ) ;
50- assert ( isAddress ( config . USDC ) , "USDC must be an address" ) ;
51- assert ( isAddress ( config . Admin ) , "Admin must be an address" ) ;
52- assert ( isAddress ( config . WithdrawProfit ) , "WithdrawProfit must be an address" ) ;
53- assert ( isAddress ( config . Pauser ) , "Pauser must be an address" ) ;
54- assert ( isAddress ( config . RebalanceCaller ) , "RebalanceCaller must be an address" ) ;
55- assert ( isAddress ( config . RepayerCaller ) , "RepayerCaller must be an address" ) ;
56- assert ( isAddress ( config . MpcAddress ) , "MpcAddress must be an address" ) ;
57- assert ( isAddress ( config . SignerAddress ) , "SignerAddress must be an address" ) ;
58- assert ( isAddress ( config . WrappedNativeToken ) , "WrappedNativeToken must be an address" ) ;
54+ assertAddress ( config . USDC , "USDC must be an address" ) ;
55+ assertAddress ( config . Admin , "Admin must be an address" ) ;
56+ assertAddress ( config . WithdrawProfit , "WithdrawProfit must be an address" ) ;
57+ assertAddress ( config . Pauser , "Pauser must be an address" ) ;
58+ assertAddress ( config . RebalanceCaller , "RebalanceCaller must be an address" ) ;
59+ assertAddress ( config . RepayerCaller , "RepayerCaller must be an address" ) ;
60+ assertAddress ( config . MpcAddress , "MpcAddress must be an address" ) ;
61+ assertAddress ( config . SignerAddress , "SignerAddress must be an address" ) ;
62+ assertAddress ( config . WrappedNativeToken , "WrappedNativeToken must be an address" ) ;
5963
6064 if ( ! config . CCTP ) {
6165 config . CCTP = {
@@ -265,6 +269,55 @@ export async function main() {
265269 }
266270 }
267271
272+ let usdcPublicPool : PublicLiquidityPool ;
273+ if ( config . USDCPublicPool ) {
274+ assertAddress ( config . USDCPublicPool . FeeSetter , "FeeSetter must be an address" ) ;
275+ const id = LiquidityPoolPublicUSDCVersions . at ( - 1 ) ;
276+ console . log ( "Deploying USDC Public Liquidity Pool" ) ;
277+ usdcPublicPool = ( await verifier . deployX (
278+ "PublicLiquidityPool" ,
279+ deployer ,
280+ { } ,
281+ [
282+ config . USDC ,
283+ deployer ,
284+ config . MpcAddress ,
285+ config . WrappedNativeToken ,
286+ config . SignerAddress ,
287+ config . USDCPublicPool . Name ,
288+ config . USDCPublicPool . Symbol ,
289+ config . USDCPublicPool . ProtocolFeeRate * 10000 / 100 ,
290+ ] ,
291+ id
292+ ) ) as PublicLiquidityPool ;
293+ console . log ( `${ id } : ${ usdcPublicPool . target } ` ) ;
294+ }
295+
296+ let erc4626AdapterUSDC : ERC4626Adapter ;
297+ if ( config . ERC4626AdapterUSDCTargetVault ) {
298+ const id = ERC4626AdapterUSDCVersions . at ( - 1 ) ;
299+ const targetVault = await resolveXAddress ( config . ERC4626AdapterUSDCTargetVault ) ;
300+ console . log ( `Target Vault: ${ targetVault } ` ) ;
301+
302+ console . log ( "Deploying ERC4626 Adapter USDC" ) ;
303+ erc4626AdapterUSDC = ( await verifier . deployX (
304+ "ERC4626Adapter" ,
305+ deployer ,
306+ { } ,
307+ [
308+ config . USDC ,
309+ targetVault ,
310+ deployer ,
311+ ] ,
312+ id
313+ ) ) as ERC4626Adapter ;
314+ console . log ( `${ id } : ${ erc4626AdapterUSDC . target } ` ) ;
315+
316+ rebalancerRoutes . Pools . push ( await erc4626AdapterUSDC . getAddress ( ) ) ;
317+ rebalancerRoutes . Domains . push ( network ) ;
318+ rebalancerRoutes . Providers . push ( Provider . LOCAL ) ;
319+ }
320+
268321 assert ( mainPool , "Main pool is not defined" ) ;
269322 const rebalancerVersion = config . IsTest ? "TestRebalancer" : "Rebalancer" ;
270323
@@ -313,6 +366,18 @@ export async function main() {
313366 await usdcStablecoinPool ! . grantRole ( PAUSER_ROLE , config . Pauser ) ;
314367 }
315368
369+ if ( config . USDCPublicPool ) {
370+ await usdcPublicPool ! . grantRole ( WITHDRAW_PROFIT_ROLE , config . WithdrawProfit ) ;
371+ await usdcPublicPool ! . grantRole ( PAUSER_ROLE , config . Pauser ) ;
372+ await usdcPublicPool ! . grantRole ( FEE_SETTER_ROLE , config . USDCPublicPool . FeeSetter ) ;
373+ }
374+
375+ if ( config . ERC4626AdapterUSDCTargetVault ) {
376+ await erc4626AdapterUSDC ! . grantRole ( LIQUIDITY_ADMIN_ROLE , rebalancer ) ;
377+ await erc4626AdapterUSDC ! . grantRole ( WITHDRAW_PROFIT_ROLE , config . WithdrawProfit ) ;
378+ await erc4626AdapterUSDC ! . grantRole ( PAUSER_ROLE , config . Pauser ) ;
379+ }
380+
316381 const repayerVersion = config . IsTest ? "TestRepayer" : "Repayer" ;
317382
318383 repayerRoutes . Pools = await resolveXAddresses ( repayerRoutes . Pools || [ ] , false ) ;
@@ -432,6 +497,16 @@ export async function main() {
432497 await usdcStablecoinPool ! . grantRole ( DEFAULT_ADMIN_ROLE , config . Admin ) ;
433498 await usdcStablecoinPool ! . renounceRole ( DEFAULT_ADMIN_ROLE , deployer ) ;
434499 }
500+
501+ if ( config . USDCPublicPool ) {
502+ await usdcPublicPool ! . grantRole ( DEFAULT_ADMIN_ROLE , config . Admin ) ;
503+ await usdcPublicPool ! . renounceRole ( DEFAULT_ADMIN_ROLE , deployer ) ;
504+ }
505+
506+ if ( config . ERC4626AdapterUSDCTargetVault ) {
507+ await erc4626AdapterUSDC ! . grantRole ( DEFAULT_ADMIN_ROLE , config . Admin ) ;
508+ await erc4626AdapterUSDC ! . renounceRole ( DEFAULT_ADMIN_ROLE , deployer ) ;
509+ }
435510 }
436511
437512 let multicall : string ;
0 commit comments