mirror of
https://github.com/luxfi/sudoamm.git
synced 2026-07-25 16:17:09 +00:00
Fixed documentation and bad naming issues from abdk
This commit is contained in:
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
||||
|
||||
import {LSSVMRouter} from "./LSSVMRouter.sol";
|
||||
|
||||
interface LSSVMPairFactoryLike {
|
||||
interface ILSSVMPairFactoryLike {
|
||||
enum PairVariant {
|
||||
ENUMERABLE_ETH,
|
||||
MISSING_ENUMERABLE_ETH,
|
||||
+28
-23
@@ -6,7 +6,7 @@ import {Ownable} from "./lib/Ownable.sol";
|
||||
import {ReentrancyGuard} from "./lib/ReentrancyGuard.sol";
|
||||
import {ICurve} from "./bonding-curves/ICurve.sol";
|
||||
import {LSSVMRouter} from "./LSSVMRouter.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
import {CurveErrorCodes} from "./bonding-curves/CurveErrorCodes.sol";
|
||||
|
||||
/// @title The base contract for an NFT/TOKEN AMM pair
|
||||
@@ -22,17 +22,22 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
// 90%, must <= 1 - MAX_PROTOCOL_FEE (set in LSSVMPairFactory)
|
||||
uint256 internal constant MAX_FEE = 0.90e18;
|
||||
|
||||
// NOTE: We use uint128 here to pack spot price and delta into one storage slot, but
|
||||
// NOTE: We use uint128 here for spotPrice and delta to pack them into one storage slot, but
|
||||
// treat them as uint256 during math calculations. LPs should be aware of potential
|
||||
// overflow when setting very large spot price and/or delta.
|
||||
// overflow when setting very large spot price and/or delta!
|
||||
|
||||
// The current price of the NFT
|
||||
// @dev This is generally used to mean the immediate sell price for the next marginal NFT.
|
||||
// However, this should NOT be assumed! Use getBuyNFTQuote and getSellNFTQuote for accurate pricing info.
|
||||
uint128 public spotPrice;
|
||||
|
||||
// The parameter for the pair's bonding curve
|
||||
// The parameter for the pair's bonding curve.
|
||||
// Units and meaning are bonding curve dependent.
|
||||
uint128 public delta;
|
||||
|
||||
// The spread between buy and sell prices. Fee is only relevant for TRADE pools
|
||||
// The spread between buy and sell prices, set to be a multiplier we apply to the buy price
|
||||
// Fee is only relevant for TRADE pools
|
||||
// Units are in base 1e18
|
||||
uint96 public fee;
|
||||
|
||||
// If set to 0, NFTs/tokens sent by traders during trades will be sent to the pair.
|
||||
@@ -50,11 +55,11 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
uint256[] nftIds,
|
||||
bool nftsIntoPool
|
||||
);
|
||||
event SpotPriceUpdated(uint128 newSpotPrice);
|
||||
event TokenDeposited(uint256 amount);
|
||||
event TokenWithdrawn(uint256 amount);
|
||||
event DeltaUpdated(uint128 newDelta);
|
||||
event FeeUpdated(uint96 newFee);
|
||||
event SpotPriceUpdate(uint128 newSpotPrice);
|
||||
event TokenDeposit(uint256 amount);
|
||||
event TokenWithdrawal(uint256 amount);
|
||||
event DeltaUpdate(uint128 newDelta);
|
||||
event FeeUpdate(uint96 newFee);
|
||||
|
||||
/**
|
||||
@notice Called during pool creation to set initial parameters
|
||||
@@ -127,7 +132,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
bool isRouter,
|
||||
address routerCaller
|
||||
) nonReentrant external payable virtual returns (uint256 inputAmount) {
|
||||
LSSVMPairFactoryLike _factory = factory();
|
||||
ILSSVMPairFactoryLike _factory = factory();
|
||||
ICurve _bondingCurve = bondingCurve();
|
||||
IERC721 _nft = nft();
|
||||
|
||||
@@ -161,7 +166,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
|
||||
// Update spot price
|
||||
spotPrice = uint128(newSpotPrice);
|
||||
emit SpotPriceUpdated(uint128(newSpotPrice));
|
||||
emit SpotPriceUpdate(uint128(newSpotPrice));
|
||||
}
|
||||
|
||||
_pullTokenInputAndPayProtocolFee(
|
||||
@@ -198,7 +203,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
bool isRouter,
|
||||
address routerCaller
|
||||
) nonReentrant external payable virtual returns (uint256 inputAmount) {
|
||||
LSSVMPairFactoryLike _factory = factory();
|
||||
ILSSVMPairFactoryLike _factory = factory();
|
||||
ICurve _bondingCurve = bondingCurve();
|
||||
IERC721 _nft = nft();
|
||||
|
||||
@@ -233,7 +238,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
|
||||
// Update spot price
|
||||
spotPrice = uint128(newSpotPrice);
|
||||
emit SpotPriceUpdated(uint128(newSpotPrice));
|
||||
emit SpotPriceUpdate(uint128(newSpotPrice));
|
||||
}
|
||||
|
||||
_pullTokenInputAndPayProtocolFee(
|
||||
@@ -298,7 +303,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
|
||||
// Update spot price
|
||||
spotPrice = uint128(newSpotPrice);
|
||||
emit SpotPriceUpdated(uint128(newSpotPrice));
|
||||
emit SpotPriceUpdate(uint128(newSpotPrice));
|
||||
}
|
||||
|
||||
// Pricing-dependent validation
|
||||
@@ -380,9 +385,9 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
public
|
||||
pure
|
||||
virtual
|
||||
returns (LSSVMPairFactoryLike.PairVariant);
|
||||
returns (ILSSVMPairFactoryLike.PairVariant);
|
||||
|
||||
function factory() public pure returns (LSSVMPairFactoryLike _factory) {
|
||||
function factory() public pure returns (ILSSVMPairFactoryLike _factory) {
|
||||
uint256 paramsLength = _immutableParamsLength();
|
||||
assembly {
|
||||
_factory := shr(
|
||||
@@ -471,7 +476,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
uint256 inputAmount,
|
||||
bool isRouter,
|
||||
address routerCaller,
|
||||
LSSVMPairFactoryLike _factory,
|
||||
ILSSVMPairFactoryLike _factory,
|
||||
uint256 protocolFee
|
||||
) internal virtual;
|
||||
|
||||
@@ -485,7 +490,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
/**
|
||||
@notice Sends protocol fee (if it exists) back to the LSSVMPairFactory from the pair
|
||||
*/
|
||||
function _payProtocolFeeFromPair(LSSVMPairFactoryLike _factory, uint256 protocolFee)
|
||||
function _payProtocolFeeFromPair(ILSSVMPairFactoryLike _factory, uint256 protocolFee)
|
||||
internal
|
||||
virtual;
|
||||
|
||||
@@ -623,7 +628,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
"Invalid new spot price for curve"
|
||||
);
|
||||
spotPrice = newSpotPrice;
|
||||
emit SpotPriceUpdated(newSpotPrice);
|
||||
emit SpotPriceUpdate(newSpotPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,7 +642,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
"Invalid delta for curve"
|
||||
);
|
||||
delta = newDelta;
|
||||
emit DeltaUpdated(newDelta);
|
||||
emit DeltaUpdate(newDelta);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -651,7 +656,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
require(_poolType == PoolType.TRADE, "Only for Trade pools");
|
||||
require(newFee < MAX_FEE, "Trade fee must be less than 90%");
|
||||
fee = newFee;
|
||||
emit FeeUpdated(newFee);
|
||||
emit FeeUpdate(newFee);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,7 +682,7 @@ abstract contract LSSVMPair is Ownable, ReentrancyGuard {
|
||||
external
|
||||
onlyOwner
|
||||
{
|
||||
LSSVMPairFactoryLike _factory = factory();
|
||||
ILSSVMPairFactoryLike _factory = factory();
|
||||
require(_factory.callAllowed(target), "Target must be whitelisted");
|
||||
(bool result, ) = target.call{value: 0}(data);
|
||||
require(result, "Call failed");
|
||||
|
||||
@@ -5,7 +5,7 @@ import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
|
||||
import {ERC20} from "solmate/tokens/ERC20.sol";
|
||||
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {LSSVMPair} from "./LSSVMPair.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
import {LSSVMRouter} from "./LSSVMRouter.sol";
|
||||
import {ICurve} from "./bonding-curves/ICurve.sol";
|
||||
import {CurveErrorCodes} from "./bonding-curves/CurveErrorCodes.sol";
|
||||
@@ -36,7 +36,7 @@ abstract contract LSSVMPairERC20 is LSSVMPair {
|
||||
uint256 inputAmount,
|
||||
bool isRouter,
|
||||
address routerCaller,
|
||||
LSSVMPairFactoryLike _factory,
|
||||
ILSSVMPairFactoryLike _factory,
|
||||
uint256 protocolFee
|
||||
) internal override {
|
||||
require(msg.value == 0, "ERC20 pair");
|
||||
@@ -107,7 +107,7 @@ abstract contract LSSVMPairERC20 is LSSVMPair {
|
||||
|
||||
/// @inheritdoc LSSVMPair
|
||||
function _payProtocolFeeFromPair(
|
||||
LSSVMPairFactoryLike _factory,
|
||||
ILSSVMPairFactoryLike _factory,
|
||||
uint256 protocolFee
|
||||
) internal override {
|
||||
// Take protocol fee (if it exists)
|
||||
@@ -135,6 +135,7 @@ abstract contract LSSVMPairERC20 is LSSVMPair {
|
||||
}
|
||||
|
||||
/// @inheritdoc LSSVMPair
|
||||
// @dev see LSSVMPairCloner for params length calculation
|
||||
function _immutableParamsLength() internal pure override returns (uint256) {
|
||||
return 81;
|
||||
}
|
||||
@@ -149,7 +150,7 @@ abstract contract LSSVMPairERC20 is LSSVMPair {
|
||||
|
||||
if (a == address(token())) {
|
||||
// emit event since it is the pair token
|
||||
emit TokenWithdrawn(amount);
|
||||
emit TokenWithdrawal(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {ERC20} from "solmate/tokens/ERC20.sol";
|
||||
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
|
||||
import {LSSVMPair} from "./LSSVMPair.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
import {ICurve} from "./bonding-curves/ICurve.sol";
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
uint256 inputAmount,
|
||||
bool, /*isRouter*/
|
||||
address, /*routerCaller*/
|
||||
LSSVMPairFactoryLike _factory,
|
||||
ILSSVMPairFactoryLike _factory,
|
||||
uint256 protocolFee
|
||||
) internal override {
|
||||
require(msg.value >= inputAmount, "Sent too little ETH");
|
||||
@@ -51,7 +51,7 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
}
|
||||
|
||||
/// @inheritdoc LSSVMPair
|
||||
function _payProtocolFeeFromPair(LSSVMPairFactoryLike _factory, uint256 protocolFee)
|
||||
function _payProtocolFeeFromPair(ILSSVMPairFactoryLike _factory, uint256 protocolFee)
|
||||
internal
|
||||
override
|
||||
{
|
||||
@@ -77,6 +77,7 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
}
|
||||
|
||||
/// @inheritdoc LSSVMPair
|
||||
// @dev see LSSVMPairCloner for params length calculation
|
||||
function _immutableParamsLength() internal pure override returns (uint256) {
|
||||
return 61;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
payable(owner()).safeTransferETH(amount);
|
||||
|
||||
// emit event since ETH is the pair token
|
||||
emit TokenWithdrawn(amount);
|
||||
emit TokenWithdrawal(amount);
|
||||
}
|
||||
|
||||
/// @inheritdoc LSSVMPair
|
||||
@@ -116,7 +117,7 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
for the owner to top up the pair's token reserves.
|
||||
*/
|
||||
receive() external payable {
|
||||
emit TokenDeposited(msg.value);
|
||||
emit TokenDeposit(msg.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +127,6 @@ abstract contract LSSVMPairETH is LSSVMPair {
|
||||
fallback() external payable {
|
||||
// Only allow calls without function selector
|
||||
require (msg.data.length == _immutableParamsLength());
|
||||
emit TokenDeposited(msg.value);
|
||||
emit TokenDeposit(msg.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions
|
||||
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {LSSVMRouter} from "./LSSVMRouter.sol";
|
||||
import {LSSVMPair} from "./LSSVMPair.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
/**
|
||||
@title An NFT/Token pair for an NFT that implements ERC721Enumerable
|
||||
|
||||
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
||||
|
||||
import {LSSVMPairERC20} from "./LSSVMPairERC20.sol";
|
||||
import {LSSVMPairEnumerable} from "./LSSVMPairEnumerable.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
/**
|
||||
@title An NFT/Token pair where the NFT implements ERC721Enumerable, and the token is an ERC20
|
||||
@@ -17,8 +17,8 @@ contract LSSVMPairEnumerableERC20 is LSSVMPairEnumerable, LSSVMPairERC20 {
|
||||
public
|
||||
pure
|
||||
override
|
||||
returns (LSSVMPairFactoryLike.PairVariant)
|
||||
returns (ILSSVMPairFactoryLike.PairVariant)
|
||||
{
|
||||
return LSSVMPairFactoryLike.PairVariant.ENUMERABLE_ERC20;
|
||||
return ILSSVMPairFactoryLike.PairVariant.ENUMERABLE_ERC20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
||||
|
||||
import {LSSVMPairETH} from "./LSSVMPairETH.sol";
|
||||
import {LSSVMPairEnumerable} from "./LSSVMPairEnumerable.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
/**
|
||||
@title An NFT/Token pair where the NFT implements ERC721Enumerable, and the token is ETH
|
||||
@@ -17,8 +17,8 @@ contract LSSVMPairEnumerableETH is LSSVMPairEnumerable, LSSVMPairETH {
|
||||
public
|
||||
pure
|
||||
override
|
||||
returns (LSSVMPairFactoryLike.PairVariant)
|
||||
returns (ILSSVMPairFactoryLike.PairVariant)
|
||||
{
|
||||
return LSSVMPairFactoryLike.PairVariant.ENUMERABLE_ETH;
|
||||
return ILSSVMPairFactoryLike.PairVariant.ENUMERABLE_ETH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import {LSSVMPairETH} from "./LSSVMPairETH.sol";
|
||||
import {ICurve} from "./bonding-curves/ICurve.sol";
|
||||
import {LSSVMPairERC20} from "./LSSVMPairERC20.sol";
|
||||
import {LSSVMPairCloner} from "./lib/LSSVMPairCloner.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
contract LSSVMPairFactory is Ownable, ILSSVMPairFactoryLike {
|
||||
using LSSVMPairCloner for address;
|
||||
using SafeTransferLib for address payable;
|
||||
using SafeTransferLib for ERC20;
|
||||
@@ -34,6 +34,8 @@ contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
LSSVMPairERC20 public immutable enumerableERC20Template;
|
||||
LSSVMPairERC20 public immutable missingEnumerableERC20Template;
|
||||
address payable public override protocolFeeRecipient;
|
||||
|
||||
// Units are in base 1e18
|
||||
uint256 public override protocolFeeMultiplier;
|
||||
|
||||
mapping(ICurve => bool) public bondingCurveAllowed;
|
||||
@@ -44,7 +46,7 @@ contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
}
|
||||
mapping(LSSVMRouter => RouterStatus) public override routerStatus;
|
||||
|
||||
event PairCreated(address poolAddress, address nft);
|
||||
event NewPair(address pairAddress);
|
||||
|
||||
constructor(
|
||||
LSSVMPairETH _enumerableETHTemplate,
|
||||
@@ -146,7 +148,7 @@ contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
_spotPrice,
|
||||
_initialNFTIDs
|
||||
);
|
||||
emit PairCreated(address(pair), address(_nft));
|
||||
emit NewPair(address(pair));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +219,7 @@ contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
params.initialNFTIDs,
|
||||
params.initialTokenBalance
|
||||
);
|
||||
emit PairCreated(address(pair), address(params.nft));
|
||||
emit NewPair(address(pair));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,7 +440,7 @@ contract LSSVMPairFactory is Ownable, LSSVMPairFactoryLike {
|
||||
uint256[] calldata ids,
|
||||
address recipient
|
||||
) external {
|
||||
// transfer initial NFTs from caller to recipient
|
||||
// transfer NFTs from caller to recipient
|
||||
for (uint256 i = 0; i < ids.length; i++) {
|
||||
_nft.safeTransferFrom(msg.sender, recipient, ids[i]);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
||||
import {LSSVMPair} from "./LSSVMPair.sol";
|
||||
import {LSSVMRouter} from "./LSSVMRouter.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
/**
|
||||
@title An NFT/Token pair for an NFT that does not implement ERC721Enumerable
|
||||
|
||||
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
||||
|
||||
import {LSSVMPairERC20} from "./LSSVMPairERC20.sol";
|
||||
import {LSSVMPairMissingEnumerable} from "./LSSVMPairMissingEnumerable.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
contract LSSVMPairMissingEnumerableERC20 is
|
||||
LSSVMPairMissingEnumerable,
|
||||
@@ -13,8 +13,8 @@ contract LSSVMPairMissingEnumerableERC20 is
|
||||
public
|
||||
pure
|
||||
override
|
||||
returns (LSSVMPairFactoryLike.PairVariant)
|
||||
returns (ILSSVMPairFactoryLike.PairVariant)
|
||||
{
|
||||
return LSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ERC20;
|
||||
return ILSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ERC20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
||||
|
||||
import {LSSVMPairETH} from "./LSSVMPairETH.sol";
|
||||
import {LSSVMPairMissingEnumerable} from "./LSSVMPairMissingEnumerable.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
|
||||
contract LSSVMPairMissingEnumerableETH is
|
||||
LSSVMPairMissingEnumerable,
|
||||
@@ -13,8 +13,8 @@ contract LSSVMPairMissingEnumerableETH is
|
||||
public
|
||||
pure
|
||||
override
|
||||
returns (LSSVMPairFactoryLike.PairVariant)
|
||||
returns (ILSSVMPairFactoryLike.PairVariant)
|
||||
{
|
||||
return LSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ETH;
|
||||
return ILSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ETH;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@ import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {ERC20} from "solmate/tokens/ERC20.sol";
|
||||
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
|
||||
import {LSSVMPair} from "./LSSVMPair.sol";
|
||||
import {LSSVMPairFactoryLike} from "./LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "./ILSSVMPairFactoryLike.sol";
|
||||
import {CurveErrorCodes} from "./bonding-curves/CurveErrorCodes.sol";
|
||||
|
||||
contract LSSVMRouter {
|
||||
@@ -37,9 +37,9 @@ contract LSSVMRouter {
|
||||
_;
|
||||
}
|
||||
|
||||
LSSVMPairFactoryLike public immutable factory;
|
||||
ILSSVMPairFactoryLike public immutable factory;
|
||||
|
||||
constructor(LSSVMPairFactoryLike _factory) {
|
||||
constructor(ILSSVMPairFactoryLike _factory) {
|
||||
factory = _factory;
|
||||
}
|
||||
|
||||
@@ -581,16 +581,16 @@ contract LSSVMRouter {
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount,
|
||||
LSSVMPairFactoryLike.PairVariant variant
|
||||
ILSSVMPairFactoryLike.PairVariant variant
|
||||
) external {
|
||||
// verify caller is a trusted pair contract
|
||||
require(factory.isPair(msg.sender, variant), "Not pair");
|
||||
|
||||
// verify caller is an ERC20 pair
|
||||
require(
|
||||
variant == LSSVMPairFactoryLike.PairVariant.ENUMERABLE_ERC20 ||
|
||||
variant == ILSSVMPairFactoryLike.PairVariant.ENUMERABLE_ERC20 ||
|
||||
variant ==
|
||||
LSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ERC20,
|
||||
ILSSVMPairFactoryLike.PairVariant.MISSING_ENUMERABLE_ERC20,
|
||||
"Not ERC20 pair"
|
||||
);
|
||||
|
||||
@@ -612,7 +612,7 @@ contract LSSVMRouter {
|
||||
address from,
|
||||
address to,
|
||||
uint256 id,
|
||||
LSSVMPairFactoryLike.PairVariant variant
|
||||
ILSSVMPairFactoryLike.PairVariant variant
|
||||
) external {
|
||||
// verify caller is a trusted pair contract
|
||||
require(factory.isPair(msg.sender, variant), "Not pair");
|
||||
|
||||
@@ -59,6 +59,7 @@ contract ExponentialCurve is ICurve, CurveErrorCodes {
|
||||
uint256 protocolFee
|
||||
)
|
||||
{
|
||||
// NOTE: we assume delta is > 1, as checked by validateDelta()
|
||||
|
||||
// We only calculate changes for buying 1 or more NFTs
|
||||
if (numItems == 0) {
|
||||
@@ -128,6 +129,8 @@ contract ExponentialCurve is ICurve, CurveErrorCodes {
|
||||
uint256 protocolFee
|
||||
)
|
||||
{
|
||||
// NOTE: we assume delta is > 1, as checked by validateDelta()
|
||||
|
||||
// We only calculate changes for buying 1 or more NFTs
|
||||
if (numItems == 0) {
|
||||
return (Error.INVALID_NUMITEMS, 0, 0, 0);
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ICurve {
|
||||
function validateDelta(uint256 delta) external pure returns (bool valid);
|
||||
|
||||
/**
|
||||
@notice Validates if a new spot price is valid for the curve.
|
||||
@notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token.
|
||||
@param newSpotPrice The new spot price to be set
|
||||
@return valid True if the new spot price is valid, false otherwise
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
import {ERC20} from "solmate/tokens/ERC20.sol";
|
||||
|
||||
import {ICurve} from "../bonding-curves/ICurve.sol";
|
||||
import {LSSVMPairFactoryLike} from "../LSSVMPairFactoryLike.sol";
|
||||
import {ILSSVMPairFactoryLike} from "../ILSSVMPairFactoryLike.sol";
|
||||
|
||||
library LSSVMPairCloner {
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ library LSSVMPairCloner {
|
||||
*/
|
||||
function cloneETHPair(
|
||||
address implementation,
|
||||
LSSVMPairFactoryLike factory,
|
||||
ILSSVMPairFactoryLike factory,
|
||||
ICurve bondingCurve,
|
||||
IERC721 nft,
|
||||
uint8 poolType
|
||||
@@ -110,7 +110,7 @@ library LSSVMPairCloner {
|
||||
*/
|
||||
function cloneERC20Pair(
|
||||
address implementation,
|
||||
LSSVMPairFactoryLike factory,
|
||||
ILSSVMPairFactoryLike factory,
|
||||
ICurve bondingCurve,
|
||||
IERC721 nft,
|
||||
uint8 poolType,
|
||||
|
||||
Reference in New Issue
Block a user