Skip to content

Mediated Reclaim ​

Reclaims an expired mediated escrow back to the depositor, without the mediator. The program moves the escrowed tokens from the vault to the depositor's associated token account and closes the MediatedEscrowDeposit, returning its rent to the depositor.

This only works when the deposit was created with an expires_at and the on-chain clock has passed it. With no expiry set, only the mediator can ever distribute the funds — see Expiry & Reclaim.

Program method — mediated_reclaim ​

Derives the mediated escrow PDA, the vault, and the depositor's associated token account, then builds, signs (payer + depositor), and sends.

ParameterTypeRequiredDefaultDescription
payerKeypairyes—The fee payer; co-signs.
mint#to_syes—The escrowed mint.
depositorKeypairyes—The depositor; co-signs. Receives the returned tokens and rent.
id#to_syes—The unique id the escrow was created with.
token_program_idStringnolegacy SPL TokenToken program that owns the mint.

Plus the shared sign: / execute: controls and Solace::Transaction return — see Conventions.

ruby
tx = program.mediated_reclaim(
  payer:     depositor,
  mint:      mint_address,
  depositor: depositor,
  id:
)
connection.wait_for_confirmed_signature { tx.signature }

Composer — ZarTrustlessEscrowMediatedReclaimComposer ​

The mediated escrow PDA, vault, and depositor token account must be resolved first.

ParameterTypeRequiredDefaultDescription
mint#to_syes—The escrowed mint.
depositor#to_syes—The depositor (writable signer; receives tokens + rent).
depositor_token_account#to_syes—The depositor's destination token account (ATA).
mediated_escrow_deposit#to_syes—The MediatedEscrowDeposit PDA.
program_token_account#to_syes—The vault PDA.
fee_payer#to_s · Keypairyes—Fee payer; writable signer.
id#to_syes—The unique id the escrow was created with.
program_id#to_snomainnet PROGRAM_IDThe escrow program id.
token_program_id#to_snolegacy SPL TokenToken program that owns the mint.
ruby
mediated_escrow, = program.get_mediated_escrow_deposit_address(id:)
vault,           = program.get_vault_address(mint: mint_address)
depositor_ata,   = Solace::Programs::AssociatedTokenAccount.get_address(
  owner: depositor.address, mint: mint_address
)

composer = Solace::Composers::ZarTrustlessEscrowMediatedReclaimComposer.new(
  mint:                    mint_address,
  depositor:               depositor.address,
  depositor_token_account: depositor_ata,
  mediated_escrow_deposit: mediated_escrow,
  program_token_account:   vault,
  fee_payer:               depositor.address,
  id:
)

tx = Solace::TransactionComposer.new(connection:)
                                .add_instruction(composer)
                                .set_fee_payer(depositor)
                                .compose_transaction

tx.sign(depositor)
connection.send_transaction(tx.serialize)

Low-level instruction (advanced) ​

MediatedReclaimInstruction.build encodes the raw instruction.

  • Discriminator: [192, 255, 211, 122, 12, 11, 191, 146]
  • Encodes (data): pubkey(id)
  • Accounts (in order): mint · depositor (writable signer) · depositor_token_account (writable) · mediated_escrow_deposit (writable) · program_token_account (writable) · fee_payer (writable signer) · system_program · token_program · associated_token_program.
ParameterTypeRequiredDescription
id#to_syesUnique id; encoded into data.
mint_indexIntegeryesIndex of the mint.
depositor_indexIntegeryesIndex of the depositor.
depositor_token_account_indexIntegeryesIndex of the depositor's token account.
mediated_escrow_deposit_indexIntegeryesIndex of the MediatedEscrowDeposit PDA.
program_token_account_indexIntegeryesIndex of the vault.
fee_payer_indexIntegeryesIndex of the fee payer.
system_program_indexIntegeryesIndex of the System program.
token_program_indexIntegeryesIndex of the token program.
associated_token_program_indexIntegeryesIndex of the Associated Token Account program.
program_indexIntegeryesIndex of the escrow program.

Built on Solace