@zoralabs/coins 0.3.1 → 0.5.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/test/Coin.t.sol CHANGED
@@ -10,19 +10,19 @@ contract CoinTest is BaseTest {
10
10
  _deployCoin();
11
11
  }
12
12
 
13
+ function test_contract_version() public view {
14
+ assertEq(coin.contractVersion(), "0.5.0");
15
+ }
16
+
13
17
  function test_supply_constants() public view {
14
- assertEq(MAX_TOTAL_SUPPLY, POOL_LAUNCH_SUPPLY + CREATOR_LAUNCH_REWARD + PLATFORM_REFERRER_LAUNCH_REWARD + PROTOCOL_LAUNCH_REWARD);
18
+ assertEq(MAX_TOTAL_SUPPLY, POOL_LAUNCH_SUPPLY + CREATOR_LAUNCH_REWARD);
15
19
 
16
20
  assertEq(MAX_TOTAL_SUPPLY, 1_000_000_000e18);
17
- assertEq(POOL_LAUNCH_SUPPLY, 980_000_000e18);
21
+ assertEq(POOL_LAUNCH_SUPPLY, 990_000_000e18);
18
22
  assertEq(CREATOR_LAUNCH_REWARD, 10_000_000e18);
19
- assertEq(PLATFORM_REFERRER_LAUNCH_REWARD, 5_000_000e18);
20
- assertEq(PROTOCOL_LAUNCH_REWARD, 5_000_000e18);
21
23
 
22
24
  assertEq(coin.totalSupply(), MAX_TOTAL_SUPPLY);
23
25
  assertEq(coin.balanceOf(coin.payoutRecipient()), CREATOR_LAUNCH_REWARD);
24
- assertEq(coin.balanceOf(coin.platformReferrer()), PLATFORM_REFERRER_LAUNCH_REWARD);
25
- assertEq(coin.balanceOf(coin.protocolRewardRecipient()), PROTOCOL_LAUNCH_REWARD);
26
26
  assertApproxEqAbs(coin.balanceOf(address(pool)), POOL_LAUNCH_SUPPLY, 1e18);
27
27
  }
28
28
 
@@ -187,6 +187,18 @@ contract CoinTest is BaseTest {
187
187
  coin.buy(users.coinRecipient, 100e6, 0, 0, users.tradeReferrer);
188
188
  }
189
189
 
190
+ function test_buy_validate_return_amounts(uint256 orderSize) public {
191
+ vm.assume(orderSize >= MIN_ORDER_SIZE);
192
+ vm.assume(orderSize < 10 ether);
193
+
194
+ vm.deal(users.buyer, orderSize);
195
+ vm.prank(users.buyer);
196
+ (uint256 amountIn, uint256 amountOut) = coin.buy{value: orderSize}(users.coinRecipient, orderSize, 0, 0, users.tradeReferrer);
197
+
198
+ assertEq(amountIn, orderSize, "amountIn");
199
+ assertGe(coin.balanceOf(users.coinRecipient), amountOut, "coinRecipient coin balance");
200
+ }
201
+
190
202
  function test_sell_for_eth() public {
191
203
  vm.deal(users.buyer, 1 ether);
192
204
  vm.prank(users.buyer);
@@ -266,6 +278,27 @@ contract CoinTest is BaseTest {
266
278
  coin.sell(users.coinRecipient, balance + 1, 0, 0, users.tradeReferrer);
267
279
  }
268
280
 
281
+ function test_sell_partial_execution() public {
282
+ vm.deal(users.creator, 1 ether);
283
+ vm.prank(users.creator);
284
+ coin.buy{value: 0.001 ether}(users.creator, 0.001 ether, 0, 0, users.tradeReferrer);
285
+
286
+ uint256 beforeBalance = coin.balanceOf(users.creator);
287
+ assertEq(beforeBalance, 10438320330337104517114132); // 10,438,320 coins
288
+
289
+ vm.prank(users.creator);
290
+ (uint256 amountSold, ) = coin.sell(users.creator, beforeBalance, 0, 0, users.tradeReferrer);
291
+ assertEq(amountSold, 442747808421317694054680); // 442,747 coins (max that could be sold)
292
+
293
+ uint256 afterBalance = coin.balanceOf(users.creator);
294
+ assertEq(afterBalance, 9997786260957893411529725); // 9,997,786 coins
295
+
296
+ uint256 expectedMarketReward = 2213739042106588470273; // 2,213 coins
297
+
298
+ // 9,997,786 = 10,438,320 order size - 442,747 true order size + 2,213 creator market reward
299
+ assertEq(afterBalance, ((beforeBalance - amountSold) + expectedMarketReward), "amountSold");
300
+ }
301
+
269
302
  function test_burn() public {
270
303
  vm.deal(users.buyer, 1 ether);
271
304
  vm.prank(users.buyer);
@@ -463,8 +496,4 @@ contract CoinTest is BaseTest {
463
496
  vm.expectRevert(abi.encodeWithSelector(MultiOwnable.OnlyOwner.selector));
464
497
  coin.setPayoutRecipient(newPayoutRecipient);
465
498
  }
466
-
467
- function test_contract_version() public view {
468
- assertEq(coin.contractVersion(), "0.3.1");
469
- }
470
499
  }
@@ -54,9 +54,7 @@ contract FactoryTest is BaseTest {
54
54
  assertEq(coin.currency(), address(weth), "currency");
55
55
  assertEq(coin.totalSupply(), 1_000_000_000e18, "totalSupply");
56
56
  assertEq(coin.balanceOf(users.creator), 10_000_000e18, "balanceOf creator");
57
- assertGe(coin.balanceOf(users.platformReferrer), 5_000_000e18, "balanceOf platformReferrer");
58
- assertGe(coin.balanceOf(users.feeRecipient), 5_000_000e18, "balanceOf protocolRewardRecipient");
59
- assertGt(coin.balanceOf(coin.poolAddress()), 979_999_983e18, "balanceOf pool");
57
+ assertGt(coin.balanceOf(coin.poolAddress()), 989_999_999e18, "balanceOf pool");
60
58
  }
61
59
 
62
60
  function test_deploy_with_eth(uint256 initialOrderSize) public {