Superposition contracts

Security

Security instructions

Contributors

Contributors

Deployments

Superposition Mainnet

Superposition RPC

AMM contract deployments
Deployment nameDeployment address
Longtail AMM
Longtail NFT manager
Permit2 router
Swaps implementation
Swaps permit2 A implementation
Quotes implementation
Positions implementation
Update position implementation
Admin implementation
Adjust position implementation
Swaps permit2 B implementation

Superposition Testnet

Superposition RPC

AMM contract deployments

Deployment nameDeployment address
Longtail AMM0x2A4a912970b780C29cf5b97aaD45ea5f98A07341
Longtail NFT manager0x380C38108a46F81F340a0837a572c7966a8552b5
Position Handler0x41AbD25155F98fF26F5e48a931c7565f04Fc6b1a
Permit2 router0x2246431582087b930F2CE561c34deb8E7e5c44bE
Swaps implementation0xc28bbb1f15fa27d32c6c892928cef984fdafae90
Swaps permit2 A implementation0xbc005f1d3b52b939a91954159320df6bed66ce17
Quotes implementation0xc8730b8ca0bc8631c75d2df6dec6244fafa2ccfd
Positions implementation0x69300b5761a79ced0322c3f0b7d6092ef0da5309
Update position implementation0xac59e975cd18bc44b6abc9fc37b14ff28f59fd42
Admin implementation0xb724609002f7651c81dd2dac9191a591805885e4
Adjust position implementation0x57470a0f95d4843adea37ec47b8e6a0616e45a58
Swaps permit2 B implementation0x0000000000000000000000000000000000000000

Leo contract deployments

Deployment nameDeployment address
Leo0xfeb228265453717352d8035b2E8e7aBFbb88d417
Collect implementation0x94e6db65496382cdfaaa6bfc89bbfdf48e7d99c7
Extras implementation0xe5e2137ff1c51ba42e0d7f8c29f73e2f4a06f526

Useful testing token deployments

Deployment nameDeployment address
fUSDC0xA8EA92c819463EFbEdDFB670FEfC881A480f0115
WETH0xde104342B32BCa03ec995f999181f7Cf1fFc04d7
USDC0x6437fdc89cED41941b97A9f1f8992D88718C81c5
WSPN0x22b9fa698b68bBA071B513959794E9a47d19214c
CATBUX0x36c116a8851869cf8a99b3Bda0Fad42453D32B99

Errors

Currently, to save on space, errors generated by the contract are terse. Decode the hex to the appropriate error in this table:

NoHexExplanation
00x00Denominator is 0
10x01Result is U256::MAX
20x02Sqrt price is 0
30x03Sqrt price is less than or equal to quotient
40x04Can not get most significant bit or least significant bit on zero value
50x05Liquidity is 0
60x06require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product);
70x07Denominator is less than or equal to prod_1
80x08Liquidity Sub
90x09Liquidity Add
100x0aThe given tick must be less than, or equal to, the maximum tick
110x0bSecond inequality must be < because the price can never reach the price at the max tick
120x0cOverflow when casting to U160
130x0dLiquidity higher than max
140x0eFee growth sub overflow
150x0fERC20 call reverted
160x10ERC20 call reverted with no data
170x11Pool is already initialised
180x12Contract is already initialised
190x13Price limit too high
200x14Price limit too low
210x15Checked abs called on an unexpected positive number
220x16Checked abs called on an unexpected negative number
230x17Checked abs called on uint.min
240x18Fee result too high
250x19Swap result too high
260x1aInternal swap amounts not matched
270x1bInternal swap result was positive
280x1cMinimum out not reached
290x1dOnly the position owner can use this
300x1eOnly the NFT manager can use this
310x1fOnly the Seawater admin can use this
320x20Operation unavailable when the pool is disabled
330x21Invalid tick spacing
340x22Swap result too low
350x23Liquidity too low or high to be a int128
360x24Invalid tick
370x25Pool enabled when it should be disabled for this action
380x26Position is empty when it shouldn't be
390x27Liquidity that was almost taken was too low when it didn't need to be
400x28Fee growth that tried to be calculated was bad internally for a tick

If more bytes are in the error, then the issue was produced by the ERC20 token. Convert any error types to their selector form to see.

Access graph

A publicly available graph for Longtail is available. It includes documentation. https://testnet-graph.long.so.

Building

Longtail ("Seawater") is a diamond-like contract, with the frontend to access the Stylus diamond facets implemented in Solidity. So, Stylus is needed with Rust for the implementation contracts, and Foundry is needed to compile the contract.

To save on contract size, and to reduce gas overhead, this contract stores the addresses of the swap router, and the admin address, at compile-time.

So these variables must set at compile-time, like so:

Build variables

NameDescription
FLU_SEAWATER_PERMIT2_ADDRUniswap Permit2 router
FLU_SEAWATER_FUSDC_ADDRUSDC Super Asset to route every trade through

Build dependencies

NameSource
Rust (nightly version)Installer
Cargo Stylus subcommandRepo
FoundryInstaller
Makebuild-essentials if you're on Linux

Build process

make build

Testing

Testing is done with via a hosted test using cargo features with the testing flag. tests.sh is provided to run both test suites.

End to end testing is currently unavailable due to issues with the deployment toolchain.

Testing process

./tests.sh

Cargo test tracing

Some of the cargo tests have optional logging, which might help with debugging. To see these logs, enable the testing-dbg-<test> feature and run the tests without capturing stdout, ie cargo test --features=testing,testing-dbg-erc20 -- --nocapture.

Testing tools are available with the with_storage macro, which lets you set slots and maximum balances for ERC20 transfers. Reproducing on-chain transactions is possible by using a tracer on the chain the transaciton took place, then examining the storage slots that were accessed (perhaps by looking at SLOADs), and setting it explicitly with the macro.

Deployment

You can deploy the contracts using the deploy.sh script.

Test deployments

Deployments on a local node can be done with ./test-deploy.sh for simplicity.

Deployment variables

NameDescription
SEAWATER_PROXY_ADMINAddress that's permitted to administrate the code, including deploying updates, and creating pools.
STYLUS_ENDPOINTURL to access the Stylus node.
STYLUS_PRIVATE_KEYPrivate key to use for deployment.
FLU_SEAWATER_FUSDC_ADDRSuper USDC address to use as the base asset for each pool.

IERC20

Git Source

Functions

transfer

function transfer(address recipient, uint256 amount) external;

Faucet

Git Source

Inherits: IFaucet

State Variables

operator_

operator to use to send the amounts on request.

address public operator_;

EMERGENCY_COUNCIL

emergency council to use to "rescue" the funds at any point.

address immutable EMERGENCY_COUNCIL;

tokens

IERC20[] public tokens;

amounts

uint256[] private amounts;

gasTokenAmount

uint256 private gasTokenAmount;

Functions

constructor

constructor(
    address _operator,
    address _emergencyCouncil,
    IERC20[] memory _tokens,
    uint256[] memory _amounts,
    uint256 _gasTokenAmount
);

receive

receive() external payable;

sendTo

sendTo the recipients given, with the amount being randomly chosen.

will break if there's not enough to send... by design.

function sendTo(FaucetReq[] calldata _requests) external;

changeOperator

function changeOperator(address _oldOperator, address _newOperator) external;

IERC165

Git Source

Functions

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 interfaceID) external view returns (bool);

Parameters

NameTypeDescription
interfaceIDbytes4The interface identifier, as specified in ERC-165

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

IERC20

Git Source

Interface of the ERC20 standard as defined in the EIP.

This includes the optional name, symbol, and decimals metadata.

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to to.

