BaseDirectToLiquidity
Inherits: BaseCallback
Base contract for DirectToLiquidity callbacks
This contract is intended to be inherited by a callback contract that supports a particular liquidity platform, such as Uniswap V2 or V3. It provides integration points that enable the implementing contract to support different liquidity platforms. NOTE: The parameters to the functions in this contract refer to linear vesting, which is currently only supported for ERC20 pool tokens. A future version could improve upon this by shifting the (ERC20) linear vesting functionality into a variant that inherits from this contract.
State Variables
ONE_HUNDRED_PERCENT
uint24 public constant ONE_HUNDRED_PERCENT = 100e2;
LINEAR_VESTING_KEYCODE
bytes5 public constant LINEAR_VESTING_KEYCODE = 0x4c49560000;
lotConfiguration
Maps the lot id to the DTL configuration
mapping(uint96 lotId => DTLConfiguration) public lotConfiguration;
Functions
constructor
constructor(
address auctionHouse_
)
BaseCallback(
auctionHouse_,
Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: false,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: false
})
);
_onCreate
Callback for when a lot is created
This function performs the following:
- Validates the input data
- Calls the Uniswap-specific implementation
- Stores the configuration for the lot
This function reverts if:
- OnCreateParams.poolPercent is out of bounds
- OnCreateParams.vestingStart or OnCreateParams.vestingExpiry do not pass validation
- Vesting is enabled and the linear vesting module is not found
- The OnCreateParams.recipient address is the zero address
function _onCreate(
uint96 lotId_,
address seller_,
address baseToken_,
address quoteToken_,
uint256 capacity_,
bool prefund_,
bytes calldata callbackData_
) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
seller_ | address | |
baseToken_ | address | The base token address |
quoteToken_ | address | The quote token address |
capacity_ | uint256 | The capacity of the lot |
prefund_ | bool | |
callbackData_ | bytes | Encoded OnCreateParams struct |
__onCreate
Uniswap-specific implementation of the onCreate callback
The implementation will be called by the _onCreate function
after the callbackData_
has been validated and after the
lot configuration is stored.
The implementation should perform the following:
- Additional validation
function __onCreate(
uint96 lotId_,
address seller_,
address baseToken_,
address quoteToken_,
uint256 capacity_,
bool prefund_,
bytes calldata callbackData_
) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
seller_ | address | The seller address |
baseToken_ | address | The base token address |
quoteToken_ | address | The quote token address |
capacity_ | uint256 | The capacity of the lot |
prefund_ | bool | Whether the lot is prefunded |
callbackData_ | bytes | Encoded OnCreateParams struct |
_onCancel
Callback for when a lot is cancelled
This function performs the following:
- Marks the lot as inactive
This function reverts if:
- The lot is not registered
- The lot has already been completed
function _onCancel(uint96 lotId_, uint256, bool, bytes calldata) internal override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
<none> | uint256 | |
<none> | bool | |
<none> | bytes |
_onCurate
Callback for when a lot is curated
This function performs the following:
- Records the curator payout
This function reverts if:
- The lot is not registered
- The lot has already been completed
function _onCurate(uint96 lotId_, uint256 curatorPayout_, bool, bytes calldata) internal override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
curatorPayout_ | uint256 | The maximum curator payout |
<none> | bool | |
<none> | bytes |
_onPurchase
Callback for a purchase
Not implemented
function _onPurchase(
uint96,
address,
uint256,
uint256,
bool,
bytes calldata
) internal pure override;
_onBid
Callback for a bid
Not implemented
function _onBid(uint96, uint64, address, uint256, bytes calldata) internal pure override;
_onSettle
Callback for claiming the proceeds
This function performs the following:
- Calculates the base and quote tokens to deposit into the pool
- Calls the Uniswap-specific implementation to mint and deposit into the pool
- If vesting is enabled, mints the vesting tokens, or transfers the LP tokens to the recipient
- Sends any remaining quote and base tokens to the seller
The assumptions are:
- the callback has
proceeds_
quantity of quote tokens (asreceiveQuoteTokens
flag is set) - the seller has the required balance of base tokens
- the seller has approved the callback to spend the base tokens
This function reverts if:
- The lot is not registered
- The lot is already complete
function _onSettle(
uint96 lotId_,
uint256 proceeds_,
uint256 refund_,
bytes calldata callbackData_
) internal virtual override;
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
proceeds_ | uint256 | The proceeds from the auction |
refund_ | uint256 | The refund from the auction |
callbackData_ | bytes | Implementation-specific data |
_mintAndDeposit
Mint and deposit into the pool
This function should be implemented by the Uniswap-specific callback
It is expected to:
- Create and initialize the pool
- Deposit the quote and base tokens into the pool
- The pool tokens should be received by this contract
- Return the ERC20 pool token
function _mintAndDeposit(
uint96 lotId_,
address quoteToken_,
uint256 quoteTokenAmount_,
address baseToken_,
uint256 baseTokenAmount_,
bytes memory callbackData_
) internal virtual returns (ERC20 poolToken);
Parameters
Name | Type | Description |
---|---|---|
lotId_ | uint96 | The lot ID |
quoteToken_ | address | The quote token address |
quoteTokenAmount_ | uint256 | The amount of quote tokens to deposit |
baseToken_ | address | The base token address |
baseTokenAmount_ | uint256 | The amount of base tokens to deposit |
callbackData_ | bytes | Implementation-specific data |
Returns
Name | Type | Description |
---|---|---|
poolToken | ERC20 | The ERC20 pool token |
_getAmountWithSlippage
function _getAmountWithSlippage(
uint256 amount_,
uint24 slippage_
) internal pure returns (uint256);
_tokensRequiredForPool
function _tokensRequiredForPool(
uint256 amount_,
uint24 poolPercent_
) internal pure returns (uint256);
_getLatestLinearVestingModule
function _getLatestLinearVestingModule() internal view returns (address);
_getEncodedVestingParams
function _getEncodedVestingParams(
uint48 start_,
uint48 expiry_
) internal pure returns (bytes memory);
Errors
Callback_InsufficientBalance
error Callback_InsufficientBalance(
address token_, address account_, uint256 balance_, uint256 required_
);
Callback_Params_InvalidAddress
error Callback_Params_InvalidAddress();
Callback_Params_PercentOutOfBounds
error Callback_Params_PercentOutOfBounds(uint24 actual_, uint24 min_, uint24 max_);
Callback_Params_PoolExists
error Callback_Params_PoolExists();
Callback_Params_InvalidVestingParams
error Callback_Params_InvalidVestingParams();
Callback_LinearVestingModuleNotFound
error Callback_LinearVestingModuleNotFound();
Callback_AlreadyComplete
The auction lot has already been completed
error Callback_AlreadyComplete();
Structs
DTLConfiguration
Configuration for the DTL callback
struct DTLConfiguration {
address recipient;
uint256 lotCapacity;
uint256 lotCuratorPayout;
uint24 poolPercent;
uint48 vestingStart;
uint48 vestingExpiry;
LinearVesting linearVestingModule;
bool active;
bytes implParams;
}
Properties
Name | Type | Description |
---|---|---|
recipient | address | Recipient of the LP tokens |
lotCapacity | uint256 | Capacity of the lot |
lotCuratorPayout | uint256 | Maximum curator payout of the lot |
poolPercent | uint24 | Percentage of the proceeds to allocate to the pool, in basis points (1% = 100). The remainder will be sent to the recipient . |
vestingStart | uint48 | Start of the vesting period for the LP tokens (0 if disabled) |
vestingExpiry | uint48 | End of the vesting period for the LP tokens (0 if disabled) |
linearVestingModule | LinearVesting | LinearVesting module for the LP tokens (only set if linear vesting is enabled) |
active | bool | Whether the lot is active |
implParams | bytes | Implementation-specific parameters |
OnCreateParams
Parameters used in the onCreate callback
struct OnCreateParams {
uint24 poolPercent;
uint48 vestingStart;
uint48 vestingExpiry;
address recipient;
bytes implParams;
}
Properties
Name | Type | Description |
---|---|---|
poolPercent | uint24 | Percentage of the proceeds to allocate to the pool, in basis points (1% = 100). The remainder will be sent to the recipient . |
vestingStart | uint48 | Start of the vesting period for the LP tokens (0 if disabled) |
vestingExpiry | uint48 | End of the vesting period for the LP tokens (0 if disabled) |
recipient | address | Recipient of the LP tokens |
implParams | bytes | Implementation-specific parameters |