We have a contract that adheres to the ERC-3156 standard, which provides flash loan functionality. We intend to deploy this contract multiple times, and in certain cases, flash loan capabilities are not required.
One possible solution is to implement a paused
flag. When set to true, this flag would deactivate the flashLoan
function. But this approach seems inefficient, as it retains the unnecessary ERC-3156 features in contracts that will never use them.
Is there a more elegant method for selectively including logic in a contract during its construction?
This is what I have in mind:
contract Foo {
constructor(bool flag) {
if (flag) {
// include ERC-3156 logic
} else {
// do not include ERC-3156 logic
}
}
}
Notes:
- I don't want two different contract names
- By "not including", I mean for the
flashLoan
function to not exist - I am deploying the contracts with Foundry