function transfer(address to, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender is allowed to spend on behalf of owner

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens.

Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from from to to using the allowance mechanism. amount is then deducted from the caller's allowance.

function transferFrom(address from, address to, uint256 amount) external returns (bool);

name

Returns the name of the token.

function name() external view returns (string memory);

symbol

Returns the symbol of the token.

function symbol() external view returns (string memory);

decimals

Returns the decimals places of the token.

function decimals() external view returns (uint8);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to).

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set, where value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

IERC721Metadata

Git Source

See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x5b5e139f.

Functions

balanceOf

Count all NFTs assigned to an owner

NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.

function balanceOf(address _owner) external view returns (uint256);

Parameters

NameTypeDescription
_owneraddressAn address for whom to query the balance

Returns

NameTypeDescription
<none>uint256The number of NFTs owned by _owner, possibly zero

ownerOf

Find the owner of an NFT

NFTs assigned to zero address are considered invalid, and queries about them do throw.

function ownerOf(uint256 _tokenId) external view returns (address);

Parameters

NameTypeDescription
_tokenIduint256The identifier for an NFT

Returns

NameTypeDescription
<none>addressThe address of the owner of the NFT

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function checks if _to is a smart contract (code size > 0). If so, it calls onERC721Received on _to and throws if the return value is not bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).

function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer
databytesAdditional data with no specified format, sent in call to _to

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

This works identically to the other function with an extra data parameter, except this function just sets data to "".

function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

transferFrom

Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT.

function transferFrom(address _from, address _to, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

approve

Change or reaffirm the approved address for an NFT

The zero address indicates there is no approved address. Throws unless msg.sender is the current NFT owner, or an authorized operator of the current owner.

function approve(address _approved, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_approvedaddressThe new approved NFT controller
_tokenIduint256The NFT to approve

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of msg.sender's assets

Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.

function setApprovalForAll(address _operator, bool _approved) external;

Parameters

NameTypeDescription
_operatoraddressAddress to add to the set of authorized operators
_approvedboolTrue if the operator is approved, false to revoke approval

getApproved

Get the approved address for a single NFT

Throws if _tokenId is not a valid NFT.

function getApproved(uint256 _tokenId) external view returns (address);

Parameters

NameTypeDescription
_tokenIduint256The NFT to find the approved address for

Returns

NameTypeDescription
<none>addressThe approved address for this NFT, or the zero address if there is none

isApprovedForAll

Query if an address is an authorized operator for another address

function isApprovedForAll(address _owner, address _operator) external view returns (bool);

Parameters

NameTypeDescription
_owneraddressThe address that owns the NFTs
_operatoraddressThe address that acts on behalf of the owner

Returns

NameTypeDescription
<none>boolTrue if _operator is an approved operator for _owner, false otherwise

name

A descriptive name for a collection of NFTs in this contract

function name() external view returns (string memory);

symbol

An abbreviated name for NFTs in this contract

function symbol() external view returns (string memory);

tokenURI

A distinct Uniform Resource Identifier (URI) for a given asset.

Throws if _tokenId is not a valid NFT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the "ERC721 Metadata JSON Schema".

function tokenURI(uint256) external view returns (string memory);

Events

Transfer

This emits when ownership of any NFT changes by any mechanism. This event emits when NFTs are created (from == 0) and destroyed (to == 0). Exception: during contract creation, any number of NFTs may be created and assigned without emitting Transfer. At the time of any transfer, the approved address for that NFT (if any) is reset to none.

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);

Approval

This emits when the approved address for an NFT is changed or reaffirmed. The zero address indicates there is no approved address. When a Transfer event emits, this also indicates that the approved address for that NFT (if any) is reset to none.

event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);

ApprovalForAll

This emits when an operator is enabled or disabled for an owner. The operator can manage all NFTs of the owner.

event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

IERC721TokenReceiver

Git Source

Functions

onERC721Received

Handle the receipt of an NFT

The ERC721 smart contract calls this function on the recipient after a transfer. This function MAY throw to revert and reject the transfer. Return of other than the magic value MUST result in the transaction being reverted. Note: the contract address is always the message sender.

function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
    external
    returns (bytes4);

Parameters

NameTypeDescription
_operatoraddressThe address which called safeTransferFrom function
_fromaddressThe address which previously owned the token
_tokenIduint256The NFT identifier which is being transferred
_databytesAdditional data with no specified format

Returns

NameTypeDescription
<none>bytes4bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")) unless throwing

IFaucet

Git Source

Functions

sendTo

sendTo the recipients given, with the amount being randomly chosen.

will break if there's not enough to send... by design.

will break if it tries to send to a contract. The callee should verify that they're not being asked to send to contracts.

function sendTo(FaucetReq[] calldata _requests) external;

Structs

FaucetReq

struct FaucetReq {
    address recipient;
    bool isStaker;
}

ILeo

Git Source

Inherits: ILeoEvents

Functions

vestPosition

vest a position that the caller owns.

function vestPosition(address pool, uint256 id, address recipient) external;

Parameters

NameTypeDescription
pooladdressto take the position from
iduint256of the position to take
recipientaddressto receive the vested position

createCampaign

create a campaign with the parameters given.

takes extraMax from the user of the token given

function createCampaign(
    bytes8 campaignId,
    address pool,
    int32 tickLower,
    int32 tickUpper,
    uint64 perSecond,
    address token,
    uint256 extraMax,
    uint64 starting,
    uint64 ending
) external;

Parameters

NameTypeDescription
campaignIdbytes8to modify for the pool given
pooladdressto reward positions that participate in with
tickLowerint32to reward positions in this range with
tickUpperint32to reward positions in this range with
perSeconduint64distribution to send
tokenaddressto give out
extraMaxuint256to start the pool amount with for this pool
startinguint64to when to start the token distribution with
endinguint64for when to stop the token distribution

cancelCampaign

cancel an ongoing campaign by amending it to have 0

only usable by the admin of the campaign

function cancelCampaign(address pool, bytes8 campaignId) external;

Parameters

NameTypeDescription
pooladdressto modify the campaign for
campaignIdbytes8to modify

campaignDetails

details of a campaign

function campaignDetails(bytes8 campaignId)
    external
    returns (
        int32 tickLower,
        int32 tickUpper,
        uint64 perSecond,
        address token,
        uint256 distributed,
        uint256 maximum,
        uint64 startingTimestamp,
        uint64 endingTimestamp
    );

Parameters

NameTypeDescription
campaignIdbytes8to identify this campaign

poolLp

pool LP tokens vested to Leo for this pool

function poolLp(address pool) external returns (uint256 lp);

Parameters

NameTypeDescription
pooladdressto check

Returns

NameTypeDescription
lpuint256tokens to return

collect

collect rewards for a position vested in a pool with the campaigns given

function collect(PositionDetails[] memory positionDetails, bytes8[] memory campaignIds, address recipient)
    external
    returns (CollectRewards memory collectRewards);

Parameters

NameTypeDescription
positionDetailsPositionDetails[]to check
campaignIdsbytes8[]to check
recipientaddressof the returned amounts

divestPosition

divest a position, returning the position ID to the user

function divestPosition(uint256 positionId, address recipient) external;

Parameters

NameTypeDescription
positionIduint256to move out
recipientaddressto send this to

Structs

PositionDetails

struct PositionDetails {
    address token;
    uint256 id;
}

PoolRewards

struct PoolRewards {
    address pool;
    uint128 amount0Lp;
    uint128 amount1Lp;
}

CampaignRewards

struct CampaignRewards {
    uint256 positionId;
    address campaignToken;
    uint256 rewards;
}

CollectRewards

struct CollectRewards {
    PoolRewards[] poolRewards;
    CampaignRewards[] campaignRewards;
}

ILeoEvents

Git Source

Events

CampaignCreated

a campaign was created. Includes the details.

