Skip to main content

BaselineAxisLaunch

Git Source

Inherits: BaseCallback, Policy, Owned

Axis auction callback to initialize a Baseline token using proceeds from a batch auction.

This contract combines Baseline's InitializeProtocol Policy and Axis' Callback functionality to build an Axis auction callback specific to Baseline V2 token launches

It is designed to be used with a single auction and Baseline pool

State Variables

_MAX_TICK

int24 internal constant _MAX_TICK = 887_272;

_MIN_TICK

int24 internal constant _MIN_TICK = -887_272;

BPOOL

IBPOOLv1 public BPOOL;

CREDT

ICREDTv1 public CREDT;

LOOPS

ILOOPSv1 public LOOPS;

RESERVE

ERC20 public immutable RESERVE;

bAsset

ERC20 public bAsset;

lotId

Lot ID of the auction for the baseline market. This callback only supports one lot.

This value is initialised with the uint96 max value to indicate that it has not been set yet.

uint96 public lotId;

auctionComplete

Indicates whether the auction is complete

This is used to prevent the callback from being called multiple times. It is set in the onSettle() callback.

bool public auctionComplete;

poolPercent

The percentage of the proceeds to allocate to the pool

This value is set in the onCreate() callback.

uint24 public poolPercent;

floorReservesPercent

The percentage of the proceeds to allocate to the floor range

This value is set in the onCreate() callback.

uint24 public floorReservesPercent;

recipient

The address to receive proceeds that do not go to the pool

This value is set in the onCreate() callback.

address public recipient;

ONE_HUNDRED_PERCENT

uint48 internal constant ONE_HUNDRED_PERCENT = 100e2;

_DISCOVERY_TICK_SPACING_WIDTH

The tick spacing width of the discovery range

int24 internal constant _DISCOVERY_TICK_SPACING_WIDTH = 350;

Functions

constructor

Constructor for BaselineAxisLaunch

constructor(
address auctionHouse_,
address baselineKernel_,
address reserve_,
address owner_
)
BaseCallback(
auctionHouse_,
Callbacks.Permissions({
onCreate: true,
onCancel: true,
onCurate: true,
onPurchase: false,
onBid: true,
onSettle: true,
receiveQuoteTokens: true,
sendBaseTokens: true
})
)
Policy(Kernel(baselineKernel_))
Owned(owner_);

Parameters

NameTypeDescription
auctionHouse_addressThe AuctionHouse the callback is paired with
baselineKernel_addressAddress of the Baseline kernel
reserve_addressAddress of the reserve token. This should match the quote token for the auction lot.
owner_addressAddress of the owner of the contract. Must be the same as the eventual seller of the auction lot.

configureDependencies

Define module dependencies for this policy.

function configureDependencies()
external
override
onlyKernel
returns (BaselineKeycode[] memory dependencies);

Returns

NameTypeDescription
dependenciesBaselineKeycode[]- Keycode array of module dependencies.

requestPermissions

Function called by kernel to set module function permissions.

function requestPermissions()
external
view
override
onlyKernel
returns (BaselinePermissions[] memory requests);

Returns

NameTypeDescription
requestsBaselinePermissions[]- Array of keycodes and function selectors for requested permissions.

onlyValidLot

Validates that the lot id matches the stored lot id

modifier onlyValidLot(uint96 lotId_);

onlyActiveLot

Validates that the auction is not already settled or cancelled

modifier onlyActiveLot();

_onCreate

This function performs the following:

  • Performs validation
  • Sets the lotId, percentReservesFloor, anchorTickWidth, and discoveryTickWidth variables
  • Calls the allowlist callback
  • Performs a solvency check to ensure the pool can support the intended supply
  • Mints the required bAsset tokens to the AuctionHouse

This function has the following assumptions:

  • Any Baseline credit allocations have been minted and allocated prior to auction creation (and this callback)

This function reverts if:

  • seller_ is not the owner
  • baseToken_ is not the same as bAsset
  • quoteToken_ is not the same as RESERVE
  • baseToken_ is not lower than quoteToken_
  • recipient is the zero address
  • lotId is already set
  • The pool fee tier is not supported
  • CreateData.floorReservesPercent is less than 10% or greater than 90%
  • CreateData.poolPercent is less than 10% or greater than 100%
  • CreateData.floorRangeGap is < 0
  • CreateData.anchorTickWidth is < 10 or > 50
  • The auction format is not supported
  • The auction is not prefunded
  • Any of the tick ranges would exceed the tick bounds
  • The provided anchor range upper tick is not the same as the calculated value
  • The pool tick is less than the auction price (in terms of ticks)
  • The pool capacity is not sufficient to support the intended supply
