Skip to content

Commit

Permalink
Merge the develop branch to the master branch, preparation to v1.1.0-rc1
Browse files Browse the repository at this point in the history
This update for the `master` branch contains the following set of changes:
  - [Improvement] Inverse logic for forwarding execution of messages (#50)
  - [Improvement] Add interfaces versions getter to external modules contracts (#51), closes #25
  - [Improvement] Add AAVE interest earning (#52)
  - [Other] Bump package and contracts interfaces version prior to 1.1.0-rc1 (#53)
  • Loading branch information
akolotov authored Jun 29, 2021
2 parents b658c7c + 27224c8 commit 68ad223
Show file tree
Hide file tree
Showing 22 changed files with 805 additions and 33 deletions.
8 changes: 8 additions & 0 deletions contracts/interfaces/IAToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IAToken is IERC20 {
// solhint-disable-next-line func-name-mixedcase
function UNDERLYING_ASSET_ADDRESS() external returns (address);
}
2 changes: 0 additions & 2 deletions contracts/interfaces/IInterestImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ interface IInterestImplementation {
function withdraw(address _token, uint256 _amount) external;

function investedAmount(address _token) external view returns (uint256);

function claimCompAndPay(address[] calldata _markets) external;
}
37 changes: 37 additions & 0 deletions contracts/interfaces/ILendingPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface ILendingPool {
function deposit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;

function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);

function borrow(
address asset,
uint256 amount,
uint256 interestRateMode,
uint16 referralCode,
address onBehalfOf
) external returns (uint256);

function repay(
address asset,
uint256 amount,
uint256 rateMode,
address onBehalfOf
) external returns (uint256);

// workaround to omit usage of abicoder v2
// see real signature at https://github.com/aave/protocol-v2/blob/master/contracts/protocol/libraries/types/DataTypes.sol
function getReserveData(address asset) external returns (address[12] memory);
}
7 changes: 7 additions & 0 deletions contracts/interfaces/IMintableERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma solidity 0.7.5;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMintableERC20 is IERC20 {
function mint(uint256 value) external;
}
11 changes: 11 additions & 0 deletions contracts/mocks/AAVEInterestERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity 0.7.5;

import "../upgradeable_contracts/modules/interest/AAVEInterestERC20.sol";

contract AAVEInterestERC20Mock is AAVEInterestERC20 {
constructor(address _omnibridge, address _owner) AAVEInterestERC20(_omnibridge, _owner) {}

function lendingPool() public pure override returns (ILendingPool) {
return ILendingPool(0xDe4e2b5D55D2eE0F95b6D96C1BF86b45364e45B0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract OmnibridgeInfo is VersionableBridge {
uint64 patch
)
{
return (3, 1, 0);
return (3, 2, 0);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions contracts/upgradeable_contracts/modules/factory/TokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ contract TokenFactory is OwnableModule {
tokenImage = _tokenImage;
}

/**
* @dev Tells the module interface version that this contract supports.
* @return major value of the version
* @return minor value of the version
* @return patch value of the version
*/
function getModuleInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (1, 0, 0);
}

/**
* @dev Updates the address of the used token image contract.
* Only owner can call this method.
Expand Down
15 changes: 15 additions & 0 deletions contracts/upgradeable_contracts/modules/factory/TokenProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,19 @@ contract TokenProxy is Proxy {
impl := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)
}
}

/**
* @dev Tells the current version of the token proxy interfaces.
*/
function getTokenProxyInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (1, 0, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ contract OmnibridgeFeeManager is MediatorOwnableModule {
rewardAddresses = _rewardAddresses;
}

/**
* @dev Tells the module interface version that this contract supports.
* @return major value of the version
* @return minor value of the version
* @return patch value of the version
*/
function getModuleInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (1, 0, 0);
}

/**
* @dev Throws if given fee amount is invalid.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ contract MultiTokenForwardingRulesConnector is Ownable {
address _receiver
) internal view returns (bool) {
MultiTokenForwardingRulesManager manager = forwardingRulesManager();
return address(manager) == address(0) || manager.destinationLane(_token, _sender, _receiver) >= 0;
// If the manager is defined the default behavior is to use manual lane
return address(manager) == address(0) || manager.destinationLane(_token, _sender, _receiver) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ contract MultiTokenForwardingRulesManager is OwnableModule {

constructor(address _owner) OwnableModule(_owner) {}

/**
* @dev Tells the module interface version that this contract supports.
* @return major value of the version
* @return minor value of the version
* @return patch value of the version
*/
function getModuleInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (1, 0, 0);
}

/**
* @dev Tells the destination lane for a particular bridge operation by checking several wildcard forwarding rules.
* @param _token address of the token contract on the foreign side of the bridge.
Expand All @@ -34,7 +52,7 @@ contract MultiTokenForwardingRulesManager is OwnableModule {
) public view returns (int256) {
int256 defaultLane = forwardingRule[_token][ANY_ADDRESS][ANY_ADDRESS]; // specific token for all senders and receivers
int256 lane;
if (defaultLane < 0) {
if (defaultLane > 0) {
lane = forwardingRule[_token][_sender][ANY_ADDRESS]; // specific token for specific sender
if (lane != 0) return lane;
lane = forwardingRule[_token][ANY_ADDRESS][_receiver]; // specific token for specific receiver
Expand All @@ -50,19 +68,19 @@ contract MultiTokenForwardingRulesManager is OwnableModule {
* Updates the forwarding rule for bridging specific token.
* Only owner can call this method.
* @param _token address of the token contract on the foreign side.
* @param _enable true, if bridge operations for a given token should be forwarded to the manual lane.
* @param _enable true, if bridge operations for a given token should be forwarded to the oracle-driven lane.
*/
function setTokenForwardingRule(address _token, bool _enable) external {
require(_token != ANY_ADDRESS);
_setForwardingRule(_token, ANY_ADDRESS, ANY_ADDRESS, _enable ? int256(-1) : int256(0));
_setForwardingRule(_token, ANY_ADDRESS, ANY_ADDRESS, _enable ? int256(1) : int256(0));
}

/**
* Allows a particular address to send bridge requests to the oracle-driven lane for a particular token.
* Allows a particular address to send bridge requests to the manual lane for a particular token.
* Only owner can call this method.
* @param _token address of the token contract on the foreign side.
* @param _sender address of the tokens sender on the home side of the bridge.
* @param _enable true, if bridge operations for a given token and sender should be forwarded to the oracle-driven lane.
* @param _enable true, if bridge operations for a given token and sender should be forwarded to the manual lane.
*/
function setSenderExceptionForTokenForwardingRule(
address _token,
Expand All @@ -71,15 +89,15 @@ contract MultiTokenForwardingRulesManager is OwnableModule {
) external {
require(_token != ANY_ADDRESS);
require(_sender != ANY_ADDRESS);
_setForwardingRule(_token, _sender, ANY_ADDRESS, _enable ? int256(1) : int256(0));
_setForwardingRule(_token, _sender, ANY_ADDRESS, _enable ? int256(-1) : int256(0));
}

/**
* Allows a particular address to receive bridged tokens from the oracle-driven lane for a particular token.
* Allows a particular address to receive bridged tokens from the manual lane for a particular token.
* Only owner can call this method.
* @param _token address of the token contract on the foreign side.
* @param _receiver address of the tokens receiver on the foreign side of the bridge.
* @param _enable true, if bridge operations for a given token and receiver should be forwarded to the oracle-driven lane.
* @param _enable true, if bridge operations for a given token and receiver should be forwarded to the manual lane.
*/
function setReceiverExceptionForTokenForwardingRule(
address _token,
Expand All @@ -88,29 +106,29 @@ contract MultiTokenForwardingRulesManager is OwnableModule {
) external {
require(_token != ANY_ADDRESS);
require(_receiver != ANY_ADDRESS);
_setForwardingRule(_token, ANY_ADDRESS, _receiver, _enable ? int256(1) : int256(0));
_setForwardingRule(_token, ANY_ADDRESS, _receiver, _enable ? int256(-1) : int256(0));
}

/**
* Updates the forwarding rule for the specific sender.
* Only owner can call this method.
* @param _sender address of the tokens sender on the home side.
* @param _enable true, if all bridge operations from a given sender should be forwarded to the manual lane.
* @param _enable true, if all bridge operations from a given sender should be forwarded to the oracle-driven lane.
*/
function setSenderForwardingRule(address _sender, bool _enable) external {
require(_sender != ANY_ADDRESS);
_setForwardingRule(ANY_ADDRESS, _sender, ANY_ADDRESS, _enable ? int256(-1) : int256(0));
_setForwardingRule(ANY_ADDRESS, _sender, ANY_ADDRESS, _enable ? int256(1) : int256(0));
}

/**
* Updates the forwarding rule for the specific receiver.
* Only owner can call this method.
* @param _receiver address of the tokens receiver on the foreign side.
* @param _enable true, if all bridge operations to a given receiver should be forwarded to the manual lane.
* @param _enable true, if all bridge operations to a given receiver should be forwarded to the oracle-driven lane.
*/
function setReceiverForwardingRule(address _receiver, bool _enable) external {
require(_receiver != ANY_ADDRESS);
_setForwardingRule(ANY_ADDRESS, ANY_ADDRESS, _receiver, _enable ? int256(-1) : int256(0));
_setForwardingRule(ANY_ADDRESS, ANY_ADDRESS, _receiver, _enable ? int256(1) : int256(0));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ contract SelectorTokenGasLimitManager is OwnableModule {
defaultGasLimit = _gasLimit;
}

/**
* @dev Tells the module interface version that this contract supports.
* @return major value of the version
* @return minor value of the version
* @return patch value of the version
*/
function getModuleInterfacesVersion()
external
pure
returns (
uint64 major,
uint64 minor,
uint64 patch
)
{
return (1, 0, 0);
}

/**
* @dev Throws if provided gas limit is greater then the maximum allowed gas limit in the AMB contract.
* @param _gasLimit gas limit value to check.
Expand Down
Loading

0 comments on commit 68ad223

Please sign in to comment.