Skip to content

Commit

Permalink
Merge pull request #11 from open-dollar/delegatable-colateral-join
Browse files Browse the repository at this point in the history
Delegatable colateral join
  • Loading branch information
MrDeadCe11 authored Jul 18, 2024
2 parents 5a1bfe8 + f61b491 commit 8d3a063
Show file tree
Hide file tree
Showing 20 changed files with 553 additions and 91 deletions.
43 changes: 43 additions & 0 deletions gov-input/mainnet/new-AddGRT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"chainid": "42161",
"description": "add GRT as a collateral type",
"network": "mainnet",
"newCollateralAddress": "0x9623063377ad1b27544c965ccd7342f7ea7e88c7",
"newCollateralType": "GRT",
"proposalType": "AddCollateral",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "TBD",
"collateralDebtFloor": "TBD"
},
"TaxCollectorCollateralParams": {
"stabilityFee": "TBD"
},
"TaxReceiver": {
"receiver": "",
"canTakeBackTax": false,
"taxPercentage": ""
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "",
"liquidationPenalty": "TBD",
"liquidationQuantity": "TBD"
},
"OracleRelayerCollateralParams": {
"delayedOracle": "TBD",
"safetyCRatio": "TBD",
"liquidationCRatio": "TBD"
},
"CollateralAuctionHouseParams": {
"maxDiscount": "TBD",
"minimumBid": "TBD",
"minDiscount": "TBD",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
43 changes: 43 additions & 0 deletions gov-input/mainnet/new-AddLINK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"chainid": "42161",
"description": "add LINK as a collateral type",
"network": "mainnet",
"newCollateralAddress": "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4",
"newCollateralType": "LINK",
"proposalType": "AddCollateral",
"ProtocolToken_Address": "",
"ODGovernor_Address": "",
"SAFEEngine_Address": "",
"OracleRelayer_Address": "",
"LiquidationEngine_Address": "",
"TaxCollector_Address": "",
"GlobalSettlement_Address": "",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "TBD",
"collateralDebtFloor": "TBD"
},
"TaxCollectorCollateralParams": {
"stabilityFee": "TBD"
},
"TaxReceiver": {
"receiver": "",
"canTakeBackTax": false,
"taxPercentage": ""
},
"LiquidationEngineCollateralParams": {
"newCAHChild": "",
"liquidationPenalty": "TBD",
"liquidationQuantity": "TBD"
},
"OracleRelayerCollateralParams": {
"delayedOracle": "TBD",
"safetyCRatio": "TBD",
"liquidationCRatio": "TBD"
},
"CollateralAuctionHouseParams": {
"maxDiscount": "TBD",
"minimumBid": "TBD",
"minDiscount": "TBD",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
2 changes: 1 addition & 1 deletion gov-input/mainnet/template-AddCollateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"minDiscount": "3",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
}
}
}
16 changes: 4 additions & 12 deletions gov-input/mainnet/template-TargetsAndCalldata.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"chainid": 42161,
"description": "Random calldatas",
"description": "add secondary tax receiver for WETH",
"network": "mainnet",
"proposalType": "TargetsAndCalldata",
"ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F",
"objectArray": [
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
},
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
},
{
"target": "0xbbB4f37c787C6ecb0b6b5Fb3F73221aA22fabA70",
"calldata": "0xC295763Eed507d4A0f8B77241c03dd3354781a15"
"target": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2",
"calldata": "0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000"
}
],
"arrayLength": "3"
"arrayLength": "1"
}
73 changes: 73 additions & 0 deletions gov-output/mainnet/add-collateral-7_13_2024-6286386.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"CollateralAuctionHouseParams": {
"maxDiscount": "1",
"minimumBid": "2",
"minDiscount": "3",
"perSecondDiscountUpdateRate": "999998607628240538157433861"
},
"Delegatee": "0x0000000000000000000000000000000000000000",
"GlobalSettlement_Address": "0x1c6B7ab018be82ed6b5c63aE82D9f07bb7B231A2",
"LiquidationEngineCollateralParams": {
"newCAHChild": "0xb043A91C26b79620aaa06C02Ddcd78F3649b27CF",
"liquidationPenalty": "1000000000000000000",
"liquidationQuantity": "1000000000000000000000000000000000000000000000"
},
"LiquidationEngine_Address": "0x17e546dDCE2EA8A74Bd667269457A2e80b309965",
"ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F",
"OracleRelayerCollateralParams": {
"delayedOracle": "0xa783CDc72e34a174CCa57a6d9a74904d0Bec05A9",
"safetyCRatio": "1000000000000000000000000000",
"liquidationCRatio": "1000000000000000000000000000"
},
"OracleRelayer_Address": "0x7404fc1F3796748FAE17011b57Fad9713185c1d6",
"ProtocolToken_Address": "0x000D636bD52BFc1B3a699165Ef5aa340BEA8939c",
"SAFEEngineCollateralParams": {
"collateralDebtCeiling": "500000000000000000000000000000000000000000000000",
"collateralDebtFloor": "100000000000000000000000000000000000000000000000"
},
"SAFEEngine_Address": "0xEff45E8e2353893BD0558bD5892A42786E9142F1",
"TaxCollectorCollateralParams": {
"stabilityFee": "1000000000000000000000000000"
},
"TaxCollector_Address": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2",
"TaxReceiver": {
"receiver": "0x9C86C719Aa29D426C50Ee3BAEd40008D292b02CF",
"canTakeBackTax": true,
"taxPercentage": "500000000000000000"
},
"calldatas": [
"0x26e166654e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000a513e6e4b8f2a923d98304ec87f64353c4d5c853",
"0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000033b2df124c64e1bef3bc405",
"0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005794c6828721caeb4b385895bfa0800000000000000000000000000000000000118427b3b4a05bc8a8a4de845986800000000000",
"0x34463c604e45574144440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000033b2e3c9fd0803ce8000000",
"0x34463c604e4557414444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000b043a91c26b79620aaa06c02ddcd78f3649b27cf0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000002cd76fe086b93ce2f768a00b22a00000000000",
"0x34463c604e4557414444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000a783cdc72e34a174cca57a6d9a74904d0bec05a90000000000000000000000000000000000000000033b2e3c9fd0803ce80000000000000000000000000000000000000000000000033b2e3c9fd0803ce8000000",
"0x12f335264e455741444400000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000"
],
"chainid": "42161",
"description": "add NEWADD as a collateral type",
"descriptionHash": "0xb2cc6970c686cc6e9cbc9d95cc525cbcc1d11bf3c626e05f95069f77120cad40",
"network": "mainnet",
"newCollateralAddress": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"newCollateralType": "NEWADD",
"proposalId": "6286386367297697622524748526094319121591800364290862196749718428572157214720",
"proposalType": "AddCollateral",
"targets": [
"0xa83c0f1e9eD8E383919Dde0fC90744ae370EB7B3",
"0x5dc1E86361faC018f24Ae0D1E5eB01D70AB32A82",
"0xEff45E8e2353893BD0558bD5892A42786E9142F1",
"0xc93F938A95488a03b976A15B20fAcFD52D087fB2",
"0x17e546dDCE2EA8A74Bd667269457A2e80b309965",
"0x7404fc1F3796748FAE17011b57Fad9713185c1d6",
"0xc93F938A95488a03b976A15B20fAcFD52D087fB2"
],
"values": [
0,
0,
0,
0,
0,
0,
0
]
}
25 changes: 25 additions & 0 deletions gov-output/mainnet/targetsAndCalldata-7_9_2024-76864215.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"ODGovernor_Address": "0xf704735CE81165261156b41D33AB18a08803B86F",
"arrayLength": "1",
"calldatas": [
"0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000"
],
"chainid": 42161,
"description": "add secondary tax receiver for WETH",
"descriptionHash": "0x42ba67fde5f25ce4c9185c3be6e859c5f2e4293c1321cfa063da8973c3b432c7",
"network": "mainnet",
"objectArray": [
{
"target": "0xc93F938A95488a03b976A15B20fAcFD52D087fB2",
"calldata": "0x12f3352657455448000000000000000000000000000000000000000000000000000000007365636f6e646172795461785265636569766572000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000009c86c719aa29d426c50ee3baed40008d292b02cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000006f05b59d3b20000"
}
],
"proposalId": 76864215325714286555073332752783782717698752062872007843280380922333230264505,
"proposalType": "TargetsAndCalldata",
"targets": [
"0xc93F938A95488a03b976A15B20fAcFD52D087fB2"
],
"values": [
0
]
}
71 changes: 60 additions & 11 deletions src/contracts/Generate/GenerateAddCollateralProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
address public liquidationEngine;
address public oracleRelayer;
address public newCAddress;
address public delegatee;

