Hello, I want to write a contract for our Defi project using the UUPS proxies, but there are a few points that I can't understand. I would be glad if you could help.
1- I will make changes in the contracts according to the decisions taken in the DAO for the Defi protocol. Do you think UUPS proxies are the right choice for this?
2- Should the functions required for the Defi protocol be written in the proxy contract or the implementation contract?
3- Is it possible to revert to the previous version after an incorrect update?
Also, could you suggest any projects using UUPS proxies that we can use as a guide? I run through the Openzeppelin tutorial (Deploying More Efficient Upgradeable Contracts), but if there is a more comprehensive example than that, it would be great.
Proxy Contract
contract Treasury is Initializable,UUPSUpgradeable, OwnableUpgradeable {
function initialize() public initializer {
__Ownable_init(); //constructor kullanilmadigi icin ownablein baslamasi lazim
}
function _authorizeUpgrade(address newImplementation) internal override onlyOwner{
}
uint protocolFee;
function setProtocolFee(uint _protocolFee) public virtual returns(uint){
protocolFee = _protocolFee;
return _protocolFee;
}
function getProtocolFee() public view virtual returns(uint){
return protocolFee;
}
}
Implementation
contract TreasuryV2 is Treasury {
function setProtocolFee(uint _protocolFeeV2) public override returns(uint){
protocolFee = _protocolFeeV2;
return protocolFee;
}
function getProtocolFee() public override view returns(uint){
return protocolFee;
}
function version() public pure override returns (string memory) {
return "v2!";
}
}