Skip to content
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

compounding error #1186

Merged
merged 4 commits into from
Aug 21, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ All components: make Main the only component that can call `upgradeTo()`

Add `savedPegPrice` to `ICollateral` interface

- cbETH: Fix deploy script to use right defaultThreshold
- rETH: Fix deploy script to use right defaultThreshold
- wstETH: Fix deploy script to use right defaultThreshold
- sfrxETH: Fix deploy script to use right defaultThreshold

### Trading

- `GnosisTrade`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ async function main() {
)) as CBEthCollateral__factory

const CBETH_ORACLE_ERROR = fp('0.01') // 1%
const oracleError = combinedError(fp('0.005'), CBETH_ORACLE_ERROR) // 0.5% & 1%
const oracleError = combinedError(fp('0.005'), CBETH_ORACLE_ERROR) // 0.5% + 1%

collateral = await CBETHCollateralFactory.connect(deployer).deploy(
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH!,
oracleError: oracleError.toString(), // 0.5% & 2%,
oracleError: oracleError.toString(), // 0.5% + 2%,
erc20: networkConfig[chainId].tokens.cbETH!,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '3600', // 1 hr,
Expand All @@ -82,13 +82,13 @@ async function main() {
)) as CBEthCollateralL2__factory

const CBETH_ORACLE_ERROR = fp('0.005') // 0.5%
const oracleError = combinedError(fp('0.0015'), CBETH_ORACLE_ERROR) // 0.15% & 0.5%
const oracleError = combinedError(fp('0.0015'), CBETH_ORACLE_ERROR) // 0.15% + 0.5%

