API reference v1.0
Introduction
periphery
tokenomics
AlgebraPool

AlgebraPool

AlgebraPool

Modifiers

onlyFactoryOwner

onlyValidTicks

Variables

mapping(bytes32 => struct AlgebraPool.Position) positions

Returns the information about a position by the position's key

Functions

constructor

PoolImmutables

constructor() public

timepoints

timepoints(uint256) view external

Returns data about a specific timepoint index

NameTypeDescription
indexuint256The element of the timepoints array to fetch

Returns:

NameTypeDescription
initializedbool
blockTimestampuint32
tickCumulativeint56
secondsPerLiquidityCumulativeuint160
volatilityCumulativeuint88
averageTickint24
volumePerLiquidityCumulativeuint144

getInnerCumulatives

onlyValidTicks

getInnerCumulatives(int24,int24) view external

Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range

NameTypeDescription
bottomTickint24The lower tick of the range
topTickint24The upper tick of the range

Returns:

NameTypeDescription
innerTickCumulativeint56
innerSecondsSpentPerLiquidityuint160
innerSecondsSpentuint32

getTimepoints

getTimepoints(uint32[]) view external

Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp

NameTypeDescription
secondsAgosuint32[]From how long ago each cumulative tick and liquidity value should be returned

Returns:

NameTypeDescription
tickCumulativesint56[]
secondsPerLiquidityCumulativesuint160[]
volatilityCumulativesuint112[]
volumePerAvgLiquiditysuint256[]

initialize

initialize(uint160) external

Sets the initial price for the pool

NameTypeDescription
initialPriceuint160

mint

lock, onlyValidTicks

mint(address,address,int24,int24,uint128,bytes) external

Adds liquidity for the given recipient/bottomTick/topTick position

NameTypeDescription
senderaddressThe address which will receive potential surplus of paid tokens
recipientaddressThe address for which the liquidity will be created
bottomTickint24The lower tick of the position in which to add liquidity
topTickint24The upper tick of the position in which to add liquidity
liquidityDesireduint128
databytesAny data that should be passed through to the callback

Returns:

NameTypeDescription
amount0uint256
amount1uint256
liquidityActualuint128

collect

lock

collect(address,int24,int24,uint128,uint128) external

Collects tokens owed to a position

NameTypeDescription
recipientaddressThe address which should receive the fees collected
bottomTickint24The lower tick of the position for which to collect fees
topTickint24The upper tick of the position for which to collect fees
amount0Requesteduint128How much token0 should be withdrawn from the fees owed
amount1Requesteduint128How much token1 should be withdrawn from the fees owed

Returns:

NameTypeDescription
amount0uint128
amount1uint128

burn

lock, onlyValidTicks

burn(int24,int24,uint128) external

Burn liquidity from the sender and account tokens owed for the liquidity to the position

NameTypeDescription
bottomTickint24The lower tick of the position for which to burn liquidity
topTickint24The upper tick of the position for which to burn liquidity
amountuint128How much liquidity to burn

Returns:

NameTypeDescription
amount0uint256
amount1uint256

swap

swap(address,bool,int256,uint160,bytes) external

Swap token0 for token1, or token1 for token0

NameTypeDescription
recipientaddressThe address to receive the output of the swap
zeroToOneboolThe direction of the swap, true for token0 to token1, false for token1 to token0
amountRequiredint256
limitSqrtPriceuint160The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
databytesAny data to be passed through to the callback. If using the Router it should contain SwapRouter#SwapCallbackData

Returns:

NameTypeDescription
amount0int256
amount1int256

swapSupportingFeeOnInputTokens

swapSupportingFeeOnInputTokens(address,address,bool,int256,uint160,bytes) external

Swap token0 for token1, or token1 for token0 (tokens that have fee on transfer)

NameTypeDescription
senderaddressThe address called this function (Comes from the Router)
recipientaddressThe address to receive the output of the swap
zeroToOneboolThe direction of the swap, true for token0 to token1, false for token1 to token0
amountRequiredint256
limitSqrtPriceuint160The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap
databytesAny data to be passed through to the callback. If using the Router it should contain SwapRouter#SwapCallbackData

Returns:

NameTypeDescription
amount0int256
amount1int256

flash

lock

flash(address,uint256,uint256,bytes) external

Receive token0 and/or token1 and pay it back, plus a fee, in the callback

NameTypeDescription
recipientaddressThe address which will receive the token0 and token1 amounts
amount0uint256The amount of token0 to send
amount1uint256The amount of token1 to send
databytesAny data to be passed through to the callback

setCommunityFee

lock, onlyFactoryOwner

setCommunityFee(uint8,uint8) external

Set the community's % share of the fees. Cannot exceed 25% (250)

NameTypeDescription
communityFee0uint8new community fee percent for token0 of the pool in thousandths (1e-3)
communityFee1uint8new community fee percent for token1 of the pool in thousandths (1e-3)

setIncentive

setIncentive(address) external

Sets an active incentive

NameTypeDescription
virtualPoolAddressaddressThe address of a virtual pool associated with the incentive

setLiquidityCooldown

onlyFactoryOwner

setLiquidityCooldown(uint32) external

Sets new lock time for added liquidity

NameTypeDescription
newLiquidityCooldownuint32The time in seconds