version: 2
models:
  - name: defi__fact_swaps
    description: "{{ doc('fact_swaps') }}"
    recent_date_filter: &recent_date_filter
      config:
        where: block_timestamp >= current_date - 7
    recent_modified_date_filter: &recent_modified_date_filter
      config:
        where: modified_timestamp >= current_date - 7
    tests:
      - reference_tx_missing:
          reference_tables:
            - 'silver__swaps_intermediate_bonkswap'
            - 'silver__swaps_intermediate_meteora'
            - 'silver__swaps_intermediate_dooar'
            - 'silver__swaps_intermediate_phoenix'
            - 'silver__swaps_intermediate_raydium_clmm'
            - 'silver__swaps_intermediate_raydium_stable'
            - 'silver__swaps_intermediate_raydium_v4_amm'
            - 'silver__swaps_pumpfun'
            - 'silver__swaps_intermediate_raydium_cpmm'
            - 'silver__swaps_pumpswap'
            - 'silver__swaps_intermediate_saber'
            - 'silver__swaps_intermediate_lifinity'
            - 'silver__swaps_intermediate_orca_whirlpool'
            - 'silver__swaps_intermediate_orca_token_swap'
            - 'silver__swaps_intermediate_meteora_bonding'
            - 'silver__swaps_pancakeswap'
          id_column: 'tx_id'
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_modified_date_filter
      - name: BLOCK_ID
        description: "{{ doc('block_id') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}" 
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SWAPPER
        description: "{{ doc('swaps_swapper') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SWAP_FROM_AMOUNT
        description: "{{ doc('swaps_from_amt') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SWAP_FROM_MINT
        description: "{{ doc('swaps_from_mint') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SWAP_TO_AMOUNT
        description: "{{ doc('swaps_to_amt') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: SWAP_TO_MINT
        description: "{{ doc('swaps_to_mint') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter
      - name: PROGRAM_ID
        description: "{{ doc('program_id') }}" 
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter

      - name: SWAP_PROGRAM
        description: "{{ doc('swap_program') }}"
        tests:
          - not_null: *recent_date_filter
      - name: _LOG_ID
        description: "{{ doc('log_id') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: FACT_SWAPS_ID
        description: "{{ doc('pk') }}"
        tests:
          - not_null: *recent_date_filter
          - unique: *recent_date_filter    
      - name: INSERTED_TIMESTAMP
        description: "{{ doc('inserted_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_date_filter    
      - name: MODIFIED_TIMESTAMP
        description: "{{ doc('modified_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist