{
  "openapi": "3.0.3",
  "info": {
    "title": "Risedle API",
    "version": "1.1.0"
  },
  "servers": [
    {
      "description": "Staging",
      "url": "https://apiedge.risedle.exchange"
    },
    {
      "description": "Production",
      "url": "https://api.risedle.exchange"
    },
    {
      "description": "Local",
      "url": "http://localhost:3000"
    }
  ],
  "tags": [
    {
      "name": "Fuse Leveraged Token",
      "description": "List of endpoint for Fuse Leveraged Token"
    }
  ],
  "paths": {
    "/v1/{chainId}/flts": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokensByChainId",
        "summary": "Get list of Fuse Leveraged Tokens on specific chain\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "List of Fuse Leveaged Token and the market information\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenInfo"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/flts/{symbol}": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokenBySymbol",
        "summary": "Get Fuse Leveraged Token by symbol",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "symbol",
            "schema": {
              "type": "string"
            },
            "example": "ETHRISE",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Fuse Leveraged Token info.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FuseLeveragedTokenInfo"
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/flts/{symbol}/charts": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokenChartsBySymbol",
        "summary": "Get Fuse Leveraged Token's historical prices, volumes and fees by symbol\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "symbol",
            "schema": {
              "type": "string"
            },
            "example": "ETHRISE",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Fuse Leveraged Token charts data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "prices": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenPrice"
                      }
                    },
                    "volumes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenVolume"
                      }
                    },
                    "fees": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenFee"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/flts/{symbol}/swaps": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokenSwapsBySymbol",
        "summary": "Get Fuse Leveraged Token's historical swaps by symbol and user address (optional)\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "symbol",
            "schema": {
              "type": "string"
            },
            "example": "ETHRISE",
            "required": true
          },
          {
            "in": "query",
            "name": "userAddress",
            "schema": {
              "type": "string"
            },
            "example": "0x1418be4753a22b69b613fa8b8144d856c023d46b"
          }
        ],
        "responses": {
          "200": {
            "description": "Fuse Leveraged Token swaps data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "flt": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenSwap"
                      }
                    },
                    "user": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenSwap"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/flts/{symbol}/backings": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokenBackingsBySymbol",
        "summary": "Get Fuse Leveraged Token's historical backings by symbol\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "symbol",
            "schema": {
              "type": "string"
            },
            "example": "ETHRISE",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Fuse Leveraged Token backings data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "backings": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenBacking"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/positions/{positionId}": {
      "get": {
        "tags": [
          "Fuse Leveraged Token"
        ],
        "operationId": "GetFuseLeveragedTokenUserOpenPosition",
        "summary": "Get user's open position by the position ID\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "positionId",
            "description": "user address - flt address",
            "schema": {
              "type": "string"
            },
            "example": "0x1418be4753a22b69b613fa8b8144d856c023d46b-0x4f7255178b8f15c2cbe92d09b8a77b53ef4ec9ea",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "User's open position",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FuseLeveragedTokenUserOpenPosition"
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/{chainId}/flts/insight/gains": {
      "get": {
        "tags": [
          "Insight Generator"
        ],
        "operationId": "GetFuseLeveragedTokensGains",
        "summary": "Get daily and weekly FLTs gains\n",
        "parameters": [
          {
            "in": "path",
            "name": "chainId",
            "schema": {
              "$ref": "#/components/schemas/ChainId"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Fuse Leveraged Tokens gains data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FuseLeveragedTokenGains"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chain ID not supported"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "description": "20 byte Ethereum address encoded as a hex with `0x` prefix",
        "type": "string",
        "example": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
      },
      "BigNumber": {
        "description": "Ethers.js BigNumber",
        "type": "string",
        "example": "1000000000"
      },
      "ChainId": {
        "description": "Chain ID",
        "type": "number",
        "example": 42161
      },
      "USD": {
        "description": "Price in USD terms",
        "type": "number",
        "format": "float",
        "example": 12.9879
      },
      "Percentage": {
        "description": "Percentage",
        "type": "number",
        "format": "float",
        "example": 99.88888888
      },
      "FuseLeveragedTokenBackingInfo": {
        "description": "Basic information of Fuse Leveraged Token underlying assets",
        "type": "object",
        "properties": {
          "name": {
            "description": "Asset's name",
            "type": "string",
            "example": "Wrapped ETH"
          },
          "symbol": {
            "description": "Asset's symbol",
            "type": "string",
            "example": "WETH"
          },
          "amount": {
            "description": "Asset's amount",
            "type": "number",
            "format": "float",
            "example": 1.2
          },
          "decimals": {
            "description": "Asset's decimals",
            "type": "number",
            "example": 18
          },
          "change": {
            "description": "Last 24h change",
            "type": "number",
            "format": "float",
            "example": 1.2
          },
          "changePercent": {
            "description": "Last 24h change in percentage",
            "type": "number",
            "format": "float",
            "example": 1.2
          }
        }
      },
      "FuseLeveragedTokenInfo": {
        "description": "Basic information of Fuse Leveraged Token",
        "type": "object",
        "properties": {
          "name": {
            "description": "Fuse Leveraged Token's name",
            "type": "string",
            "example": "2X Long ETH Risedle"
          },
          "symbol": {
            "description": "Fuse Leveraged Token's symbol",
            "type": "string",
            "example": "ETHRISE"
          },
          "decimals": {
            "description": "Fuse Leveraged Token's decimals",
            "type": "number",
            "example": 18
          },
          "address": {
            "description": "Fuse Leveraged Token's contract address",
            "$ref": "#/components/schemas/Address"
          },
          "priceUSD": {
            "description": "Current price in USD",
            "$ref": "#/components/schemas/USD"
          },
          "dailyPriceChangeUSD": {
            "description": "Price change (USD) in the last 24 hours. It can be negative.\n",
            "$ref": "#/components/schemas/USD"
          },
          "dailyPriceChangePercentage": {
            "description": "Price change (%) in the last 24 hours. It can be negative.\n",
            "$ref": "#/components/schemas/Percentage"
          },
          "totalVolumeUSD": {
            "description": "Total trade volume in USD",
            "$ref": "#/components/schemas/USD"
          },
          "dailyVolumeChangeUSD": {
            "description": "Volume change (USD) in the last 24 hours. It can be negative.\n",
            "$ref": "#/components/schemas/USD"
          },
          "dailyVolumeChangePercentage": {
            "description": "Volume change (%) in the last 24 hours. It can be negative.\n",
            "$ref": "#/components/schemas/Percentage"
          },
          "marketcapUSD": {
            "description": "Total supply times current price",
            "$ref": "#/components/schemas/USD"
          },
          "maxMarketcapUSD": {
            "description": "Max supply times current price",
            "$ref": "#/components/schemas/USD"
          },
          "collateral": {
            "description": "Collateral of Fuse Leveraged Token",
            "$ref": "#/components/schemas/FuseLeveragedTokenBackingInfo"
          },
          "debt": {
            "description": "Debt of Fuse Leveraged Token",
            "$ref": "#/components/schemas/FuseLeveragedTokenBackingInfo"
          },
          "totalCollateral": {
            "description": "Fuse Leveraged Token's total collateral",
            "type": "number",
            "example": 1.1
          },
          "totalDebt": {
            "description": "Fuse Leveraged Token's total debt",
            "type": "number",
            "example": 999
          }
        }
      },
      "FuseLeveragedTokenPrice": {
        "description": "Fuse Leveraged Token's price at given timestamp",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "open": {
            "description": "Open price in USD",
            "$ref": "#/components/schemas/USD"
          },
          "high": {
            "description": "The highest price in USD",
            "$ref": "#/components/schemas/USD"
          },
          "low": {
            "description": "The lowest price in USD",
            "$ref": "#/components/schemas/USD"
          },
          "close": {
            "description": "The lowest price in USD",
            "$ref": "#/components/schemas/USD"
          }
        }
      },
      "FuseLeveragedTokenVolume": {
        "description": "Fuse Leveraged Token's trade volume at given timestamp",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "usd": {
            "description": "Trade volume in USD",
            "$ref": "#/components/schemas/USD"
          }
        }
      },
      "FuseLeveragedTokenFee": {
        "description": "Fuse Leveraged Token's trade fee at given timestamp",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "usd": {
            "description": "Trade fee in USD",
            "$ref": "#/components/schemas/USD"
          }
        }
      },
      "FuseLeveragedTokenGains": {
        "description": "Fuse Leveraged Token's gain for daily and weekly timeframe",
        "type": "object",
        "properties": {
          "symbol": {
            "description": "Token's Symbol",
            "type": "string",
            "example": "BNBRISE"
          },
          "name": {
            "description": "Token's name",
            "type": "string",
            "example": "2X Long ETH Risedle"
          },
          "dailyGain": {
            "description": "Token's daily gain data",
            "$ref": "#/components/schemas/FuseLeveragedTokenDailyGain"
          },
          "weeklyGain": {
            "description": "Token's weekly gain data",
            "$ref": "#/components/schemas/FuseLeveragedTokenWeeklyGain"
          }
        }
      },
      "SwapTokenInfo": {
        "description": "Swap token info",
        "type": "object",
        "properties": {
          "name": {
            "description": "Token's name",
            "type": "string",
            "example": "2X Long ETH Risedle"
          },
          "symbol": {
            "description": "Token's symbol",
            "type": "string",
            "example": "ETHRISE"
          }
        }
      },
      "FuseLeveragedTokenSwap": {
        "description": "Fuse Leveraged Token's swap activity",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "hash": {
            "description": "Transaction hash",
            "type": "string",
            "example": "0x5b0824785cc2370f5d903532eb6b26f4154e90e2faa5864c9dac9ebb9a25d3df"
          },
          "user": {
            "description": "EOA that initiate the transaction",
            "type": "string",
            "example": "0x1418be4753a22b69b613fa8b8144d856c023d46b"
          },
          "tokenIn": {
            "description": "Input token",
            "$ref": "#/components/schemas/SwapTokenInfo"
          },
          "amountIn": {
            "description": "Token input amount",
            "type": "number",
            "format": "float",
            "example": 0.6
          },
          "amountInUSD": {
            "description": "Token input amount in USD",
            "$ref": "#/components/schemas/USD"
          },
          "tokenOut": {
            "description": "Output token",
            "$ref": "#/components/schemas/SwapTokenInfo"
          },
          "amountOut": {
            "description": "Token output amount",
            "type": "number",
            "format": "float",
            "example": 0.6
          },
          "amountOutUSD": {
            "description": "Token output amount in USD",
            "$ref": "#/components/schemas/USD"
          }
        }
      },
      "FuseLeveragedTokenBacking": {
        "description": "Fuse Leveraged Token's backing",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "collateralPerShare": {
            "description": "Collateral amount per Fuse Leveraged Token",
            "type": "number",
            "format": "float",
            "example": 0.6
          },
          "debtPerShare": {
            "description": "Debt amount per Fuse Leveraged Token",
            "type": "number",
            "format": "float",
            "example": 0.6
          },
          "valueUSD": {
            "description": "Price at given timestamp",
            "$ref": "#/components/schemas/USD"
          }
        }
      },
      "FuseLeveragedTokenUserOpenPosition": {
        "description": "User's open position",
        "type": "object",
        "properties": {
          "balance": {
            "description": "Current Fuse Leveraged Token Balance",
            "type": "number",
            "format": "float",
            "example": 0.6
          },
          "usd": {
            "description": "USD value",
            "$ref": "#/components/schemas/USD"
          },
          "pnlUSD": {
            "description": "Open p/l in USD",
            "$ref": "#/components/schemas/USD"
          },
          "pnlPercent": {
            "description": "Open p/l in percentage",
            "type": "number",
            "format": "float",
            "example": 10.03
          }
        }
      },
      "FuseLeveragedTokenDailyGain": {
        "description": "Daily FLT's gain data",
        "type": "object",
        "properties": {
          "timestamp": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "gain": {
            "description": "Price gain in percentage",
            "type": "number",
            "example": 4.12
          }
        }
      },
      "FuseLeveragedTokenWeeklyGain": {
        "description": "Weekly FLT's gain data",
        "type": "object",
        "properties": {
          "timestampStart": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "timestampEnd": {
            "description": "Unix timestamp in seconds",
            "type": "number",
            "example": 1657868400
          },
          "gain": {
            "description": "Price gain in percentage",
            "type": "number",
            "example": 4.12
          }
        }
      }
    }
  }
}