pub use IFeeManager::{IFeeManagerErrors as FeeManagerError, IFeeManagerEvents as FeeManagerEvent};
pub use ITIPFeeAMM::{ITIPFeeAMMErrors as TIPFeeAMMError, ITIPFeeAMMEvents as TIPFeeAMMEvent};
crate::sol! {
#[derive(Debug, PartialEq, Eq)]
#[sol(abi)]
interface IFeeManager {
struct FeeInfo {
uint128 amount;
bool hasBeenSet;
}
function userTokens(address user) external view returns (address);
function validatorTokens(address validator) external view returns (address);
function setUserToken(address token) external;
function setValidatorToken(address token) external;
function distributeFees(address validator, address token) external;
function collectedFees(address validator, address token) external view returns (uint256);
event UserTokenSet(address indexed user, address indexed token);
event ValidatorTokenSet(address indexed validator, address indexed token);
event FeesDistributed(address indexed validator, address indexed token, uint256 amount);
error OnlyValidator();
error OnlySystemContract();
error InvalidToken();
error PoolDoesNotExist();
error InsufficientFeeTokenBalance();
error InternalError();
error CannotChangeWithinBlock();
error CannotChangeWithPendingFees();
error TokenPolicyForbids();
}
}
sol! {
#[derive(Debug, PartialEq, Eq)]
#[allow(clippy::too_many_arguments)]
interface ITIPFeeAMM {
struct Pool {
uint128 reserveUserToken;
uint128 reserveValidatorToken;
}
struct PoolKey {
address token0;
address token1;
}
function M() external view returns (uint256);
function N() external view returns (uint256);
function SCALE() external view returns (uint256);
function MIN_LIQUIDITY() external view returns (uint256);
function getPoolId(address userToken, address validatorToken) external pure returns (bytes32);
function getPool(address userToken, address validatorToken) external view returns (Pool memory);
function pools(bytes32 poolId) external view returns (Pool memory);
function mint(address userToken, address validatorToken, uint256 amountValidatorToken, address to) external returns (uint256 liquidity);
function burn(address userToken, address validatorToken, uint256 liquidity, address to) external returns (uint256 amountUserToken, uint256 amountValidatorToken);
function totalSupply(bytes32 poolId) external view returns (uint256);
function liquidityBalances(bytes32 poolId, address user) external view returns (uint256);
function rebalanceSwap(address userToken, address validatorToken, uint256 amountOut, address to) external returns (uint256 amountIn);
event Mint(address sender, address indexed to, address indexed userToken, address indexed validatorToken, uint256 amountValidatorToken, uint256 liquidity);
event Burn(address indexed sender, address indexed userToken, address indexed validatorToken, uint256 amountUserToken, uint256 amountValidatorToken, uint256 liquidity, address to);
event RebalanceSwap(address indexed userToken, address indexed validatorToken, address indexed swapper, uint256 amountIn, uint256 amountOut);
error IdenticalAddresses();
error InvalidToken();
error InsufficientLiquidity();
error InsufficientReserves();
error InvalidAmount();
error DivisionByZero();
error InvalidSwapCalculation();
}
}
impl FeeManagerError {
pub const fn only_validator() -> Self {
Self::OnlyValidator(IFeeManager::OnlyValidator {})
}
pub const fn only_system_contract() -> Self {
Self::OnlySystemContract(IFeeManager::OnlySystemContract {})
}
pub const fn invalid_token() -> Self {
Self::InvalidToken(IFeeManager::InvalidToken {})
}
pub const fn pool_does_not_exist() -> Self {
Self::PoolDoesNotExist(IFeeManager::PoolDoesNotExist {})
}
pub const fn insufficient_fee_token_balance() -> Self {
Self::InsufficientFeeTokenBalance(IFeeManager::InsufficientFeeTokenBalance {})
}
pub const fn cannot_change_within_block() -> Self {
Self::CannotChangeWithinBlock(IFeeManager::CannotChangeWithinBlock {})
}
pub const fn cannot_change_with_pending_fees() -> Self {
Self::CannotChangeWithPendingFees(IFeeManager::CannotChangeWithPendingFees {})
}
pub const fn token_policy_forbids() -> Self {
Self::TokenPolicyForbids(IFeeManager::TokenPolicyForbids {})
}
}
impl TIPFeeAMMError {
pub const fn identical_addresses() -> Self {
Self::IdenticalAddresses(ITIPFeeAMM::IdenticalAddresses {})
}
pub const fn invalid_token() -> Self {
Self::InvalidToken(ITIPFeeAMM::InvalidToken {})
}
pub const fn insufficient_liquidity() -> Self {
Self::InsufficientLiquidity(ITIPFeeAMM::InsufficientLiquidity {})
}
pub const fn insufficient_reserves() -> Self {
Self::InsufficientReserves(ITIPFeeAMM::InsufficientReserves {})
}
pub const fn invalid_amount() -> Self {
Self::InvalidAmount(ITIPFeeAMM::InvalidAmount {})
}
pub const fn invalid_swap_calculation() -> Self {
Self::InvalidSwapCalculation(ITIPFeeAMM::InvalidSwapCalculation {})
}
pub const fn division_by_zero() -> Self {
Self::DivisionByZero(ITIPFeeAMM::DivisionByZero {})
}
}