collateral = await CBETHCollateralFactory.connect(deployer).deploy(
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH!,
oracleError: oracleError.toString(), // 0.15% & 0.5%,
oracleError: oracleError.toString(), // 0.15% + 0.5%,
erc20: networkConfig[chainId].tokens.cbETH!,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '1200', // 20 min
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ async function main() {
'ETHxCollateral'
)

const oracleError = combinedError(ETH_ORACLE_ERROR, ETHX_ORACLE_ERROR) // 0.5% & 0.5%
const oracleError = combinedError(ETH_ORACLE_ERROR, ETHX_ORACLE_ERROR) // 0.5% + 0.5%

const collateral = <ETHxCollateral>await ETHxCollateralFactory.connect(deployer).deploy(
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.5% & 0.5%
oracleError: oracleError.toString(), // 0.5% + 0.5%
erc20: networkConfig[chainId].tokens.ETHx,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: ETH_ORACLE_TIMEOUT.toString(), // 1 hr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function main() {
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: BASE_PRICE_FEEDS.stETH_ETH, // ignored
oracleError: BASE_ORACLE_ERROR.toString(), // 0.5% & 0.5% & 0.15%
oracleError: BASE_ORACLE_ERROR.toString(), // 0.5% + 0.5% + 0.15%
erc20: networkConfig[chainId].tokens.wstETH,
maxTradeVolume: fp('5e5').toString(), // $500k
oracleTimeout: BASE_FEEDS_TIMEOUT.stETH_ETH, // 86400, ignored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ async function main() {
)

const RETH_ORACLE_ERROR = fp('0.02')
const oracleError = combinedError(fp('0.005'), RETH_ORACLE_ERROR) // 0.5% & 2%
const oracleError = combinedError(fp('0.005'), RETH_ORACLE_ERROR) // 0.5% + 2%

const collateral = <RethCollateral>await RethCollateralFactory.connect(deployer).deploy(
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.5% & 2%
oracleError: oracleError.toString(), // 0.5% + 2%
erc20: networkConfig[chainId].tokens.rETH,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '3600', // 1 hr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function main() {
)

const SFRAXETH_ORACLE_ERROR = fp('0.0002')
const oracleError = combinedError(fp('0.005'), SFRAXETH_ORACLE_ERROR) // 0.5% & 0.02%
const oracleError = combinedError(fp('0.005'), SFRAXETH_ORACLE_ERROR) // 0.5% + 0.02%

const collateral = <SFraxEthCollateral>await SFraxEthCollateralFactory.connect(deployer).deploy(
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const priceTimeout = bn('604800') // 1 week
export const revenueHiding = fp('1e-6') // 1 part in a million

export const combinedError = (x: BigNumber, y: BigNumber): BigNumber => {
return fp('1').add(x).mul(fp('1').add(y)).div(fp('1')).sub(fp('1'))
return x.add(y)
}

export const validatePrerequisites = async (deployments: IDeployments) => {
Expand Down
8 changes: 4 additions & 4 deletions scripts/verification/collateral-plugins/verify_cbeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main() {
/******** Verify Coinbase staked ETH - CBETH **************************/
if (!baseL2Chains.includes(hre.network.name)) {
const CBETH_ORACLE_ERROR = fp('0.01')
const oracleError = combinedError(fp('0.005'), CBETH_ORACLE_ERROR) // 0.5% & 1%
const oracleError = combinedError(fp('0.005'), CBETH_ORACLE_ERROR) // 0.5% + 1%

await verifyContract(
chainId,
Expand All @@ -37,7 +37,7 @@ async function main() {
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.5% & 2%
oracleError: oracleError.toString(), // 0.5% + 2%
erc20: networkConfig[chainId].tokens.cbETH!,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '3600', // 1 hr
Expand All @@ -53,15 +53,15 @@ async function main() {
)
} else if (chainId == '8453' || chainId == '84531') {
const CBETH_ORACLE_ERROR = fp('0.005')
const oracleError = combinedError(fp('0.0015'), CBETH_ORACLE_ERROR) // 0.15% & 0.5%
const oracleError = combinedError(fp('0.0015'), CBETH_ORACLE_ERROR) // 0.15% + 0.5%
await verifyContract(
chainId,
deployments.collateral.cbETH,
[
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.15% & 0.5%,
oracleError: oracleError.toString(), // 0.15% + 0.5%,
erc20: networkConfig[chainId].tokens.cbETH!,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '1200', // 20 min
Expand Down
4 changes: 2 additions & 2 deletions scripts/verification/collateral-plugins/verify_ethx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ async function main() {
deployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename)

/******** Verify Stader ETH - ETHx **************************/
const oracleError = combinedError(ETH_ORACLE_ERROR, ETHX_ORACLE_ERROR) // 0.5% & 0.5%
const oracleError = combinedError(ETH_ORACLE_ERROR, ETHX_ORACLE_ERROR) // 0.5% + 0.5%
await verifyContract(
chainId,
deployments.collateral.ETHx,
[
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.5% & 0.5%
oracleError: oracleError.toString(), // 0.5% + 0.5%
erc20: networkConfig[chainId].tokens.ETHx,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: ETH_ORACLE_TIMEOUT.toString(), // 1 hr,
Expand Down
4 changes: 2 additions & 2 deletions scripts/verification/collateral-plugins/verify_reth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ async function main() {

/******** Verify Rocket-Pool ETH - rETH **************************/
const RETH_ORACLE_ERROR = fp('0.02')
const oracleError = combinedError(fp('0.005'), RETH_ORACLE_ERROR) // 0.5% & 2%
const oracleError = combinedError(fp('0.005'), RETH_ORACLE_ERROR) // 0.5% + 2%
await verifyContract(
chainId,
deployments.collateral.rETH,
[
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.ETH,
oracleError: oracleError.toString(), // 0.5% & 2%,
oracleError: oracleError.toString(), // 0.5% + 2%,
erc20: networkConfig[chainId].tokens.rETH,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '3600', // 1 hr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function main() {

/******** Verify sFRAX **************************/
const SFRAXETH_ORACLE_ERROR = fp('0.0002')
const oracleError = combinedError(fp('0.005'), SFRAXETH_ORACLE_ERROR) // 0.5% & 0.02%
const oracleError = combinedError(fp('0.005'), SFRAXETH_ORACLE_ERROR) // 0.5% + 0.02%

await verifyContract(
chainId,
Expand Down
2 changes: 1 addition & 1 deletion scripts/verification/collateral-plugins/verify_wsteth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function main() {
{
priceTimeout: priceTimeout.toString(),
chainlinkFeed: BASE_PRICE_FEEDS.stETH_ETH, // ignored
oracleError: BASE_ORACLE_ERROR.toString(), // 0.5% & 0.5% & 0.15%
oracleError: BASE_ORACLE_ERROR.toString(), // 0.5% + 0.5% + 0.15%
erc20: networkConfig[chainId].tokens.wstETH,
maxTradeVolume: fp('5e5').toString(), // $500k
oracleTimeout: BASE_FEEDS_TIMEOUT.stETH_ETH, // 86400, ignored
Expand Down
4 changes: 2 additions & 2 deletions test/integration/mainnet-test/IssuancePremium.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describeFork(`ETH+ Issuance Premium - Mainnet Forking P${IMPLEMENTATION}`, funct

// SFraxEthCollateral
const SFraxEthCollateralFactory = await hre.ethers.getContractFactory('SFraxEthCollateral')
let oracleError = combinedError(fp('0.005'), fp('0.0002')) // 0.5% & 0.02%
let oracleError = combinedError(fp('0.005'), fp('0.0002')) // 0.5% + 0.02%
const newSfrxETH = <SFraxEthCollateral>await SFraxEthCollateralFactory.deploy(
{
priceTimeout: '604800',
Expand Down Expand Up @@ -158,7 +158,7 @@ describeFork(`ETH+ Issuance Premium - Mainnet Forking P${IMPLEMENTATION}`, funct

// RethCollateral
const RethCollateralFactory = await hre.ethers.getContractFactory('RethCollateral')
oracleError = combinedError(fp('0.005'), fp('0.02')) // 0.5% & 2%
oracleError = combinedError(fp('0.005'), fp('0.02')) // 0.5% + 2%
const newRETH = <RethCollateral>await RethCollateralFactory.deploy(
{
priceTimeout: '604800',
Expand Down
Loading