Skip to content
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
11 changes: 7 additions & 4 deletions contracts/tokenManager/MysoTokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ contract MysoTokenManager is Ownable2Step, IMysoTokenManager {
applicableProtocolFeeParams = currProtocolFeeParams;
address _mysoToken = mysoToken;
if (_mysoToken != address(0)) {
if (loan.loanToken == _mysoToken && lenderVault == mysoIOOVault) {
totalMysoLoanAmount += loan.initLoanAmount;
}
if (!_isAllowed(loan)) {
bool isMysoIoo = loan.loanToken == _mysoToken &&
lenderVault == mysoIOOVault;
if (!_isAllowed(isMysoIoo, loan)) {
revert NotAllowed();
}
if (isMysoIoo) {
totalMysoLoanAmount += loan.initLoanAmount;
}
address _stMysoToken = stMysoToken;
if (
_stMysoToken != address(0) &&
Expand Down Expand Up @@ -210,6 +212,7 @@ contract MysoTokenManager is Ownable2Step, IMysoTokenManager {
}

function _isAllowed(
bool /*isMysoIoo*/,
DataTypesPeerToPeer.Loan calldata /*loan*/
) internal virtual returns (bool) {
return true;
Expand Down
50 changes: 31 additions & 19 deletions contracts/tokenManager/MysoTokenManagerArbitrum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ contract MysoTokenManagerArbitrum is MysoTokenManager {
0xd3443ee1e91aF28e5FB858Fbd0D72A63bA8046E0;
address internal constant GETH = 0x5977A9682D7AF81D347CFc338c61692163a2784C;
mapping(address => uint256) public gVolume;
uint256 public gVolumeCap;
mapping(address => uint256) public gVolumeCaps;

event GVolumeSet(address gToken, uint256 gVolume);
event GVolumeCapSet(uint256 gVolumeCap);
event GVolumeCapSet(address gToken, uint256 gVolumeCap);

error NoGToken();

constructor(
address _mysoIOOVault,
address _mysoToken,
address _stMysoToken,
uint256 _minMysoWeight,
uint256 _gVolumeCap
uint256 _gDaiCap,
uint256 _gUsdcCap,
uint256 _gEthCap
)
MysoTokenManager(
_mysoIOOVault,
Expand All @@ -30,7 +34,9 @@ contract MysoTokenManagerArbitrum is MysoTokenManager {
_minMysoWeight
)
{
gVolumeCap = _gVolumeCap;
gVolumeCaps[GDAI] = _gDaiCap;
gVolumeCaps[GUSDC] = _gUsdcCap;
gVolumeCaps[GETH] = _gEthCap;
}

function setGVolume(address _gToken, uint256 _gVolume) external {
Expand All @@ -39,27 +45,33 @@ contract MysoTokenManagerArbitrum is MysoTokenManager {
emit GVolumeSet(_gToken, _gVolume);
}

function setGVolumeCap(uint256 _gVolumeCap) external {
function setGVolumeCap(address gToken, uint256 _gVolumeCap) external {
_checkOwner();
gVolumeCap = _gVolumeCap;
emit GVolumeCapSet(_gVolumeCap);
if (gToken != GDAI && gToken != GDAI && gToken != GDAI) {
revert NoGToken();
}
gVolumeCaps[gToken] = _gVolumeCap;
emit GVolumeCapSet(gToken, _gVolumeCap);
}

function _isAllowed(
bool isMysoIoo,
DataTypesPeerToPeer.Loan calldata loan
) internal override returns (bool isAllowed) {
if (
loan.collToken == GDAI ||
loan.collToken == GUSDC ||
loan.collToken == GETH
) {
uint256 _gVolume = gVolume[loan.collToken];
_gVolume +=
(loan.collToken == GETH ? 3500 : 1) *
loan.initCollAmount;
isAllowed = _gVolume <= gVolumeCap;
if (isAllowed) {
gVolume[loan.collToken] = _gVolume;
if (isMysoIoo) {
if (
loan.collToken == GDAI ||
loan.collToken == GUSDC ||
loan.collToken == GETH
) {
uint256 _newGVolume = gVolume[loan.collToken] +
loan.initCollAmount;
isAllowed = _newGVolume <= gVolumeCaps[loan.collToken];
if (isAllowed) {
gVolume[loan.collToken] = _newGVolume;
}
} else {
isAllowed = true;
}
} else {
isAllowed = true;
Expand Down
17 changes: 11 additions & 6 deletions contracts/tokenManager/MysoTokenManagerMainnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ contract MysoTokenManagerMainnet is MysoTokenManager {
}

function _isAllowed(
bool isMysoIoo,
DataTypesPeerToPeer.Loan calldata loan
) internal virtual override returns (bool) {
address _degenscoreBeaconReader = degenscoreBeaconReader;
if (_degenscoreBeaconReader == address(0)) {
if (isMysoIoo) {
address _degenscoreBeaconReader = degenscoreBeaconReader;
if (_degenscoreBeaconReader == address(0)) {
return true;
}
BeaconData memory beaconData = IDegenScoreBeaconReader(
_degenscoreBeaconReader
).beaconDataOf(loan.borrower);
return beaconData.updatedAt != 0;
} else {
return true;
}
BeaconData memory beaconData = IDegenScoreBeaconReader(
_degenscoreBeaconReader
).beaconDataOf(loan.borrower);
return beaconData.updatedAt != 0;
}
}