event CampaignCreated(
    bytes8 indexed identifier, address indexed pool, address indexed token, uint256 details, uint256 times
);

Parameters

NameTypeDescription
identifierbytes8that was computed to represent this campaign
pooladdressthat this is eligible for
tokenaddressthat is being given out for this campaign
detailsuint256that are packed including the lower tick, upper, and the owner
timesuint256that contains the starting, ending timestamp, and per second distribution

CampaignUpdated

a campaign was updated. Includes the new settings.

event CampaignUpdated(bytes8 indexed identifier, address indexed pool, uint256 indexed perSecond, uint256 extras);

Parameters

NameTypeDescription
identifierbytes8that was computed to represent this campaign
pooladdressthat this campaign is for that was just updated
perSeconduint256distribution to give out
extrasuint256including the tick lower, the tick upper, the starting and ending timestamp

PositionVested2

a specific position was vested

event PositionVested2(uint256 indexed positionId, address indexed owner);

Parameters

NameTypeDescription
positionIduint256that was just vested
owneraddress

PositionDivested2

a specific position was just divested from Leo

event PositionDivested2(uint256 indexed positionId, address indexed recipient);

Parameters

NameTypeDescription
positionIduint256that was divested
recipientaddressof the divested position

ISeawater

Git Source

Inherits: ISeawaterAMM

ISeawaterAMM

Git Source

Inherits: ISeawaterEvents, ISeawaterExecutorSwap, ISeawaterExecutorSwapPermit2A, ISeawaterExecutorQuote, ISeawaterExecutorPosition, ISeawaterExecutorUpdatePosition, ISeawaterExecutorAdminExposed, ISeawaterExecutorAdjustPosition, ISeawaterExecutorSwapPermit2B

Functions

swapIn32502CA71

swaps _token for USDC

function swapIn32502CA71(address _token, uint256 _amount, uint256 _minOut) external returns (int256, int256);

Parameters

NameTypeDescription
_tokenaddressthe token to swap
_amountuint256input amount (token)
_minOutuint256the minimum output amount (usdc), reverting if the actual output is lower

Returns

NameTypeDescription
<none>int256amount of usdc out
<none>int256

swapInPermit2CEAAB576

swaps _token for USDC

function swapInPermit2CEAAB576(
    address _token,
    uint256 _amount,
    uint256 _minOut,
    uint256 _nonce,
    uint256 _deadline,
    uint256 _maxAmount,
    bytes memory _sig
) external returns (int256, int256);

Parameters

NameTypeDescription
_tokenaddressthe token to swap
_amountuint256input amount (token)
_minOutuint256the minimum output amount (usdc), reverting if the actual output is lower
_nonceuint256the nonce for the token
_deadlineuint256the deadline for the token
_maxAmountuint256the max amount of the token
_sigbytesthe signature for the token

Returns

NameTypeDescription
<none>int256amount of usdc out
<none>int256

swapOut5E08A399

swaps USDC for _token

function swapOut5E08A399(address _token, uint256 _amount, uint256 _minOut) external returns (int256, int256);

Parameters

NameTypeDescription
_tokenaddressthe token to swap
_amountuint256input amount (usdc)
_minOutuint256the minimum output amount (token), reverting if the actual output is lower

Returns

NameTypeDescription
<none>int256amount of token out
<none>int256

swapOutPermit23273373B

swaps USDC for _token

function swapOutPermit23273373B(
    address _token,
    uint256 _amount,
    uint256 _minOut,
    uint256 _nonce,
    uint256 _deadline,
    uint256 _maxAmount,
    bytes memory _sig
) external returns (int256, int256);

Parameters

NameTypeDescription
_tokenaddressthe token to swap
_amountuint256input amount (usdc)
_minOutuint256the minimum output amount (token), reverting if the actual output is lower
_nonceuint256the nonce for the token
_deadlineuint256the deadline for the token
_maxAmountuint256the max amount of the token
_sigbytesthe signature for the token

Returns

NameTypeDescription
<none>int256amount of token out
<none>int256

swap2ExactIn41203F1D

swaps tokenA for tokenB

function swap2ExactIn41203F1D(address _tokenA, address _tokenB, uint256 _amount, uint256 _minOut)
    external
    returns (uint256, uint256);

Parameters

NameTypeDescription
_tokenAaddressthe input token
_tokenBaddressthe output token
_amountuint256input amount (tokenA)
_minOutuint256the minimum output amount (tokenB), reverting if the actual output is lower

Returns

NameTypeDescription
<none>uint256amount of token A in, amount of token B out
<none>uint256

ISeawaterEvents

Git Source

Events

MintPosition

emitted when a new position is minted

event MintPosition(uint256 indexed id, address indexed owner, address indexed pool, int32 lower, int32 upper);

Parameters

NameTypeDescription
iduint256the position id
owneraddressthe owner of the position
pooladdressthe pool the position is associated with
lowerint32the lower tick of the position's concentrated liquidity range
upperint32the upper tick of the position's concentrated liquidity range

BurnPosition

emitted when a position is burned

event BurnPosition(uint256 indexed id, address indexed owner);

Parameters

NameTypeDescription
iduint256the id of the position being burned
owneraddressthe user the owned the position

TransferPosition

emitted when a position changes owners

event TransferPosition(address indexed from, address indexed to, uint256 indexed id);

Parameters

NameTypeDescription
fromaddressthe original owner of the position
toaddressthe new owner of the position
iduint256the id of the position being transferred

UpdatePositionLiquidity

emitted when the liquidity in a position is changed.

event UpdatePositionLiquidity(uint256 indexed id, int256 token0, int256 token1);

Parameters

NameTypeDescription
iduint256
token0int256
token1int256that was taken or given to the contract.

CollectFees

emitted when a liquidity provider collects the fees associated with a position

event CollectFees(uint256 indexed id, address indexed pool, address indexed to, uint128 amount0, uint128 amount1);

Parameters

NameTypeDescription
iduint256the id of the position whose liquidity is being collected
pooladdressthe address of the pool the position is associated with
toaddressthe recipient of the fees
amount0uint128the amount of token0 being collected
amount1uint128the amount of token1 being collected

NewPool

emitted when a new pool is created

event NewPool(address indexed token, uint32 indexed fee, uint8 decimals, uint8 tickSpacing);

Parameters

NameTypeDescription
tokenaddressthe token0 the pool is associated with (where token1 is a fluid token)
feeuint32the fee being used for this pool
decimalsuint8the decimals for the token
tickSpacinguint8the tick spacing for the pool

CollectProtocolFees

emitted when a protocol admin collects protocol fees

event CollectProtocolFees(address indexed pool, address indexed to, uint128 amount0, uint128 amount1);

Parameters

NameTypeDescription
pooladdressthe pool for which protocol fees are being collected
toaddressthe account the fees are being sent to
amount0uint128the amount of token0 being collected
amount1uint128the amount of token1 being collected

Swap2

emitted when a user swaps a nonfluid token for a nonfluid token (2-step swap)

event Swap2(
    address indexed user,
    address indexed from,
    address indexed to,
    uint256 amountIn,
    uint256 amountOut,
    uint256 fluidVolume,
    int32 finalTick0,
    int32 finalTick1
);

Parameters

NameTypeDescription
useraddressthe user performing the swap
fromaddressthe input token
toaddressthe output token
amountInuint256the amount of from the user is paying
amountOutuint256the amount of to the user is receiving
fluidVolumeuint256the volume of the internal transfer
finalTick0int32the tick that the first token's pool ended on
finalTick1int32the tick that the second token's pool ended on

Swap1

emitted when a user swaps a token for the pool's fluid token, or vice-versa

event Swap1(
    address indexed user, address indexed pool, bool zeroForOne, uint256 amount0, uint256 amount1, int32 finalTick
);

