Skip to content

Getting Started with LuminaDex SDK

The LuminaDex SDK is a powerful library for interacting with the Lumina DEX contracts on the Mina and Zeko blockchains. It provides a state machine-driven approach to managing wallet connections, token swaps, liquidity provision, and other DEX-related operations.

Installation

bash
npm install @lumina-dex/sdk
bash
pnpm add @lumina-dex/sdk
bash
yarn add @lumina-dex/sdk
bash
bun add @lumina-dex/sdk

Prerequisites

To develop a dapp using the LuminaDex SDK effectively, you'll need:

  • A modern JavaScript environment with ES modules support
  • A Mina wallet extension installed in the user's browser (like Auro Wallet)
  • Basic familiarity with state machines (though not strictly required)

Quick Start

The core of the SDK revolves around two main modules:

  1. Wallet: Manages wallet connection, network switching, and balance fetching
  2. DEX: Handles all DEX-related operations like swapping, liquidity, and token deployment

These modules are xstate machines. Here's a quick example to connect a wallet and initialize the DEX:

ts
import { createDex, createWallet } from "@lumina-dex/sdk"

// Create and start the wallet
const Wallet = createWallet()

// Create and start the Dex
const Dex = createDex({
	input: {
		wallet: Wallet,
		frontendFee: {
			destination: "B62qmdQRb8FKaKA7cwaujmuTBbpp5NXTJFQqL1X9ya5nkvHSuWsiQ1H",
			amount: 1
		}
	}
})

// Connect the wallet
Wallet.send({ type: "Connect" })

Feature Loading

You can choose which specific features you need from the SDK when initializing it.

ts
const Dex = createDex({
	input: {
		wallet: Wallet,
		features: ["Swap"] // This is the default.
		frontendFee: {
			destination: "B62qmdQRb8FKaKA7cwaujmuTBbpp5NXTJFQqL1X9ya5nkvHSuWsiQ1H",
			amount: 1
		}
	}
})

You can load the following features:

  • Swap: For token swapping functionality
  • DeployPool: For deploying liquidity pools
  • DeployToken: For deploying new tokens
  • Claim: For claiming tokens from the Faucet

If you want to load additional features after the SDK has been initialized, you can use LoadFeatures :

ts
Dex.send({ type: "LoadFeatures", features: ["DeployPool"] })

Framework Integration

The SDK is framework-agnostic, but it provides dedicated integration modules for both React and Vue. See the React Integration and Vue Integration pages for complete examples.

Debugging and Caching

There are 2 values that can be set in localStorage to help with debugging and caching:

ts
localStorage.setItem("disableCache", true) // default false
localStorage.setItem("debugLogs", true) // default false in prod

Disabling cache will prevent the SDK from using the remote cache for contract compilation, and will force a compilation of the contracts from scratch. This takes longer, but can be useful for debugging.

Debug Logs will enable additional logging in the console, which can help with debugging issues in the SDK in your application during production or preview stage of the development. These logs are enabled by default in development mode.

What's Next?

Released under the MIT License.