Skip to content

orca-so/whirlpool-cpi-sample

Repository files navigation

Whirlpool CPI Sample

This repo contains samples contracts which interact with Whirlpool via CPI.

This sample will just proxy Whirlpool instructions via CPI.

sample1

Based on this sample, you can build a program executing Whirlpool instructions via CPI.

sample2

Anchor / Solana version mapping

Directory Anchor version Solana version (rustc version)
anchor-0.24.2 v0.24.2 Solana 1.9.29 (1.59.0-dev)
anchor-0.25.0 v0.25.0 Solana 1.10.41 (1.59.0-dev)
anchor-0.26.0 v0.26.0 Solana 1.14.29 (1.62.0-dev)
anchor-0.27.0 v0.27.0 Solana 1.14.17 (1.62.0-dev)
anchor-0.28.0 v0.28.0 Solana 1.16.26 (1.68.0-dev)
anchor-0.29.0 v0.29.0 Solana 1.17.14 (1.68.0-dev)
anchor-0.30.1 v0.30.1 Solana 1.18.21 (1.75.0-dev)

Contract Instruction

You can write a contract to execute CPI to Whirlpool based on the following sample instructions.

  • VerifyX reads the account and displays the contents.
  • ProxyX executes the received instructions directly through CPI.
Context (instruction) What to do
VerifyWhirlpoolsConfigAccount print fields of WhirlpoolsConfig account
VerifyFeeTierAccount print fields of FeeTier account
VerifyWhirlpoolAccount print fields of Whirlpool account
VerifyTickArrayAccount print fields of TickArray account
VerifyPositionAccount print field of Position account
ProxySwap execute swap instruction via CPI
ProxyOpenPosition execute open_position instruction via CPI
ProxyIncreaseLiquidity execute increase_liquidity instruction via CPI
ProxyDecreaseLiquidity execute decrease_liquidity instruction via CPI
ProxyUpdateFeesAndRewards execute update_fees_and_rewards instruction via CPI
ProxyCollectFees execute collect_fees instruction via CPI
ProxyCollectReward execute collect_reward instruction via CPI
ProxyClose execute close_position instruction via CPI
ProxyInitializePool execute initialize_pool instruction via CPI
ProxyInitializeTickArray execute initialize_tick_array instruction via CPI

whirlpool-cpi crate

The following crate is used to read accounts and execute CPI:

https://github.com/orca-so/whirlpool-cpi

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published