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.
Unix timestamp (seconds) when first resolver can start
Array of whitelisted resolversUnix 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
}
]
)
Configured Whitelist instance
Whitelist.fromNow()
Creates a whitelist starting from the current time.
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
}
])
Whitelist starting from current time
Whitelist.decode()
Decodes a whitelist from hex bytes.
Hex-encoded whitelist data with 0x prefix
const whitelist = Whitelist.decode('0x...')
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)
Decoded Whitelist instance
Methods
encode()
Serializes whitelist to hex bytes.
const encoded = whitelist.encode()
// => '0x...'
Hex-encoded whitelist with 0x prefix
encodeInto()
Serializes whitelist into a BytesBuilder.
Optional BytesBuilder instance (creates new if not provided)
const builder = new BytesBuilder()
whitelist.encodeInto(builder)
Builder with encoded whitelist data
canExecuteAt()
Checks if an address can resolve the order at a specific time.
Resolver address to check
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)
True if executor can fill at that time
isExclusiveResolver()
Checks if an address has exclusive first-fill rights.
Resolver address to check
const isExclusive = whitelist.isExclusiveResolver(
new Address('0x111111111117dc0aa78b770fa6a738034120c302')
)
// => true (if first in whitelist and has delay before next)
True if wallet has exclusive access period
isExclusivityPeriod()
Checks if the whitelist is currently in an exclusivity period.
Unix timestamp to check (defaults to now)
import {now} from '@1inch/fusion-sdk'
const isExclusive = whitelist.isExclusivityPeriod(now() + 5n)
// => true (if within exclusive period)
True if in exclusivity period at given time
isWhitelisted()
Checks if an address is in the whitelist.
const whitelisted = whitelist.isWhitelisted(
new Address('0x111111111117dc0aa78b770fa6a738034120c302')
)
True if address is whitelisted
equal()
Compares two whitelists for equality.
const isEqual = whitelist.equal(otherWhitelist)
True if whitelists are identical
Properties
Unix timestamp when resolving begins
Array of whitelist entries with addressHalf and delay
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
- Resolving Start Time: Global start time for the order
- Sequential Access: Each resolver gets access at their
allowFrom time
- Relative Delays: Internally stored as delays between resolvers for efficiency
- Exclusivity: First resolver with delayed access has exclusive period
- 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}
])