gn-contracts 1.0.0 → 1.0.2
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/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol/ERC20Burnable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol/AccessControlUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol/IAccessControlUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol/OwnableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol/IERC1967Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/interfaces/IERC4906Upgradeable.sol/IERC4906Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol/IERC1822ProxiableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol/ERC1967UpgradeUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol/IBeaconUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol/Initializable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol/UUPSUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol/ReentrancyGuardUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol/ERC721Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol/IERC721ReceiverUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol/IERC721Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol/ERC721EnumerableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol/ERC721URIStorageUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol/IERC721EnumerableUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol/IERC721MetadataUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol/AddressUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol/ContextUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol/CountersUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol/StorageSlotUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol/StringsUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol/ERC165Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol/IERC165Upgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol/MathUpgradeable.dbg.json +1 -1
- package/artifacts/@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol/SignedMathUpgradeable.dbg.json +1 -1
- package/artifacts/build-info/{5c571e0d4e969428dca2c8e1dbdb7c69.json → 44138e8f5cba15b8d9fb0b0302f6f9cc.json} +1 -1
- package/artifacts/contracts/CROWD.sol/CROWD.dbg.json +1 -1
- package/artifacts/contracts/CROWD.sol/CROWD.json +2 -2
- package/artifacts/contracts/CUSDT.sol/CUSDT.dbg.json +1 -1
- package/artifacts/contracts/CUSDT.sol/CUSDT.json +2 -2
- package/artifacts/contracts/NFT.sol/NFT.dbg.json +1 -1
- package/artifacts/contracts/NFT.sol/NFT.json +2 -2
- package/artifacts/contracts/NFTFounder.sol/NFTFounder.dbg.json +1 -1
- package/artifacts/contracts/NFTFounder.sol/NFTFounder.json +2 -2
- package/artifacts/contracts/NFTGenesis.sol/NFTGenesis.dbg.json +1 -1
- package/artifacts/contracts/NFTGenesis.sol/NFTGenesis.json +2 -2
- package/artifacts/contracts/Network.sol/Network.dbg.json +1 -1
- package/artifacts/contracts/Network.sol/Network.json +2 -2
- package/artifacts/contracts/Swap.sol/Swap.dbg.json +1 -1
- package/artifacts/contracts/Swap.sol/Swap.json +136 -47
- package/artifacts/contracts/USDT.sol/USDT.dbg.json +1 -1
- package/artifacts/contracts/USDT.sol/USDT.json +2 -2
- package/artifacts/contracts/lib/AccessControl.sol/AccessControl.dbg.json +1 -1
- package/artifacts/contracts/lib/NFTGetter.sol/NFTGetter.dbg.json +1 -1
- package/artifacts/contracts/lib/NFTHelpers.sol/NFTHelpers.dbg.json +1 -1
- package/artifacts/contracts/lib/ValhallaBlackList.sol/ValhallaBlackList.dbg.json +1 -1
- package/artifacts/contracts/lib/ValhallaPool.sol/ValhallaPool.dbg.json +1 -1
- package/contracts/CROWD.sol +2 -2
- package/contracts/CUSDT.sol +2 -2
- package/contracts/NFT.sol +53 -53
- package/contracts/Network.sol +4 -4
- package/contracts/Swap.sol +101 -14
- package/contracts/USDT.sol +2 -2
- package/package.json +1 -1
- package/typechain-types/contracts/Swap.ts +254 -98
- package/typechain-types/factories/contracts/CROWD__factory.ts +1 -1
- package/typechain-types/factories/contracts/CUSDT__factory.ts +1 -1
- package/typechain-types/factories/contracts/NFTFounder__factory.ts +1 -1
- package/typechain-types/factories/contracts/NFTGenesis__factory.ts +1 -1
- package/typechain-types/factories/contracts/NFT__factory.ts +1 -1
- package/typechain-types/factories/contracts/Network__factory.ts +1 -1
- package/typechain-types/factories/contracts/Swap__factory.ts +135 -46
- package/typechain-types/factories/contracts/USDT__factory.ts +1 -1
- package/artifacts/build-info/3b73b26b5bedaeb08a2c2823a85a9eb7.json +0 -1
- package/artifacts/build-info/b6798c83bba51d6a98d799cc7723db38.json +0 -1
package/contracts/NFT.sol
CHANGED
|
@@ -168,9 +168,8 @@ contract NFT is
|
|
|
168
168
|
|
|
169
169
|
function buy(uint cardId) public notInBlacklist {
|
|
170
170
|
bool is_registered;
|
|
171
|
-
Rank rank;
|
|
172
171
|
address directReferrer;
|
|
173
|
-
(is_registered, ,
|
|
172
|
+
(is_registered, , , directReferrer, , , , ) = valhalla.accountMap(
|
|
174
173
|
msg.sender
|
|
175
174
|
);
|
|
176
175
|
address feeReceiver = valhalla.feeReceiverAddress();
|
|
@@ -183,61 +182,57 @@ contract NFT is
|
|
|
183
182
|
require(_card.price > 0, "Invalid card");
|
|
184
183
|
require(_card.isMintable, "Card is not mintable");
|
|
185
184
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
185
|
+
uint distributeGenesis = (_card.price * 5) / 100;
|
|
186
|
+
uint globalPoolAmount = (_card.price * 17) / 100;
|
|
187
|
+
uint tax = (_card.price * 20) / 100;
|
|
188
|
+
uint halfTax = tax / 2;
|
|
189
|
+
uint burnAmount = (_card.price * 50) / 100;
|
|
190
|
+
uint referralReward = directReferrer != address(0) ? (_card.price * 8) / 100 : 0;
|
|
191
|
+
|
|
192
|
+
uint totalNeeded = _card.price;
|
|
193
|
+
|
|
194
|
+
require(
|
|
195
|
+
gnetERC20.allowance(msg.sender, address(this)) >= totalNeeded,
|
|
196
|
+
"Insufficient allowance"
|
|
197
|
+
);
|
|
198
|
+
require(
|
|
199
|
+
gnetERC20.balanceOf(msg.sender) >= totalNeeded,
|
|
200
|
+
"Insufficient balance"
|
|
201
|
+
);
|
|
195
202
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
uint256 tokenId = _tokenIdCounter.current();
|
|
204
|
+
OwnedToken storage _purchasedToken = ownedTokenMap[tokenId];
|
|
205
|
+
_purchasedToken.cardId = cardId;
|
|
206
|
+
_purchasedToken.mintingPrice = _card.price;
|
|
207
|
+
_purchasedToken.mintedAt = block.timestamp;
|
|
208
|
+
_purchasedToken.lastFarmedAt = block.timestamp;
|
|
209
|
+
_purchasedToken.percentage = _getRandomFarmPercentage();
|
|
210
|
+
|
|
211
|
+
_tokenIdCounter.increment();
|
|
212
|
+
|
|
213
|
+
_storeGlobalPool(globalPoolAmount);
|
|
214
|
+
|
|
215
|
+
_applyReferralReward(directReferrer, referralReward);
|
|
205
216
|
|
|
206
|
-
uint distributeGenesis = (_card.price * 5) / 100;
|
|
207
217
|
gnetERC20.transferFrom(
|
|
208
218
|
msg.sender,
|
|
209
219
|
address(this),
|
|
210
220
|
_card.price - distributeGenesis
|
|
211
221
|
);
|
|
212
222
|
|
|
213
|
-
_storeGlobalPool((_card.price * 17) / 100);
|
|
214
223
|
genesisPoolResolver(distributeGenesis);
|
|
215
|
-
|
|
216
|
-
uint halfTax = tax / 2;
|
|
217
|
-
// rewardMap[feeReceiver] += halfTax;
|
|
218
|
-
// rewardMap[feeReceiver2] += halfTax;
|
|
224
|
+
|
|
219
225
|
gnetERC20.transfer(feeReceiver, halfTax);
|
|
220
226
|
gnetERC20.transfer(feeReceiver2, halfTax);
|
|
221
|
-
|
|
227
|
+
|
|
228
|
+
gnetERC20.burn(burnAmount);
|
|
222
229
|
|
|
230
|
+
_safeMint(msg.sender, tokenId);
|
|
231
|
+
|
|
232
|
+
emit Buy(msg.sender, tokenId);
|
|
223
233
|
if (directReferrer != address(0)) {
|
|
224
|
-
uint referralReward = (_card.price * 8) / 100;
|
|
225
|
-
rewardMap[directReferrer] += referralReward;
|
|
226
|
-
referralRewardMap[directReferrer] += referralReward;
|
|
227
234
|
emit DirectReferralReward(directReferrer, msg.sender, referralReward);
|
|
228
235
|
}
|
|
229
|
-
|
|
230
|
-
uint256 tokenId = _tokenIdCounter.current();
|
|
231
|
-
OwnedToken storage _purchasedToken = ownedTokenMap[tokenId];
|
|
232
|
-
_purchasedToken.cardId = cardId;
|
|
233
|
-
_purchasedToken.mintingPrice = _card.price;
|
|
234
|
-
_purchasedToken.mintedAt = block.timestamp;
|
|
235
|
-
_purchasedToken.lastFarmedAt = block.timestamp;
|
|
236
|
-
_purchasedToken.percentage = _getRandomFarmPercentage();
|
|
237
|
-
|
|
238
|
-
_tokenIdCounter.increment();
|
|
239
|
-
_safeMint(msg.sender, tokenId);
|
|
240
|
-
emit Buy(msg.sender, tokenId);
|
|
241
236
|
}
|
|
242
237
|
|
|
243
238
|
function withdrawAllGenesisPool() public onlyOwner {
|
|
@@ -291,15 +286,22 @@ contract NFT is
|
|
|
291
286
|
);
|
|
292
287
|
}
|
|
293
288
|
|
|
289
|
+
function _applyReferralReward(address directReferrer, uint referralReward) private {
|
|
290
|
+
if (directReferrer != address(0) && referralReward > 0) {
|
|
291
|
+
rewardMap[directReferrer] += referralReward;
|
|
292
|
+
referralRewardMap[directReferrer] += referralReward;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
294
296
|
function farm(uint tokenId) public notInBlacklist {
|
|
295
297
|
require(ownerOf(tokenId) == msg.sender, "caller is not owner");
|
|
296
298
|
require(ownedTokenMap[tokenId].isBlackListed == false, "token blacklisted");
|
|
297
299
|
uint reward = getFarmValue(tokenId);
|
|
298
300
|
require(reward > 0, "No reward to farm");
|
|
299
301
|
uint tax = (reward * 10) / 100;
|
|
300
|
-
uint
|
|
301
|
-
gnetERC20.mintForFarm(
|
|
302
|
-
gnetERC20.mintForFarm(
|
|
302
|
+
uint halfTax = tax / 2;
|
|
303
|
+
gnetERC20.mintForFarm(halfTax, valhalla.feeReceiverAddress());
|
|
304
|
+
gnetERC20.mintForFarm(halfTax, valhalla.feeReceiverAddress2());
|
|
303
305
|
gnetERC20.mintForFarm(reward - tax, msg.sender);
|
|
304
306
|
|
|
305
307
|
Rank rank;
|
|
@@ -384,7 +386,7 @@ contract NFT is
|
|
|
384
386
|
distribution = superLegendRankDistribution;
|
|
385
387
|
base = (globalPool.claimable * 34) / 100;
|
|
386
388
|
}
|
|
387
|
-
|
|
389
|
+
if (distribution == 0) return 0;
|
|
388
390
|
return base / distribution;
|
|
389
391
|
}
|
|
390
392
|
|
|
@@ -407,13 +409,11 @@ contract NFT is
|
|
|
407
409
|
|
|
408
410
|
require(myReward > 0, "No Reward can be claimed");
|
|
409
411
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
);
|
|
416
|
-
}
|
|
412
|
+
if (rank != Rank.NoRank) {
|
|
413
|
+
require(
|
|
414
|
+
nftValue >= eligValue[uint(rank)] * 10 ** gnetERC20.decimals(),
|
|
415
|
+
"Not Eligible"
|
|
416
|
+
);
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
uint tax = (myReward * 10) / 100;
|
package/contracts/Network.sol
CHANGED
|
@@ -144,7 +144,7 @@ contract Network is
|
|
|
144
144
|
// for the sake of gas optimization
|
|
145
145
|
if (_account.rank == Rank.SuperLegend) return;
|
|
146
146
|
|
|
147
|
-
if (_account.downlineCount >=
|
|
147
|
+
if (_account.downlineCount >= 200000 && _account.rank == Rank.Legend) {
|
|
148
148
|
uint totalEligibleDirectRank = directLegendRankMap[_address] +
|
|
149
149
|
directSuperLegendRankMap[_address];
|
|
150
150
|
|
|
@@ -155,7 +155,7 @@ contract Network is
|
|
|
155
155
|
directLegendRankMap[_account.referrer] -= 1;
|
|
156
156
|
directSuperLegendRankMap[_account.referrer] += 1;
|
|
157
157
|
}
|
|
158
|
-
} else if (_account.downlineCount >=
|
|
158
|
+
} else if (_account.downlineCount >= 50000 && _account.rank == Rank.Epic) {
|
|
159
159
|
uint totalEligibleDirectRank = directEpicRankMap[_address] +
|
|
160
160
|
directLegendRankMap[_address] +
|
|
161
161
|
directSuperLegendRankMap[_address];
|
|
@@ -168,7 +168,7 @@ contract Network is
|
|
|
168
168
|
directLegendRankMap[_account.referrer] += 1;
|
|
169
169
|
}
|
|
170
170
|
} else if (
|
|
171
|
-
_account.downlineCount >=
|
|
171
|
+
_account.downlineCount >= 10000 && _account.rank == Rank.SuperRare
|
|
172
172
|
) {
|
|
173
173
|
uint totalEligibleDirectRank = directSuperRareRankMap[_address] +
|
|
174
174
|
directEpicRankMap[_address] +
|
|
@@ -182,7 +182,7 @@ contract Network is
|
|
|
182
182
|
directSuperRareRankMap[_account.referrer] -= 1;
|
|
183
183
|
directEpicRankMap[_account.referrer] += 1;
|
|
184
184
|
}
|
|
185
|
-
} else if (_account.downlineCount >=
|
|
185
|
+
} else if (_account.downlineCount >= 2000 && _account.rank == Rank.Rare) {
|
|
186
186
|
uint totalEligibleDirectRank = directRareRankMap[_address] +
|
|
187
187
|
directSuperRareRankMap[_address] +
|
|
188
188
|
directEpicRankMap[_address] +
|
package/contracts/Swap.sol
CHANGED
|
@@ -19,29 +19,35 @@ contract Swap is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
|
|
19
19
|
address _user,
|
|
20
20
|
uint _timeStamp
|
|
21
21
|
);
|
|
22
|
+
|
|
23
|
+
event AddLiquidity(
|
|
24
|
+
ERC20 indexed token,
|
|
25
|
+
uint amount,
|
|
26
|
+
uint timestamp
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
event RemoveLiquidity(
|
|
30
|
+
ERC20 indexed token,
|
|
31
|
+
uint amount,
|
|
32
|
+
uint timestamp
|
|
33
|
+
);
|
|
22
34
|
|
|
23
35
|
ERC20 public usdt;
|
|
24
36
|
ERC20 public cusdt;
|
|
25
37
|
ERC20 public crowd;
|
|
26
|
-
address public feeReceiver;
|
|
27
|
-
address public feeMarketing;
|
|
28
38
|
|
|
29
39
|
function initialize(
|
|
30
40
|
ERC20 _usdt,
|
|
31
41
|
ERC20 _cusdt,
|
|
32
|
-
ERC20 _crowd
|
|
33
|
-
address _feeReceiver,
|
|
34
|
-
address _feeMarketing
|
|
42
|
+
ERC20 _crowd
|
|
35
43
|
) public initializer {
|
|
36
44
|
__Ownable_init();
|
|
37
45
|
__UUPSUpgradeable_init();
|
|
38
46
|
usdt = _usdt;
|
|
39
47
|
cusdt = _cusdt;
|
|
40
48
|
crowd = _crowd;
|
|
41
|
-
feeReceiver = _feeReceiver;
|
|
42
|
-
feeMarketing = _feeMarketing;
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
|
|
45
51
|
function swapToCUSDT(uint _amount) public {
|
|
46
52
|
// USDT has 18 decimals. CUSDT has 18 decimals.
|
|
47
53
|
// 1:1 ratio.
|
|
@@ -64,23 +70,104 @@ contract Swap is Initializable, OwnableUpgradeable, UUPSUpgradeable {
|
|
|
64
70
|
crowd.transfer(msg.sender, crowdAmount);
|
|
65
71
|
emit SwapToken(usdt, crowd, _amount, msg.sender, block.timestamp);
|
|
66
72
|
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @notice Owner adds CUSDT liquidity to the pool
|
|
76
|
+
* @param _amount Amount of CUSDT to add
|
|
77
|
+
*/
|
|
78
|
+
function addLiquidityCUSDT(uint _amount) public onlyOwner {
|
|
79
|
+
require(_amount > 0, "Amount must be greater than 0");
|
|
80
|
+
|
|
81
|
+
cusdt.transferFrom(msg.sender, address(this), _amount);
|
|
82
|
+
|
|
83
|
+
emit AddLiquidity(cusdt, _amount, block.timestamp);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @notice Owner adds CROWD liquidity to the pool
|
|
88
|
+
* @param _amount Amount of CROWD to add
|
|
89
|
+
*/
|
|
90
|
+
function addLiquidityCROWD(uint _amount) public onlyOwner {
|
|
91
|
+
require(_amount > 0, "Amount must be greater than 0");
|
|
92
|
+
|
|
93
|
+
crowd.transferFrom(msg.sender, address(this), _amount);
|
|
94
|
+
|
|
95
|
+
emit AddLiquidity(crowd, _amount, block.timestamp);
|
|
96
|
+
}
|
|
67
97
|
|
|
68
|
-
|
|
69
|
-
|
|
98
|
+
/**
|
|
99
|
+
* @notice Owner removes CUSDT liquidity from the pool
|
|
100
|
+
* @param _amount Amount of CUSDT to remove
|
|
101
|
+
*/
|
|
102
|
+
function removeLiquidityCUSDT(uint _amount) public onlyOwner {
|
|
103
|
+
require(_amount > 0, "Amount must be greater than 0");
|
|
104
|
+
require(cusdt.balanceOf(address(this)) >= _amount, "Insufficient pool balance");
|
|
105
|
+
|
|
70
106
|
cusdt.transfer(msg.sender, _amount);
|
|
107
|
+
|
|
108
|
+
emit RemoveLiquidity(cusdt, _amount, block.timestamp);
|
|
71
109
|
}
|
|
72
110
|
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
/**
|
|
112
|
+
* @notice Owner removes CROWD liquidity from the pool
|
|
113
|
+
* @param _amount Amount of CROWD to remove
|
|
114
|
+
*/
|
|
115
|
+
function removeLiquidityCROWD(uint _amount) public onlyOwner {
|
|
116
|
+
require(_amount > 0, "Amount must be greater than 0");
|
|
117
|
+
require(crowd.balanceOf(address(this)) >= _amount, "Insufficient pool balance");
|
|
118
|
+
|
|
75
119
|
crowd.transfer(msg.sender, _amount);
|
|
120
|
+
|
|
121
|
+
emit RemoveLiquidity(crowd, _amount, block.timestamp);
|
|
76
122
|
}
|
|
77
123
|
|
|
124
|
+
/**
|
|
125
|
+
* @notice Owner removes USDT from the pool (accumulated from swaps)
|
|
126
|
+
* @param _amount Amount of USDT to remove
|
|
127
|
+
*/
|
|
78
128
|
function withdrawUSDT(uint _amount) public onlyOwner {
|
|
79
|
-
require(
|
|
129
|
+
require(_amount > 0, "Amount must be greater than 0");
|
|
130
|
+
require(usdt.balanceOf(address(this)) >= _amount, "Insufficient pool balance");
|
|
131
|
+
|
|
80
132
|
usdt.transfer(msg.sender, _amount);
|
|
81
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @notice Get pool balances for all tokens
|
|
137
|
+
*/
|
|
138
|
+
function getPoolBalances() public view returns (
|
|
139
|
+
uint usdtBalance,
|
|
140
|
+
uint cusdtBalance,
|
|
141
|
+
uint crowdBalance
|
|
142
|
+
) {
|
|
143
|
+
return (
|
|
144
|
+
usdt.balanceOf(address(this)),
|
|
145
|
+
cusdt.balanceOf(address(this)),
|
|
146
|
+
crowd.balanceOf(address(this))
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @notice Get CUSDT exchange rate
|
|
152
|
+
* @dev Returns how much CUSDT you get per 1 USDT (with 18 decimals)
|
|
153
|
+
* @return cusdtRate The amount of CUSDT per 1 USDT (1:1 ratio = 1e18)
|
|
154
|
+
*/
|
|
155
|
+
function getCusdtRate() public pure returns (uint cusdtRate) {
|
|
156
|
+
// 1 USDT = 1 CUSDT (1:1 ratio)
|
|
157
|
+
return 1e18; // 1 USDT (18 decimals) = 1 CUSDT (18 decimals)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @notice Get CROWD exchange rate
|
|
162
|
+
* @dev Returns how much CROWD you get per 1 USDT (with 18 decimals)
|
|
163
|
+
* @return crowdRate The amount of CROWD per 1 USDT (500 CROWD per USDT = 500e18)
|
|
164
|
+
*/
|
|
165
|
+
function getCrowdRate() public pure returns (uint crowdRate) {
|
|
166
|
+
// 1 USDT = 500 CROWD (or 1 CROWD = 0.002 USDT)
|
|
167
|
+
return 500e18; // 1 USDT (18 decimals) = 500 CROWD (18 decimals)
|
|
168
|
+
}
|
|
82
169
|
|
|
83
170
|
function _authorizeUpgrade(
|
|
84
171
|
address newImplementation
|
|
85
172
|
) internal override onlyOwner {}
|
|
86
|
-
}
|
|
173
|
+
}
|
package/contracts/USDT.sol
CHANGED
|
@@ -9,8 +9,8 @@ contract USDT is ERC20, ERC20Burnable, Ownable {
|
|
|
9
9
|
address public minterContract;
|
|
10
10
|
|
|
11
11
|
// this is not real name, please check the contract first before deploying !
|
|
12
|
-
constructor() ERC20("United
|
|
13
|
-
_mint(msg.sender,
|
|
12
|
+
constructor() ERC20("United States Dollar", "USDT") {
|
|
13
|
+
_mint(msg.sender, 1_000_000 * 10 ** 18);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function decimals() public pure override returns (uint8) {
|