{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "mode": {
      "const": "economic",
      "title": "Market Model",
      "type": "string"
    },
    "window": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        },
        "end_policy": {
          "enum": [
            "teardown",
            "mark"
          ]
        },
        "cleanup": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)(s|m|h|d)$"
            }
          ]
        }
      },
      "required": [
        "start",
        "end",
        "end_policy",
        "cleanup"
      ]
    },
    "inventory": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "funds": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "balances": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "asset": {
                      "type": "string",
                      "description": "Full CAIP-19 asset type"
                    },
                    "quantity": {
                      "oneOf": [
                        {
                          "type": "string",
                          "pattern": "^[0-9]+(\\.[0-9]+)?$"
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "base_units": {
                              "type": "integer",
                              "minimum": 0
                            }
                          },
                          "required": [
                            "base_units"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "asset",
                    "quantity"
                  ]
                }
              },
              "payer": {
                "type": "string"
              }
            },
            "required": [
              "balances"
            ]
          }
        },
        "payers": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "chain": {
                "description": "The payer's chain: CAIP-2 text on the public author root, the harness chain object otherwise",
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$"
                  },
                  {
                    "$ref": "#/$defs/Chain"
                  }
                ]
              },
              "balances": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "asset": {
                      "type": "string",
                      "description": "Full CAIP-19 asset type"
                    },
                    "quantity": {
                      "oneOf": [
                        {
                          "type": "string",
                          "pattern": "^[0-9]+(\\.[0-9]+)?$"
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "base_units": {
                              "type": "integer",
                              "minimum": 0
                            }
                          },
                          "required": [
                            "base_units"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "asset",
                    "quantity"
                  ]
                }
              }
            },
            "required": [
              "chain",
              "balances"
            ]
          }
        }
      },
      "required": [
        "funds"
      ]
    },
    "execution": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "latency": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)(s|m|h|d)$"
            }
          ]
        },
        "decision_interval": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)(s|m|h|d)$"
            }
          ]
        },
        "models": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "swap_model": {
              "const": "prepared_integer_pool",
              "title": "Swap Model",
              "type": "string"
            },
            "liquidity_model": {
              "anyOf": [
                {
                  "const": "fixed_historical_fee_growth",
                  "description": "Exact historical fee growth of each fixed range, without dilution.",
                  "type": "string"
                },
                {
                  "const": "bracketed_historical_fee_growth",
                  "description": "Required for band allocations: credits the fee growth continuously initialized sampled ticks prove accrued inside each concrete range and reports the upper bracket.",
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Liquidity Model"
            }
          },
          "required": [
            "swap_model"
          ]
        }
      },
      "required": [
        "latency"
      ]
    },
    "data": {
      "additionalProperties": false,
      "properties": {
        "sample_seconds": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)(s|m|h|d)$"
            }
          ]
        },
        "max_age_seconds": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "string",
              "pattern": "^(0|[1-9][0-9]*)(s|m|h|d)$"
            }
          ]
        },
        "max_samples": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Samples",
          "type": "integer"
        },
        "max_bitmap_words": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Bitmap Words",
          "type": "integer"
        },
        "max_initialized_ticks": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Initialized Ticks",
          "type": "integer"
        },
        "coverage": {
          "items": {
            "$ref": "#/$defs/Coverage"
          },
          "minItems": 1,
          "title": "Coverage",
          "type": "array"
        }
      },
      "required": [
        "sample_seconds",
        "max_age_seconds",
        "max_samples",
        "max_bitmap_words",
        "max_initialized_ticks",
        "coverage"
      ],
      "title": "PoolDataPolicy",
      "type": "object"
    },
    "costs": {
      "discriminator": {
        "mapping": {
          "excluded": "#/$defs/ExcludedCosts",
          "fixed_native": "#/$defs/EconomicCosts"
        },
        "propertyName": "kind"
      },
      "oneOf": [
        {
          "$ref": "#/$defs/ExcludedCosts"
        },
        {
          "$ref": "#/$defs/EconomicCosts"
        }
      ],
      "title": "Costs"
    }
  },
  "required": [
    "mode",
    "window",
    "inventory",
    "execution",
    "data",
    "costs"
  ],
  "$defs": {
    "Account": {
      "additionalProperties": false,
      "properties": {
        "chain": {
          "$ref": "#/$defs/Chain"
        },
        "address": {
          "title": "Address",
          "type": "string"
        }
      },
      "required": [
        "chain",
        "address"
      ],
      "title": "Account",
      "type": "object"
    },
    "AlchemyProvider": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "alchemy",
          "title": "Kind",
          "type": "string"
        },
        "network": {
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
          "title": "Network",
          "type": "string"
        },
        "api_key_env": {
          "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
          "title": "Api Key Env",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "network",
        "api_key_env"
      ],
      "title": "AlchemyProvider",
      "type": "object"
    },
    "AssetAmount": {
      "additionalProperties": false,
      "description": "Nonnegative base-unit amount with explicit asset identity.",
      "properties": {
        "asset": {
          "pattern": "^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$",
          "title": "Asset",
          "type": "string"
        },
        "amount": {
          "minimum": 0,
          "title": "Amount",
          "type": "integer"
        }
      },
      "required": [
        "asset",
        "amount"
      ],
      "title": "AssetAmount",
      "type": "object"
    },
    "Chain": {
      "additionalProperties": false,
      "properties": {
        "chain_id": {
          "pattern": "^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$",
          "title": "Chain Id",
          "type": "string"
        },
        "environment": {
          "minLength": 1,
          "title": "Environment",
          "type": "string"
        }
      },
      "required": [
        "chain_id",
        "environment"
      ],
      "title": "Chain",
      "type": "object"
    },
    "CollectionLimits": {
      "additionalProperties": false,
      "properties": {
        "max_in_flight": {
          "default": 4,
          "maximum": 64,
          "minimum": 1,
          "title": "Max In Flight",
          "type": "integer"
        },
        "batch_size": {
          "default": 32,
          "maximum": 32,
          "minimum": 1,
          "title": "Batch Size",
          "type": "integer"
        },
        "requests_per_second": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Requests Per Second"
        },
        "max_retries": {
          "default": 3,
          "maximum": 8,
          "minimum": 0,
          "title": "Max Retries",
          "type": "integer"
        }
      },
      "title": "CollectionLimits",
      "type": "object"
    },
    "Coverage": {
      "additionalProperties": false,
      "properties": {
        "allocation": {
          "minLength": 1,
          "pattern": "^\\S+$",
          "title": "Allocation",
          "type": "string"
        },
        "lower": {
          "maximum": 887272,
          "minimum": -887272,
          "title": "Lower",
          "type": "integer"
        },
        "upper": {
          "maximum": 887272,
          "minimum": -887272,
          "title": "Upper",
          "type": "integer"
        }
      },
      "required": [
        "allocation",
        "lower",
        "upper"
      ],
      "title": "Coverage",
      "type": "object"
    },
    "EconomicCosts": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "fixed_native",
          "title": "Kind",
          "type": "string"
        },
        "swap": {
          "minimum": 0,
          "title": "Swap",
          "type": "integer"
        },
        "mint": {
          "minimum": 0,
          "title": "Mint",
          "type": "integer"
        },
        "collect": {
          "minimum": 0,
          "title": "Collect",
          "type": "integer"
        },
        "burn": {
          "minimum": 0,
          "title": "Burn",
          "type": "integer"
        },
        "revoke": {
          "minimum": 0,
          "title": "Revoke",
          "type": "integer"
        }
      },
      "required": [
        "kind",
        "swap",
        "mint",
        "collect",
        "burn",
        "revoke"
      ],
      "title": "EconomicCosts",
      "type": "object"
    },
    "ExcludedCosts": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "excluded",
          "title": "Kind",
          "type": "string"
        }
      },
      "required": [
        "kind"
      ],
      "title": "ExcludedCosts",
      "type": "object"
    },
    "History": {
      "items": {
        "$ref": "#/$defs/HistoryBinding"
      },
      "minItems": 1,
      "title": "History",
      "type": "array"
    },
    "HistoryBinding": {
      "additionalProperties": false,
      "properties": {
        "chain": {
          "$ref": "#/$defs/Chain"
        },
        "provider": {
          "discriminator": {
            "mapping": {
              "alchemy": "#/$defs/AlchemyProvider",
              "rpc_url": "#/$defs/UrlProvider"
            },
            "propertyName": "kind"
          },
          "oneOf": [
            {
              "$ref": "#/$defs/AlchemyProvider"
            },
            {
              "$ref": "#/$defs/UrlProvider"
            }
          ],
          "title": "Provider"
        },
        "collection": {
          "$ref": "#/$defs/CollectionLimits",
          "default": {
            "max_in_flight": 4,
            "batch_size": 32,
            "requests_per_second": null,
            "max_retries": 3
          }
        }
      },
      "required": [
        "chain",
        "provider"
      ],
      "title": "HistoryBinding",
      "type": "object"
    },
    "PoolDataPolicy": {
      "additionalProperties": false,
      "properties": {
        "sample_seconds": {
          "exclusiveMinimum": 0,
          "title": "Sample Seconds",
          "type": "integer"
        },
        "max_age_seconds": {
          "exclusiveMinimum": 0,
          "title": "Max Age Seconds",
          "type": "integer"
        },
        "max_samples": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Samples",
          "type": "integer"
        },
        "max_bitmap_words": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Bitmap Words",
          "type": "integer"
        },
        "max_initialized_ticks": {
          "exclusiveMinimum": 0,
          "minimum": 0,
          "title": "Max Initialized Ticks",
          "type": "integer"
        },
        "coverage": {
          "items": {
            "$ref": "#/$defs/Coverage"
          },
          "minItems": 1,
          "title": "Coverage",
          "type": "array"
        }
      },
      "required": [
        "sample_seconds",
        "max_age_seconds",
        "max_samples",
        "max_bitmap_words",
        "max_initialized_ticks",
        "coverage"
      ],
      "title": "PoolDataPolicy",
      "type": "object"
    },
    "SafeRoles": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "safe_roles",
          "title": "Kind",
          "type": "string"
        },
        "fund": {
          "$ref": "#/$defs/Account"
        },
        "operator": {
          "$ref": "#/$defs/Account"
        },
        "roles_module": {
          "title": "Roles Module",
          "type": "string"
        },
        "role_key": {
          "pattern": "^0x[0-9a-f]{64}$",
          "title": "Role Key",
          "type": "string"
        },
        "safe_deployment_block": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Safe Deployment Block"
        },
        "roles_deployment_block": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Roles Deployment Block"
        }
      },
      "required": [
        "kind",
        "fund",
        "operator",
        "roles_module",
        "role_key"
      ],
      "title": "SafeRoles",
      "type": "object"
    },
    "Schedule": {
      "additionalProperties": false,
      "properties": {
        "start": {
          "maximum": 253402300799,
          "minimum": 0,
          "title": "Start",
          "type": "integer"
        },
        "end": {
          "maximum": 253402300799,
          "minimum": 0,
          "title": "End",
          "type": "integer"
        },
        "decision_interval_override_seconds": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Decision Interval Override Seconds"
        },
        "latency_seconds": {
          "minimum": 0,
          "title": "Latency Seconds",
          "type": "integer"
        },
        "end_policy": {
          "enum": [
            "mark_open",
            "teardown"
          ],
          "title": "End Policy",
          "type": "string"
        },
        "cleanup_seconds": {
          "minimum": 0,
          "title": "Cleanup Seconds",
          "type": "integer"
        }
      },
      "required": [
        "start",
        "end",
        "latency_seconds",
        "end_policy",
        "cleanup_seconds"
      ],
      "title": "Schedule",
      "type": "object"
    },
    "SimulationAccount": {
      "additionalProperties": false,
      "description": "An adapter identity without signing or installed account authority.",
      "properties": {
        "kind": {
          "const": "simulation",
          "default": "simulation",
          "title": "Kind",
          "type": "string"
        },
        "fund": {
          "$ref": "#/$defs/Account"
        },
        "payer": {
          "anyOf": [
            {
              "$ref": "#/$defs/Account"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "fund"
      ],
      "title": "SimulationAccount",
      "type": "object"
    },
    "UrlProvider": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "rpc_url",
          "title": "Kind",
          "type": "string"
        },
        "url_env": {
          "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
          "title": "Url Env",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "url_env"
      ],
      "title": "UrlProvider",
      "type": "object"
    },
    "almanak__backtest__config__Fund": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "minLength": 1,
          "pattern": "^\\S+$",
          "title": "Name",
          "type": "string"
        },
        "fund": {
          "$ref": "#/$defs/Account"
        },
        "balances": {
          "items": {
            "$ref": "#/$defs/AssetAmount"
          },
          "title": "Balances",
          "type": "array"
        }
      },
      "required": [
        "name",
        "fund",
        "balances"
      ],
      "title": "Fund",
      "type": "object"
    },
    "almanak__connectors__uniswap_v4__backtest_config__Fund": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "minLength": 1,
          "pattern": "^\\S+$",
          "title": "Name",
          "type": "string"
        },
        "profile": {
          "anyOf": [
            {
              "$ref": "#/$defs/SafeRoles"
            },
            {
              "$ref": "#/$defs/SimulationAccount"
            }
          ],
          "title": "Profile"
        },
        "balances": {
          "items": {
            "$ref": "#/$defs/AssetAmount"
          },
          "title": "Balances",
          "type": "array"
        }
      },
      "required": [
        "name",
        "profile",
        "balances"
      ],
      "title": "Fund",
      "type": "object"
    }
  }
}
