Skip to content

LBBaseHooks ​

Git Source

Inherits:ILBHooks

Base contract for LBPair hooks
This contract is meant to be inherited by any contract that wants to implement LBPair hooks

Functions ​

onlyTrustedCaller ​

Modifier to check that the caller is the trusted caller

solidity
modifier onlyTrustedCaller();

getLBPair ​

Returns the LBPair contract

solidity
function getLBPair() external view override returns (ILBPair);

Returns

NameTypeDescription
<none>ILBPairThe LBPair contract

isLinked ​

Returns whether the contract is linked to the pair or not

solidity
function isLinked() external view override returns (bool);

Returns

NameTypeDescription
<none>boolWhether the contract is linked to the pair or not

onHooksSet ​

Hook called by the pair when the hooks parameters are set

Only callable by the pair

solidity
function onHooksSet(bytes32 hooksParameters, bytes calldata onHooksSetData)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
hooksParametersbytes32The hooks parameters
onHooksSetDatabytesThe onHooksSet data

Returns

NameTypeDescription
<none>bytes4The function selector

beforeSwap ​

Hook called by the pair before a swap

Only callable by the pair

solidity
function beforeSwap(address sender, address to, bool swapForY, bytes32 amountsIn)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the swap
toaddressThe address that will receive the swapped tokens
swapForYboolWhether the swap is for token Y
amountsInbytes32The amounts in

Returns

NameTypeDescription
<none>bytes4The function selector

afterSwap ​

Hook called by the pair after a swap

Only callable by the pair

solidity
function afterSwap(address sender, address to, bool swapForY, bytes32 amountsOut)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the swap
toaddressThe address that received the swapped tokens
swapForYboolWhether the swap was for token Y
amountsOutbytes32The amounts out

Returns

NameTypeDescription
<none>bytes4The function selector

beforeFlashLoan ​

Hook called by the pair before a flash loan

Only callable by the pair

solidity
function beforeFlashLoan(address sender, address to, bytes32 amounts)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the flash loan
toaddressThe address that will receive the flash loaned tokens
amountsbytes32The amounts

Returns

NameTypeDescription
<none>bytes4The function selector

afterFlashLoan ​

Hook called by the pair after a flash loan

Only callable by the pair

solidity
function afterFlashLoan(address sender, address to, bytes32 fees, bytes32 feesReceived)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the flash loan
toaddressThe address that received the flash loaned tokens
feesbytes32The flashloan fees
feesReceivedbytes32The fees received

Returns

NameTypeDescription
<none>bytes4The function selector

beforeMint ​

Hook called by the pair before minting

Only callable by the pair

solidity
function beforeMint(address sender, address to, bytes32[] calldata liquidityConfigs, bytes32 amountsReceived)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the mint
toaddressThe address that will receive the minted tokens
liquidityConfigsbytes32[]The liquidity configurations
amountsReceivedbytes32The amounts received

Returns

NameTypeDescription
<none>bytes4The function selector

afterMint ​

Hook called by the pair after minting

Only callable by the pair

solidity
function afterMint(address sender, address to, bytes32[] calldata liquidityConfigs, bytes32 amountsIn)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the mint
toaddressThe address that received the minted tokens
liquidityConfigsbytes32[]The liquidity configurations
amountsInbytes32The amounts in

Returns

NameTypeDescription
<none>bytes4The function selector

beforeBurn ​

Hook called by the pair before burning

Only callable by the pair

solidity
function beforeBurn(address sender, address from, address to, uint256[] calldata ids, uint256[] calldata amountsToBurn)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the burn
fromaddressThe address that will burn the tokens
toaddressThe address that will receive the burned tokens
idsuint256[]The token ids
amountsToBurnuint256[]The amounts to burn

Returns

NameTypeDescription
<none>bytes4The function selector

afterBurn ​

Hook called by the pair after burning

Only callable by the pair

solidity
function afterBurn(address sender, address from, address to, uint256[] calldata ids, uint256[] calldata amountsToBurn)
    external
    override
    onlyTrustedCaller
    returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the burn
fromaddressThe address that burned the tokens
toaddressThe address that received the burned tokens
idsuint256[]The token ids
amountsToBurnuint256[]The amounts to burn

Returns

NameTypeDescription
<none>bytes4The function selector

beforeBatchTransferFrom ​

Hook called by the pair before a batch transfer

Only callable by the pair

solidity
function beforeBatchTransferFrom(
    address sender,
    address from,
    address to,
    uint256[] calldata ids,
    uint256[] calldata amounts
) external override onlyTrustedCaller returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the transfer
fromaddressThe address that will transfer the tokens
toaddressThe address that will receive the tokens
idsuint256[]The token ids
amountsuint256[]The amounts

Returns

NameTypeDescription
<none>bytes4The function selector

afterBatchTransferFrom ​

Hook called by the pair after a batch transfer

Only callable by the pair