Parameters

NameTypeDescription
useraddressthe user performing the swap
pooladdressthe token being swapped for the fluid token
zeroForOnebooltrue if the user is swapping token->fluid, false otherwise
amount0uint256the amount of the nonfluid token being transferred
amount1uint256the amount of the fluid token being transferred
finalTickint32the tick the pool ended on

NewFees

new fees were set!

event NewFees(address indexed pool, uint8 indexed feeProtocol);

Parameters

NameTypeDescription
pooladdressthat the fees are set for.
feeProtocoluint8that's taken by the protocol

ISeawaterExecutorSwap

Git Source

Functions

swap904369BE

swaps within a pool

function swap904369BE(address pool, bool zeroForOne, int256 amount, uint256 priceLimit)
    external
    returns (int256, int256);

Parameters

NameTypeDescription
pooladdressthe pool to swap on
zeroForOnebooltrue if swapping token->fluid token
amountint256the amount of token to swap, positive if exactIn, negative if exactOut
priceLimituint256the price limit for swaps, encoded as a sqrtX96 price

Returns

NameTypeDescription
<none>int256(token0, token1) delta
<none>int256

swap2ExactIn41203F1D

performs a two stage swap across two pools

function swap2ExactIn41203F1D(address from, address to, uint256 amount, uint256 minOut)
    external
    returns (uint256, uint256);

Parameters

NameTypeDescription
fromaddressthe input token
toaddressthe output token
amountuint256the amount of the input token to use
minOutuint256the minimum valid amount of the output token, reverts if not reached

Returns

NameTypeDescription
<none>uint256(amount in, amount out)
<none>uint256

ISeawaterExecutorSwapPermit2A

Git Source

Functions

swapPermit2EE84AD91

swaps within a pool using permit2 for token transfers

function swapPermit2EE84AD91(
    address pool,
    bool zeroForOne,
    int256 amount,
    uint256 priceLimit,
    uint256 nonce,
    uint256 deadline,
    uint256 maxAmount,
    bytes memory sig
) external returns (int256, int256);

Parameters

NameTypeDescription
pooladdressthe pool to swap on
zeroForOnebooltrue if swapping token->fluid token
amountint256the amount of token to swap, positive if exactIn, negative if exactOut
priceLimituint256the price limit for swaps, encoded as a sqrtX96 price
nonceuint256the permit2 nonce
deadlineuint256the permit2 deadline
maxAmountuint256the permit2 maxAmount
sigbytesthe permit2 signature

Returns

NameTypeDescription
<none>int256(token0, token1) delta
<none>int256

ISeawaterExecutorSwapPermit2B

Git Source

Functions

swap2ExactInPermit254A7DBB1

performs a two stage swap across two pools using permit2 for token transfers

permit2's max amount must be set to amount

function swap2ExactInPermit254A7DBB1(
    address from,
    address to,
    uint256 amount,
    uint256 minOut,
    uint256 nonce,
    uint256 deadline,
    bytes memory sig
) external returns (uint256, uint256);

Parameters

NameTypeDescription
fromaddressthe input token
toaddressthe output token
amountuint256the amount of the input token to use
minOutuint256the minimum valid amount of the output token, reverts if not reached
nonceuint256the permit2 nonce
deadlineuint256the permit2 deadline
sigbytesthe permit2 signature

Returns

NameTypeDescription
<none>uint256(amount in, amount out)
<none>uint256

ISeawaterExecutorQuote

Git Source

Functions

quote72E2ADE7

reverts with the expected amount of fUSDC or pool token for a swap with the given parameters

always revert with Error(string(amountOut))

function quote72E2ADE7(address pool, bool zeroForOne, int256 amount, uint256 priceLimit) external;

Parameters

NameTypeDescription
pooladdressthe pool to swap on
zeroForOnebooltrue if swapping token->fluid token
amountint256the amount of token to swap, positive if exactIn, negative if exactOut
priceLimituint256the price limit for swaps, encoded as a sqrtX96 price

quote2CD06B86E

reverts with the expected amount of tokenOut for a 2-token swap with the given parameters

always revert with Error(string(amountOut))

function quote2CD06B86E(address from, address to, uint256 amount, uint256 minOut) external;

Parameters

NameTypeDescription
fromaddressthe input token
toaddressthe output token
amountuint256the amount of the input token to use
minOutuint256the minimum valid amount of the output token, reverts if not reached

ISeawaterExecutorPosition

Git Source

Functions

mintPositionBC5B086D

creates a new position

function mintPositionBC5B086D(address pool, int32 lower, int32 upper) external returns (uint256 id);

Parameters

NameTypeDescription
pooladdressthe pool to create the position on
lowerint32the lower tick of the position (for concentrated liquidity)
upperint32the upper tick of the position

transferPositionEEC7A3CD

transferPosition transfers a position. usable only by the NFT manager

function transferPositionEEC7A3CD(uint256 id, address from, address to) external;

Parameters

NameTypeDescription
iduint256the id of the position to transfer
fromaddressthe user to transfer the position from
toaddressthe user to transfer the position to

positionOwnerD7878480

gets the owner of a position

function positionOwnerD7878480(uint256 id) external returns (address);

Parameters

NameTypeDescription
iduint256the id of the position

Returns

NameTypeDescription
<none>addressthe owner of the position

positionBalance4F32C7DB

gets the number of positions owned by a user

function positionBalance4F32C7DB(address user) external returns (uint256);

Parameters

NameTypeDescription
useraddressthe user to get position balance for

Returns

NameTypeDescription
<none>uint256the number of positions owned by the user

positionLiquidity8D11C045

gets the amount of liquidity in a position

function positionLiquidity8D11C045(address pool, uint256 id) external returns (uint128);

Parameters

NameTypeDescription
pooladdressthe position belongs to
iduint256the id of the position

Returns

NameTypeDescription
<none>uint128the amount of liquidity contained in the position

positionTickLower2F77CCE1

get the lower tick of the position id

function positionTickLower2F77CCE1(address pool, uint256 id) external returns (int32);

Parameters

NameTypeDescription
pooladdressthe position belongs to
iduint256of the position

Returns

NameTypeDescription
<none>int32the lower tick of the position given

positionTickUpper67FD55BA

get the upper tick of the position id

function positionTickUpper67FD55BA(address pool, uint256 id) external returns (int32);

Parameters

NameTypeDescription
pooladdressthe position belongs to
iduint256of the position

Returns

NameTypeDescription
<none>int32the lower tick of the position given

collectSingleTo6D76575F

collect a single position's yield

function collectSingleTo6D76575F(address pool, uint256 id, address recipient)
    external
    returns (uint128 amount0, uint128 amount1);

Parameters

NameTypeDescription
pooladdressthe position belongs to
iduint256of the position to use
recipientaddressof the money that's earned

Returns

NameTypeDescription
amount0uint128and amount1
amount1uint128

collect7F21947C

collects fees from from positions

function collect7F21947C(address[] memory pools, uint256[] memory ids) external returns (CollectResult[] memory);

Parameters

NameTypeDescription
poolsaddress[]to claim accumulated yield from
idsuint256[]to claim the positions of

Structs

CollectResult

struct CollectResult {
    uint128 amount0;
    uint128 amount1;
}

ISeawaterExecutorUpdatePosition

Git Source

Functions

updatePositionC7F1F740

refreshes a position's fees, and adds or removes liquidity

function updatePositionC7F1F740(address pool, uint256 id, int128 delta) external returns (int256, int256);

Parameters

NameTypeDescription
pooladdressto use this with
iduint256the id of the position
deltaint128the amount of liquidity to add or remove

Returns

NameTypeDescription
<none>int256the deltas for token0 and token1 for the user
<none>int256

ISeawaterExecutorAdminExposed

