GitBook: [#162] No subject

This commit is contained in:
Sidney Seo
2022-08-25 15:50:33 +00:00
committed by gitbook-bot
parent c9a4dcc7bf
commit 8f44ed85f6
6 changed files with 2888 additions and 93 deletions

View File

@@ -0,0 +1,863 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "1.0.6",
"title": "Swagger Petstore",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"basePath": "/v2",
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Access to Petstore orders"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"paths": {
"/pet/{petId}/uploadImage": {
"post": {
"tags": [
"pet"
],
"summary": "uploads an image",
"description": "",
"operationId": "uploadFile",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to update",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "additionalMetadata",
"in": "formData",
"description": "Additional data to pass to server",
"required": false,
"type": "string"
},
{
"name": "file",
"in": "formData",
"description": "file to upload",
"required": false,
"type": "file"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet": {
"post": {
"tags": [
"pet"
],
"summary": "Add a new pet to the store",
"description": "",
"operationId": "addPet",
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": true,
"schema": {
"$ref": "#/definitions/Pet"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"put": {
"tags": [
"pet"
],
"summary": "Update an existing pet",
"description": "",
"operationId": "updatePet",
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": true,
"schema": {
"$ref": "#/definitions/Pet"
}
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
},
"405": {
"description": "Validation exception"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/findByStatus": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by status",
"description": "Multiple status values can be provided with comma separated strings",
"operationId": "findPetsByStatus",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": true,
"type": "array",
"items": {
"type": "string",
"enum": [
"available",
"pending",
"sold"
],
"default": "available"
},
"collectionFormat": "multi"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"400": {
"description": "Invalid status value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/findByTags": {
"get": {
"tags": [
"pet"
],
"summary": "Finds Pets by tags",
"description": "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
"operationId": "findPetsByTags",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "tags",
"in": "query",
"description": "Tags to filter by",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"400": {
"description": "Invalid tag value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
],
"deprecated": true
}
},
"/pet/{petId}": {
"get": {
"tags": [
"pet"
],
"summary": "Find pet by ID",
"description": "Returns a single pet",
"operationId": "getPetById",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet to return",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
}
},
"security": [
{
"api_key": [
]
}
]
},
"post": {
"tags": [
"pet"
],
"summary": "Updates a pet in the store with form data",
"description": "",
"operationId": "updatePetWithForm",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "ID of pet that needs to be updated",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "name",
"in": "formData",
"description": "Updated name of the pet",
"required": false,
"type": "string"
},
{
"name": "status",
"in": "formData",
"description": "Updated status of the pet",
"required": false,
"type": "string"
}
],
"responses": {
"405": {
"description": "Invalid input"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
},
"delete": {
"tags": [
"pet"
],
"summary": "Deletes a pet",
"description": "",
"operationId": "deletePet",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "api_key",
"in": "header",
"required": false,
"type": "string"
},
{
"name": "petId",
"in": "path",
"description": "Pet id to delete",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Pet not found"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/store/order": {
"post": {
"tags": [
"store"
],
"summary": "Place an order for a pet",
"description": "",
"operationId": "placeOrder",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "order placed for purchasing the pet",
"required": true,
"schema": {
"$ref": "#/definitions/Order"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid Order"
}
}
}
},
"/store/order/{orderId}": {
"get": {
"tags": [
"store"
],
"summary": "Find purchase order by ID",
"description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions",
"operationId": "getOrderById",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of pet that needs to be fetched",
"required": true,
"type": "integer",
"maximum": 10,
"minimum": 1,
"format": "int64"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Order"
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Order not found"
}
}
},
"delete": {
"tags": [
"store"
],
"summary": "Delete purchase order by ID",
"description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors",
"operationId": "deleteOrder",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "orderId",
"in": "path",
"description": "ID of the order that needs to be deleted",
"required": true,
"type": "integer",
"minimum": 1,
"format": "int64"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Order not found"
}
}
}
},
"/store/inventory": {
"get": {
"tags": [
"store"
],
"summary": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"operationId": "getInventory",
"produces": [
"application/json"
],
"parameters": [
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int32"
}
}
}
},
"security": [
{
"api_key": [
]
}
]
}
},
"/user/createWithArray": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithArrayInput",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "List of user object",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/createWithList": {
"post": {
"tags": [
"user"
],
"summary": "Creates list of users with given input array",
"description": "",
"operationId": "createUsersWithListInput",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "List of user object",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user/{username}": {
"get": {
"tags": [
"user"
],
"summary": "Get user by user name",
"description": "",
"operationId": "getUserByName",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be fetched. Use user1 for testing. ",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/User"
}
},
"400": {
"description": "Invalid username supplied"
},
"404": {
"description": "User not found"
}
}
},
"put": {
"tags": [
"user"
],
"summary": "Updated user",
"description": "This can only be done by the logged in user.",
"operationId": "updateUser",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "name that need to be updated",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "Updated user object",
"required": true,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"400": {
"description": "Invalid user supplied"
},
"404": {
"description": "User not found"
}
}
},
"delete": {
"tags": [
"user"
],
"summary": "Delete user",
"description": "This can only be done by the logged in user.",
"operationId": "deleteUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "path",
"description": "The name that needs to be deleted",
"required": true,
"type": "string"
}
],
"responses": {
"400": {
"description": "Invalid username supplied"
},
"404": {
"description": "User not found"
}
}
}
},
"/user/login": {
"get": {
"tags": [
"user"
],
"summary": "Logs user into the system",
"description": "",
"operationId": "loginUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "username",
"in": "query",
"description": "The user name for login",
"required": true,
"type": "string"
},
{
"name": "password",
"in": "query",
"description": "The password for login in clear text",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"400": {
"description": "Invalid username/password supplied"
}
}
}
},
"/user/logout": {
"get": {
"tags": [
"user"
],
"summary": "Logs out current logged in user session",
"description": "",
"operationId": "logoutUser",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
},
"/user": {
"post": {
"tags": [
"user"
],
"summary": "Create user",
"description": "This can only be done by the logged in user.",
"operationId": "createUser",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Created user object",
"required": true,
"schema": {
"$ref": "#/definitions/User"
}
}
],
"responses": {
"default": {
"description": "successful operation"
}
}
}
}
}
}

