The Kodiak Island contracts provide a framework for creating and managing concentrated liquidity positions on Kodiak V3. They enable users to deposit tokens into a managed Kodiak V3 position, receiving shares in return. They allow managers to rebalance the position, collect fees, and adjust the position and management parameters. The contracts support minting, burning, rebalancing, and integration with external routers for complex strategies.
Adding/Removing Liquidity
These functions are used to mint/burn island shares resulting in adding/removing liquidity from the island's underlying v3 pool position. It is highly recommended to use the Island Router to add/remove liquidity as it handles slippage settings.
Mints new Island tokens by providing liquidity to the underlying Kodiak V3 position.
mintAmount: Number of Island tokens to mint
receiver: Address to receive the minted tokens
Returns amounts of token0/token1 used and liquidity added
Removing Liquidity
Burns Island tokens to withdraw underlying assets.
burnAmount: Number of Island tokens to burn
receiver: Address to receive the underlying tokens
Returns amounts of token0/token1 received and liquidity removed
Compounding collected fee
Collects the fee earned by the island's position and reinvests as much of token0 and token1 into the position as possible after deducting the manager fee from the collected fee.
View Functions
Get Underlying Balances
Returns:
amount0Current: The total amounts of underlying tokens represented by the entire Island supply. This includes deployed liqudity (uni v3 pool tokens), any unclaimed earned fee, and any undeployed tokens
amount1Current: The total amounts of underlying tokens represented by the entire Island supply. This includes deployed liqudity (uni v3 pool tokens), any unclaimed earned fee, and any undeployed tokens resulting from fee imbalance
Get Mint Amounts
This function allows you to find the optimal deposit amounts for token0 and token1 in correct ratio to deposit maximally into the underlying island position Arguments:
amount0Max: Max amount of token0 the user is willing to deposit
amount1Max: Max amount of token1 the user is willing to deposit Returns:
amount0: The amount of token0 used from the max
amount1: The amount of token1 used from the max
mintAmount: The number of island tokens minted using amount0 and amount1
Get Underlying Balances At Price
This function calculates the underlying token balances at a specific price point Arguments:
sqrtRatioX96: The sqrt price to calculate balances at, in Q96 format Returns:
amount0Current: Amount of token0 at the specified price
amount1Current: Amount of token1 at the specified price
Get Position ID
Returns the unique identifier for the current Kodiak V3 position Returns:
positionID: Keccak256 hash of packed (island address, lowerTick, upperTick)
Get Token0
Returns the address of token0
Get Token1
Returns the address of token1
Get Upper Tick
Returns the upper tick of the island's position
Get Lower Tick
Returns the lower tick of the island's position
Get Pool
Returns the address of the Kodiak V3 pool
Get Total Supply
Returns the total supply of the island tokens
Get Balance Of
Returns the balance of the specified account
Get Manager Fee BPS
Returns the manager fee in basis points
Get Manager Treasury
Returns the manager treasury address
Get Manager Balance 0
Returns the manager balance of token0
Get Manager Balance 1
Returns the manager balance of token1
Get Manager
Returns the current manager address. Should be address(0) for unmanaged islands
Island Management
This is applicable only for managed islands. Permissionless islands only expose the functionality to compound the fee collected.
Admin roles involved
manager - can alter island position bounds to manage liquidity optimally
pauser - can pause operations in case of a security breach
Island Configuration Parameters
Manager Parameters
manager: The address authorized to perform management operations like rebalancing
managerTreasury: Address where manager fees are sent
managerFeeBPS: Percentage of earned fees that go to the manager (in basis points, max 10000)
restrictedMint: When true, only the manager can mint new Island tokens
compounderSlippageBPS: Maximum allowed slippage for rebalance operations (in basis points)
compounderSlippageInterval: Time window for TWAP price calculation using kodiak pool observations (in seconds)
Island Position Parameters
lowerTick: Lower price bound of the Kodiak V3 position
upperTick: Upper price bound of the Kodiak V3 position
pool: The underlying Kodiak V3 pool address
token0: First token in the uni pool pair
token1: Second token in the uni pool pair
Manager Fee
For active management of the island, the manager fee is collected from the UniV3 earned fees. For Kodiak team managed islands the manager fee is 0.
Fee = (Total Fees Earned * managerFeeBPS) / 10000
Unmanaged/Permissionless Islands use the Island factory's default fee settings
Restricted Minting
When restrictedMint is enabled:
Only the manager can mint new Island tokens
The first mint needs to atleast add INITIAL_MINT amount of liquidity.After the first mint this liquidity is burned.
Manager Functions
Update Manager Parameters
Updates the manager configuration parameters for the island Arguments:
newManagerFeeBPS: New manager fee in basis points (-1 to keep current)
newManagerTreasury: New treasury address (address(0) to keep current)
newSlippageBPS: New slippage tolerance in basis points (-1 to keep current)
newSlippageInterval: New TWAP interval in seconds (-1 to keep current)
Executive Rebalance
Rebalances the position by changing price range and optionally performing underlying pool swaps Arguments:
newLowerTick: New lower price bound of the position
newUpperTick: New upper price bound of the position
swapThresholdPrice: Maximum/minimum price for the swap in sqrtPriceX96 for uni v3 slippage protection
swapAmountBPS: Percentage of excess available tokens to swap in BPS
zeroForOne: True to swap token0 for token1, false for opposite
Notes: In order to generate the parameters for an executive rebalance one has to understand the flow of this operation. First, the Kodiak island removes all the liquidity and fees earned. Then, it tries to deposit as much liquidity as possible around the new price range. Next, whatever is leftover is then swapped based on the swap parameters. Finally, another deposit of maximal liquidity to the position is attempted and any leftover sits in the contract balance waiting to be reinvested.
Call getUnderlyingBalances on the ArrakisVault to obtain amount0Current and amount1Current
Compute amount0Liquidity and amount1Liquidity using LiquidityAmounts.sol library, the new position bounds, the current price and the current amounts from step 1.
Compute amount0Leftover and amount1Leftover with formula amount0Leftover = amount0Current - amount0Liquidity. In most cases one of these values will be 0 (or very close to 0).
Use amount0Liquidity and amount1Liquidity to compute the current proportion of each asset needed.
Use the amount0Leftover and amount1Leftover and the proportion from previous step to compute which token to swap and the swapAmount.
Convert swapAmount to swapAmountBPS by doing swapAmount * 10000 / amountLeftover for the token being swapped.
Executive Rebalance With Router
Rebalances using an external router for optimized swaps across all available liquidity. Arguments:
newLowerTick: New lower price bound of the position
newUpperTick: New upper price bound of the position
swapData: Struct containing:
router: Address of whitelisted router to use
amountIn: Amount of tokens to swap
minAmountOut: Minimum tokens to receive
zeroForOne: Swap direction
routeData: Encoded swap route data
Set Restricted Mint
Restricts minting to only the manager address Arguments:
_status: True to restrict minting, false to allow public minting
Set Pauser
Adds or removes an address from the pauser role Arguments:
_pauser: Address to modify pauser status for
_status: True to add as pauser, false to remove
Pause/Unpause
Emergency functions to pause/unpause all island operations
pause: Can be called by manager or pauser
unpause: Can only be called by manager
Fee Management
Withdraw Manager Balance
Withdraws accumulated manager fees to the manager treasury
Transfers all accumulated token0 and token1 fees
Resets manager balance tracking to zero
Sync To Factory
Updates unmanaged island parameters to match factory settings when updated.