ICollateralAuctionHouse.CollateralAuctionHouseParams internal _cahCParams;
ISAFEEngine.SAFEEngineCollateralParams internal _SAFEEngineCollateralParams;
ITaxCollector.TaxCollectorCollateralParams internal _taxCollectorCParams;
ITaxCollector.TaxReceiver internal _taxReceiver;
ILiquidationEngine.LiquidationEngineCollateralParams internal _liquidationEngineCParams;
IOracleRelayer.OracleRelayerCollateralParams internal _oracleCParams;

Expand All @@ -54,6 +56,15 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
// uint256 /* RAY */ stabilityFee;
// }

// struct TaxReceiver {
// // the secondary tax receiver. normally the StabilityFeeTreasury
// address receiver;
// // Whether this receiver can accept a negative rate (taking SF from it)
// bool /* bool */ canTakeBackTax;
// // Percentage of SF allocated to this receiver
// uint256 /* WAD % */ taxPercentage;
// }

// struct LiquidationEngineCollateralParams {
// // Address of the collateral auction house handling liquidations for this collateral type
// address /* */ collateralAuctionHouse;
Expand Down Expand Up @@ -87,6 +98,7 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
taxCollector = json.readAddress(string(abi.encodePacked('.TaxCollector_Address:')));
liquidationEngine = json.readAddress(string(abi.encodePacked('.LiquidationEngine_Address:')));
oracleRelayer = json.readAddress(string(abi.encodePacked('.OracleRelayer_Address:')));
delegatee = json.readAddress(string(abi.encodePacked('.Delegatee')));

