@sfpro/sdk

Flow Scheduler

Schedule and automate Superfluid payment streams

The Flow Scheduler enables scheduling of Superfluid streams to start and stop at specific times. This is useful for recurring payments, time-based subscriptions, and automated payroll systems.

Overview

Flow Scheduler provides:

  • Future-dated stream creation
  • Automatic stream termination
  • Recurring payment schedules
  • Batch scheduling operations
  • Gas-efficient automation

Read Functions

getFlowSchedule

Returns details of a scheduled flow.

import { useReadFlowScheduler } from '@sfpro/sdk/hook/automation';

const { data: schedule } = useReadFlowScheduler({
  address: '0x...',
  functionName: 'getFlowSchedule',
  args: [superToken, sender, receiver],
});
import { flowScheduler } from '@sfpro/sdk/abi/automation';

const schedule = await client.readContract({
  address: '0x...',
  abi: flowScheduler,
  functionName: 'getFlowSchedule',
  args: [superToken, sender, receiver],
});
import { readFlowScheduler } from '@sfpro/sdk/action/automation';

const schedule = await readFlowScheduler(client, {
  address: '0x...',
  functionName: 'getFlowSchedule',
  args: [superToken, sender, receiver],
});

canExecuteSchedule

Checks if a scheduled flow can be executed.

getScheduleInfo

Returns comprehensive information about a flow schedule.

Write Functions

createFlowSchedule

Creates a new scheduled flow with start and optional end time.

import { useWriteFlowScheduler } from '@sfpro/sdk/hook/automation';

const { writeContract } = useWriteFlowScheduler();

await writeContract({
  address: '0x...',
  functionName: 'createFlowSchedule',
  args: [
    superToken,
    receiver,
    flowRate,
    startDate,
    endDate,
    userData
  ],
});
import { flowScheduler } from '@sfpro/sdk/abi/automation';

const hash = await client.writeContract({
  address: '0x...',
  abi: flowScheduler,
  functionName: 'createFlowSchedule',
  args: [
    superToken,
    receiver,
    flowRate,
    startDate,
    endDate, // optional, use 0 for indefinite
    userData
  ],
});
import { writeFlowScheduler } from '@sfpro/sdk/action/automation';

const hash = await writeFlowScheduler(client, {
  address: '0x...',
  functionName: 'createFlowSchedule',
  args: [
    superToken,
    receiver,
    flowRate,
    startDate,
    endDate,
    userData
  ],
});

deleteFlowSchedule

Cancels a scheduled flow before it starts.

executeStartSchedule

Triggers the start of a scheduled flow (can be called by anyone).

executeEndSchedule

Triggers the end of a scheduled flow (can be called by anyone).

createScheduleFromAmountAndDuration

Creates a schedule by specifying total amount and duration.

Schedule Parameters

  • startDate: Unix timestamp when the flow should start
  • endDate: Unix timestamp when the flow should end (0 for indefinite)
  • flowRate: Rate of the stream in wei per second
  • userData: Optional metadata for the schedule

Use Cases

  • Payroll: Schedule salary payments to start on specific dates
  • Subscriptions: Time-limited access with automatic termination
  • Recurring Payments: Weekly/monthly payment automation
  • Trial Periods: Free trials that convert to paid streams