@reyaxyz/api-sdk 0.45.1 → 0.46.1
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/modules/deposit-existing-MA.simulation/index.js +3 -3
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js.map +1 -1
- package/dist/clients/modules/deposit-existing-MA.simulation/types.js.map +1 -1
- package/dist/clients/modules/edit-collateral.simulation/index.js +1 -1
- package/dist/clients/modules/edit-collateral.simulation/index.js.map +1 -1
- package/dist/clients/modules/edit-collateral.simulation/types.js.map +1 -1
- package/dist/clients/modules/withdraw-MA.simulation/index.js +3 -3
- package/dist/clients/modules/withdraw-MA.simulation/index.js.map +1 -1
- package/dist/clients/modules/withdraw-MA.simulation/types.js.map +1 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts +3 -3
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts.map +1 -1
- package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts +2 -2
- package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts.map +1 -1
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts +2 -2
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/modules/deposit-existing-MA.simulation/index.ts +3 -3
- package/src/clients/modules/deposit-existing-MA.simulation/types.ts +3 -3
- package/src/clients/modules/edit-collateral.simulation/index.ts +2 -2
- package/src/clients/modules/edit-collateral.simulation/types.ts +2 -2
- package/src/clients/modules/withdraw-MA.simulation/index.ts +3 -3
- package/src/clients/modules/withdraw-MA.simulation/types.ts +2 -2
|
@@ -60,8 +60,8 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
60
60
|
// Synchronous method to simulate operations based on an amount
|
|
61
61
|
DepositExistingMASimulationClient.prototype.simulate = function (params) {
|
|
62
62
|
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
signedAmount: params.amount,
|
|
64
|
+
tokenAddress: params.tokenAddress,
|
|
65
65
|
});
|
|
66
66
|
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
67
67
|
moneyInOutChainId: params.moneyInOutChainId,
|
|
@@ -71,7 +71,7 @@ var DepositExistingMASimulationClient = /** @class */ (function () {
|
|
|
71
71
|
});
|
|
72
72
|
var result = {
|
|
73
73
|
fees: fees.fees,
|
|
74
|
-
|
|
74
|
+
feesUnderlyingToken: fees.feesUnderlyingToken,
|
|
75
75
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
76
76
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
77
77
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4E;AAQ5E;IAEE,2CAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,+CAAG,GAAT,UAAU,MAAiD;;;;4BACzD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,oDAAQ,GAAR,UACE,MAAiD;QAEjD,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4E;AAQ5E;IAEE,2CAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,+CAAG,GAAT,UAAU,MAAiD;;;;4BACzD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,oDAAQ,GAAR,UACE,MAAiD;QAEjD,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,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,IAAM,IAAI,GAAG,IAAA,6BAAoB,EAAC;YAChC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC,CAAC;QAEH,IAAM,MAAM,GAAoC;YAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SAClE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,wCAAC;AAAD,CAAC,AAzCD,IAyCC","sourcesContent":["import { getSocketBridgeTime, getSocketDepositFees } from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n DepositExistingMASimulationLoadDataParams,\n DepositExistingMASimulationSimulateParams,\n SimulateDepositExistingMAEntity,\n} from './types';\n\nexport default class DepositExistingMASimulationClient {\n private editCollateralClient: EditCollateralClient;\n constructor(editCollateralClient: EditCollateralClient) {\n // Constructor added\n this.editCollateralClient = editCollateralClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(params: DepositExistingMASimulationLoadDataParams): Promise<void> {\n await this.editCollateralClient.arm({\n marginAccountId: params.marginAccountId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositExistingMASimulationSimulateParams,\n ): SimulateDepositExistingMAEntity {\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 const fees = getSocketDepositFees({\n moneyInOutChainId: params.moneyInOutChainId,\n });\n\n const result: SimulateDepositExistingMAEntity = {\n fees: fees.fees,\n feesUnderlyingToken: fees.feesUnderlyingToken,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n };\n\n return result;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type DepositExistingMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type DepositExistingMASimulationSimulateParams = {\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateDepositExistingMAEntity = {\n fees: number;\n feesUnderlyingToken: string;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
|
|
@@ -70,7 +70,7 @@ var EditCollateralSimulationClient = /** @class */ (function () {
|
|
|
70
70
|
throw new Error('Data not loaded. Call arm() first.');
|
|
71
71
|
}
|
|
72
72
|
var userAccountExposure = new common_1.ExposureCommand(this.loadedData.exposureDataAccount.accountId, this.loadedData.exposureDataAccount.rootCollateralPoolId, this.loadedData.exposureDataAccount.oraclePricePerMarket, this.loadedData.exposureDataAccount.accountBalancePerAsset, this.loadedData.exposureDataAccount.groupedByCollateral, this.loadedData.exposureDataAccount.riskMultipliers, this.loadedData.exposureDataAccount.riskMatrices, this.loadedData.exposureDataAccount.exchangeInfoPerAsset, this.loadedData.exposureDataAccount.positionInfoMarketConfiguration, this.loadedData.exposureDataAccount.uniqueTokenAddresses, this.loadedData.exposureDataAccount.uniqueQuoteCollaterals, this.loadedData.exposureDataAccount.tokenMarginInfoPerAsset, this.loadedData.exposureDataAccount.realizedPnLSum, this.loadedData.exposureDataAccount.unrealizedPnLSum, this.loadedData.exposureDataAccount.collateralAddressToExchangePrice);
|
|
73
|
-
var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.
|
|
73
|
+
var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.signedAmount, params.tokenAddress);
|
|
74
74
|
var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo);
|
|
75
75
|
var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio, newMarginInfo);
|
|
76
76
|
return {
|
|
@@ -1 +1 @@
|
|
|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CollateralSimulationSimulateParams,\n SimulateEditCollateralEntity,\n} from './types';\nimport AccountClient from '../account';\nimport {\n EditCollateralSimulationState,\n ExposureCommand,\n} from '@reyaxyz/common';\n\nexport default class EditCollateralSimulationClient {\n private accountId: number | null = null;\n private loadedData: EditCollateralSimulationState | null = null;\n private accountClient: AccountClient;\n constructor(accountClient: AccountClient) {\n // Constructor added\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 const newMarginInfo =\n userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(\n params.signedAmount,\n params.tokenAddress,\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":"types.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, TokenEntity } from '@reyaxyz/common';\n\nexport type EditCollateralSimulationLoadDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type EditCollateralSimulationSimulateParams = {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, TokenEntity } from '@reyaxyz/common';\n\nexport type EditCollateralSimulationLoadDataParams = {\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type EditCollateralSimulationSimulateParams = {\n signedAmount: number; // + for deposit, - for withdraw\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateEditCollateralEntity = {\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
|
|
@@ -60,15 +60,15 @@ var WithdrawMASimulationClient = /** @class */ (function () {
|
|
|
60
60
|
// Synchronous method to simulate operations based on an amount
|
|
61
61
|
WithdrawMASimulationClient.prototype.simulate = function (params) {
|
|
62
62
|
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
signedAmount: -params.amount,
|
|
64
|
+
tokenAddress: params.tokenAddress,
|
|
65
65
|
});
|
|
66
66
|
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
67
67
|
moneyInOutChainId: params.moneyInOutChainId,
|
|
68
68
|
}).bridgeTimeInMS;
|
|
69
69
|
var fees = (0, common_1.getSocketWithdrawFees)({
|
|
70
70
|
reyaChainId: params.reyaChainId,
|
|
71
|
-
tokenAddress: params.
|
|
71
|
+
tokenAddress: params.tokenAddress,
|
|
72
72
|
});
|
|
73
73
|
return {
|
|
74
74
|
fees: fees.fees,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6E;AAQ7E;IAEE,oCAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,wCAAG,GAAT,UAAU,MAA0C;;;;4BAClD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,6CAAQ,GAAR,UACE,MAA0C;QAE1C,IAAM,4BAA4B,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACtE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6E;AAQ7E;IAEE,oCAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,wCAAG,GAAT,UAAU,MAA0C;;;;4BAClD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;4BAClC,eAAe,EAAE,MAAM,CAAC,eAAe;yBACxC,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,6CAAQ,GAAR,UACE,MAA0C;QAE1C,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,IAAM,IAAI,GAAG,IAAA,8BAAqB,EAAC;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SACtC,CAAC;IAChC,CAAC;IACH,iCAAC;AAAD,CAAC,AAvCD,IAuCC","sourcesContent":["import { getSocketBridgeTime, getSocketWithdrawFees } from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n SimulateWithdrawMAEntity,\n WithdrawMASimulationLoadDataParams,\n WithdrawMASimulationSimulateParams,\n} from './types';\n\nexport default class WithdrawMASimulationClient {\n private editCollateralClient: EditCollateralClient;\n constructor(editCollateralClient: EditCollateralClient) {\n // Constructor added\n this.editCollateralClient = editCollateralClient;\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\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: WithdrawMASimulationSimulateParams,\n ): SimulateWithdrawMAEntity {\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 const fees = getSocketWithdrawFees({\n reyaChainId: params.reyaChainId,\n tokenAddress: params.tokenAddress,\n });\n\n return {\n fees: fees.fees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n } as SimulateWithdrawMAEntity;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n ReyaChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n reyaChainId: ReyaChainId;\n moneyInOutChainId: MoneyInOutChainId;\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginAccountEntity,\n MoneyInOutChainId,\n ReyaChainId,\n TokenEntity,\n} from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type WithdrawMASimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type WithdrawMASimulationSimulateParams = {\n reyaChainId: ReyaChainId;\n moneyInOutChainId: MoneyInOutChainId;\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateWithdrawMAEntity = {\n fees: number;\n bridgeTimeInMS: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n};\n"]}
|
|
@@ -3,12 +3,12 @@ import { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simul
|
|
|
3
3
|
export type DepositExistingMASimulationLoadDataParams = EditCollateralSimulationLoadDataParams;
|
|
4
4
|
export type DepositExistingMASimulationSimulateParams = {
|
|
5
5
|
moneyInOutChainId: MoneyInOutChainId;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
amount: number;
|
|
7
|
+
tokenAddress: TokenEntity['address'];
|
|
8
8
|
};
|
|
9
9
|
export type SimulateDepositExistingMAEntity = {
|
|
10
10
|
fees: number;
|
|
11
|
-
|
|
11
|
+
feesUnderlyingToken: string;
|
|
12
12
|
bridgeTimeInMS: number;
|
|
13
13
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
14
14
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,yCAAyC,GACnD,sCAAsC,CAAC;AAEzC,MAAM,MAAM,yCAAyC,GAAG;IACtD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
|
@@ -3,8 +3,8 @@ export type EditCollateralSimulationLoadDataParams = {
|
|
|
3
3
|
marginAccountId: MarginAccountEntity['id'];
|
|
4
4
|
};
|
|
5
5
|
export type EditCollateralSimulationSimulateParams = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
signedAmount: number;
|
|
7
|
+
tokenAddress: TokenEntity['address'];
|
|
8
8
|
};
|
|
9
9
|
export type SimulateEditCollateralEntity = {
|
|
10
10
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,MAAM,sCAAsC,GAAG;IACnD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,MAAM,sCAAsC,GAAG;IACnD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
|
@@ -4,8 +4,8 @@ export type WithdrawMASimulationLoadDataParams = EditCollateralSimulationLoadDat
|
|
|
4
4
|
export type WithdrawMASimulationSimulateParams = {
|
|
5
5
|
reyaChainId: ReyaChainId;
|
|
6
6
|
moneyInOutChainId: MoneyInOutChainId;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
amount: number;
|
|
8
|
+
tokenAddress: TokenEntity['address'];
|
|
9
9
|
};
|
|
10
10
|
export type SimulateWithdrawMAEntity = {
|
|
11
11
|
fees: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,kCAAkC,GAC5C,sCAAsC,CAAC;AAEzC,MAAM,MAAM,kCAAkC,GAAG;IAC/C,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/withdraw-MA.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAE7F,MAAM,MAAM,kCAAkC,GAC5C,sCAAsC,CAAC;AAEzC,MAAM,MAAM,kCAAkC,GAAG;IAC/C,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;CAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.23.
|
|
36
|
+
"@reyaxyz/common": "0.23.1",
|
|
37
37
|
"axios": "^1.6.2",
|
|
38
38
|
"bignumber.js": "^9.1.2"
|
|
39
39
|
},
|
|
40
40
|
"packageManager": "pnpm@8.10.4",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "65f3be42b0110c2d3c4abc373cdd55cc8251665e"
|
|
42
42
|
}
|
|
@@ -25,8 +25,8 @@ export default class DepositExistingMASimulationClient {
|
|
|
25
25
|
params: DepositExistingMASimulationSimulateParams,
|
|
26
26
|
): SimulateDepositExistingMAEntity {
|
|
27
27
|
const simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
signedAmount: params.amount,
|
|
29
|
+
tokenAddress: params.tokenAddress,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
const bridgeTimeInMS = getSocketBridgeTime({
|
|
@@ -39,7 +39,7 @@ export default class DepositExistingMASimulationClient {
|
|
|
39
39
|
|
|
40
40
|
const result: SimulateDepositExistingMAEntity = {
|
|
41
41
|
fees: fees.fees,
|
|
42
|
-
|
|
42
|
+
feesUnderlyingToken: fees.feesUnderlyingToken,
|
|
43
43
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
44
44
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
45
45
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
@@ -10,13 +10,13 @@ export type DepositExistingMASimulationLoadDataParams =
|
|
|
10
10
|
|
|
11
11
|
export type DepositExistingMASimulationSimulateParams = {
|
|
12
12
|
moneyInOutChainId: MoneyInOutChainId;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
amount: number;
|
|
14
|
+
tokenAddress: TokenEntity['address'];
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export type SimulateDepositExistingMAEntity = {
|
|
18
18
|
fees: number;
|
|
19
|
-
|
|
19
|
+
feesUnderlyingToken: string;
|
|
20
20
|
bridgeTimeInMS: number;
|
|
21
21
|
marginRatio: MarginAccountEntity['marginRatioPercentage'];
|
|
22
22
|
marginRatioHealth: MarginAccountEntity['marginRatioHealth'];
|
|
@@ -56,8 +56,8 @@ export default class EditCollateralSimulationClient {
|
|
|
56
56
|
|
|
57
57
|
const newMarginInfo =
|
|
58
58
|
userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(
|
|
59
|
-
params.
|
|
60
|
-
params.
|
|
59
|
+
params.signedAmount,
|
|
60
|
+
params.tokenAddress,
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);
|
|
@@ -5,8 +5,8 @@ export type EditCollateralSimulationLoadDataParams = {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export type EditCollateralSimulationSimulateParams = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
signedAmount: number; // + for deposit, - for withdraw
|
|
9
|
+
tokenAddress: TokenEntity['address'];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export type SimulateEditCollateralEntity = {
|
|
@@ -25,8 +25,8 @@ export default class WithdrawMASimulationClient {
|
|
|
25
25
|
params: WithdrawMASimulationSimulateParams,
|
|
26
26
|
): SimulateWithdrawMAEntity {
|
|
27
27
|
const simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
signedAmount: -params.amount,
|
|
29
|
+
tokenAddress: params.tokenAddress,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
const bridgeTimeInMS = getSocketBridgeTime({
|
|
@@ -35,7 +35,7 @@ export default class WithdrawMASimulationClient {
|
|
|
35
35
|
|
|
36
36
|
const fees = getSocketWithdrawFees({
|
|
37
37
|
reyaChainId: params.reyaChainId,
|
|
38
|
-
tokenAddress: params.
|
|
38
|
+
tokenAddress: params.tokenAddress,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
return {
|
|
@@ -12,8 +12,8 @@ export type WithdrawMASimulationLoadDataParams =
|
|
|
12
12
|
export type WithdrawMASimulationSimulateParams = {
|
|
13
13
|
reyaChainId: ReyaChainId;
|
|
14
14
|
moneyInOutChainId: MoneyInOutChainId;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
amount: number;
|
|
16
|
+
tokenAddress: TokenEntity['address'];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export type SimulateWithdrawMAEntity = {
|