1
0
forked from mico/idle_moloch

Adjusted buyins, adjusted rewards

This commit is contained in:
mic0 2024-11-01 11:42:50 +01:00
parent 1f24f68862
commit 030dc849c6
Signed by: mico
GPG Key ID: A3F8023524CF1C8D
6 changed files with 45 additions and 16 deletions

View File

@ -25,13 +25,13 @@ export const bossToName: Record<BossLevel, string> = {
}
export const bossToReward: Record<BossLevel, bigint> = {
0: BigInt("200000000000000000"),
1: BigInt("28274420000000000000"),
2: BigInt("174191628800000000000"),
3: BigInt("513254698112000000000"),
4: BigInt("963499867554252800000"),
5: BigInt("1424610762718861153000"),
6: BigInt("1758160308403017784500"),
0: BigInt("129600000000000000"),
1: BigInt("18321824160000000000"),
2: BigInt("112876175462400000000"),
3: BigInt("332589044376576000000"),
4: BigInt("624347914175155814400"),
5: BigInt("923147774241822027325"),
6: BigInt("1139287879845155524372"),
}
// for boss chances (percent) [99, 89, 80, 70, 62, 51, 40]

View File

@ -158,7 +158,7 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
abi,
address: contractAddress,
functionName: 'register_eth',
value: parseEther("0.00005"),
value: parseEther("0.00045"),
}, {
onSuccess: (hash) => {
setHashAndCallback([hash, resetHashAndCallback])
@ -170,7 +170,7 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
abi,
address: daoTokenAddress,
functionName: 'approve',
args: [contractAddress, parseEther("500")],
args: [contractAddress, parseEther("400")],
}, {
onSuccess: (hash) => {
setHashAndCallback([

View File

@ -3,6 +3,7 @@ pragma solidity ^0.8.13;
contract Constants {
//base addresses
address public constant DAO_TREASURY = 0xfaAf7776E05696682f6B170Bf463819219c8d3A6;
address public constant DAO_TOKEN = 0x11dC980faf34A1D082Ae8A6a883db3A950a3c6E8;
address public constant POOL = 0x27004f6d0c1bB7979367D32Ba9d6DF6d61A18926;
address public constant BAAL = 0x4d5A5B4a679b10038e1677C84Cb675d10d29fFFD;

View File

@ -16,7 +16,7 @@ import { Constants} from "../src/Constants.sol";
contract RaidGeld is ERC20, Ownable, Constants {
uint256 public constant MANTISSA = 1e4;
uint256 public constant BUY_IN_AMOUNT = 0.00005 ether;
uint256 public constant BUY_IN_AMOUNT = 0.00045 ether;
uint256 public BUY_IN_DAO_TOKEN_AMOUNT;
uint256 public constant INITIAL_GELD = 50 * MANTISSA;
uint256 public constant SACRIFICE_SHARE = 1e3; // 10%
@ -108,7 +108,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
daoToken = ERC20(_daoToken);
DAOWETHpool = _pool;
baal = IBaal(_baal);
BUY_IN_DAO_TOKEN_AMOUNT = 500 * 10 ** daoToken.decimals();
BUY_IN_DAO_TOKEN_AMOUNT = 400 * 10 ** daoToken.decimals();
nonfungiblePositionManager = INonfungiblePositionManager(_nftPositionManager);
IUniswapV3Factory factory = IUniswapV3Factory(nonfungiblePositionManager.factory());
@ -116,7 +116,6 @@ contract RaidGeld is ERC20, Ownable, Constants {
require(tickSpacing != 0, "InvalidPoolFee");
maxTick = (887272 / tickSpacing) * tickSpacing;
minTick = -maxTick;
}
function start_game(address player) private {
@ -322,8 +321,16 @@ contract RaidGeld is ERC20, Ownable, Constants {
if (hasWonBattle) {
// Burn geld, send some sweet DAO Token and continue
_burn(msg.sender, geld_to_burn);
uint256 reward = RaidGeldUtils.calculateBossReward(boss_to_attack.level, BUY_IN_DAO_TOKEN_AMOUNT);
uint256 baseReward = (BUY_IN_DAO_TOKEN_AMOUNT - BUY_IN_DAO_TOKEN_AMOUNT * SACRIFICE_SHARE / MANTISSA);
uint256 wholeReward = RaidGeldUtils.calculateBossReward(boss_to_attack.level, baseReward);
uint256 treasuryShare = wholeReward * SACRIFICE_SHARE / MANTISSA;
uint256 reward = wholeReward - treasuryShare;
// send a share to dao treasury
daoToken.transfer(DAO_TREASURY, treasuryShare);
players[msg.sender].total_rewards += reward;
// send user its reward
daoToken.transfer(msg.sender, reward);
emit BossDefeated(msg.sender, boss_to_attack.level, reward);

View File

@ -269,6 +269,7 @@ contract raid_geldTest is Test, Constants {
registerPlayerWithDaoToken();
raid_geld.addUnit(0, 1);
uint256 initialDaoTreasuryBalance = raid_geld.daoToken().balanceOf(DAO_TREASURY);
uint256 initialDaoBalance = raid_geld.daoToken().balanceOf(player1);
uint256 initialContractBalance = raid_geld.daoToken().balanceOf(address(raid_geld));
@ -286,6 +287,7 @@ contract raid_geldTest is Test, Constants {
// First boss doesnt grant a new prestige level (ascension)
assertEq(results[1], false);
uint256 daoTreasuryBalance = raid_geld.daoToken().balanceOf(DAO_TREASURY);
uint256 afterBossDaoBalance = raid_geld.daoToken().balanceOf(player1);
uint256 afterBossContractBalance = raid_geld.daoToken().balanceOf(address(raid_geld));
LastBossResult memory bossResult = raid_geld.getLastBossResult(player1);
@ -297,6 +299,7 @@ contract raid_geldTest is Test, Constants {
assertEq(bossResult.prestigeGained, false);
// User should receive funs, contract should lose them
assertLt(initialDaoTreasuryBalance, daoTreasuryBalance);
assertLt(initialDaoBalance, afterBossDaoBalance);
assertGt(initialContractBalance, afterBossContractBalance);

View File

@ -5,8 +5,22 @@ import {Test, console} from "forge-std/Test.sol";
import {Army, Raider} from "../src/RaidGeldStructs.sol";
import "../src/RaidGeldUtils.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import {RaidGeld} from "../src/RaidGeld.sol";
import {Constants} from "../src/Constants.sol";
contract raid_geldTest is Test, Constants {
RaidGeld public raid_geld;
address public owner;
function setUp() public {
owner = address(0x126);
vm.deal(owner, 10 ether);
vm.prank(owner);
raid_geld = new RaidGeld(DAO_TOKEN, POOL, BAAL, NFT_POSITION_MANAGER);
raid_geld.weth().deposit{value: 5 ether}();
}
contract raid_geldTest is Test {
function test_0_unit_price() public pure {
// buying 1 unit of moloch_denier
uint256 basePriceMolochDenier = RaidGeldUtils.calculateUnitPrice(0, 0, 1);
@ -141,8 +155,12 @@ contract raid_geldTest is Test {
function test_4_print_boss_rewards() public {
uint256 total = 0;
uint256 buyInAmount = 400e18;
uint256 baseReward = buyInAmount - buyInAmount * raid_geld.SACRIFICE_SHARE() / raid_geld.MANTISSA();
for (uint8 i = 0; i < 7; i++) {
uint256 reward = RaidGeldUtils.calculateBossReward(i, 500e18);
uint256 wholeReward = RaidGeldUtils.calculateBossReward(i, baseReward);
uint256 baalShare = wholeReward * raid_geld.SACRIFICE_SHARE() / raid_geld.MANTISSA();
uint256 reward = wholeReward - baalShare;
console.log("Reward", i,reward);
total += reward;
}