@sfpro/sdk

Auto Wrap

Automatic wrapping strategy for Super Tokens

The Auto Wrap contract enables automatic wrapping of underlying tokens to Super Tokens based on configurable strategies. This helps maintain optimal Super Token balances without manual intervention.

Overview

Auto Wrap provides:

  • Automatic wrapping based on balance thresholds
  • Configurable trigger strategies
  • Gas-efficient batch operations
  • Integration with existing Superfluid streams

Read Functions

getStrategy

Returns the auto-wrap strategy for an account.

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

const { data: strategy } = useReadAutoWrap({
  address: '0x...',
  functionName: 'getStrategy',
  args: [account, superToken],
});
import { autoWrap } from '@sfpro/sdk/abi/automation';

const strategy = await client.readContract({
  address: '0x...',
  abi: autoWrap,
  functionName: 'getStrategy',
  args: [account, superToken],
});
import { readAutoWrap } from '@sfpro/sdk/action/automation';

const strategy = await readAutoWrap(client, {
  address: '0x...',
  functionName: 'getStrategy',
  args: [account, superToken],
});

canWrap

Checks if an auto-wrap can be triggered for an account.

getWrapAmount

Calculates the amount to be wrapped based on the strategy.

Write Functions

setStrategy

Configures the auto-wrap strategy for your account.

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

const { writeContract } = useWriteAutoWrap();

await writeContract({
  address: '0x...',
  functionName: 'setStrategy',
  args: [
    superToken,
    {
      lowerThreshold: parseEther('10'),
      upperThreshold: parseEther('100'),
      expiry: BigInt(Math.floor(Date.now() / 1000) + 86400 * 30)
    }
  ],
});
import { autoWrap } from '@sfpro/sdk/abi/automation';

const hash = await client.writeContract({
  address: '0x...',
  abi: autoWrap,
  functionName: 'setStrategy',
  args: [
    superToken,
    {
      lowerThreshold: parseEther('10'),
      upperThreshold: parseEther('100'),
      expiry: BigInt(Math.floor(Date.now() / 1000) + 86400 * 30)
    }
  ],
});
import { writeAutoWrap } from '@sfpro/sdk/action/automation';

const hash = await writeAutoWrap(client, {
  address: '0x...',
  functionName: 'setStrategy',
  args: [
    superToken,
    {
      lowerThreshold: parseEther('10'),
      upperThreshold: parseEther('100'),
      expiry: BigInt(Math.floor(Date.now() / 1000) + 86400 * 30)
    }
  ],
});

wrap

Triggers auto-wrap for an account (can be called by anyone).

removeStrategy

Removes the auto-wrap strategy for your account.

wrapMultiple

Triggers auto-wrap for multiple accounts in a single transaction.

Strategy Configuration

The auto-wrap strategy consists of:

  • lowerThreshold: Minimum Super Token balance to maintain
  • upperThreshold: Target balance after wrapping
  • expiry: Strategy expiration timestamp

When the Super Token balance falls below the lower threshold, anyone can trigger a wrap that brings the balance up to the upper threshold.