From 7e6df2080ee3f26ebc9dbb575ac0a624b7964391 Mon Sep 17 00:00:00 2001 From: deep-path <476044723@qq.com> Date: Tue, 19 Nov 2024 11:01:07 +0800 Subject: [PATCH] feat: add margin interface --- data/datasource.js | 11 +++++++++++ utils/config.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/data/datasource.js b/data/datasource.js index 7e851a3c..f4a619f2 100644 --- a/data/datasource.js +++ b/data/datasource.js @@ -37,6 +37,7 @@ class DataSource { throw new Error("Failed to connect server"); } + // eslint-disable-next-line no-useless-catch try { const json = await parseResponse(response); return json; @@ -104,6 +105,16 @@ class DataSource { getTxId(receipt_id) { return this.callAPI(`/v1/search/?keyword=${receipt_id}`, "GET", null, null, config?.txIdApiUrl); } + + getMarginTradingPosition(params) { + return this.callAPI( + `/v3/margin-trading/position`, + "POST", + null, + params, + config?.marginTradingUrl, + ); + } } export default DataSource; diff --git a/utils/config.ts b/utils/config.ts index 35ee6f15..9430e4c8 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -103,6 +103,7 @@ const getConfig = (env: string = defaultNetwork) => { liquidationUrl: "https://dev.data-service.ref-finance.com", recordsUrl: "https://dev-indexer.ref-finance.com", txIdApiUrl: "https://api-testnet.nearblocks.io", + marginTradingUrl: " https://testnet-indexer.ref-finance.com", SPECIAL_REGISTRATION_TOKEN_IDS: [ "3e2210e1184b45b64c8a434c0a7e7b23cc04ea7eb7a6c3c32520d03d4afcb8af", ],