Skip to content

Commit

Permalink
avalanche hardhat verify setup, mainnet USDC support upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
David405 committed Oct 31, 2023
1 parent fd55af7 commit ef665b6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 50 deletions.
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

0 comments on commit ef665b6

Please sign in to comment.