Superposition contracts

Security

Security instructions

Contributors

Contributors

Deployments

Superposition Mainnet

Superposition RPC

AMM contract deployments

Deployment nameDeployment address
Longtail AMM0x452D796b656D3720f2d06B3439eF95899f0db755
Longtail NFT manager0x42f104ed693792c858D03f987DfFB30e39cC1ce9
Permit2 router0x244517Dc59943E8CdFbD424Bdb3262c5f04a1387
Swaps implementation0xfc66c25dbdb0606e7f9ca1d2754eb0a0f8306da9
Swaps permit2 A implementation0x0b319db00d07c8fadfaaef13c910141a5da0aa8f
Quotes implementation0x05c1702aa4e5590970884645eae4bfa1b5210b27
Positions implementation0xb7a2930e66d84da74cdcfe4f97fae9fc8f1114e8
Update position implementation0x3079a40a0e0eaeef4d5d74fe22063b35844b3761
Admin implementation0xc0b176592d1f7abe464d3f27aec6d9f27bb5f6e1
Adjust position A implementation0xff634a3cb97bcf8cbaf8d2379afc8360c541218a
Swaps permit2 B implementation0xe3bafbd8f86800bac86025b2903335b32aa6f51f
Adjust position B implementation0xb4647415a644f6a09c84a2af6458d1d38d6e9d80
Position Handler0x46f9dea606a3D5890aD6d36C64acD55C26C51B8a

Administrative deployments

Deployment nameDeployment address
Proxy admin for Leo0x1192fC9c51C421578c099e4251D04F762bf87F68

Leo contract deployments

Deployment nameDeployment address
Leo proxy0xF3a2F99EDC730651428A490eDa4b1Fe4278bF0bb

Token deployments

Deployment nameDeployment address
USDC (base asset)0x6c030c5CC283F791B26816f325b9C632d964F8A1
WETH (native)0x1fB719f10b56d7a85DCD32f27f897375fB21cfdd

Superposition Testnet

Superposition RPC

AMM contract deployments

Deployment nameDeployment address
Longtail AMM0xAe86141e3f1C9168cE6c948FDC884F2A5f45d7B6
Longtail NFT manager0x8aa3750A7e8c98830e3421a89bFf80Fc175e4C98
Position Handler0x73387E7E4DF41f58Be13cdE4Dd4EAf3675c1C44c
Permit2 router0x2246431582087b930F2CE561c34deb8E7e5c44bE
Swaps A implementation0x0dc55b20bdf11fb0ea39e61743532711cda5436c
Swaps B implementation0xea0edbb819bcf094590000e36f19a5285c6457c3
Swaps permit2 A implementation0x0000000000000000000000000000000000000000
Quotes A implementation0xb5fb8fae334286f992a697e75f0c5d68d845415b
Quotes B implementation0xd8d7f75988556fb2dd1b971a4848f7b56cbcfd39
Positions implementation0xc9328bb8cdc2a890d428709b781f5f5932addb99
Update position implementation0xe6474ec944b35a914f915ce7686cd0003ca5b695
Admin implementation0x60c8d4ef56fd56967fcc123fe6b677bf41105180
Adjust position A impl0xc0111b0fae58f58451ba64dabfc5a2d5aaa0d5d3
Swaps permit2 B implementation0x0000000000000000000000000000000000000000
Adjust position B impl0xe96e51ced07a09d99c5b4c6068d274fdb12f9264

Leo contract deployments

Deployment nameDeployment address
Leo0xADA1629b77A4864340b7b9Dc4B9874068E844b08
Collect implementation0xcc76d4d1e7e021bd2309bfe236b345d95b8526c5
Extras implementation0x50bdc4ea3f3003099f936f2fc6f8cee0b730c168

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, ISeawaterExecutorSwapA, ISeawaterExecutorSwapPermit2A, ISeawaterExecutorQuoteA, ISeawaterExecutorPosition, ISeawaterExecutorUpdatePosition, ISeawaterExecutorAdminExposed, ISeawaterExecutorAdjustPositionA, ISeawaterExecutorSwapPermit2B, ISeawaterExecutorAdjustPositionB, ISeawaterExecutorSwapB, ISeawaterExecutorQuoteB

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

swap2ExactInED91BB1D

swaps tokenA for tokenB

