Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/NFTPerp connector #263

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
432 changes: 431 additions & 1 deletion docs/swagger/definitions.yml

Large diffs are not rendered by default.

315 changes: 315 additions & 0 deletions docs/swagger/nftperp-routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
paths:
/nftperp/supported:
post:
tags:
- 'nftperp'
summary: 'Get the supported amms'
operationId: 'supported'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpSupportedRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpSupportedResponse'

/nftperp/position:
post:
tags:
- 'nftperp'
summary: 'Get the position information'
operationId: 'position'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpCommonRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpPositionResponse'

/nftperp/markPrice:
post:
tags:
- 'nftperp'
summary: 'Get the mark price for a given amm'
operationId: 'markPrice'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpCommonRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpPriceResponse'

/nftperp/indexPrice:
post:
tags:
- 'nftperp'
summary: 'Get the index price for a given amm'
operationId: 'indexPrice'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpCommonRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpPriceResponse'

/nftperp/fundingRate:
post:
tags:
- 'nftperp'
summary: 'Get the funding rate for a given amm'
operationId: 'fundingRate'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpCommonRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpPriceResponse'

/nftperp/openMarketOrder:
post:
tags:
- 'nftperp'
summary: 'Create a market order'
operationId: 'openMarketOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpOpenMarketOrderRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/openLimitOrder:
post:
tags:
- 'nftperp'
summary: 'Create a limit order'
operationId: 'openLimitOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpOpenLimitOrderRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/updateLimitOrder:
post:
tags:
- 'nftperp'
summary: 'Update a given limit order'
operationId: 'updateLimitOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpUpdateLimitOrderRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/deleteLimitOrder:
post:
tags:
- 'nftperp'
summary: 'Delete a given limit order'
operationId: 'deleteLimitOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpDeleteOrderRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/openLimitOrderBatch:
post:
tags:
- 'nftperp'
summary: 'Create limit orders in batch'
operationId: 'openLimitOrderBatch'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpOpenLimitOrderBatchRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/updateLimitOrderBatch:
post:
tags:
- 'nftperp'
summary: 'Update given limit orders'
operationId: 'updateLimitOrderBatch'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpUpdateLimitOrderBatchRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/deleteLimitOrderBatch:
post:
tags:
- 'nftperp'
summary: 'Delete given limit orders'
operationId: 'deleteLimitOrderBatch'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpDeleteOrdersRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/openTriggerOrder:
post:
tags:
- 'nftperp'
summary: 'Create a trigger order'
operationId: 'openTriggerOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpDeleteOrdersRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/deleteTriggerOrder:
post:
tags:
- 'nftperp'
summary: 'Delete a given trigger order'
operationId: 'deleteTriggerOrder'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpDeleteOrderRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'

/nftperp/closePosition:
post:
tags:
- 'nftperp'
summary: 'Close a given amm position'
operationId: 'closePosition'
consumes:
- 'application/json'
produces:
- 'application/json'
parameters:
- in: 'body'
name: 'body'
required: true
schema:
$ref: '#/definitions/NftPerpClosePositionRequest'
responses:
'200':
schema:
$ref: '#/definitions/NftPerpExecuteTxResponse'
2 changes: 2 additions & 0 deletions docs/swagger/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ tags:
description: 'CLOB spot DEX endpoints'
- name: 'clob/perp'
description: 'CLOB perpetual DEX endpoints'
- name: 'nftperp'
description: 'NftPerp endpoints'

schemes:
- 'http'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@harmony-js/utils": "^0.1.56",
"@improbable-eng/grpc-web": "^0.13.0",
"@injectivelabs/sdk-ts": "^1.10.58",
"@nftperp/sdk": "6.0.2",
"@pancakeswap/sdk": "^4.0.0",
"@pancakeswap/smart-router": "^4.2.1",
"@pancakeswap/swap-sdk-core": "^1.0.0",
Expand Down
7 changes: 5 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import { SwaggerManager } from './services/swagger-manager';
import { ConnectorsRoutes } from './connectors/connectors.routes';
import { AmmRoutes, AmmLiquidityRoutes, PerpAmmRoutes } from './amm/amm.routes';
import { CLOBRoutes, PerpClobRoutes } from './clob/clob.routes';
import { ChainRoutes } from './chains/chain.routes';
import { NftPerpRoutes } from './nftperp/nftperp.routes';

import morgan from 'morgan';
import swaggerUi from 'swagger-ui-express';
import { ChainRoutes } from './chains/chain.routes';

export const gatewayApp = express();

Expand Down Expand Up @@ -52,6 +53,7 @@ gatewayApp.use('/amm/liquidity', AmmLiquidityRoutes.router);
gatewayApp.use('/wallet', WalletRoutes.router);
gatewayApp.use('/clob', CLOBRoutes.router);
gatewayApp.use('/clob/perp', PerpClobRoutes.router);
gatewayApp.use('/nftperp', NftPerpRoutes.router);

// a simple route to test that the server is running
gatewayApp.get('/', (_req: Request, res: Response) => {
Expand Down Expand Up @@ -94,6 +96,7 @@ export const swaggerDocument = SwaggerManager.generateSwaggerJson(
'./docs/swagger/amm-routes.yml',
'./docs/swagger/amm-liquidity-routes.yml',
'./docs/swagger/chain-routes.yml',
'./docs/swagger/nftperp-routes.yml'
]
);

Expand All @@ -112,7 +115,7 @@ export const startSwagger = async () => {

export const startGateway = async () => {
const port = ConfigManagerV2.getInstance().get('server.port');
const gateway_version="dev-1.24.0"; // gateway version
const gateway_version = "dev-1.24.0"; // gateway version
if (!ConfigManagerV2.getInstance().get('server.id')) {
ConfigManagerV2.getInstance().set(
'server.id',
Expand Down
7 changes: 7 additions & 0 deletions src/connectors/connectors.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { CurveConfig } from './curve/curveswap.config';
import { PlentyConfig } from './plenty/plenty.config';
import { XRPLCLOBConfig } from './xrpl/xrpl.clob.config';
import { KujiraConfig } from './kujira/kujira.config';
import { NftPerpConfig } from './nftperp/nftperp.config';
import { QuipuswapConfig } from './quipuswap/quipuswap.config';

export namespace ConnectorsRoutes {
Expand Down Expand Up @@ -163,6 +164,12 @@ export namespace ConnectorsRoutes {
'Enter your kujira account number (input 0 if unsure) >>> ',
},
},
{
name: 'nftperp',
trading_type: NftPerpConfig.config.tradingTypes,
chain_type: NftPerpConfig.config.chainType,
available_networks: NftPerpConfig.config.availableNetworks
},
{
name: 'quipuswap',
trading_type: QuipuswapConfig.config.tradingTypes,
Expand Down
Loading
Loading