solidity
function afterBatchTransferFrom(
    address sender,
    address from,
    address to,
    uint256[] calldata ids,
    uint256[] calldata amounts
) external override onlyTrustedCaller returns (bytes4);

Parameters

NameTypeDescription
senderaddressThe address that initiated the transfer
fromaddressThe address that transferred the tokens
toaddressThe address that received the tokens
idsuint256[]The token ids
amountsuint256[]The amounts

Returns

NameTypeDescription
<none>bytes4The function selector

_checkTrustedCaller ​

Checks that the caller is the trusted caller, otherwise reverts

solidity
function _checkTrustedCaller() internal view virtual;

_isLinked ​

Checks if the contract is linked to the pair

solidity
function _isLinked() internal view virtual returns (bool);

Returns

NameTypeDescription
<none>boolWhether the contract is linked to the pair or not

_getLBPair ​

Returns the LBPair contract

solidity
function _getLBPair() internal view virtual returns (ILBPair);

_onHooksSet ​

Internal function to be overridden that is called when the hooks parameters are set

solidity
function _onHooksSet(bytes32 hooksParameters, bytes calldata onHooksSetData) internal virtual;

Parameters

NameTypeDescription
hooksParametersbytes32The hooks parameters
onHooksSetDatabytesThe onHooksSet data

_beforeSwap ​

Internal function to be overridden that is called before a swap

solidity
function _beforeSwap(address sender, address to, bool swapForY, bytes32 amountsIn) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the swap
toaddressThe address that will receive the swapped tokens
swapForYboolWhether the swap is for token Y
amountsInbytes32The amounts in

_afterSwap ​

Internal function to be overridden that is called after a swap

solidity
function _afterSwap(address sender, address to, bool swapForY, bytes32 amountsOut) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the swap
toaddressThe address that received the swapped tokens
swapForYboolWhether the swap was for token Y
amountsOutbytes32The amounts out

_beforeFlashLoan ​

Internal function to be overridden that is called before a flash loan

solidity
function _beforeFlashLoan(address sender, address to, bytes32 amounts) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the flash loan
toaddressThe address that will receive the flash loaned tokens
amountsbytes32The amounts

_afterFlashLoan ​

Internal function to be overridden that is called after a flash loan

solidity
function _afterFlashLoan(address sender, address to, bytes32 fees, bytes32 feesReceived) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the flash loan
toaddressThe address that received the flash loaned tokens
feesbytes32The flashloan fees
feesReceivedbytes32The fees received

_beforeMint ​

Internal function to be overridden that is called before minting

solidity
function _beforeMint(address sender, address to, bytes32[] calldata liquidityConfigs, bytes32 amountsReceived)
    internal
    virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the mint
toaddressThe address that will receive the minted tokens
liquidityConfigsbytes32[]The liquidity configurations
amountsReceivedbytes32The amounts received

_afterMint ​

Internal function to be overridden that is called after minting

solidity
function _afterMint(address sender, address to, bytes32[] calldata liquidityConfigs, bytes32 amountsIn)
    internal
    virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the mint
toaddressThe address that received the minted tokens
liquidityConfigsbytes32[]The liquidity configurations
amountsInbytes32The amounts in

_beforeBurn ​

Internal function to be overridden that is called before burning

solidity
function _beforeBurn(address sender, address from, address to, uint256[] calldata ids, uint256[] calldata amountsToBurn)
    internal
    virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the burn
fromaddressThe address that will burn the tokens
toaddressThe address that will receive the burned tokens
idsuint256[]The token ids
amountsToBurnuint256[]The amounts to burn

_afterBurn ​

Internal function to be overridden that is called after burning

solidity
function _afterBurn(address sender, address from, address to, uint256[] calldata ids, uint256[] calldata amountsToBurn)
    internal
    virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the burn
fromaddressThe address that burned the tokens
toaddressThe address that received the burned tokens
idsuint256[]The token ids
amountsToBurnuint256[]The amounts to burn

_beforeBatchTransferFrom ​

Internal function to be overridden that is called before a batch transfer

solidity
function _beforeBatchTransferFrom(
    address sender,
    address from,
    address to,
    uint256[] calldata ids,
    uint256[] calldata amounts
) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the transfer
fromaddressThe address that will transfer the tokens
toaddressThe address that will receive the tokens
idsuint256[]The token ids
amountsuint256[]The amounts

_afterBatchTransferFrom ​

Internal function to be overridden that is called after a batch transfer

solidity
function _afterBatchTransferFrom(
    address sender,
    address from,
    address to,
    uint256[] calldata ids,
    uint256[] calldata amounts
) internal virtual;

Parameters

NameTypeDescription
senderaddressThe address that initiated the transfer
fromaddressThe address that transferred the tokens
toaddressThe address that received the tokens
idsuint256[]The token ids
amountsuint256[]The amounts

Errors ​

LBBaseHooks__InvalidCaller ​

solidity
error LBBaseHooks__InvalidCaller(address caller);

LBBaseHooks__NotLinked ​

solidity
error LBBaseHooks__NotLinked();