gn-contract 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.openzeppelin/bsc-testnet.json +1847 -0
- package/.prettierrc +15 -0
- package/README.md +14 -0
- package/constants/getter.ts +4 -0
- package/constants/rootAddress.ts +22 -0
- package/contracts/CROWD.sol +32 -0
- package/contracts/CUSDT.sol +32 -0
- package/contracts/NFT.sol +499 -0
- package/contracts/NFTFounder.sol +254 -0
- package/contracts/NFTGenesis.sol +337 -0
- package/contracts/Network.sol +503 -0
- package/contracts/Swap.sol +86 -0
- package/contracts/USDT.sol +32 -0
- package/contracts/lib/AccessControl.sol +35 -0
- package/contracts/lib/NFTGetter.sol +60 -0
- package/contracts/lib/NFTHelpers.sol +111 -0
- package/contracts/lib/ValhallaBlackList.sol +18 -0
- package/contracts/lib/ValhallaPool.sol +44 -0
- package/hardhat.config.ts +44 -0
- package/package.json +50 -0
- package/scripts/DeployNetwork.ts +123 -0
- package/scripts/DeploySwap.ts +57 -0
- package/scripts/DeployUSDT.ts +16 -0
- package/test/Swap.test.ts +182 -0
- package/test/lib/initializer.ts +193 -0
- package/test/nft_genesis.test.ts +399 -0
- package/test/nft_purchase.test.ts +210 -0
- package/test/rank_distribution.test.ts +142 -0
- package/test/registration.test.ts +267 -0
- package/test/registration_reward.test.ts +114 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
import "./ValhallaPool.sol";
|
|
5
|
+
|
|
6
|
+
struct Card {
|
|
7
|
+
bool isMintable;
|
|
8
|
+
uint price;
|
|
9
|
+
uint halfingPercentage;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
struct CardGenesis {
|
|
13
|
+
uint price;
|
|
14
|
+
uint genesisPercentage;
|
|
15
|
+
uint totalMinted;
|
|
16
|
+
uint maxMinted;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
struct CardsRewardGenesis {
|
|
20
|
+
uint ownedNfts;
|
|
21
|
+
uint currentRewards;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
struct CardFounder {
|
|
25
|
+
uint price;
|
|
26
|
+
uint totalMinted;
|
|
27
|
+
uint maxMinted;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct CardsRewardFounder {
|
|
31
|
+
uint ownedNfts;
|
|
32
|
+
uint currentRewards;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
struct OwnedToken {
|
|
36
|
+
bool isBlackListed;
|
|
37
|
+
uint cardId;
|
|
38
|
+
uint percentage;
|
|
39
|
+
uint lastFarmedAt;
|
|
40
|
+
uint mintedAt;
|
|
41
|
+
uint mintingPrice;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
contract NFTGetter {
|
|
45
|
+
mapping(uint => OwnedToken) public tokenToCardMap;
|
|
46
|
+
mapping(uint => Card) public cardMap;
|
|
47
|
+
mapping(address => uint) public totalValueMap;
|
|
48
|
+
mapping(address => uint) public farmReward;
|
|
49
|
+
|
|
50
|
+
function startClaimingRankReward() external {}
|
|
51
|
+
|
|
52
|
+
function stopClaimingRankReward() external {}
|
|
53
|
+
|
|
54
|
+
function amountNftTypes() external view returns (uint) {}
|
|
55
|
+
|
|
56
|
+
function percentageByNftType(uint nftType) external view returns (uint) {}
|
|
57
|
+
|
|
58
|
+
function distributeGenesisRewards(uint typePool, uint value) external {}
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
library NFTHelpers {
|
|
5
|
+
function getRandomFarmPercentage(
|
|
6
|
+
uint256 rand
|
|
7
|
+
) internal pure returns (uint256) {
|
|
8
|
+
if (rand >= 0 && rand <= 699) {
|
|
9
|
+
return 5;
|
|
10
|
+
}
|
|
11
|
+
if (rand > 699 && rand <= 900) {
|
|
12
|
+
return 6;
|
|
13
|
+
}
|
|
14
|
+
if (rand > 900 && rand <= 991) {
|
|
15
|
+
return 7;
|
|
16
|
+
}
|
|
17
|
+
if (rand > 991 && rand <= 996) {
|
|
18
|
+
return 8;
|
|
19
|
+
}
|
|
20
|
+
if (rand > 996 && rand <= 998) {
|
|
21
|
+
return 10;
|
|
22
|
+
}
|
|
23
|
+
if (rand == 999) {
|
|
24
|
+
return 15;
|
|
25
|
+
}
|
|
26
|
+
return 8;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function calculateFarmValue(
|
|
30
|
+
uint mintedAt,
|
|
31
|
+
uint lastFarmedAt,
|
|
32
|
+
uint percentage,
|
|
33
|
+
uint price,
|
|
34
|
+
uint halfingPercentage
|
|
35
|
+
) internal view returns (uint256) {
|
|
36
|
+
uint dayInSec = 86400;
|
|
37
|
+
if (block.timestamp > mintedAt + dayInSec * 450) return 0;
|
|
38
|
+
|
|
39
|
+
uint baseReward = (price * percentage) / 1000;
|
|
40
|
+
uint rewardPerSec = baseReward / dayInSec;
|
|
41
|
+
uint farmValue = (block.timestamp - lastFarmedAt) * rewardPerSec;
|
|
42
|
+
return (farmValue * halfingPercentage) / 100;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getReferrerMatchingPercentage(
|
|
46
|
+
uint level,
|
|
47
|
+
uint8 rank,
|
|
48
|
+
uint totalValue,
|
|
49
|
+
uint decimals
|
|
50
|
+
) internal pure returns (uint) {
|
|
51
|
+
if (level >= 1 && level <= 5 && totalValue >= 5000 * 10 ** decimals) {
|
|
52
|
+
return 5;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
level >= 6 &&
|
|
57
|
+
level <= 10 &&
|
|
58
|
+
rank >= 1 &&
|
|
59
|
+
totalValue >= 25_000 * 10 ** decimals
|
|
60
|
+
) {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
level >= 11 &&
|
|
66
|
+
level <= 20 &&
|
|
67
|
+
rank >= 2 &&
|
|
68
|
+
totalValue >= 100_000 * 10 ** decimals
|
|
69
|
+
) {
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (
|
|
74
|
+
level >= 21 &&
|
|
75
|
+
level <= 40 &&
|
|
76
|
+
rank >= 3 &&
|
|
77
|
+
totalValue >= 500_000 * 10 ** decimals
|
|
78
|
+
) {
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
level >= 41 &&
|
|
84
|
+
level <= 60 &&
|
|
85
|
+
rank >= 4 &&
|
|
86
|
+
totalValue >= 2_500_000 * 10 ** decimals
|
|
87
|
+
) {
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
level >= 61 &&
|
|
93
|
+
level <= 80 &&
|
|
94
|
+
rank >= 5 &&
|
|
95
|
+
totalValue >= 10_000_000 * 10 ** decimals
|
|
96
|
+
) {
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (
|
|
101
|
+
level >= 81 &&
|
|
102
|
+
level <= 100 &&
|
|
103
|
+
rank == 6 &&
|
|
104
|
+
totalValue >= 50_000_000 * 10 ** decimals
|
|
105
|
+
) {
|
|
106
|
+
return 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
abstract contract ValhallaBlackList {
|
|
5
|
+
mapping(address => bool) public blacklistedAddressMap;
|
|
6
|
+
|
|
7
|
+
modifier notInBlacklist() {
|
|
8
|
+
require(
|
|
9
|
+
blacklistedAddressMap[msg.sender] != true,
|
|
10
|
+
"Address blacklisted"
|
|
11
|
+
);
|
|
12
|
+
_;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function addToBlacklistMap(address addr) internal {
|
|
16
|
+
blacklistedAddressMap[addr] = true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
struct PoolType {
|
|
5
|
+
uint claimable;
|
|
6
|
+
uint valueLeft;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
abstract contract ValhallaPool {
|
|
10
|
+
// pool key definition
|
|
11
|
+
bytes32 public constant GLOBAL_POOL_KEY = keccak256("GLOBAL_POOL");
|
|
12
|
+
bytes32 public constant RESERVED_POOL_KEY = keccak256("RESERVED_POOL");
|
|
13
|
+
bytes32 public constant IPO_POOL_KEY = keccak256("IPO_POOL");
|
|
14
|
+
bytes32 public constant GENESIS_POOL_KEY = keccak256("GENESIS_POOL");
|
|
15
|
+
|
|
16
|
+
mapping(bytes32 => PoolType) public poolMap;
|
|
17
|
+
|
|
18
|
+
function _storeGlobalPool(uint value) internal {
|
|
19
|
+
PoolType storage global_pool = poolMap[GLOBAL_POOL_KEY];
|
|
20
|
+
global_pool.claimable += value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getGlobalPool() public view returns (PoolType memory) {
|
|
24
|
+
return poolMap[GLOBAL_POOL_KEY];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _storeIpoPool(uint value) internal {
|
|
28
|
+
PoolType storage ipo_pool = poolMap[IPO_POOL_KEY];
|
|
29
|
+
ipo_pool.claimable += value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getIpoPool() public view returns (PoolType memory) {
|
|
33
|
+
return poolMap[IPO_POOL_KEY];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _storeGenesisPool(uint value) internal {
|
|
37
|
+
PoolType storage genesisPool = poolMap[GENESIS_POOL_KEY];
|
|
38
|
+
genesisPool.claimable += value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getGenesisPool() public view returns (PoolType memory) {
|
|
42
|
+
return poolMap[GENESIS_POOL_KEY];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as dotenv from "dotenv";
|
|
2
|
+
|
|
3
|
+
import { HardhatUserConfig } from "hardhat/config";
|
|
4
|
+
import "@nomicfoundation/hardhat-toolbox";
|
|
5
|
+
import "@openzeppelin/hardhat-upgrades";
|
|
6
|
+
|
|
7
|
+
dotenv.config();
|
|
8
|
+
|
|
9
|
+
const config: HardhatUserConfig = {
|
|
10
|
+
solidity: {
|
|
11
|
+
compilers: [
|
|
12
|
+
{
|
|
13
|
+
version: "0.8.17",
|
|
14
|
+
settings: {
|
|
15
|
+
optimizer: {
|
|
16
|
+
enabled: true,
|
|
17
|
+
runs: 200,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
defaultNetwork: "hardhat",
|
|
24
|
+
mocha: {
|
|
25
|
+
timeout: 100000000,
|
|
26
|
+
},
|
|
27
|
+
networks: {
|
|
28
|
+
testnet: {
|
|
29
|
+
url: "https://data-seed-prebsc-1-s1.bnbchain.org:8545",
|
|
30
|
+
accounts: {
|
|
31
|
+
mnemonic: process.env.MNEMONIC ?? "",
|
|
32
|
+
},
|
|
33
|
+
gasPrice: 10000000000,
|
|
34
|
+
},
|
|
35
|
+
mainnet: {
|
|
36
|
+
url: "https://bsc-dataseed.bnbchain.org",
|
|
37
|
+
accounts: {
|
|
38
|
+
mnemonic: process.env.MNEMONIC ?? "",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default config;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gn-contract",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"packageManager": "pnpm@10.20.0",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@ethersproject/abi": "^5.7.0",
|
|
15
|
+
"@ethersproject/bytes": "^5.0.0",
|
|
16
|
+
"@ethersproject/providers": "^5.7.2",
|
|
17
|
+
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
|
|
18
|
+
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
|
|
19
|
+
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
|
|
20
|
+
"@nomiclabs/hardhat-ethers": "^2.2.1",
|
|
21
|
+
"@nomiclabs/hardhat-etherscan": "^3.1.2",
|
|
22
|
+
"@nomiclabs/hardhat-ganache": "^2.0.1",
|
|
23
|
+
"@typechain/ethers-v5": "^10.1.1",
|
|
24
|
+
"@typechain/hardhat": "^6.1.4",
|
|
25
|
+
"@types/chai": "^4.3.4",
|
|
26
|
+
"@types/mocha": "^9.1.1",
|
|
27
|
+
"@types/node": "^18.11.9",
|
|
28
|
+
"chai": "^4.3.7",
|
|
29
|
+
"ethers": "^5.7.2",
|
|
30
|
+
"evm-bn": "^1.1.2",
|
|
31
|
+
"hardhat": "^2.12.2",
|
|
32
|
+
"hardhat-gas-reporter": "^1.0.9",
|
|
33
|
+
"prettier": "^3.7.4",
|
|
34
|
+
"prettier-plugin-solidity": "^2.2.0",
|
|
35
|
+
"semantic-release": "^19.0.2",
|
|
36
|
+
"solidity-coverage": "^0.8.2",
|
|
37
|
+
"ts-node": "^10.9.1",
|
|
38
|
+
"typechain": "^8.1.1",
|
|
39
|
+
"typescript": "^4.9.3"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@openzeppelin/contracts": "^4.8.0",
|
|
43
|
+
"@openzeppelin/contracts-upgradeable": "^4.8.0",
|
|
44
|
+
"@openzeppelin/hardhat-upgrades": "^1.21.0",
|
|
45
|
+
"dotenv": "^16.0.3"
|
|
46
|
+
},
|
|
47
|
+
"volta": {
|
|
48
|
+
"node": "18.16.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ethers, upgrades } from "hardhat";
|
|
2
|
+
import {
|
|
3
|
+
feeReceiverAddress,
|
|
4
|
+
feeReceiverAddress2,
|
|
5
|
+
reserveAddress,
|
|
6
|
+
rootAdressList,
|
|
7
|
+
} from "../constants/rootAddress";
|
|
8
|
+
import { getter } from "../constants/getter";
|
|
9
|
+
import { toBn } from "evm-bn";
|
|
10
|
+
|
|
11
|
+
const main = async () => {
|
|
12
|
+
const [admin] = await ethers.getSigners();
|
|
13
|
+
console.log("Deploying contracts with account:", admin.address);
|
|
14
|
+
|
|
15
|
+
// 1. Deploy CROWD Token
|
|
16
|
+
const CROWDContract = await ethers.getContractFactory("CROWD");
|
|
17
|
+
const crowd = await CROWDContract.connect(admin).deploy();
|
|
18
|
+
await crowd.connect(admin).deployed();
|
|
19
|
+
console.log("CROWD deployed to:", crowd.address);
|
|
20
|
+
|
|
21
|
+
const CUSDTContract = await ethers.getContractFactory("CUSDT");
|
|
22
|
+
const cusdt = await CUSDTContract.connect(admin).deploy();
|
|
23
|
+
await cusdt.connect(admin).deployed();
|
|
24
|
+
console.log("CUSDT deployed to:", cusdt.address);
|
|
25
|
+
|
|
26
|
+
// 2. Deploy Network (Valhalla)
|
|
27
|
+
const ValhallaContract = await ethers.getContractFactory("Network");
|
|
28
|
+
const valhalla = (await upgrades.deployProxy(
|
|
29
|
+
ValhallaContract,
|
|
30
|
+
[
|
|
31
|
+
admin.address,
|
|
32
|
+
rootAdressList,
|
|
33
|
+
feeReceiverAddress,
|
|
34
|
+
feeReceiverAddress2,
|
|
35
|
+
reserveAddress,
|
|
36
|
+
0,
|
|
37
|
+
toBn("10", 18), // Registration fee: 50 USDT (18 decimals)
|
|
38
|
+
],
|
|
39
|
+
{ kind: "transparent" }
|
|
40
|
+
)) as any;
|
|
41
|
+
await valhalla.connect(admin).deployed();
|
|
42
|
+
console.log("Network (Valhalla) deployed to:", valhalla.address);
|
|
43
|
+
|
|
44
|
+
// 3. Deploy NFT
|
|
45
|
+
const NFTContract = await ethers.getContractFactory("NFT");
|
|
46
|
+
const nft = (await upgrades.deployProxy(NFTContract, [crowd.address, valhalla.address], {
|
|
47
|
+
kind: "transparent",
|
|
48
|
+
})) as any;
|
|
49
|
+
await nft.connect(admin).deployed();
|
|
50
|
+
console.log("NFT deployed to:", nft.address);
|
|
51
|
+
|
|
52
|
+
// 4. Deploy NFTGenesis
|
|
53
|
+
// Note: Using a placeholder receiver address if not defined in getter, or use admin
|
|
54
|
+
const genesisReceiver = admin.address;
|
|
55
|
+
const NFTGenesiscontract = await ethers.getContractFactory("NFTGenesis");
|
|
56
|
+
const nftGenesis = (await upgrades.deployProxy(
|
|
57
|
+
NFTGenesiscontract,
|
|
58
|
+
[crowd.address, cusdt.address, nft.address, valhalla.address, genesisReceiver],
|
|
59
|
+
{ kind: "transparent" }
|
|
60
|
+
)) as any;
|
|
61
|
+
await nftGenesis.connect(admin).deployed();
|
|
62
|
+
console.log("NFTGenesis deployed to:", nftGenesis.address);
|
|
63
|
+
|
|
64
|
+
// 5. Deploy NFTFounder
|
|
65
|
+
const NFTFounderContract = await ethers.getContractFactory("NFTFounder");
|
|
66
|
+
const nftFounder = (await upgrades.deployProxy(
|
|
67
|
+
NFTFounderContract,
|
|
68
|
+
[
|
|
69
|
+
getter.usdt.address,
|
|
70
|
+
valhalla.address,
|
|
71
|
+
genesisReceiver, // Using same receiver for founder
|
|
72
|
+
],
|
|
73
|
+
{ kind: "transparent" }
|
|
74
|
+
)) as any;
|
|
75
|
+
await nftFounder.connect(admin).deployed();
|
|
76
|
+
console.log("NFTFounder deployed to:", nftFounder.address);
|
|
77
|
+
|
|
78
|
+
// --- Configuration ---
|
|
79
|
+
|
|
80
|
+
console.log("Configuring contracts...");
|
|
81
|
+
|
|
82
|
+
const tx = await crowd.setMinterContract(nft.address);
|
|
83
|
+
await tx.wait();
|
|
84
|
+
console.log("CROWD minter set to NFT");
|
|
85
|
+
|
|
86
|
+
const tx2 = await valhalla.connect(admin).setNftAddress(nft.address);
|
|
87
|
+
await tx2.wait();
|
|
88
|
+
console.log("Network NFT address set");
|
|
89
|
+
|
|
90
|
+
const tx3 = await valhalla.connect(admin).setCRWDAddress(crowd.address);
|
|
91
|
+
await tx3.wait();
|
|
92
|
+
console.log("Network CROWD address set");
|
|
93
|
+
|
|
94
|
+
const tx4 = await nft.setNFTGenesis(nftGenesis.address);
|
|
95
|
+
await tx4.wait();
|
|
96
|
+
console.log("NFT Genesis address set");
|
|
97
|
+
|
|
98
|
+
const tx5 = await valhalla.connect(admin).setCUSDAddress(cusdt.address);
|
|
99
|
+
await tx5.wait();
|
|
100
|
+
console.log("Network Payment Token (CUSDT) set");
|
|
101
|
+
|
|
102
|
+
const tx6 = await valhalla.connect(admin).setNFTFounderAddress(nftFounder.address);
|
|
103
|
+
await tx6.wait();
|
|
104
|
+
console.log("Network NFTFounder address set");
|
|
105
|
+
|
|
106
|
+
// Set receiver2 for NFTFounder if needed (optional based on logic)
|
|
107
|
+
// const tx7 = await nftFounder.setReceiverAddress2(receiverAddress2);
|
|
108
|
+
// await tx7.wait();
|
|
109
|
+
|
|
110
|
+
console.table({
|
|
111
|
+
valhalla: valhalla.address,
|
|
112
|
+
nft: nft.address,
|
|
113
|
+
nftGenesis: nftGenesis.address,
|
|
114
|
+
nftFounder: nftFounder.address,
|
|
115
|
+
crowd: crowd.address,
|
|
116
|
+
cusdt: cusdt.address,
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
main().catch((e) => {
|
|
121
|
+
console.log(e);
|
|
122
|
+
process.exitCode = 1;
|
|
123
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ethers, upgrades } from "hardhat";
|
|
2
|
+
import {
|
|
3
|
+
feeReceiverAddress,
|
|
4
|
+
feeReceiverAddress2,
|
|
5
|
+
} from "../constants/rootAddress";
|
|
6
|
+
import { getter } from "../constants/getter";
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const [deployer] = await ethers.getSigners();
|
|
10
|
+
console.log("Deploying contracts with the account:", deployer.address);
|
|
11
|
+
|
|
12
|
+
// 1. Deploy CROWD Token
|
|
13
|
+
console.log("Deploying CROWD...");
|
|
14
|
+
const CROWDFactory = await ethers.getContractFactory("CROWD");
|
|
15
|
+
const crowd = await CROWDFactory.deploy();
|
|
16
|
+
await crowd.deployed();
|
|
17
|
+
console.log("CROWD deployed to:", crowd.address);
|
|
18
|
+
|
|
19
|
+
// 2. Deploy CUSDT Token
|
|
20
|
+
console.log("Deploying CUSDT...");
|
|
21
|
+
const CUSDTFactory = await ethers.getContractFactory("CUSDT");
|
|
22
|
+
const cusdt = await CUSDTFactory.deploy();
|
|
23
|
+
await cusdt.deployed();
|
|
24
|
+
console.log("CUSDT deployed to:", cusdt.address);
|
|
25
|
+
|
|
26
|
+
// 3. Deploy Swap Contract
|
|
27
|
+
console.log("Deploying Swap...");
|
|
28
|
+
const SwapFactory = await ethers.getContractFactory("Swap");
|
|
29
|
+
// Arguments: _usdt, _cusdt, _crowd, _feeReceiver, _feeMarketing
|
|
30
|
+
const swap = await upgrades.deployProxy(
|
|
31
|
+
SwapFactory,
|
|
32
|
+
[
|
|
33
|
+
getter.usdt.address,
|
|
34
|
+
cusdt.address,
|
|
35
|
+
crowd.address,
|
|
36
|
+
feeReceiverAddress,
|
|
37
|
+
feeReceiverAddress2,
|
|
38
|
+
],
|
|
39
|
+
{ kind: "uups" },
|
|
40
|
+
);
|
|
41
|
+
await swap.deployed();
|
|
42
|
+
console.log("Swap deployed to:", swap.address);
|
|
43
|
+
|
|
44
|
+
// Verification Log
|
|
45
|
+
console.table({
|
|
46
|
+
Deployer: deployer.address,
|
|
47
|
+
CROWD: crowd.address,
|
|
48
|
+
CUSDT: cusdt.address,
|
|
49
|
+
Swap: swap.address,
|
|
50
|
+
USDT: getter.usdt.address,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
main().catch((error) => {
|
|
55
|
+
console.error(error);
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ethers, upgrades } from "hardhat";
|
|
2
|
+
|
|
3
|
+
const main = async () => {
|
|
4
|
+
const [admin] = await ethers.getSigners();
|
|
5
|
+
console.log("Deploying contracts with account:", admin.address);
|
|
6
|
+
|
|
7
|
+
const USDTContract = await ethers.getContractFactory("USDT");
|
|
8
|
+
const usdt = await USDTContract.connect(admin).deploy();
|
|
9
|
+
await usdt.connect(admin).deployed();
|
|
10
|
+
console.log("USDT deployed at", usdt.address);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
main().catch((e) => {
|
|
14
|
+
console.log(e);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
});
|