Skip to content

Polygon #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: bsc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0b8909a
BatchMining
Dec 7, 2021
f3d7273
Batch close
Dec 8, 2021
4422a28
Complete
Dec 8, 2021
e2f2890
Complete Test
Dec 9, 2021
2fa187a
Optimize code
Dec 9, 2021
27885d9
Merger takeToken0 and takeToken1
Dec 9, 2021
d9a4ca2
Multiple prices can be queried at one time
Dec 9, 2021
27d5d99
Fix bug
Dec 9, 2021
102cc74
Add comment
Dec 9, 2021
3e7b516
Test query price
Dec 11, 2021
22109b7
Add interface INestBatchPrice2
Dec 11, 2021
532ec77
Organize code directory
Dec 11, 2021
6c24322
Deploy to rinkeby
Dec 11, 2021
cc56560
Check equivalent
Dec 14, 2021
b2c8223
Test
Dec 14, 2021
7a90e9b
Optimize code
Dec 14, 2021
f09a693
Arrange code
Dec 14, 2021
51d7d11
Rearrange fields
Dec 15, 2021
e9b032b
Rename tmp to shares
Dec 15, 2021
5d18ec4
Use uint128
Dec 16, 2021
f96b562
Optimize code
Dec 16, 2021
62936e3
Deploy to rinkeby
Dec 16, 2021
664444a
Prepare for deploy
Dec 17, 2021
4c651e2
Prepare for deploy
Dec 17, 2021
8e4f12f
Fix bug
Dec 18, 2021
aa9043c
Deploy to mainnet
Dec 18, 2021
abde2db
Change open method
Dec 20, 2021
9024abd
Rename governance to opener
Dec 21, 2021
93a3564
Update README.md
JacksonComing Dec 22, 2021
b107e43
Optimize code
Dec 23, 2021
b0ccc6d
Extract custom parts
Jan 8, 2022
c02250e
Prepare for mumbai
Jan 10, 2022
9e2f368
Deploy to mumbai
Jan 11, 2022
6f64c31
Add proxyAdmin address
Jan 15, 2022
f37ea5c
Add polygon_main
Jan 19, 2022
a6dd9cd
Fix bug
Jan 19, 2022
a0ce922
Add deploy script
Jan 19, 2022
f45cc83
Prepare for deploy
Jan 19, 2022
019c90c
Add open script
Jan 19, 2022
d2573de
Prepare for deploy
Jan 20, 2022
8c37915
Deploy to mainnet
Jan 21, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
opensrc
.openzeppelin
.openzeppelin-
#Hardhat files
cache
artifacts
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,29 @@ npx truffle migrate --network ropsten

## Contract Addresses

### 2022-01-21@polygon_main

| Name | Interfaces | polygon_main |
| ---- | ---- | ---- |
| nest | IERC20 | 0x98f8669F6481EbB341B522fCD3663f79A3d1A6A7 |
| pusd | IERC20 | 0xf26D86043a3133Cc042221Ea178cAED7Fe0eE362 |
| peth | IERC20 | 0x1E0967e10B5Ef10342d4D71da69c30332666C899 |
| nestGovernance | INestGovernance | 0x7b5ee1Dc65E2f3EDf41c798e7bd3C22283C3D4bb |
| nestLedger | INestLedger | 0x7DBe94A4D6530F411A1E7337c7eb84185c4396e6 |
| nestBatchMining | INestBatchMining, INestBatchPrice2, INestBatchPriceView | 0x09CE0e021195BA2c1CDE62A8B187abf810951540 |

### 2021-12-18@mainnet
| Name | Interfaces | mainnet |
| ---- | ---- | ---- |
| nest | IERC20 | 0x04abEdA201850aC0124161F037Efd70c74ddC74C |
| usdt | IERC20 | 0xdAC17F958D2ee523a2206206994597C13D831ec7 |
| hbtc | IERC20 | 0x0316EB71485b0Ab14103307bf65a021042c6d380 |
| pusd | IERC20 | 0xCCEcC702Ec67309Bc3DDAF6a42E9e5a6b8Da58f0 |
| nestGovernance | INestGovernance | 0xA2eFe217eD1E56C743aeEe1257914104Cf523cf5 |
| nestBatchPlatform2 | INestBatchMining, INestBatchPriceView, INestBatchPrice2 | 0xE544cF993C7d477C7ef8E91D28aCA250D135aa03 |

