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

Fix Base unit and fork tests #2345

Merged
merged 4 commits into from
Jan 9, 2025
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
23 changes: 11 additions & 12 deletions .github/workflows/defi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
18 changes: 11 additions & 7 deletions contracts/contracts/token/OUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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()`
Expand All @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions contracts/deploy/base/000_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
7 changes: 6 additions & 1 deletion contracts/deploy/base/021_upgrade_oeth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading