Skip to content

Commit

Permalink
Merge pull request #258 from Kwenta/format-codebase
Browse files Browse the repository at this point in the history
✨ prettify
  • Loading branch information
Flocqst authored Sep 3, 2024
2 parents 0a14321 + 5407e50 commit 685a7bb
Show file tree
Hide file tree
Showing 34 changed files with 446 additions and 657 deletions.
15 changes: 3 additions & 12 deletions contracts/EscrowDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ contract EscrowDistributor {
/// @notice kwenta token contract
IERC20 public immutable kwenta;

event BatchEscrowed(
uint256 totalAccounts,
uint256 totalTokens,
uint256 durationWeeks
);
event BatchEscrowed(uint256 totalAccounts, uint256 totalTokens, uint256 durationWeeks);

constructor(address kwentaAddr, address rewardEscrowAddr) {
kwenta = IERC20(kwentaAddr);
Expand All @@ -36,8 +32,7 @@ contract EscrowDistributor {
uint256 durationWeeks
) external {
require(
accounts.length == amounts.length,
"Number of accounts does not match number of values"
accounts.length == amounts.length, "Number of accounts does not match number of values"
);

uint256 length = accounts.length;
Expand All @@ -60,11 +55,7 @@ contract EscrowDistributor {
unchecked {
--length;
}
rewardEscrow.createEscrowEntry(
accounts[length],
amounts[length],
duration
);
rewardEscrow.createEscrowEntry(accounts[length], amounts[length], duration);
} while (length != 0);

emit BatchEscrowed({
Expand Down
29 changes: 7 additions & 22 deletions contracts/EscrowedMultipleMerkleDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import "./interfaces/IEscrowedMultipleMerkleDistributor.sol";
/// @title Kwenta EscrowedMultipleMerkleDistributor
/// @author JaredBorders and JChiaramonte7
/// @notice Facilitates trading incentives distribution over multiple periods.
contract EscrowedMultipleMerkleDistributor is
IEscrowedMultipleMerkleDistributor,
Owned
{
contract EscrowedMultipleMerkleDistributor is IEscrowedMultipleMerkleDistributor, Owned {
/// @inheritdoc IEscrowedMultipleMerkleDistributor
address public immutable override rewardEscrow;

Expand All @@ -31,29 +28,19 @@ contract EscrowedMultipleMerkleDistributor is
/// @param _owner: designated owner of this contract
/// @param _token: address of erc20 token to be distributed
/// @param _rewardEscrow: address of kwenta escrow for tokens claimed
constructor(
address _owner,
address _token,
address _rewardEscrow
) Owned(_owner) {
constructor(address _owner, address _token, address _rewardEscrow) Owned(_owner) {
token = _token;
rewardEscrow = _rewardEscrow;
}

/// @inheritdoc IEscrowedMultipleMerkleDistributor
function setMerkleRootForEpoch(
bytes32 merkleRoot,
uint256 epoch
) external override onlyOwner {
function setMerkleRootForEpoch(bytes32 merkleRoot, uint256 epoch) external override onlyOwner {
merkleRoots[epoch] = merkleRoot;
emit MerkleRootModified(epoch);
}

/// @inheritdoc IEscrowedMultipleMerkleDistributor
function isClaimed(
uint256 index,
uint256 epoch
) public view override returns (bool) {
function isClaimed(uint256 index, uint256 epoch) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMaps[epoch][claimedWordIndex];
Expand All @@ -68,8 +55,7 @@ contract EscrowedMultipleMerkleDistributor is
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMaps[epoch][claimedWordIndex] =
claimedBitMaps[epoch][claimedWordIndex] |
(1 << claimedBitIndex);
claimedBitMaps[epoch][claimedWordIndex] | (1 << claimedBitIndex);
}

/// @inheritdoc IEscrowedMultipleMerkleDistributor
Expand All @@ -81,8 +67,7 @@ contract EscrowedMultipleMerkleDistributor is
uint256 epoch
) public override {
require(
!isClaimed(index, epoch),
"EscrowedMultipleMerkleDistributor: Drop already claimed."
!isClaimed(index, epoch), "EscrowedMultipleMerkleDistributor: Drop already claimed."
);

// verify the merkle proof
Expand All @@ -108,7 +93,7 @@ contract EscrowedMultipleMerkleDistributor is
/// @inheritdoc IEscrowedMultipleMerkleDistributor
function claimMultiple(Claims[] calldata claims) external override {
uint256 cacheLength = claims.length;
for (uint256 i = 0; i < cacheLength; ) {
for (uint256 i = 0; i < cacheLength;) {
claim(
claims[i].index,
claims[i].account,
Expand Down
12 changes: 2 additions & 10 deletions contracts/Kwenta.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,15 @@ contract Kwenta is ERC20, Owned, IKwenta {
}

// Mints inflationary supply
function mint(address account, uint256 amount)
external
override
onlySupplySchedule
{
function mint(address account, uint256 amount) external override onlySupplySchedule {
_mint(account, amount);
}

function burn(uint256 amount) external override {
_burn(msg.sender, amount);
}

function setSupplySchedule(address _supplySchedule)
external
override
onlyOwner
{
function setSupplySchedule(address _supplySchedule) external override onlyOwner {
require(_supplySchedule != address(0), "Kwenta: Invalid Address");
supplySchedule = ISupplySchedule(_supplySchedule);
}
Expand Down
24 changes: 6 additions & 18 deletions contracts/MultipleMerkleDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "./interfaces/IMultipleMerkleDistributor.sol";
contract MultipleMerkleDistributor is IMultipleMerkleDistributor, Owned {
using SafeERC20 for IERC20;
/// @inheritdoc IMultipleMerkleDistributor

address public immutable override token;

/// @inheritdoc IMultipleMerkleDistributor
Expand All @@ -31,22 +32,13 @@ contract MultipleMerkleDistributor is IMultipleMerkleDistributor, Owned {
}

/// @inheritdoc IMultipleMerkleDistributor
function setMerkleRootForEpoch(bytes32 merkleRoot, uint256 epoch)
external
override
onlyOwner
{
function setMerkleRootForEpoch(bytes32 merkleRoot, uint256 epoch) external override onlyOwner {
merkleRoots[epoch] = merkleRoot;
emit MerkleRootModified(epoch);
}

/// @inheritdoc IMultipleMerkleDistributor
function isClaimed(uint256 index, uint256 epoch)
public
view
override
returns (bool)
{
function isClaimed(uint256 index, uint256 epoch) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMaps[epoch][claimedWordIndex];
Expand All @@ -61,8 +53,7 @@ contract MultipleMerkleDistributor is IMultipleMerkleDistributor, Owned {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMaps[epoch][claimedWordIndex] =
claimedBitMaps[epoch][claimedWordIndex] |
(1 << claimedBitIndex);
claimedBitMaps[epoch][claimedWordIndex] | (1 << claimedBitIndex);
}

/// @inheritdoc IMultipleMerkleDistributor
Expand All @@ -73,10 +64,7 @@ contract MultipleMerkleDistributor is IMultipleMerkleDistributor, Owned {
bytes32[] calldata merkleProof,
uint256 epoch
) public override {
require(
!isClaimed(index, epoch),
"MultipleMerkleDistributor: Drop already claimed."
);
require(!isClaimed(index, epoch), "MultipleMerkleDistributor: Drop already claimed.");

// verify the merkle proof
bytes32 node = keccak256(abi.encodePacked(index, account, amount));
Expand All @@ -95,7 +83,7 @@ contract MultipleMerkleDistributor is IMultipleMerkleDistributor, Owned {
/// @inheritdoc IMultipleMerkleDistributor
function claimMultiple(Claims[] calldata claims) external override {
uint256 cacheLength = claims.length;
for (uint256 i = 0; i < cacheLength; ) {
for (uint256 i = 0; i < cacheLength;) {
claim(
claims[i].index,
claims[i].account,
Expand Down
Loading

0 comments on commit 685a7bb

Please sign in to comment.