Skip to content

Commit

Permalink
deployed with new events
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Jul 4, 2023
1 parent 07836f0 commit 527a90a
Show file tree
Hide file tree
Showing 28 changed files with 26,969 additions and 24,436 deletions.
156 changes: 156 additions & 0 deletions broadcast/Deploy.s.sol/5/run-1688514034.json

Large diffs are not rendered by default.

294 changes: 294 additions & 0 deletions broadcast/Deploy.s.sol/5/run-1688514065.json

Large diffs are not rendered by default.

294 changes: 294 additions & 0 deletions broadcast/Deploy.s.sol/5/run-1688514196.json

Large diffs are not rendered by default.

204 changes: 102 additions & 102 deletions broadcast/Deploy.s.sol/5/run-latest.json

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions contracts/DefifaDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {
/// @notice The amount of $DEFIFA and $BASE_PROTOCOL tokens this game was allocated from paying the network fee.
/// @return defifaTokenAllocation The $DEFIFA token allocation.
/// @return baseProtocolTokenAllocation The $BASE_PROTOCOL token allocation.
function tokenAllocations() public view returns (uint256 defifaTokenAllocation, uint256 baseProtocolTokenAllocation) {
function tokenAllocations()
public
view
returns (uint256 defifaTokenAllocation, uint256 baseProtocolTokenAllocation)
{
// Get a reference to the pakced token allocation.
uint256 _packed = _packedTokenAllocation;

Expand All @@ -321,7 +325,9 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {
// Return the values.
defifaTokenAllocation =
(_defifaTokenAllocation != 0) ? _defifaTokenAllocation : defifaToken.balanceOf(address(this));
baseProtocolTokenAllocation = (_baseProtocolTokenAllocation != 0) ? _baseProtocolTokenAllocation : baseProtocolToken.balanceOf(address(this));
baseProtocolTokenAllocation = (_baseProtocolTokenAllocation != 0)
? _baseProtocolTokenAllocation
: baseProtocolToken.balanceOf(address(this));
}

/// @notice Part of IJBFundingCycleDataSource, this function gets called when a project's token holders redeem.
Expand Down Expand Up @@ -425,7 +431,8 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {

// The amount of $DEFIFA and $BASE_PROTOCOL to send is the same proportion as the amount being redeemed to the total pot before any amount redeemed.
defifaTokenAmount = PRBMath.mulDiv(_defifaTokenAllocation, _cumulativePrice, _pot + amountRedeemed);
baseProtocolTokenAmount = PRBMath.mulDiv(_baseProtocolTokenAllocation, _cumulativePrice, _pot + amountRedeemed);
baseProtocolTokenAmount =
PRBMath.mulDiv(_baseProtocolTokenAllocation, _cumulativePrice, _pot + amountRedeemed);
}
}

Expand Down Expand Up @@ -650,6 +657,8 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {

// Mark the redemption weight as set.
redemptionWeightIsSet = true;

emit TierRedemptionWeightsSet(_tierWeights, msg.sender);
}

/// @notice Part of IJBRedeemDelegate, this function gets called when the token holder redeems. It will burn the specified NFTs to reclaim from the treasury to the _data.beneficiary.
Expand Down Expand Up @@ -707,8 +716,8 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {
if (_isComplete) {
amountRedeemed += _data.reclaimedAmount.value;

// Claim any $DEFIFA tokens available.
_claimDefifaTokensFor(_data.holder, _decodedTokenIds);
// Claim any $DEFIFA and $BASE_PROTOCOL tokens available.
_claimTokensFor(_data.holder, _decodedTokenIds);
}
}

Expand Down Expand Up @@ -988,7 +997,7 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {
/// @notice Claim $DEFIFA and $BASE_PROTOCOL tokens to an account for a certain redeemed amount.
/// @param _beneficiary The beneficiary of the $DEFIFA tokens.
/// @param _tokenIds The IDs of the tokens being redeemed that are justifying a $DEFIFA claim.
function _claimDefifaTokensFor(address _beneficiary, uint256[] memory _tokenIds) internal {
function _claimTokensFor(address _beneficiary, uint256[] memory _tokenIds) internal {
// Set the amount of total $DEFIFA token allocation if it hasn't been set yet.
if (_packedTokenAllocation == 0) {
uint256 _packed;
Expand All @@ -1006,6 +1015,8 @@ contract DefifaDelegate is JB721Delegate, Ownable, IDefifaDelegate {
// Send the tokens.
defifaToken.transfer(_beneficiary, _defifaTokenAmount);
baseProtocolToken.transfer(_beneficiary, _baseProtocolTokenAmount);

emit ClaimedTokens(_beneficiary, _defifaTokenAmount, _baseProtocolTokenAmount, msg.sender);
}

/// @notice User the hook to register the first owner if it's not yet registered.
Expand Down
14 changes: 6 additions & 8 deletions contracts/DefifaDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam

// Check for no contest.
if (_noContestInevitable(_gameId, _currentFundingCycle)) {
emit QueuedNoContest(_gameId, msg.sender);
return _queueNoContest(_gameId, _metadata.dataSource);
}

Expand All @@ -444,8 +445,10 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam

// Queue the next phase of the game.
if (_currentFundingCycle.number == 1 && _opsOf[_gameId].refundPeriodDuration != 0) {
emit QueuedRefundPhase(_gameId, msg.sender);
return _queueRefundPhase(_gameId, _metadata.dataSource);
} else {
emit QueuedScoringPhase(_gameId, msg.sender);
return _queueGamePhase(_gameId, _metadata.dataSource);
}
}
Expand Down Expand Up @@ -668,7 +671,8 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
}

// Get a reference to any unclaimed base protocol tokens.
uint256 _unclaimedBaseProtocolTokens = controller.tokenStore().unclaimedBalanceOf(address(this), baseProtocolProjectId);
uint256 _unclaimedBaseProtocolTokens =
controller.tokenStore().unclaimedBalanceOf(address(this), baseProtocolProjectId);

// Claim any $JBX that's unclaimed.
if (_unclaimedBaseProtocolTokens != 0) {
Expand All @@ -690,13 +694,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
fulfilledCommitmentsOf[_gameId] = _pot - _leftoverAmount;

emit FulfilledCommitments(
_gameId,
_pot,
_splits,
_leftoverAmount,
_defifaTokenBalance,
_baseProtocolBalance,
msg.sender
_gameId, _pot, _splits, _leftoverAmount, _defifaTokenBalance, _baseProtocolBalance, msg.sender
);
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/DefifaGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {

// Store the packed value.
_packedScorecardInfoOf[_gameId] = _packed;

emit GameInitialized(_gameId, _attestationStartTime, _attestationGracePeriod, msg.sender);
}

//*********************************************************************//
Expand Down
2 changes: 1 addition & 1 deletion contracts/forge-test/SVG.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract SVGTest is Test {
}

event K(bytes4 k);

function testWithTierImage() public {
emit K(type(IDefifaDelegate).interfaceId);
IDefifaDelegate _delegate =
Expand Down Expand Up @@ -164,6 +165,5 @@ contract SVGTest is Test {
bytes memory res = vm.ffi(inputs);
res;
vm.ffi(inputs);

}
}
6 changes: 6 additions & 0 deletions contracts/interfaces/IDefifaDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ interface IDefifaDelegate is IJB721Delegate {

event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

event ClaimedTokens(
address indexed beneficiary, uint256 defifaTokenAmount, uint256 baseProtocolTokenAmount, address caller
);

event TierRedemptionWeightsSet(DefifaTierRedemptionWeight[] _tierWeights, address caller);

function TOTAL_REDEMPTION_WEIGHT() external view returns (uint256);

function defifaToken() external view returns (IERC20);
Expand Down
22 changes: 14 additions & 8 deletions contracts/interfaces/IDefifaDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,28 @@ interface IDefifaDeployer {
address caller
);

event QueuedRefundPhase(uint256 indexed gameId, address caller);

event QueuedScoringPhase(uint256 indexed gameId, address caller);

event QueuedNoContest(uint256 indexed gameId, address caller);

event FulfilledCommitments(
uint256 indexed gameId,
uint256 pot,
JBSplit[] splits,
uint256 leftoverAmount,
uint256 defifaTokenBalance,
uint256 baseProtocolBalance,
address caller
uint256 indexed gameId,
uint256 pot,
JBSplit[] splits,
uint256 leftoverAmount,
uint256 defifaTokenBalance,
uint256 baseProtocolBalance,
address caller
);

event DistributeToSplit(JBSplit split, uint256 amount, address caller);

function splitGroup() external view returns (uint256);

function defifaProjectId() external view returns (uint256);

function baseProtocolProjectId() external view returns (uint256);

function delegateCodeOrigin() external view returns (address);
Expand Down
4 changes: 4 additions & 0 deletions contracts/interfaces/IDefifaGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {DefifaTierRedemptionWeight} from "../structs/DefifaTierRedemptionWeight.
import {IDefifaDelegate} from "./IDefifaDelegate.sol";

interface IDefifaGovernor {
event GameInitialized(
uint256 indexed gameId, uint256 attestationStartTime, uint256 attestationGracePeriod, address caller
);

event ScorecardSubmitted(
uint256 indexed gameId,
uint256 indexed scorecardId,
Expand Down
9,734 changes: 5,031 additions & 4,703 deletions out/DefifaDelegate.sol/DefifaDelegate.json

Large diffs are not rendered by default.

11,850 changes: 6,111 additions & 5,739 deletions out/DefifaDeployer.sol/DefifaDeployer.json

Large diffs are not rendered by default.

Loading

0 comments on commit 527a90a

Please sign in to comment.