function swap2ExactInED91BB1D(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

ISeawaterExecutorSwapA

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

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

ISeawaterExecutorQuoteA

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

ISeawaterExecutorQuoteB

Git Source

Functions

quote2A9EFFCC6

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

always revert with Error(string(amountOut))

function quote2A9EFFCC6(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

setFeeProtocolCBD3EC35

function setFeeProtocolCBD3EC35(address pool, uint8 feeProtocol0, uint8 feeProtocol1) external;

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

ISeawaterExecutorSwapB

Git Source

Functions

swap2ExactInED91BB1D

performs a two stage swap across two pools

function swap2ExactInED91BB1D(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

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

ISeawaterExecutorAdjustPositionA

Git Source

Functions

incrPositionE2437399

refreshes and takes a position's fees, and returns liquidity, preventing less than the minimum from being taken to be sent to the user.

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

ISeawaterExecutorAdjustPositionB

Git Source

Functions

decrPosition9A7D32E2

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

function decrPosition9A7D32E2(
    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 give to the user. May go lower.
amount1Desireduint256to give to the user. May go lower.

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 _admin, 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

upgrade

function upgrade(address _collect, address _extras) external;

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

Events

AdminChanged

event AdminChanged(address indexed oldAdmin, address indexed newAdmin);

Upgraded

event Upgraded(address indexed extras, address indexed collect);

Constants

Git Source

ADMIN_SLOT

bytes32 constant ADMIN_SLOT = bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1);

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

IEIP712

Git Source

Functions

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

ISignatureTransfer

Git Source

Inherits: IEIP712

Handles ERC20 token transfers through signature based actions

Requires user's token approval on the Permit2 contract

Functions

nonceBitmap

A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection

Uses unordered nonces so that permit messages do not need to be spent in a certain order

The mapping is indexed first by the token owner, then by an index specified in the nonce

It returns a uint256 bitmap

The index, or wordPosition is capped at type(uint248).max

function nonceBitmap(address, uint256) external view returns (uint256);

permitTransferFrom

Transfers a token using a signed permit message

Reverts if the requested amount is greater than the permitted signed amount

function permitTransferFrom(
    PermitTransferFrom memory permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetailsThe spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
signaturebytesThe signature to verify

permitWitnessTransferFrom

Transfers a token using a signed permit message

Includes extra data provided by the caller to verify signature over

The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition

Reverts if the requested amount is greater than the permitted signed amount

function permitWitnessTransferFrom(
    PermitTransferFrom memory permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes32 witness,
    string calldata witnessTypeString,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetailsThe spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
witnessbytes32Extra data to include when checking the user signature
witnessTypeStringstringThe EIP-712 type definition for remaining string stub of the typehash
signaturebytesThe signature to verify

permitTransferFrom

Transfers multiple tokens using a signed permit message

function permitTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitBatchTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetails[]Specifies the recipient and requested amount for the token transfer
owneraddressThe owner of the tokens to transfer
signaturebytesThe signature to verify

permitWitnessTransferFrom

Transfers multiple tokens using a signed permit message

Includes extra data provided by the caller to verify signature over

The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition

function permitWitnessTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes32 witness,
    string calldata witnessTypeString,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitBatchTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetails[]Specifies the recipient and requested amount for the token transfer
owneraddressThe owner of the tokens to transfer
witnessbytes32Extra data to include when checking the user signature
witnessTypeStringstringThe EIP-712 type definition for remaining string stub of the typehash
signaturebytesThe signature to verify

invalidateUnorderedNonces

Invalidates the bits specified in mask for the bitmap at the word position

The wordPos is maxed at type(uint248).max

function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;

Parameters

NameTypeDescription
wordPosuint256A number to index the nonceBitmap at
maskuint256A bitmap masked against msg.sender's current bitmap at the word position

Events

UnorderedNonceInvalidation

Emits an event when the owner successfully invalidates an unordered nonce.

event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask);

Errors

InvalidAmount

Thrown when the requested amount for a transfer is larger than the permissioned amount

error InvalidAmount(uint256 maxAmount);

Parameters

NameTypeDescription
maxAmountuint256The maximum amount a spender can request to transfer

LengthMismatch

Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred

If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred

error LengthMismatch();

Structs

TokenPermissions

The token and amount details for a transfer signed in the permit transfer signature

struct TokenPermissions {
    address token;
    uint256 amount;
}

PermitTransferFrom

The signed permit message for a single token transfer

struct PermitTransferFrom {
    TokenPermissions permitted;
    uint256 nonce;
    uint256 deadline;
}

SignatureTransferDetails

Specifies the recipient address and amount for batched transfers.

Recipients and amounts correspond to the index of the signed token permissions array.

Reverts if the requested amount is greater than the permitted signed amount.

struct SignatureTransferDetails {
    address to;
    uint256 requestedAmount;
}

PermitBatchTransferFrom

Used to reconstruct the signed permit message for multiple token transfers

Do not need to pass in spender address as it is required that it is msg.sender

Note that a user still signs over a spender address

struct PermitBatchTransferFrom {
    TokenPermissions[] permitted;
    uint256 nonce;
    uint256 deadline;
}

SignatureExpired

Git Source

Shared errors between signature based transfers and allowance based transfers.

Thrown when validating an inputted signature that is stale

error SignatureExpired(uint256 signatureDeadline);

Parameters

NameTypeDescription
signatureDeadlineuint256The timestamp at which a signature is no longer valid

InvalidNonce

Git Source

Thrown when validating that the inputted nonce has not been used

error InvalidNonce();

ERC20

Git Source

Authors: Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol), Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)

Modern and gas efficient ERC20 + EIP-2612 implementation.

Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.

State Variables

name

string public name;

symbol

string public symbol;

decimals

uint8 public immutable decimals;

totalSupply

uint256 public totalSupply;

balanceOf

mapping(address => uint256) public balanceOf;

allowance

mapping(address => mapping(address => uint256)) public allowance;

INITIAL_CHAIN_ID

uint256 internal immutable INITIAL_CHAIN_ID;

INITIAL_DOMAIN_SEPARATOR

bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

nonces

mapping(address => uint256) public nonces;

Functions

constructor

constructor(string memory _name, string memory _symbol, uint8 _decimals);

approve

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

transfer

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

transferFrom

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

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    virtual;

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() public view virtual returns (bytes32);

computeDomainSeparator

function computeDomainSeparator() internal view virtual returns (bytes32);

_mint

function _mint(address to, uint256 amount) internal virtual;

_burn

function _burn(address from, uint256 amount) internal virtual;

Events

Transfer

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

Approval

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

SafeTransferLib

Git Source

Author: Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)

Safe ETH and ERC20 transfer library that gracefully handles missing return values.

Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.

Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.

Functions

safeTransferETH

function safeTransferETH(address to, uint256 amount) internal;

safeTransferFrom

function safeTransferFrom(ERC20 token, address from, address to, uint256 amount) internal;

safeTransfer

function safeTransfer(ERC20 token, address to, uint256 amount) internal;

safeApprove

function safeApprove(ERC20 token, address to, uint256 amount) internal;

IERC1271

Git Source

Functions

isValidSignature

Should return whether the signature provided is valid for the provided data

function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);

