version: 2
models:
  - name: silver__marinade_liquid_staking_actions
    description: Table capturing actions related to Marinade liquid staking, including deposits, unstakes, and claims.
    tests:
      - dbt_utils.unique_combination_of_columns:
          combination_of_columns:
            - TX_ID
            - INDEX
            - INNER_INDEX
          where: block_timestamp::date > current_date - 30
    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: 1
      - 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') }}"
      - name: ACTION_TYPE
        description: "{{ doc('action') }}"
        tests:
          - not_null: *recent_date_filter
      - name: PROVIDER_ADDRESS
        description: "{{ doc('liquidity_provider') }}"
        tests:
          - not_null: *recent_date_filter
      - name: DEPOSIT_AMOUNT
        description: "The amount of SOL deposited"
        tests: 
          - not_null:
              where: action_type = 'deposit' AND _inserted_timestamp >= current_date - 7
      - name: MSOL_MINTED
        description: "The amount of mSOL minted"
      - name: MSOL_BURNED
        description: "The amount of mSOL burned"
        tests: 
          - not_null:
              where: action_type = 'orderUnstake' AND _inserted_timestamp >= current_date - 7
      - name: CLAIM_AMOUNT
        description: "The amount of SOL claimed"
        tests: 
          - not_null:
              where: action_type = 'claim' AND _inserted_timestamp >= current_date - 7
      - name: PROGRAM_ID
        description: "{{ doc('program_id') }}"
        tests:
          - not_null: *recent_date_filter
      - name: _INSERTED_TIMESTAMP
        description: "{{ doc('_inserted_timestamp') }}"
        tests:
          - not_null: *recent_date_filter
      - name: MARINADE_LIQUID_STAKING_ACTIONS_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_liquid_staking_actions__invocation_id
              <<: *recent_date_filter
