vdAMM Contracts
vdAMM-III.sol
Note
Split reference
This reference file was too long so it is split into multiple chunks. This is chunk number III.
This Solidity file appears to be part of a larger smart contract project related to a decentralized automated market maker. The code defines a few helper functions for arithmetic operations and a key function (_swapLsdToLsd) for swapping tokens within the smart contract. The contract is also set to accept Ether payments.
_swapLsdToLsd
_swapLsdToLsd(uint256 amountIn, address lsdIn, address lsdOut, uint256 minAmountOut) internal returns (uint256, uint256, uint256)
This function swaps one token for another within the context of the smart contract. It calculates protocol fees and maintains a share for unshETH holders.
Parameters
- amountIn uint256: The amount of the input token.
- lsdIn address: The address of the input token.
- lsdOut address: The address of the output token.
- minAmountOut uint256: The minimum acceptable amount of the output token.
Return Values
- tuple: Returns a tuple of three uint256 values: the amount of the output token, the base fee, and the dynamic fee.
Errors
- Slippage limit reached: Thrown if the expected amount of output token is less than the minimum acceptable amount.
- Not enough lsdOut in vault: Thrown if there are not enough tokens in the vault for the swap.
unchkIncr
unchkIncr(uint256 i) private pure returns (uint256)
Increments the given number without checking for overflows.
Parameters
- i uint256: The number to increment.
Return Values
- uint256: Returns the incremented number.
_min
_min(uint256 _a, uint256 _b) private pure returns (uint256)
Returns the minimum of two numbers.
Parameters
- _a uint256: The first number.
- _b uint256: The second number.
Return Values
- uint256: Returns the smaller number.
_max
_max(uint256 _a, uint256 _b) private pure returns (uint256)
Returns the maximum of two numbers.
Parameters
- _a uint256: The first number.
- _b uint256: The second number.
Return Values
- uint256: Returns the larger number.
_absDiff
_absDiff(uint256 _a, uint256 _b) private pure returns (uint256)
Calculates the absolute difference between two numbers.
Parameters
- _a uint256: The first number.
- _b uint256: The second number.
Return Values
- uint256: Returns the absolute difference.