Skip to content

Commit

Permalink
fix $lords distribution amounts (#391)
Browse files Browse the repository at this point in the history
* previous implementation was incorrectly using ^ operator
  • Loading branch information
ponderingdemocritus authored Oct 10, 2023
1 parent 320e0c7 commit 0d47231
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
26 changes: 13 additions & 13 deletions contracts/game/src/game/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod messages {

// TODO: Update for mainnet
const BLOCKS_IN_A_WEEK: u64 = 1000;
const COST_TO_PLAY: u8 = 25;
const COST_TO_PLAY: u256 = 25000000000000000000;
const NUM_STARTING_STATS: u8 = 9;
const STARTING_GAME_ENTROPY_ROTATION_INTERVAL: u8 = 6;
const MINIMUM_DAMAGE_FROM_BEASTS: u8 = 2;
Expand All @@ -50,25 +50,25 @@ struct Week {
mod REWARD_DISTRIBUTIONS_PHASE1 {
const DAO: u256 = 0;
const INTERFACE: u256 = 0;
const FIRST_PLACE: u256 = 12;
const SECOND_PLACE: u256 = 8;
const THIRD_PLACE: u256 = 5;
const FIRST_PLACE: u256 = 12000000000000000000;
const SECOND_PLACE: u256 = 8000000000000000000;
const THIRD_PLACE: u256 = 5000000000000000000;
}

mod REWARD_DISTRIBUTIONS_PHASE2 {
const DAO: u256 = 5;
const DAO: u256 = 5000000000000000000;
const INTERFACE: u256 = 0;
const FIRST_PLACE: u256 = 10;
const SECOND_PLACE: u256 = 6;
const THIRD_PLACE: u256 = 4;
const FIRST_PLACE: u256 = 10000000000000000000;
const SECOND_PLACE: u256 = 6000000000000000000;
const THIRD_PLACE: u256 = 4000000000000000000;
}

mod REWARD_DISTRIBUTIONS_PHASE3 {
const DAO: u256 = 5;
const INTERFACE: u256 = 4;
const FIRST_PLACE: u256 = 9;
const SECOND_PLACE: u256 = 4;
const THIRD_PLACE: u256 = 3;
const DAO: u256 = 5000000000000000000;
const INTERFACE: u256 = 4000000000000000000;
const FIRST_PLACE: u256 = 9000000000000000000;
const SECOND_PLACE: u256 = 4000000000000000000;
const THIRD_PLACE: u256 = 3000000000000000000;
}

const STARTER_BEAST_ATTACK_DAMAGE: u16 = 10;
16 changes: 6 additions & 10 deletions contracts/game/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1139,10 +1139,6 @@ mod Game {
}
}

fn _to_ether(amount: u256) -> u256 {
amount * 10 ^ 18
}

fn _process_payment_and_distribute_rewards(
ref self: ContractState, client_address: ContractAddress
) {
Expand All @@ -1165,7 +1161,7 @@ mod Game {
// without this, there would be an incentive to start and die immediately after contract is deployed
// to capture the rewards from the launch hype
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, dao_address, _to_ether(COST_TO_PLAY.into()));
.transferFrom(caller, dao_address, COST_TO_PLAY.into());

__event_RewardDistribution(
ref self,
Expand Down Expand Up @@ -1222,26 +1218,26 @@ mod Game {
// DAO
if (week.DAO != 0) {
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, dao_address, _to_ether(week.DAO));
.transferFrom(caller, dao_address, week.DAO);
}

// interface
if (week.INTERFACE != 0) {
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, client_address, _to_ether(week.INTERFACE));
.transferFrom(caller, client_address, week.INTERFACE);
}

// first place
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, first_place_address, _to_ether(week.FIRST_PLACE));
.transferFrom(caller, first_place_address, week.FIRST_PLACE);

// second place
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, second_place_address, _to_ether(week.SECOND_PLACE));
.transferFrom(caller, second_place_address, week.SECOND_PLACE);

// third place
IERC20CamelDispatcher { contract_address: lords }
.transferFrom(caller, third_place_address, _to_ether(week.THIRD_PLACE));
.transferFrom(caller, third_place_address, week.THIRD_PLACE);

__event_RewardDistribution(
ref self,
Expand Down
4 changes: 2 additions & 2 deletions contracts/game/src/tests/test_game.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ mod tests {

const ADVENTURER_ID: felt252 = 1;

const MAX_LORDS: u256 = 500000000000000000000;
const APPROVE: u256 = 50000000000000000000;
const MAX_LORDS: u256 = 1000000000000000000000;
const APPROVE: u256 = 100000000000000000000;
const NAME: felt252 = 111;
const SYMBOL: felt252 = 222;

Expand Down

1 comment on commit 0d47231

@vercel
Copy link

@vercel vercel bot commented on 0d47231 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.