loom_defi_abi/maverick/
pool.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use alloy_sol_types::sol;

sol! {
    #[derive(Debug, PartialEq, Eq)]
    struct State {
        int32 activeTick;
        uint8 status;
        uint128 binCounter;
        uint64 protocolFeeRatio;
    }

    #[derive(Debug, PartialEq, Eq)]
    struct BinState {
        uint128 reserveA;
        uint128 reserveB;
        uint128 mergeBinBalance;
        uint128 mergeId;
        uint128 totalSupply;
        uint8 kind;
        int32 lowerTick;
    }

    #[derive(Debug, PartialEq, Eq)]
    struct BinDelta {
        uint128 deltaA;
        uint128 deltaB;
        uint256 deltaLpBalance;
        uint128 binId;
        uint8 kind;
        int32 lowerTick;
        bool isActive;
    }

    #[derive(Debug, PartialEq, Eq)]
    struct TwaState {
        int96 twa;
        int96 value;
        uint64 lastTimestamp;
    }

    #[derive(Debug, PartialEq, Eq)]
    struct AddLiquidityParams {
        uint8 kind;
        int32 pos;
        bool isDelta;
        uint128 deltaA;
        uint128 deltaB;
    }
    #[derive(Debug, PartialEq, Eq)]
    struct RemoveLiquidityParams {
        uint128 binId;
        uint128 amount;
    }

    #[sol(abi=true,rpc)]
    #[derive(Debug, PartialEq, Eq)]
    interface IMaverickPool {
        event Swap(address sender, address recipient, bool tokenAIn, bool exactOutput, uint256 amountIn, uint256 amountOut, int32 activeTick);
        event AddLiquidity(address indexed sender, uint256 indexed tokenId, BinDelta[] binDeltas);
        event MigrateBinsUpStack(address indexed sender, uint128 binId, uint32 maxRecursion);
        event TransferLiquidity(uint256 fromTokenId, uint256 toTokenId, RemoveLiquidityParams[] params);
        event RemoveLiquidity(address indexed sender, address indexed recipient, uint256 indexed tokenId, BinDelta[] binDeltas);
        event BinMerged(uint128 indexed binId, uint128 reserveA, uint128 reserveB, uint128 mergeId);
        event BinMoved(uint128 indexed binId, int128 previousTick, int128 newTick);
        event ProtocolFeeCollected(uint256 protocolFee, bool isTokenA);
        event SetProtocolFeeRatio(uint256 protocolFee);


        function fee() external view returns (uint256);
        function lookback() external view returns (int256);
        function tickSpacing() external view returns (uint256);
        function tokenA() external view returns (address);
        function tokenB() external view returns (address);
        function factory() external view returns (address);

        function binMap(int32 tick) external view returns (uint256);
        function binPositions(int32 tick, uint256 kind) external view returns (uint128);
        function binBalanceA() external view returns (uint128);
        function binBalanceB() external view returns (uint128);
        function getTwa() external view returns (TwaState memory);
        function getCurrentTwa() external view returns (int256);
        function getState() external view returns (State memory);
        function getBin(uint128 binId) external view returns (BinState memory bin);

        function balanceOf(uint256 tokenId, uint128 binId) external view returns (uint256 lpToken);

        function tokenAScale() external view returns (uint256);

        function tokenBScale() external view returns (uint256);
        function swap(
            address recipient,
            uint256 amount,
            bool tokenAIn,
            bool exactOutput,
            uint256 sqrtPriceLimit,
            bytes calldata data
        ) external returns (uint256 amountIn, uint256 amountOut);
    }
}