Parameters

NameTypeDescription
hashbytes32Hash of the data to be signed
signaturebytesSignature byte array associated with _data

Returns

NameTypeDescription
magicValuebytes4The bytes4 magic value 0x1626ba7e

SignatureVerification

Git Source

State Variables

UPPER_BIT_MASK

bytes32 constant UPPER_BIT_MASK = (0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);

Functions

verify

function verify(bytes calldata signature, bytes32 hash, address claimedSigner) internal view;

Errors

InvalidSignatureLength

Thrown when the passed in signature is not a valid length

error InvalidSignatureLength();

InvalidSignature

Thrown when the recovered signer is equal to the zero address

error InvalidSignature();

InvalidSigner

Thrown when the recovered signer does not equal the claimedSigner

error InvalidSigner();

InvalidContractSignature

Thrown when the recovered contract signature is incorrect

error InvalidContractSignature();

IAllowanceTransfer

Git Source

Inherits: IEIP712

Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts

Requires user's token approval on the Permit2 contract

Functions

allowance

A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.

The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]

The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.

function allowance(address user, address token, address spender)
    external
    view
    returns (uint160 amount, uint48 expiration, uint48 nonce);

approve

Approves the spender to use up to amount of the specified token up until the expiration

The packed allowance also holds a nonce, which will stay unchanged in approve

Setting amount to type(uint160).max sets an unlimited approval

function approve(address token, address spender, uint160 amount, uint48 expiration) external;

Parameters

NameTypeDescription
tokenaddressThe token to approve
spenderaddressThe spender address to approve
amountuint160The approved amount of the token
expirationuint48The timestamp at which the approval is no longer valid

permit

Permit a spender to a given amount of the owners token via the owner's EIP-712 signature

May fail if the owner's nonce was invalidated in-flight by invalidateNonce

function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;

Parameters

NameTypeDescription
owneraddressThe owner of the tokens being approved
permitSinglePermitSingleData signed over by the owner specifying the terms of approval
signaturebytesThe owner's signature over the permit data

permit

Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature

May fail if the owner's nonce was invalidated in-flight by invalidateNonce

function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;

Parameters

NameTypeDescription
owneraddressThe owner of the tokens being approved
permitBatchPermitBatchData signed over by the owner specifying the terms of approval
signaturebytesThe owner's signature over the permit data

transferFrom

