Skip to main content

Overview

The Whitelist class manages resolver access control for Fusion orders. It defines:
  • Which addresses can resolve the order
  • When each address gains access
  • Exclusive resolver periods
Whitelisting enables priority access for preferred resolvers while eventually opening to all whitelisted addresses.

Constructor

Whitelist uses static factory methods instead of direct construction.

Static Methods

Whitelist.new()

Creates a new whitelist with time-based resolver access.
resolvingStartTime
bigint
required
Unix timestamp (seconds) when first resolver can start
whitelist
array
required
Array of whitelisted resolvers
address
Address
required
Resolver wallet address
allowFrom
bigint
required
Unix timestamp (seconds) when this resolver can start filling
import {Whitelist, Address} from '@1inch/fusion-sdk'

const resolvingStartTime = 1673548149n
const whitelist = Whitelist.new(
    resolvingStartTime,
    [
        {
            address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime
        },
        {
            address: new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime + 10n
        }
    ]
)
return
Whitelist
Configured Whitelist instance

Whitelist.fromNow()

Creates a whitelist starting from the current time.
whitelist
array
required
Array of whitelisted resolvers with allowFrom timestamps
import {Whitelist, Address} from '@1inch/fusion-sdk'

const whitelist = Whitelist.fromNow([
    {
        address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
        allowFrom: Date.now() / 1000
    }
])
return
Whitelist
Whitelist starting from current time

Whitelist.decode()

Decodes a whitelist from hex bytes.
bytes
string
required
Hex-encoded whitelist data with 0x prefix
const whitelist = Whitelist.decode('0x...')
return
Whitelist
Decoded Whitelist instance

Whitelist.decodeFrom()

Decodes a whitelist from a BytesIter.
bytes
BytesIter<string | bigint>
required
BytesIter positioned at whitelist data
const iter = BytesIter.HexString('0x...')
const whitelist = Whitelist.decodeFrom(iter)
return
Whitelist
Decoded Whitelist instance

Methods

encode()

Serializes whitelist to hex bytes.
const encoded = whitelist.encode()
// => '0x...'
return
string
Hex-encoded whitelist with 0x prefix

encodeInto()

Serializes whitelist into a BytesBuilder.
builder
BytesBuilder
Optional BytesBuilder instance (creates new if not provided)
const builder = new BytesBuilder()
whitelist.encodeInto(builder)
return
BytesBuilder
Builder with encoded whitelist data

canExecuteAt()

Checks if an address can resolve the order at a specific time.
executor
Address
required
Resolver address to check
executionTime
bigint
required
Unix timestamp (seconds) to check
import {Whitelist, Address, now} from '@1inch/fusion-sdk'

const canExecute = whitelist.canExecuteAt(
    new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
    now()
)
// => false (if before allowFrom time)
return
boolean
True if executor can fill at that time

isExclusiveResolver()

Checks if an address has exclusive first-fill rights.
wallet
Address
required
Resolver address to check
const isExclusive = whitelist.isExclusiveResolver(
    new Address('0x111111111117dc0aa78b770fa6a738034120c302')
)
// => true (if first in whitelist and has delay before next)
return
boolean
True if wallet has exclusive access period

isExclusivityPeriod()

Checks if the whitelist is currently in an exclusivity period.
time
bigint
Unix timestamp to check (defaults to now)
import {now} from '@1inch/fusion-sdk'

const isExclusive = whitelist.isExclusivityPeriod(now() + 5n)
// => true (if within exclusive period)
return
boolean
True if in exclusivity period at given time

isWhitelisted()

Checks if an address is in the whitelist.
address
Address
required
Address to check
const whitelisted = whitelist.isWhitelisted(
    new Address('0x111111111117dc0aa78b770fa6a738034120c302')
)
return
boolean
True if address is whitelisted

equal()

Compares two whitelists for equality.
other
Whitelist
required
Whitelist to compare
const isEqual = whitelist.equal(otherWhitelist)
return
boolean
True if whitelists are identical

Properties

resolvingStartTime
bigint
Unix timestamp when resolving begins
whitelist
WhitelistItem[]
Array of whitelist entries with addressHalf and delay
length
number
Number of whitelisted addresses

Examples

Encode/Decode Whitelist

import {Whitelist, now, Address} from '@1inch/fusion-sdk'

const resolvingStartTime = now()
const whitelist = Whitelist.new(
    resolvingStartTime,
    [
        {
            address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime
        },
        {
            address: new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime + 10n
        }
    ]
)

const encoded = whitelist.encode() // => '0x...'
const decoded = Whitelist.decode(encoded) // => same as whitelist

Check Exclusivity

import {Whitelist, now, Address} from '@1inch/fusion-sdk'

const resolvingStartTime = now()
const whitelist = Whitelist.new(
    resolvingStartTime,
    [
        {
            address: new Address('0x111111111117dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime
        },
        {
            address: new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
            allowFrom: resolvingStartTime + 10n
        }
    ]
)

const isExclusive = whitelist.isExclusiveResolver(
    new Address('0x111111111117dc0aa78b770fa6a738034120c302')
) // => true

const isExclusivityPeriod = whitelist.isExclusivityPeriod(
    resolvingStartTime + 5n
) // => true

const canExecuteNow = whitelist.canExecuteAt(
    new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
    resolvingStartTime
) // => false (must wait 10 seconds)

const canExecuteLater = whitelist.canExecuteAt(
    new Address('0x222222222227dc0aa78b770fa6a738034120c302'),
    resolvingStartTime + 10n
) // => true

How Whitelisting Works

  1. Resolving Start Time: Global start time for the order
  2. Sequential Access: Each resolver gets access at their allowFrom time
  3. Relative Delays: Internally stored as delays between resolvers for efficiency
  4. Exclusivity: First resolver with delayed access has exclusive period
  5. Address Matching: Uses last 10 bytes of address for gas optimization

Use Cases

Private Resolver

// Single resolver, indefinite exclusivity
const whitelist = Whitelist.new(now(), [
    {
        address: resolverAddress,
        allowFrom: now()
    }
])

Timed Fallback

// Preferred resolver has 30 seconds, then fallback
const startTime = now()
const whitelist = Whitelist.new(startTime, [
    {
        address: preferredResolver,
        allowFrom: startTime
    },
    {
        address: fallbackResolver,
        allowFrom: startTime + 30n
    }
])

Public Auction

// All resolvers access simultaneously
const startTime = now()
const whitelist = Whitelist.new(startTime, [
    {address: resolver1, allowFrom: startTime},
    {address: resolver2, allowFrom: startTime},
    {address: resolver3, allowFrom: startTime}
])

Build docs developers (and LLMs) love