version: 2
models:
  - name: defi__fact_swaps_jupiter_summary
    description: "{{ doc('fact_swaps_jupiter_summary') }}"
    recent_date_filter: &recent_date_filter
      config:
        where: modified_timestamp >= current_date - 7
    tests:
      - reference_tx_missing:
          reference_tables:
            - 'silver__swaps_intermediate_jupiterv6_2'
            - 'silver__swaps_intermediate_jupiterv4_2'
          id_column: 'tx_id'
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null: *recent_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: INDEX
        description: "{{ doc('event_index') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - not_null:
              where: modified_timestamp >= current_date - 7 AND (program_id <> 'JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB' AND block_timestamp::date >= '2023-10-31')
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: SWAP_INDEX
        description: "{{ doc('swaps_swap_index') }}"
        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: PROGRAM_ID
        description: "{{ doc('program_id') }}"
        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: IS_DCA_SWAP
        description: "{{ doc('is_dca_swap') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: DCA_REQUESTER
        description: "{{ doc('dca_requester') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: IS_LIMIT_SWAP
        description: "{{ doc('is_limit_swap') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: LIMIT_REQUESTER
        description: "{{ doc('limit_requester') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
      - name: FACT_SWAPS_JUPITER_SUMMARY_ID
        description: "{{ doc('pk') }}"
        tests:
          - dbt_expectations.expect_column_to_exist
          - 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
