@reyaxyz/api-sdk 0.85.3 → 0.86.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.
@@ -84,18 +84,21 @@ var WithdrawMASimulationClient = /** @class */ (function (_super) {
84
84
  // Synchronous method to simulate operations based on an amount
85
85
  WithdrawMASimulationClient.prototype.simulate = function (params) {
86
86
  var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress, this.reyaChainId);
87
+ var moneyInOutTokenInfo = tokenInfo.name === 'RUSD'
88
+ ? (0, common_1.getRUSDUnderlyingTokenInfo)(params.moneyInOutChainId)
89
+ : tokenInfo;
87
90
  var socketWithdrawFeesEntry = this.socketWithdrawFeesList.find(function (socketWithdrawFeesEntry) {
88
91
  return socketWithdrawFeesEntry.moneyInOutChainId ===
89
92
  params.moneyInOutChainId &&
90
- socketWithdrawFeesEntry.tokenName === tokenInfo.name;
93
+ socketWithdrawFeesEntry.tokenName === moneyInOutTokenInfo.name;
91
94
  });
92
95
  if (!socketWithdrawFeesEntry) {
93
- throw new Error("Socket withdraw fees for chain ".concat(params.moneyInOutChainId, " and token ").concat(tokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
96
+ throw new Error("Socket withdraw fees for chain ".concat(params.moneyInOutChainId, " and token ").concat(moneyInOutTokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
94
97
  }
95
98
  var socketWithdrawFees = {
96
99
  fees: socketWithdrawFeesEntry.fees,
97
- feesInUnderlyingToken: (0, common_1.descale)(tokenInfo.decimals)(socketWithdrawFeesEntry.fees),
98
- underlyingTokenName: tokenInfo.name,
100
+ feesInUnderlyingToken: (0, common_1.descale)(moneyInOutTokenInfo.decimals)(socketWithdrawFeesEntry.fees),
101
+ underlyingTokenName: moneyInOutTokenInfo.name,
99
102
  };
100
103
  var simulateEditCollateralEntity = this.editCollateralClient.simulate({
101
104
  signedAmount: -params.amount,
@@ -1 +1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S,CAAC,IAAI,iGAA8F,CACrL,CAAC;QACJ,CAAC;QAED,IAAM,kBAAkB,GAAuB;YAC7C,IAAI,EAAE,uBAAuB,CAAC,IAAI;YAClC,qBAAqB,EAAE,IAAA,gBAAO,EAAC,SAAS,CAAC,QAAQ,CAAC,CAChD,uBAAuB,CAAC,IAAI,CAC7B;YACD,mBAAmB,EAAE,SAAS,CAAC,IAAI;SACpC,CAAC;QAEF,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,kBAAkB,oBAAA;YAClB,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SACtC,CAAC;IAChC,CAAC;IACH,iCAAC;AAAD,CAAC,AAvED,CAAwD,mBAAU,GAuEjE","sourcesContent":["import {\n getSocketBridgeTime,\n getTokenInfoByAddress,\n ReyaChainId,\n SocketWithdrawFeesEntry,\n RestClient,\n SocketWithdrawFees,\n descale,\n} from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n SimulateWithdrawMAEntity,\n WithdrawMASimulationLoadDataParams,\n WithdrawMASimulationSimulateParams,\n} from './types';\n\nexport default class WithdrawMASimulationClient extends RestClient {\n private editCollateralClient: EditCollateralClient;\n private reyaChainId: ReyaChainId;\n private socketWithdrawFeesList: SocketWithdrawFeesEntry[] = [];\n\n constructor(\n editCollateralClient: EditCollateralClient,\n reyaChainId: ReyaChainId,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\n this.editCollateralClient = editCollateralClient;\n this.reyaChainId = reyaChainId;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: WithdrawMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n\n this.socketWithdrawFeesList = await this.get<SocketWithdrawFeesEntry[]>(\n `/api/socket/withdraw-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: WithdrawMASimulationSimulateParams,\n ): SimulateWithdrawMAEntity {\n const tokenInfo = getTokenInfoByAddress(\n params.tokenAddress,\n this.reyaChainId,\n );\n const socketWithdrawFeesEntry = this.socketWithdrawFeesList.find(\n (socketWithdrawFeesEntry) =>\n socketWithdrawFeesEntry.moneyInOutChainId ===\n params.moneyInOutChainId &&\n socketWithdrawFeesEntry.tokenName === tokenInfo.name,\n );\n if (!socketWithdrawFeesEntry) {\n throw new Error(\n `Socket withdraw fees for chain ${params.moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,\n );\n }\n\n const socketWithdrawFees: SocketWithdrawFees = {\n fees: socketWithdrawFeesEntry.fees,\n feesInUnderlyingToken: descale(tokenInfo.decimals)(\n socketWithdrawFeesEntry.fees,\n ),\n underlyingTokenName: tokenInfo.name,\n };\n\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: params.moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketWithdrawFees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n } as SimulateWithdrawMAEntity;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,CAAC,iBAAiB,wBAAc,mBAAmB,CAAC,IAAI,iGAA8F,CAC/L,CAAC;QACJ,CAAC;QAED,IAAM,kBAAkB,GAAuB;YAC7C,IAAI,EAAE,uBAAuB,CAAC,IAAI;YAClC,qBAAqB,EAAE,IAAA,gBAAO,EAAC,mBAAmB,CAAC,QAAQ,CAAC,CAC1D,uBAAuB,CAAC,IAAI,CAC7B;YACD,mBAAmB,EAAE,mBAAmB,CAAC,IAAI;SAC9C,CAAC;QAEF,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,CAAC,MAAM,CAAC,MAAM;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,kBAAkB,oBAAA;YAClB,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SACtC,CAAC;IAChC,CAAC;IACH,iCAAC;AAAD,CAAC,AA5ED,CAAwD,mBAAU,GA4EjE","sourcesContent":["import {\n getSocketBridgeTime,\n getTokenInfoByAddress,\n ReyaChainId,\n SocketWithdrawFeesEntry,\n RestClient,\n SocketWithdrawFees,\n descale,\n getRUSDUnderlyingTokenInfo,\n} from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n SimulateWithdrawMAEntity,\n WithdrawMASimulationLoadDataParams,\n WithdrawMASimulationSimulateParams,\n} from './types';\n\nexport default class WithdrawMASimulationClient extends RestClient {\n private editCollateralClient: EditCollateralClient;\n private reyaChainId: ReyaChainId;\n private socketWithdrawFeesList: SocketWithdrawFeesEntry[] = [];\n\n constructor(\n editCollateralClient: EditCollateralClient,\n reyaChainId: ReyaChainId,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\n this.editCollateralClient = editCollateralClient;\n this.reyaChainId = reyaChainId;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: WithdrawMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n\n this.socketWithdrawFeesList = await this.get<SocketWithdrawFeesEntry[]>(\n `/api/socket/withdraw-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: WithdrawMASimulationSimulateParams,\n ): SimulateWithdrawMAEntity {\n const tokenInfo = getTokenInfoByAddress(\n params.tokenAddress,\n this.reyaChainId,\n );\n\n const moneyInOutTokenInfo =\n tokenInfo.name === 'RUSD'\n ? getRUSDUnderlyingTokenInfo(params.moneyInOutChainId)\n : tokenInfo;\n const socketWithdrawFeesEntry = this.socketWithdrawFeesList.find(\n (socketWithdrawFeesEntry) =>\n socketWithdrawFeesEntry.moneyInOutChainId ===\n params.moneyInOutChainId &&\n socketWithdrawFeesEntry.tokenName === moneyInOutTokenInfo.name,\n );\n if (!socketWithdrawFeesEntry) {\n throw new Error(\n `Socket withdraw fees for chain ${params.moneyInOutChainId} and token ${moneyInOutTokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,\n );\n }\n\n const socketWithdrawFees: SocketWithdrawFees = {\n fees: socketWithdrawFeesEntry.fees,\n feesInUnderlyingToken: descale(moneyInOutTokenInfo.decimals)(\n socketWithdrawFeesEntry.fees,\n ),\n underlyingTokenName: moneyInOutTokenInfo.name,\n };\n\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: params.moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketWithdrawFees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n } as SimulateWithdrawMAEntity;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAEX,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,UAAU;IAChE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,sBAAsB,CAAiC;gBAG7D,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAQtB,GAAG,CAAC,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC;IAWpE,QAAQ,CACN,MAAM,EAAE,kCAAkC,GACzC,wBAAwB;CAyC5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAEX,UAAU,EAIX,MAAM,iBAAiB,CAAC;AACzB,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,0BAA2B,SAAQ,UAAU;IAChE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,sBAAsB,CAAiC;gBAG7D,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAQtB,GAAG,CAAC,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC;IAWpE,QAAQ,CACN,MAAM,EAAE,kCAAkC,GACzC,wBAAwB;CA8C5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.85.3",
3
+ "version": "0.86.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -39,7 +39,7 @@
39
39
  "ws": "^8.16.0"
40
40
  },
41
41
  "packageManager": "pnpm@8.3.1",
42
- "gitHead": "16729c84a71c0db295a91b9eea7df49f8a1b9beb",
42
+ "gitHead": "ae4f10275c3306cc3a7eb8ff384ebd6595b8cdd6",
43
43
  "devDependencies": {
44
44
  "@types/ws": "8.5.10"
45
45
  }
@@ -6,6 +6,7 @@ import {
6
6
  RestClient,
7
7
  SocketWithdrawFees,
8
8
  descale,
9
+ getRUSDUnderlyingTokenInfo,
9
10
  } from '@reyaxyz/common';
10
11
  import EditCollateralClient from '../edit-collateral.simulation';
11
12
  import {
@@ -49,24 +50,29 @@ export default class WithdrawMASimulationClient extends RestClient {
49
50
  params.tokenAddress,
50
51
  this.reyaChainId,
51
52
  );
53
+
54
+ const moneyInOutTokenInfo =
55
+ tokenInfo.name === 'RUSD'
56
+ ? getRUSDUnderlyingTokenInfo(params.moneyInOutChainId)
57
+ : tokenInfo;
52
58
  const socketWithdrawFeesEntry = this.socketWithdrawFeesList.find(
53
59
  (socketWithdrawFeesEntry) =>
54
60
  socketWithdrawFeesEntry.moneyInOutChainId ===
55
61
  params.moneyInOutChainId &&
56
- socketWithdrawFeesEntry.tokenName === tokenInfo.name,
62
+ socketWithdrawFeesEntry.tokenName === moneyInOutTokenInfo.name,
57
63
  );
58
64
  if (!socketWithdrawFeesEntry) {
59
65
  throw new Error(
60
- `Socket withdraw fees for chain ${params.moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
66
+ `Socket withdraw fees for chain ${params.moneyInOutChainId} and token ${moneyInOutTokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
61
67
  );
62
68
  }
63
69
 
64
70
  const socketWithdrawFees: SocketWithdrawFees = {
65
71
  fees: socketWithdrawFeesEntry.fees,
66
- feesInUnderlyingToken: descale(tokenInfo.decimals)(
72
+ feesInUnderlyingToken: descale(moneyInOutTokenInfo.decimals)(
67
73
  socketWithdrawFeesEntry.fees,
68
74
  ),
69
- underlyingTokenName: tokenInfo.name,
75
+ underlyingTokenName: moneyInOutTokenInfo.name,
70
76
  };
71
77
 
72
78
  const simulateEditCollateralEntity = this.editCollateralClient.simulate({