Compare commits
4 Commits
9e15e0eb2a
...
f6f3e5cadf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6f3e5cadf | ||
|
|
06434f5281 | ||
|
|
e028e84a9d | ||
|
|
98913323f8 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,3 +4,6 @@
|
||||
[submodule "lib/openzeppelin-contracts"]
|
||||
path = lib/openzeppelin-contracts
|
||||
url = https://github.com/OpenZeppelin/openzeppelin-contracts
|
||||
[submodule "lib/Baal"]
|
||||
path = lib/Baal
|
||||
url = https://github.com/HausDAO/Baal
|
||||
|
||||
1
lib/Baal
Submodule
1
lib/Baal
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ee3d5ab910399c2b70e70aee2eb3c874047313ed
|
||||
1
lib/v3-core
Submodule
1
lib/v3-core
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit e3589b192d0be27e100cd0daaf6c97204fdb1899
|
||||
1
lib/v3-periphery
Submodule
1
lib/v3-periphery
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 80f26c86c57b8a5e4b913f42844d4c8bd274d058
|
||||
@ -12,7 +12,7 @@ contract RaidGeldScript is Script, Constants {
|
||||
|
||||
function run() public {
|
||||
vm.startBroadcast();
|
||||
raidgeld = new RaidGeld(DAO_TOKEN, POOL);
|
||||
raidgeld = new RaidGeld(DAO_TOKEN, POOL, BAAL);
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ contract Constants {
|
||||
//base addresses
|
||||
address public constant DAO_TOKEN = 0x11dC980faf34A1D082Ae8A6a883db3A950a3c6E8;
|
||||
address public constant POOL = 0x27004f6d0c1bB7979367D32Ba9d6DF6d61A18926;
|
||||
address public constant BAAL = 0x4d5A5B4a679b10038e1677C84Cb675d10d29fFFD;
|
||||
address public constant WETH = 0x4200000000000000000000000000000000000006;
|
||||
address public constant SWAP_ROUTER = 0x2626664c2603336E57B271c5C0b26F421741e481;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ pragma solidity ^0.8.13;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import {IBaal} from "lib/Baal/contracts/interfaces/IBaal.sol";
|
||||
|
||||
import {RaidGeldUtils} from "../src/RaidGeldUtils.sol";
|
||||
import {Army, Player, Raider, Boss} from "../src/RaidGeldStructs.sol";
|
||||
@ -13,6 +14,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
uint256 public constant BUY_IN_AMOUNT = 0.00005 ether;
|
||||
uint256 public BUY_IN_DAO_TOKEN_AMOUNT;
|
||||
uint256 public constant INITIAL_GELD = 50 * MANTISSA;
|
||||
uint256 public constant SACRIFICE_SHARE = 1e3; // 10%
|
||||
mapping(address => Player) private players;
|
||||
mapping(address => Army) private armies;
|
||||
mapping(address => Boss) private bosses;
|
||||
@ -21,6 +23,7 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
IWETH public immutable weth = IWETH(WETH);
|
||||
// RGCVII token
|
||||
ERC20 public daoToken;
|
||||
IBaal public baal;
|
||||
// RGCVII pool
|
||||
address public pool;
|
||||
// Uniswap
|
||||
@ -62,9 +65,10 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
_;
|
||||
}
|
||||
|
||||
constructor(address _daoToken, address _pool) ERC20("Raid Geld", "GELD") Ownable(msg.sender) {
|
||||
constructor(address _daoToken, address _pool, address _baal) ERC20("Raid Geld", "GELD") Ownable(msg.sender) {
|
||||
daoToken = ERC20(_daoToken);
|
||||
pool = _pool;
|
||||
baal = IBaal(_baal);
|
||||
BUY_IN_DAO_TOKEN_AMOUNT = 500 * 10 ** daoToken.decimals();
|
||||
}
|
||||
|
||||
@ -121,7 +125,8 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
amountOutMinimum: 0,
|
||||
sqrtPriceLimitX96: 0
|
||||
});
|
||||
router.exactInputSingle(params);
|
||||
uint256 daoTokenAmount = router.exactInputSingle(params);
|
||||
performSacrifice(daoTokenAmount);
|
||||
start_game(msg.sender);
|
||||
}
|
||||
|
||||
@ -132,8 +137,14 @@ contract RaidGeld is ERC20, Ownable, Constants {
|
||||
require(
|
||||
daoToken.transferFrom(msg.sender, address(this), BUY_IN_DAO_TOKEN_AMOUNT), "Failed to transfer DAO tokens"
|
||||
);
|
||||
performSacrifice(BUY_IN_DAO_TOKEN_AMOUNT);
|
||||
start_game(msg.sender);
|
||||
}
|
||||
function performSacrifice(uint256 _baseAmount) private {
|
||||
uint256 amount = _baseAmount * SACRIFICE_SHARE / MANTISSA;
|
||||
address[] memory tokens = new address[](0);
|
||||
baal.ragequit(address(this), amount, 0, tokens);
|
||||
}
|
||||
|
||||
// Override for default number of decimals
|
||||
function decimals() public view virtual override returns (uint8) {
|
||||
|
||||
@ -36,7 +36,7 @@ contract raid_geldTest is Test, Constants {
|
||||
vm.deal(owner, 10 ether);
|
||||
fundAccount(player1);
|
||||
vm.prank(owner);
|
||||
raid_geld = new RaidGeld(DAO_TOKEN, POOL);
|
||||
raid_geld = new RaidGeld(DAO_TOKEN, POOL, BAAL);
|
||||
raid_geld.weth().deposit{value: 5 ether}();
|
||||
}
|
||||
|
||||
@ -116,8 +116,10 @@ contract raid_geldTest is Test, Constants {
|
||||
assertEq(raid_geld.balanceOf(player1), raid_geld.INITIAL_GELD());
|
||||
|
||||
// Verify the contract dao token balance is updated
|
||||
uint256 expectedDaoBalance = initialBalance + raid_geld.BUY_IN_DAO_TOKEN_AMOUNT() -
|
||||
raid_geld.BUY_IN_DAO_TOKEN_AMOUNT() * raid_geld.SACRIFICE_SHARE() / raid_geld.MANTISSA();
|
||||
assertEq(
|
||||
raid_geld.daoToken().balanceOf(address(raid_geld)), initialBalance + raid_geld.BUY_IN_DAO_TOKEN_AMOUNT()
|
||||
raid_geld.daoToken().balanceOf(address(raid_geld)), expectedDaoBalance
|
||||
);
|
||||
|
||||
// Verify player is set initially
|
||||
|
||||
Loading…
Reference in New Issue
Block a user