Superposition contracts
Security
Contributors
Deployments
Superposition Mainnet
AMM contract deployments
Deployment name | Deployment address |
---|---|
Longtail AMM | 0x452D796b656D3720f2d06B3439eF95899f0db755 |
Longtail NFT manager | 0x42f104ed693792c858D03f987DfFB30e39cC1ce9 |
Permit2 router | 0x244517Dc59943E8CdFbD424Bdb3262c5f04a1387 |
Swaps implementation | 0xfc66c25dbdb0606e7f9ca1d2754eb0a0f8306da9 |
Swaps permit2 A implementation | 0x0b319db00d07c8fadfaaef13c910141a5da0aa8f |
Quotes implementation | 0x05c1702aa4e5590970884645eae4bfa1b5210b27 |
Positions implementation | 0xb7a2930e66d84da74cdcfe4f97fae9fc8f1114e8 |
Update position implementation | 0x3079a40a0e0eaeef4d5d74fe22063b35844b3761 |
Admin implementation | 0xc0b176592d1f7abe464d3f27aec6d9f27bb5f6e1 |
Adjust position A implementation | 0xff634a3cb97bcf8cbaf8d2379afc8360c541218a |
Swaps permit2 B implementation | 0xe3bafbd8f86800bac86025b2903335b32aa6f51f |
Adjust position B implementation | 0xb4647415a644f6a09c84a2af6458d1d38d6e9d80 |
Position Handler | 0x46f9dea606a3D5890aD6d36C64acD55C26C51B8a |
Administrative deployments
Deployment name | Deployment address |
---|---|
Proxy admin for Leo | 0x1192fC9c51C421578c099e4251D04F762bf87F68 |
Leo contract deployments
Deployment name | Deployment address |
---|---|
Leo proxy | 0xF3a2F99EDC730651428A490eDa4b1Fe4278bF0bb |
Token deployments
Deployment name | Deployment address |
---|---|
USDC (base asset) | 0x6c030c5CC283F791B26816f325b9C632d964F8A1 |
WETH (native) | 0x1fB719f10b56d7a85DCD32f27f897375fB21cfdd |
Superposition Testnet
AMM contract deployments
Deployment name | Deployment address |
---|---|
Longtail AMM | 0xAe86141e3f1C9168cE6c948FDC884F2A5f45d7B6 |
Longtail NFT manager | 0x8aa3750A7e8c98830e3421a89bFf80Fc175e4C98 |
Position Handler | 0x73387E7E4DF41f58Be13cdE4Dd4EAf3675c1C44c |
Permit2 router | 0x2246431582087b930F2CE561c34deb8E7e5c44bE |
Swaps A implementation | 0x0dc55b20bdf11fb0ea39e61743532711cda5436c |
Swaps B implementation | 0xea0edbb819bcf094590000e36f19a5285c6457c3 |
Swaps permit2 A implementation | 0x0000000000000000000000000000000000000000 |
Quotes A implementation | 0xb5fb8fae334286f992a697e75f0c5d68d845415b |
Quotes B implementation | 0xd8d7f75988556fb2dd1b971a4848f7b56cbcfd39 |
Positions implementation | 0xc9328bb8cdc2a890d428709b781f5f5932addb99 |
Update position implementation | 0xe6474ec944b35a914f915ce7686cd0003ca5b695 |
Admin implementation | 0x60c8d4ef56fd56967fcc123fe6b677bf41105180 |
Adjust position A impl | 0xc0111b0fae58f58451ba64dabfc5a2d5aaa0d5d3 |
Swaps permit2 B implementation | 0x0000000000000000000000000000000000000000 |
Adjust position B impl | 0xe96e51ced07a09d99c5b4c6068d274fdb12f9264 |
Leo contract deployments
Deployment name | Deployment address |
---|---|
Leo | 0xADA1629b77A4864340b7b9Dc4B9874068E844b08 |
Collect implementation | 0xcc76d4d1e7e021bd2309bfe236b345d95b8526c5 |
Extras implementation | 0x50bdc4ea3f3003099f936f2fc6f8cee0b730c168 |
Useful testing token deployments
Deployment name | Deployment address |
---|---|
fUSDC | 0xA8EA92c819463EFbEdDFB670FEfC881A480f0115 |
WETH | 0xde104342B32BCa03ec995f999181f7Cf1fFc04d7 |
USDC | 0x6437fdc89cED41941b97A9f1f8992D88718C81c5 |
WSPN | 0x22b9fa698b68bBA071B513959794E9a47d19214c |
CATBUX | 0x36c116a8851869cf8a99b3Bda0Fad42453D32B99 |
Errors
Currently, to save on space, errors generated by the contract are terse. Decode the hex to the appropriate error in this table:
No | Hex | Explanation |
---|---|---|
0 | 0x00 | Denominator is 0 |
1 | 0x01 | Result is U256::MAX |
2 | 0x02 | Sqrt price is 0 |
3 | 0x03 | Sqrt price is less than or equal to quotient |
4 | 0x04 | Can not get most significant bit or least significant bit on zero value |
5 | 0x05 | Liquidity is 0 |
6 | 0x06 | require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); |
7 | 0x07 | Denominator is less than or equal to prod_1 |
8 | 0x08 | Liquidity Sub |
9 | 0x09 | Liquidity Add |
10 | 0x0a | The given tick must be less than, or equal to, the maximum tick |
11 | 0x0b | Second inequality must be < because the price can never reach the price at the max tick |
12 | 0x0c | Overflow when casting to U160 |
13 | 0x0d | Liquidity higher than max |
14 | 0x0e | Fee growth sub overflow |
15 | 0x0f | ERC20 call reverted |
16 | 0x10 | ERC20 call reverted with no data |
17 | 0x11 | Pool is already initialised |
18 | 0x12 | Contract is already initialised |
19 | 0x13 | Price limit too high |
20 | 0x14 | Price limit too low |
21 | 0x15 | Checked abs called on an unexpected positive number |
22 | 0x16 | Checked abs called on an unexpected negative number |
23 | 0x17 | Checked abs called on uint.min |
24 | 0x18 | Fee result too high |
25 | 0x19 | Swap result too high |
26 | 0x1a | Internal swap amounts not matched |
27 | 0x1b | Internal swap result was positive |
28 | 0x1c | Minimum out not reached |
29 | 0x1d | Only the position owner can use this |
30 | 0x1e | Only the NFT manager can use this |
31 | 0x1f | Only the Seawater admin can use this |
32 | 0x20 | Operation unavailable when the pool is disabled |
33 | 0x21 | Invalid tick spacing |
34 | 0x22 | Swap result too low |
35 | 0x23 | Liquidity too low or high to be a int128 |
36 | 0x24 | Invalid tick |
37 | 0x25 | Pool enabled when it should be disabled for this action |
38 | 0x26 | Position is empty when it shouldn't be |
39 | 0x27 | Liquidity that was almost taken was too low when it didn't need to be |
40 | 0x28 | Fee 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
Name | Description |
---|---|
FLU_SEAWATER_PERMIT2_ADDR | Uniswap Permit2 router |
FLU_SEAWATER_FUSDC_ADDR | USDC Super Asset to route every trade through |
Build dependencies
Name | Source |
---|---|
Rust (nightly version) | Installer |
Cargo Stylus subcommand | Repo |
Foundry | Installer |
Make | build-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 SLOAD
s), 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
Name | Description |
---|---|
SEAWATER_PROXY_ADMIN | Address that's permitted to administrate the code, including deploying updates, and creating pools. |
STYLUS_ENDPOINT | URL to access the Stylus node. |
STYLUS_PRIVATE_KEY | Private key to use for deployment. |
FLU_SEAWATER_FUSDC_ADDR | Super USDC address to use as the base asset for each pool. |
IERC20
Functions
transfer
function transfer(address recipient, uint256 amount) external;
Faucet
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
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
Name | Type | Description |
---|---|---|
interfaceID | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC20
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
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
Name | Type | Description |
---|---|---|
_owner | address | An address for whom to query the balance |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
data | bytes | Additional 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True 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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The 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
Name | Type | Description |
---|---|---|
_owner | address | The address that owns the NFTs |
_operator | address | The address that acts on behalf of the owner |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True 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
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
Name | Type | Description |
---|---|---|
_operator | address | The address which called safeTransferFrom function |
_from | address | The address which previously owned the token |
_tokenId | uint256 | The NFT identifier which is being transferred |
_data | bytes | Additional data with no specified format |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")) unless throwing |
IFaucet
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
Inherits: ILeoEvents
Functions
vestPosition
vest a position that the caller owns.
function vestPosition(address pool, uint256 id, address recipient) external;
Parameters
Name | Type | Description |
---|---|---|
pool | address | to take the position from |
id | uint256 | of the position to take |
recipient | address | to 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
Name | Type | Description |
---|---|---|
campaignId | bytes8 | to modify for the pool given |
pool | address | to reward positions that participate in with |
tickLower | int32 | to reward positions in this range with |
tickUpper | int32 | to reward positions in this range with |
perSecond | uint64 | distribution to send |
token | address | to give out |
extraMax | uint256 | to start the pool amount with for this pool |
starting | uint64 | to when to start the token distribution with |
ending | uint64 | for 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
Name | Type | Description |
---|---|---|
pool | address | to modify the campaign for |
campaignId | bytes8 | to 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
Name | Type | Description |
---|---|---|
campaignId | bytes8 | to identify this campaign |
poolLp
pool LP tokens vested to Leo for this pool
function poolLp(address pool) external returns (uint256 lp);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to check |
Returns
Name | Type | Description |
---|---|---|
lp | uint256 | tokens 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
Name | Type | Description |
---|---|---|
positionDetails | PositionDetails[] | to check |
campaignIds | bytes8[] | to check |
recipient | address | of the returned amounts |
divestPosition
divest a position, returning the position ID to the user
function divestPosition(uint256 positionId, address recipient) external;
Parameters
Name | Type | Description |
---|---|---|
positionId | uint256 | to move out |
recipient | address | to 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
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
Name | Type | Description |
---|---|---|
identifier | bytes8 | that was computed to represent this campaign |
pool | address | that this is eligible for |
token | address | that is being given out for this campaign |
details | uint256 | that are packed including the lower tick, upper, and the owner |
times | uint256 | that 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
Name | Type | Description |
---|---|---|
identifier | bytes8 | that was computed to represent this campaign |
pool | address | that this campaign is for that was just updated |
perSecond | uint256 | distribution to give out |
extras | uint256 | including 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
Name | Type | Description |
---|---|---|
positionId | uint256 | that was just vested |
owner | address |
PositionDivested2
a specific position was just divested from Leo
event PositionDivested2(uint256 indexed positionId, address indexed recipient);
Parameters
Name | Type | Description |
---|---|---|
positionId | uint256 | that was divested |
recipient | address | of the divested position |
ISeawater
Inherits: ISeawaterAMM
ISeawaterAMM
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
Name | Type | Description |
---|---|---|
_token | address | the token to swap |
_amount | uint256 | input amount (token) |
_minOut | uint256 | the minimum output amount (usdc), reverting if the actual output is lower |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount 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
Name | Type | Description |
---|---|---|
_token | address | the token to swap |
_amount | uint256 | input amount (token) |
_minOut | uint256 | the minimum output amount (usdc), reverting if the actual output is lower |
_nonce | uint256 | the nonce for the token |
_deadline | uint256 | the deadline for the token |
_maxAmount | uint256 | the max amount of the token |
_sig | bytes | the signature for the token |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount of usdc out |
<none> | int256 |
swapOut5E08A399
swaps USDC for _token
function swapOut5E08A399(address _token, uint256 _amount, uint256 _minOut) external returns (int256, int256);
Parameters
Name | Type | Description |
---|---|---|
_token | address | the token to swap |
_amount | uint256 | input amount (usdc) |
_minOut | uint256 | the minimum output amount (token), reverting if the actual output is lower |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount 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
Name | Type | Description |
---|---|---|
_token | address | the token to swap |
_amount | uint256 | input amount (usdc) |
_minOut | uint256 | the minimum output amount (token), reverting if the actual output is lower |
_nonce | uint256 | the nonce for the token |
_deadline | uint256 | the deadline for the token |
_maxAmount | uint256 | the max amount of the token |
_sig | bytes | the signature for the token |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount 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
Name | Type | Description |
---|---|---|
_tokenA | address | the input token |
_tokenB | address | the output token |
_amount | uint256 | input amount (tokenA) |
_minOut | uint256 | the minimum output amount (tokenB), reverting if the actual output is lower |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | amount of token A in, amount of token B out |
<none> | uint256 |
ISeawaterEvents
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
Name | Type | Description |
---|---|---|
id | uint256 | the position id |
owner | address | the owner of the position |
pool | address | the pool the position is associated with |
lower | int32 | the lower tick of the position's concentrated liquidity range |
upper | int32 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | the id of the position being burned |
owner | address | the user the owned the position |
TransferPosition
emitted when a position changes owners
event TransferPosition(address indexed from, address indexed to, uint256 indexed id);
Parameters
Name | Type | Description |
---|---|---|
from | address | the original owner of the position |
to | address | the new owner of the position |
id | uint256 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | |
token0 | int256 | |
token1 | int256 | that 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
Name | Type | Description |
---|---|---|
id | uint256 | the id of the position whose liquidity is being collected |
pool | address | the address of the pool the position is associated with |
to | address | the recipient of the fees |
amount0 | uint128 | the amount of token0 being collected |
amount1 | uint128 | the 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
Name | Type | Description |
---|---|---|
token | address | the token0 the pool is associated with (where token1 is a fluid token) |
fee | uint32 | the fee being used for this pool |
decimals | uint8 | the decimals for the token |
tickSpacing | uint8 | the 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
Name | Type | Description |
---|---|---|
pool | address | the pool for which protocol fees are being collected |
to | address | the account the fees are being sent to |
amount0 | uint128 | the amount of token0 being collected |
amount1 | uint128 | the 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
Name | Type | Description |
---|---|---|
user | address | the user performing the swap |
from | address | the input token |
to | address | the output token |
amountIn | uint256 | the amount of from the user is paying |
amountOut | uint256 | the amount of to the user is receiving |
fluidVolume | uint256 | the volume of the internal transfer |
finalTick0 | int32 | the tick that the first token's pool ended on |
finalTick1 | int32 | the 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
Name | Type | Description |
---|---|---|
user | address | the user performing the swap |
pool | address | the token being swapped for the fluid token |
zeroForOne | bool | true if the user is swapping token->fluid, false otherwise |
amount0 | uint256 | the amount of the nonfluid token being transferred |
amount1 | uint256 | the amount of the fluid token being transferred |
finalTick | int32 | the tick the pool ended on |
NewFees
new fees were set!
event NewFees(address indexed pool, uint8 indexed feeProtocol);
Parameters
Name | Type | Description |
---|---|---|
pool | address | that the fees are set for. |
feeProtocol | uint8 | that's taken by the protocol |
ISeawaterExecutorSwapA
Functions
swap904369BE
swaps within a pool
function swap904369BE(address pool, bool zeroForOne, int256 amount, uint256 priceLimit)
external
returns (int256, int256);
Parameters
Name | Type | Description |
---|---|---|
pool | address | the pool to swap on |
zeroForOne | bool | true if swapping token->fluid token |
amount | int256 | the amount of token to swap, positive if exactIn, negative if exactOut |
priceLimit | uint256 | the price limit for swaps, encoded as a sqrtX96 price |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | (token0, token1) delta |
<none> | int256 |
ISeawaterExecutorSwapPermit2A
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
Name | Type | Description |
---|---|---|
pool | address | the pool to swap on |
zeroForOne | bool | true if swapping token->fluid token |
amount | int256 | the amount of token to swap, positive if exactIn, negative if exactOut |
priceLimit | uint256 | the price limit for swaps, encoded as a sqrtX96 price |
nonce | uint256 | the permit2 nonce |
deadline | uint256 | the permit2 deadline |
maxAmount | uint256 | the permit2 maxAmount |
sig | bytes | the permit2 signature |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | (token0, token1) delta |
<none> | int256 |
ISeawaterExecutorSwapPermit2B
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
Name | Type | Description |
---|---|---|
from | address | the input token |
to | address | the output token |
amount | uint256 | the amount of the input token to use |
minOut | uint256 | the minimum valid amount of the output token, reverts if not reached |
nonce | uint256 | the permit2 nonce |
deadline | uint256 | the permit2 deadline |
sig | bytes | the permit2 signature |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | (amount in, amount out) |
<none> | uint256 |
ISeawaterExecutorQuoteA
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
Name | Type | Description |
---|---|---|
pool | address | the pool to swap on |
zeroForOne | bool | true if swapping token->fluid token |
amount | int256 | the amount of token to swap, positive if exactIn, negative if exactOut |
priceLimit | uint256 | the price limit for swaps, encoded as a sqrtX96 price |
ISeawaterExecutorQuoteB
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
Name | Type | Description |
---|---|---|
from | address | the input token |
to | address | the output token |
amount | uint256 | the amount of the input token to use |
minOut | uint256 | the minimum valid amount of the output token, reverts if not reached |
ISeawaterExecutorPosition
Functions
mintPositionBC5B086D
creates a new position
function mintPositionBC5B086D(address pool, int32 lower, int32 upper) external returns (uint256 id);
Parameters
Name | Type | Description |
---|---|---|
pool | address | the pool to create the position on |
lower | int32 | the lower tick of the position (for concentrated liquidity) |
upper | int32 | the 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
Name | Type | Description |
---|---|---|
id | uint256 | the id of the position to transfer |
from | address | the user to transfer the position from |
to | address | the user to transfer the position to |
positionOwnerD7878480
gets the owner of a position
function positionOwnerD7878480(uint256 id) external returns (address);
Parameters
Name | Type | Description |
---|---|---|
id | uint256 | the id of the position |
Returns
Name | Type | Description |
---|---|---|
<none> | address | the owner of the position |
positionBalance4F32C7DB
gets the number of positions owned by a user
function positionBalance4F32C7DB(address user) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
user | address | the user to get position balance for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the 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
Name | Type | Description |
---|---|---|
pool | address | the position belongs to |
id | uint256 | the id of the position |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the 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
Name | Type | Description |
---|---|---|
pool | address | the position belongs to |
id | uint256 | of the position |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the 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
Name | Type | Description |
---|---|---|
pool | address | the position belongs to |
id | uint256 | of the position |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the 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
Name | Type | Description |
---|---|---|
pool | address | the position belongs to |
id | uint256 | of the position to use |
recipient | address | of the money that's earned |
Returns
Name | Type | Description |
---|---|---|
amount0 | uint128 | and amount1 |
amount1 | uint128 |
collect7F21947C
collects fees from from positions
function collect7F21947C(address[] memory pools, uint256[] memory ids) external returns (CollectResult[] memory);
Parameters
Name | Type | Description |
---|---|---|
pools | address[] | to claim accumulated yield from |
ids | uint256[] | to claim the positions of |
Structs
CollectResult
struct CollectResult {
uint128 amount0;
uint128 amount1;
}
ISeawaterExecutorUpdatePosition
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
Name | Type | Description |
---|---|---|
pool | address | to use this with |
id | uint256 | the id of the position |
delta | int128 | the amount of liquidity to add or remove |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | the deltas for token0 and token1 for the user |
<none> | int256 |
ISeawaterExecutorAdminExposed
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
Name | Type | Description |
---|---|---|
pool | address | the token to create the pool with |
sqrtPriceX96 | uint256 | the starting price for the pool |
fee | uint32 | the 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
Name | Type | Description |
---|---|---|
pool | address | the pool to collect fees for |
amount0 | uint128 | the maximum amount of token0 fees to collect |
amount1 | uint128 | the maximum amount of token1 fees to collect |
recipient | address | of the funds that're earned |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the 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
Name | Type | Description |
---|---|---|
pool | address | to get the fees owed for |
id | uint256 | of the position to check for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the 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
Name | Type | Description |
---|---|---|
pool | address | to get from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the current sqrtPriceX96 for the pool |
curTick181C6FD9
gets the currently used tick of the pool
function curTick181C6FD9(address pool) external returns (int32);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to get from |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the current active tick in the pool |
tickSpacing653FE28F
gets the tick spacing of the pool
function tickSpacing653FE28F(address pool) external returns (uint8);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to get from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint8 | the tick spacing of the pool |
feeBB3CF608
gets the fee for a specific pool
function feeBB3CF608(address pool) external returns (uint32);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to get the fee for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint32 | the fee for the pool |
feeGrowthGlobal038B5665B
gets the fee growth for token 0
function feeGrowthGlobal038B5665B(address pool) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to get from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the fee growth for the other token |
feeGrowthGlobal1A33A5A1B
gets the fee growth for token 1
function feeGrowthGlobal1A33A5A1B(address pool) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to get from |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the fee growth for fUSDC |
enablePool579DA658
enables or disables a pool
function enablePool579DA658(address pool, bool enabled) external;
Parameters
Name | Type | Description |
---|---|---|
pool | address | the pool to enable or disable |
enabled | bool | true 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
Name | Type | Description |
---|---|---|
enabler | address | |
enabled | bool | to set their status |
setSqrtPriceFF4DB98C
set the sqrt price for a pool in the event of misconfiguration.
function setSqrtPriceFF4DB98C(address pool, uint256 price) external;
Parameters
Name | Type | Description |
---|---|---|
pool | address | to set |
price | uint256 | to 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
Name | Type | Description |
---|---|---|
manager | address | address to set to in its new form |
updateSeawaterAdminD25D364D
set the new admin.
function updateSeawaterAdminD25D364D(address operator) external;
Parameters
Name | Type | Description |
---|---|---|
operator | address | to replace the existing operator with |
updateEmergencyCouncil7D0C1C58
updateEmergencyCouncil to a new address.
function updateEmergencyCouncil7D0C1C58(address newCouncil) external;
Parameters
Name | Type | Description |
---|---|---|
newCouncil | address | to set the emergency council to |
ISeawaterExecutorSwapB
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
Name | Type | Description |
---|---|---|
from | address | the input token |
to | address | the output token |
amount | uint256 | the amount of the input token to use |
minOut | uint256 | the minimum valid amount of the output token, reverts if not reached |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | (amount in, amount out) |
<none> | uint256 |
ISeawaterExecutorAdmin
Inherits: ISeawaterExecutorAdminExposed
Functions
ctor
constructor function
function ctor(address seawaterAdmin, address nftManager, address emergencyCouncil) external;
Parameters
Name | Type | Description |
---|---|---|
seawaterAdmin | address | the account with administrative power on the amm |
nftManager | address | the account with control over NFT ownership |
emergencyCouncil | address | to use to control for pool disabling interactions |
ISeawaterExecutorAdjustPositionA
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
Name | Type | Description |
---|---|---|
pool | address | of the token to use |
id | uint256 | the id of the position |
amount0Min | uint256 | minimum of amount0 to take from the user |
amount1Min | uint256 | minimum of amount1 to take from the user |
amount0Desired | uint256 | to take from the user. May exceed. |
amount1Desired | uint256 | to take from the user. May exceed. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the deltas for token0, and token1 |
<none> | uint256 |
ISeawaterExecutorAdjustPositionB
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
Name | Type | Description |
---|---|---|
pool | address | of the token to use |
id | uint256 | the id of the position |
amount0Min | uint256 | minimum of amount0 to take from the user |
amount1Min | uint256 | minimum of amount1 to take from the user |
amount0Desired | uint256 | to give to the user. May go lower. |
amount1Desired | uint256 | to give to the user. May go lower. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the deltas for token0, and token1 |
<none> | uint256 |
ISeawaterExecutorFallback
ISeawaterMigrations
StorageSlot
Functions
getAddressSlot
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r);
Structs
AddressSlot
struct AddressSlot {
address value;
}
LeoCtor
Functions
ctor
function ctor(address) external;
LeoProxy
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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | bytes8 |
poolLp
pool LP tokens vested to Leo for this pool
function poolLp(address) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | lp 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
Name | Type | Description |
---|---|---|
<none> | PositionDetails[] | |
<none> | bytes8[] | |
<none> | address |
vestPosition
vest a position that the caller owns.
function vestPosition(address, uint256, address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | address |
divestPosition
divest a position, returning the position ID to the user
function divestPosition(uint256, address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | uint256 | |
<none> | address |
Events
AdminChanged
event AdminChanged(address indexed oldAdmin, address indexed newAdmin);
Upgraded
event Upgraded(address indexed extras, address indexed collect);
Constants
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
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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The 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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The 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
Name | Type | Description |
---|---|---|
_sender | address | that did the transfer |
_from | address | owner of the NFT that the sender is transferring |
_to | address | recipient of the NFT that we're calling the function on |
_tokenId | uint256 | that 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The 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
Name | Type | Description |
---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True 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
Name | Type | Description |
---|---|---|
_spender | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
_interfaceId | bytes4 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IEIP712
Functions
DOMAIN_SEPARATOR
function DOMAIN_SEPARATOR() external view returns (bytes32);
ISignatureTransfer
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
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
witness | bytes32 | Extra data to include when checking the user signature |
witnessTypeString | string | The EIP-712 type definition for remaining string stub of the typehash |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitBatchTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails[] | Specifies the recipient and requested amount for the token transfer |
owner | address | The owner of the tokens to transfer |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitBatchTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails[] | Specifies the recipient and requested amount for the token transfer |
owner | address | The owner of the tokens to transfer |
witness | bytes32 | Extra data to include when checking the user signature |
witnessTypeString | string | The EIP-712 type definition for remaining string stub of the typehash |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
wordPos | uint256 | A number to index the nonceBitmap at |
mask | uint256 | A 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
Name | Type | Description |
---|---|---|
maxAmount | uint256 | The 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
Shared errors between signature based transfers and allowance based transfers.
Thrown when validating an inputted signature that is stale
error SignatureExpired(uint256 signatureDeadline);
Parameters
Name | Type | Description |
---|---|---|
signatureDeadline | uint256 | The timestamp at which a signature is no longer valid |
InvalidNonce
Thrown when validating that the inputted nonce has not been used
error InvalidNonce();
ERC20
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
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
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
Name | Type | Description |
---|---|---|
hash | bytes32 | Hash of the data to be signed |
signature | bytes | Signature byte array associated with _data |
Returns
Name | Type | Description |
---|---|---|
magicValue | bytes4 | The bytes4 magic value 0x1626ba7e |
SignatureVerification
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
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
Name | Type | Description |
---|---|---|
token | address | The token to approve |
spender | address | The spender address to approve |
amount | uint160 | The approved amount of the token |
expiration | uint48 | The 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
Name | Type | Description |
---|---|---|
owner | address | The owner of the tokens being approved |
permitSingle | PermitSingle | Data signed over by the owner specifying the terms of approval |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
owner | address | The owner of the tokens being approved |
permitBatch | PermitBatch | Data signed over by the owner specifying the terms of approval |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
from | address | The address to transfer from |
to | address | The address of the recipient |
amount | uint160 | The amount of the token to transfer |
token | address | The 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
Name | Type | Description |
---|---|---|
transferDetails | AllowanceTransferDetails[] | 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
Name | Type | Description |
---|---|---|
approvals | TokenSpenderPair[] | 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
Name | Type | Description |
---|---|---|
token | address | The token to invalidate nonces for |
spender | address | The spender to invalidate nonces for |
newNonce | uint48 | The 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
Name | Type | Description |
---|---|---|
deadline | uint256 | The 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
Name | Type | Description |
---|---|---|
amount | uint256 | The 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
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
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
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
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
witness | bytes32 | Extra data to include when checking the user signature |
witnessTypeString | string | The EIP-712 type definition for remaining string stub of the typehash |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
dataHash | bytes32 | The EIP-712 hash of permit data to include when checking signature |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitBatchTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails[] | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitBatchTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails[] | The spender's requested transfer details for the permitted token |
owner | address | The owner of the tokens to transfer |
witness | bytes32 | Extra data to include when checking the user signature |
witnessTypeString | string | The EIP-712 type definition for remaining string stub of the typehash |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
permit | PermitBatchTransferFrom | The permit data signed over by the owner |
transferDetails | SignatureTransferDetails[] | |
owner | address | The owner of the tokens to transfer |
dataHash | bytes32 | The EIP-712 hash of permit data to include when checking signature |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
wordPos | uint256 | A number to index the nonceBitmap at |
mask | uint256 | A 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
Name | Type | Description |
---|---|---|
nonce | uint256 | The nonce to get the associated word and bit positions |
Returns
Name | Type | Description |
---|---|---|
wordPos | uint256 | The word position or index into the nonceBitmap |
bitPos | uint256 | The 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
Name | Type | Description |
---|---|---|
from | address | The address to use the nonce at |
nonce | uint256 | The nonce to spend |
Allowance
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
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
Name | Type | Description |
---|---|---|
token | address | The token to approve |
spender | address | The spender address to approve |
amount | uint160 | The approved amount of the token |
expiration | uint48 | The 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
Name | Type | Description |
---|---|---|
owner | address | The owner of the tokens being approved |
permitSingle | PermitSingle | Data signed over by the owner specifying the terms of approval |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
owner | address | The owner of the tokens being approved |
permitBatch | PermitBatch | |
signature | bytes | The 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
Name | Type | Description |
---|---|---|
from | address | The address to transfer from |
to | address | The address of the recipient |
amount | uint160 | The amount of the token to transfer |
token | address | The 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
Name | Type | Description |
---|---|---|
transferDetails | AllowanceTransferDetails[] |
_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
Name | Type | Description |
---|---|---|
approvals | TokenSpenderPair[] | 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
Name | Type | Description |
---|---|---|
token | address | The token to invalidate nonces for |
spender | address | The spender to invalidate nonces for |
newNonce | uint48 | The 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
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
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
Functions
getAddressSlot
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r);
Structs
AddressSlot
struct AddressSlot {
address value;
}
SeawaterAMM
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
Name | Type | Description |
---|---|---|
_proxyAdmin | address | the admin that can control proxy functions (change addresses) |
_seawaterAdmin | address | the admin of the AMM |
_nftManager | address | the account that can transfer position NFTs |
_emergencyCouncil | address | |
_executorSwapA | ISeawaterExecutorSwapA | the deployed code for the swap executor (swap 1) |
_executorSwapPermit2A | ISeawaterExecutorSwapPermit2A | the deployed code for the swap_permit2 executor (facet A) |
_executorQuoteA | ISeawaterExecutorQuoteA | the deployed code for the quote A executor |
_executorPosition | ISeawaterExecutorPosition | the deployed code for the positions executor |
_executorUpdatePosition | ISeawaterExecutorUpdatePosition | |
_executorAdmin | ISeawaterExecutorAdmin | the deployed code for the admin executor |
_executorAdjustPositionsA | ISeawaterExecutorAdjustPositionA | the deployed code for the adjust positions executor (facet A) |
_executorSwapPermit2B | ISeawaterExecutorSwapPermit2B | the deployed code for the swap_permit2 executor (facet B) |
_executorAdjustPositionsB | ISeawaterExecutorAdjustPositionB | the deployed code for the adjust positions executor (facet B) |
_executorSwapB | ISeawaterExecutorSwapB | the deployed code for the swap executor (swap 2) |
_executorQuoteB | ISeawaterExecutorQuoteB | the deployed code for the quote B executor (quote 2) |
_executorFallback | ISeawaterExecutorFallback | an 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
Name | Type | Description |
---|---|---|
newAdmin | address | the 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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint128 | |
<none> | uint128 | |
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the amount of token0 and token1 fees collected |
<none> | uint128 |
enablePool579DA658
enables or disables a pool
function enablePool579DA658(address, bool) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | bool |
authoriseEnabler5B17C274
authorise an address to create and enable pools on its own
function authoriseEnabler5B17C274(address, bool) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | bool |
setSqrtPriceFF4DB98C
set the sqrt price for a pool in the event of misconfiguration.
function setSqrtPriceFF4DB98C(address, uint256) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 |
setFeeProtocolCBD3EC35
function setFeeProtocolCBD3EC35(address, uint8, uint8) external;
updateNftManager9BDF41F6
set the NFT manager.
function updateNftManager9BDF41F6(address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
updateSeawaterAdminD25D364D
set the new admin.
function updateSeawaterAdminD25D364D(address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
updateEmergencyCouncil7D0C1C58
updateEmergencyCouncil to a new address.
function updateEmergencyCouncil7D0C1C58(address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
swap904369BE
swaps within a pool
function swap904369BE(address, bool, int256, uint256) external returns (int256, int256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | bool | |
<none> | int256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | bool | |
<none> | int256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | bytes |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | address | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | bytes |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | address | |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
token | address | |
amountIn | uint256 | |
minOut | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount 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
Name | Type | Description |
---|---|---|
token | address | |
amountIn | uint256 | |
minOut | uint256 | |
nonce | uint256 | |
deadline | uint256 | |
maxAmount | uint256 | |
sig | bytes |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount of usdc out |
<none> | int256 |
swapOut5E08A399
swaps USDC for _token
function swapOut5E08A399(address token, uint256 amountIn, uint256 minOut) external returns (int256, int256);
Parameters
Name | Type | Description |
---|---|---|
token | address | |
amountIn | uint256 | |
minOut | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount 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
Name | Type | Description |
---|---|---|
token | address | |
amountIn | uint256 | |
minOut | uint256 | |
nonce | uint256 | |
deadline | uint256 | |
maxAmount | uint256 | |
sig | bytes |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | amount of token out |
<none> | int256 |
mintPositionBC5B086D
creates a new position
function mintPositionBC5B086D(address, int32, int32) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | int32 | |
<none> | int32 |
positionOwnerD7878480
gets the owner of a position
function positionOwnerD7878480(uint256) external returns (address);
Parameters
Name | Type | Description |
---|---|---|
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | address | the owner of the position |
transferPositionEEC7A3CD
transferPosition transfers a position. usable only by the NFT manager
function transferPositionEEC7A3CD(uint256, address, address) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | uint256 | |
<none> | address | |
<none> | address |
positionBalance4F32C7DB
gets the number of positions owned by a user
function positionBalance4F32C7DB(address) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the number of positions owned by the user |
positionLiquidity8D11C045
gets the amount of liquidity in a position
function positionLiquidity8D11C045(address, uint256) external returns (uint128);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the amount of liquidity contained in the position |
positionTickLower2F77CCE1
get the lower tick of the position id
function positionTickLower2F77CCE1(address, uint256) external returns (int32);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the lower tick of the position given |
positionTickUpper67FD55BA
get the upper tick of the position id
function positionTickUpper67FD55BA(address, uint256) external returns (int32);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the lower tick of the position given |
sqrtPriceX967B8F5FC5
gets the current sqrt price of the pool
function sqrtPriceX967B8F5FC5(address) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the current sqrtPriceX96 for the pool |
feesOwed22F28DBD
feesOwed to a position ID given.
function feesOwed22F28DBD(address, uint256) external returns (uint128, uint128);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | the 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
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | int32 | the current active tick in the pool |
tickSpacing653FE28F
gets the tick spacing of the pool
function tickSpacing653FE28F(address) external returns (uint8);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint8 | the tick spacing of the pool |
feeBB3CF608
gets the fee for a specific pool
function feeBB3CF608(address) external returns (uint32);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint32 | the fee for the pool |
feeGrowthGlobal038B5665B
gets the fee growth for token 0
function feeGrowthGlobal038B5665B(address) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the fee growth for the other token |
feeGrowthGlobal1A33A5A1B
gets the fee growth for token 1
function feeGrowthGlobal1A33A5A1B(address) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the fee growth for fUSDC |
collectSingleTo6D76575F
collect a single position's yield
function collectSingleTo6D76575F(address, uint256, address) external returns (uint128, uint128);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint128 | amount0 and amount1 |
<none> | uint128 |
collect7F21947C
collects fees from from positions
function collect7F21947C(address[] memory pools, uint256[] memory ids)
external
returns (CollectResult[] memory results);
Parameters
Name | Type | Description |
---|---|---|
pools | address[] | to claim accumulated yield from |
ids | uint256[] | 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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | int128 |
Returns
Name | Type | Description |
---|---|---|
<none> | int256 | the 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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the 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
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 | |
<none> | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the 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
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;