Git Source

contains just the admin functions that are exposed directly

Functions

createPool653F395E

initialises a new pool. only usable by the seawater admin

function createPool653F395E(address pool, uint256 sqrtPriceX96, uint32 fee) external;

Parameters

NameTypeDescription
pooladdressthe token to create the pool with
sqrtPriceX96uint256the starting price for the pool
feeuint32the fee to use

collectProtocol7540FA9F

collects protocol fees. only usable by the seawater admin

function collectProtocol7540FA9F(address pool, uint128 amount0, uint128 amount1, address recipient)
    external
    returns (uint128, uint128);

Parameters

NameTypeDescription
pooladdressthe pool to collect fees for
amount0uint128the maximum amount of token0 fees to collect
amount1uint128the maximum amount of token1 fees to collect
recipientaddressof the funds that're earned

Returns

NameTypeDescription
<none>uint128the amount of token0 and token1 fees collected
<none>uint128

feesOwed22F28DBD

feesOwed to a position ID given.

function feesOwed22F28DBD(address pool, uint256 id) external returns (uint128, uint128);

Parameters

NameTypeDescription
pooladdressto get the fees owed for
iduint256of the position to check for

Returns

NameTypeDescription
<none>uint128the amount of token0 and token1 to get in return
<none>uint128

sqrtPriceX967B8F5FC5

gets the current sqrt price of the pool

function sqrtPriceX967B8F5FC5(address pool) external returns (uint256);

Parameters

NameTypeDescription
pooladdressto get from

Returns

NameTypeDescription
<none>uint256the current sqrtPriceX96 for the pool

curTick181C6FD9

gets the currently used tick of the pool

function curTick181C6FD9(address pool) external returns (int32);

Parameters

NameTypeDescription
pooladdressto get from

Returns

NameTypeDescription
<none>int32the current active tick in the pool

tickSpacing653FE28F

gets the tick spacing of the pool

function tickSpacing653FE28F(address pool) external returns (uint8);

Parameters

NameTypeDescription
pooladdressto get from

Returns

NameTypeDescription
<none>uint8the tick spacing of the pool

feeBB3CF608

gets the fee for a specific pool

function feeBB3CF608(address pool) external returns (uint32);

Parameters

NameTypeDescription
pooladdressto get the fee for

Returns

NameTypeDescription
<none>uint32the fee for the pool

feeGrowthGlobal038B5665B

gets the fee growth for token 0

function feeGrowthGlobal038B5665B(address pool) external returns (uint256);

Parameters

NameTypeDescription
pooladdressto get from

Returns

NameTypeDescription
<none>uint256the fee growth for the other token

feeGrowthGlobal1A33A5A1B

gets the fee growth for token 1

function feeGrowthGlobal1A33A5A1B(address pool) external returns (uint256);

Parameters

NameTypeDescription
pooladdressto get from

Returns

NameTypeDescription
<none>uint256the fee growth for fUSDC

enablePool579DA658

enables or disables a pool

function enablePool579DA658(address pool, bool enabled) external;

Parameters

NameTypeDescription
pooladdressthe pool to enable or disable
enabledbooltrue to enable to pool, false to disable it

authoriseEnabler5B17C274

authorise an address to create and enable pools on its own

function authoriseEnabler5B17C274(address enabler, bool enabled) external;

Parameters

NameTypeDescription
enableraddress
enabledboolto set their status

setSqrtPriceFF4DB98C

set the sqrt price for a pool in the event of misconfiguration.

function setSqrtPriceFF4DB98C(address pool, uint256 price) external;

Parameters

NameTypeDescription
pooladdressto set
priceuint256to use as the starting place

updateNftManager9BDF41F6

set the NFT manager.

function updateNftManager9BDF41F6(address manager) external;

Parameters

NameTypeDescription
manageraddressaddress to set to in its new form

updateSeawaterAdminD25D364D

set the new admin.

function updateSeawaterAdminD25D364D(address operator) external;

Parameters

NameTypeDescription
operatoraddressto replace the existing operator with

updateEmergencyCouncil7D0C1C58

updateEmergencyCouncil to a new address.

function updateEmergencyCouncil7D0C1C58(address newCouncil) external;

Parameters

NameTypeDescription
newCounciladdressto set the emergency council to

ISeawaterExecutorAdmin

Git Source

Inherits: ISeawaterExecutorAdminExposed

Functions

ctor

constructor function

function ctor(address seawaterAdmin, address nftManager, address emergencyCouncil) external;

Parameters

NameTypeDescription
seawaterAdminaddressthe account with administrative power on the amm
nftManageraddressthe account with control over NFT ownership
emergencyCounciladdressto use to control for pool disabling interactions

ISeawaterExecutorAdjustPosition

Git Source

Functions

incrPositionE2437399

refreshes a position's fees, and adds liquidity, preventing less than the minimum from being taken.

function incrPositionE2437399(
    address pool,
    uint256 id,
    uint256 amount0Min,
    uint256 amount1Min,
    uint256 amount0Desired,
    uint256 amount1Desired
) external returns (uint256, uint256);

Parameters

NameTypeDescription
pooladdressof the token to use
iduint256the id of the position
amount0Minuint256minimum of amount0 to take from the user
amount1Minuint256minimum of amount1 to take from the user
amount0Desireduint256to take from the user. May exceed.
amount1Desireduint256to take from the user. May exceed.

Returns

NameTypeDescription
<none>uint256the deltas for token0, and token1
<none>uint256

ISeawaterExecutorFallback

Git Source

ISeawaterMigrations

Git Source

StorageSlot

Git Source

Functions

getAddressSlot

function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r);

Structs

AddressSlot

struct AddressSlot {
    address value;
}

LeoCtor

Git Source

Functions

ctor

function ctor(address) external;

LeoProxy

Git Source

Inherits: ILeo

Functions

directDelegate

function directDelegate(address to) internal;

constructor

constructor(address _collect, address _extras, address _emergency);

createCampaign

create a campaign with the parameters given.

takes extraMax from the user of the token given

function createCampaign(bytes8, address, int32, int32, uint64, address, uint256, uint64, uint64) external;

Parameters

NameTypeDescription
<none>bytes8
<none>address
<none>int32
<none>int32
<none>uint64
<none>address
<none>uint256
<none>uint64
<none>uint64

campaignDetails

details of a campaign

function campaignDetails(bytes8) external returns (int32, int32, uint64, address, uint256, uint256, uint64, uint64);

Parameters

NameTypeDescription
<none>bytes8

cancelCampaign

cancel an ongoing campaign by amending it to have 0

only usable by the admin of the campaign

function cancelCampaign(address, bytes8) external;

Parameters

NameTypeDescription
<none>address
<none>bytes8

poolLp

pool LP tokens vested to Leo for this pool

function poolLp(address) external returns (uint256);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256lp tokens to return

collect

collect rewards for a position vested in a pool with the campaigns given

function collect(PositionDetails[] memory, bytes8[] memory, address) external returns (CollectRewards memory);

Parameters

NameTypeDescription
<none>PositionDetails[]
<none>bytes8[]
<none>address

vestPosition

vest a position that the caller owns.

function vestPosition(address, uint256, address) external;

Parameters

NameTypeDescription
<none>address
<none>uint256
<none>address

divestPosition

divest a position, returning the position ID to the user

function divestPosition(uint256, address) external;

Parameters

NameTypeDescription
<none>uint256
<none>address

Constants

Git Source

EXTRAS_SLOT

0x265c22645a278354f32cb66e6ace5ae683d2e0f04117019dbeb0727f85f1690e

bytes32 constant EXTRAS_SLOT = bytes32(uint256(keccak256("leo.impl.extras")) - 1);

COLLECT_SLOT