function _onCreate(
uint96 lotId_,
address seller_,
address baseToken_,
address quoteToken_,
uint256 capacity_,
bool prefund_,
bytes calldata callbackData_
) internal override;

__onCreate

Override this function to implement allowlist functionality

function __onCreate(
uint96 lotId_,
address seller_,
address baseToken_,
address quoteToken_,
uint256 capacity_,
bool prefund_,
bytes memory allowlistData_
) internal virtual;

_onCancel

This function performs the following:

  • Performs validation
  • Burns the refunded bAsset tokens

This function has the following assumptions:

  • BaseCallback has already validated the lot ID
  • The AuctionHouse has already sent the correct amount of bAsset tokens
  • The auction seller has manually unlocked BPOOL transfers, in order to allow the transfer of BPOOL tokens from the AuctionHouse to the callback

This function reverts if:

  • lotId_ is not the same as the stored lotId
  • The auction is already complete
  • Sufficient quantity of bAsset have not been sent to the callback
function _onCancel(
uint96 lotId_,
uint256 refund_,
bool,
bytes calldata
) internal override onlyValidLot(lotId_) onlyActiveLot;

_onCurate

This function performs the following:

  • Performs validation

This function has the following assumptions:

  • BaseCallback has already validated the lot ID

This function reverts if:

  • lotId_ is not the same as the stored lotId
  • The curator fee is non-zero
function _onCurate(
uint96 lotId_,
uint256 curatorFee_,
bool,
bytes calldata
) internal override onlyValidLot(lotId_) onlyActiveLot;

_onPurchase

Not implemented since atomic auctions are not supported

function _onPurchase(
uint96,
address,
uint256,
uint256,
bool,
bytes calldata
) internal pure override;

_onBid

No logic is needed for this function here, but it can be overridden by a lower-level contract to provide allowlist functionality

function _onBid(
uint96 lotId_,
uint64 bidId,
address buyer_,
uint256 amount_,
bytes calldata callbackData_
) internal virtual override;

_onSettle

This function performs the following:

  • Performs validation
  • Sets the auction as complete
  • Burns any refunded bAsset tokens
  • Ensures that the pool is at the correct price
  • Deploys reserves and liquidity into the Baseline pool
  • Performs a solvency check to ensure the pool can support the supply
  • Transfers any remaining proceeds (reserves) to the recipient

Next steps:

  • Activate the market making and credit facility policies in the Baseline stack, which cannot be enabled before the auction is settled and the pool is initialized

This function has the following assumptions:

  • BaseCallback has already validated the lot ID
  • The AuctionHouse has already sent the correct amount of quote tokens (proceeds)
  • The AuctionHouse has already sent the correct amount of refunded base tokens
  • The AuctionHouse is pre-funded, so does not require additional base tokens (bAssets) to be supplied
  • No new Baseline credit allocations have been made since the auction was created (and onCreate was called)
  • The auction seller has manually unlocked BPOOL transfers, in order to allow the transfer of refunded BPOOL tokens from the AuctionHouse to the callback

This function reverts if:

  • lotId_ is not the same as the stored lotId
  • The auction is already complete
  • The reported proceeds received are less than the reserve balance
  • The reported refund received is less than the bAsset balance
  • The pool price is not at the target price
  • The pool capacity is not sufficient to support the intended supply

Note that while the solvency check in both onCreate and onSettle are consistent, if the auction is not fully subscribed (and hence there is a refund), it can cause the solvency check to fail in onSettle.

function _onSettle(
uint96 lotId_,
uint256 proceeds_,
uint256 refund_,
bytes calldata
) internal virtual override onlyValidLot(lotId_) onlyActiveLot;

_getExpectedProceeds

Calculate the expected proceeds from the auction and how much will be deposited in the pool

The proceeds sent to the onSettle callback function will exclude any protocol and referrer fees, so this calculation mimics the behaviour

function _getExpectedProceeds(
uint96 lotId_,
uint256 auctionPrice_,
uint256 capacity_
) internal view returns (uint256);

Parameters

NameTypeDescription
lotId_uint96Lot ID of the auction
auctionPrice_uint256Price of the auction
capacity_uint256Capacity of the auction

Returns

NameTypeDescription
<none>uint256proceeds Expected proceeds from the auction

uniswapV3SwapCallback

function uniswapV3SwapCallback(int256 bAssetDelta_, int256, bytes calldata data_) external;

Events

