Skip to main content
Index Orca Whirlpool swap instructions on Solana mainnet.

Prerequisites

  • Node.js 22.15+ installed
  • pnpm (recommended): npm install -g pnpm, or if pnpm is under ~/node/bin, run export PATH=${PATH}:${HOME}/node/bin before the init command

Initialize the project

Run the following in an empty directory, then follow the instructions.
pnpx @iankressin/pipes-cli@latest init --config '{
  "projectFolder": "orca-example",
  "packageManager": "pnpm",
  "sink": "postgresql",
  "networkType": "svm",
  "network": "solana-mainnet",
  "templates": [
    {
      "templateId": "custom",
      "params": {
        "contracts": [
          {
            "contractAddress": "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc",
            "contractName": "OrcaWhirlpool",
            "contractEvents": [
              {
                "name": "swap",
                "type": "instruction",
                "inputs": [
                  { "name": "amount", "type": "u64" },
                  { "name": "sqrtPriceLimit", "type": "u128" }
                ]
              }
            ]
          }
        ]
      }
    }
  ]
}'

What itโ€™s doing

Find the following code at src/index.ts:
const custom = solanaInstructionDecoder({
  range: { from: 'latest' },
  programId: ['whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc'],
  /**
   * Or optionally use pass all events object directly to listen to all contract events
   * ```ts
   * events: myContractEvents,
   * ```
   */
  instructions: {
    swap: orcaWhirlpoolInstructions.swap,
  },
}).pipe(enrichEvents)

export async function main() {
  await solanaPortalSource({
    portal: 'https://portal.sqd.dev/datasets/solana-mainnet',
  })
    .pipeComposite({
      custom,
    })
    .pipeTo(
      drizzleTarget({
        db: drizzle(env.DB_CONNECTION_STR),
        tables: [orcaWhirlpoolSwapTable],
        onData: async ({ tx, data }) => {
          for (const values of chunk(data.custom.swap)) {
            await tx.insert(orcaWhirlpoolSwapTable).values(values)
          }
        },
      }),
    )
}
Explanations TBA.

Using with AI

Instructions on setting up AI workflows in common environments TBA. Tentatively skills-based.