@reyaxyz/api-sdk 0.91.4 → 0.92.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.
@@ -75,6 +75,9 @@ var EditCollateralSimulationClient = /** @class */ (function () {
75
75
  if (tokenInfo.isRUSDUnderlying) {
76
76
  tokenInfo = (0, common_1.getTokenInfoByName)('RUSD', this.reyaChainId);
77
77
  }
78
+ else {
79
+ tokenInfo = (0, common_1.getTokenInfoByName)(tokenInfo.name, this.reyaChainId);
80
+ }
78
81
  var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.signedAmount, tokenInfo.address);
79
82
  var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo);
80
83
  var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio, newMarginInfo);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,0CAMyB;AACzB;IAKE,wCAAY,WAAwB,EAAE,aAA4B;QAH1D,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAAyC,IAAI,CAAC;QAG9D,oBAAoB;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,wDAAwD;IAClD,4CAAG,GAAT,UAAU,MAA8C;;;;;;wBACtD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;wBAExC,KAAA,IAAI,CAAA;wBACF,qBAAM,IAAI,CAAC,aAAa,CAAC,sCAAsC,CAAC;gCAC9D,eAAe,EAAE,IAAI,CAAC,SAAS;6BAChC,CAAC,EAAA;;wBAHJ,GAAK,UAAU;4BACb,SAEE,CAAC;;;;;KACN;IAED,+DAA+D;IAC/D,iDAAQ,GAAR,UACE,MAA8C;QAE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Y,EACnB,SAAS,CAAC,OAAO,CAClB,CAAC;QAEJ,IAAM,WAAW,GAAG,wBAAe,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAElE,IAAM,iBAAiB,GAAG,wBAAe,CAAC,oBAAoB,CAC5D,WAAW,EACX,aAAa,CACd,CAAC;QAEF,OAAO;YACL,WAAW,EAAE,WAAW,GAAG,GAAG;YAC9B,iBAAiB,EAAE,iBAAiB;SACL,CAAC;IACpC,CAAC;IACH,qCAAC;AAAD,CAAC,AAtED,IAsEC","sourcesContent":["import {\n EditCollateralSimulationLoadDataParams,\n EditCollateralSimulationSimulateParams,\n SimulateEditCollateralEntity,\n} from './types';\nimport AccountClient from '../account';\nimport {\n EditCollateralSimulationState,\n ExposureCommand,\n ReyaChainId,\n getTokenInfoByAddress,\n getTokenInfoByName,\n} from '@reyaxyz/common';\nexport default class EditCollateralSimulationClient {\n private reyaChainId: ReyaChainId;\n private accountId: number | null = null;\n private loadedData: EditCollateralSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {\n // Constructor added\n this.reyaChainId = reyaChainId;\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: EditCollateralSimulationLoadDataParams): Promise<void> {\n this.accountId = params.marginAccountId;\n\n this.loadedData =\n await this.accountClient.getEditCollateralSimulationInitialData({\n marginAccountId: this.accountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: EditCollateralSimulationSimulateParams,\n ): SimulateEditCollateralEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const userAccountExposure = new ExposureCommand(\n this.loadedData.exposureDataAccount.accountId,\n this.loadedData.exposureDataAccount.rootCollateralPoolId,\n this.loadedData.exposureDataAccount.oraclePricePerMarket,\n this.loadedData.exposureDataAccount.accountBalancePerAsset,\n this.loadedData.exposureDataAccount.groupedByCollateral,\n this.loadedData.exposureDataAccount.riskMultipliers,\n this.loadedData.exposureDataAccount.riskMatrices,\n this.loadedData.exposureDataAccount.exchangeInfoPerAsset,\n this.loadedData.exposureDataAccount.positionInfoMarketConfiguration,\n this.loadedData.exposureDataAccount.uniqueTokenAddresses,\n this.loadedData.exposureDataAccount.uniqueQuoteCollaterals,\n this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataAccount.realizedPnLSum,\n this.loadedData.exposureDataAccount.unrealizedPnLSum,\n this.loadedData.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (tokenInfo.isRUSDUnderlying) {\n tokenInfo = getTokenInfoByName('RUSD', this.reyaChainId);\n }\n\n const newMarginInfo =\n userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(\n params.signedAmount,\n tokenInfo.address,\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio,\n newMarginInfo,\n );\n\n return {\n marginRatio: marginRatio * 100,\n marginRatioHealth: marginRatioHealth,\n } as SimulateEditCollateralEntity;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,0CAMyB;AACzB;IAKE,wCAAY,WAAwB,EAAE,aAA4B;QAH1D,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAAyC,IAAI,CAAC;QAG9D,oBAAoB;QACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,wDAAwD;IAClD,4CAAG,GAAT,UAAU,MAA8C;;;;;;wBACtD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;wBAExC,KAAA,IAAI,CAAA;wBACF,qBAAM,IAAI,CAAC,aAAa,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gB,EAAE,CAAC;YAC/B,SAAS,GAAG,IAAA,2BAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,IAAA,2BAAkB,EAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACnE,CAAC;QAED,IAAM,aAAa,GACjB,mBAAmB,CAAC,sCAAsC,CACxD,MAAM,CAAC,YAAY,EACnB,SAAS,CAAC,OAAO,CAClB,CAAC;QAEJ,IAAM,WAAW,GAAG,wBAAe,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAElE,IAAM,iBAAiB,GAAG,wBAAe,CAAC,oBAAoB,CAC5D,WAAW,EACX,aAAa,CACd,CAAC;QAEF,OAAO;YACL,WAAW,EAAE,WAAW,GAAG,GAAG;YAC9B,iBAAiB,EAAE,iBAAiB;SACL,CAAC;IACpC,CAAC;IACH,qCAAC;AAAD,CAAC,AAxED,IAwEC","sourcesContent":["import {\n EditCollateralSimulationLoadDataParams,\n EditCollateralSimulationSimulateParams,\n SimulateEditCollateralEntity,\n} from './types';\nimport AccountClient from '../account';\nimport {\n EditCollateralSimulationState,\n ExposureCommand,\n ReyaChainId,\n getTokenInfoByAddress,\n getTokenInfoByName,\n} from '@reyaxyz/common';\nexport default class EditCollateralSimulationClient {\n private reyaChainId: ReyaChainId;\n private accountId: number | null = null;\n private loadedData: EditCollateralSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(reyaChainId: ReyaChainId, accountClient: AccountClient) {\n // Constructor added\n this.reyaChainId = reyaChainId;\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: EditCollateralSimulationLoadDataParams): Promise<void> {\n this.accountId = params.marginAccountId;\n\n this.loadedData =\n await this.accountClient.getEditCollateralSimulationInitialData({\n marginAccountId: this.accountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: EditCollateralSimulationSimulateParams,\n ): SimulateEditCollateralEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const userAccountExposure = new ExposureCommand(\n this.loadedData.exposureDataAccount.accountId,\n this.loadedData.exposureDataAccount.rootCollateralPoolId,\n this.loadedData.exposureDataAccount.oraclePricePerMarket,\n this.loadedData.exposureDataAccount.accountBalancePerAsset,\n this.loadedData.exposureDataAccount.groupedByCollateral,\n this.loadedData.exposureDataAccount.riskMultipliers,\n this.loadedData.exposureDataAccount.riskMatrices,\n this.loadedData.exposureDataAccount.exchangeInfoPerAsset,\n this.loadedData.exposureDataAccount.positionInfoMarketConfiguration,\n this.loadedData.exposureDataAccount.uniqueTokenAddresses,\n this.loadedData.exposureDataAccount.uniqueQuoteCollaterals,\n this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset,\n this.loadedData.exposureDataAccount.realizedPnLSum,\n this.loadedData.exposureDataAccount.unrealizedPnLSum,\n this.loadedData.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n let tokenInfo = getTokenInfoByAddress(params.tokenAddress);\n if (tokenInfo.isRUSDUnderlying) {\n tokenInfo = getTokenInfoByName('RUSD', this.reyaChainId);\n } else {\n tokenInfo = getTokenInfoByName(tokenInfo.name, this.reyaChainId);\n }\n\n const newMarginInfo =\n userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(\n params.signedAmount,\n tokenInfo.address,\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio,\n newMarginInfo,\n );\n\n return {\n marginRatio: marginRatio * 100,\n marginRatioHealth: marginRatioHealth,\n } as SimulateEditCollateralEntity;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAGL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,aAAa,CAAgB;gBACzB,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAO5D,GAAG,CAAC,MAAM,EAAE,sCAAsC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,QAAQ,CACN,MAAM,EAAE,sCAAsC,GAC7C,4BAA4B;CA8ChC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AACjB,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAGL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AACzB,MAAM,CAAC,OAAO,OAAO,8BAA8B;IACjD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,aAAa,CAAgB;gBACzB,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAO5D,GAAG,CAAC,MAAM,EAAE,sCAAsC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,QAAQ,CACN,MAAM,EAAE,sCAAsC,GAC7C,4BAA4B;CAgDhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.91.4",
3
+ "version": "0.92.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,13 +33,13 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.120.0",
36
+ "@reyaxyz/common": "0.122.0",
37
37
  "bignumber.js": "^9.1.2",
38
38
  "isomorphic-ws": "^5.0.0",
39
39
  "ws": "^8.16.0"
40
40
  },
41
41
  "packageManager": "pnpm@8.3.1",
42
- "gitHead": "d86ee44b3242f7b46ca1b7b84701b59de8623371",
42
+ "gitHead": "23137238bed500c4567d2962c1d23ad4f6d5d6d1",
43
43
  "devDependencies": {
44
44
  "@types/ws": "8.5.10"
45
45
  }
@@ -61,6 +61,8 @@ export default class EditCollateralSimulationClient {
61
61
  let tokenInfo = getTokenInfoByAddress(params.tokenAddress);
62
62
  if (tokenInfo.isRUSDUnderlying) {
63
63
  tokenInfo = getTokenInfoByName('RUSD', this.reyaChainId);
64
+ } else {
65
+ tokenInfo = getTokenInfoByName(tokenInfo.name, this.reyaChainId);
64
66
  }
65
67
 
66
68
  const newMarginInfo =