1- import { ContractInfo , Contracts , GovV3 , PoolInfo } from './types.js' ;
1+ import { ContractInfo , Contracts } from './types.js' ;
22import actionsConfig from '../statics/actionsConfig.json' assert { type : 'json' } ;
33
44export type Decentralization = {
@@ -11,29 +11,35 @@ export enum Controller {
1111 GOV_V3 = 'Governance' ,
1212 MULTI_SIG = 'Multi-sig' ,
1313 EOA = 'External Contract' ,
14+ PPC_MULTI_SIG = 'PPC Multi-sig' ,
1415}
1516
16- export const getActionExecutors = ( poolInfo : Contracts , govInfo : Contracts ) => {
17+ export const getActionExecutors = ( poolInfo : Contracts , govInfo : Contracts , isWhiteLabel : boolean ) => {
1718 const actionsObject : Record < string , Set < string > > = { } ;
1819 Object . keys ( actionsConfig ) . forEach ( ( action ) => {
1920 actionsObject [ action ] = new Set < string > ( ) ;
20- if (
21- action === 'updateReserveBorrowSettings' ||
22- action === 'configureCollateral' ||
23- action === 'updateReserveSettings' ||
24- action === 'reserveUpgradeability'
25- ) {
26- actionsObject [ action ] . add ( Controller . GOV_V3 ) ;
27- } else {
28- for ( let contractName of Object . keys ( poolInfo ) ) {
29- const contract = poolInfo [ contractName ] ;
30- // search all modifiers
31- contract . modifiers . forEach ( ( modifier ) => {
32- const hasFunction = modifier . functions . some ( ( functionName : string ) =>
33- // @ts -ignore
34- actionsConfig [ action ] . includes ( functionName ) ,
35- ) ;
36- if ( hasFunction ) {
21+ for ( let contractName of Object . keys ( poolInfo ) ) {
22+ const contract = poolInfo [ contractName ] ;
23+ // search all modifiers
24+ contract . modifiers . forEach ( ( modifier ) => {
25+ const hasFunction = modifier . functions . some ( ( functionName : string ) =>
26+ // @ts -ignore
27+ actionsConfig [ action ] . includes ( functionName ) ,
28+ ) ;
29+ if ( hasFunction ) {
30+ if (
31+ action === 'updateReserveBorrowSettings' ||
32+ action === 'configureCollateral' ||
33+ action === 'updateReserveSettings' ||
34+ action === 'reserveUpgradeability' ||
35+ action === 'configureProtocolFees'
36+ ) {
37+ if ( isWhiteLabel ) {
38+ actionsObject [ action ] . add ( Controller . PPC_MULTI_SIG ) ;
39+ } else {
40+ actionsObject [ action ] . add ( Controller . GOV_V3 ) ;
41+ }
42+ } else {
3743 modifier . addresses . map ( ( addressInfo ) => {
3844 if ( addressInfo . owners . length > 0 ) {
3945 actionsObject [ action ] . add ( Controller . MULTI_SIG ) ;
@@ -42,6 +48,7 @@ export const getActionExecutors = (poolInfo: Contracts, govInfo: Contracts) => {
4248 addressInfo . address ,
4349 poolInfo ,
4450 govInfo ,
51+ isWhiteLabel ,
4552 ) ;
4653 if ( ownedInfo . owned ) {
4754 actionsObject [ action ] . add ( ownedInfo . ownedBy ) ;
@@ -51,8 +58,8 @@ export const getActionExecutors = (poolInfo: Contracts, govInfo: Contracts) => {
5158 }
5259 } ) ;
5360 }
54- } ) ;
55- }
61+ }
62+ } ) ;
5663 }
5764 } ) ;
5865
@@ -63,6 +70,7 @@ export const getLevelOfDecentralization = (
6370 contract : ContractInfo ,
6471 poolInfo : Contracts ,
6572 govInfo : Contracts ,
73+ isWhiteLabel : boolean ,
6674) : Decentralization => {
6775 let upgradeable = false ;
6876 let ownedBy = Controller . NONE ;
@@ -74,13 +82,14 @@ export const getLevelOfDecentralization = (
7482 contract . proxyAdmin ,
7583 poolInfo ,
7684 govInfo ,
85+ isWhiteLabel ,
7786 ) ;
7887
7988 if ( proxyOwnership . owned ) {
8089 ownedBy = proxyOwnership . ownedBy ;
8190 }
8291 } else {
83- let ownership = isOwnedAndByWho ( contract . address , poolInfo , govInfo ) ;
92+ let ownership = isOwnedAndByWho ( contract . address , poolInfo , govInfo , isWhiteLabel ) ;
8493 if ( ownership . owned ) {
8594 ownedBy = ownership . ownedBy ;
8695 }
@@ -137,13 +146,14 @@ const isOwnedAndByWho = (
137146 address : string ,
138147 poolInfo : Contracts ,
139148 govInfo : Contracts ,
149+ isWhiteLabel : boolean ,
140150) : { owned : boolean ; ownedBy : Controller } => {
141151 let ownerInfo = { owned : false , ownedBy : Controller . EOA } ;
142152 for ( let contractName of Object . keys ( poolInfo ) ) {
143153 const contract = poolInfo [ contractName ] ;
144154 if ( contract . address ?. toLowerCase ( ) === address . toLowerCase ( ) ) {
145155 if ( contract . proxyAdmin ) {
146- ownerInfo = isOwnedAndByWho ( contract . proxyAdmin , poolInfo , govInfo ) ;
156+ ownerInfo = isOwnedAndByWho ( contract . proxyAdmin , poolInfo , govInfo , isWhiteLabel ) ;
147157 } else {
148158 contract . modifiers . forEach ( ( modifierInfo ) => {
149159 if ( modifierInfo . modifier === 'onlyOwner' ) {
@@ -156,7 +166,11 @@ const isOwnedAndByWho = (
156166 modifierInfo . addresses [ 0 ] . address ,
157167 ) ;
158168 if ( ownedByGov ) {
159- ownerInfo = { owned : true , ownedBy : Controller . GOV_V3 } ;
169+ if ( isWhiteLabel ) {
170+ ownerInfo = { owned : true , ownedBy : Controller . PPC_MULTI_SIG } ;
171+ } else {
172+ ownerInfo = { owned : true , ownedBy : Controller . GOV_V3 } ;
173+ }
160174 } else {
161175 ownerInfo = { owned : true , ownedBy : Controller . EOA } ;
162176 }
@@ -174,13 +188,14 @@ const isAdministeredAndByWho = (
174188 address : string ,
175189 poolInfo : Contracts ,
176190 govInfo : Contracts ,
191+ isWhiteLabel : boolean ,
177192) : { owned : boolean ; ownedBy : Controller } => {
178193 let ownerInfo = { owned : false , ownedBy : Controller . EOA } ;
179194 for ( let contractName of Object . keys ( poolInfo ) ) {
180195 const contract = poolInfo [ contractName ] ;
181196 if ( contract . address ?. toLowerCase ( ) === address . toLowerCase ( ) ) {
182197 if ( contract . proxyAdmin ) {
183- ownerInfo = isOwnedAndByWho ( contract . proxyAdmin , poolInfo , govInfo ) ;
198+ ownerInfo = isOwnedAndByWho ( contract . proxyAdmin , poolInfo , govInfo , isWhiteLabel ) ;
184199 } else {
185200 contract . modifiers . forEach ( ( modifierInfo ) => {
186201 if (
@@ -190,6 +205,7 @@ const isAdministeredAndByWho = (
190205 contractName !== 'GhoStewardV2' ) ||
191206 modifierInfo . modifier === 'onlyEmergencyAdmin' ||
192207 modifierInfo . modifier === 'onlyDefaultAdmin'
208+ // modifierInfo.modifier === 'onlyPayloadsManager'
193209 ) {
194210 if ( modifierInfo . addresses [ 0 ] . owners . length > 0 ) {
195211 ownerInfo = { owned : true , ownedBy : Controller . MULTI_SIG } ;
@@ -200,7 +216,11 @@ const isAdministeredAndByWho = (
200216 modifierInfo . addresses [ 0 ] . address ,
201217 ) ;
202218 if ( ownedByGov ) {
203- ownerInfo = { owned : true , ownedBy : Controller . GOV_V3 } ;
219+ if ( isWhiteLabel ) {
220+ ownerInfo = { owned : true , ownedBy : Controller . PPC_MULTI_SIG } ;
221+ } else {
222+ ownerInfo = { owned : true , ownedBy : Controller . GOV_V3 } ;
223+ }
204224 } else {
205225 ownerInfo = { owned : true , ownedBy : Controller . EOA } ;
206226 }
0 commit comments