Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"AMMMath.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
library AMMMath {
uint256 public constant BASIS_POINTS = 10000;
uint256 public constant MIN_LIQUIDITY = 1000;
error AMM__InsufficientLiquidity();
error AMM__InsufficientAmount();
error AMM__InvalidK();
error AMM__Overflow();
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut,
uint256 fee
) internal pure returns (uint256 amountOut) {
if (amountIn == 0) revert AMM__InsufficientAmount();
if (reserveIn == 0 || reserveOut == 0) revert AMM__InsufficientLiquidity();
uint256 amountInWithFee = amountIn * (BASIS_POINTS - fee);
uint256 numerator = amountInWithFee * reserveOut;
uint256 denominator = (reserveIn * BASIS_POINTS) + amountInWithFee;
amountOut = numerator / denominator;
}
function sqrt(uint256 x) internal pure returns (uint256) {
if (x == 0) return 0;
uint256 z = (x + 1) / 2;
uint256 y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
return y;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-07 15:48:54
Comments
Log in to comment.
No comments yet.