### 2021-11-20@bsc_main
| Name | Interfaces | rinkeby |
| Name | Interfaces | bsc_main |
| ---- | ---- | ---- |
| nest | IERC20 | 0x98f8669F6481EbB341B522fCD3663f79A3d1A6A7 |
| pusd | IERC20 | 0x9b2689525e07406D8A6fB1C40a1b86D2cd34Cbb2 |
Expand Down
4 changes: 2 additions & 2 deletions contracts/NToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity ^0.8.6;

import "./interface/INToken.sol";
import "./interface/INestGovernance.sol";
import "./interfaces/INToken.sol";
import "./interfaces/INestGovernance.sol";
import "./NestBase.sol";

// The contract is based on Nest_NToken from Nest Protocol v3.0. Considering compatibility, the interface
Expand Down
57 changes: 22 additions & 35 deletions contracts/NestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,44 @@

pragma solidity ^0.8.6;

import "./lib/TransferHelper.sol";
import "./interface/INestGovernance.sol";
import "./interface/INestLedger.sol";
import "./libs/TransferHelper.sol";
import "./interfaces/INestGovernance.sol";
import "./interfaces/INestLedger.sol";

/// @dev Base contract of nest
contract NestBase {

// Address of nest token contract
address constant NEST_TOKEN_ADDRESS = 0x98f8669F6481EbB341B522fCD3663f79A3d1A6A7;

// Genesis block number of nest
// NEST token contract is created at block height 6913517. However, because the mining algorithm of nest1.0
// is different from that at present, a new mining algorithm is adopted from nest2.0. The new algorithm
// includes the attenuation logic according to the block. Therefore, it is necessary to trace the block
// where the nest begins to decay. According to the circulation when nest2.0 is online, the new mining
// algorithm is used to deduce and convert the nest, and the new algorithm is used to mine the nest2.0
// on-line flow, the actual block is 5120000
//uint constant NEST_GENESIS_BLOCK = 0;

/// @dev To support open-zeppelin/upgrades
/// @param nestGovernanceAddress INestGovernance implementation contract address
function initialize(address nestGovernanceAddress) public virtual {
/// @param governance INestGovernance implementation contract address
function initialize(address governance) public virtual {
require(_governance == address(0), "NEST:!initialize");
_governance = nestGovernanceAddress;
_governance = governance;
}

/// @dev INestGovernance implementation contract address
address public _governance;

/// @dev Rewritten in the implementation contract, for load other contract addresses. Call
/// super.update(nestGovernanceAddress) when overriding, and override method without onlyGovernance
/// @param nestGovernanceAddress INestGovernance implementation contract address
function update(address nestGovernanceAddress) public virtual {

/// super.update(newGovernance) when overriding, and override method without onlyGovernance
/// @param newGovernance INestGovernance implementation contract address
function update(address newGovernance) public virtual {
address governance = _governance;
require(governance == msg.sender || INestGovernance(governance).checkGovernance(msg.sender, 0), "NEST:!gov");
_governance = nestGovernanceAddress;
_governance = newGovernance;
}

/// @dev Migrate funds from current contract to NestLedger
/// @param tokenAddress Destination token address.(0 means eth)
/// @param value Migrate amount
function migrate(address tokenAddress, uint value) external onlyGovernance {

address to = INestGovernance(_governance).getNestLedgerAddress();
if (tokenAddress == address(0)) {
INestLedger(to).addETHReward { value: value } (0);
} else {
TransferHelper.safeTransfer(tokenAddress, to, value);
}
}
// /// @dev Migrate funds from current contract to NestLedger
// /// @param tokenAddress Destination token address.(0 means eth)
// /// @param value Migrate amount
// function migrate(address tokenAddress, uint value) external onlyGovernance {

// address to = INestGovernance(_governance).getNestLedgerAddress();
// if (tokenAddress == address(0)) {
// INestLedger(to).addETHReward { value: value } (0);
// } else {
// TransferHelper.safeTransfer(tokenAddress, to, value);
// }
// }

//---------modifier------------

Expand Down
Loading