version: 2
models:
  - name: silver__liquidity_pools
    description: Table containing information on liquidity pools
    recent_date_filter: &recent_date_filter
      config:
        where: _inserted_timestamp >= current_date - 7
    columns:
      - name: POOL_ADDRESS
        description: "{{ doc('liquidity_pool_address') }}"
        data_tests: 
          - not_null
          - unique
      - name: POOL_NAME
        description: >
          Name of the liquidity pool
        data_tests: 
          - not_null:
              config:
                where: >
                  token_a_symbol IS NOT NULL
                  AND token_b_symbol IS NOT NULL
                  AND _inserted_timestamp >= current_date - 7
      - name: POOL_TOKEN_MINT
        description: "{{ doc('liquidity_pool_token_mint') }}"
      - name: TOKEN_A_MINT
        description:  "{{ doc('token_a_mint') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: TOKEN_A_SYMBOL
        description:  "{{ doc('prices_symbol') }}"
      - name: TOKEN_A_ACCOUNT
        description:  "{{ doc('token_a_account') }}"
        data_tests: 
          - not_null:
              # carried over from initialization_pools_meteora test config
              config:
                severity: error
                error_if: "> 31" 
      - name: TOKEN_B_MINT
        description:  "{{ doc('token_b_mint') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: TOKEN_B_SYMBOL
        description:  "{{ doc('prices_symbol') }}"
      - name: TOKEN_B_ACCOUNT
        description:  "{{ doc('token_b_account') }}"
        data_tests: 
          - not_null:
              # carried over from initialization_pools_meteora test config
              config:
                severity: error
                error_if: "> 31"
      - name: INITIALIZED_AT_BLOCK_TIMESTAMP
        description: "{{ doc('block_timestamp') }}"
        data_tests:
          - not_null: *recent_date_filter
      - name: INITIALIZED_AT_BLOCK_ID
        description: "{{ doc('block_id') }}"
        data_tests:
          - not_null: *recent_date_filter
      - name: INITIALIZED_AT_TX_ID
        description: "{{ doc('tx_id') }}"
        data_tests:
          - not_null: *recent_date_filter
      - name: INITIALIZED_AT_INDEX
        description: "{{ doc('event_index') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: INITIALIZED_AT_INNER_INDEX
        description: "{{ doc('inner_index') }}"
      - name: PROGRAM_ID
        description: "{{ doc('program_id') }}"
        data_tests: 
          - not_null: *recent_date_filter
      - name: PLATFORM
        description: >
          Name of the liquidity pool protocol
        data_tests: 
          - not_null: *recent_date_filter
      - name: LIQUIDITY_POOLS_ID
        description: '{{ doc("pk") }}'   
        data_tests: 
          - unique
      - name: INSERTED_TIMESTAMP
        description: '{{ doc("inserted_timestamp") }}'   
        data_tests: 
          - not_null: *recent_date_filter
      - name: MODIFIED_TIMESTAMP
        description: '{{ doc("modified_timestamp") }}' 
        data_tests: 
          - not_null: *recent_date_filter
      - name: _INVOCATION_ID
        description: '{{ doc("_invocation_id") }}' 
        data_tests: 
          - not_null: 
              name: test_silver__not_null_liquidity_pools__invocation_id
              <<: *recent_date_filter
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        data_tests: 
          - not_null
