MakerSolver
A maker solver over a wallet runtime: builds and proves maker offers from distinct NIGHT coins, completes counterparty offers, sponsors DUST for balanced fills, watches settlement and reports inventory. Everything our own solver does goes through this class (no private hooks).
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MakerSolver(
wallet,cfg):MakerSolver
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
wallet |
WalletRuntime |
cfg |
MakerConfig |
Returns
Section titled “Returns”MakerSolver
Properties
Section titled “Properties”inventory
Section titled “inventory”
readonlyinventory:NightInventory
giveToken
Section titled “giveToken”
readonlygiveToken:string
The unshielded token given (MakerConfig.giveToken).
wallet
Section titled “wallet”
readonlywallet:WalletRuntime
readonlycfg:MakerConfig
Accessors
Section titled “Accessors”networkId
Section titled “networkId”Get Signature
Section titled “Get Signature”get networkId():
string
Returns
Section titled “Returns”string
Methods
Section titled “Methods”start()
Section titled “start()”start():
Promise<void>
Follows the chain and reports settlements and expiries to on(...) listeners.
Returns
Section titled “Returns”Promise<void>
stop()
Section titled “stop()”stop():
void
Returns
Section titled “Returns”void
on(
fn): () =>void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fn |
(s) => void |
Returns
Section titled “Returns”() => void
refreshInventory()
Section titled “refreshInventory()”refreshInventory():
Promise<void>
Returns
Section titled “Returns”Promise<void>
prepareLots()
Section titled “prepareLots()”prepareLots(
sizes,opts?):Promise<{txHashes:string[]; }>
Splits NIGHT into offer-sized coins (the ladder's distinct coins). Normally only coins
outside the reserve are split; fromReserve (bootstrap, when the reserve is the only
coin) re-outputs the reserve in full beside the lots, restarting its DUST generation.
Up to two lots per transaction, each waiting for the previous; fewer when a node would
refuse the split as too slow to check for its size (see fittedSplit).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sizes |
bigint[] |
opts? |
{ fromReserve?: boolean; timeoutMs?: number; } |
opts.fromReserve? |
boolean |
opts.timeoutMs? |
number |
Returns
Section titled “Returns”Promise<{ txHashes: string[]; }>
topUpLots()
Section titled “topUpLots()”topUpLots(
targets):Promise<string|null>
Keeps offer-sized coins available (replenishment): each fill spends a coin and returns only its change, so free coins of each target size run out unless the large remainder is split again. Splits at most two coins per call; call it periodically.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
targets |
object[] |
Returns
Section titled “Returns”Promise<string | null>
buildMakerOffer()
Section titled “buildMakerOffer()”buildMakerOffer(
terms,opts?):Promise<MadeOffer>
buildMakerOffer (the initSwap → finalizeRecipe shape): a proven leg giving
terms.give NIGHT to terms.giveTo and wanting terms.want USDM, of which the fee
outputs are part. Its coins stay locked until it settles or its TTL passes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
terms |
SwapTerms |
opts? |
{ background?: boolean; } |
opts.background? |
boolean |
Returns
Section titled “Returns”Promise<MadeOffer>
sponsorFees()
Section titled “sponsorFees()”sponsorFees(
swapId,txHex,maxDust?,requireOutputs?):Promise<{txHash:string;dustFee:bigint;bytes:number; }>
Sponsorship: the user's wallet balanced our offer without paying fees; add a
DUST-only intent priced on the whole transaction and submit. Refuses transactions
that do not contain an outstanding offer of ours, are not otherwise balanced, or
would cost more than maxDust.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
swapId |
string |
undefined |
txHex |
string |
undefined |
maxDust? |
bigint |
... |
requireOutputs? |
object[] |
[] |
Returns
Section titled “Returns”Promise<{ txHash: string; dustFee: bigint; bytes: number; }>
completeOffer()
Section titled “completeOffer()”completeOffer(
offer,opts?):Promise<{txHash:string;dustFee:bigint;bytes:number; }>
completeOffer (balanceFinalizedTransaction → finalizeRecipe → submit): fills a
counterparty's offer from our inventory, paying the DUST, optionally taking a fee
output from the surplus. The taker flow.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
offer |
string |
opts? |
{ fee?: { token: string; amount: bigint; to: ShieldedRecipient; }; ttlMs?: number; } |
opts.fee? |
{ token: string; amount: bigint; to: ShieldedRecipient; } |
opts.fee.token |
string |
opts.fee.amount |
bigint |
opts.fee.to |
ShieldedRecipient |
opts.ttlMs? |
number |
Returns
Section titled “Returns”Promise<{ txHash: string; dustFee: bigint; bytes: number; }>
buildOffer()
Section titled “buildOffer()”buildOffer(
fillId,terms,opts?):Promise<MadeOffer>
rfq.accept (solver_offer): the leg for the accepted quote. Buy side (the
user receives NIGHT): the maker leg with the NIGHT output to the quoted
address. Sell side (the user receives USDM): a leg spending our USDM into the user's
shielded output and the fee outputs, wanting NIGHT to us; the wallet covers that
NIGHT deficit (balanceSealedTransaction spending its NIGHT).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fillId |
string |
terms |
MakeTerms |
opts? |
{ background?: boolean; } |
opts.background? |
boolean |
Returns
Section titled “Returns”Promise<MadeOffer>
completeJob()
Section titled “completeJob()”completeJob(
fillId,offers,fees,opts?):Promise<CompletedJob>
Completes the offers of a job with our leg. expect bounds what the offers may take
from us per token (see JobExpect: the quote's or the ladder's terms); an offer
outside it, or one that does not settle entirely in its guaranteed section, is
refused before any coin is taken. Without expect (and without surplusOnly) a job
could spend anything we hold: callers that pay out pass one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fillId |
string |
offers |
string[] |
fees |
SwapFeeOutput[] |
opts? |
{ surplusOnly?: boolean; ttlMs?: number; maxDust?: bigint; expect?: JobExpect; } |
opts.surplusOnly? |
boolean |
opts.ttlMs? |
number |
opts.maxDust? |
bigint |
opts.expect? |
JobExpect |
Returns
Section titled “Returns”Promise<CompletedJob>
estimateFee()
Section titled “estimateFee()”estimateFee(
tx):bigint
estimateFee: Specks for a sealed transaction (accurate for proven ones).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
tx |
string | SealedTx |
Returns
Section titled “Returns”bigint
dustBudget()
Section titled “dustBudget()”dustBudget():
object
dustBudget: DUST on hand against the recent sponsored cost per fill.
Returns
Section titled “Returns”object
balance
Section titled “balance”balance:
bigint
perFillEstimate
Section titled “perFillEstimate”perFillEstimate:
bigint
fillsCovered
Section titled “fillsCovered”fillsCovered:
number
watchSettlement()
Section titled “watchSettlement()”watchSettlement(
swapId,timeoutMs?):Promise<MakerStatus>
watchSettlement: resolves when the offer settles, expires or fails on chain.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
swapId |
string |
undefined |
timeoutMs? |
number |
600_000 |
Returns
Section titled “Returns”Promise<MakerStatus>
release()
Section titled “release()”release(
swapId):void
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
swapId |
string |
Returns
Section titled “Returns”void
outstandingCount()
Section titled “outstandingCount()”outstandingCount():
number
Returns
Section titled “Returns”number
snapshot()
Section titled “snapshot()”snapshot():
MakerInventory