@ballkidz/defifa 0.0.8 → 0.0.10
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/ARCHITECTURE.md +2 -0
- package/README.md +1 -1
- package/package.json +6 -6
- package/src/DefifaDeployer.sol +4 -0
- package/src/DefifaGovernor.sol +1 -0
- package/src/DefifaHook.sol +3 -2
- package/test/DefifaGovernor.t.sol +6 -8
- package/test/DefifaNoContest.t.sol +1 -3
- package/test/DefifaSecurity.t.sol +1 -3
- package/test/DefifaUSDC.t.sol +1 -2
- package/test/Fork.t.sol +1 -3
package/ARCHITECTURE.md
CHANGED
|
@@ -75,6 +75,8 @@ Attestor → DefifaGovernor.attestToScorecard(proposalId)
|
|
|
75
75
|
- `@bananapus/721-hook-v6` — NFT tier system
|
|
76
76
|
- `@bananapus/address-registry-v6` — Deterministic deploys
|
|
77
77
|
- `@bananapus/permission-ids-v6` — Permission constants
|
|
78
|
+
- `@croptop/core-v6` — Croptop integration
|
|
79
|
+
- `@rev-net/core-v6` — Revnet integration
|
|
78
80
|
- `@openzeppelin/contracts` — Checkpoints, Ownable, Clones
|
|
79
81
|
- `@prb/math` — mulDiv
|
|
80
82
|
- `scripty.sol` — On-chain scripting for SVG
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ballkidz/defifa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.0.0"
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"url": "https://github.com/BallKidz/defifa-collection-deployer"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@bananapus/721-hook-v6": "^0.0.
|
|
17
|
-
"@bananapus/address-registry-v6": "^0.0.
|
|
18
|
-
"@bananapus/core-v6": "^0.0.
|
|
16
|
+
"@bananapus/721-hook-v6": "^0.0.19",
|
|
17
|
+
"@bananapus/address-registry-v6": "^0.0.11",
|
|
18
|
+
"@bananapus/core-v6": "^0.0.24",
|
|
19
19
|
"@bananapus/permission-ids-v6": "^0.0.10",
|
|
20
|
-
"@croptop/core-v6": "^0.0.
|
|
20
|
+
"@croptop/core-v6": "^0.0.20",
|
|
21
21
|
"@openzeppelin/contracts": "^5.6.1",
|
|
22
22
|
"@prb/math": "^4.1.1",
|
|
23
|
-
"@rev-net/core-v6": "^0.0.
|
|
23
|
+
"@rev-net/core-v6": "^0.0.15",
|
|
24
24
|
"scripty.sol": "^2.1.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
package/src/DefifaDeployer.sol
CHANGED
|
@@ -345,12 +345,14 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
|
|
|
345
345
|
// Payout failed — fee stays in pot. Reset to sentinel (1) so currentGamePotOf
|
|
346
346
|
// doesn't double-count the fee, while preserving the reentrancy guard.
|
|
347
347
|
fulfilledCommitmentsOf[gameId] = 1;
|
|
348
|
+
// slither-disable-next-line reentrancy-events
|
|
348
349
|
emit CommitmentPayoutFailed({gameId: gameId, amount: _feeAmount, reason: reason});
|
|
349
350
|
}
|
|
350
351
|
|
|
351
352
|
// Queue the final ruleset and emit.
|
|
352
353
|
_queueFinalRuleset({gameId: gameId, metadata: _metadata});
|
|
353
354
|
|
|
355
|
+
// slither-disable-next-line reentrancy-events
|
|
354
356
|
emit FulfilledCommitments({gameId: gameId, pot: _pot, caller: msg.sender});
|
|
355
357
|
}
|
|
356
358
|
|
|
@@ -543,6 +545,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
|
|
|
543
545
|
// Add the hook to the registry, contract nonce starts at 1
|
|
544
546
|
REGISTRY.registerAddress({deployer: address(this), nonce: _currentNonce});
|
|
545
547
|
|
|
548
|
+
// slither-disable-next-line reentrancy-events
|
|
546
549
|
emit LaunchGame(gameId, _hook, GOVERNOR, _uriResolver, msg.sender);
|
|
547
550
|
}
|
|
548
551
|
|
|
@@ -619,6 +622,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
|
|
|
619
622
|
projectId: gameId, rulesetConfigurations: rulesetConfigs, memo: "Defifa game: no contest."
|
|
620
623
|
});
|
|
621
624
|
|
|
625
|
+
// slither-disable-next-line reentrancy-events
|
|
622
626
|
emit QueuedNoContest(gameId, msg.sender);
|
|
623
627
|
}
|
|
624
628
|
|
package/src/DefifaGovernor.sol
CHANGED
|
@@ -174,6 +174,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
174
174
|
// handles sendPayoutsOf failures, ensuring the final ruleset is always queued.
|
|
175
175
|
IDefifaDeployer(CONTROLLER.PROJECTS().ownerOf(gameId)).fulfillCommitmentsOf(gameId);
|
|
176
176
|
|
|
177
|
+
// slither-disable-next-line reentrancy-events
|
|
177
178
|
emit ScorecardRatified(gameId, scorecardId, msg.sender);
|
|
178
179
|
}
|
|
179
180
|
|
package/src/DefifaHook.sol
CHANGED
|
@@ -284,8 +284,9 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
284
284
|
|
|
285
285
|
// Use this contract as the only cash out hook.
|
|
286
286
|
hookSpecifications = new JBCashOutHookSpecification[](1);
|
|
287
|
-
hookSpecifications[0] =
|
|
288
|
-
|
|
287
|
+
hookSpecifications[0] = JBCashOutHookSpecification({
|
|
288
|
+
hook: this, noop: false, amount: 0, metadata: abi.encode(_cumulativeMintPrice)
|
|
289
|
+
});
|
|
289
290
|
|
|
290
291
|
// Compute the cash out count based on the game phase.
|
|
291
292
|
cashOutCount = DefifaHookLib.computeCashOutCount({
|
|
@@ -558,8 +558,7 @@ contract DefifaGovernorTest is JBTest, TestBaseWorkflow {
|
|
|
558
558
|
)
|
|
559
559
|
internal
|
|
560
560
|
{
|
|
561
|
-
uint256 _pot = jbMultiTerminal()
|
|
562
|
-
.currentSurplusOf(_projectId, jbMultiTerminal().accountingContextsOf(_projectId), 18, JBCurrencyIds.ETH);
|
|
561
|
+
uint256 _pot = jbMultiTerminal().currentSurplusOf(_projectId, new address[](0), 18, JBCurrencyIds.ETH);
|
|
563
562
|
// Assert that the deployer did *NOT* receive any fee tokens.
|
|
564
563
|
assertEq(IERC20(_protocolFeeProjectTokenAccount).balanceOf(address(deployer)), 0);
|
|
565
564
|
assertEq(IERC20(_defifaProjectTokenAccount).balanceOf(address(deployer)), 0);
|
|
@@ -569,8 +568,8 @@ contract DefifaGovernorTest is JBTest, TestBaseWorkflow {
|
|
|
569
568
|
_verifySingleCashOut(_projectId, _nft, scorecards[i], _users[i], _pot, _sumDistribution, distribution, i);
|
|
570
569
|
}
|
|
571
570
|
// All NFTs should have been redeemed, only some dust should be left
|
|
572
|
-
uint256 remainingSurplus =
|
|
573
|
-
.currentSurplusOf(_projectId,
|
|
571
|
+
uint256 remainingSurplus =
|
|
572
|
+
jbMultiTerminal().currentSurplusOf(_projectId, new address[](0), 18, JBCurrencyIds.ETH);
|
|
574
573
|
uint256 _expected = _pot * (_nft.TOTAL_CASHOUT_WEIGHT() - assignedCashOutWeight) / _nft.TOTAL_CASHOUT_WEIGHT();
|
|
575
574
|
assertApproxEqAbs(remainingSurplus, _expected, 10 ** 14);
|
|
576
575
|
|
|
@@ -884,8 +883,7 @@ contract DefifaGovernorTest is JBTest, TestBaseWorkflow {
|
|
|
884
883
|
_governor.ratifyScorecardFrom(_gameId, scorecards);
|
|
885
884
|
vm.warp(block.timestamp + 1);
|
|
886
885
|
|
|
887
|
-
uint256 _pot = jbMultiTerminal()
|
|
888
|
-
.currentSurplusOf(_projectId, jbMultiTerminal().accountingContextsOf(_projectId), 18, JBCurrencyIds.ETH);
|
|
886
|
+
uint256 _pot = jbMultiTerminal().currentSurplusOf(_projectId, new address[](0), 18, JBCurrencyIds.ETH);
|
|
889
887
|
|
|
890
888
|
// Verify that the cashOutWeights actually changed
|
|
891
889
|
for (uint256 i = 0; i < _users.length; i++) {
|
|
@@ -932,8 +930,8 @@ contract DefifaGovernorTest is JBTest, TestBaseWorkflow {
|
|
|
932
930
|
}
|
|
933
931
|
// All NFTs should have been redeemed, only some dust should be left
|
|
934
932
|
// Max allowed dust is 0.0001
|
|
935
|
-
uint256 remainingSurplus =
|
|
936
|
-
.currentSurplusOf(_projectId,
|
|
933
|
+
uint256 remainingSurplus =
|
|
934
|
+
jbMultiTerminal().currentSurplusOf(_projectId, new address[](0), 18, JBCurrencyIds.ETH);
|
|
937
935
|
assertApproxEqAbs(
|
|
938
936
|
remainingSurplus, _pot * (totalCashOutWeight - assignedCashOutWeight) / totalCashOutWeight, 10 ** 14
|
|
939
937
|
);
|
|
@@ -892,9 +892,7 @@ contract DefifaNoContestTest is JBTest, TestBaseWorkflow {
|
|
|
892
892
|
}
|
|
893
893
|
|
|
894
894
|
function _surplus() internal view returns (uint256) {
|
|
895
|
-
return
|
|
896
|
-
jbMultiTerminal()
|
|
897
|
-
.currentSurplusOf(_pid, jbMultiTerminal().accountingContextsOf(_pid), 18, JBCurrencyIds.ETH);
|
|
895
|
+
return jbMultiTerminal().currentSurplusOf(_pid, new address[](0), 18, JBCurrencyIds.ETH);
|
|
898
896
|
}
|
|
899
897
|
|
|
900
898
|
function _cashOut(address user, uint256 tid, uint256 tnum) internal {
|
|
@@ -678,9 +678,7 @@ contract DefifaSecurityTest is JBTest, TestBaseWorkflow {
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
function _surplus() internal view returns (uint256) {
|
|
681
|
-
return
|
|
682
|
-
jbMultiTerminal()
|
|
683
|
-
.currentSurplusOf(_pid, jbMultiTerminal().accountingContextsOf(_pid), 18, JBCurrencyIds.ETH);
|
|
681
|
+
return jbMultiTerminal().currentSurplusOf(_pid, new address[](0), 18, JBCurrencyIds.ETH);
|
|
684
682
|
}
|
|
685
683
|
|
|
686
684
|
function _cashOut(address user, uint256 tid, uint256 tnum) internal {
|
package/test/DefifaUSDC.t.sol
CHANGED
|
@@ -306,8 +306,7 @@ contract DefifaUSDCTest is JBTest, TestBaseWorkflow {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
function _surplus() internal view returns (uint256) {
|
|
309
|
-
return jbMultiTerminal()
|
|
310
|
-
.currentSurplusOf(_pid, jbMultiTerminal().accountingContextsOf(_pid), 6, uint32(uint160(address(usdc))));
|
|
309
|
+
return jbMultiTerminal().currentSurplusOf(_pid, new address[](0), 6, uint32(uint160(address(usdc))));
|
|
311
310
|
}
|
|
312
311
|
|
|
313
312
|
function _generateTokenId(uint256 tierId, uint256 tokenNumber) internal pure returns (uint256) {
|
package/test/Fork.t.sol
CHANGED
|
@@ -2325,9 +2325,7 @@ contract DefifaForkTest is JBTest, TestBaseWorkflow {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
|
|
2327
2327
|
function _surplus() internal view returns (uint256) {
|
|
2328
|
-
return
|
|
2329
|
-
jbMultiTerminal()
|
|
2330
|
-
.currentSurplusOf(_pid, jbMultiTerminal().accountingContextsOf(_pid), 18, JBCurrencyIds.ETH);
|
|
2328
|
+
return jbMultiTerminal().currentSurplusOf(_pid, new address[](0), 18, JBCurrencyIds.ETH);
|
|
2331
2329
|
}
|
|
2332
2330
|
|
|
2333
2331
|
function _balance() internal view returns (uint256) {
|