LiquidityDeployed

event LiquidityDeployed(
int24 floorTickLower, int24 anchorTickUpper, uint128 floorLiquidity, uint128 anchorLiquidity
);

Errors

Callback_Params_BAssetTokenMismatch

The address of the base token (passed in the onCreate callback) does not match the address of the bAsset that the callback was initialized with

error Callback_Params_BAssetTokenMismatch(address baseToken_, address bAsset_);

Callback_Params_ReserveTokenMismatch

The address of the quote token (passed in the onCreate callback) does not match the address of the reserve that the callback was initialized with

error Callback_Params_ReserveTokenMismatch(address quoteToken_, address reserve_);

Callback_Params_UnsupportedAuctionFormat

The auction format is not supported

error Callback_Params_UnsupportedAuctionFormat();

Callback_Params_UnsupportedPoolFeeTier

The pool fee tier is not supported

error Callback_Params_UnsupportedPoolFeeTier();

Callback_Params_InvalidAnchorTickWidth

The anchor tick width is invalid

error Callback_Params_InvalidAnchorTickWidth();

Callback_Params_InvalidDiscoveryTickWidth

The discovery tick width is invalid

error Callback_Params_InvalidDiscoveryTickWidth();

Callback_Params_InvalidFloorRangeGap

The floor range gap is invalid

error Callback_Params_InvalidFloorRangeGap();

Callback_Params_InvalidAnchorTickUpper

The anchor tick upper is invalid

error Callback_Params_InvalidAnchorTickUpper();

Callback_Params_RangeOutOfBounds

One of the ranges is out of bounds

error Callback_Params_RangeOutOfBounds();

Callback_Params_InvalidFloorReservesPercent

The floor reserves percent is invalid

error Callback_Params_InvalidFloorReservesPercent();

Callback_Params_InvalidPoolPercent

The pool percent is invalid

error Callback_Params_InvalidPoolPercent();

Callback_Params_InvalidRecipient

The recipient address is invalid

error Callback_Params_InvalidRecipient();

Callback_AlreadyComplete

The auction tied to this callbacks contract has already been completed

error Callback_AlreadyComplete();

Callback_MissingFunds

The required funds were not sent to this callbacks contract

error Callback_MissingFunds();

Callback_InvalidInitialization

The initialization is invalid

error Callback_InvalidInitialization();

Callback_InvalidCapacityRatio

The capacity ratio is invalid

error Callback_InvalidCapacityRatio(uint256 capacityRatio);

Parameters

NameTypeDescription
capacityRatiouint256The ratio of the pool capacity to the circulating supply

Callback_PoolLessThanAuctionPrice

The pool price is lower than the auction price

error Callback_PoolLessThanAuctionPrice(int24 currentTick, int24 auctionTick);

Parameters

NameTypeDescription
currentTickint24The current tick of the pool
auctionTickint24The tick corresponding to the auction price

Callback_BPOOLReserveMismatch

The BPOOL reserve token does not match the configured RESERVE address

error Callback_BPOOLReserveMismatch();

Callback_BPOOLInvalidAddress

The address of the BPOOL is higher than the RESERVE token address, when it must be lower

error Callback_BPOOLInvalidAddress();

Callback_Swap_InvalidCaller

The caller to the Uniswap V3 swap callback is invalid

error Callback_Swap_InvalidCaller();

Callback_Swap_InvalidCase

The case for the Uniswap V3 swap callback is invalid

error Callback_Swap_InvalidCase();

Structs

CreateData

Data struct for the onCreate callback

struct CreateData {
address recipient;
uint24 poolPercent;
uint24 floorReservesPercent;
int24 floorRangeGap;
int24 anchorTickU;
int24 anchorTickWidth;
bytes allowlistParams;
}

Properties

NameTypeDescription
recipientaddressThe address to receive proceeds that do not go to the pool
poolPercentuint24The percentage of the proceeds to allocate to the pool, in basis points (1% = 100). The remainder will be sent to the recipient.
floorReservesPercentuint24The percentage of the pool proceeds to allocate to the floor range, in basis points (1% = 100). The remainder will be allocated to the anchor range.
floorRangeGapint24The gap between the floor and anchor ranges, as a multiple of the pool tick spacing.
anchorTickUint24The upper tick of the anchor range. Validated against the calculated upper bound of the anchor range. This is provided off-chain to prevent front-running.
anchorTickWidthint24The width of the anchor tick range, as a multiple of the pool tick spacing.
allowlistParamsbytesAdditional parameters for an allowlist, passed to __onCreate() for further processing