Transfer approved tokens from one address to another

Requires the from address to have approved at least the desired amount of tokens to msg.sender.

function transferFrom(address from, address to, uint160 amount, address token) external;

Parameters

NameTypeDescription
fromaddressThe address to transfer from
toaddressThe address of the recipient
amountuint160The amount of the token to transfer
tokenaddressThe token address to transfer

transferFrom

Transfer approved tokens in a batch

Requires the from addresses to have approved at least the desired amount of tokens to msg.sender.

function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;

Parameters

NameTypeDescription
transferDetailsAllowanceTransferDetails[]Array of owners, recipients, amounts, and tokens for the transfers

lockdown

Enables performing a "lockdown" of the sender's Permit2 identity by batch revoking approvals

function lockdown(TokenSpenderPair[] calldata approvals) external;

Parameters

NameTypeDescription
approvalsTokenSpenderPair[]Array of approvals to revoke.

invalidateNonces

Invalidate nonces for a given (token, spender) pair

Can't invalidate more than 2**16 nonces per transaction.

function invalidateNonces(address token, address spender, uint48 newNonce) external;

Parameters

NameTypeDescription
tokenaddressThe token to invalidate nonces for
spenderaddressThe spender to invalidate nonces for
newNonceuint48The new nonce to set. Invalidates all nonces less than it.

Events

NonceInvalidation

Emits an event when the owner successfully invalidates an ordered nonce.

event NonceInvalidation(
    address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce
);

Approval

Emits an event when the owner successfully sets permissions on a token for the spender.

event Approval(
    address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration
);

Permit

Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender.

event Permit(
    address indexed owner,
    address indexed token,
    address indexed spender,
    uint160 amount,
    uint48 expiration,
    uint48 nonce
);

Lockdown

Emits an event when the owner sets the allowance back to 0 with the lockdown function.

event Lockdown(address indexed owner, address token, address spender);

Errors

AllowanceExpired

Thrown when an allowance on a token has expired.

error AllowanceExpired(uint256 deadline);

Parameters

NameTypeDescription
deadlineuint256The timestamp at which the allowed amount is no longer valid

InsufficientAllowance

Thrown when an allowance on a token has been depleted.

error InsufficientAllowance(uint256 amount);

Parameters

NameTypeDescription
amountuint256The maximum amount allowed

ExcessiveInvalidation

Thrown when too many nonces are invalidated.

error ExcessiveInvalidation();

Structs

PermitDetails

The permit data for a token

struct PermitDetails {
    address token;
    uint160 amount;
    uint48 expiration;
    uint48 nonce;
}

PermitSingle

The permit message signed for a single token allowance

struct PermitSingle {
    PermitDetails details;
    address spender;
    uint256 sigDeadline;
}

PermitBatch

The permit message signed for multiple token allowances

struct PermitBatch {
    PermitDetails[] details;
    address spender;
    uint256 sigDeadline;
}

PackedAllowance

The saved permissions

This info is saved per owner, per token, per spender and all signed over in the permit message

Setting amount to type(uint160).max sets an unlimited approval

struct PackedAllowance {
    uint160 amount;
    uint48 expiration;
    uint48 nonce;
}

TokenSpenderPair

A token spender pair.

struct TokenSpenderPair {
    address token;
    address spender;
}

AllowanceTransferDetails

Details for a token transfer.

struct AllowanceTransferDetails {
    address from;
    address to;
    uint160 amount;
    address token;
}

PermitHash

Git Source

State Variables

_PERMIT_DETAILS_TYPEHASH

bytes32 public constant _PERMIT_DETAILS_TYPEHASH =
    keccak256("PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)");

_PERMIT_SINGLE_TYPEHASH

bytes32 public constant _PERMIT_SINGLE_TYPEHASH = keccak256(
    "PermitSingle(PermitDetails details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)"
);

_PERMIT_BATCH_TYPEHASH

bytes32 public constant _PERMIT_BATCH_TYPEHASH = keccak256(
    "PermitBatch(PermitDetails[] details,address spender,uint256 sigDeadline)PermitDetails(address token,uint160 amount,uint48 expiration,uint48 nonce)"
);

_TOKEN_PERMISSIONS_TYPEHASH

bytes32 public constant _TOKEN_PERMISSIONS_TYPEHASH = keccak256("TokenPermissions(address token,uint256 amount)");

_PERMIT_TRANSFER_FROM_TYPEHASH

bytes32 public constant _PERMIT_TRANSFER_FROM_TYPEHASH = keccak256(
    "PermitTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline)TokenPermissions(address token,uint256 amount)"
);

_PERMIT_BATCH_TRANSFER_FROM_TYPEHASH

