@@ -21,9 +21,11 @@ import {
2121 MultiTokenCategoryRegistry,
2222 IChainlinkFeedRegistryLike,
2323 PWNStableProduct,
24- PWNWorldStableProduct
24+ PWNInstallmentsProduct
2525} from "pwn/Deployments.sol " ;
2626
27+ import { PWNCrowdsourceLenderVault } from "pwn/periphery/crowdsource/PWNCrowdsourceLenderVault.sol " ;
28+
2729
2830library PWNContractDeployerSalt {
2931
@@ -44,7 +46,10 @@ library PWNContractDeployerSalt {
4446 bytes32 internal constant FIXED_PRODUCT = keccak256 ("PWNFixedProduct " );
4547 bytes32 internal constant UNISWAP_V3_INDIVIDUAL_PRODUCT = keccak256 ("PWNUniswapV3IndividualProduct " );
4648 bytes32 internal constant UNISWAP_V3_SET_PRODUCT = keccak256 ("PWNUniswapV3SetProduct " );
49+ bytes32 internal constant INSTALLMENTS_PRODUCT = keccak256 ("PWNInstallmentsProduct " );
4750
51+ // Others
52+ bytes32 internal constant CROWDSOURCE_LENDER_VAULT = keccak256 ("PWNCrowdsourceLenderVault " );
4853}
4954
5055using GnosisSafeUtils for GnosisSafeLike;
@@ -100,36 +105,75 @@ forge script script/PWN.s.sol:Deploy --sig "deploy()" \
100105 PWNContractDeployerSalt.LOAN,
101106 abi.encodePacked (
102107 type (PWNLoan).creationCode,
103- abi.encode (address (__d.hub), address (__d. loanToken), address (__d.config), address (__d.categoryRegistry), __e.permit2 )
108+ abi.encode (address (__d.loanToken), address (__d.config), address (__d.categoryRegistry))
104109 )
105110 )
106111 );
107112
108- __d.products.stable = PWNStableProduct (
113+ __d.products.installments = PWNInstallmentsProduct (
109114 _deploy (
110- PWNContractDeployerSalt.STABLE_PRODUCT ,
115+ PWNContractDeployerSalt.INSTALLMENTS_PRODUCT ,
111116 abi.encodePacked (
112- type (PWNWorldStableProduct ).creationCode,
113- abi.encode (address (__d.hub), address (__d.revokedNonce), address (__d.utilizedCredit), address (__d.chainlinkFeedRegistry), __e.chainlinkL2SequencerUptimeFeed, __e.weth, 0x17B354dD2595411ff79041f930e491A4Df39A278 , " app_17abe44eaf47c99566f5378aa4e19463 " , " verify-humanness " )
117+ type (PWNInstallmentsProduct ).creationCode,
118+ abi.encode (address (__d.hub), address (__d.revokedNonce), address (__d.utilizedCredit), address (__d.chainlinkFeedRegistry), __e.chainlinkL2SequencerUptimeFeed, __e.weth)
114119 )
115120 )
116121 );
117122
118123 console2.log ("PWNLoan: " , address (__d.loan));
119- console2.log ("PWNStableProduct : " , address (__d.products.stable ));
124+ console2.log ("PWNInstallmentsProduct : " , address (__d.products.installments ));
120125
121- address [] memory addrs = new address [](3 );
126+ address [] memory addrs = new address [](2 );
122127 addrs[0 ] = address (__d.loan);
123- addrs[1 ] = address (__d.products.stable);
124- addrs[2 ] = address (__d.products.stable);
128+ addrs[1 ] = address (__d.products.installments);
125129
126- bytes32 [] memory tags = new bytes32 [](3 );
130+ bytes32 [] memory tags = new bytes32 [](2 );
127131 tags[0 ] = PWNHubTags.ACTIVE_LOAN;
128132 tags[1 ] = PWNHubTags.LOAN_PROPOSAL;
129- tags[2 ] = PWNHubTags.NONCE_MANAGER;
130133
134+ // TODO on what contract this should be called?
131135 console2.logBytes (abi.encodeWithSignature ("setTags(address[],bytes32[],bool) " , addrs, tags, true ));
132136
137+ address [] memory feedIntermediaryDenominations = new address [](1 );
138+ // USDC / USD feed + ETH / USD feed
139+ feedIntermediaryDenominations[0 ] = address (840 ); // USD representation in chainlink
140+ bool [] memory feedInvertFlags = new bool [](2 );
141+ feedInvertFlags[0 ] = false ;
142+ feedInvertFlags[1 ] = true ;
143+
144+ __d.crowdsourceLenderVault = PWNCrowdsourceLenderVault (
145+ _deploy (
146+ PWNContractDeployerSalt.CROWDSOURCE_LENDER_VAULT,
147+ abi.encodePacked (
148+ type (PWNCrowdsourceLenderVault).creationCode,
149+ // TODO Terms terms parameter
150+ abi.encode (
151+ address (__d.loan),
152+ address (__d.products.installments),
153+ address (__e.aave),
154+ "PWNInstallmentsProduct " ,
155+ "PWNInstallmentsProduct " ,
156+ PWNCrowdsourceLenderVault.Terms ({
157+ collateralAddress: address (0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9 ),
158+ creditAddress: address (0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8 ),
159+ feedIntermediaryDenominations: feedIntermediaryDenominations,
160+ feedInvertFlags: feedInvertFlags,
161+ loanToValue: 7500 , // 75%
162+ interestAPR: 1000 , // 10%
163+ postponement: 2592000 , // 30 days in seconds
164+ duration: 63072000 , // 730 days (2 years) in seconds
165+ minCreditAmount: 5000000000 , // 5000 tokens (assuming 6 decimals)
166+ expiration: block .timestamp + 10368000 // 120 days from now
167+ })
168+ )
169+ )
170+ )
171+ );
172+
173+ console2.log ("PWNCrowdsourceLenderVault: " , address (__d.crowdsourceLenderVault));
174+
175+ // TODO anything else to do here?
176+
133177 vm.stopBroadcast ();
134178 }
135179
0 commit comments