Superposition contracts
Security
Contributors
Longtail
Longtail is Arbitrum's cheapest and most rewarding AMM.
Deployments
Superposition Testnet
AMM contract deployments
Deployment name | Deployment address |
---|---|
Longtail AMM | 0x3d37c3f4a7c773243f9FC31a891911D39d5A75fE |
Longtail NFT manager | 0x7AD12Ef3578D5eb845883d156D8dFB2eA39448B5 |
Permit2 router | 0x2246431582087b930F2CE561c34deb8E7e5c44bE |
Swaps implementation | 0xf45d0f868e93d68c6698c88b2c0a06feb0f5effc |
Swaps permit2 implementation | 0x486ee4cb319b19652c97bf4bf81046a5fbd62bf4 |
Quotes implementation | 0xa75a2c5e441c3b97d49ceb2d3b1fb4c4ec5f8284 |
Positions implementation | 0xd82a006d4af64db35ea83963e815cd8f1ba41fdc |
Update position implementation | 0xbf20f2a6f01fc23b4dc45eacb584e85a04d62130 |
Admin implementation | 0x092fbb759ab57261e2ad6d283a25ee3c235620e8 |
Leo contract deployments
Deployment name | Deployment address |
---|---|
Implementation | 0xe2c9281ec0a52d2fafeb26b2c3555e09e48614a1 |
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. |
Leo
Leo (also known as the Seawater Rewards Manager) is a contract that allows users to vest their LP tokens in the form of a transferFrom using the NFTManager contract. Leo remembers who owns the LP NFTs it has, and does things like collect fees on the behalf of the owner, and knows to do so when determining "real yield" mixed with fees earned for LPing.
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) external;
Parameters
Name | Type | Description |
---|---|---|
pool | address | to take the position from |
id | uint256 | of the position to take |
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 |
updateCampaign
create a campaign with the parameters given.
takes extraMax from the user of the token given
function updateCampaign(
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 |
campaignRevisions
the amount of times this campaign was modified for the pool
function campaignRevisions(address pool, bytes8 campaignId) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
pool | address | to check the campaign for |
campaignId | bytes8 | to check revisions for |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the amount of times the campaign was modified |
cancelCampaign
cancel an ongoing campaign by amending it to have 0
only usable by the admin of the pool
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(address pool, bytes8 campaignId)
external
view
returns (
int32 tickLower,
int32 tickUpper,
uint64 perSecond,
address token,
uint256 distributed,
uint256 maximum,
uint64 startingTimestamp,
uint64 endingTimestamp
);
Parameters
Name | Type | Description |
---|---|---|
pool | address | this campaign is for |
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)
external
returns (PoolRewards[] memory poolRewards, CampaignRewards[] memory campaignRewards);
Parameters
Name | Type | Description |
---|---|---|
positionDetails | PositionDetails[] | to check |
campaignIds | bytes8[] | to check |
divestPosition
divest a position, returning the position ID to the user
function divestPosition(address pool, uint256 positionId) external;
Parameters
Name | Type | Description |
---|---|---|
pool | address | to check |
positionId | uint256 | to check |
Structs
PositionDetails
struct PositionDetails {
address token;
uint256 id;
}
PoolRewards
struct PoolRewards {
address pool;
uint128 amount0Lp;
uint128 amount1Lp;
}
CampaignRewards
struct CampaignRewards {
address campaignToken;
uint256 rewards;
}
ILeoEvents
Events
CampaignBalanceUpdated
a campaign's balance was updated to reflect a new amount to give out max
event CampaignBalanceUpdated(bytes8 indexed identifier, uint256 indexed newMaximum);
Parameters
Name | Type | Description |
---|---|---|
identifier | bytes8 | that was computed to represent this campaign |
newMaximum | uint256 | from the previous to give out |
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 |
PositionVested
a specific position was vested
event PositionVested(uint256 indexed positionId);
Parameters
Name | Type | Description |
---|---|---|
positionId | uint256 | that was just vested |
PositionDivested
a specific position was just divested from Leo
event PositionDivested(uint256 indexed positionId);
Parameters
Name | Type | Description |
---|---|---|
positionId | uint256 | that was divested |
ISeawater
Inherits: ISeawaterAMM
ISeawaterAMM
Inherits: ISeawaterEvents, ISeawaterExecutorSwap, ISeawaterExecutorSwapPermit2, ISeawaterExecutorQuote, ISeawaterExecutorPosition, ISeawaterExecutorUpdatePosition, ISeawaterExecutorAdminExposed
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 |
swap2ExactIn41203F1D
swaps tokenA for tokenB
function swap2ExactIn41203F1D(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 |
ISeawaterExecutorSwap
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 |
swap2ExactIn41203F1D
performs a two stage swap across two pools
function swap2ExactIn41203F1D(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 |
ISeawaterExecutorSwapPermit2
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 |
swap2ExactInPermit236B2FDD8
performs a two stage swap across two pools using permit2 for token transfers
permit2's max amount must be set to amount
function swap2ExactInPermit236B2FDD8(
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 |
ISeawaterExecutorQuote
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 |
quote2CD06B86E
reverts with the expected amount of tokenOut for a 2-token swap with the given parameters
always revert with Error(string(amountOut))
function quote2CD06B86E(address from, address to, uint256 amount, uint256 minOut) external;
Parameters
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 |
incrPosD3521721
refreshes a position's fees, and adds liquidity, preventing less than the minimum from being taken.
function incrPosD3521721(
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 |
decrPosition09293696
refreshes a position's fees, and takes liquidity, preventing less than the minimum from being taken.
function decrPosition09293696(
address pool,
uint256 id,
uint256 amount0Min,
uint256 amount1Min,
uint256 amount0Max,
uint256 amount1Max
) external returns (uint256, uint256);
Parameters
Name | Type | Description |
---|---|---|
pool | address | |
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 |
amount0Max | uint256 | to use as the maximum of amount0, used to create the delta |
amount1Max | uint256 | to use as the maximum of amount1, used to create the delta |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | the deltas for token0, and token1 |
<none> | uint256 |
ISeawaterExecutorAdminExposed
contains just the admin functions that are exposed directly
Functions
createPoolD650E2D0
initialises a new pool. only usable by the seawater admin
function createPoolD650E2D0(
address pool,
uint256 sqrtPriceX96,
uint32 fee,
uint8 tickSpacing,
uint128 maxLiquidityPerTick
) 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 |
tickSpacing | uint8 | the spacing for valid liquidity ticks |
maxLiquidityPerTick | uint128 | the maximum amount of liquidity allowed in a single tick |
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 |
updateNftManager9BDF41F6
set the NFT manager.
function updateNftManager9BDF41F6(address manager) external;
Parameters
Name | Type | Description |
---|---|---|
manager | address | address to set to in its new form |
updateEmergencyCouncil7D0C1C58
updateEmergencyCouncil to a new address.
function updateEmergencyCouncil7D0C1C58(address newCouncil) external;
Parameters
Name | Type | Description |
---|---|---|
newCouncil | address | to set the emergency council to |
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 |
ISeawaterExecutorFallback
ISeawaterMigrations
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 |
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,
ISeawaterExecutorSwap _executorSwap,
ISeawaterExecutorSwapPermit2 _executorSwapPermit2,
ISeawaterExecutorQuote _executorQuote,
ISeawaterExecutorPosition _executorPosition,
ISeawaterExecutorUpdatePosition _executorUpdatePosition,
ISeawaterExecutorAdmin _executorAdmin,
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 | |
_executorSwap | ISeawaterExecutorSwap | the deployed code for the swap executor |
_executorSwapPermit2 | ISeawaterExecutorSwapPermit2 | the deployed code for the swap_permit2 executor |
_executorQuote | ISeawaterExecutorQuote | the deployed code for the quote executor |
_executorPosition | ISeawaterExecutorPosition | the deployed code for the positions executor |
_executorUpdatePosition | ISeawaterExecutorUpdatePosition | |
_executorAdmin | ISeawaterExecutorAdmin | the deployed code for the admin executor |
_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 |
updateExecutors
updates the addresses of the executors. only usable by the proxy admin
function updateExecutors(
ISeawaterExecutorSwap executorSwap,
ISeawaterExecutorSwapPermit2 executorSwapPermit2,
ISeawaterExecutorQuote executorQuote,
ISeawaterExecutorPosition executorPosition,
ISeawaterExecutorUpdatePosition executorUpdatePosition,
ISeawaterExecutorAdmin executorAdmin,
ISeawaterExecutorFallback executorFallback
) public onlyProxyAdmin;
Parameters
Name | Type | Description |
---|---|---|
executorSwap | ISeawaterExecutorSwap | the address of the swap executor |
executorSwapPermit2 | ISeawaterExecutorSwapPermit2 | the deployed code for the swap_permit2 executor |
executorQuote | ISeawaterExecutorQuote | the deployed code for the quote executor |
executorPosition | ISeawaterExecutorPosition | the address of the position executor |
executorUpdatePosition | ISeawaterExecutorUpdatePosition | |
executorAdmin | ISeawaterExecutorAdmin | the address of the admin executor |
executorFallback | ISeawaterExecutorFallback | the address of the fallback executor |
directDelegate
function directDelegate(address to) internal;
createPoolD650E2D0
initialises a new pool. only usable by the seawater admin
function createPoolD650E2D0(address, uint256, uint32, uint8, uint128) external;
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
<none> | uint256 | |
<none> | uint32 | |
<none> | uint8 | |
<none> | uint128 |
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 |
updateNftManager9BDF41F6
set the NFT manager.
function updateNftManager9BDF41F6(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 |
quote2CD06B86E
reverts with the expected amount of tokenOut for a 2-token swap with the given parameters
function quote2CD06B86E(address, address, uint256, uint256) external;
Parameters
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 |
swap2ExactIn41203F1D
performs a two stage swap across two pools
function swap2ExactIn41203F1D(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 |
swap2ExactInPermit236B2FDD8
performs a two stage swap across two pools using permit2 for token transfers
function swap2ExactInPermit236B2FDD8(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 |
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, uint256[] memory) external returns (CollectResult[] memory);
Parameters
Name | Type | Description |
---|---|---|
<none> | address[] | |
<none> | uint256[] |
updatePositionC7F1F740
refreshes a position's fees, and adds or removes liquidity
function updatePositionC7F1F740(address, uint256, int128) external returns (int256, int256);
Parameters
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 |
incrPosD3521721
refreshes a position's fees, and adds liquidity, preventing less than the minimum from being taken.
function incrPosD3521721(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 |
decrPosition09293696
refreshes a position's fees, and takes liquidity, preventing less than the minimum from being taken.
function decrPosition09293696(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 |
fallback
fallback() external;
_getExecutorSwap
function _getExecutorSwap() internal view returns (address);
_getExecutorSwapPermit2
function _getExecutorSwapPermit2() internal view returns (address);
_getExecutorQuote
function _getExecutorQuote() internal view returns (address);
_getExecutorPosition
function _getExecutorPosition() internal view returns (address);
_getExecutorUpdatePosition
function _getExecutorUpdatePosition() internal view returns (address);
_getExecutorAdmin
function _getExecutorAdmin() internal view returns (address);
_getExecutorFallback
function _getExecutorFallback() internal view returns (address);
_setProxyAdmin
function _setProxyAdmin(address newAdmin) internal;
_setProxies
function _setProxies(
ISeawaterExecutorSwap executorSwap,
ISeawaterExecutorSwapPermit2 executorSwapPermit2,
ISeawaterExecutorQuote executorQuote,
ISeawaterExecutorPosition executorPosition,
ISeawaterExecutorUpdatePosition executorUpdatePosition,
ISeawaterExecutorAdmin executorAdmin,
ISeawaterExecutorFallback executorFallback
) internal;
Constants
EXECUTOR_SWAP_SLOT
0xb27456616f8c77c635d3551b8179f6887795e920c5c4421a6fa3c3c76fc90fa8
bytes32 constant EXECUTOR_SWAP_SLOT = bytes32(uint256(keccak256("seawater.impl.swap")) - 1);
EXECUTOR_SWAP_PERMIT2_SLOT
0x70879b7e5737e63f52eca3402c644a487e49ffeb7d78b75e54b18301a4f376ac
bytes32 constant EXECUTOR_SWAP_PERMIT2_SLOT = bytes32(uint256(keccak256("seawater.impl.swap_permit2")) - 1);
EXECUTOR_QUOTE_SLOT
0x031aae58aa658a4a607141f8a509c1b56789f013acaf58a8e12eb86456e099e4
bytes32 constant EXECUTOR_QUOTE_SLOT = bytes32(uint256(keccak256("seawater.impl.quote")) - 1);
EXECUTOR_POSITION_SLOT
0x75711a1f12071de4ad9b405fd0234f84fcd9d494050d3a5169de3ad4fd942476
bytes32 constant EXECUTOR_POSITION_SLOT = bytes32(uint256(keccak256("seawater.impl.position")) - 1);
EXECUTOR_UPDATE_POSITION_SLOT
0x81e9c7c70971b5eb969cec21a82e6deed42e7c6736e0e83ced66d72297d9f1d7
bytes32 constant EXECUTOR_UPDATE_POSITION_SLOT = bytes32(uint256(keccak256("seawater.impl.update_position")) - 1);
EXECUTOR_ADMIN_SLOT
0x344c13190645d452a52856ca1efc42b3609893d92b93219c8820b76f3aa11288
bytes32 constant EXECUTOR_ADMIN_SLOT = bytes32(uint256(keccak256("seawater.impl.admin")) - 1);
EXECUTOR_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);