Skip to content

Commit

Permalink
fix: definitive ekoke erc20 supply
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Nov 29, 2024
1 parent fa40b13 commit 13b1951
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
15 changes: 8 additions & 7 deletions ethereum/contracts/Ekoke.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract Ekoke is ERC20, Ownable {
/// @notice The address of the reward pool contract.
address public rewardPool;
/// @notice token decimals
uint8 private _decimals;

/// @notice The maximum supply of the token. (8 Millions and more)
uint256 public constant MAX_SUPPLY = 888_010_101_000_000;
/// @notice The maximum amount of tokens mintable by the reward pool. (7 Millions)
uint256 public constant MAX_REWARD_POOL_MINT = 700_000_000_000_000;
/// @notice The maximum amount of tokens mintable by the owner. (~1 Million)
/// @notice The maximum amount of tokens mintable by the reward pool. (66%)
uint256 public constant MAX_REWARD_POOL_MINT = 592_006_734_000_000;
/// @notice The maximum amount of tokens mintable by the owner. (33%)
uint256 public constant MAX_OWNER_MINT = MAX_SUPPLY - MAX_REWARD_POOL_MINT;
/// @notice contract decimals
uint8 private DECIMALS = 8;

/// @notice The amount of tokens minted by the reward pool.
uint256 public rewardPoolMintedSupply = 0;
/// @notice The amount of tokens minted by the owner.
uint256 public ownerMintedSupply = 0;

/// @notice Event emitted when tokens are minted by the reward pool.
event RewardMinted(address indexed _to, uint256 _amount);
/// @notice Event emitted when tokens are minted by the owner.
event OwnerMinted(address indexed _to, uint256 _amount);

constructor(
address _initialOwner
) ERC20("Ekoke", "EKOKE") Ownable(_initialOwner) {
_decimals = 8;
rewardPool = address(0);
}

Expand All @@ -44,7 +45,7 @@ contract Ekoke is ERC20, Ownable {
}

function decimals() public view virtual override returns (uint8) {
return _decimals;
return DECIMALS;
}

/// @notice Mint the provided amount of tokens to the recipient. Only the reward pool can call this function.
Expand Down
4 changes: 2 additions & 2 deletions src/deferred_minter/src/app/ethereum/reward_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl RewardPool {
/// Get the available amount of reward tokens in the reward pool
pub async fn available_rewards(&self, client: &EvmRpcClient) -> DeferredMinterResult<u128> {
if cfg!(test) {
return Ok(700_000_000_000_000);
return Ok(592_006_734_000_000);
}

let call = abi::RewardPoolCalls::AvailableReward(AvailableRewardCall).encode();
Expand Down Expand Up @@ -53,6 +53,6 @@ mod test {
.await
.unwrap();

assert_eq!(reward_pool, 700000000000000);
assert_eq!(reward_pool, 592006734000000);
}
}
8 changes: 4 additions & 4 deletions src/deferred_minter/src/app/reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ mod test {

use super::*;

const DEFAULT_REMAINING_SUPPLY: u128 = 700_000_000_000_000;
const DEFAULT_REMAINING_SUPPLY: u128 = 592_006_734_000_000;

#[tokio::test]
async fn test_should_get_reward_if_pool_doesnt_exist() {
assert_eq!(
Reward::get_contract_reward(4_000, DEFAULT_REMAINING_SUPPLY, BASE_TOKEN_PRICE as u64)
.unwrap(),
2_939_999_999, // 29 ekoke
2486428282, // 29 ekoke
);
assert_eq!(CPM.with_borrow(|cpm| *cpm.get()), 1);

Expand All @@ -207,7 +207,7 @@ mod test {
// next reward should be less
assert_eq!(
Reward::get_contract_reward(4_000, remaining_supply, BASE_TOKEN_PRICE as u64).unwrap(),
2939876519,
2486304802,
);
assert_eq!(CPM.with_borrow(|cpm| *cpm.get()), 2);
}
Expand All @@ -216,7 +216,7 @@ mod test {
async fn test_should_get_less_value_if_token_price_is_lower() {
assert_eq!(
Reward::get_contract_reward(4_000, DEFAULT_REMAINING_SUPPLY, 1).unwrap(),
2_940_000_000 / 100, // 0.29 ekoke
24864283, // 0.29 ekoke
);
assert_eq!(CPM.with_borrow(|cpm| *cpm.get()), 1);
}
Expand Down

0 comments on commit 13b1951

Please sign in to comment.