loom_defi_abi/balancer/
vault.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
use alloy_sol_types::sol;

sol! {
    #[derive(Debug, PartialEq, Eq)]
    interface IVault  {
        function getAuthorizer() external view returns (address);

        function setAuthorizer(address newAuthorizer) external;
        event AuthorizerChanged(address  indexed newAuthorizer);
        function hasApprovedRelayer(address user, address relayer) external view returns (bool);
        function setRelayerApproval(
            address sender,
            address relayer,
            bool approved
        ) external;
        event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved);
        function getInternalBalance(address user, address[] memory tokens) external view returns (uint256[] memory);
        function manageUserBalance(UserBalanceOp[] memory ops) external payable;

        struct UserBalanceOp {
            UserBalanceOpKind kind;
            address asset;
            uint256 amount;
            address sender;
            address payable recipient;
        }


        enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL }

        event InternalBalanceChanged(address indexed user, address indexed token, int256 delta);

        event ExternalBalanceTransfer(address indexed token, address indexed sender, address recipient, uint256 amount);


        enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN }


        function registerPool(PoolSpecialization specialization) external returns (bytes32);

        event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization);

        function getPool(bytes32 poolId) external view returns (address, PoolSpecialization);


        function registerTokens(
            bytes32 poolId,
            address[] memory tokens,
            address[] memory assetManagers
        ) external;

        event TokensRegistered(bytes32 indexed poolId, address[] tokens, address[] assetManagers);


        function deregisterTokens(bytes32 poolId, address[] memory tokens) external;
        event TokensDeregistered(bytes32 indexed poolId, address[] tokens);


        function getPoolTokenInfo(bytes32 poolId, address token)
            external
            view
            returns (
                uint256 cash,
                uint256 managed,
                uint256 lastChangeBlock,
                address assetManager
            );


        function getPoolTokens(bytes32 poolId)
            external
            view
            returns (
                address[] memory tokens,
                uint256[] memory balances,
                uint256 lastChangeBlock
            );


        function joinPool(
            bytes32 poolId,
            address sender,
            address recipient,
            JoinPoolRequest memory request
        ) external payable;

        struct JoinPoolRequest {
            address[] assets;
            uint256[] maxAmountsIn;
            bytes userData;
            bool fromInternalBalance;
        }


        function exitPool(
            bytes32 poolId,
            address sender,
            address payable recipient,
            ExitPoolRequest memory request
        ) external;

        struct ExitPoolRequest {
            address[] assets;
            uint256[] minAmountsOut;
            bytes userData;
            bool toInternalBalance;
        }

        event PoolBalanceChanged(
            bytes32 indexed poolId,
            address indexed liquidityProvider,
            address[] tokens,
            int256[] deltas,
            uint256[] protocolFeeAmounts
        );

        enum PoolBalanceChangeKind { JOIN, EXIT }

        enum SwapKind { GIVEN_IN, GIVEN_OUT }

        function swap(
            SingleSwap memory singleSwap,
            FundManagement memory funds,
            uint256 limit,
            uint256 deadline
        ) external payable returns (uint256);


        struct SingleSwap {
            bytes32 poolId;
            SwapKind kind;
            address assetIn;
            address assetOut;
            uint256 amount;
            bytes userData;
        }


        function batchSwap(
            SwapKind kind,
            BatchSwapStep[] memory swaps,
            address[] memory assets,
            FundManagement memory funds,
            int256[] memory limits,
            uint256 deadline
        ) external payable returns (int256[] memory);


        struct BatchSwapStep {
            bytes32 poolId;
            uint256 assetInIndex;
            uint256 assetOutIndex;
            uint256 amount;
            bytes userData;
        }

        event Swap(
            bytes32 indexed poolId,
            address indexed tokenIn,
            address indexed tokenOut,
            uint256 amountIn,
            uint256 amountOut
        );


        struct FundManagement {
            address sender;
            bool fromInternalBalance;
            address payable recipient;
            bool toInternalBalance;
        }

        function queryBatchSwap(
            SwapKind kind,
            BatchSwapStep[] memory swaps,
            address[] memory assets,
            FundManagement memory funds
        ) external returns (int256[] memory assetDeltas);


        function flashLoan(
            address recipient,
            address[] memory tokens,
            uint256[] memory amounts,
            bytes memory userData
        ) external;

        event FlashLoan(address indexed recipient, address indexed token, uint256 amount, uint256 feeAmount);


        function managePoolBalance(PoolBalanceOp[] memory ops) external;

        struct PoolBalanceOp {
            PoolBalanceOpKind kind;
            bytes32 poolId;
            address token;
            uint256 amount;
        }


        enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE }

        event PoolBalanceManaged(
            bytes32 indexed poolId,
            address indexed assetManager,
            address indexed token,
            int256 cashDelta,
            int256 managedDelta
        );


        function getProtocolFeesCollector() external view returns (address);


        function setPaused(bool paused) external;

        function WETH() external view returns (address);
    }
}