From d2d3f9b62b86d0659f77eb25fcd5f053c276eb96 Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Thu, 9 Jan 2025 17:35:24 +1100 Subject: [PATCH 1/4] Fixed base unit tests after Fix upgrade script of OETHBase --- contracts/deploy/base/000_mock.js | 4 +--- contracts/deploy/base/021_upgrade_oeth.js | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts/deploy/base/000_mock.js b/contracts/deploy/base/000_mock.js index e3fa3ce690..af6b617cdc 100644 --- a/contracts/deploy/base/000_mock.js +++ b/contracts/deploy/base/000_mock.js @@ -101,10 +101,8 @@ const deployCore = async () => { // Init OETHb const resolution = ethers.utils.parseUnits("1", 27); const initDataOETHb = cOETHb.interface.encodeFunctionData( - "initialize(string,string,address,uint256)", + "initialize(address,uint256)", [ - "Super OETH", - "superOETHb", // Token Symbol cOETHbVaultProxy.address, // OETHb Vault resolution, // HighRes ] diff --git a/contracts/deploy/base/021_upgrade_oeth.js b/contracts/deploy/base/021_upgrade_oeth.js index c2fd99fae3..5da1c0573e 100644 --- a/contracts/deploy/base/021_upgrade_oeth.js +++ b/contracts/deploy/base/021_upgrade_oeth.js @@ -6,7 +6,12 @@ module.exports = deployOnBaseWithGuardian( deployName: "021_upgrade_oeth", }, async ({ ethers }) => { - const dOETHb = await deployWithConfirmation("OETHBase"); + const dOETHb = await deployWithConfirmation( + "OETHBase", + [], + undefined, + true + ); const cOETHbProxy = await ethers.getContract("OETHBaseProxy"); From 076ee2fc5fa17f23a75972eec30cfdff08b3687e Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Thu, 9 Jan 2025 17:41:00 +1100 Subject: [PATCH 2/4] Added Base fork tests to Coverage --- .github/workflows/defi.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/defi.yml b/.github/workflows/defi.yml index 5872321d5b..e4118c0bde 100644 --- a/.github/workflows/defi.yml +++ b/.github/workflows/defi.yml @@ -43,7 +43,7 @@ jobs: working-directory: ./contracts contracts-test: - name: "Contracts Unit Tests" + name: "Mainnet Unit Tests" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -66,7 +66,7 @@ jobs: working-directory: ./contracts contracts-unit-coverage: - name: "Contracts Unit Coverage" + name: "Mainnet Unit Coverage" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -81,7 +81,7 @@ jobs: - run: yarn install --frozen-lockfile working-directory: ./contracts - - name: Run Unit Coverage + - name: Run Mainnet Unit Coverage run: yarn run test:coverage working-directory: ./contracts @@ -94,7 +94,7 @@ jobs: retention-days: 1 contracts-base-test: - name: "Contracts Unit Tests (Base)" + name: "Base Unit Coverage" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -109,10 +109,8 @@ jobs: - run: yarn install --frozen-lockfile working-directory: ./contracts - # this will run the unit tests and report the gas usage - - name: Run Unit Tests + - name: Run Base Unit Coverage env: - REPORT_GAS: true UNIT_TESTS_NETWORK: base run: yarn run test:coverage:base working-directory: ./contracts @@ -126,7 +124,7 @@ jobs: retention-days: 1 contracts-forktest: - name: "Contracts Fork Tests ${{ matrix.chunk_id }}" + name: "Mainnet Fork Tests ${{ matrix.chunk_id }}" runs-on: ubuntu-latest strategy: matrix: @@ -268,7 +266,7 @@ jobs: cache: "yarn" cache-dependency-path: contracts/yarn.lock - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: hardhat-cache with: path: contracts/cache @@ -282,23 +280,24 @@ jobs: - run: yarn run test:coverage:base-fork working-directory: ./contracts - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: fork-test-base-coverage-${{ github.sha }} path: | ./contracts/coverage.json ./contracts/coverage/**/* retention-days: 1 - + coverage-uploader: name: "Upload Coverage Reports" runs-on: ubuntu-latest needs: - contracts-unit-coverage + - contracts-base-test - contracts-forktest - contracts-arb-forktest - contracts-hol-forktest - - contracts-base-test + - contracts-base-forktest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: From 4e0d836cdef4107b1809b36ddc8a9b38b566dc3d Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Thu, 9 Jan 2025 20:10:04 +1100 Subject: [PATCH 3/4] Prettier OUSD --- contracts/contracts/token/OUSD.sol | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/contracts/contracts/token/OUSD.sol b/contracts/contracts/token/OUSD.sol index 9c9f87b750..d24398dc4e 100644 --- a/contracts/contracts/token/OUSD.sol +++ b/contracts/contracts/token/OUSD.sol @@ -495,7 +495,7 @@ contract OUSD is Governable { // at least the balance that they should have. // Note this should always be used on an absolute account value, // not on a possibly negative diff, because then the rounding would be wrong. - return ((_balance) * rebasingCreditsPerToken_ + 1e18 - 1) / 1e18; + return ((_balance) * rebasingCreditsPerToken_ + 1e18 - 1) / 1e18; } /** @@ -656,12 +656,14 @@ contract OUSD is Governable { uint256 fromBalance = balanceOf(_from); uint256 toBalance = balanceOf(_to); uint256 oldToCredits = creditBalances[_to]; - uint256 newToCredits = _balanceToRebasingCredits(fromBalance + toBalance); + uint256 newToCredits = _balanceToRebasingCredits( + fromBalance + toBalance + ); // Set up the bidirectional links yieldTo[_from] = _to; yieldFrom[_to] = _from; - + // Local rebaseState[_from] = RebaseOptions.YieldDelegationSource; alternativeCreditsPerToken[_from] = 1e18; @@ -670,7 +672,8 @@ contract OUSD is Governable { creditBalances[_to] = newToCredits; // Global - int256 creditsChange = newToCredits.toInt256() - oldToCredits.toInt256(); + int256 creditsChange = newToCredits.toInt256() - + oldToCredits.toInt256(); _adjustGlobals(creditsChange, -(fromBalance).toInt256()); emit YieldDelegated(_from, _to); } @@ -685,13 +688,13 @@ contract OUSD is Governable { address to = yieldTo[_from]; uint256 fromBalance = balanceOf(_from); uint256 toBalance = balanceOf(to); - uint256 oldToCredits = creditBalances[to]; + uint256 oldToCredits = creditBalances[to]; uint256 newToCredits = _balanceToRebasingCredits(toBalance); // Remove the bidirectional links yieldFrom[to] = address(0); yieldTo[_from] = address(0); - + // Local rebaseState[_from] = RebaseOptions.StdNonRebasing; // alternativeCreditsPerToken[from] already 1e18 from `delegateYield()` @@ -701,7 +704,8 @@ contract OUSD is Governable { creditBalances[to] = newToCredits; // Global - int256 creditsChange = newToCredits.toInt256() - oldToCredits.toInt256(); + int256 creditsChange = newToCredits.toInt256() - + oldToCredits.toInt256(); _adjustGlobals(creditsChange, fromBalance.toInt256()); emit YieldUndelegated(_from, to); } From b9837f3f68e39e03d4ec8a232c1ef5fb0bfd3cb1 Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Thu, 9 Jan 2025 20:34:34 +1100 Subject: [PATCH 4/4] Add Solidity files to prettier check --- contracts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/package.json b/contracts/package.json index 75ea9f7de9..b3e8e07af3 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -22,7 +22,7 @@ "lint:js": "eslint \"test/**/*.js\" \"tasks/**/*.js\" \"deploy/**/*.js\"", "lint:sol": "solhint \"contracts/**/*.sol\"", "prettier": "yarn run prettier:js && yarn run prettier:sol", - "prettier:check": "prettier -c \"*.js\" \"deploy/**/*.js\" \"scripts/**/*.js\" \"smoke/**/*.js\" \"scripts/**/*.js\" \"tasks/**/*.js\" \"test/**/*.js\" \"utils/**/*.js\"", + "prettier:check": "prettier -c \"contracts/**/*.sol\" \"*.js\" \"deploy/**/*.js\" \"scripts/**/*.js\" \"smoke/**/*.js\" \"scripts/**/*.js\" \"tasks/**/*.js\" \"test/**/*.js\" \"utils/**/*.js\"", "prettier:js": "prettier --write \"*.js\" \"deploy/**/*.js\" \"scripts/**/*.js\" \"smoke/**/*.js\" \"scripts/**/*.js\" \"tasks/**/*.js\" \"test/**/*.js\" \"utils/**/*.js\"", "prettier:sol": "prettier --write \"contracts/**/*.sol\"", "test": "rm -rf deployments/hardhat && IS_TEST=true npx hardhat test",