Hooks

Design

Hooks follow the same design principle as Sui's Kiosk transfer policy. It allows developers to enforce rules to pools. The rules are completed by calling the rule's module and collecting its witness. Rules can be anything from custom oracles to fee on swap.

Hooks

The CLAMM supports 8 hooks:

  • Start Swap: This hook must be completed before a swap transaction.

  • Finish Swap: A swap transaction must fulfill this hook to finish.

  • Start Add Liquidity: This hook must be completed before a user adds liquidity.

  • Finish Add Liquidity: A transaction to add liquidity must fulfill this hook to finish.

  • Start Remove Liquidity: This hook must be completed before a user removes liquidity.

  • Finish Remove Liquidity: A transaction to remove liquidity must fulfill this hook to finish.

  • Start Donate: This hook must be completed before a swap transaction.

  • Finish Donate: A swap transaction must fulfill this hook to finish.

Pools are not required to have hooks and a pool can have a Start Swap hook without a Finish Swap hook. Hooks are set at deployment and cannot be changed afterwards.

Examples

We will provide a set of standard hooks that will be automatically resolved via the SDK. Please refer to them on how to use your own hooks!

https://github.com/interest-protocol/hooks

Last updated