_cahCParams.minimumBid = json.readUint(string(abi.encodePacked('.CollateralAuctionHouseParams.minimumBid')));
_cahCParams.minDiscount = json.readUint(string(abi.encodePacked('.CollateralAuctionHouseParams.minDiscount')));
Expand All @@ -102,6 +114,10 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
_taxCollectorCParams.stabilityFee =
json.readUint(string(abi.encodePacked('.TaxCollectorCollateralParams.stabilityFee')));

_taxReceiver.receiver = json.readAddress(string(abi.encodePacked('.TaxReceiver.receiver')));
_taxReceiver.canTakeBackTax = json.readBool(string(abi.encodePacked('.TaxReceiver.canTakeBackTax')));
_taxReceiver.taxPercentage = json.readUint(string(abi.encodePacked('.TaxReceiver.taxPercentage')));

_liquidationEngineCParams.collateralAuctionHouse =
json.readAddress(string(abi.encodePacked('.LiquidationEngineCollateralParams.newCAHChild')));
_liquidationEngineCParams.liquidationPenalty =
Expand All @@ -120,31 +136,37 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
ODGovernor gov = ODGovernor(payable(governanceAddress));
IGlobalSettlement globalSettlement = IGlobalSettlement(globalSettlementAddress);

address[] memory targets = new address[](6);
address[] memory targets = new address[](7);
{
targets[0] = address(globalSettlement.collateralJoinFactory());
targets[1] = address(globalSettlement.collateralAuctionHouseFactory());
targets[2] = safeEngine;
targets[3] = taxCollector;
targets[4] = liquidationEngine;
targets[5] = oracleRelayer;
targets[6] = taxCollector;
}
// No values needed
uint256[] memory values = new uint256[](6);
uint256[] memory values = new uint256[](7);
{
values[0] = 0;
values[1] = 0;
values[2] = 0;
values[3] = 0;
values[4] = 0;
values[5] = 0;
values[6] = 0;
}
// Get calldata for:

bytes[] memory calldatas = new bytes[](6);

calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress);

bytes[] memory calldatas = new bytes[](7);
if (delegatee != address(0)) {
calldatas[0] = abi.encodeWithSelector(
ICollateralJoinFactory.deployDelegatableCollateralJoin.selector, newCType, newCAddress, delegatee
);
} else {
calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress);
}
calldatas[1] = abi.encodeWithSelector(
IModifiablePerCollateral.initializeCollateralType.selector, newCType, abi.encode(_cahCParams)
);
Expand All @@ -160,20 +182,47 @@ contract GenerateAddCollateralProposal is Generator, JSONScript {
calldatas[5] = abi.encodeWithSelector(
IModifiablePerCollateral.initializeCollateralType.selector, newCType, abi.encode(_oracleCParams)
);
calldatas[6] = abi.encodeWithSelector(
IModifiablePerCollateral.modifyParameters.selector,
newCType,
bytes32(abi.encodePacked('secondaryTaxReceiver')),
abi.encode(_taxReceiver)
);

// Get the descriptionHash
bytes32 descriptionHash = keccak256(bytes(description));

// stacc too dank
FileNameStrings memory fileNameStrings;

// Propose the action to add the collateral type
uint256 proposalId = gov.hashProposal(targets, values, calldatas, descriptionHash);
string memory stringProposalId = vm.toString(proposalId / 10 ** 69);
fileNameStrings.proposalIdUint = gov.hashProposal(targets, values, calldatas, descriptionHash);
fileNameStrings.shortProposalId = vm.toString(fileNameStrings.proposalIdUint / 10 ** 69);
fileNameStrings.proposalId = vm.toString(fileNameStrings.proposalIdUint);

(fileNameStrings.year, fileNameStrings.month, fileNameStrings.day) = timestampToDate(block.timestamp);
fileNameStrings.formattedDate = string.concat(
vm.toString(fileNameStrings.month), '_', vm.toString(fileNameStrings.day), '_', vm.toString(fileNameStrings.year)
);

{
string memory objectKey = 'PROPOSE_ADD_COLLATERAL_KEY';
// Build the JSON output
string memory builtProp =
_buildProposalParamsJSON(proposalId, objectKey, targets, values, calldatas, description, descriptionHash);
vm.writeJson(builtProp, string.concat('./gov-output/', _network, '/add-collateral-', stringProposalId, '.json'));
string memory builtProp = _buildProposalParamsJSON(
fileNameStrings.proposalId, objectKey, targets, values, calldatas, description, descriptionHash
);
vm.writeJson(
builtProp,
string.concat(
'./gov-output/',
_network,
'/add-collateral-',
fileNameStrings.formattedDate,
'-',
fileNameStrings.shortProposalId,
'.json'
)
);
}
}

Expand Down
Loading

0 comments on commit 8d3a063

Please sign in to comment.