1037
.gitbook/assets/erase.json Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -0,0 +1,822 @@
{
"openapi": "3.0.0",
"paths": {
"/v1/allswaps": {
"get": {
"operationId": "PoolController_getAllSwaps",
"summary": "Returns all existing swaps with status",
"parameters": [],
"responses": {
"200": {
"description": "Succesfully returning all existing swaps",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/pool_stats/{pool_token}": {
"get": {
"operationId": "PoolController_getPriceHistory",
"summary": "Returns pool stats",
"parameters": [
{
"name": "pool_token",
"required": true,
"in": "path",
"description": "pool token of swap pool eg. fwp-alex-wslm",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning pool stats",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/pool_volume/{pool_token}": {
"get": {
"operationId": "PoolController_getPoolVolumeHistory",
"summary": "Returns all 24 hour pool volumes in time series",
"parameters": [
{
"name": "pool_token",
"required": true,
"in": "path",
"description": "pool token of swap pool eg. fwp-alex-wslm",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning volumes",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/volume_24h/{token}": {
"get": {
"operationId": "PoolController_getVolume24HRHistory",
"summary": "Returns daily volumes of token in time series",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"description": "name of token eg. age000-governance-token",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning volumes"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/volume_7d/{token}": {
"get": {
"operationId": "PoolController_getVolume7DHistory",
"summary": "Returns weekly volumes of token in time series",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"description": "name of token eg. age000-governance-token",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning volumes"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/pool_liquidity/{pool_token}": {
"get": {
"operationId": "PoolController_getPoolLiquidityHistory",
"summary": "Returns liquidity in time series",
"parameters": [
{
"name": "pool_token",
"required": true,
"in": "path",
"description": "pool token of swap pool eg. fwp-alex-wslm",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning liquidity"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/liquidity/{token}": {
"get": {
"operationId": "PoolController_getLiquidityHistory",
"summary": "Returns liquidity of token in time series",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"description": "name of token eg. age000-governance-token",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": false,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning liquidity"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/fee/{pool_token}": {
"get": {
"operationId": "PoolController_getFeeHistory",
"summary": "Returns pool fee in time series",
"parameters": [
{
"name": "pool_token",
"required": true,
"in": "path",
"description": "pool token of swap pool eg. fwp-alex-wslm",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning fee"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"pool"
]
}
},
"/v1/stats/tvl": {
"get": {
"operationId": "StatsController_getTVL",
"summary": "Returns total TVL(total value locked) value of ALEX platform",
"parameters": [],
"responses": {
"200": {
"description": "Succesfully returning TVL"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"stats"
]
}
},
"/v1/stats/tvl/{token}": {
"get": {
"operationId": "StatsController_getTokenTVL",
"summary": "Returns token TVL(total value locked) in time series",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": false,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning liquidity",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"stats"
]
}
},
"/v1/stats/total_supply/{token}": {
"get": {
"operationId": "StatsController_getTotalSupply",
"summary": "Returns total supply of queried token eg. age000-governance-token",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Succesfully returning total supply"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"stats"
]
}
},
"/v1/price/{token}": {
"get": {
"operationId": "PriceController_getPrice",
"summary": "Returns price of token",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"description": "name of token eg. age000-governance-token",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
}
],
"responses": {
"200": {
"description": "Succesfully returning price"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"price"
]
}
},
"/v1/pool_token_price/{pool_token}": {
"get": {
"operationId": "PriceController_getPoolTokenPrice",
"summary": "Returns pool token price value of ALEX platform",
"parameters": [
{
"name": "pool_token",
"required": true,
"in": "path",
"description": "pool token of swap pool eg. fwp-alex-wslm",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
}
],
"responses": {
"200": {
"description": "Succesfully returning Pool token price"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"price"
]
}
},
"/v1/pool_token_stats": {
"get": {
"operationId": "PriceController_getAllPoolTokenPrice",
"summary": "Returns pool token price value of ALEX platform",
"parameters": [],
"responses": {
"200": {
"description": "Succesfully returning all existing pool token stats"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"price"
]
}
},
"/v1/price_history/{token}": {
"get": {
"operationId": "PriceController_getPriceHistory",
"summary": "Returns price history of token",
"parameters": [
{
"name": "token",
"required": true,
"in": "path",
"description": "name of token eg. age000-governance-token",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "offset",
"required": false,
"in": "query",
"description": "Specifies the offset of data to be returned, default value is 0",
"schema": {}
},
{
"name": "limit",
"required": false,
"in": "query",
"description": "Specifies number of data to be returned, default value is 10",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning price history"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"price"
]
}
},
"/v1/pairs": {
"get": {
"operationId": "DexController_getAllPairs",
"summary": "Returns all existing pairs",
"parameters": [],
"responses": {
"200": {
"description": "Succesfully returning all existing pairs"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"dex"
]
}
},
"/v1/tickers": {
"get": {
"operationId": "DexController_getAllTickers",
"summary": "Returns all markets statistics for the last 24 hours",
"parameters": [],
"responses": {
"200": {
"description": "Succesfully returning all markets statistics for the last 24 hours"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"dex"
]
}
},
"/v1/historical_swaps/{ticker}": {
"get": {
"operationId": "DexController_getHistoricalTrades",
"summary": "Returns all existing historical trades",
"parameters": [
{
"name": "ticker",
"required": true,
"in": "path",
"description": "A ticker with delimiter between different cryptoassets eg. ALEX_WSLM",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "limit",
"required": true,
"in": "query",
"description": "Specifies number of recent block heights to be returned, default value is 1000",
"schema": {}
}
],
"responses": {
"200": {
"description": "Succesfully returning all historical trades of certain ticker"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"dex"
]
}
},
"/v1/orderbook/{ticker_id}": {
"get": {
"operationId": "DexController_getOrderBookDepth",
"summary": "Returns orderbook information",
"parameters": [
{
"name": "ticker_id",
"required": true,
"in": "path",
"description": "A ticker with delimiter between different cryptoassets eg. ALEX_WSLM",
"schema": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
}
},
{
"name": "depth",
"required": true,
"in": "query",
"description": "Specifies value of depth on either side of bid/ask",
"schema": {}
}
],
"responses": {
"200": {
"description": "Return orderbook information of queried ticker"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
},
"tags": [
"dex"
]
}
}
},
"info": {
"title": "Alex REST API",
"description": "Alex Open API service",
"version": "1.0",
"contact": {
"name": "ALEX DEV Team",
"url": "https://app.alexgo.io",
"email": "sidney@alexgo.io"
}
},
"tags": [
{
"name": "ALEX REST API",
"description": "ALEX Open API for public usage"
}
],
"servers": [],
"components": {
"securitySchemes": {
"bearer": {
"scheme": "bearer",
"bearerFormat": "JWT",
"type": "http"
}
},
"schemas": {}
},
"definitions": {
"ApiResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
}

View File

@@ -6,7 +6,9 @@ Documentation is also available in json format at [https://api.alexlab.co/swagge
### General
{% swagger src="https://api.alexlab.co/swagger-api.json" path="/v1/pool_stats/{pool_token}" method="get" %}
{% swagger src="https://api.alexlab.co/swagger-api.json" path="undefined" method="undefined" %}
[https://api.alexlab.co/swagger-api.json](https://api.alexlab.co/swagger-api.json)
{% endswagger %}
@@ -64,18 +66,138 @@ Documentation is also available in json format at [https://api.alexlab.co/swagge
### DEX
{% swagger src="https://api.alexlab.co/swagger-api.json" path="/v1/pairs" method="get" %}
[https://api.alexlab.co/swagger-api.json](https://api.alexlab.co/swagger-api.json)
{% swagger method="get" path="" baseUrl="https://api.alexlab.co/v1/pairs" summary="" %}
{% swagger-description %}
Returns all existing pairs
{% endswagger-description %}
{% swagger-response status="200: OK" description="Succesfully returning all existing pairs" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="403: Forbidden" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="404: Not Found" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% endswagger %}
{% swagger src="https://api.alexlab.co/swagger-api.json" path="/v1/tickers" method="get" %}
[https://api.alexlab.co/swagger-api.json](https://api.alexlab.co/swagger-api.json)
{% swagger method="get" path="" baseUrl="https://api.alexlab.co/v1/tickers" summary="" %}
{% swagger-description %}
Returns all markets statistics for the last 24 hours
{% endswagger-description %}
{% swagger-response status="200: OK" description="uccesfully returning all markets statistics for the last 24 hours" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="403: Forbidden" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="404: Not Found" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% endswagger %}
{% swagger src="https://api.alexlab.co/swagger-api.json" path="/v1/historical_swaps/{ticker}" method="get" %}
[https://api.alexlab.co/swagger-api.json](https://api.alexlab.co/swagger-api.json)
{% swagger method="get" path="" baseUrl="https://api.alexlab.co/v1/historical_swaps" summary="" %}
{% swagger-description %}
Returns all existing historical trades
{% endswagger-description %}
{% swagger-parameter in="path" name="ticker" required="true" %}
ticker with delimiter between different cryptoassets eg. ALEX_WSLM
{% endswagger-parameter %}
{% swagger-parameter in="query" name="limit" type="Int" %}
Specifies number of recent block heights to be returned, default value is 1000
{% endswagger-parameter %}
{% swagger-response status="200: OK" description="Succesfully returning all historical trades of certain ticker" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="403: Forbidden" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="404: Not Found" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% endswagger %}
{% swagger src="https://api.alexlab.co/swagger-api.json" path="/v1/orderbook/{ticker_id}" method="get" %}
[https://api.alexlab.co/swagger-api.json](https://api.alexlab.co/swagger-api.json)
{% swagger method="get" path="" baseUrl="https://api.alexlab.co/v1/orderbook" summary="" %}
{% swagger-description %}
Returns orderbook information
{% endswagger-description %}
{% swagger-parameter in="path" name="ticker_id" required="true" %}
ticker with delimiter between different cryptoassets eg. ALEX_WSLM
{% endswagger-parameter %}
{% swagger-parameter in="query" name="depth" required="true" type="Int" %}
specifies value of depth on either side of bid/ask
{% endswagger-parameter %}
{% swagger-response status="200: OK" description="Return orderbook information of queried ticker" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="403: Forbidden" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% swagger-response status="404: Not Found" description="" %}
```javascript
{
// Response
}
```
{% endswagger-response %}
{% endswagger %}

View File

@@ -2,7 +2,7 @@
## Abstract
ALEX aims to provide a fixed rate borrowing and lending service with pre-determined maturity in the world of decentralised finance \(DeFi\). We include forward contracts in our trading pool, with Automated Market Making \(AMM\) engine in association with generalised mean. While we formalise the trading practise swapping forward contracts with underlying asset, we incorporate the latest innovation in the industry - concentrated liquidity. Consequently, liquidity provider of ALEX can save decent amount of capital by making markets on a selected range of interest rate.
ALEX aims to provide a fixed rate borrowing and lending service with pre-determined maturity in the world of decentralised finance (DeFi). We include forward contracts in our trading pool, with Automated Market Making (AMM) engine in association with generalised mean. While we formalise the trading practise swapping forward contracts with underlying asset, we incorporate the latest innovation in the industry - concentrated liquidity. Consequently, liquidity provider of ALEX can save decent amount of capital by making markets on a selected range of interest rate.
## Introduction
@@ -16,7 +16,7 @@ This paper focuses on technical aspects of AMM and is the first of a series of A
## AMM and Invariant Function
ALEX AMM is built on three beliefs: \(i\) it is mathematically neat and reflect economic demand and supply; \(ii\) it is a type of mean, like other AMMs; and \(iii\) it is derived and can be interpreted in terms of yield and is somehow related to conventional finance, where research has been conducted for decades.
ALEX AMM is built on three beliefs: (i) it is mathematically neat and reflect economic demand and supply; (ii) it is a type of mean, like other AMMs; and (iii) it is derived and can be interpreted in terms of yield and is somehow related to conventional finance, where research has been conducted for decades.
We will firstly review some desirable features of AMM that ALEX hopes to exhibit.
@@ -27,7 +27,7 @@ AMM protocol, which provides liquidity algorithmically, is the core engine of De
* monotonically decreasing, i.e. $$\frac{dg(x_1)}{dx_1}<0$$. This is because price is often defined as $$-\frac{dg(x_1)}{dx_1}$$. A decreasing function ensures price to be positive.
* convex, i.e. $$\frac{d^2g(x_1)}{dx_1^2} \geq 0$$. This is equivalent to say that $$-\frac{dg(x_1)}{dx_1}$$ is a non-increasing function of $$x_1$$. It is within the expectation of economic theory of demand and supply, as more reserve of $$x_1$$ means declining price.
Meanwhile, $$f$$ can usually be interpreted as a form of mean, for example, [mStable](https://docs.mstable.org) relates to arithmetic mean, where $$x_1+x_2=L$$ \(constant sum formula\); one of the most popular platforms [Uniswap](https://uniswap.org/whitepaper-v3.pdf) relates to geometric mean, where $$x_1 x_2=L$$ \(constant product formula\); [Balancer](https://balancer.fi/whitepaper.pdf), which our collateral rebalancing pool employs, applies weighted geometric mean. Its AMM is $$x_1^{w_1} x_2^{w_2}=L$$ where $$w_1$$ and $$w_2$$ are fixed weights. However, none of these three protocols consider time to maturity, which is essential in modern interest rate theory.
Meanwhile, $$f$$ can usually be interpreted as a form of mean, for example, [mStable](https://docs.mstable.org) relates to arithmetic mean, where $$x_1+x_2=L$$ (constant sum formula); one of the most popular platforms [Uniswap](https://uniswap.org/whitepaper-v3.pdf) relates to geometric mean, where $$x_1 x_2=L$$ (constant product formula); [Balancer](https://balancer.fi/whitepaper.pdf), which our collateral rebalancing pool employs, applies weighted geometric mean. Its AMM is $$x_1^{w_1} x_2^{w_2}=L$$ where $$w_1$$ and $$w_2$$ are fixed weights. However, none of these three protocols consider time to maturity, which is essential in modern interest rate theory.
### ALEX AMM
@@ -45,7 +45,7 @@ $$
x_1^p+x_2^p=L
$$
This equation is regarded reasonable as AMM, because \(i\) function $$g$$ where $$x_2=g(x_1)$$ is monotonically decreasing and convex; and \(ii\) The boundary value of $$p=1$$ and $$p=0$$ corresponds to constant sum and constant product formula respectively. When $$p$$ increases from 0 to 1, price $$-\frac{dg(x_1)}{x_1}$$ gradually converges to 1. This is what ALEX hopes to achieve when forward becomes spot. This also means that $$p$$ is somehow related to time to maturity. Please refer to [Appendix 1](automated-market-making-of-alex.md#appendix-1-generalised-mean-when-d-2) for a detailed discussion.
This equation is regarded reasonable as AMM, because (i) function $$g$$ where $$x_2=g(x_1)$$ is monotonically decreasing and convex; and (ii) The boundary value of $$p=1$$ and $$p=0$$ corresponds to constant sum and constant product formula respectively. When $$p$$ increases from 0 to 1, price $$-\frac{dg(x_1)}{x_1}$$ gradually converges to 1. This is what ALEX hopes to achieve when forward becomes spot. This also means that $$p$$ is somehow related to time to maturity. Please refer to [Appendix 1](automated-market-making-of-alex.md#appendix-1-generalised-mean-when-d-2) for a detailed discussion.
In the benchmark research piece by [Yield Space](https://yield.is/YieldSpace.pdf), the invariant function above is formalised from the perspective of zero coupon bond. $$p$$ is replaced by $$1-t$$ where $$t$$ is time to maturity and $$L$$ is a function of $$t$$, so that
@@ -59,8 +59,6 @@ $$
-\frac{dx_2}{dx_1}=\left(\frac{x_2}{x_1} \right)^t
$$
In the rest of the paper, to be consistent with [Yield Space](https://yield.is/YieldSpace.pdf), we employ notations below
* $$x$$ : balance of the underlying Token
@@ -104,10 +102,7 @@ $$
When transaction cost exists, the actual deposit to the pool is less than $$\Delta x$$. Assuming $$\lambda\Delta x$$ is the actual amount and $$(1-\lambda)\Delta x$$ is the fee, above can now be expressed as
$$
\begin{split}
&(x+\lambda\Delta x)^{1-t}+(y-\Delta y)^{1-t}=x^{1-t}+y^{1-t}\\
&\Delta y=y-\left[x^{1-t}+y^{1-t}-(x+\lambda\Delta x)^{1-t}\right]^{\frac{1}{1-t}}
\end{split}
\begin{split} &(x+\lambda\Delta x)^{1-t}+(y-\Delta y)^{1-t}=x^{1-t}+y^{1-t}\\ &\Delta y=y-\left[x^{1-t}+y^{1-t}-(x+\lambda\Delta x)^{1-t}\right]^{\frac{1}{1-t}} \end{split}
$$
To keep $$L$$ constant, the updated balance is: $$x\rightarrow x+\lambda\Delta x$$ and $$y\rightarrow y-\Delta y$$.
@@ -131,16 +126,9 @@ $$
Then, the added amount of $$\Delta x$$ can be calculated from the formula below
$$
\begin{split}
&(x+\lambda\Delta x)^{1-t}+(y-\Delta y)^{1-t}=x^{1-t}+y^{1-t}\\
&1+\left(\frac{y}{x}\right)^{1-t}=\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}+(\frac{y-\Delta y}{x})^{1-t}\\
&1+p^{\frac{1-t}{t}}=\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}+p'^{\frac{1-t}{t}}\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}\\
&\Delta x=\frac{x}{\lambda}\left[\left(\frac{1+p^{\frac{1-t}{t}}}{1+p'^{\frac{1-t}{t}}}\right)^{\frac{1}{1-t}}-1\right]\\
\end{split}
\begin{split} &(x+\lambda\Delta x)^{1-t}+(y-\Delta y)^{1-t}=x^{1-t}+y^{1-t}\\ &1+\left(\frac{y}{x}\right)^{1-t}=\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}+(\frac{y-\Delta y}{x})^{1-t}\\ &1+p^{\frac{1-t}{t}}=\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}+p'^{\frac{1-t}{t}}\left(1+\lambda\frac{\Delta x}{x}\right)^{1-t}\\ &\Delta x=\frac{x}{\lambda}\left[\left(\frac{1+p^{\frac{1-t}{t}}}{1+p'^{\frac{1-t}{t}}}\right)^{\frac{1}{1-t}}-1\right]\\ \end{split}
$$
Denote $$r$$ and $$r'$$ the current and trader's target interest rate respectively. Because $$p=e^{rt}$$ and $$p'=e^{r't}$$, the above equation can also be rewritten as
$$
@@ -195,7 +183,7 @@ $$
x^{1-t}+(y+y_{v})^{1-t}=L
$$
Figure 1 illustrates the example above of $$t$$= 0.5 and $$L$$= 20 by displaying two sets of curves: Invariant Function Curve \(IFC"\) satisfying $$x^{1-t}+y^{1-t}=L$$ and Capital Efficiency Curve \(CEC"\) satisfying $$x^{1-t}+(y+y_v)^{1-t}=L$$. Intuitively CEC is attained by lowering IFC by $$y_v$$= 100.
Figure 1 illustrates the example above of $$t$$= 0.5 and $$L$$= 20 by displaying two sets of curves: Invariant Function Curve (IFC") satisfying $$x^{1-t}+y^{1-t}=L$$ and Capital Efficiency Curve (CEC") satisfying $$x^{1-t}+(y+y_v)^{1-t}=L$$. Intuitively CEC is attained by lowering IFC by $$y_v$$= 100.
![Figure 1](../.gitbook/assets/cecjing.png)
@@ -214,19 +202,13 @@ Before liquidity expansion or reduction by minting or burning coins, assume that
Minting and burning should not affect price and interest rate. This means that newly added or withdrawn coins would be in proportion to x and y. Denote new amount of Token and ayToken as $$x'=kx$$ and $$y'=ky$$ respectively. $$y'=y'_a+y'_v$$ where $$y'_a$$ is actual whereas $$y'_v$$ virtual. They satisfy the following
$$
\begin{split}
&y'_a+y'_v=ky\\
&2y'^{1-t}_v=k^{1-t}L
\end{split}
\begin{split} &y'_a+y'_v=ky\\ &2y'^{1-t}_v=k^{1-t}L \end{split}
$$
Solution to the above equations is
$$
\begin{split}
&y'_{a}=ky-y'_{v}\\y'_{v}
&=\left(\frac{1}{2}L\right)^{\frac{1}{1-t}}k
\end{split}
\begin{split} &y'_{a}=ky-y'_{v}\\y'_{v} &=\left(\frac{1}{2}L\right)^{\frac{1}{1-t}}k \end{split}
$$
This means $$y'_v=ky_v$$ and $$y'_a=ky_a$$.
@@ -235,32 +217,26 @@ This means $$y'_v=ky_v$$ and $$y'_a=ky_a$$.
Assume $$t$$= 0.5. Rachel initialises a liquidity pool of 0% interest rate with 100 Token on CEC. Although there is no actual ayToken, 0% rate implies 100 virtual tokens and $$L$$= 20 on IFC.
Suppose Rachel then sells 50 ayToken to the pool on the same day. On IFC, this means ayToken amount of 150 \(50 actual and 100 virtual\) and the amount of 60.10 Token remaining on IFC.
Suppose Rachel then sells 50 ayToken to the pool on the same day. On IFC, this means ayToken amount of 150 (50 actual and 100 virtual) and the amount of 60.10 Token remaining on IFC.
Now suppose Billy wants to mint 10% of the liquidity pool. This means that Billy needs to deposit 6.01 \(10% of 60.10\) Token. Virtual balance is updated to $$\left(\frac{1}{2}\times20\right)^{\frac{1}{0.5}}\times1.1=110$$. Billy needs to deposit 5 ayToken \($$1.1\times150-110-50$$\), so that the summation of actual and virtual ayToken is 165. Interest rate remains the same before and after Billy's participation. Note that both actual and virtual ayToken balance increase by 10%, which is the same proportion as the growth of liquidity pool.
Now suppose Billy wants to mint 10% of the liquidity pool. This means that Billy needs to deposit 6.01 (10% of 60.10) Token. Virtual balance is updated to $$\left(\frac{1}{2}\times20\right)^{\frac{1}{0.5}}\times1.1=110$$. Billy needs to deposit 5 ayToken ($$1.1\times150-110-50$$), so that the summation of actual and virtual ayToken is 165. Interest rate remains the same before and after Billy's participation. Note that both actual and virtual ayToken balance increase by 10%, which is the same proportion as the growth of liquidity pool.
### Range-bound Pool
The above section can be extended to any constraint pool with upper interest rate $$r_{u}$$ and lower interest rate $$r_{l}$$. If interest rate falls out of \[$$r_{l} $$,$$r_{u}$$\], swapping would be suspended as one of the tokens would have been depleted.
The above section can be extended to any constraint pool with upper interest rate $$r_{u}$$ and lower interest rate $$r_{l}$$. If interest rate falls out of \[$$r_{l}$$,$$r_{u}$$], swapping would be suspended as one of the tokens would have been depleted.
Denote $$x_{a}$$, $$x_{v}$$, $$y_{a}$$ and $$y_{v}$$ balance of actual Token, virtual Token, actual ayToken and virtual ayToken respectively. They satisfy invariant function on IFC, i.e. $$(x{a}+x{v})^{1-t}+(y{a}+y{v})^{1-t}=L$$.
The amount of Token an ayToken can be expressed as a function of L and current interest rate $$r_{c}=\frac{y_{a}+y_{v}}{x_{a}+x_{v}}$$.
$$
\begin{split}
&x_{a}+x_{v}&=\left[\frac{L}{1+e^{(1-t)r_{c}}}\right]^{\frac{1}{1-t}}\\
&y_{a}+y_{v}&=\left[\frac{L}{1+e^{-(1-t)r_{c}}}\right]^{\frac{1}{1-t}}
\end{split}
\begin{split} &x_{a}+x_{v}&=\left[\frac{L}{1+e^{(1-t)r_{c}}}\right]^{\frac{1}{1-t}}\\ &y_{a}+y_{v}&=\left[\frac{L}{1+e^{-(1-t)r_{c}}}\right]^{\frac{1}{1-t}} \end{split}
$$
Intuitively, when $$r_{c}=r_{l}$$, ayToken is depleted; Similarly, when $$r_{c}=r_{u}$$, Token is used up. Therefore,
$$
\begin{split}
&x_{v}=\left[\frac{L}{1+e^{(1-t)r_{u}}}\right]^{\frac{1}{1-t}}\\
&y_{v}=\left[\frac{L}{1+e^{-(1-t)r_{l}}}\right]^{\frac{1}{1-t}}
\end{split}
\begin{split} &x_{v}=\left[\frac{L}{1+e^{(1-t)r_{u}}}\right]^{\frac{1}{1-t}}\\ &y_{v}=\left[\frac{L}{1+e^{-(1-t)r_{l}}}\right]^{\frac{1}{1-t}} \end{split}
$$
See [Appendix 3](automated-market-making-of-alex.md#appendix-3-derivation-of-actual-and-virtual-token-reserve) for a detailed derivation of virtual, as well as actual token reserve.
@@ -271,7 +247,7 @@ Similar to the case of 0% floor, minting or burning coins would result in invari
We aim to show here how virtual token is able to assist liquidity providers to efficiently manage capital.
![Figure 2](../.gitbook/assets/cectable2.png)
![Figure 2](<../.gitbook/assets/cectable2 (1).png>)
In Figure 2, assume lower bound is 0%, whereas upper bound is 50%. We also set $$t$$= 0.5 and $$L$$= 20. If interest rate is 0%, $$L$$= 20 means holding equal amount of Token and ayToken of 100 each $$\left(100^{0.5}+100^{0.5}=20\right)$$. The figure compares actual holding of Token and ayToken with and without cap and floor.
@@ -290,11 +266,7 @@ When $$0<p<1$$, $$g\left(x_{1}\right)$$ is monotonically decreasing and convex.
This is equivalent to prove $$\frac{dg(x_{1})}{dx_{1}}<0$$ and $$\frac{d^{2}g(x_{1})}{dx_{1}^{2}}\geq0$$.
$$
\begin{split}
&\frac{dg(x_{1})}{dx_{1}}=\frac{1}{p}(L-x_{1}^{p})^{\frac{1}{p}-1}\left(-px_{1}^{p-1}\right)=-\left(\frac{L-x_{1}^{p}}{x_{1}^{p}}\right)^{\frac{1-p}{p}}<0\\
&\frac{d^{2}g(x_{1})}{dx_{1}^{2}}=-\frac{1-p}{p}\left(\frac{L-x_{1}^{p}}{x_{1}^{p}}\right)^{\frac{1-2p}{p}}\left[\frac{-px_{1}^{p-1}x_{1}^{p}-(L-x_{1}^{p})px^{p-1}}{x_{1}^{2}p}\right]\\
&=L(1-p)\left(\frac{x_{2}}{x_{1}}\right)^{1-2p}x_{1}^{-p-1}\geq0
\end{split}
\begin{split} &\frac{dg(x_{1})}{dx_{1}}=\frac{1}{p}(L-x_{1}^{p})^{\frac{1}{p}-1}\left(-px_{1}^{p-1}\right)=-\left(\frac{L-x_{1}^{p}}{x_{1}^{p}}\right)^{\frac{1-p}{p}}<0\\ &\frac{d^{2}g(x_{1})}{dx_{1}^{2}}=-\frac{1-p}{p}\left(\frac{L-x_{1}^{p}}{x_{1}^{p}}\right)^{\frac{1-2p}{p}}\left[\frac{-px_{1}^{p-1}x_{1}^{p}-(L-x_{1}^{p})px^{p-1}}{x_{1}^{2}p}\right]\\ &=L(1-p)\left(\frac{x_{2}}{x_{1}}\right)^{1-2p}x_{1}^{-p-1}\geq0 \end{split}
$$
The last inequality holds because each component is positive.
@@ -333,7 +305,7 @@ Proof of the corollary is trivial, as it is a direct application of the theorem.
## Appendix 2: Liquidity Mapping to Uniswap v3
As Uniswap v3 is able to simulate liquidity curve of any AMM, we are interested in exploring the connection between ALEX's AMM and that of _Uniswap_'s. Interesting questions include: what is the shape of the liquidity distribution? Which point\(s\) has the highest liquidity? We acknowledge that the section is more of a theoretical study for now.
As Uniswap v3 is able to simulate liquidity curve of any AMM, we are interested in exploring the connection between ALEX's AMM and that of _Uniswap_'s. Interesting questions include: what is the shape of the liquidity distribution? Which point(s) has the highest liquidity? We acknowledge that the section is more of a theoretical study for now.
_Uniswap V3_ AMM can be expressed as a function of invariant constant $$L$$ with respect to price $$p$$, $$L_{\text{Uniswap}}=\frac{dy}{d\sqrt{p}}$$. In terms of ALEX, as price p=e^{rt}, where $$r$$ is the implied interest rate, we have
@@ -350,14 +322,10 @@ $$
Therefore
$$
\begin{split}
&\frac{dy}{dr}=L^{\frac{1}{1-t}}\frac{e^{-(1-t)r}}{(1+e^{-(1-t)r})^{\frac{2-t}{1-t}}}\\
&L_{\text{Uniswap}}=\frac{2}{t}L^{\frac{1}{1-t}}\left(e^{\frac{r(1-t)}{2}}+e^{\frac{-r(1-t)}{2}}\right)^{\frac{-2+t}{1-t}}\\
&=\frac{2}{t}L^{\frac{1}{1-t}}\big\{2\cosh\left[\frac{r(1-t)}{2}\right]\big\}^{\frac{-2+t}{1-t}}
\end{split}
\begin{split} &\frac{dy}{dr}=L^{\frac{1}{1-t}}\frac{e^{-(1-t)r}}{(1+e^{-(1-t)r})^{\frac{2-t}{1-t}}}\\ &L_{\text{Uniswap}}=\frac{2}{t}L^{\frac{1}{1-t}}\left(e^{\frac{r(1-t)}{2}}+e^{\frac{-r(1-t)}{2}}\right)^{\frac{-2+t}{1-t}}\\ &=\frac{2}{t}L^{\frac{1}{1-t}}\big\{2\cosh\left[\frac{r(1-t)}{2}\right]\big\}^{\frac{-2+t}{1-t}} \end{split}
$$
![Figure 3](../.gitbook/assets/liquidity%20%282%29%20%282%29%20%282%29%20%282%29%20%282%29%20%282%29%20%282%29%20%282%29.png)
![Figure 3](<../.gitbook/assets/liquidity (2) (2) (2) (2) (2) (2) (2) (1) (1).png>)
Figure 3 plots $$L_{\text{Uniswap}}$$ against interest rate $$r$$ regarding various levels of $$t$$. When $$0<t<1$$, $$L_{\text{Uniswap}}$$ is symmetric around 0% at which the maximum reaches . This is because
@@ -368,26 +336,16 @@ Furthermore, the higher the $$t$$, the flatter the liquidity distribution is. Wh
## Appendix 3: Derivation of Actual and Virtual Token Reserve
On CEC, there are two boundary points \($$x_{b}$$,0\) and \(0,$$y_{b}$$\) corresponding to the lower and upper bound of interest rate $$r_{l}$$ and $$r_{u}$$ respectively. We assume $$L$$ is pre-determined, as liquidity provider knows the pool size. We aim to find $$x_{b}$$, $$y_{b}$$, $$x_{v}$$ and $$y_{v}$$ which satisfy the following equations
On CEC, there are two boundary points ($$x_{b}$$,0) and (0,$$y_{b}$$) corresponding to the lower and upper bound of interest rate $$r_{l}$$ and $$r_{u}$$ respectively. We assume $$L$$ is pre-determined, as liquidity provider knows the pool size. We aim to find $$x_{b}$$, $$y_{b}$$, $$x_{v}$$ and $$y_{v}$$ which satisfy the following equations
$$
\begin{split}
&(x_{b}+x_{v})^{1-t}+y_{v}^{1-t}=L\\
&x_{v}^{1-t}+(y_{b}+y_{v})^{1-t}=L\\
&\frac{y_{v}}{x_{b}+x_{v}}=e^{r_{l}}\\
&\frac{y_{b}+y_{v}}{x_{v}}=e^{r_{u}}
\end{split}
\begin{split} &(x_{b}+x_{v})^{1-t}+y_{v}^{1-t}=L\\ &x_{v}^{1-t}+(y_{b}+y_{v})^{1-t}=L\\ &\frac{y_{v}}{x_{b}+x_{v}}=e^{r_{l}}\\ &\frac{y_{b}+y_{v}}{x_{v}}=e^{r_{u}} \end{split}
$$
As there are four unknown variables with four equations, solutions can be expressed as below
$$
\begin{split}
&x_{v}=\left[\frac{L}{1+e^{(1-t)r_{u}}}\right]^{\frac{1}{1-t}}\\
&y_{v}=\left[\frac{L}{1+e^{-(1-t)r_{l}}}\right]^{\frac{1}{1-t}}\\
&x_{b}=y_{v}e^{-r_{l}}-x_{v}=\left[\frac{L}{1+e^{r_{l}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{r_{u}(1-t)}}\right]^{\frac{1}{1-t}}\\
&y_{b}=x_{v}e^{r_{u}}-y_{v}=\left[\frac{L}{1+e^{-r_{u}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{-r_{l}(1-t)}}\right]^{\frac{1}{1-t}}
\end{split}
\begin{split} &x_{v}=\left[\frac{L}{1+e^{(1-t)r_{u}}}\right]^{\frac{1}{1-t}}\\ &y_{v}=\left[\frac{L}{1+e^{-(1-t)r_{l}}}\right]^{\frac{1}{1-t}}\\ &x_{b}=y_{v}e^{-r_{l}}-x_{v}=\left[\frac{L}{1+e^{r_{l}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{r_{u}(1-t)}}\right]^{\frac{1}{1-t}}\\ &y_{b}=x_{v}e^{r_{u}}-y_{v}=\left[\frac{L}{1+e^{-r_{u}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{-r_{l}(1-t)}}\right]^{\frac{1}{1-t}} \end{split}
$$
When $$r_{l}=0$$, the pool is floored at 0%. This means that $$x_{v}=0$$, $$y_{v}=\left(\frac{1}{2}L\right)^{\frac{1}{1-t}}$$, $$x_{b}=y_{v}$$.
@@ -395,20 +353,13 @@ When $$r_{l}=0$$, the pool is floored at 0%. This means that $$x_{v}=0$$, $$y_{v
When the current interest rate $$r_{c}$$ is known and $$r_{c}\in[r_{l},r_{u}]$$, we can calculate $$x_{a}$$ and $$y_{a}$$ satisfying the following equations. When $$r_{c} \notin[r_{l},r_{u}]$$, only one token exists and swapping activities are suspended.
$$
\begin{split}
&(x_{v}+x_{a})^{1-t}+(y_{v}+y_{a})^{1-t}=L\\
&\frac{y_{v}+y_{a}}{x_{v}+x_{a}}=e^{r_{c}}
\end{split}
\begin{split} &(x_{v}+x_{a})^{1-t}+(y_{v}+y_{a})^{1-t}=L\\ &\frac{y_{v}+y_{a}}{x_{v}+x_{a}}=e^{r_{c}} \end{split}
$$
Solution to above is
$$
\begin{split}
&x_{a}=\left[\frac{L}{1+e^{r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-x_{v}=\left[\frac{L}{1+e^{r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{r_{u}(1-t)}}\right]^{\frac{1}{1-t}}\\
&y_{a}=\left[\frac{L}{1+e^{-r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-y_{v}=\left[\frac{L}{1+e^{-r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{-r_{l}(1-t)}}\right]^{\frac{1}{1-t}}
\end{split}
\begin{split} &x_{a}=\left[\frac{L}{1+e^{r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-x_{v}=\left[\frac{L}{1+e^{r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{r_{u}(1-t)}}\right]^{\frac{1}{1-t}}\\ &y_{a}=\left[\frac{L}{1+e^{-r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-y_{v}=\left[\frac{L}{1+e^{-r_{c}(1-t)}}\right]^{\frac{1}{1-t}}-\left[\frac{L}{1+e^{-r_{l}(1-t)}}\right]^{\frac{1}{1-t}} \end{split}
$$
At the boundary points, when $$r_{c}=r_{l}$$, $$x_{a}=x_{b}$$ and $$y_{a}=0$$; when $$r_{c}=r_{u}$$, $$x_{a}=0$$ and $$y_{a}=y_{b}$$.