tempo_contracts/precompiles/
tip_fee_manager.rs1pub use IFeeManager::{IFeeManagerErrors as FeeManagerError, IFeeManagerEvents as FeeManagerEvent};
2pub use ITIPFeeAMM::{ITIPFeeAMMErrors as TIPFeeAMMError, ITIPFeeAMMEvents as TIPFeeAMMEvent};
3
4crate::sol! {
5 #[derive(Debug, PartialEq, Eq)]
18 #[sol(abi)]
19 interface IFeeManager {
20 struct FeeInfo {
22 uint128 amount;
23 bool hasBeenSet;
24 }
25
26 function userTokens(address user) external view returns (address);
28 function validatorTokens(address validator) external view returns (address);
29 function setUserToken(address token) external;
30 function setValidatorToken(address token) external;
31
32 function distributeFees(address validator, address token) external;
34 function collectedFees(address validator, address token) external view returns (uint256);
35 event UserTokenSet(address indexed user, address indexed token);
40 event ValidatorTokenSet(address indexed validator, address indexed token);
41 event FeesDistributed(address indexed validator, address indexed token, uint256 amount);
42
43 error InvalidToken();
45 error InsufficientFeeTokenBalance();
46 error CannotChangeWithinBlock();
47 }
48}
49
50sol! {
51 #[derive(Debug, PartialEq, Eq)]
58 #[sol(abi)]
59 #[allow(clippy::too_many_arguments)]
60 interface ITIPFeeAMM {
61 struct Pool {
63 uint128 reserveUserToken;
64 uint128 reserveValidatorToken;
65 }
66
67 struct PoolKey {
68 address token0;
69 address token1;
70 }
71
72
73 function M() external view returns (uint256);
75 function N() external view returns (uint256);
76 function SCALE() external view returns (uint256);
77 function MIN_LIQUIDITY() external view returns (uint256);
78
79 function getPoolId(address userToken, address validatorToken) external pure returns (bytes32);
81 function getPool(address userToken, address validatorToken) external view returns (Pool memory);
82 function pools(bytes32 poolId) external view returns (Pool memory);
83
84 function mint(address userToken, address validatorToken, uint256 amountValidatorToken, address to) external returns (uint256 liquidity);
86 function burn(address userToken, address validatorToken, uint256 liquidity, address to) external returns (uint256 amountUserToken, uint256 amountValidatorToken);
87
88 function totalSupply(bytes32 poolId) external view returns (uint256);
90 function liquidityBalances(bytes32 poolId, address user) external view returns (uint256);
91
92 function rebalanceSwap(address userToken, address validatorToken, uint256 amountOut, address to) external returns (uint256 amountIn);
94
95 event Mint(address sender, address indexed to, address indexed userToken, address indexed validatorToken, uint256 amountValidatorToken, uint256 liquidity);
97 event Burn(address indexed sender, address indexed userToken, address indexed validatorToken, uint256 amountUserToken, uint256 amountValidatorToken, uint256 liquidity, address to);
98 event RebalanceSwap(address indexed userToken, address indexed validatorToken, address indexed swapper, uint256 amountIn, uint256 amountOut);
99
100 error IdenticalAddresses();
102 error InvalidToken();
103 error InsufficientLiquidity();
104 error InsufficientReserves();
105 error InvalidAmount();
106 error DivisionByZero();
107 error InvalidSwapCalculation();
108 }
109}
110
111impl FeeManagerError {
112 pub const fn invalid_token() -> Self {
114 Self::InvalidToken(IFeeManager::InvalidToken {})
115 }
116
117 pub const fn insufficient_fee_token_balance() -> Self {
119 Self::InsufficientFeeTokenBalance(IFeeManager::InsufficientFeeTokenBalance {})
120 }
121
122 pub const fn cannot_change_within_block() -> Self {
124 Self::CannotChangeWithinBlock(IFeeManager::CannotChangeWithinBlock {})
125 }
126}
127
128impl TIPFeeAMMError {
129 pub const fn identical_addresses() -> Self {
131 Self::IdenticalAddresses(ITIPFeeAMM::IdenticalAddresses {})
132 }
133
134 pub const fn invalid_token() -> Self {
136 Self::InvalidToken(ITIPFeeAMM::InvalidToken {})
137 }
138
139 pub const fn insufficient_liquidity() -> Self {
141 Self::InsufficientLiquidity(ITIPFeeAMM::InsufficientLiquidity {})
142 }
143
144 pub const fn insufficient_reserves() -> Self {
146 Self::InsufficientReserves(ITIPFeeAMM::InsufficientReserves {})
147 }
148 pub const fn invalid_amount() -> Self {
150 Self::InvalidAmount(ITIPFeeAMM::InvalidAmount {})
151 }
152
153 pub const fn invalid_swap_calculation() -> Self {
155 Self::InvalidSwapCalculation(ITIPFeeAMM::InvalidSwapCalculation {})
156 }
157
158 pub const fn division_by_zero() -> Self {
160 Self::DivisionByZero(ITIPFeeAMM::DivisionByZero {})
161 }
162}