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

Deploy to Base and support USDC #172

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6b53062
new: deploy lens on optimism.
twygod Oct 23, 2023
af8688c
chg: update hardhat to 2.21.0
maxweng Mar 14, 2024
c94c453
chg: update deploy script to support USDC and Base network
maxweng Mar 15, 2024
68c84ad
chg: update github actions
maxweng Mar 15, 2024
a7092fe
chg: update hardhat version
maxweng Mar 15, 2024
eca9109
chg: remove gov actions
maxweng Mar 15, 2024
cf7330d
chg: update dependencies
maxweng Mar 15, 2024
76c1e05
chg: update github actions
maxweng Mar 16, 2024
96144bc
chg: add base-sepolia deployment
maxweng Mar 16, 2024
a0235ae
chg: update eth-optimism/sdk to support base network
maxweng Mar 18, 2024
58df6dd
new: deploy lens
twygod Mar 18, 2024
7758295
fix: unit error
twygod Mar 21, 2024
a4a5f81
chg: update contract and test
twygod Mar 26, 2024
cf09374
chg: update contract and test
twygod Mar 26, 2024
b31a98d
chg: update deploy script and deploy contract
twygod Mar 26, 2024
36f7883
chg: deploy and set aaveadapter on base sepolia
twygod Jun 13, 2024
de2b1c3
new: add testing
twygod Jun 20, 2024
38fc165
chg: add ScaledDecimalBase contract
maxweng Jun 20, 2024
b3ca13e
fix: compiler warnings
maxweng Jun 20, 2024
feabaf2
chg: add env var DECIMALS for various tokens decimals testing
maxweng Jun 20, 2024
5b204ba
fix: update erc20 mock contract to fix permit func error
twygod Jun 24, 2024
c61b149
chg: add new test
twygod Jun 24, 2024
7b00ef5
chg: update UNIT setting on foundry test
twygod Jun 24, 2024
58a40b5
chg: set DECIMAL's default value if not set
maxweng Jul 1, 2024
8003e7d
chg: add base-sepolia testnet
maxweng Jul 1, 2024
9fe5a80
Merge remote-tracking branch 'origin/develop' into feature/uni-1825-d…
maxweng Jul 1, 2024
353db2e
chg: fix test errors after merging the dev branch
maxweng Jul 1, 2024
0ce7036
fix: slither warnings
maxweng Jul 1, 2024
1e6c540
chg: add extra check on the withdrawal amount from the assetManager
maxweng Jul 24, 2024
84eb9d7
chg: update to use the correct OZ lib
maxweng Jul 24, 2024
9f1c1ea
fix: calculate the global total stake after total frozen is updated
maxweng Jul 22, 2024
7c39016
fix: coverage report error
maxweng Jul 29, 2024
bb7454f
fix: rounding up the utoken amount when redeeming
maxweng Jul 23, 2024
b1786d2
Merge remote-tracking branch 'origin/feature/uni-1825-deploy-to-base-…
maxweng Aug 30, 2024
10e974b
Merge pull request #175 from unioncredit/finding/uni-1992-repaying-a-…
maxweng Aug 30, 2024
da5c99d
chg: consider introducing an option for rounding the decimalReducing(…
twygod Jul 25, 2024
be12536
chg: add test
twygod Jul 25, 2024
3ad06dc
chg: modify coverage configuration
twygod Jul 26, 2024
2cc2c60
chg: add scaledDecimal test
twygod Jul 26, 2024
2027dec
chg: update scaledDecimal test
twygod Jul 26, 2024
d5d4996
chg: update scaledDecimal test
twygod Jul 26, 2024
9425e85
fix: repayBorrowWithERC20Permit functions use incorrectly scaled accu…
twygod Jul 25, 2024
037dbea
chg: update test
twygod Jul 30, 2024
1dd601d
fix: exchangeRateStored decimals are incorrect and misaligned with ex…
twygod Jul 25, 2024
b47c6b8
chg: update test
twygod Jul 25, 2024
295042b
fix: the amount of _totalStaked added when writeOffDebt is not scaled
twygod Jul 25, 2024
3d6da9a
chg: add test
twygod Jul 25, 2024
93934fa
chg: max_borrow_rate to 100% apr
maxweng Jul 30, 2024
d3197fc
Merge branch 'feature/uni-1825-deploy-to-base-sepolia-testnet' into f…
maxweng Aug 31, 2024
ef7e42d
Merge pull request #180 from unioncredit/finding/uni-1989-wrong-calcu…
maxweng Aug 31, 2024
2216798
fix: slither warnings
maxweng Aug 31, 2024
65007a0
new: deploye contract when fixed
twygod Sep 19, 2024
0626512
chg: update contract address
twygod Sep 19, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/ci_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install dependencies
run: yarn install
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Install dependencies
run: yarn install
Expand Down Expand Up @@ -45,14 +45,14 @@ jobs:
run: yarn hh:test

- name: Run Slither
uses: crytic/[email protected].0
uses: crytic/[email protected].1
id: slither
with:
node-version: 16
node-version: 20
sarif: results.sarif
fail-on: none

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
7 changes: 3 additions & 4 deletions .github/workflows/ci_slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ jobs:
name: Run slither
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crytic/[email protected].0
- uses: actions/checkout@v4
- uses: crytic/[email protected].1
with:
node-version: 16
node-version: 20
target: "."
slither-args: '--filter-path "test|node_modules|contracts/mocks"'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docs
.envrc
dist
report
arguments.js
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ CONFIG=arbitrum FORK_NODE_URL=<URL> FORK_BLOCK=<NUMBER> yarn hh:test
```
yarn format
```

## Other Scripts

Deposit to L2

yarn hardhat --network sepolia --config hardhat-task.config.ts op:deposit --pk <private_key> --l1-rpc-url https://eth-sepolia.public.blastapi.io --l2-rpc-url https://sepolia.base.org --l1-union 0xE4ADdfdf5641EB4e15F60a81F63CEd4884B49823 --l2-union 0xB025ee78b54B5348BD638Fe4a6D77Ec2F813f4f9 --amount 10000
48 changes: 19 additions & 29 deletions contracts/UnionLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ contract UnionLens {
IUserManager userManager = IUserManager(marketRegistry.userManagers(underlying));
IUToken uToken = IUToken(marketRegistry.uTokens(underlying));

(bool isMember, uint96 stakedAmount, uint96 locked, , , ) = userManager.stakers(user);
bool isMember = userManager.checkIsMember(user);
uint256 stakedAmount = userManager.getStakerBalance(user);
uint256 locked = userManager.getTotalLockedStake(user);

userInfo.isOverdue = uToken.checkIsOverdue(user);
userInfo.memberFrozen = userManager.memberFrozen(user);

userInfo.isMember = isMember;
userInfo.locked = uint256(locked);
userInfo.stakedAmount = uint256(stakedAmount);
userInfo.locked = locked;
userInfo.stakedAmount = stakedAmount;

userInfo.voucherCount = userManager.getVoucherCount(user);
userInfo.voucheeCount = userManager.getVoucheeCount(user);
Expand All @@ -81,7 +83,7 @@ contract UnionLens {
) public view returns (uint256, uint256, uint256, uint256) {
IUserManager userManager = IUserManager(marketRegistry.userManagers(underlying));

(, uint96 stakerStakedAmount, , , , ) = userManager.stakers(staker);
uint256 stakerStakedAmount = userManager.getStakerBalance(staker);

bool isSet;
uint256 idx;
Expand All @@ -95,7 +97,7 @@ contract UnionLens {

return (
uint256(trust),
trust > stakerStakedAmount ? stakerStakedAmount : trust, // vouch
uint256(trust) > stakerStakedAmount ? stakerStakedAmount : uint256(trust), // vouch
uint256(locked),
uint256(lastUpdated)
);
Expand All @@ -106,32 +108,20 @@ contract UnionLens {
address staker,
address borrower
) public view returns (RelatedInfo memory related) {
(
uint256 voucherTrust,
uint256 voucherVouch,
uint256 voucherLocked,
uint256 voucherLastUpdated
) = getVouchInfo(underlying, staker, borrower);

(
uint256 voucheeTrust,
uint256 voucheeVouch,
uint256 voucheeLocked,
uint256 voucheeLastUpdated
) = getVouchInfo(underlying, borrower, staker);

related.voucher = VouchInfo(
voucherTrust,
voucherVouch,
voucherLocked,
voucherLastUpdated
(uint256 voucherTrust, uint256 voucherVouch, uint256 voucherLocked, uint256 voucherLastUpdated) = getVouchInfo(
underlying,
staker,
borrower
);

related.vouchee = VouchInfo(
voucheeTrust,
voucheeVouch,
voucheeLocked,
voucheeLastUpdated
(uint256 voucheeTrust, uint256 voucheeVouch, uint256 voucheeLocked, uint256 voucheeLastUpdated) = getVouchInfo(
underlying,
borrower,
staker
);

related.voucher = VouchInfo(voucherTrust, voucherVouch, voucherLocked, voucherLastUpdated);

related.vouchee = VouchInfo(voucheeTrust, voucheeVouch, voucheeLocked, voucheeLastUpdated);
}
}
2 changes: 2 additions & 0 deletions contracts/interfaces/IDai.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ interface IDai is IERC20 {
bytes32 r,
bytes32 s
) external;

function decimals() external view returns (uint8);
}
2 changes: 2 additions & 0 deletions contracts/interfaces/IUserManager.sol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment

Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ interface IUserManager {
*/
function getStakeInfo(address staker) external view returns (bool, uint256, uint256, uint256);

function getStakeInfoMantissa(address staker) external view returns (bool, uint256, uint256, uint256);

/**
* @dev Update the frozen info by the comptroller
* @param staker Staker address
Expand Down
2 changes: 1 addition & 1 deletion contracts/market/UDai.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ contract UDai is UToken, IUDai {

if (!accrueInterest()) revert AccrueInterestFailed();
uint256 interest = calculatingInterest(borrower);
_repayBorrowFresh(msg.sender, borrower, amount, interest);
_repayBorrowFresh(msg.sender, borrower, decimalScaling(amount, underlyingDecimal), interest);
}
}
2 changes: 1 addition & 1 deletion contracts/market/UErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ contract UErc20 is UToken {

if (!accrueInterest()) revert AccrueInterestFailed();
uint256 interest = calculatingInterest(borrower);
_repayBorrowFresh(msg.sender, borrower, amount, interest);
_repayBorrowFresh(msg.sender, borrower, decimalScaling(amount, underlyingDecimal), interest);
}
}
Loading
Loading