{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/signo-fi/json-schema/signo-fi-shield-permission-request-schema.json",
  "title": "ShieldPermissionRequest",
  "description": "Draft an Execute permission on X Layer or Arbitrum One; the owner must authorize it separately. New Execute setup is in early access: an ineligible wallet gets a Prepare agent draft instead of 403 execute_team_only, and no proposal is stored. Asset fields accept a curated Signo symbol, a symbol on the chain's token list (OKX on X Layer, LI.FI on Arbitrum), or an ERC-20 address. Curated names resolve first; USDT aliases USDT0. If several listed tokens share a symbol, needs_clarification returns candidate addresses and token-page links so the caller can choose an address and retry. These symbols are not an allowlist for transfers or swaps; Aave actions require an Aave reserve. Drafting does not require the wallet to hold the budget yet.",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/signo-fi-openapi.yaml#/components/schemas/ShieldPermissionRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "wallet",
    "chain_id",
    "action",
    "trigger",
    "budget",
    "cap_per"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "enum": [
        2
      ]
    },
    "wallet": {
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]{40}$"
    },
    "chain_id": {
      "type": "integer",
      "enum": [
        196,
        42161
      ],
      "description": "X Layer (196) or Arbitrum One (42161). GET /api/shield/compile lists the live chains."
    },
    "budget": {
      "type": "string",
      "description": "Lifetime input-token budget before fees. The Shield fee comes on top; the registered lifetime cap and token approval include a rounded-up fee buffer. Must be at least cap_per, and may equal it. The wallet need not hold it at draft time; each firing checks its balance."
    },
    "cap_per": {
      "type": "string",
      "description": "Per-execution input-token cap before fees. Must be positive and no greater than budget (it may equal budget). The Shield fee comes on top."
    },
    "expiry_days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 90,
      "default": 30
    },
    "trigger": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "comparator",
            "value"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "health_factor"
              ]
            },
            "comparator": {
              "type": "string",
              "enum": [
                "<",
                "<=",
                ">",
                ">="
              ]
            },
            "value": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 100
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "asset",
            "comparator",
            "value"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "token_balance"
              ]
            },
            "asset": {
              "type": "string",
              "description": "Token symbol or ERC-20 address, resolved as described above; balance is in token units on the chain of the permission for the owner wallet."
            },
            "comparator": {
              "type": "string",
              "enum": [
                "<",
                "<=",
                ">",
                ">="
              ]
            },
            "value": {
              "type": "number",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "asset",
            "comparator",
            "value"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "price"
              ]
            },
            "asset": {
              "type": "string",
              "description": "Token symbol or ERC-20 address with an Aave oracle price on the chain of the permission (Chainlink-backed); the current USD price, never a move over a window."
            },
            "comparator": {
              "type": "string",
              "enum": [
                "<",
                "<=",
                ">",
                ">="
              ]
            },
            "value": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1000000000000
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "request"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "condition"
              ]
            },
            "request": {
              "type": "string",
              "minLength": 8,
              "maxLength": 2000,
              "description": "A supported plain-English Execute condition. Compiled by the same compiler as the app; the part the Shield can read is pinned and re-checked on chain, the rest is decided by the hourly check. Execute is not available for the app Portfolio move trigger; boxed Pendle PT loops are notify-only today. A recurring schedule is not an Execute trigger."
            }
          }
        }
      ]
    },
    "action": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "asset",
            "recipient"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "transfer"
              ]
            },
            "asset": {
              "type": "string"
            },
            "recipient": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "asset",
            "token_out"
          ],
          "description": "Provide exactly one of min_out or max_slippage_bps.",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "swap"
              ]
            },
            "asset": {
              "type": "string"
            },
            "token_out": {
              "type": "string"
            },
            "min_out": {
              "type": "string",
              "description": "Positive output-token floor per execution."
            },
            "max_slippage_bps": {
              "type": "integer",
              "minimum": 50,
              "maximum": 1000,
              "description": "Oracle-price slippage bound. A swap has no omitted default: provide this or min_out."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "vault"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "vault"
              ]
            },
            "vault": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            },
            "asset": {
              "type": "string"
            },
            "max_slippage_bps": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000,
              "default": 0
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "asset"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "supply",
                "repay_from_wallet"
              ],
              "description": "supply into Aave, or repay_from_wallet: repay Aave debt from the wallet balance. The pre-2026-09-25 name \"wallet\" is still accepted."
            },
            "asset": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "collateral",
            "debt",
            "target_health_factor"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "repay_from_collateral"
              ],
              "description": "Repay Aave debt by selling collateral down to target_health_factor. The pre-2026-09-25 name \"collateral\" is still accepted."
            },
            "collateral": {
              "type": "string"
            },
            "debt": {
              "type": "string"
            },
            "target_health_factor": {
              "type": "number",
              "exclusiveMinimum": 1,
              "maximum": 10
            },
            "max_slippage_bps": {
              "type": "integer",
              "minimum": 50,
              "maximum": 1000,
              "description": "Oracle-price slippage bound. Defaults to 100 bps on X Layer and 50 bps on Arbitrum when omitted."
            }
          }
        }
      ]
    }
  }
}