0x5f9cf5b10fe99c3929b5aaee8330476b5fdcda9bd9a0df70532d2c68fe1683a9

bytes32 constant COLLECT_SLOT = bytes32(uint256(keccak256("leo.impl.collect")) - 1);

OwnershipNFTs

Git Source

Inherits: IERC721Metadata, IERC165

State Variables

SEAWATER

ISeawaterAMM public immutable SEAWATER;

TOKEN_URI

TOKEN_URI to set as the default token URI for every NFT

immutable in practice (not set anywhere)

string public TOKEN_URI;

name

name of the NFT, set by the constructor

string public name;

symbol

symbol of the NFT, set during the constructor

string public symbol;

getApproved_

getApproved that can spend the id of the tokens given

required in the NFT spec and we simplify the use here by naming the storage slot as such

mapping(uint256 => address) private getApproved_;

isApprovedForAll

Query if an address is an authorized operator for another address

mapping(address => mapping(address => bool)) public isApprovedForAll;

Functions

constructor

constructor(string memory _name, string memory _symbol, string memory _tokenURI, ISeawaterAMM _seawater);

ownerOf

Find the owner of an NFT

NFTs assigned to zero address are considered invalid, and queries about them do throw.

function ownerOf(uint256 _tokenId) public view returns (address);

Parameters

NameTypeDescription
_tokenIduint256The identifier for an NFT

Returns

NameTypeDescription
<none>addressThe address of the owner of the NFT

getApproved

Get the approved address for a single NFT

Throws if _tokenId is not a valid NFT.

function getApproved(uint256 _tokenId) external view returns (address);

Parameters

NameTypeDescription
_tokenIduint256The NFT to find the approved address for

Returns

NameTypeDescription
<none>addressThe approved address for this NFT, or the zero address if there is none

_onTransferReceived

_onTransferReceived by calling the callback onERC721Received in the recipient if they have codesize > 0. if the callback doesn't return the selector, revert!

function _onTransferReceived(address _sender, address _from, address _to, uint256 _tokenId) internal;

Parameters

NameTypeDescription
_senderaddressthat did the transfer
_fromaddressowner of the NFT that the sender is transferring
_toaddressrecipient of the NFT that we're calling the function on
_tokenIduint256that we're transferring from our internal storage

_requireAuthorised

function _requireAuthorised(address _from, uint256 _tokenId) internal view;

_transfer

function _transfer(address _from, address _to, uint256 _tokenId) internal;

transferFrom

Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT.

function transferFrom(address _from, address _to, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function checks if _to is a smart contract (code size > 0). If so, it calls onERC721Received on _to and throws if the return value is not bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).

function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function checks if _to is a smart contract (code size > 0). If so, it calls onERC721Received on _to and throws if the return value is not bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).

function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata) external payable;

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer
<none>bytes

approve

Change or reaffirm the approved address for an NFT

The zero address indicates there is no approved address. Throws unless msg.sender is the current NFT owner, or an authorized operator of the current owner.

function approve(address _approved, uint256 _tokenId) external payable;

Parameters

NameTypeDescription
_approvedaddressThe new approved NFT controller
_tokenIduint256The NFT to approve

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of msg.sender's assets

Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.

function setApprovalForAll(address _operator, bool _approved) external;

Parameters

NameTypeDescription
_operatoraddressAddress to add to the set of authorized operators
_approvedboolTrue if the operator is approved, false to revoke approval

balanceOf

Count all NFTs assigned to an owner

NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.

function balanceOf(address _spender) external view returns (uint256);

Parameters

NameTypeDescription
_spenderaddress

Returns

NameTypeDescription
<none>uint256The number of NFTs owned by _owner, possibly zero

tokenURI

A distinct Uniform Resource Identifier (URI) for a given asset.

Throws if _tokenId is not a valid NFT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the "ERC721 Metadata JSON Schema".

function tokenURI(uint256) external view returns (string memory);

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 _interfaceId) external pure returns (bool);

Parameters

NameTypeDescription
_interfaceIdbytes4

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

PositionHandler

Git Source

State Variables

LONGTAIL

ISeawaterAMM immutable LONGTAIL;

LEO

ILeo immutable LEO;

FUSDC

IERC20 immutable FUSDC;

NFT_MANAGER

OwnershipNFTs immutable NFT_MANAGER;

Functions

constructor

constructor(ISeawaterAMM longtail, ILeo leo, OwnershipNFTs nftManager, IERC20 fusdcAddr);

proxyVestIncr

function proxyVestIncr(
    address pool,
    int32 lower,
    int32 upper,
    uint256 amount0Min,
    uint256 fusdcMin,
    uint256 amount0Max,
    uint256 fusdcMax,
    bool shouldVest,
    address recipient
) external returns (uint256);

StorageSlot

Git Source

Functions

getAddressSlot

function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r);

Structs

AddressSlot

struct AddressSlot {
    address value;
}

SeawaterAMM

Git Source

Inherits: ISeawaterAMM

Functions

onlyProxyAdmin

modifier onlyProxyAdmin();

constructor

constructor function, sets proxy details and then forwards to the seawater initialiser

constructor(
    address _proxyAdmin,
    address _seawaterAdmin,
    address _nftManager,
    address _emergencyCouncil,
    ISeawaterExecutorSwap _executorSwap,
    ISeawaterExecutorSwapPermit2A _executorSwapPermit2A,
    ISeawaterExecutorQuote _executorQuote,
    ISeawaterExecutorPosition _executorPosition,
    ISeawaterExecutorUpdatePosition _executorUpdatePosition,
    ISeawaterExecutorAdmin _executorAdmin,
    ISeawaterExecutorAdjustPosition _executorAdjustPositions,
    ISeawaterExecutorSwapPermit2B _executorSwapPermit2B,
    ISeawaterExecutorFallback _executorFallback
);

Parameters

NameTypeDescription
_proxyAdminaddressthe admin that can control proxy functions (change addresses)
_seawaterAdminaddressthe admin of the AMM
_nftManageraddressthe account that can transfer position NFTs
_emergencyCounciladdress
_executorSwapISeawaterExecutorSwapthe deployed code for the swap executor
_executorSwapPermit2AISeawaterExecutorSwapPermit2Athe deployed code for the swap_permit2 executor (facet A)
_executorQuoteISeawaterExecutorQuotethe deployed code for the quote executor
_executorPositionISeawaterExecutorPositionthe deployed code for the positions executor
_executorUpdatePositionISeawaterExecutorUpdatePosition
_executorAdminISeawaterExecutorAdminthe deployed code for the admin executor
_executorAdjustPositionsISeawaterExecutorAdjustPositionthe deployed code for the adjust positions executor
_executorSwapPermit2BISeawaterExecutorSwapPermit2Bthe deployed code for the swap_permit2 executor (facet B)
_executorFallbackISeawaterExecutorFallbackan address that functions not matching a specific executor get set to

updateProxyAdmin

updates the proxy admin. only usable by the proxy admin

function updateProxyAdmin(address newAdmin) public onlyProxyAdmin;

Parameters

NameTypeDescription
newAdminaddressthe new proxy admin to set

directDelegate

function directDelegate(address to) internal;

createPool653F395E

initialises a new pool. only usable by the seawater admin

function createPool653F395E(address, uint256, uint32) external;

Parameters

NameTypeDescription
<none>address
<none>uint256
<none>uint32

collectProtocol7540FA9F

collects protocol fees. only usable by the seawater admin

function collectProtocol7540FA9F(address, uint128, uint128, address) external returns (uint128, uint128);

Parameters

NameTypeDescription
<none>address
<none>uint128
<none>uint128
<none>address

Returns

NameTypeDescription
<none>uint128the amount of token0 and token1 fees collected
<none>uint128

enablePool579DA658

