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

avalanche hardhat verify setup, mainnet USDC support upgrade #47

Merged
merged 1 commit into from
Nov 9, 2023
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
24 changes: 16 additions & 8 deletions contracts/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ contract Vault is

mapping(address => uint256) public lastUserCollateralRatio;

uint256 private constant USDC_DIVISOR = 1e12;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
Expand All @@ -118,7 +120,7 @@ contract Vault is
zUSD = _zusd;
COLLATERIZATION_RATIO_THRESHOLD = 15 * 1e2;
LIQUIDATION_REWARD = 15;
treasuryWallet = 0x6F996Cb36a2CB5f0e73Fc07460f61cD083c63d4b;
treasuryWallet = 0x9e0FBB6c48E571744c09d695552Ad20d44C3fC50;
swapFee = WadRayMath.wadDiv(8, 1000);
globalMintersPercentOfSwapFee = WadRayMath.wadDiv(1, 2);
treasuryPercentOfSwapFee = WadRayMath.wadDiv(1, 2);
Expand Down Expand Up @@ -185,10 +187,12 @@ contract Vault is
blockBlacklistedAddresses(msg.sender);
isTxPaused();

uint256 depositAmountInUSDC = _depositAmount / USDC_DIVISOR;

require(
collateral.balanceOf(msg.sender) >=
_depositAmount,
"Insufficient Balance"
depositAmountInUSDC,
"Insufficient Balance"
);

userCollateralBalance[msg.sender] += _depositAmount;
Expand Down Expand Up @@ -230,10 +234,10 @@ contract Vault is

_testImpact();

collateral.safeTransferFrom(
collateral.safeTransferFrom(
msg.sender,
address(this),
_depositAmount
depositAmountInUSDC
);

emit Deposit(msg.sender, _depositAmount, _mintAmount);
Expand Down Expand Up @@ -370,9 +374,11 @@ contract Vault is

_testImpact();

uint256 amountToWithdrawInUSDC = _amountToWithdraw / USDC_DIVISOR;

collateral.safeTransfer(
msg.sender,
_amountToWithdraw
amountToWithdrawInUSDC
);

emit Withdraw(msg.sender, _zToken, _amountToWithdraw);
Expand Down Expand Up @@ -401,14 +407,16 @@ contract Vault is

_burn(zUSD, msg.sender, userDebt);

uint256 totalRewardsInUSDC = totalRewards / USDC_DIVISOR;

if (userCollateralBalance[_user] <= totalRewards) {
userCollateralBalance[_user] = 0;

totalCollateral -= totalRewards;

collateral.safeTransfer(
msg.sender,
totalRewards
totalRewardsInUSDC
);

} else {
Expand All @@ -418,7 +426,7 @@ contract Vault is

collateral.safeTransfer(
msg.sender,
totalRewards
totalRewardsInUSDC
);
}

Expand Down
9 changes: 5 additions & 4 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require("@nomiclabs/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades");
require("@nomiclabs/hardhat-etherscan");
require("@nomicfoundation/hardhat-verify");

const dotenv = require('dotenv');
dotenv.config();
Expand Down Expand Up @@ -36,9 +37,9 @@ module.exports = {
process.env.MAINNET_PRIVATE_KEY,
],
chainId: 43114
}
// etherscan: {
// apiKey: process.env.ETHERSCAN_API_KEY,
// },
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
},
};
Loading