Skip to content

Commit

Permalink
Merge the develop branch to the master branch, preparation to v5.7.0-rc1
Browse files Browse the repository at this point in the history
This set of changes includes the following improvements and few fixes:
  * [Improvement] Earn interest on locked tokens using Compound Protocol (#590)
  * [Other] Remove deprecated bridge types (#595)
  * [Other] Bump contracts and package version before 5.7.0-rc1 (#597)
  • Loading branch information
akolotov authored May 4, 2021
2 parents c937711 + ccb4ffd commit 7edfe77
Show file tree
Hide file tree
Showing 142 changed files with 52,791 additions and 40,309 deletions.
3 changes: 3 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"bracket-align": "off",
"no-complex-fallback": "off",
"no-simple-event-func-name": "off",
"const-name-snakecase": "off",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"compiler-version": ["error", "0.4.24"]
}
}
2 changes: 0 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ COPY ./upgrade/package.json ./upgrade/
COPY ./upgrade/package-lock.json ./upgrade/
RUN cd ./upgrade; npm install; cd ..

COPY ./scripts ./scripts

COPY truffle-config.js truffle-config.js
COPY ./contracts ./contracts
RUN npm run compile
Expand Down
3 changes: 0 additions & 3 deletions GAS_CONSUMPTION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
## Gas Consumption by Bridge Mode

- [NATIVE-TO-ERC](docs/NATIVE-TO-ERC.md)
- [NATIVE-TO-ERC-WITH-REWARD](docs/NATIVE-TO-ERC-WITH-REWARD.md)
- [ERC-TO-ERC](docs/ERC-TO-ERC.md)
- [ERC-TO-NATIVE](docs/ERC-TO-NATIVE.md)
- [ERC-TO-NATIVE-WITH-REWARD](docs/ERC-TO-NATIVE-WITH-REWARD.md)
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ The POA bridge contracts consist of several components:
* The **Home Bridge** smart contract. This is currently deployed in POA.Network.
* The **Foreign Bridge** smart contract. This is deployed in the Ethereum Mainnet.
* Depending on the type of relay operations the following components are also used:
* in `NATIVE-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Foreign network;
* in `AMB-NATIVE-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Foreign network;
* in `ERC-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Home network;
* in `AMB-ERC-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Home network;
* in `ERC-TO-NATIVE` mode: The home network nodes must support consensus engine that allows using a smart contract for block reward calculation;
* The **Validators** smart contract is deployed in both the POA.Network and the Ethereum Mainnet.
Expand All @@ -59,14 +56,9 @@ Responsibilities and roles of the bridge:
- listen for `UserRequestForAffirmation` or `Transfer` (depending on the bridge mode) events on the Foreign Bridge and send approval to Home Bridge to relay assets from Foreign Network to Home
- **User** role:
- sends assets to Bridge contracts:
- in `NATIVE-TO-ERC` mode: send native coins to the Home Bridge to receive ERC20 tokens from the Foreign Bridge, send ERC20 tokens to the Foreign Bridge to unlock native coins from the Home Bridge;
- in `ERC-TO-ERC` mode: transfer ERC20 tokens to the Foreign Bridge to mint ERC20 tokens on the Home Network, transfer ERC20 tokens to the Home Bridge to unlock ERC20 tokens on Foreign networks;
- in `ERC-TO-NATIVE` mode: send ERC20 tokens to the Foreign Bridge to receive native coins from the Home Bridge, send native coins to the Home Bridge to unlock ERC20 tokens from the Foreign Bridge;
- in `ARBITRARY-MESSAGE` mode: Invoke Home/Foreign Bridge to send a message that will be executed on the other Network as an arbitrary contract method invocation;
- in `AMB-ERC-TO-ERC` mode: transfer ERC20 tokens to the Foreign Mediator which will interact with Foreign AMB Bridge to mint ERC20 tokens on the Home Network, transfer ERC20 tokens to the Home Mediator which will interact with Home AMB Bridge to unlock ERC20 tokens on Foreign network.
- in `AMB-NATIVE-TO-ERC` mode: send native coins to the Home Mediator which will interact with Home AMB Bridge to mint ERC20 tokens on the Foreign Network, transfer ERC20 tokens to the Foreign Mediator which will interact with Foreign AMB Bridge to unlock native coins from Home network.
- in `AMB-ERC-TO-NATIVE` mode: send ERC20 tokens to the Foreign Mediator which will interact with Foreign AMB Bridge to receive native coins from the Home Mediator on the Home Network, send native coins to the Home Mediator which will interact with Home AMB Bridge to unlock ERC20 tokens from the Foreign Mediator.
- in `MULTI-AMB-ERC-TO-ERC` mode: transfer any ERC20/ERC677 tokens to the Foreign Mediator which will interact with Foreign AMB Bridge to mint ERC677 tokens on the Home Network, transfer ERC677 tokens to the Home Mediator which will interact with Home AMB Bridge to unlock associated ERC20/ERC677 tokens on the Foreign network.

## Usage

Expand Down Expand Up @@ -166,17 +158,6 @@ or with Docker:
./deploy.sh token
```

For testing bridge scripts in ERC20-to-NATIVE mode, you can deploy an interest receiver to the foreign network.
This can be done by running the following command:
```bash
cd deploy
node testenv-deploy.js interestReceiver
```
or with Docker:
```bash
./deploy.sh interestReceiver
```

## Contributing

See the [CONTRIBUTING](CONTRIBUTING.md) document for contribution, testing and pull request protocol.
Expand Down
58 changes: 0 additions & 58 deletions REWARD_MANAGEMENT.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
# Reward Management

## NATIVE-TO-ERC
Configuration:
```
HOME_REWARDABLE=ONE_DIRECTION
FOREIGN_REWARDABLE=ONE_DIRECTION
```
### Home to Foreign transfer
Fees are calculated and distributed on Foreign network. Validators will receive ERC20 tokens.
![native-erc-hometoforeign](https://user-images.githubusercontent.com/4614574/51607402-4bda6180-1ef3-11e9-91e3-50fe5d35d296.png)

### Foreign to Home transfer
Fees are calculated and distributed on Home network. Validators will receive native coins.
![native-erc-foreigntohome](https://user-images.githubusercontent.com/4614574/51607428-5d236e00-1ef3-11e9-8083-3669899c7252.png)

## NATIVE-TO-ERC - Fees collected on Home network only
Configuration:
```
HOME_REWARDABLE=BOTH_DIRECTIONS
FOREIGN_REWARDABLE=false
```
### Home to Foreign transfer
Fees are calculated and distributed on Home network. Validators will receive native coins.
![native-erc-homefee-hometoforeign](https://user-images.githubusercontent.com/4614574/53118155-43456d00-352b-11e9-80db-53e31494e09b.png)

### Foreign to Home transfer
Fees are calculated and distributed on Home network. Validators will receive native coins.
![native-erc-homefee-foreigntohome](https://user-images.githubusercontent.com/4614574/53118176-4b9da800-352b-11e9-8118-123f30e37d61.png)

## ERC-TO-NATIVE - Fees distributed among bridge validators
Configuration:
```
Expand Down Expand Up @@ -57,33 +29,3 @@ Fees are calculated and distributed on Home network. Validators will receive nat
### Home to Foreign transfer
Fees are calculated and distributed on Home network. Validators will receive native coins.
![POSDAO-ERC-Native-HomeToForeign](https://user-images.githubusercontent.com/4614574/59941982-f750f900-9434-11e9-8557-a90d9dfa6799.png)

## ERC-TO-ERC
Configuration:
```
HOME_REWARDABLE=BOTH_DIRECTIONS
FOREIGN_REWARDABLE=false
```
### Foreign to Home transfer
Fees are calculated and distributed on Home network. Validators will receive ERC20 tokens.
![ERC-ERC-ForeignToHome](https://user-images.githubusercontent.com/4614574/59939650-016ff900-942f-11e9-9593-9861455c7b62.png)

### Home to Foreign transfer
Fees are calculated and distributed on Home network. Validators will receive ERC20 tokens.
![ERC-ERC-HomeToForeign](https://user-images.githubusercontent.com/4614574/59939670-0cc32480-942f-11e9-9693-727125555c97.png)

## AMB-NATIVE-TO-ERC
Configuration:
```
HOME_REWARDABLE=ONE_DIRECTION
FOREIGN_REWARDABLE=ONE_DIRECTION
```
### Home to Foreign transfer
Fees are calculated and distributed on Foreign network. The reward accounts will receive ERC20 tokens.
![AMB-NATIVE-TO-ERC677-Home-Foreign](https://user-images.githubusercontent.com/4614574/74660965-dd0f1c80-5175-11ea-8d6c-51b8bd85f844.png)

### Foreign to Home transfer
Fees are calculated and distributed on Home network. The reward accounts will receive native tokens.
![AMB-NATIVE-TO-ERC677-Foreign-Home](https://user-images.githubusercontent.com/4614574/74660986-e6988480-5175-11ea-9216-7f008a6fdaf0.png)


10 changes: 10 additions & 0 deletions contracts/interfaces/ICToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity 0.4.24;

interface ICToken {
function mint(uint256 mintAmount) external returns (uint256);
function redeemUnderlying(uint256 redeemAmount) external returns (uint256);
function balanceOf(address account) external view returns (uint256);
function balanceOfUnderlying(address account) external view returns (uint256);
function borrow(uint256 borrowAmount) external returns (uint256);
function repayBorrow(uint256 borrowAmount) external returns (uint256);
}
15 changes: 0 additions & 15 deletions contracts/interfaces/IChai.sol

This file was deleted.

5 changes: 5 additions & 0 deletions contracts/interfaces/IComptroller.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma solidity 0.4.24;

interface IComptroller {
function claimComp(address[] holders, address[] cTokens, bool borrowers, bool suppliers) external;
}
5 changes: 5 additions & 0 deletions contracts/interfaces/IInterestReceiver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma solidity 0.4.24;

interface IInterestReceiver {
function onInterestReceived(address _token) external;
}
7 changes: 0 additions & 7 deletions contracts/interfaces/IPot.sol

This file was deleted.

15 changes: 15 additions & 0 deletions contracts/interfaces/IUniswapRouterV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity 0.4.24;

interface IUniswapRouterV2 {
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] path,
address to,
uint256 deadline
) external returns (uint256[] amounts);
function swapExactTokensForETH(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline)
external
returns (uint256[] amounts);
function getAmountsOut(uint256 amountIn, address[] path) external view returns (uint256[] memory amounts);
}
138 changes: 0 additions & 138 deletions contracts/libraries/TokenReader.sol

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/mocks/BlockRewardWithoutSystem.sol

This file was deleted.

Loading

0 comments on commit 7edfe77

Please sign in to comment.