> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allium.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Avenia Pay 🌱

### Table Details

| Property     | Value                           |
| ------------ | ------------------------------- |
| Table Name   | `polygon.payments.avenia_pay`   |
| Table Status | Beta 🌱                         |
| Unique Key   | `transaction_hash`, `unique_id` |

### Table Columns

| Column Name                  | Data Type         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ---------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| block\_timestamp             | TIMESTAMP\_NTZ(9) | Timestamp (UTC) of the block that contains this record.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| block\_number                | NUMBER(38,0)      | Sequential number of the block that contains this record. Starts at 0 (genesis block) and increments by 1 for each new block.                                                                                                                                                                                                                                                                                                                                                               |
| transaction\_hash            | VARCHAR(66)       | Hash of the transaction that produced this record. Uniquely identifies a transaction within the blockchain.                                                                                                                                                                                                                                                                                                                                                                                 |
| log\_index                   | NUMBER(38,0)      | Zero-based position of this event log within its transaction. The first log emitted by a transaction has index 0.                                                                                                                                                                                                                                                                                                                                                                           |
| source\_contract             | VARCHAR(16777216) | Which of the two Avenia contracts emitted this event. `avenia_router` = `0xe41d3fcba696b67311dcb1c94193fb829fd6a0e2` (CentralizedBRLAUSDSwapV2 router/swap proxy, source of PixIn / PixOut / Swap / PartialUsdSwap / PartialBrlaSwap events). `brla_token` = `0xe6a537a407488807f0bbeb0038b79004f19dddfb` (BRLA ERC-20, source of Mint and Burn). Filter by this column to avoid double-counting — a single PIX-in flow fires both a router PixIn AND a token Mint in the same transaction. |
| contract\_address            | VARCHAR(42)       | Address of the smart contract that emitted this event or was called in this transaction.                                                                                                                                                                                                                                                                                                                                                                                                    |
| action                       | VARCHAR(16777216) | High-level action or operation type for this record. Values are model-specific (e.g. `deposit`, `withdraw`, `stake`, `unstake` in staking models).                                                                                                                                                                                                                                                                                                                                          |
| from\_address                | VARCHAR(42)       | Address that initiated or sent from in this event. For token transfers, the account whose balance decreased. For transactions, the transaction sender (msg.sender).                                                                                                                                                                                                                                                                                                                         |
| to\_address                  | VARCHAR(42)       | Address that received in this event. For token transfers, the account whose balance increased. For transactions, the destination address (may be a smart contract).                                                                                                                                                                                                                                                                                                                         |
| brla\_amount\_raw            | VARCHAR(16777216) | BRLA amount in raw 18-decimal integer units (the `uint256` value emitted on-chain before scaling).                                                                                                                                                                                                                                                                                                                                                                                          |
| brla\_amount                 | FLOAT             | BRLA amount in human-readable units (1 BRLA = 1 BRL). Decoded directly from event data for router events; sourced from the ERC-20 Transfer event for token Mint/Burn rows. Null on PartialUsdSwap (USD-only event).                                                                                                                                                                                                                                                                         |
| brla\_amount\_str            | VARCHAR(16777216) | BRLA amount as a string (preserves full precision for very large values that would lose digits in a numeric type).                                                                                                                                                                                                                                                                                                                                                                          |
| brla\_usd\_exchange\_rate    | FLOAT             | BRLA → USD exchange rate at block time, sourced from `int_common_markets__hydrated_prices_hourly` (CoinGecko, `chain='polygon'`, `symbol='brla'`). Hourly bucket first; falls back to the day's last hourly price when the exact hour is missing.                                                                                                                                                                                                                                           |
| brla\_usd\_value             | FLOAT             | USD value of the BRLA leg of this operation at block time. Computed as `brla_amount * brla_usd_exchange_rate`. Null for periods before 2024-09 where no BRLA price feed exists.                                                                                                                                                                                                                                                                                                             |
| usd\_token\_address          | VARCHAR(42)       | USD stablecoin contract address involved in a Swap or PartialUsdSwap event. Typically USDC native (`0x3c499c...`), USDC.e (`0x2791bca1...`), or USDT/USDT0 (`0xc2132d05...`). Null for events that do not involve a USD stablecoin (PixIn, PixOut, PartialBrlaSwap, Mint, Burn).                                                                                                                                                                                                            |
| usd\_token\_symbol           | VARCHAR(16777216) | Symbol of the USD stablecoin involved in this event (USDC, USDT, USDC.e). Null when no USD-side stablecoin is involved.                                                                                                                                                                                                                                                                                                                                                                     |
| usd\_token\_name             | VARCHAR(16777216) | Name of the USD stablecoin involved in this event. Null when no USD-side stablecoin is involved.                                                                                                                                                                                                                                                                                                                                                                                            |
| usd\_token\_amount\_raw      | VARCHAR(16777216) | USD-stablecoin amount in raw 6-decimal integer units, decoded directly from event data.                                                                                                                                                                                                                                                                                                                                                                                                     |
| usd\_token\_amount\_raw\_str | VARCHAR(16777216) | Raw USD-stablecoin amount as a string from the matched ERC-20 transfer.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| usd\_token\_amount           | FLOAT             | USD-stablecoin amount in human-readable units. Joined from the matching ERC-20 transfer in the same transaction. Null for events that do not involve a USD stablecoin transfer.                                                                                                                                                                                                                                                                                                             |
| usd\_token\_amount\_str      | VARCHAR(16777216) | USD-stablecoin amount as a string (preserves precision).                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| usd\_value                   | FLOAT             | USD value of the USD-stablecoin leg of this operation, sourced from `marts_polygon_assets__erc20_token_transfers`. Approximately equal to `usd_token_amount` since USDC/USDT are dollar-pegged.                                                                                                                                                                                                                                                                                             |
| usd\_exchange\_rate          | FLOAT             | USD price per unit of the token at the time of the event, used to compute `usd_amount`. Sourced from Allium's hourly price feed.                                                                                                                                                                                                                                                                                                                                                            |
| total\_usd\_value            | FLOAT             | Best USD valuation for the entire operation. Prefers the USDC/USDT leg (more reliable than BRL price feeds) and falls back to `brla_usd_value` when no USD-stablecoin leg is present (PixIn, PixOut, PartialBrlaSwap, Mint, Burn).                                                                                                                                                                                                                                                          |
| is\_usd\_to\_brla            | BOOLEAN           | Swap direction (only set for `Swap` action). `true` = the caller deposited USD and received BRLA (USD on-ramp). `false` = the caller deposited BRLA and received USD (USD off-ramp). Null for non-Swap rows.                                                                                                                                                                                                                                                                                |
| unique\_id                   | VARCHAR(16777216) | Allium's deterministic unique identifier for this row. Generated from the fields that uniquely identify the record (e.g. transaction hash + log index). Stable across full refreshes.                                                                                                                                                                                                                                                                                                       |
| \_created\_at                | TIMESTAMP\_NTZ(9) | Timestamp of when the entry was created in the database.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| \_updated\_at                | TIMESTAMP\_NTZ(9) | Timestamp of when the entry was last updated in the database.                                                                                                                                                                                                                                                                                                                                                                                                                               |
