Puzzle #4
PairAssetManager
Author
0xb49bf876be26435b6fae1ef42c3c82c5867fa149
chainlight.io
SoliditySolidity's logo.Puzzle
Curtacallsverify()
1
pragma solidity ^0.8.20;
2
3
import "../lib/curta/src/interfaces/IPuzzle.sol";
4
5
contract Puzzle is IPuzzle{
6
mapping(uint256 => Challenge) public factories;
7
8
function name() external pure returns (string memory) {
9
return "PairAssetManager";
10
}
11
12
function generate(address solver) public pure returns (uint256) {
13
return uint256(keccak256(abi.encode(solver)));
14
}
15
16
function verify(uint256 seed, uint256) external view returns (bool) {
17
return factories[seed].isSolved();
18
}
19
20
function deploy() external {
21
factories[generate(msg.sender)] = new Challenge();
22
factories[generate(msg.sender)].init(generate(msg.sender));
23
}
24
}
25
26
contract Deployer {
27
function create(address owner, address factory) external returns (PairAssetManager) {
28
return new PairAssetManager(owner, factory);
29
}
30
}
31
32
contract Challenge {
33
UniswapV2Factory public factory;
34
PairAssetManager public assetManager;
35
Keeper public keeper;
36
37
CurtaToken public curtaUSD;
38
CurtaToken public curtaStUSD;
39
40
uint256 public seed;
41
bool public initialized;
42
43
function init(uint256 _seed) external {
44
require(!initialized);
45
initialized = true;
46
seed = _seed;
47
48
factory = new UniswapV2Factory(address(0));
49
assetManager = Deployer(address(0x1D1f5f03feDD0358e7eB8A980870ef6695834bB9)).create(address(this), address(factory));
50
keeper = new Keeper(address(assetManager));
51
assetManager.setKeeper(address(keeper));
52
curtaUSD = new CurtaToken("curtaUSD", "USD");
53
curtaStUSD = new CurtaToken("curtaStUSD", "stUSD");
54
55
curtaUSD.mint(address(this), 1 ether);
56
curtaStUSD.mint(address(this), 1 ether);
57
58
curtaUSD.approve(address(assetManager), 1 ether);
59
curtaStUSD.approve(address(assetManager), 1 ether);
60
61
factory.createPair(address(curtaUSD), address(curtaStUSD));
62
assetManager.setStrategyPair(address(curtaUSD), address(curtaStUSD));
63
assetManager.deposit(address(curtaUSD), address(curtaStUSD), 1 ether, 1 ether, 0);
64
65
curtaUSD.mint(address(keeper), 10000 ether + 1);
66
curtaStUSD.mint(address(keeper), 10000 ether + 1);
67
68
keeper.rebalancing(address(curtaUSD), address(curtaStUSD), 1, 0, type(uint256).max, type(uint256).max);
69
}
70
71
function isSolved() external view returns (bool) {
72
require(
73
curtaUSD.balanceOf(address(uint160(seed))) == 10000 ether
74
&& curtaStUSD.balanceOf(address(uint160(seed))) == 10000 ether
75
);
76
return true;
77
}
78
}
First Blood
fuzzland.eth
07:02:08
11
Time Left

Solve locally (WIP)

  1. Clone GitHub repo + install deps
git clone https://github.com/waterfall-mkt/curta-puzzles.git && cd curta-puzzles && forge install
  1. Set RPC_URL_MAINNET in .env
.env
RPC_URL_MAINNET=""
  1. Write solution + run script
forge script <PATH_TO_PUZZLE> -f mainnet -vvv
This is still WIP.
Waterfall