DocsFees and the relayer

DocsConcepts12 of 33 · 2 min read

Fees and the relayer

The two flat fees on a payment or withdrawal, who receives them, and what the relayer does.

A payment or a withdrawal is submitted by the relayer, and pays two flat fees out of the sender's private balance. A deposit is signed and paid for by the depositing wallet and carries no Liora fee.

#The two fees

FeePaid toField in the configuration
Protocol feeThe fee recipientprotocolFeeLamports
Relayer feeThe relayer, for what the transfer cost itrelayerFeeLamports

Both are in lamports of SOL and both are the same for every payment and withdrawal, whatever the amount. The fees leave the Ring in public, and a flat fee tells a reader nothing about the amount it came with.

The relayer fee pays the relayer back for the transaction's signature fee and for the fee the Ring's tree charges per transfer. The program checks, at the end of each payment and withdrawal, that the relayer has been made whole for the signature, and rejects the transfer otherwise.

The current values are in the program's configuration. Read them with the SDK's config() or from the API before showing a total.

A transfer needs the amount plus both fees in spendable notes. With less, the device stops with INSUFFICIENT_BALANCE before anything is proved.

#How a fee is paid

They are paid in the same instruction as the transfer:

  1. The Ring pays out

    The transfer includes one public SOL withdrawal to the program's settlement address: both fees for a payment, both fees plus the amount for a withdrawal.

  2. The program checks the sum

    The settlement address must have received exactly that.

  3. The program pays on

    The protocol fee goes to the fee recipient, the relayer fee to the relayer, and a withdrawal's amount to its destination.

The proof binds both fees, the fee recipient and the relayer. A transaction that paid different fees, or paid them elsewhere, would not verify.

#The relayer

The relayer is one wallet named in the configuration. It signs each payment and withdrawal as fee payer, so the transaction contains no wallet of the sender.

The relayer canThe relayer cannot
Submit a transferChange its recipient, amount, destination or fees
Decline a transferSpend from anyone's balance
See the public parts of the transactionSee the recipient or the amount

Before signing, the relayer checks that the transaction calls only the Liora program and simulates it. A transfer that fails simulation is never sent. While a transfer is pending, the relayer refuses another one that spends the same note, with INPUT_SPENT.

A sender's device builds and proves the whole transaction, hands it to the relayer through the API, and follows its signature until it confirms or fails.