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
owneronly when you need a specific address; omit it when awalletis configured — Whose wallet (owner). - You may need
balances.approvebeforedepositif allowance is too low. - After a successful write, refresh farm or
positionsreads. Pollsettlement.trackuntilconfirmedorfailedif the handle is still running. - For a mixed portfolio table, prefer
positions.listPositionswithkinds: ['farm']. - Deposit / withdraw / harvest can incur gas and the service fee when they run. The SDK does not return a
costslist 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
| Field | Type | Description |
|---|---|---|
ledgers | LedgerScope[] | Optional. Limit to these ledgers (ID or alias). |
venueId | VenueId | Optional. Only farms tied to this pool (e.g. after the user picked a pair). |
Returns — Farm[]
| Field | Type | Description |
|---|---|---|
id | FarmId | Opaque farm id — pass to deposit / withdraw / harvest / getFarm. |
ledger | LedgerId | Canonical ledger. |
stakeInstrumentId | InstrumentId | Asset users deposit (often an LP share). Show this in “you deposit”. |
rewardInstrumentId | InstrumentId | Reward token. Show this in “you earn”. |
venueId | VenueId | Optional. 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
| Field | Type | Description |
|---|---|---|
farmId | FarmId | Farm 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
| Field | Type | Description |
|---|---|---|
farmId | FarmId | Farm to inspect. |
owner | string | Optional. Omit to use the connected wallet — Whose wallet (owner). |
Returns — FarmPosition
| Field | Type | Description |
|---|---|---|
id | PositionId | Opaque position id. |
farmId | FarmId | Farm this deposit belongs to. |
ledger | LedgerId | Canonical ledger. |
owner | string | Depositor address. |
amount | string | Deposited stake-asset amount as a display decimal. |
claimableReward | object | Optional. 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
| Field | Type | Description |
|---|---|---|
farmId | FarmId | Target farm. |
amount | string | How much of the farm’s stake asset to deposit (display decimal). |
deadline | number | Optional. 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
| Field | Type | Description |
|---|---|---|
farmId | FarmId | Farm to withdraw from. |
amount | string | How much to withdraw (display decimal). |
deadline | number | Optional. 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
| Field | Type | Description |
|---|---|---|
farmId | FarmId | Farm whose rewards you are claiming. |
deadline | number | Optional. 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