{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/swopme-co/json-schema/swopme-co-environment-policy-schema.json",
  "title": "EnvironmentPolicy",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/swopme-co-openapi.json#/components/schemas/EnvironmentPolicy",
  "type": "object",
  "required": [
    "allowedChains",
    "exportPolicy",
    "signingPolicy",
    "executionPolicy",
    "walletPolicy",
    "sessionPolicy",
    "recoveryPolicy"
  ],
  "properties": {
    "loginPolicy": {
      "type": "object",
      "properties": {
        "emailLogin": {
          "type": "boolean",
          "default": true
        },
        "smsLogin": {
          "type": "boolean",
          "default": false
        },
        "passkeyLogin": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "allowedChains": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Chain"
      }
    },
    "exportPolicy": {
      "type": "object",
      "required": [
        "enabled",
        "requireMfa"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "requireMfa": {
          "type": "boolean"
        }
      }
    },
    "signingPolicy": {
      "type": "object",
      "required": [
        "requireMfa",
        "allowRawSigning",
        "allowedKinds"
      ],
      "properties": {
        "requireMfa": {
          "type": "boolean"
        },
        "allowRawSigning": {
          "type": "boolean"
        },
        "allowedKinds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SigningIntentKind"
          }
        }
      }
    },
    "executionPolicy": {
      "type": "object",
      "required": [
        "requireMfa",
        "hostedExecution",
        "maxTransactionValueUsd",
        "sponsorship"
      ],
      "properties": {
        "requireMfa": {
          "type": "boolean"
        },
        "hostedExecution": {
          "type": "boolean"
        },
        "maxTransactionValueUsd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "sponsorship": {
          "type": "object",
          "required": [
            "enabled",
            "autoSponsorTransactions",
            "sponsoredNetworks"
          ],
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "autoSponsorTransactions": {
              "type": "boolean"
            },
            "sponsoredNetworks": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "allowClientTransactions": {
              "type": "boolean"
            },
            "maxSpendPerUserUsd": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "maxSpendPerDayUsd": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "allowedContractAddresses": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "solanaMode": {
              "type": "string",
              "enum": [
                "prefund",
                "fee_payer"
              ]
            },
            "evmMode": {
              "type": "string",
              "enum": [
                "prefund",
                "exact_gas"
              ]
            },
            "maxSponsoredTransactionsPerAccountPerDay": {
              "type": [
                "integer",
                "null"
              ]
            },
            "solanaMaxPriorityFeeLamports": {
              "type": "integer"
            },
            "solanaMaxTokenAccountCreations": {
              "type": "integer"
            },
            "relayerMode": {
              "type": "string",
              "enum": [
                "swivy_managed",
                "organization_managed"
              ]
            },
            "requireAdminApproval": {
              "type": "boolean"
            },
            "relayerPoolLabel": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "relayerUserTags": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "fundingSource": {
              "type": "object",
              "properties": {
                "rails": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "crypto",
                      "stripe"
                    ]
                  }
                },
                "allowUserDeposits": {
                  "type": "boolean"
                },
                "stripeEnabled": {
                  "type": "boolean"
                },
                "lowBalanceAlertUsd": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "depositAddresses": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "chain",
                      "network",
                      "assetSymbol",
                      "address",
                      "memo"
                    ],
                    "properties": {
                      "chain": {
                        "$ref": "#/$defs/Chain"
                      },
                      "network": {
                        "type": "string"
                      },
                      "assetSymbol": {
                        "type": "string"
                      },
                      "address": {
                        "type": "string"
                      },
                      "memo": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "walletToolPolicy": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "maxSwapValueUsd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "maxSlippageBps": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "evmAllowedTokenAddresses": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "solanaAllowedMints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "polymarket": {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean"
            },
            "agentTradingEnabled": {
              "type": "boolean"
            },
            "maxOrderValueUsd": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "maxStopLimitOrdersPerAccount": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "allowedConditionIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "allowedTokenIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "allowedJurisdictions": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "blockedJurisdictions": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "requireManagedTeeForAgents": {
              "type": "boolean"
            },
            "requireSplitCustodyForPersonal": {
              "type": "boolean"
            },
            "requirePasskeyApproval": {
              "type": "boolean"
            },
            "builderCode": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          }
        }
      }
    },
    "walletPolicy": {
      "type": "object",
      "required": [
        "allowManagedAccounts",
        "allowLinkedWallets",
        "allowSplitCustody",
        "defaultCustodyMode",
        "autoCreateManagedAccounts",
        "managedAccountChains"
      ],
      "properties": {
        "allowManagedAccounts": {
          "type": "boolean"
        },
        "allowLinkedWallets": {
          "type": "boolean"
        },
        "allowSplitCustody": {
          "type": "boolean"
        },
        "defaultCustodyMode": {
          "$ref": "#/$defs/CustodyMode"
        },
        "autoCreateManagedAccounts": {
          "type": "boolean"
        },
        "managedAccountChains": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Chain"
          }
        }
      }
    },
    "serverWalletPolicy": {
      "type": "object",
      "description": "When requireAuthorizationKey is true (the default), server wallets need an Ed25519 authorization key and every intent must be signed with it.",
      "required": [
        "requireAuthorizationKey"
      ],
      "properties": {
        "requireAuthorizationKey": {
          "type": "boolean"
        }
      }
    },
    "offlineSigningPolicy": {
      "type": "object",
      "required": [
        "enabled",
        "bluetoothMeshEnabled",
        "qrFallbackEnabled",
        "nfcFallbackEnabled",
        "fileFallbackEnabled",
        "requireSplitCustody",
        "requirePasskeyApproval",
        "allowRecoveryPackageSigning",
        "maxEnvelopeTtlSeconds"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "bluetoothMeshEnabled": {
          "type": "boolean"
        },
        "qrFallbackEnabled": {
          "type": "boolean"
        },
        "nfcFallbackEnabled": {
          "type": "boolean"
        },
        "fileFallbackEnabled": {
          "type": "boolean"
        },
        "requireSplitCustody": {
          "type": "boolean"
        },
        "requirePasskeyApproval": {
          "type": "boolean"
        },
        "allowRecoveryPackageSigning": {
          "type": "boolean"
        },
        "maxEnvelopeTtlSeconds": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "blockchainDataPolicy": {
      "type": "object",
      "required": [
        "enabled",
        "primaryProvider",
        "allowFallbackProviders",
        "providers"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "primaryProvider": {
          "type": "string",
          "enum": [
            "solscope",
            "helius",
            "solscan",
            "jupiter",
            "custom"
          ]
        },
        "allowFallbackProviders": {
          "type": "boolean"
        },
        "providers": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "enabled",
              "baseUrl",
              "apiKeySecretRef",
              "priority"
            ],
            "properties": {
              "id": {
                "type": "string",
                "enum": [
                  "solscope",
                  "helius",
                  "solscan",
                  "jupiter",
                  "custom"
                ]
              },
              "enabled": {
                "type": "boolean"
              },
              "baseUrl": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uri"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "apiKeySecretRef": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "priority": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        }
      }
    },
    "rpcProviderPolicy": {
      "type": "object",
      "required": [
        "enabled",
        "primaryProvider",
        "allowFallbackProviders",
        "autoImportNetworks",
        "controlPlaneUrl",
        "dataPlaneUrl",
        "projectId",
        "projectSecretRef",
        "providedNetworks"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "primaryProvider": {
          "type": "string",
          "enum": [
            "rpc-infra",
            "alchemy",
            "quicknode",
            "helius",
            "custom"
          ]
        },
        "allowFallbackProviders": {
          "type": "boolean"
        },
        "autoImportNetworks": {
          "type": "boolean"
        },
        "controlPlaneUrl": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri"
            },
            {
              "type": "null"
            }
          ]
        },
        "dataPlaneUrl": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri"
            },
            {
              "type": "null"
            }
          ]
        },
        "projectId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "projectSecretRef": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "providedNetworks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "key",
              "label",
              "chain",
              "chainId",
              "enabled",
              "rpcUrl",
              "wsUrl",
              "priority"
            ],
            "properties": {
              "key": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "chain": {
                "$ref": "#/$defs/Chain"
              },
              "chainId": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "enabled": {
                "type": "boolean"
              },
              "rpcUrl": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uri"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "wsUrl": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uri"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "priority": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        }
      }
    },
    "sessionPolicy": {
      "type": "object",
      "required": [
        "allowDelegatedSessionKeys",
        "requireMfa",
        "defaultExpirySeconds",
        "maxExpirySeconds",
        "allowedSigningKinds",
        "allowTransactionExecution",
        "allowedNetworks",
        "maxTransactionValueUsd"
      ],
      "properties": {
        "allowDelegatedSessionKeys": {
          "type": "boolean"
        },
        "requireMfa": {
          "type": "boolean"
        },
        "defaultExpirySeconds": {
          "type": "integer"
        },
        "maxExpirySeconds": {
          "type": "integer"
        },
        "allowedSigningKinds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SigningIntentKind"
          }
        },
        "allowTransactionExecution": {
          "type": "boolean"
        },
        "allowedNetworks": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "maxTransactionValueUsd": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "recoveryPolicy": {
      "type": "object",
      "required": [
        "allowEmailRecovery",
        "allowPasskeyRecovery",
        "allowSmsRecovery"
      ],
      "properties": {
        "allowEmailRecovery": {
          "type": "boolean"
        },
        "allowPasskeyRecovery": {
          "type": "boolean"
        },
        "allowSmsRecovery": {
          "type": "boolean"
        }
      }
    }
  },
  "$defs": {
    "Chain": {
      "type": "string",
      "enum": [
        "evm",
        "solana"
      ]
    },
    "CustodyMode": {
      "type": "string",
      "enum": [
        "managed_tee",
        "split_custody"
      ]
    },
    "SigningIntentKind": {
      "type": "string",
      "enum": [
        "sign_message",
        "sign_digest",
        "sign_typed_data",
        "sign_transaction"
      ]
    }
  }
}