version: 2
models:
  - name: silver__swaps_inner_intermediate_jupiterv6
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - INDEX
            - INNER_INDEX
            - SWAP_INDEX
          where: block_timestamp::date > current_date - 30
      - compare_model_subset:
          name: silver__swaps_inner_intermediate_jupiterv6_business_logic_test
          compare_model: ref('testing__swaps_inner_intermediate_jupiterv6')
          compare_columns: 
            - tx_id
            - index
            - inner_index
            - swap_index
            - swapper
            - from_mint
            - round(from_amount,2)
            - to_mint
            - round(to_amount,2)
            - swap_program_id
          model_condition: "where tx_id in ('4UkpYVPGr5uQnr1Zb7AuUrryF8qFYJvHJqGBVkjgQkJEbxTuR4tgx8NG7t329TbHkSUSUnj7E13c18ZQ6XbDf34T',
            'Cn7LBvp6iRdg3SMPbRsZx88kVzhDsRXt6EXxpqhH8DpwziLBbDuKh9Ay8cpiHiSRoXX7bVj5ueYtAU4wtWeGmFa',
            '4ExHEmvVXiXgGCHVWrfD8cshnQA3GvV84dTGbSsoXBr9NZHAoEDMHKiT8jY44AreyAkorc34UyNamJjKWbPgQQv9',
            '5UMtTnzJRZDnKYjM1nnVzU46gnys98EZySiUUkWEaWj2G82D7EhzxQHdPJ6nYDDd5T9dB7KanGQHKwWdXN5KXjGh',
            '5bnJuU5wkckz82WZLDPcA9v6uFwX1QJg7t9pL56cRbLc9VPNYaNKTo2ddRB1AECkSEmoHBYQsjtSLr7dguSGscUc',
            '3ho3m3EYmWy5T3GPvL83HQw2ntezXYXYiwqhJyV6izFGPUEkRMgtzT9Hp67ftvaXxCpbZH2W4LWTDR55G7DMEAcF',
            '32q7kcFadu2gzNSaTviBpdSfa9GHEuHb9JC8morJqUKGPtVa7ndknTJ1VBwFWFZ2un9kaqd8WbQxBAJUBjG5t71X')"  
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    columns:
      - name: BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        tests:
          - not_null: *recent_date_filter
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: day
              interval: 2
      - name: BLOCK_ID
        description: "{{ doc('block_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: TX_ID
        description: "{{ doc('tx_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: INDEX
        description: "{{ doc('event_index') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: INNER_INDEX
        description: "{{ doc('inner_index') }}. This is the inner index of the log event listing the inner swap"
        tests: 
          - not_null: *recent_date_filter
      - name: SWAP_INDEX
        description: "{{ doc('swaps_swap_index') }} as it relates to the top level Jupiter V6 swap instruction"
        tests: 
          - not_null: *recent_date_filter
      - name: SUCCEEDED
        description: "{{ doc('tx_succeeded') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: SWAP_PROGRAM_ID
        description: "{{ doc('program_id') }}. This is the AMM performing the swap. This will be NULL for new _v2 events introduced in Jupiter in Sept. 2025."
      - name: AGGREGATOR_PROGRAM_ID
        description: "{{ doc('program_id') }}. This is the aggregator calling the different AMMs."
        tests: 
          - not_null: *recent_date_filter
          - accepted_values:
              values: ['JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4']
              <<: *recent_date_filter
      - name: SWAPPER
        description: "{{ doc('swaps_swapper') }}"
        tests: 
          - not_null:
              where: _inserted_timestamp between current_date - 7 and current_date - 2 # allow it to be null during lookback buffer
      - name: FROM_AMOUNT
        description:  "{{ doc('swaps_from_amt') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: FROM_MINT
        description:  "{{ doc('swaps_from_mint') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: TO_AMOUNT
        description:  "{{ doc('swaps_to_amt') }}"
        tests: 
          - not_null: *recent_date_filter
      - name: TO_MINT
        description:  "{{ doc('swaps_to_mint') }}"
        tests: 
          - not_null: *recent_date_filter 
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests: 
          - not_null
      - name: SWAPS_INNER_INTERMEDIATE_JUPITERV6_ID
        description: '{{ doc("pk") }}'   
        tests: 
          - unique: *recent_date_filter
      - name: INSERTED_TIMESTAMP
        description: '{{ doc("inserted_timestamp") }}'   
        tests: 
          - not_null: *recent_date_filter
      - name: MODIFIED_TIMESTAMP
        description: '{{ doc("modified_timestamp") }}' 
        tests: 
          - not_null: *recent_date_filter
      - name: _INVOCATION_ID
        description: '{{ doc("_invocation_id") }}' 
        tests: 
          - not_null: 
              name: test_silver__not_null_swaps_inner_intermediate_jupiterv6__invocation_id
              <<: *recent_date_filter