11import dotenv from "dotenv" ;
22dotenv . config ( ) ;
3-
43import hre from "hardhat" ;
54import { isAddress , MaxUint256 , getBigInt } from "ethers" ;
6- import { ZERO_BYTES32 } from "../test/helpers" ;
5+ import { toBytes32 } from "../test/helpers" ;
76import {
87 assert , getVerifier , isSet , ProviderSolidity , DomainSolidity , deployProxy ,
98 getProxyCreateAddress ,
109} from "./helpers" ;
1110import {
1211 TestUSDC , SprinterUSDCLPShare , LiquidityHub ,
13- TestLiquidityPool , SprinterLiquidityMining , TestCCTPTokenMessenger , TestCCTPMessageTransmitter ,
14- Rebalancer ,
12+ SprinterLiquidityMining , TestCCTPTokenMessenger , TestCCTPMessageTransmitter ,
13+ Rebalancer , LiquidityPool ,
1514} from "../typechain-types" ;
1615import { networkConfig , Network , Provider , NetworkConfig } from "../network.config" ;
1716
1817async function main ( ) {
18+ // Rework granting admin roles on deployments so that deployer does not have to be admin.
1919 const [ deployer ] = await hre . ethers . getSigners ( ) ;
2020 const admin : string = isAddress ( process . env . ADMIN ) ? process . env . ADMIN : deployer . address ;
21- const rebalanceCaller : string = isAddress ( process . env . REBALANCE_CALLER ) ?
22- process . env . REBALANCE_CALLER : deployer . address ;
2321 const adjuster : string = isAddress ( process . env . ADJUSTER ) ? process . env . ADJUSTER : deployer . address ;
2422 const maxLimit : bigint = MaxUint256 / 10n ** 12n ;
2523 const assetsLimit : bigint = getBigInt ( process . env . ASSETS_LIMIT || maxLimit ) ;
2624
25+ const rebalanceCaller : string = isAddress ( process . env . REBALANCE_CALLER ) ?
26+ process . env . REBALANCE_CALLER : deployer . address ;
27+
28+ const mpcAddress : string = isAddress ( process . env . MPC_ADDRESS ) ?
29+ process . env . MPC_ADDRESS : deployer . address ;
30+ const withdrawProfit : string = isAddress ( process . env . WITHDRAW_PROFIT ) ?
31+ process . env . WITHDRAW_PROFIT : deployer . address ;
32+ const minHealthFactor : bigint = getBigInt ( process . env . MIN_HEALTH_FACTOR || 500n ) * 10n ** 18n / 100n ;
33+ const defaultLTV : bigint = getBigInt ( process . env . DEFAULT_LTV || 20n ) * 10n ** 18n / 100n ;
34+
35+ const LIQUIDITY_ADMIN_ROLE = toBytes32 ( "LIQUIDITY_ADMIN_ROLE" ) ;
36+ const WITHDRAW_PROFIT_ROLE = toBytes32 ( "WITHDRAW_PROFIT_ROLE" ) ;
37+
2738 const verifier = getVerifier ( ) ;
2839
2940 let config : NetworkConfig ;
3041 if ( Object . values ( Network ) . includes ( hre . network . name as Network ) ) {
3142 config = networkConfig [ hre . network . name as Network ] ;
3243 } else {
44+ console . log ( "TEST: Using TEST USDC and CCTP" ) ;
3345 const testUSDC = ( await verifier . deploy ( "TestUSDC" , deployer ) ) as TestUSDC ;
3446 const cctpTokenMessenger = ( await verifier . deploy ( "TestCCTPTokenMessenger" , deployer ) ) as TestCCTPTokenMessenger ;
3547 const cctpMessageTransmitter = (
@@ -51,8 +63,27 @@ async function main() {
5163 } ;
5264 }
5365
54- console . log ( "TEST: Using TEST Liquidity Pool" ) ;
55- const liquidityPool = ( await verifier . deploy ( "TestLiquidityPool" , deployer , { } , config . USDC ) ) as TestLiquidityPool ;
66+ let liquidityPool : LiquidityPool ;
67+ if ( config . Aave ) {
68+ const { target, targetAdmin : liquidityPoolAdmin } = await deployProxy < LiquidityPool > (
69+ verifier . deploy ,
70+ "LiquidityPool" ,
71+ deployer ,
72+ admin ,
73+ [ config . USDC , config . Aave ] ,
74+ [
75+ admin ,
76+ minHealthFactor ,
77+ defaultLTV ,
78+ mpcAddress ,
79+ ] ,
80+ ) ;
81+ liquidityPool = target ;
82+ console . log ( `LiquidityPoolProxyAdmin: ${ liquidityPoolAdmin . target } ` ) ;
83+ } else {
84+ console . log ( "TEST: Using TEST Liquidity Pool" ) ;
85+ liquidityPool = ( await verifier . deploy ( "TestLiquidityPool" , deployer , { } , [ config . USDC ] ) ) as LiquidityPool ;
86+ }
5687
5788 const rebalancerVersion = config . IsTest ? "TestRebalancer" : "Rebalancer" ;
5889
@@ -70,10 +101,8 @@ async function main() {
70101 ] ,
71102 ) ;
72103
73- const DEFAULT_ADMIN_ROLE = ZERO_BYTES32 ;
74-
75- console . log ( "TEST: Using default admin role for Rebalancer on Pool" ) ;
76- await liquidityPool . grantRole ( DEFAULT_ADMIN_ROLE , rebalancer ) ;
104+ await liquidityPool . grantRole ( LIQUIDITY_ADMIN_ROLE , rebalancer ) ;
105+ await liquidityPool . grantRole ( WITHDRAW_PROFIT_ROLE , withdrawProfit ) ;
77106
78107 if ( config . IsHub ) {
79108 const tiers = [ ] ;
@@ -94,9 +123,13 @@ async function main() {
94123 const startingNonce = await deployer . getNonce ( ) ;
95124
96125 const liquidityHubAddress = await getProxyCreateAddress ( deployer , startingNonce + 1 ) ;
97- const lpToken = (
98- await verifier . deploy ( "SprinterUSDCLPShare" , deployer , { nonce : startingNonce + 0 } , liquidityHubAddress )
99- ) as SprinterUSDCLPShare ;
126+ const lpToken = ( await verifier . deploy (
127+ "SprinterUSDCLPShare" ,
128+ deployer ,
129+ { } ,
130+ [ liquidityHubAddress ] ,
131+ "contracts/SprinterUSDCLPShare.sol:SprinterUSDCLPShare"
132+ ) ) as SprinterUSDCLPShare ;
100133
101134 const { target : liquidityHub , targetAdmin : liquidityHubAdmin } = await deployProxy < LiquidityHub > (
102135 verifier . deploy ,
@@ -109,13 +142,11 @@ async function main() {
109142
110143 assert ( liquidityHubAddress == liquidityHub . target , "LiquidityHub address mismatch" ) ;
111144 const liquidityMining = (
112- await verifier . deploy ( "SprinterLiquidityMining" , deployer , { } , admin , liquidityHub , tiers )
145+ await verifier . deploy ( "SprinterLiquidityMining" , deployer , { } , [ admin , liquidityHub , tiers ] )
113146 ) as SprinterLiquidityMining ;
114147
115- console . log ( "TEST: Using default admin role for Hub on Pool" ) ;
116- await liquidityPool . grantRole ( DEFAULT_ADMIN_ROLE , liquidityHub ) ;
148+ await liquidityPool . grantRole ( LIQUIDITY_ADMIN_ROLE , liquidityHub ) ;
117149
118- console . log ( ) ;
119150 console . log ( `SprinterUSDCLPShare: ${ lpToken . target } ` ) ;
120151 console . log ( `LiquidityHub: ${ liquidityHub . target } ` ) ;
121152 console . log ( `LiquidityHubProxyAdmin: ${ liquidityHubAdmin . target } ` ) ;
0 commit comments