bytes32 public constant _PERMIT_BATCH_TRANSFER_FROM_TYPEHASH = keccak256(
    "PermitBatchTransferFrom(TokenPermissions[] permitted,address spender,uint256 nonce,uint256 deadline)TokenPermissions(address token,uint256 amount)"
);

_TOKEN_PERMISSIONS_TYPESTRING

string public constant _TOKEN_PERMISSIONS_TYPESTRING = "TokenPermissions(address token,uint256 amount)";

_PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB

string public constant _PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB =
    "PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,";

_PERMIT_BATCH_WITNESS_TRANSFER_FROM_TYPEHASH_STUB

string public constant _PERMIT_BATCH_WITNESS_TRANSFER_FROM_TYPEHASH_STUB =
    "PermitBatchWitnessTransferFrom(TokenPermissions[] permitted,address spender,uint256 nonce,uint256 deadline,";

Functions

hash

function hash(IAllowanceTransfer.PermitSingle memory permitSingle) internal pure returns (bytes32);

hash

function hash(IAllowanceTransfer.PermitBatch memory permitBatch) internal pure returns (bytes32);

hash

function hash(ISignatureTransfer.PermitTransferFrom memory permit) internal view returns (bytes32);

hash

function hash(ISignatureTransfer.PermitBatchTransferFrom memory permit) internal view returns (bytes32);

hashWithWitness

function hashWithWitness(
    ISignatureTransfer.PermitTransferFrom memory permit,
    bytes32 witness,
    string calldata witnessTypeString
) internal view returns (bytes32);

hashWithWitness

function hashWithWitness(
    ISignatureTransfer.PermitBatchTransferFrom memory permit,
    bytes32 witness,
    string calldata witnessTypeString
) internal view returns (bytes32);

_hashPermitDetails

function _hashPermitDetails(IAllowanceTransfer.PermitDetails memory details) private pure returns (bytes32);

_hashTokenPermissions

function _hashTokenPermissions(ISignatureTransfer.TokenPermissions memory permitted) private pure returns (bytes32);

EIP712

Git Source

Inherits: IEIP712

EIP712 helpers for permit2

Maintains cross-chain replay protection in the event of a fork

Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol

State Variables

_CACHED_DOMAIN_SEPARATOR

bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;

_CACHED_CHAIN_ID

uint256 private immutable _CACHED_CHAIN_ID;

_HASHED_NAME

bytes32 private constant _HASHED_NAME = keccak256("Permit2");

_TYPE_HASH

bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");

Functions

constructor

constructor();

DOMAIN_SEPARATOR

Returns the domain separator for the current chain.

Uses cached version if chainid and address are unchanged from construction.

function DOMAIN_SEPARATOR() public view override returns (bytes32);

_buildDomainSeparator

Builds a domain separator using the current chainId and contract address.

function _buildDomainSeparator(bytes32 typeHash, bytes32 nameHash) private view returns (bytes32);

_hashTypedData

Creates an EIP-712 typed data hash

function _hashTypedData(bytes32 dataHash) internal view returns (bytes32);

SignatureTransfer

Git Source

Inherits: ISignatureTransfer, EIP712

State Variables

nonceBitmap

A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection

Uses unordered nonces so that permit messages do not need to be spent in a certain order

mapping(address => mapping(uint256 => uint256)) public nonceBitmap;

Functions

permitTransferFrom

Transfers a token using a signed permit message

Reverts if the requested amount is greater than the permitted signed amount

