Skip to content

Add dripRateProposer script for OETH #2369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"@aws-sdk/client-kms": "^3.598.0",
"@aws-sdk/client-s3": "^3.600.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-solhint": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@openzeppelin/contracts": "4.4.2",
Expand Down Expand Up @@ -115,6 +115,9 @@
},
"dependencies": {
"@chainlink/contracts-ccip": "^1.2.1",
"@safe-global/api-kit": "^2.5.7",
"@safe-global/protocol-kit": "^5.2.0",
"@safe-global/types-kit": "^1.0.1",
"ganache": "^7.9.2"
}
}
}
107 changes: 107 additions & 0 deletions contracts/scripts/defender-actions/oeth/dripRateProposer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
const { ethers } = require("ethers");
const {
DefenderRelaySigner,
DefenderRelayProvider,
} = require("@openzeppelin/defender-relay-client/lib/ethers");
const addresses = require("../../../utils/addresses");

const { SafeApiKit } = require("@safe-global/api-kit");
const { Safe } = require("@safe-global/protocol-kit");
const { OperationType } = require("@safe-global/types-kit");

const log = require("../../../utils/logger")("action:oeth:dripRateProposer");

const OETHAbi = [
"function totalSupply() external view returns (uint256)",
"function nonRebasingSupply() external view returns (uint256)",
];
const OETHFixedRateDripperAbi = ["function setDripRate(uint192) external"];

const TARGET_APR = 0.034;
const PERF_FEE = 0.2;

const computeDripRate = async (provider) => {
const oeth = new ethers.Contract(
addresses.mainnet.OETHProxy,
OETHAbi,
provider
);
const totalSupply = await oeth.totalSupply();
const nonRebasingSupply = await oeth.nonRebasingSupply();
const rebasingSupply = totalSupply.sub(nonRebasingSupply);

log(`Total supply: ${totalSupply}`);
log(`Non rebasing supply: ${nonRebasingSupply}`);
log(`Rebasing supply: ${rebasingSupply}`);

const dailyYield = rebasingSupply
.mul(TARGET_APR)
.mul((1 / (1 - PERF_FEE)).toFixed(2))
.div(365);
const ratePerSecond = dailyYield.div(86400);
return ratePerSecond;
};

const proposeDripRate = async (provider, signer, ratePerSecond) => {
const apiKit = new SafeApiKit({
chainId: "1",
});

const safe = await Safe.init({
provider: provider,
signer: signer,
safeAddress: addresses.multichainStrategist,
});

const dripper = new ethers.Contract(
addresses.mainnet.OETHFixedRateDripper,
OETHFixedRateDripperAbi,
signer
);
const encodedTx = dripper.interface.encodeFunctionData(
"setDripRate(uint192)",
[ratePerSecond]
);

const txData = {
to: addresses.mainnet.OETHFixedRateDripper,
value: "0",
data: encodedTx,
operation: OperationType.Call,
};

const safeTx = await safe.createTransaction({
transactions: [txData],
});

const safeTxHash = await safe.getTransactionHash(safeTx);
const signature = await safe.signHash(safeTxHash);

await apiKit.proposeTransaction({
safeAddress: addresses.multichainStrategist,
safeTransactionData: safeTx.data,
safeTxHash,
senderAddress: signer.address,
senderSignature: signature.data,
});

log(`Transaction proposed: ${safeTxHash}`);
};

const handler = async (event) => {
const provider = new DefenderRelayProvider(event);
const signer = new DefenderRelaySigner(event, provider, { speed: "fastest" });

// Make sure network is mainnet
const network = await provider.getNetwork();
if (network.chainId !== 1) {
throw new Error("Network is not mainnet");
}

const targetRate = await computeDripRate(provider);
log(`Target rate: ${targetRate}`);

await proposeDripRate(provider, signer, targetRate);
};

module.exports = { handler };
9 changes: 9 additions & 0 deletions contracts/scripts/defender-actions/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,13 @@ module.exports = [
format: "cjs",
},
},
{
...commonConfig,
input: "oeth/dripRateProposer.js",
output: {
file: "dist/oeth/dripRateProposer/index.js",
inlineDynamicImports: true,
format: "cjs",
},
},
];
5 changes: 4 additions & 1 deletion contracts/utils/addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ addresses.createX = "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed";
addresses.multichainStrategist = "0x4FF1b9D9ba8558F5EAfCec096318eA0d8b541971";
addresses.votemarket = "0x5e5C922a5Eeab508486eB906ebE7bDFFB05D81e5";

addresses.multichainStrategist = "0x4FF1b9D9ba8558F5EAfCec096318eA0d8b541971";

addresses.mainnet = {};
addresses.holesky = {};

Expand Down Expand Up @@ -227,7 +229,8 @@ addresses.mainnet.rETH = "0xae78736Cd615f374D3085123A210448E74Fc6393";
addresses.mainnet.stETH = "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
addresses.mainnet.wstETH = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0";
addresses.mainnet.FraxETHMinter = "0xbAFA44EFE7901E04E39Dad13167D089C559c1138";

addresses.mainnet.OETHFixedRateDripper =
"0xe3B3b4Fc77505EcfAACf6dD21619a8Cc12fcc501";
// 1Inch
addresses.mainnet.oneInchRouterV5 =
"0x1111111254EEB25477B68fb85Ed929f73A960582";
Expand Down
Loading
Loading