|
| 1 | +--- |
| 2 | +title: Monitor Redemptions & Execute Defaults |
| 3 | +tags: [intermediate, fassets] |
| 4 | +slug: fassets-redemption-default |
| 5 | +description: Learn how to monitor and handle redemption non-payment scenarios |
| 6 | +keywords: [fassets, flare-network] |
| 7 | +sidebar_position: 10 |
| 8 | +--- |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +In the FAssets system, once a **redeemer submits a redemption request**, the assigned **agent must send the underlying asset** (e.g., XRP) to the redeemer within a specific time that is defined by the [operational parameters](/fassets/operational-parameters). |
| 13 | + |
| 14 | +This guide explains: |
| 15 | + |
| 16 | +- How to **observe the redemption deadline**. |
| 17 | +- What parameters to use (`underlyingSecondsForPayment`, `underlyingBlocksForPayment`) |
| 18 | +- How to **handle agent failure** by calling [`redemptionPaymentDefault`](/fassets/reference/IAssetManager#redemptionpaymentdefault). |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Basic understanding of [FAssets system](/fassets/overview). |
| 23 | +- [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts) package. |
| 24 | + |
| 25 | +## Key Operational Parameters |
| 26 | + |
| 27 | +| Parameter | Unit | Purpose | |
| 28 | +| ----------------------------- | ------- | ------------------------------------------------------------------------------------ | |
| 29 | +| `underlyingSecondsForPayment` | seconds | The minimum time allowed for an agent to pay for a redemption. | |
| 30 | +| `underlyingBlocksForPayment` | blocks | The number of underlying blocks during which the agent can pay the underlying value. | |
| 31 | + |
| 32 | +Both values are defined per asset in the FAssets system and can be fetched from the [Asset Manager contract](/fassets/developer-guides/fassets-settings-solidity). |
| 33 | + |
| 34 | +## Monitoring the Redemption Window |
| 35 | + |
| 36 | +When a redemption is created, the [`RedemptionRequested`](/fassets/reference/IAssetManagerEvents#redemptionrequested) event is emitted by the Asset Manager contract. |
| 37 | + |
| 38 | +From this event, you can obtain the following: |
| 39 | + |
| 40 | +- `requestId` - unique identifier for the redemption. |
| 41 | +- `agentVault` - the agent vault responsible for payment. |
| 42 | +- `redeemer` - address requesting redemption. |
| 43 | +- `underlyingAddress` - the destination address on the underlying chain. |
| 44 | +- `paymentReference` - a unique hash for proof tracking. |
| 45 | +- `firstUnderlyingBlock` - the first underlying block to submit payment. |
| 46 | +- `lastUnderlyingBlock` - the last underlying block to submit payment. |
| 47 | +- `lastUnderlyingTimestamp` — the **deadline** on the underlying chain for submitting the redemption payment. |
| 48 | + |
| 49 | +You should wait until this deadline is passed and then check whether the agent has paid the redemption payment in the underlying chain. |
| 50 | +The [`RedemptionPaymentCompleted`](/fassets/reference/IAssetManagerEvents#redemptionpaymentcompleted) event is emitted by the Asset Manager contract when the redemption payment is completed. |
| 51 | + |
| 52 | +## Handling Non-Payment |
| 53 | + |
| 54 | +If the agent fails to pay the redemption payment in the underlying chain, the redeemer or the executor can start the redemption default process. |
| 55 | + |
| 56 | +### Generate the Proof of Payment Non-Existence |
| 57 | + |
| 58 | +With information from the [`RedemptionRequested`](/fassets/reference/IAssetManagerEvents#redemptionrequested) event, you can generate the attestation request for the [ReferencedPaymentNonexistence](/fdc/attestation-types/referenced-payment-nonexistence) attestation type. |
| 59 | + |
| 60 | +Use the following parameters: |
| 61 | + |
| 62 | +- `minimalBlockNumber`: The starting block number of the search range, which is the value of `firstUnderlyingBlock`. |
| 63 | +- `deadlineBlockNumber`: The block number to include as the end of the search range, which is the value of `lastUnderlyingBlock`. |
| 64 | +- `deadlineTimestamp`: The timestamp to include as the end of the search range, which is the value of `lastUnderlyingTimestamp`. |
| 65 | +- `destinationAddressHash`: The standard hash of the address where the payment was expected, which is the value of `underlyingAddress`. |
| 66 | +- `amount`: The required payment amount in minimal units, which is the value of `valueUBA`. |
| 67 | +- `standardPaymentReference`: The specific payment reference that should have been included, which is the value of `paymentReference`. |
| 68 | +- `checkSourceAddresses`: Not used in case of XRP Ledger, always set to false. |
| 69 | +- `sourceAddressesRoot`: Not used in case of XRP Ledger, always set to zero address. |
| 70 | + |
| 71 | +With this information, create the attestation request with the Flare Data Connector and wait for the attestation request to be confirmed. |
| 72 | + |
| 73 | +### Execute the Redemption Default |
| 74 | + |
| 75 | +After the attestation request is confirmed, you can retrieve the proof of payment non-existence of the redemption payment on the XRP Ledger. |
| 76 | + |
| 77 | +The redeemer or executor can execute the redemption default process by calling the [`redemptionPaymentDefault`](/fassets/reference/IAssetManager#redemptionpaymentdefault) function on the Asset Manager contract. |
| 78 | + |
| 79 | +This function requires two parameters: |
| 80 | + |
| 81 | +- `_proof`: The proof of payment non-existence of the redemption payment on the XRP Ledger. |
| 82 | +- `_redemptionRequestId`: The request ID of the redemption request. |
| 83 | + |
| 84 | +It does the following: |
| 85 | + |
| 86 | +- Checks if the proof of payment non-existence is valid. |
| 87 | +- Enough time has passed since the redemption request was created. |
| 88 | +- Executes the compensation payment to the redeemer or the executor from the agent's collateral. |
| 89 | +- Releases the agent's locked collateral. |
| 90 | +- Emits [`RedemptionDefaulted`](/fassets/reference/IAssetManagerEvents#redemptiondefault) event. |
| 91 | + |
| 92 | +## Summary |
| 93 | + |
| 94 | +In this guide, you learned how to monitor redemption requests and handle agent payment failures in the FAssets system: |
| 95 | + |
| 96 | +- **Monitor deadlines**: Track the [`RedemptionRequested`](/fassets/reference/IAssetManagerEvents#redemptionrequested) event and wait for the payment deadline to pass. |
| 97 | +- **Generate proof**: Create a [`ReferencedPaymentNonexistence`](/fdc/attestation-types/referenced-payment-nonexistence) attestation using the [Flare Data Connector](/fdc/overview). |
| 98 | +- **Execute default**: Call [`redemptionPaymentDefault`](/fassets/reference/IAssetManager#redemptionpaymentdefault) to trigger compensation from the agent's collateral. |
| 99 | + |
| 100 | +This process ensures redeemers can recover their funds when agents fail to fulfill payment obligations. |
| 101 | + |
| 102 | +:::tip Next Steps |
| 103 | +To continue your FAssets development journey, you can: |
| 104 | + |
| 105 | +- Understand how to [redeem FXRP](/fassets/developer-guides/fassets-redeem) |
| 106 | +- Learn how to [mint FXRP](/fassets/developer-guides/fassets-mint) |
| 107 | +- Explore [FAssets system settings](/fassets/operational-parameters) |
| 108 | + ::: |
0 commit comments