function permitTransferFrom(
    PermitTransferFrom memory permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetailsThe spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
signaturebytesThe signature to verify

permitWitnessTransferFrom

Transfers a token using a signed permit message

The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition

function permitWitnessTransferFrom(
    PermitTransferFrom memory permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes32 witness,
    string calldata witnessTypeString,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetailsThe spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
witnessbytes32Extra data to include when checking the user signature
witnessTypeStringstringThe EIP-712 type definition for remaining string stub of the typehash
signaturebytesThe signature to verify

_permitTransferFrom

Transfers a token using a signed permit message.

function _permitTransferFrom(
    PermitTransferFrom memory permit,
    SignatureTransferDetails calldata transferDetails,
    address owner,
    bytes32 dataHash,
    bytes calldata signature
) private;

Parameters

NameTypeDescription
permitPermitTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetailsThe spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
dataHashbytes32The EIP-712 hash of permit data to include when checking signature
signaturebytesThe signature to verify

permitTransferFrom

Transfers a token using a signed permit message

Reverts if the requested amount is greater than the permitted signed amount

function permitTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitBatchTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetails[]The spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
signaturebytesThe signature to verify

permitWitnessTransferFrom

Transfers a token using a signed permit message

The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition

function permitWitnessTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes32 witness,
    string calldata witnessTypeString,
    bytes calldata signature
) external;

Parameters

NameTypeDescription
permitPermitBatchTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetails[]The spender's requested transfer details for the permitted token
owneraddressThe owner of the tokens to transfer
witnessbytes32Extra data to include when checking the user signature
witnessTypeStringstringThe EIP-712 type definition for remaining string stub of the typehash
signaturebytesThe signature to verify

_permitTransferFrom

Transfers tokens using a signed permit messages

function _permitTransferFrom(
    PermitBatchTransferFrom memory permit,
    SignatureTransferDetails[] calldata transferDetails,
    address owner,
    bytes32 dataHash,
    bytes calldata signature
) private;

Parameters

NameTypeDescription
permitPermitBatchTransferFromThe permit data signed over by the owner
transferDetailsSignatureTransferDetails[]
owneraddressThe owner of the tokens to transfer
dataHashbytes32The EIP-712 hash of permit data to include when checking signature
signaturebytesThe signature to verify

invalidateUnorderedNonces

Invalidates the bits specified in mask for the bitmap at the word position

The wordPos is maxed at type(uint248).max

function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;

Parameters

NameTypeDescription
wordPosuint256A number to index the nonceBitmap at
maskuint256A bitmap masked against msg.sender's current bitmap at the word position

bitmapPositions

Returns the index of the bitmap and the bit position within the bitmap. Used for unordered nonces

The first 248 bits of the nonce value is the index of the desired bitmap

The last 8 bits of the nonce value is the position of the bit in the bitmap

function bitmapPositions(uint256 nonce) private pure returns (uint256 wordPos, uint256 bitPos);

Parameters

NameTypeDescription
nonceuint256The nonce to get the associated word and bit positions

Returns

NameTypeDescription
wordPosuint256The word position or index into the nonceBitmap
bitPosuint256The bit position

_useUnorderedNonce

Checks whether a nonce is taken and sets the bit at the bit position in the bitmap at the word position

function _useUnorderedNonce(address from, uint256 nonce) internal;

Parameters

NameTypeDescription
fromaddressThe address to use the nonce at
nonceuint256The nonce to spend

Allowance

Git Source

State Variables

BLOCK_TIMESTAMP_EXPIRATION

uint256 private constant BLOCK_TIMESTAMP_EXPIRATION = 0;

Functions

updateAll

Sets the allowed amount, expiry, and nonce of the spender's permissions on owner's token.

Nonce is incremented.

If the inputted expiration is 0, the stored expiration is set to block.timestamp

function updateAll(IAllowanceTransfer.PackedAllowance storage allowed, uint160 amount, uint48 expiration, uint48 nonce)
    internal;

updateAmountAndExpiration

Sets the allowed amount and expiry of the spender's permissions on owner's token.

Nonce does not need to be incremented.

function updateAmountAndExpiration(
    IAllowanceTransfer.PackedAllowance storage allowed,
    uint160 amount,
    uint48 expiration
) internal;

pack

Computes the packed slot of the amount, expiration, and nonce that make up PackedAllowance

function pack(uint160 amount, uint48 expiration, uint48 nonce) internal pure returns (uint256 word);

AllowanceTransfer

Git Source

Inherits: IAllowanceTransfer, EIP712

State Variables

allowance

Maps users to tokens to spender addresses and information about the approval on the token

Indexed in the order of token owner address, token address, spender address

The stored word saves the allowed amount, expiration on the allowance, and nonce

mapping(address => mapping(address => mapping(address => PackedAllowance))) public allowance;

Functions

approve

Approves the spender to use up to amount of the specified token up until the expiration

The packed allowance also holds a nonce, which will stay unchanged in approve

function approve(address token, address spender, uint160 amount, uint48 expiration) external;

Parameters

NameTypeDescription
tokenaddressThe token to approve
spenderaddressThe spender address to approve
amountuint160The approved amount of the token
expirationuint48The timestamp at which the approval is no longer valid

permit

Permit a spender to a given amount of the owners token via the owner's EIP-712 signature

May fail if the owner's nonce was invalidated in-flight by invalidateNonce

function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;

Parameters

NameTypeDescription
owneraddressThe owner of the tokens being approved
permitSinglePermitSingleData signed over by the owner specifying the terms of approval
signaturebytesThe owner's signature over the permit data

permit

Permit a spender to a given amount of the owners token via the owner's EIP-712 signature

May fail if the owner's nonce was invalidated in-flight by invalidateNonce

function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;

Parameters

NameTypeDescription
owneraddressThe owner of the tokens being approved
permitBatchPermitBatch
signaturebytesThe owner's signature over the permit data

transferFrom

Transfer approved tokens from one address to another

Requires the from address to have approved at least the desired amount of tokens to msg.sender.

function transferFrom(address from, address to, uint160 amount, address token) external;

Parameters

NameTypeDescription
fromaddressThe address to transfer from
toaddressThe address of the recipient
amountuint160The amount of the token to transfer
tokenaddressThe token address to transfer

transferFrom

Transfer approved tokens from one address to another

Requires the from address to have approved at least the desired amount of tokens to msg.sender.

function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;

Parameters

NameTypeDescription
transferDetailsAllowanceTransferDetails[]

_transfer

Internal function for transferring tokens using stored allowances

Will fail if the allowed timeframe has passed

function _transfer(address from, address to, uint160 amount, address token) private;

lockdown

Enables performing a "lockdown" of the sender's Permit2 identity by batch revoking approvals

function lockdown(TokenSpenderPair[] calldata approvals) external;

Parameters

NameTypeDescription
approvalsTokenSpenderPair[]Array of approvals to revoke.

invalidateNonces

Invalidate nonces for a given (token, spender) pair

Can't invalidate more than 2**16 nonces per transaction.

function invalidateNonces(address token, address spender, uint48 newNonce) external;

Parameters

NameTypeDescription
tokenaddressThe token to invalidate nonces for
spenderaddressThe spender to invalidate nonces for
newNonceuint48The new nonce to set. Invalidates all nonces less than it.

_updateApproval

Sets the new values for amount, expiration, and nonce.

Will check that the signed nonce is equal to the current nonce and then incrememnt the nonce value by 1.

Emits a Permit event.

function _updateApproval(PermitDetails memory details, address owner, address spender) private;

Permit2

Git Source

Inherits: SignatureTransfer, AllowanceTransfer

Permit2 handles signature-based transfers in SignatureTransfer and allowance-based transfers in AllowanceTransfer.

Users must approve Permit2 before calling any of the transfer functions.

PositionHandler

Git Source

State Variables

LONGTAIL

ISeawaterAMM immutable LONGTAIL;

LEO

ILeo immutable LEO;

NFT_MANAGER

OwnershipNFTs immutable NFT_MANAGER;

FUSDC

IERC20 immutable FUSDC;

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,
    ISeawaterExecutorSwapA _executorSwapA,
    ISeawaterExecutorSwapPermit2A _executorSwapPermit2A,
    ISeawaterExecutorQuoteA _executorQuoteA,
    ISeawaterExecutorPosition _executorPosition,
    ISeawaterExecutorUpdatePosition _executorUpdatePosition,
    ISeawaterExecutorAdmin _executorAdmin,
    ISeawaterExecutorAdjustPositionA _executorAdjustPositionsA,
    ISeawaterExecutorSwapPermit2B _executorSwapPermit2B,
    ISeawaterExecutorAdjustPositionB _executorAdjustPositionsB,
    ISeawaterExecutorSwapB _executorSwapB,
    ISeawaterExecutorQuoteB _executorQuoteB,
    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
_executorSwapAISeawaterExecutorSwapAthe deployed code for the swap executor (swap 1)
_executorSwapPermit2AISeawaterExecutorSwapPermit2Athe deployed code for the swap_permit2 executor (facet A)
_executorQuoteAISeawaterExecutorQuoteAthe deployed code for the quote A executor
_executorPositionISeawaterExecutorPositionthe deployed code for the positions executor
_executorUpdatePositionISeawaterExecutorUpdatePosition
_executorAdminISeawaterExecutorAdminthe deployed code for the admin executor
_executorAdjustPositionsAISeawaterExecutorAdjustPositionAthe deployed code for the adjust positions executor (facet A)
_executorSwapPermit2BISeawaterExecutorSwapPermit2Bthe deployed code for the swap_permit2 executor (facet B)
_executorAdjustPositionsBISeawaterExecutorAdjustPositionBthe deployed code for the adjust positions executor (facet B)
_executorSwapBISeawaterExecutorSwapBthe deployed code for the swap executor (swap 2)
_executorQuoteBISeawaterExecutorQuoteBthe deployed code for the quote B executor (quote 2)
_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

setFeeProtocolCBD3EC35

function setFeeProtocolCBD3EC35(address, uint8, uint8) external;

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

quote2A9EFFCC6

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

function quote2A9EFFCC6(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

swap2ExactInED91BB1D

performs a two stage swap across two pools

function swap2ExactInED91BB1D(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 pools, uint256[] memory ids)
    external
    returns (CollectResult[] memory results);

Parameters

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

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 and takes a position's fees, and returns liquidity, preventing less than the minimum from being taken to be sent to the user.

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

decrPosition9A7D32E2

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

function decrPosition9A7D32E2(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

setExecutorSwapA

function setExecutorSwapA(address a) external onlyProxyAdmin;

setExecutorSwapPermit2A

function setExecutorSwapPermit2A(address a) external onlyProxyAdmin;

setExecutorQuoteA

function setExecutorQuoteA(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;

setExecutorAdjustPositionA

function setExecutorAdjustPositionA(address a) external onlyProxyAdmin;

setExecutorSwapPermit2B

function setExecutorSwapPermit2B(address a) external onlyProxyAdmin;

setExecutorSwapB

function setExecutorSwapB(address a) external onlyProxyAdmin;

setExecutorQuoteB

function setExecutorQuoteB(address a) external onlyProxyAdmin;

setExecutorFallback

function setExecutorFallback(address a) external onlyProxyAdmin;

fallback

fallback() external;

_getExecutorSwapA

function _getExecutorSwapA() internal view returns (address);

_getExecutorSwapPermit2A

function _getExecutorSwapPermit2A() internal view returns (address);

_getExecutorQuoteA

function _getExecutorQuoteA() 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);

_getExecutorAdjustPositionA

function _getExecutorAdjustPositionA() internal view returns (address);

_getExecutorAdjustPositionB

function _getExecutorAdjustPositionB() internal view returns (address);

_getExecutorSwapPermit2B

function _getExecutorSwapPermit2B() internal view returns (address);

_getExecutorSwapB

function _getExecutorSwapB() internal view returns (address);

_getExecutorQuoteB

function _getExecutorQuoteB() internal view returns (address);

_getExecutorFallback

function _getExecutorFallback() internal view returns (address);

_setProxyAdmin

function _setProxyAdmin(address newAdmin) internal;

_setProxies

function _setProxies(
    ISeawaterExecutorSwapA executorSwapA,
    ISeawaterExecutorSwapPermit2A executorSwapPermit2A,
    ISeawaterExecutorQuoteA executorQuoteA,
    ISeawaterExecutorPosition executorPosition,
    ISeawaterExecutorUpdatePosition executorUpdatePosition,
    ISeawaterExecutorAdmin executorAdmin,
    ISeawaterExecutorAdjustPositionA executorAdjustPositionA,
    ISeawaterExecutorSwapPermit2B executorSwapPermit2B,
    ISeawaterExecutorAdjustPositionB executorAdjustPositionB,
    ISeawaterExecutorSwapB executorSwapB,
    ISeawaterExecutorQuoteB executorQuoteB,
    ISeawaterExecutorFallback executorFallback
) internal;

Constants

Git Source

EXECUTOR_SWAP_A_SLOT

**

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

EXECUTOR_SWAP_PERMIT2_A_SLOT

0x918729dd8afb81fac3242345361976256d4c1121ed7c3b67e14c9e3fd9e750e2

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

EXECUTOR_QUOTE_A_SLOT

**

bytes32 constant EXECUTOR_QUOTE_A_SLOT = bytes32(uint256(keccak256("seawater.impl.quote.a")) - 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_A_SLOT

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

EXECUTOR_ADJUST_POSITION_B_SLOT

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

EXECUTOR_SWAP_PERMIT2_B_SLOT

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

EXECUTOR_SWAP_B_SLOT

**

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

EXECUTOR_QUOTE_B_SLOT

bytes32 constant EXECUTOR_QUOTE_B_SLOT = bytes32(uint256(keccak256("seawater.impl.quote.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_A_DISPATCH

uint8 constant EXECUTOR_SWAP_A_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_A_DISPATCH

uint8 constant EXECUTOR_QUOTES_A_DISPATCH = 5;

EXECUTOR_ADJUST_POSITION_A_DISPATCH

uint8 constant EXECUTOR_ADJUST_POSITION_A_DISPATCH = 6;

EXECUTOR_SWAP_PERMIT2_B_DISPATCH

uint8 constant EXECUTOR_SWAP_PERMIT2_B_DISPATCH = 7;

EXECUTOR_ADJUST_POSITION_B_DISPATCH

uint8 constant EXECUTOR_ADJUST_POSITION_B_DISPATCH = 8;

EXECUTOR_SWAP_B_DISPATCH

uint8 constant EXECUTOR_SWAP_B_DISPATCH = 9;

EXECUTOR_QUOTES_B_DISPATCH

uint8 constant EXECUTOR_QUOTES_B_DISPATCH = 10;