@reyaxyz/api-sdk 0.49.4 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/api-client.js +9 -0
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/modules/funding-rate/index.js +90 -0
- package/dist/clients/modules/funding-rate/index.js.map +1 -0
- package/dist/clients/modules/funding-rate/types.js +3 -0
- package/dist/clients/modules/funding-rate/types.js.map +1 -0
- package/dist/clients/types.js +1 -0
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/api-client.d.ts +3 -0
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/modules/funding-rate/index.d.ts +14 -0
- package/dist/types/clients/modules/funding-rate/index.d.ts.map +1 -0
- package/dist/types/clients/modules/funding-rate/types.d.ts +4 -0
- package/dist/types/clients/modules/funding-rate/types.d.ts.map +1 -0
- package/dist/types/clients/types.d.ts +1 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/api-client.ts +7 -0
- package/src/clients/modules/funding-rate/index.ts +47 -0
- package/src/clients/modules/funding-rate/types.ts +3 -0
- package/src/clients/types.ts +1 -0
|
@@ -17,6 +17,7 @@ var deposit_new_MA_simulation_1 = __importDefault(require("./modules/deposit-new
|
|
|
17
17
|
var withdraw_MA_simulation_1 = __importDefault(require("./modules/withdraw-MA.simulation"));
|
|
18
18
|
var transfer_margin_between_MAs_simulation_1 = __importDefault(require("./modules/transfer-margin-between-MAs.simulation"));
|
|
19
19
|
var transfer_MA_Pool_simulation_1 = __importDefault(require("./modules/transfer-MA-Pool.simulation"));
|
|
20
|
+
var funding_rate_1 = __importDefault(require("./modules/funding-rate"));
|
|
20
21
|
/**
|
|
21
22
|
* @description Client for API
|
|
22
23
|
*/
|
|
@@ -26,6 +27,7 @@ var ApiClient = /** @class */ (function () {
|
|
|
26
27
|
this._account = new account_1.default(ApiClient.config.apiEndpoint);
|
|
27
28
|
this._lp = new lp_1.default(ApiClient.config.apiEndpoint);
|
|
28
29
|
this._tradeSimulation = new trade_simulation_1.default(this._account);
|
|
30
|
+
this._fundingRateHistory = new funding_rate_1.default(this._markets);
|
|
29
31
|
this._editCollateralSimulation = new edit_collateral_simulation_1.default(this._account);
|
|
30
32
|
this._depositExistingMASimulation = new deposit_existing_MA_simulation_1.default(this._editCollateralSimulation);
|
|
31
33
|
this._depositNewMASimulation = new deposit_new_MA_simulation_1.default(this._depositExistingMASimulation);
|
|
@@ -105,6 +107,13 @@ var ApiClient = /** @class */ (function () {
|
|
|
105
107
|
enumerable: false,
|
|
106
108
|
configurable: true
|
|
107
109
|
});
|
|
110
|
+
Object.defineProperty(ApiClient, "fundingRateHistory", {
|
|
111
|
+
get: function () {
|
|
112
|
+
return ApiClient.getInstance()._fundingRateHistory;
|
|
113
|
+
},
|
|
114
|
+
enumerable: false,
|
|
115
|
+
configurable: true
|
|
116
|
+
});
|
|
108
117
|
Object.defineProperty(ApiClient, "editCollateralSimulationClient", {
|
|
109
118
|
/**
|
|
110
119
|
* Provides access to the EditCollateralSimulationClient instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwE;AACxE,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,4FAA0E;AAC1E,4HAAwG;AACxG,sGAAmF;AAEnF;;GAEG;AACH;IAgBE;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,GAAG,IAA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AW,EAAE,CAAC,mCAAmC,CAAC;QACrE,CAAC;;;OAAA;IAgBD,sBAAkB,qCAAwB;QAd1C;;;;;;;;;;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,yBAAyB,CAAC;QAC3D,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;IA1Pc,gBAAM,GAAkB,8BAAkB,CAAC,MAAM,CAAC,CAAC;IA2PpE,gBAAC;CAAA,AA7PD,IA6PC;AA7PY,8BAAS","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(this._account);\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_tradeSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._tradeSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwE;AACxE,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,4FAA0E;AAC1E,4HAAwG;AACxG,sGAAmF;AACnF,wEAAuD;AAEvD;;GAEG;AACH;IAiBE;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,IAAI,0BAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,IAAI,CAAC,mBAAmB,GAAG,IAAI,sBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,yBAAyB,GAAG,IAAI,oCAA8B,CACjE,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,CAAC,4BAA4B,GAAG,IAAI,wCAAiC,CACvE,IAAI,CAAC,yBAAyB,CAC/B,CAAC;QACF,IAAI,CAAC,uBAAuB,GAAG,IAAI,mCAA4B,CAC7D,IAAI,CAAC,4BAA4B,CAClC,CAAC;QACF,IA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AAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;IAhQc,gBAAM,GAAkB,8BAAkB,CAAC,MAAM,CAAC,CAAC;IAiQpE,gBAAC;CAAA,AAnQD,IAmQC;AAnQY,8BAAS","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport FundingRateClient from './modules/funding-rate';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(this._account);\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_tradeSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._tradeSimulation;\n }\n\n public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the TokensClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n\n /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var FundingRateClient = /** @class */ (function () {
|
|
40
|
+
function FundingRateClient(marketClient) {
|
|
41
|
+
this.marketId = null;
|
|
42
|
+
this.loadedData = null;
|
|
43
|
+
// Constructor added
|
|
44
|
+
this.marketClient = marketClient;
|
|
45
|
+
}
|
|
46
|
+
// Method to asynchronously load data based on marketId and accountId
|
|
47
|
+
FundingRateClient.prototype.arm = function (params) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var _a;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
this.marketId = params.marketId;
|
|
54
|
+
_a = this;
|
|
55
|
+
return [4 /*yield*/, this.fetchFundingRateData(params)];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.loadedData = _b.sent();
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
FundingRateClient.prototype.fetchFundingRateData = function (params) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
return [2 /*return*/, this.marketClient.getFundingRateChartData(params)];
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
FundingRateClient.prototype.createGraph = function (params) {
|
|
71
|
+
if (!this.loadedData) {
|
|
72
|
+
throw new Error('Data not loaded. Call arm() first.');
|
|
73
|
+
}
|
|
74
|
+
if (params.resolution === '1h')
|
|
75
|
+
return this.loadedData;
|
|
76
|
+
var multiplicator = params.resolution === '24h' ? 24 : 24 * 365;
|
|
77
|
+
return {
|
|
78
|
+
fundingRate: this.loadedData.fundingRate * multiplicator,
|
|
79
|
+
fundingRateData: this.loadedData.fundingRateData.map(function (point) {
|
|
80
|
+
return {
|
|
81
|
+
timestampInMs: point.timestampInMs,
|
|
82
|
+
value: point.value * multiplicator,
|
|
83
|
+
};
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
return FundingRateClient;
|
|
88
|
+
}());
|
|
89
|
+
exports.default = FundingRateClient;
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/funding-rate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;IAIE,2BAAY,YAA2B;QAH/B,aAAQ,GAAkB,IAAI,CAAC;QAC/B,eAAU,GAAyC,IAAI,CAAC;QAG9D,oBAAoB;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,qEAAqE;IAC/D,+BAAG,GAAT,UAAU,MAAqC;;;;;;wBAC7C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;wBAEhC,KAAA,IAAI,CAAA;wBAAc,qBAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAA;;wBAAzD,GAAK,UAAU,GAAG,SAAuC,CAAC;;;;;KAC3D;IAEa,gDAAoB,GAAlC,UACE,MAAqC;;;gBAErC,sBAAO,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAC;;;KAC1D;IAED,uCAAW,GAAX,UAAY,MAA6B;QACvC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC;QAEvD,IAAM,aAAa,GAAG,MAAM,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC;QAElE,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,aAAa;YACxD,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,UAAC,KAAK;gBACzD,OAAO;oBACL,aAAa,EAAE,KAAK,CAAC,aAAa;oBAClC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,aAAa;iBACnC,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;IACH,wBAAC;AAAD,CAAC,AAzCD,IAyCC","sourcesContent":["import { FundingRateResolution } from './types';\nimport { GetFundingRateChartDataParams } from '../markets/types';\nimport MarketsClient from '../markets';\nimport { GetFundingRateChartDataResult } from '@reyaxyz/common';\n\nexport default class FundingRateClient {\n private marketId: number | null = null;\n private loadedData: GetFundingRateChartDataResult | null = null;\n private marketClient: MarketsClient;\n constructor(marketClient: MarketsClient) {\n // Constructor added\n this.marketClient = marketClient;\n }\n\n // Method to asynchronously load data based on marketId and accountId\n async arm(params: GetFundingRateChartDataParams): Promise<void> {\n this.marketId = params.marketId;\n\n this.loadedData = await this.fetchFundingRateData(params);\n }\n\n private async fetchFundingRateData(\n params: GetFundingRateChartDataParams,\n ): Promise<GetFundingRateChartDataResult> {\n return this.marketClient.getFundingRateChartData(params);\n }\n\n createGraph(params: FundingRateResolution): GetFundingRateChartDataResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n if (params.resolution === '1h') return this.loadedData;\n\n const multiplicator = params.resolution === '24h' ? 24 : 24 * 365;\n\n return {\n fundingRate: this.loadedData.fundingRate * multiplicator,\n fundingRateData: this.loadedData.fundingRateData.map((point) => {\n return {\n timestampInMs: point.timestampInMs,\n value: point.value * multiplicator,\n };\n }),\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/funding-rate/types.ts"],"names":[],"mappings":"","sourcesContent":["export type FundingRateResolution = {\n resolution: '1h' | '24h' | '1y';\n};\n"]}
|
package/dist/clients/types.js
CHANGED
|
@@ -36,4 +36,5 @@ __exportStar(require("./modules/edit-collateral.simulation/types"), exports);
|
|
|
36
36
|
__exportStar(require("./modules/withdraw-MA.simulation/types"), exports);
|
|
37
37
|
__exportStar(require("./modules/transfer-margin-between-MAs.simulation/types"), exports);
|
|
38
38
|
__exportStar(require("./modules/transfer-MA-Pool.simulation/types"), exports);
|
|
39
|
+
__exportStar(require("./modules/funding-rate/types"), exports);
|
|
39
40
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CAyByB;AAvBvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAErC,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,6EAA2D;AAC3D,yEAAuD;AACvD,yFAAuE;AACvE,8EAA4D","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,0CAyByB;AAvBvB,2GAAA,iBAAiB,OAAA;AAYjB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAGjB,8GAAA,oBAAoB,OAAA;AACpB,yHAAA,+BAA+B,OAAA;AAE/B,oIAAA,0CAA0C,OAAA;AAG1C,6HAAA,mCAAmC,OAAA;AAErC,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,4EAA0D;AAC1D,6EAA2D;AAC3D,yEAAuD;AACvD,yFAAuE;AACvE,8EAA4D;AAC5D,+DAA6C","sourcesContent":["// reexporting what we want to share with integrators\nexport {\n Candle,\n CandlesResolution,\n MarketEntity,\n LpTransactionHistoryEntity,\n TradingHistoryEntity,\n PositionHistoryEntity,\n PositionEntity,\n TransactionHistoryType,\n MarginAccountTransactionHistoryType,\n MarginAccountTransactionHistoryEntity,\n MarginAccountEntity,\n LpPositionEntity,\n LpPoolEntity,\n ReyaChainId,\n MoneyInOutChainId,\n GetLpPoolPerformanceChartDataResult,\n GetLpPoolBalanceChartDataResult,\n LpBalanceGranularity,\n MarginAccountBalanceGranularity,\n GetMarginAccountBalanceChartDataResult,\n MarginAccountCollateralsBalanceGranularity,\n GetMarginAccountCollateralsBalanceChartDataResult,\n GetAllMarginAccountsBalanceChartDataResult,\n AllMarginAccountsBalanceGranularity,\n} from '@reyaxyz/common';\nexport * from './modules/account/types';\nexport * from './modules/lp/types';\nexport * from './modules/markets/types';\nexport * from './modules/tokens/types';\nexport * from './modules/trade.simulation/types';\nexport * from './modules/owner/types';\nexport * from './modules/deposit-existing-MA.simulation/types';\nexport * from './modules/deposit-new-MA.simulation/types';\nexport * from './modules/edit-collateral.simulation/types';\nexport * from './modules/withdraw-MA.simulation/types';\nexport * from './modules/transfer-margin-between-MAs.simulation/types';\nexport * from './modules/transfer-MA-Pool.simulation/types';\nexport * from './modules/funding-rate/types';\n"]}
|
|
@@ -12,6 +12,7 @@ import DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';
|
|
|
12
12
|
import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
|
|
13
13
|
import TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';
|
|
14
14
|
import TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';
|
|
15
|
+
import FundingRateClient from './modules/funding-rate';
|
|
15
16
|
/**
|
|
16
17
|
* @description Client for API
|
|
17
18
|
*/
|
|
@@ -22,6 +23,7 @@ export declare class ApiClient {
|
|
|
22
23
|
private readonly _account;
|
|
23
24
|
private readonly _lp;
|
|
24
25
|
private readonly _tradeSimulation;
|
|
26
|
+
private readonly _fundingRateHistory;
|
|
25
27
|
private readonly _editCollateralSimulation;
|
|
26
28
|
private readonly _depositExistingMASimulation;
|
|
27
29
|
private readonly _depositNewMASimulation;
|
|
@@ -64,6 +66,7 @@ export declare class ApiClient {
|
|
|
64
66
|
* const tradeSimulationClient = ApiClient.tradeSimulation;
|
|
65
67
|
*/
|
|
66
68
|
static get tradeSimulation(): TradeSimulationClient;
|
|
69
|
+
static get fundingRateHistory(): FundingRateClient;
|
|
67
70
|
/**
|
|
68
71
|
* Provides access to the EditCollateralSimulationClient instance.
|
|
69
72
|
* This getter allows for interacting with edit collateral simulation functionalities.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,iCAAiC,MAAM,0CAA0C,CAAC;AACzF,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAC/E,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1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|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FundingRateResolution } from './types';
|
|
2
|
+
import { GetFundingRateChartDataParams } from '../markets/types';
|
|
3
|
+
import MarketsClient from '../markets';
|
|
4
|
+
import { GetFundingRateChartDataResult } from '@reyaxyz/common';
|
|
5
|
+
export default class FundingRateClient {
|
|
6
|
+
private marketId;
|
|
7
|
+
private loadedData;
|
|
8
|
+
private marketClient;
|
|
9
|
+
constructor(marketClient: MarketsClient);
|
|
10
|
+
arm(params: GetFundingRateChartDataParams): Promise<void>;
|
|
11
|
+
private fetchFundingRateData;
|
|
12
|
+
createGraph(params: FundingRateResolution): GetFundingRateChartDataResult;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/funding-rate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,YAAY,CAAgB;gBACxB,YAAY,EAAE,aAAa;IAMjC,GAAG,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;YAMjD,oBAAoB;IAMlC,WAAW,CAAC,MAAM,EAAE,qBAAqB,GAAG,6BAA6B;CAmB1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/funding-rate/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;CACjC,CAAC"}
|
|
@@ -11,4 +11,5 @@ export * from './modules/edit-collateral.simulation/types';
|
|
|
11
11
|
export * from './modules/withdraw-MA.simulation/types';
|
|
12
12
|
export * from './modules/transfer-margin-between-MAs.simulation/types';
|
|
13
13
|
export * from './modules/transfer-MA-Pool.simulation/types';
|
|
14
|
+
export * from './modules/funding-rate/types';
|
|
14
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,iDAAiD,EACjD,0CAA0C,EAC1C,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wDAAwD,CAAC;AACvE,cAAc,6CAA6C,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,mCAAmC,EACnC,qCAAqC,EACrC,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,iDAAiD,EACjD,0CAA0C,EAC1C,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wDAAwD,CAAC;AACvE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"bignumber.js": "^9.1.2"
|
|
39
39
|
},
|
|
40
40
|
"packageManager": "pnpm@8.10.4",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "e4aacf2b8695a831ec55bd9c1fa37a8ce94c6e2a"
|
|
42
42
|
}
|
|
@@ -12,6 +12,7 @@ import DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';
|
|
|
12
12
|
import WithdrawMASimulationClient from './modules/withdraw-MA.simulation';
|
|
13
13
|
import TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';
|
|
14
14
|
import TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';
|
|
15
|
+
import FundingRateClient from './modules/funding-rate';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @description Client for API
|
|
@@ -23,6 +24,7 @@ export class ApiClient {
|
|
|
23
24
|
private readonly _account: AccountClient;
|
|
24
25
|
private readonly _lp: LpClient;
|
|
25
26
|
private readonly _tradeSimulation: TradeSimulationClient;
|
|
27
|
+
private readonly _fundingRateHistory: FundingRateClient;
|
|
26
28
|
private readonly _editCollateralSimulation: EditCollateralSimulationClient;
|
|
27
29
|
private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;
|
|
28
30
|
private readonly _depositNewMASimulation: DepositNewMASimulationClient;
|
|
@@ -37,6 +39,7 @@ export class ApiClient {
|
|
|
37
39
|
this._account = new AccountClient(ApiClient.config.apiEndpoint);
|
|
38
40
|
this._lp = new LpClient(ApiClient.config.apiEndpoint);
|
|
39
41
|
this._tradeSimulation = new TradeSimulationClient(this._account);
|
|
42
|
+
this._fundingRateHistory = new FundingRateClient(this._markets);
|
|
40
43
|
this._editCollateralSimulation = new EditCollateralSimulationClient(
|
|
41
44
|
this._account,
|
|
42
45
|
);
|
|
@@ -120,6 +123,10 @@ export class ApiClient {
|
|
|
120
123
|
return ApiClient.getInstance()._tradeSimulation;
|
|
121
124
|
}
|
|
122
125
|
|
|
126
|
+
public static get fundingRateHistory(): FundingRateClient {
|
|
127
|
+
return ApiClient.getInstance()._fundingRateHistory;
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
/**
|
|
124
131
|
* Provides access to the EditCollateralSimulationClient instance.
|
|
125
132
|
* This getter allows for interacting with edit collateral simulation functionalities.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FundingRateResolution } from './types';
|
|
2
|
+
import { GetFundingRateChartDataParams } from '../markets/types';
|
|
3
|
+
import MarketsClient from '../markets';
|
|
4
|
+
import { GetFundingRateChartDataResult } from '@reyaxyz/common';
|
|
5
|
+
|
|
6
|
+
export default class FundingRateClient {
|
|
7
|
+
private marketId: number | null = null;
|
|
8
|
+
private loadedData: GetFundingRateChartDataResult | null = null;
|
|
9
|
+
private marketClient: MarketsClient;
|
|
10
|
+
constructor(marketClient: MarketsClient) {
|
|
11
|
+
// Constructor added
|
|
12
|
+
this.marketClient = marketClient;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Method to asynchronously load data based on marketId and accountId
|
|
16
|
+
async arm(params: GetFundingRateChartDataParams): Promise<void> {
|
|
17
|
+
this.marketId = params.marketId;
|
|
18
|
+
|
|
19
|
+
this.loadedData = await this.fetchFundingRateData(params);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private async fetchFundingRateData(
|
|
23
|
+
params: GetFundingRateChartDataParams,
|
|
24
|
+
): Promise<GetFundingRateChartDataResult> {
|
|
25
|
+
return this.marketClient.getFundingRateChartData(params);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
createGraph(params: FundingRateResolution): GetFundingRateChartDataResult {
|
|
29
|
+
if (!this.loadedData) {
|
|
30
|
+
throw new Error('Data not loaded. Call arm() first.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (params.resolution === '1h') return this.loadedData;
|
|
34
|
+
|
|
35
|
+
const multiplicator = params.resolution === '24h' ? 24 : 24 * 365;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
fundingRate: this.loadedData.fundingRate * multiplicator,
|
|
39
|
+
fundingRateData: this.loadedData.fundingRateData.map((point) => {
|
|
40
|
+
return {
|
|
41
|
+
timestampInMs: point.timestampInMs,
|
|
42
|
+
value: point.value * multiplicator,
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/clients/types.ts
CHANGED
|
@@ -37,3 +37,4 @@ export * from './modules/edit-collateral.simulation/types';
|
|
|
37
37
|
export * from './modules/withdraw-MA.simulation/types';
|
|
38
38
|
export * from './modules/transfer-margin-between-MAs.simulation/types';
|
|
39
39
|
export * from './modules/transfer-MA-Pool.simulation/types';
|
|
40
|
+
export * from './modules/funding-rate/types';
|