Skip to content

Commit

Permalink
style: prettier and lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Apr 23, 2024
1 parent 70a413b commit c48d22f
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"max-line-length": ["error", 120],
"max-line-length": ["warn", 120],
"avoid-call-value": "warn",
"avoid-low-level-calls": "off",
"avoid-tx-origin": "warn",
Expand Down
4 changes: 2 additions & 2 deletions contracts/agToken/AgTokenSideChainMultiBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import "oz/token/ERC20/utils/SafeERC20.sol";
/// @title AgTokenSideChainMultiBridge
/// @author Angle Labs, Inc.
/// @notice Contract for Angle agTokens on other chains than Ethereum mainnet
/// @dev This contract supports bridge tokens having a minting right on the stablecoin (also referred to as the canonical
/// or the native token)
/// @dev This contract supports bridge tokens having a minting right on the stablecoin
/// (also referred to as the canonicalor the native token)
contract AgTokenSideChainMultiBridge is AgToken {
using SafeERC20 for IERC20;

Expand Down
7 changes: 3 additions & 4 deletions contracts/agToken/layerZero/utils/IOFTCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import "oz/utils/introspection/IERC165.sol";
interface IOFTCore is IERC165 {
/// @notice Estimates send token `_tokenId` to (`_dstChainId`, `_toAddress`)
/// @param _dstChainId L0 defined chain id to send tokens too
/// @param _toAddress dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
/// @param _toAddress dynamic bytes array which contains the address to whom you are sending
/// tokens to on the dstChain
/// @param _amount amount of the tokens to transfer
/// @param _useZro indicates to use zro to pay L0 fees
/// @param _adapterParams flexible bytes array to indicate messaging adapter services in L0
Expand Down Expand Up @@ -106,6 +107,4 @@ interface IOFTCore is IERC165 {
}

/// @dev Interface of the OFT standard
interface IOFT is IOFTCore, IERC20 {

}
interface IOFT is IOFTCore, IERC20 {}
3 changes: 2 additions & 1 deletion contracts/agToken/layerZero/utils/NonblockingLzApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ abstract contract NonblockingLzApp is Initializable, ILayerZeroReceiver, ILayerZ
if (msg.sender != address(lzEndpoint)) revert InvalidEndpoint();

bytes memory trustedRemote = trustedRemoteLookup[_srcChainId];
// if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote.
// if will still block the message pathway from (srcChainId, srcAddress).
// should not receive message from untrusted remote.
if (_srcAddress.length != trustedRemote.length || keccak256(_srcAddress) != keccak256(trustedRemote))
revert InvalidSource();

Expand Down
3 changes: 2 additions & 1 deletion contracts/agToken/layerZero/utils/OFTCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import "oz-upgradeable/utils/introspection/ERC165Upgradeable.sol";

/// @title OFTCore
/// @author Forked from https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/OFTCore.sol
/// but with slight modifications from the Angle Labs, Inc. which added return values to the `_creditTo` and `_debitFrom` functions
/// but with slight modifications from the Angle Labs, Inc. which added return values to the `_creditTo`
/// and `_debitFrom` functions
/// @notice Base contract for bridging using LayerZero
abstract contract OFTCore is NonblockingLzApp, ERC165Upgradeable, IOFTCore {
/// @notice Amount of additional gas specified
Expand Down
2 changes: 2 additions & 0 deletions contracts/agToken/polygon/utils/ERC20UpgradeableCustom.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

// solhint-disable custom-errors

pragma solidity ^0.8.0;

import "oz-upgradeable/token/ERC20/IERC20Upgradeable.sol";
Expand Down
43 changes: 24 additions & 19 deletions contracts/interfaces/IVaultManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,18 @@ interface IVaultManagerFunctions {
/// @notice Accrues interest accumulated across all vaults to the surplus and sends the surplus to the treasury
/// @return surplusValue Value of the surplus communicated to the `Treasury`
/// @return badDebtValue Value of the bad debt communicated to the `Treasury`
/// @dev `surplus` and `badDebt` should be reset to 0 once their current value have been given to the `treasury` contract
/// @dev `surplus` and `badDebt` should be reset to 0 once their current value have been given to the
/// `treasury` contract
function accrueInterestToTreasury() external returns (uint256 surplusValue, uint256 badDebtValue);

/// @notice Removes debt from a vault after being requested to do so by another `VaultManager` contract
/// @param vaultID ID of the vault to remove debt from
/// @param amountStablecoins Amount of stablecoins to remove from the debt: this amount is to be converted to an
/// internal debt amount
/// @param senderBorrowFee Borrowing fees from the contract which requested this: this is to make sure that people are not
/// arbitraging difference in minting fees
/// @param senderRepayFee Repay fees from the contract which requested this: this is to make sure that people are not arbitraging
/// differences in repay fees
/// @param senderBorrowFee Borrowing fees from the contract which requested this: this is to make sure that people
/// are not arbitraging difference in minting fees
/// @param senderRepayFee Repay fees from the contract which requested this: this is to make sure that people
/// are not arbitraging differences in repay fees
/// @dev This function can only be called from a vaultManager registered in the same Treasury
function getDebtOut(
uint256 vaultID,
Expand Down Expand Up @@ -145,20 +146,23 @@ interface IVaultManagerFunctions {
/// @notice Allows composability between calls to the different entry points of this module. Any user calling
/// this function can perform any of the allowed actions in the order of their choice
/// @param actions Set of actions to perform
/// @param datas Data to be decoded for each action: it can include like the `vaultID` or the `stablecoinAmount` to borrow
/// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address
/// should either be the `msg.sender` or be approved by the latter
/// @param datas Data to be decoded for each action: it can include like the `vaultID` or the `stablecoinAmount`
/// to borrow
/// @param from Address from which stablecoins will be taken if one action includes burning stablecoins.
/// This address should either be the `msg.sender` or be approved by the latter
/// @param to Address to which stablecoins and/or collateral will be sent in case of
/// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral
/// @param repayData Data to pass to the repayment contract in case of
/// @return paymentData Struct containing the accounting changes from the protocol's perspective (like how much of collateral
/// or how much has been received). Note that the values in the struct are not aggregated and you could have in the output
/// a positive amount of stablecoins to receive as well as a positive amount of stablecoins to give
/// @return paymentData Struct containing the accounting changes from the protocol's perspective (like how much
/// of collateral or how much has been received). Note that the values in the struct are not aggregated and you
/// could have in the output a positive amount of stablecoins to receive as well as a positive amount of
/// stablecoins to give
/// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls
/// or computations (like `oracleValue`) are done only once
/// @dev When specifying `vaultID` in `data`, it is important to know that if you specify `vaultID = 0`, it will simply
/// use the latest `vaultID`. This is the default behavior, and unless you're engaging into some complex protocol actions
/// it is encouraged to use `vaultID = 0` only when the first action of the batch is `createVault`
/// @dev When specifying `vaultID` in `data`, it is important to know that if you specify `vaultID = 0`,
/// it will simply use the latest `vaultID`. This is the default behavior, and unless you're engaging into some
/// complex protocol actions, it is encouraged to use `vaultID = 0` only when the first action of the
/// batch is `createVault`
function angle(
ActionType[] memory actions,
bytes[] memory datas,
Expand All @@ -168,8 +172,8 @@ interface IVaultManagerFunctions {
bytes memory repayData
) external returns (PaymentData memory paymentData);

/// @notice This function is a wrapper built on top of the function above. It enables users to interact with the contract
/// without having to provide `who` and `repayData` parameters
/// @notice This function is a wrapper built on top of the function above. It enables users to interact with
/// the contract without having to provide `who` and `repayData` parameters
function angle(
ActionType[] memory actions,
bytes[] memory datas,
Expand All @@ -194,7 +198,8 @@ interface IVaultManagerFunctions {
string memory _symbol
) external;

/// @notice Minimum amount of debt a vault can have, expressed in `BASE_TOKENS` that is to say the base of the agTokens
/// @notice Minimum amount of debt a vault can have, expressed in `BASE_TOKENS` that is to say the base
/// of the agTokens
function dust() external view returns (uint256);

/// @notice Pauses external permissionless functions of the contract
Expand Down Expand Up @@ -229,8 +234,8 @@ interface IVaultManagerStorage {
/// @notice Reference to the collateral handled by this `VaultManager`
function collateral() external view returns (IERC20);

/// @notice Total normalized amount of stablecoins borrowed, not taking into account the potential bad debt accumulated
/// This value is expressed in the base of Angle stablecoins (`BASE_TOKENS = 10**18`)
/// @notice Total normalized amount of stablecoins borrowed, not taking into account the potential
/// bad debt accumulated. This value is expressed in the base of Angle stablecoins (`BASE_TOKENS = 10**18`)
function totalNormalizedDebt() external view returns (uint256);

/// @notice Maximum amount of stablecoins that can be issued with this contract. It is expressed in `BASE_TOKENS`
Expand Down
6 changes: 2 additions & 4 deletions contracts/mock/MockLayerZero.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

pragma solidity ^0.8.12;

interface ILzApp {
function lzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) external;
}
import "layer-zero/interfaces/ILayerZeroReceiver.sol";

contract MockLayerZero {
mapping(uint16 => uint256) public counters;
Expand Down Expand Up @@ -43,7 +41,7 @@ contract MockLayerZero {
uint64 _nonce,
bytes memory _payload
) public {
ILzApp(lzApp).lzReceive(_srcChainId, _srcAddress, _nonce, _payload);
ILayerZeroReceiver(lzApp).lzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}

function estimateFees(
Expand Down
10 changes: 5 additions & 5 deletions contracts/treasury/Treasury.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ contract Treasury is ITreasury, Initializable {
/// @param surplusBufferValue Value of the surplus buffer after the calls to the different modules
/// @param badDebtValue Value of the bad debt after the calls to the different modules
/// @return Value of the `surplusBuffer` corrected from the `badDebt`
/// @return Value of the `badDebt` corrected from the `surplusBuffer` and from the surplus the treasury had accumulated
/// previously
/// @dev When calling this function, it is possible that there is a positive `surplusBufferValue` and `badDebtValue`,
/// this function tries to reconcile both values and makes sure that we either have surplus or bad debt but not both
/// at the same time
/// @return Value of the `badDebt` corrected from the `surplusBuffer` and from the surplus the treasury
/// had accumulated previously
/// @dev When calling this function, it is possible that there is a positive `surplusBufferValue`
/// and `badDebtValue`, this function tries to reconcile both values and makes sure that we either have
/// surplus or bad debt but not both at the same time
function _updateSurplusAndBadDebt(
uint256 surplusBufferValue,
uint256 badDebtValue
Expand Down
24 changes: 7 additions & 17 deletions test/units/agToken/AgTokenSideChainMultiBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {

// ================================= INITIALIZE ================================

function test_initialize_Constructor() public {
function test_initialize_Constructor() public view {
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
Expand Down Expand Up @@ -98,7 +98,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {

// ================================= AddBridgeToken ================================

function test_addBridgeToken_Normal() public {
function test_addBridgeToken_Normal() public view {
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
Expand Down Expand Up @@ -241,9 +241,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {
function test_setLimit_Normal() public {
vm.prank(_GOVERNOR);
_agToken.setLimit(address(_bridgeToken), 1000e18);
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
(uint256 limit, , , , ) = _agToken.bridges(address(_bridgeToken));
assertEq(limit, 1000e18);
}

Expand All @@ -264,9 +262,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {
function test_setHourlyLimit_Normal() public {
vm.prank(_GOVERNOR);
_agToken.setHourlyLimit(address(_bridgeToken), 1000e18);
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
(, uint256 hourlyLimit, , , ) = _agToken.bridges(address(_bridgeToken));
assertEq(hourlyLimit, 1000e18);
}

Expand Down Expand Up @@ -307,9 +303,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {
function test_setSwapFee_Normal() public {
vm.prank(_GOVERNOR);
_agToken.setSwapFee(address(_bridgeToken), 3e8);
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
(, , uint64 fee, , ) = _agToken.bridges(address(_bridgeToken));
assertEq(fee, 3e8);
}

Expand All @@ -330,9 +324,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {
function test_toggleBridge_Paused() public {
vm.prank(_GOVERNOR);
_agToken.toggleBridge(address(_bridgeToken));
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
(, , , , bool paused) = _agToken.bridges(address(_bridgeToken));
assertTrue(paused);
}

Expand All @@ -341,9 +333,7 @@ contract AgTokenSideChainMultiBridgeTest is BaseTest {
_agToken.toggleBridge(address(_bridgeToken));
_agToken.toggleBridge(address(_bridgeToken));
vm.stopPrank();
(uint256 limit, uint256 hourlyLimit, uint64 fee, bool allowed, bool paused) = _agToken.bridges(
address(_bridgeToken)
);
(, , , , bool paused) = _agToken.bridges(address(_bridgeToken));
assertFalse(paused);
}

Expand Down

0 comments on commit c48d22f

Please sign in to comment.