enables or disables a pool

function enablePool579DA658(address, bool) external;

Parameters

NameTypeDescription
<none>address
<none>bool

authoriseEnabler5B17C274

authorise an address to create and enable pools on its own

function authoriseEnabler5B17C274(address, bool) external;

Parameters

NameTypeDescription
<none>address
<none>bool

setSqrtPriceFF4DB98C

set the sqrt price for a pool in the event of misconfiguration.

function setSqrtPriceFF4DB98C(address, uint256) external;

Parameters

NameTypeDescription
<none>address
<none>uint256

updateNftManager9BDF41F6

set the NFT manager.

function updateNftManager9BDF41F6(address) external;

Parameters

NameTypeDescription
<none>address

updateSeawaterAdminD25D364D

set the new admin.

function updateSeawaterAdminD25D364D(address) external;

Parameters

NameTypeDescription
<none>address

updateEmergencyCouncil7D0C1C58

updateEmergencyCouncil to a new address.

function updateEmergencyCouncil7D0C1C58(address) external;

Parameters

NameTypeDescription
<none>address

swap904369BE

swaps within a pool

function swap904369BE(address, bool, int256, uint256) external returns (int256, int256);

Parameters

NameTypeDescription
<none>address
<none>bool
<none>int256
<none>uint256

Returns

NameTypeDescription
<none>int256(token0, token1) delta
<none>int256

quote72E2ADE7

reverts with the expected amount of fUSDC or pool token for a swap with the given parameters

function quote72E2ADE7(address, bool, int256, uint256) external;

Parameters

NameTypeDescription
<none>address
<none>bool
<none>int256
<none>uint256

quote2CD06B86E

reverts with the expected amount of tokenOut for a 2-token swap with the given parameters

function quote2CD06B86E(address, address, uint256, uint256) external;

Parameters

NameTypeDescription
<none>address
<none>address
<none>uint256
<none>uint256

swapPermit2EE84AD91

swaps within a pool using permit2 for token transfers

function swapPermit2EE84AD91(address, bool, int256, uint256, uint256, uint256, uint256, bytes memory)
    external
    returns (int256, int256);

Parameters

NameTypeDescription
<none>address
<none>bool
<none>int256
<none>uint256
<none>uint256
<none>uint256
<none>uint256
<none>bytes

Returns

NameTypeDescription
<none>int256(token0, token1) delta
<none>int256

swap2ExactInPermit254A7DBB1

performs a two stage swap across two pools using permit2 for token transfers

function swap2ExactInPermit254A7DBB1(address, address, uint256, uint256, uint256, uint256, bytes memory)
    external
    returns (uint256, uint256);

Parameters

NameTypeDescription
<none>address
<none>address
<none>uint256
<none>uint256
<none>uint256
<none>uint256
<none>bytes

Returns

NameTypeDescription
<none>uint256(amount in, amount out)
<none>uint256

swap2ExactIn41203F1D

performs a two stage swap across two pools

function swap2ExactIn41203F1D(address, address, uint256, uint256) external returns (uint256, uint256);

Parameters

NameTypeDescription
<none>address
<none>address
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256(amount in, amount out)
<none>uint256

swapIn32502CA71

swaps _token for USDC

function swapIn32502CA71(address token, uint256 amountIn, uint256 minOut) external returns (int256, int256);

Parameters

NameTypeDescription
tokenaddress
amountInuint256
minOutuint256

Returns

NameTypeDescription
<none>int256amount of usdc out
<none>int256

swapInPermit2CEAAB576

swaps _token for USDC

function swapInPermit2CEAAB576(
    address token,
    uint256 amountIn,
    uint256 minOut,
    uint256 nonce,
    uint256 deadline,
    uint256 maxAmount,
    bytes memory sig
) external returns (int256, int256);

Parameters

NameTypeDescription
tokenaddress
amountInuint256
minOutuint256
nonceuint256
deadlineuint256
maxAmountuint256
sigbytes

Returns

NameTypeDescription
<none>int256amount of usdc out
<none>int256

swapOut5E08A399

swaps USDC for _token

function swapOut5E08A399(address token, uint256 amountIn, uint256 minOut) external returns (int256, int256);

Parameters

NameTypeDescription
tokenaddress
amountInuint256
minOutuint256

Returns

NameTypeDescription
<none>int256amount of token out
<none>int256

swapOutPermit23273373B

swaps USDC for _token

function swapOutPermit23273373B(
    address token,
    uint256 amountIn,
    uint256 minOut,
    uint256 nonce,
    uint256 deadline,
    uint256 maxAmount,
    bytes memory sig
) external returns (int256, int256);

Parameters

NameTypeDescription
tokenaddress
amountInuint256
minOutuint256
nonceuint256
deadlineuint256
maxAmountuint256
sigbytes

Returns

NameTypeDescription
<none>int256amount of token out
<none>int256

mintPositionBC5B086D

creates a new position

function mintPositionBC5B086D(address, int32, int32) external returns (uint256);

Parameters

NameTypeDescription
<none>address
<none>int32
<none>int32

positionOwnerD7878480

gets the owner of a position

function positionOwnerD7878480(uint256) external returns (address);

Parameters

NameTypeDescription
<none>uint256

Returns

NameTypeDescription
<none>addressthe owner of the position

transferPositionEEC7A3CD

transferPosition transfers a position. usable only by the NFT manager

function transferPositionEEC7A3CD(uint256, address, address) external;

Parameters

NameTypeDescription
<none>uint256
<none>address
<none>address

positionBalance4F32C7DB

gets the number of positions owned by a user

function positionBalance4F32C7DB(address) external returns (uint256);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256the number of positions owned by the user

positionLiquidity8D11C045

gets the amount of liquidity in a position

function positionLiquidity8D11C045(address, uint256) external returns (uint128);

Parameters

NameTypeDescription
<none>address
<none>uint256

Returns

NameTypeDescription
<none>uint128the amount of liquidity contained in the position

positionTickLower2F77CCE1

get the lower tick of the position id

function positionTickLower2F77CCE1(address, uint256) external returns (int32);

Parameters

NameTypeDescription
<none>address
<none>uint256

Returns

NameTypeDescription
<none>int32the lower tick of the position given

positionTickUpper67FD55BA

get the upper tick of the position id

function positionTickUpper67FD55BA(address, uint256) external returns (int32);

Parameters

NameTypeDescription
<none>address
<none>uint256

Returns

NameTypeDescription
<none>int32the lower tick of the position given

sqrtPriceX967B8F5FC5

gets the current sqrt price of the pool

function sqrtPriceX967B8F5FC5(address) external returns (uint256);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256the current sqrtPriceX96 for the pool

feesOwed22F28DBD

feesOwed to a position ID given.

function feesOwed22F28DBD(address, uint256) external returns (uint128, uint128);

Parameters

NameTypeDescription
<none>address
<none>uint256

Returns

NameTypeDescription
<none>uint128the amount of token0 and token1 to get in return
<none>uint128

curTick181C6FD9

gets the currently used tick of the pool

function curTick181C6FD9(address) external returns (int32);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>int32the current active tick in the pool

tickSpacing653FE28F

gets the tick spacing of the pool

function tickSpacing653FE28F(address) external returns (uint8);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint8the tick spacing of the pool

feeBB3CF608

gets the fee for a specific pool

function feeBB3CF608(address) external returns (uint32);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint32the fee for the pool

feeGrowthGlobal038B5665B

gets the fee growth for token 0

function feeGrowthGlobal038B5665B(address) external returns (uint256);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256the fee growth for the other token

feeGrowthGlobal1A33A5A1B

gets the fee growth for token 1

function feeGrowthGlobal1A33A5A1B(address) external returns (uint256);

Parameters

NameTypeDescription
<none>address

