Skip to content
CTRL K
    Farming

    Farming

    Use this module for liquidity mining: list farms, show a user’s deposit, deposit or withdraw the farm’s stake asset (often an LP share), and harvest rewards.

    This is a product program over catalog instruments — not native chain / consensus staking.

    Amounts are display decimals. Writes use a Wallet adapter.

    Rules

    • Deposit / withdraw / harvest are separate writes. A common app flow is add liquidity → deposit LP → harvest — you compose those steps; Nutrimatic does not chain them.
    • Pass owner only when you need a specific address; omit it when a wallet is configured — Whose wallet (owner).
    • You may need balances.approve before deposit if allowance is too low.
    • After a successful write, refresh farm or positions reads. Poll settlement.track until confirmed or failed if the handle is still running.
    • For a mixed portfolio table, prefer positions.listPositions with kinds: ['farm'].
    • Deposit / withdraw / harvest can incur gas and the service fee when they run. The SDK does not return a costs list before those calls — Fees and costs.

    Reads

    farming.listFarms

    Discover farms you can show in a farm picker or directory.

    const farms = await sdk.farming.listFarms({
      ledgers: ['infinite-mainnet'],
    })

    Parameters — ListFarmsQuery

    FieldTypeDescription
    ledgersLedgerScope[]Optional. Limit to these ledgers (ID or alias).
    venueIdVenueIdOptional. Only farms tied to this pool (e.g. after the user picked a pair).

    Returns — Farm[]

    FieldTypeDescription
    idFarmIdOpaque farm id — pass to deposit / withdraw / harvest / getFarm.
    ledgerLedgerIdCanonical ledger.
    stakeInstrumentIdInstrumentIdAsset users deposit (often an LP share). Show this in “you deposit”.
    rewardInstrumentIdInstrumentIdReward token. Show this in “you earn”.
    venueIdVenueIdOptional. Related pool when the farm is pool-scoped.

    Example response:

    [
      {
        "id": "farm_01H…",
        "ledger": "evm:421018",
        "stakeInstrumentId": "evm:421018:instrument:lp-42-usdt",
        "rewardInstrumentId": "evm:421018:instrument:42",
        "venueId": "evm:421018:amm:v2:0xabc123"
      }
    ]

    farming.getFarm

    One farm by id (detail header before deposit).

    const farm = await sdk.farming.getFarm('farm_01H…')

    Parameters

    FieldTypeDescription
    farmIdFarmIdFarm id from listFarms or a position’s farmId.

    Returns — Farm

    Same fields as each element in listFarms.

    Example response:

    {
      "id": "farm_01H…",
      "ledger": "evm:421018",
      "stakeInstrumentId": "evm:421018:instrument:lp-42-usdt",
      "rewardInstrumentId": "evm:421018:instrument:42",
      "venueId": "evm:421018:amm:v2:0xabc123"
    }

    farming.getFarmPosition

    How much the owner has deposited in a farm, plus claimable rewards.

    const position = await sdk.farming.getFarmPosition({
      farmId: 'farm_01H…',
    })

    Parameters — GetFarmPositionParams

    FieldTypeDescription
    farmIdFarmIdFarm to inspect.
    ownerstringOptional. Omit to use the connected wallet — Whose wallet (owner).

    Returns — FarmPosition

    FieldTypeDescription
    idPositionIdOpaque position id.
    farmIdFarmIdFarm this deposit belongs to.
    ledgerLedgerIdCanonical ledger.
    ownerstringDepositor address.
    amountstringDeposited stake-asset amount as a display decimal.
    claimableRewardobjectOptional. Pending harvest: instrumentId + display amount.

    Example response:

    {
      "id": "pos_farm_01…",
      "farmId": "farm_01H…",
      "ledger": "evm:421018",
      "owner": "0xabc…",
      "amount": "10",
      "claimableReward": {
        "instrumentId": "evm:421018:instrument:42",
        "amount": "0.4"
      }
    }

    Writes

    farming.deposit

    Deposit amount of the farm’s stake instrument. Signing uses purpose: 'farm_deposit'.

    const handle = await sdk.farming.deposit({
      farmId: 'farm_01H…',
      amount: '10',
    })

    Parameters — FarmDepositRequest

    FieldTypeDescription
    farmIdFarmIdTarget farm.
    amountstringHow much of the farm’s stake asset to deposit (display decimal).
    deadlinenumberOptional. Unix time in milliseconds.

    Returns — ExecutionHandle

    Poll settlement.track until confirmed or failed if still running.

    Example response:

    {
      "id": "exec_01HZZ…",
      "status": "confirmed",
      "ledger": "evm:421018",
      "txRef": "0xdef…"
    }

    farming.withdraw

    Withdraw amount of the deposited stake asset. Signing uses purpose: 'farm_withdraw'.

    const handle = await sdk.farming.withdraw({
      farmId: 'farm_01H…',
      amount: '5',
    })

    Parameters — FarmWithdrawRequest

    FieldTypeDescription
    farmIdFarmIdFarm to withdraw from.
    amountstringHow much to withdraw (display decimal).
    deadlinenumberOptional. Unix time in milliseconds.

    Returns — ExecutionHandle

    Same shape as farming.deposit.

    Example response:

    {
      "id": "exec_01HZZ…",
      "status": "confirmed",
      "ledger": "evm:421018",
      "txRef": "0xabc…"
    }

    farming.harvest

    Claim pending farm rewards. Signing uses purpose: 'farm_harvest'.

    const handle = await sdk.farming.harvest({
      farmId: 'farm_01H…',
    })

    Parameters — FarmHarvestRequest

    FieldTypeDescription
    farmIdFarmIdFarm whose rewards you are claiming.
    deadlinenumberOptional. Unix time in milliseconds.

    Returns — ExecutionHandle

    Same shape as farming.deposit.

    Example response:

    {
      "id": "exec_01HZZ…",
      "status": "confirmed",
      "ledger": "evm:421018",
      "txRef": "0xharvest…"
    }

    Errors

    READ_ONLY_MODE, CAPABILITY_NOT_AVAILABLE, WALLET_REQUIRED, USER_REJECTED, LEDGER_NOT_SUPPORTED.

    Positions · Staking · Liquidity · Write operations