Returns

NameTypeDescription
<none>uint256the fee growth for fUSDC

collectSingleTo6D76575F

collect a single position's yield

function collectSingleTo6D76575F(address, uint256, address) external returns (uint128, uint128);

Parameters

NameTypeDescription
<none>address
<none>uint256
<none>address

Returns

NameTypeDescription
<none>uint128amount0 and amount1
<none>uint128

collect7F21947C

collects fees from from positions

function collect7F21947C(address[] memory, uint256[] memory) external returns (CollectResult[] memory);

Parameters

NameTypeDescription
<none>address[]
<none>uint256[]

updatePositionC7F1F740

refreshes a position's fees, and adds or removes liquidity

function updatePositionC7F1F740(address, uint256, int128) external returns (int256, int256);

Parameters

NameTypeDescription
<none>address
<none>uint256
<none>int128

Returns

NameTypeDescription
<none>int256the deltas for token0 and token1 for the user
<none>int256

incrPositionE2437399

refreshes a position's fees, and adds liquidity, preventing less than the minimum from being taken.

function incrPositionE2437399(address, uint256, uint256, uint256, uint256, uint256)
    external
    returns (uint256, uint256);

Parameters

NameTypeDescription
<none>address
<none>uint256
<none>uint256
<none>uint256
<none>uint256
<none>uint256

Returns

NameTypeDescription
<none>uint256the deltas for token0, and token1
<none>uint256

setExecutorSwap

function setExecutorSwap(address a) external onlyProxyAdmin;

setExecutorSwapPermit2A

function setExecutorSwapPermit2A(address a) external onlyProxyAdmin;

setExecutorQuote

function setExecutorQuote(address a) external onlyProxyAdmin;

setExecutorPosition

function setExecutorPosition(address a) external onlyProxyAdmin;

setExecutorUpdatePosition

function setExecutorUpdatePosition(address a) external onlyProxyAdmin;

setExecutorAdmin

function setExecutorAdmin(address a) external onlyProxyAdmin;

setExecutorAdjustPosition

function setExecutorAdjustPosition(address a) external onlyProxyAdmin;

setExecutorSwapPermit2B

function setExecutorSwapPermit2B(address a) external onlyProxyAdmin;

setExecutorFallback

function setExecutorFallback(address a) external onlyProxyAdmin;

fallback

fallback() external;

_getExecutorSwap

function _getExecutorSwap() internal view returns (address);

_getExecutorSwapPermit2A

function _getExecutorSwapPermit2A() internal view returns (address);

_getExecutorQuote

function _getExecutorQuote() internal view returns (address);

_getExecutorPosition

function _getExecutorPosition() internal view returns (address);

_getExecutorUpdatePosition

function _getExecutorUpdatePosition() internal view returns (address);

_getExecutorAdmin

function _getExecutorAdmin() internal view returns (address);

_getExecutorAdjustPosition

function _getExecutorAdjustPosition() internal view returns (address);

_getExecutorSwapPermit2B

function _getExecutorSwapPermit2B() internal view returns (address);

_getExecutorFallback

function _getExecutorFallback() internal view returns (address);

_setProxyAdmin

function _setProxyAdmin(address newAdmin) internal;

_setProxies

function _setProxies(
    ISeawaterExecutorSwap executorSwap,
    ISeawaterExecutorSwapPermit2A executorSwapPermit2A,
    ISeawaterExecutorQuote executorQuote,
    ISeawaterExecutorPosition executorPosition,
    ISeawaterExecutorUpdatePosition executorUpdatePosition,
    ISeawaterExecutorAdmin executorAdmin,
    ISeawaterExecutorAdjustPosition executorAdjustPosition,
    ISeawaterExecutorSwapPermit2B executorSwapPermit2B,
    ISeawaterExecutorFallback executorFallback
) internal;

Constants

Git Source

EXECUTOR_SWAP_SLOT

0xb27456616f8c77c635d3551b8179f6887795e920c5c4421a6fa3c3c76fc90fa8

bytes32 constant EXECUTOR_SWAP_SLOT = bytes32(uint256(keccak256("seawater.impl.swap")) - 1);

EXECUTOR_SWAP_PERMIT2_A_SLOT

0x70879b7e5737e63f52eca3402c644a487e49ffeb7d78b75e54b18301a4f376ac

bytes32 constant EXECUTOR_SWAP_PERMIT2_A_SLOT = bytes32(uint256(keccak256("seawater.impl.swap_permit2.a")) - 1);

EXECUTOR_QUOTE_SLOT

0x031aae58aa658a4a607141f8a509c1b56789f013acaf58a8e12eb86456e099e4

bytes32 constant EXECUTOR_QUOTE_SLOT = bytes32(uint256(keccak256("seawater.impl.quote")) - 1);

EXECUTOR_POSITION_SLOT

0x75711a1f12071de4ad9b405fd0234f84fcd9d494050d3a5169de3ad4fd942476

bytes32 constant EXECUTOR_POSITION_SLOT = bytes32(uint256(keccak256("seawater.impl.position")) - 1);

EXECUTOR_UPDATE_POSITION_SLOT

0x81e9c7c70971b5eb969cec21a82e6deed42e7c6736e0e83ced66d72297d9f1d7

bytes32 constant EXECUTOR_UPDATE_POSITION_SLOT = bytes32(uint256(keccak256("seawater.impl.update_position")) - 1);

EXECUTOR_ADMIN_SLOT

0x344c13190645d452a52856ca1efc42b3609893d92b93219c8820b76f3aa11288

bytes32 constant EXECUTOR_ADMIN_SLOT = bytes32(uint256(keccak256("seawater.impl.admin")) - 1);

EXECUTOR_ADJUST_POSITION_SLOT

bytes32 constant EXECUTOR_ADJUST_POSITION_SLOT = bytes32(uint256(keccak256("seawater.impl.adjust_position")) - 1);

EXECUTOR_SWAP_PERMIT2_B_SLOT

bytes32 constant EXECUTOR_SWAP_PERMIT2_B_SLOT = bytes32(uint256(keccak256("seawater.impl.swap_permit2.b")) - 1);

EXECUTOR_FALLBACK_SLOT

0xa77145850668b2edbbe1c458388a99e3dca3d62b8335520225dc4d03b2e2bfe0

bytes32 constant EXECUTOR_FALLBACK_SLOT = bytes32(uint256(keccak256("seawater.impl.fallback")) - 1);

PROXY_ADMIN_SLOT

bytes32 constant PROXY_ADMIN_SLOT = bytes32(uint256(keccak256("seawater.role.proxy.admin")) - 1);

EXECUTOR_SWAP_DISPATCH

uint8 constant EXECUTOR_SWAP_DISPATCH = 0;

EXECUTOR_UPDATE_POSITION_DISPATCH

uint8 constant EXECUTOR_UPDATE_POSITION_DISPATCH = 1;

EXECUTOR_POSITION_DISPATCH

uint8 constant EXECUTOR_POSITION_DISPATCH = 2;

EXECUTOR_ADMIN_DISPATCH

uint8 constant EXECUTOR_ADMIN_DISPATCH = 3;

EXECUTOR_SWAP_PERMIT2_A_DISPATCH

uint8 constant EXECUTOR_SWAP_PERMIT2_A_DISPATCH = 4;

EXECUTOR_QUOTES_DISPATCH

uint8 constant EXECUTOR_QUOTES_DISPATCH = 5;

EXECUTOR_ADJUST_POSITION_DISPATCH

uint8 constant EXECUTOR_ADJUST_POSITION_DISPATCH = 6;

EXECUTOR_SWAP_PERMIT2_B_DISPATCH

uint8 constant EXECUTOR_SWAP_PERMIT2_B_DISPATCH = 7;