@reyaxyz/api-sdk 0.69.3 → 0.69.4
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 +8 -7
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js.map +1 -1
- package/dist/clients/modules/deposit-passive-pool.simulation/index.js +8 -9
- package/dist/clients/modules/deposit-passive-pool.simulation/index.js.map +1 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/index.d.ts.map +1 -1
- package/dist/types/clients/modules/deposit-passive-pool.simulation/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/deposit-existing-MA.simulation/index.ts +11 -11
- package/src/clients/modules/deposit-passive-pool.simulation/index.ts +16 -13
|
@@ -52,6 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
var common_1 = require("@reyaxyz/common");
|
|
55
|
+
var common_2 = require("@reyaxyz/common");
|
|
55
56
|
var DepositExistingMASimulationClient = /** @class */ (function (_super) {
|
|
56
57
|
__extends(DepositExistingMASimulationClient, _super);
|
|
57
58
|
function DepositExistingMASimulationClient(editCollateralClient, host, apiTimeout) {
|
|
@@ -82,33 +83,33 @@ var DepositExistingMASimulationClient = /** @class */ (function (_super) {
|
|
|
82
83
|
};
|
|
83
84
|
// Synchronous method to simulate operations based on an amount
|
|
84
85
|
DepositExistingMASimulationClient.prototype.simulate = function (params) {
|
|
85
|
-
var
|
|
86
|
+
var moneyInOutChainId = params.moneyInOutChainId;
|
|
87
|
+
var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress, moneyInOutChainId);
|
|
86
88
|
var socketDpositFeesRow = this.socketDepositFeesList.find(function (socketDepositFeesRow) {
|
|
87
|
-
return socketDepositFeesRow.moneyInOutChainId ===
|
|
89
|
+
return socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
|
|
88
90
|
socketDepositFeesRow.tokenName === tokenInfo.name;
|
|
89
91
|
});
|
|
90
92
|
if (!socketDpositFeesRow) {
|
|
91
|
-
throw new Error("Socket deposit fees for chain ".concat(
|
|
93
|
+
throw new Error("Socket deposit fees for chain ".concat(moneyInOutChainId, " and token ").concat(tokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
|
|
92
94
|
}
|
|
93
95
|
var socketDepositFees = {
|
|
94
96
|
fees: socketDpositFeesRow.fees,
|
|
95
97
|
feesInUnderlyingToken: (0, common_1.descale)(18)(socketDpositFeesRow.fees),
|
|
96
|
-
underlyingTokenName:
|
|
98
|
+
underlyingTokenName: (0, common_2.getNativeToken)(moneyInOutChainId),
|
|
97
99
|
};
|
|
98
100
|
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
99
101
|
signedAmount: params.amount,
|
|
100
102
|
tokenAddress: params.tokenAddress,
|
|
101
103
|
});
|
|
102
104
|
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
103
|
-
moneyInOutChainId:
|
|
105
|
+
moneyInOutChainId: moneyInOutChainId,
|
|
104
106
|
}).bridgeTimeInMS;
|
|
105
|
-
|
|
107
|
+
return {
|
|
106
108
|
socketDepositFees: socketDepositFees,
|
|
107
109
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
108
110
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
109
111
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
110
112
|
};
|
|
111
|
-
return result;
|
|
112
113
|
};
|
|
113
114
|
return DepositExistingMASimulationClient;
|
|
114
115
|
}(common_1.RestClient));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAOzB,0CAAiD;AAEjD;IAA+D,qDAAU;IAIvE,2CACE,oBAA0C,EAC1C,IAAY,EACZ,UAA0B;QAE1B,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QAPlB,2BAAqB,GAA2B,EAAE,CAAC;QAQzD,KAAI,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;wBAEH,KAAA,IAAI,CAAA;wBAAyB,qBAAM,IAAI,CAAC,GAAG,CACzC,0BAA0B,CAC3B,EAAA;;wBAFD,GAAK,qBAAqB,GAAG,SAE5B,CAAC;;;;;KACH;IAED,+DAA+D;IAC/D,oDAAQ,GAAR,UACE,MAAiD;QAEjD,IAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAM,SAAS,GAAG,IAAA,8BAAqB,EACrC,MAAM,CAAC,YAAY,EACnB,iBAAiB,CAClB,CAAC;QACF,IAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CACzD,UAAC,oBAAoB;YACnB,OAAA,oBAAoB,CAAC,iBAAiB,KAAK,iBAAiB;gBAC5D,oBAAoB,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI;QADjD,CACiD,CACpD,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,wCAAiC,iBAAiB,wBAAc,SAAS,CAAC,IAAI,iGAA8F,CAC7K,CAAC;QACJ,CAAC;QACD,IAAM,iBAAiB,GAAsB;YAC3C,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,qBAAqB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC5D,mBAAmB,EAAE,IAAA,uBAAc,EAAC,iBAAiB,CAAC;SACvD,CAAC;QAEF,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,iBAAiB;SACrC,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,cAAc;YAC9B,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SAClE,CAAC;IACJ,CAAC;IACH,wCAAC;AAAD,CAAC,AAjED,CAA+D,mBAAU,GAiExE","sourcesContent":["import {\n descale,\n getSocketBridgeTime,\n getTokenInfoByAddress,\n RestClient,\n SocketDepositFees,\n SocketDepositFeesRow,\n} from '@reyaxyz/common';\nimport EditCollateralClient from '../edit-collateral.simulation';\nimport {\n DepositExistingMASimulationLoadDataParams,\n DepositExistingMASimulationSimulateParams,\n SimulateDepositExistingMAEntity,\n} from './types';\nimport { getNativeToken } from '@reyaxyz/common';\n\nexport default class DepositExistingMASimulationClient extends RestClient {\n private editCollateralClient: EditCollateralClient;\n private socketDepositFeesList: SocketDepositFeesRow[] = [];\n\n constructor(\n editCollateralClient: EditCollateralClient,\n host: string,\n apiTimeout?: number | null,\n ) {\n super(host, apiTimeout);\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 this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(\n `/api/socket/deposit-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositExistingMASimulationSimulateParams,\n ): SimulateDepositExistingMAEntity {\n const moneyInOutChainId = params.moneyInOutChainId;\n const tokenInfo = getTokenInfoByAddress(\n params.tokenAddress,\n moneyInOutChainId,\n );\n const socketDpositFeesRow = this.socketDepositFeesList.find(\n (socketDepositFeesRow) =>\n socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&\n socketDepositFeesRow.tokenName === tokenInfo.name,\n );\n if (!socketDpositFeesRow) {\n throw new Error(\n `Socket deposit fees for chain ${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 const socketDepositFees: SocketDepositFees = {\n fees: socketDpositFeesRow.fees,\n feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),\n underlyingTokenName: getNativeToken(moneyInOutChainId),\n };\n\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketDepositFees: socketDepositFees,\n bridgeTimeInMS: bridgeTimeInMS,\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n };\n }\n}\n"]}
|
|
@@ -53,7 +53,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
var common_1 = require("@reyaxyz/common");
|
|
55
55
|
var common_2 = require("@reyaxyz/common");
|
|
56
|
-
var common_3 = require("@reyaxyz/common");
|
|
57
56
|
var DepositPassivePoolSimulationClient = /** @class */ (function (_super) {
|
|
58
57
|
__extends(DepositPassivePoolSimulationClient, _super);
|
|
59
58
|
function DepositPassivePoolSimulationClient(host, apiTimeout) {
|
|
@@ -79,27 +78,27 @@ var DepositPassivePoolSimulationClient = /** @class */ (function (_super) {
|
|
|
79
78
|
};
|
|
80
79
|
// Synchronous method to simulate operations based on an amount
|
|
81
80
|
DepositPassivePoolSimulationClient.prototype.simulate = function (params) {
|
|
82
|
-
var
|
|
81
|
+
var moneyInOutChainId = params.moneyInOutChainId;
|
|
82
|
+
var tokenInfo = (0, common_1.getRUSDUnderlyingTokenInfo)(moneyInOutChainId);
|
|
83
83
|
var socketDpositFeesRow = this.socketDepositFeesList.find(function (socketDepositFeesRow) {
|
|
84
|
-
return socketDepositFeesRow.moneyInOutChainId ===
|
|
84
|
+
return socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
|
|
85
85
|
socketDepositFeesRow.tokenName === tokenInfo.name;
|
|
86
86
|
});
|
|
87
87
|
if (!socketDpositFeesRow) {
|
|
88
|
-
throw new Error("Socket deposit fees for chain ".concat(
|
|
88
|
+
throw new Error("Socket deposit fees for chain ".concat(moneyInOutChainId, " and token ").concat(tokenInfo.name, " not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)"));
|
|
89
89
|
}
|
|
90
90
|
var socketDepositFees = {
|
|
91
91
|
fees: socketDpositFeesRow.fees,
|
|
92
|
-
feesInUnderlyingToken: (0,
|
|
93
|
-
underlyingTokenName:
|
|
92
|
+
feesInUnderlyingToken: (0, common_1.descale)(18)(socketDpositFeesRow.fees),
|
|
93
|
+
underlyingTokenName: (0, common_2.getNativeToken)(moneyInOutChainId),
|
|
94
94
|
};
|
|
95
95
|
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
96
|
-
moneyInOutChainId:
|
|
96
|
+
moneyInOutChainId: moneyInOutChainId,
|
|
97
97
|
}).bridgeTimeInMS;
|
|
98
|
-
|
|
98
|
+
return {
|
|
99
99
|
socketDepositFees: socketDepositFees,
|
|
100
100
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
101
101
|
};
|
|
102
|
-
return result;
|
|
103
102
|
};
|
|
104
103
|
return DepositPassivePoolSimulationClient;
|
|
105
104
|
}(common_1.RestClient));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAOyB;AAKzB,0CAAiD;AAEjD;IAAgE,sDAAU;IAGxE,4CAAY,IAAY,EAAE,UAA0B;QAClD,YAAA,MAAK,YAAC,IAAI,EAAE,UAAU,CAAC,SAAC;QAHlB,2BAAqB,GAA2B,EAAE,CAAC;;IAI3D,CAAC;IAED,wDAAwD;IAClD,gDAAG,GAAT;;;;;;wBACE,KAAA,IAAI,CAAA;wBAAyB,qBAAM,IAAI,CAAC,GAAG,CACzC,0BAA0B,CAC3B,EAAA;;wBAFD,GAAK,qBAAqB,GAAG,SAE5B,CAAC;;;;;KACH;IAED,+DAA+D;IAC/D,qDAAQ,GAAR,UACE,MAAkD;QAElD,IAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAM,SAAS,GAAG,IAAA,mCAA0B,EAAC,iBAAiB,CAAC,CAAC;QAChE,IAAM,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CACzD,UAAC,oBAAoB;YACnB,OAAA,oBAAoB,CAAC,iBAAiB,KAAK,iBAAiB;gBAC5D,oBAAoB,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI;QADjD,CACiD,CACpD,CAAC;QACF,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,wCAAiC,iBAAiB,wBAAc,SAAS,CAAC,IAAI,iGAA8F,CAC7K,CAAC;QACJ,CAAC;QACD,IAAM,iBAAiB,GAAsB;YAC3C,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,qBAAqB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC5D,mBAAmB,EAAE,IAAA,uBAAc,EAAC,iBAAiB,CAAC;SACvD,CAAC;QAEF,IAAM,cAAc,GAAG,IAAA,4BAAmB,EAAC;YACzC,iBAAiB,EAAE,iBAAiB;SACrC,CAAC,CAAC,cAAc,CAAC;QAElB,OAAO;YACL,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,cAAc;SAC/B,CAAC;IACJ,CAAC;IACH,yCAAC;AAAD,CAAC,AA7CD,CAAgE,mBAAU,GA6CzE","sourcesContent":["import {\n descale,\n getRUSDUnderlyingTokenInfo,\n getSocketBridgeTime,\n RestClient,\n SocketDepositFees,\n SocketDepositFeesRow,\n} from '@reyaxyz/common';\nimport {\n DepositPassivePoolSimulationSimulateParams,\n SimulateDepositPassivePoolEntity,\n} from './types';\nimport { getNativeToken } from '@reyaxyz/common';\n\nexport default class DepositPassivePoolSimulationClient extends RestClient {\n private socketDepositFeesList: SocketDepositFeesRow[] = [];\n\n constructor(host: string, apiTimeout?: number | null) {\n super(host, apiTimeout);\n }\n\n // Method to asynchronously load data based on accountId\n async arm(): Promise<void> {\n this.socketDepositFeesList = await this.get<SocketDepositFeesRow[]>(\n `/api/socket/deposit-fees`,\n );\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositPassivePoolSimulationSimulateParams,\n ): SimulateDepositPassivePoolEntity {\n const moneyInOutChainId = params.moneyInOutChainId;\n const tokenInfo = getRUSDUnderlyingTokenInfo(moneyInOutChainId);\n const socketDpositFeesRow = this.socketDepositFeesList.find(\n (socketDepositFeesRow) =>\n socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&\n socketDepositFeesRow.tokenName === tokenInfo.name,\n );\n if (!socketDpositFeesRow) {\n throw new Error(\n `Socket deposit fees for chain ${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 const socketDepositFees: SocketDepositFees = {\n fees: socketDpositFeesRow.fees,\n feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),\n underlyingTokenName: getNativeToken(moneyInOutChainId),\n };\n\n const bridgeTimeInMS = getSocketBridgeTime({\n moneyInOutChainId: moneyInOutChainId,\n }).bridgeTimeInMS;\n\n return {\n socketDepositFees: socketDepositFees,\n bridgeTimeInMS: bridgeTimeInMS,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,EACL,yCAAyC,EACzC,yCAAyC,EACzC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,iCAAkC,SAAQ,UAAU;IACvE,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,qBAAqB,CAA8B;gBAGzD,oBAAoB,EAAE,oBAAoB,EAC1C,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAOtB,GAAG,CAAC,MAAM,EAAE,yCAAyC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW3E,QAAQ,CACN,MAAM,EAAE,yCAAyC,GAChD,+BAA+B;CAsCnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/deposit-passive-pool.simulation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0CAA0C,EAC1C,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,UAAU;IACxE,OAAO,CAAC,qBAAqB,CAA8B;gBAE/C,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAK9C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAO1B,QAAQ,CACN,MAAM,EAAE,0CAA0C,GACjD,gCAAgC;CA4BpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.69.
|
|
3
|
+
"version": "0.69.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bignumber.js": "^9.1.2"
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "pnpm@8.10.4",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "295e2c471470d65be16adc928bbbab253b4776a4"
|
|
41
41
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
RestClient,
|
|
3
|
-
SocketDepositFees,
|
|
4
2
|
descale,
|
|
5
3
|
getSocketBridgeTime,
|
|
6
4
|
getTokenInfoByAddress,
|
|
5
|
+
RestClient,
|
|
6
|
+
SocketDepositFees,
|
|
7
|
+
SocketDepositFeesRow,
|
|
7
8
|
} from '@reyaxyz/common';
|
|
8
9
|
import EditCollateralClient from '../edit-collateral.simulation';
|
|
9
10
|
import {
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
DepositExistingMASimulationSimulateParams,
|
|
12
13
|
SimulateDepositExistingMAEntity,
|
|
13
14
|
} from './types';
|
|
14
|
-
import {
|
|
15
|
+
import { getNativeToken } from '@reyaxyz/common';
|
|
15
16
|
|
|
16
17
|
export default class DepositExistingMASimulationClient extends RestClient {
|
|
17
18
|
private editCollateralClient: EditCollateralClient;
|
|
@@ -41,24 +42,25 @@ export default class DepositExistingMASimulationClient extends RestClient {
|
|
|
41
42
|
simulate(
|
|
42
43
|
params: DepositExistingMASimulationSimulateParams,
|
|
43
44
|
): SimulateDepositExistingMAEntity {
|
|
45
|
+
const moneyInOutChainId = params.moneyInOutChainId;
|
|
44
46
|
const tokenInfo = getTokenInfoByAddress(
|
|
45
47
|
params.tokenAddress,
|
|
46
|
-
|
|
48
|
+
moneyInOutChainId,
|
|
47
49
|
);
|
|
48
50
|
const socketDpositFeesRow = this.socketDepositFeesList.find(
|
|
49
51
|
(socketDepositFeesRow) =>
|
|
50
|
-
socketDepositFeesRow.moneyInOutChainId ===
|
|
52
|
+
socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
|
|
51
53
|
socketDepositFeesRow.tokenName === tokenInfo.name,
|
|
52
54
|
);
|
|
53
55
|
if (!socketDpositFeesRow) {
|
|
54
56
|
throw new Error(
|
|
55
|
-
`Socket deposit fees for chain ${
|
|
57
|
+
`Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
|
|
56
58
|
);
|
|
57
59
|
}
|
|
58
60
|
const socketDepositFees: SocketDepositFees = {
|
|
59
61
|
fees: socketDpositFeesRow.fees,
|
|
60
62
|
feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),
|
|
61
|
-
underlyingTokenName:
|
|
63
|
+
underlyingTokenName: getNativeToken(moneyInOutChainId),
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
const simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
@@ -67,16 +69,14 @@ export default class DepositExistingMASimulationClient extends RestClient {
|
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
const bridgeTimeInMS = getSocketBridgeTime({
|
|
70
|
-
moneyInOutChainId:
|
|
72
|
+
moneyInOutChainId: moneyInOutChainId,
|
|
71
73
|
}).bridgeTimeInMS;
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
return {
|
|
74
76
|
socketDepositFees: socketDepositFees,
|
|
75
77
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
76
78
|
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
77
79
|
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
78
80
|
};
|
|
79
|
-
|
|
80
|
-
return result;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
descale,
|
|
3
|
+
getRUSDUnderlyingTokenInfo,
|
|
4
|
+
getSocketBridgeTime,
|
|
5
|
+
RestClient,
|
|
6
|
+
SocketDepositFees,
|
|
7
|
+
SocketDepositFeesRow,
|
|
8
|
+
} from '@reyaxyz/common';
|
|
2
9
|
import {
|
|
3
10
|
DepositPassivePoolSimulationSimulateParams,
|
|
4
11
|
SimulateDepositPassivePoolEntity,
|
|
5
12
|
} from './types';
|
|
6
|
-
import {
|
|
7
|
-
import { getRUSDUnderlyingTokenInfo } from '@reyaxyz/common';
|
|
8
|
-
import { SocketDepositFees } from '@reyaxyz/common';
|
|
9
|
-
import { descale } from '@reyaxyz/common';
|
|
13
|
+
import { getNativeToken } from '@reyaxyz/common';
|
|
10
14
|
|
|
11
15
|
export default class DepositPassivePoolSimulationClient extends RestClient {
|
|
12
16
|
private socketDepositFeesList: SocketDepositFeesRow[] = [];
|
|
@@ -26,32 +30,31 @@ export default class DepositPassivePoolSimulationClient extends RestClient {
|
|
|
26
30
|
simulate(
|
|
27
31
|
params: DepositPassivePoolSimulationSimulateParams,
|
|
28
32
|
): SimulateDepositPassivePoolEntity {
|
|
29
|
-
const
|
|
33
|
+
const moneyInOutChainId = params.moneyInOutChainId;
|
|
34
|
+
const tokenInfo = getRUSDUnderlyingTokenInfo(moneyInOutChainId);
|
|
30
35
|
const socketDpositFeesRow = this.socketDepositFeesList.find(
|
|
31
36
|
(socketDepositFeesRow) =>
|
|
32
|
-
socketDepositFeesRow.moneyInOutChainId ===
|
|
37
|
+
socketDepositFeesRow.moneyInOutChainId === moneyInOutChainId &&
|
|
33
38
|
socketDepositFeesRow.tokenName === tokenInfo.name,
|
|
34
39
|
);
|
|
35
40
|
if (!socketDpositFeesRow) {
|
|
36
41
|
throw new Error(
|
|
37
|
-
`Socket deposit fees for chain ${
|
|
42
|
+
`Socket deposit fees for chain ${moneyInOutChainId} and token ${tokenInfo.name} not loaded. Call arm() first (or make sure arm will fetch info for this chain id and token)`,
|
|
38
43
|
);
|
|
39
44
|
}
|
|
40
45
|
const socketDepositFees: SocketDepositFees = {
|
|
41
46
|
fees: socketDpositFeesRow.fees,
|
|
42
47
|
feesInUnderlyingToken: descale(18)(socketDpositFeesRow.fees),
|
|
43
|
-
underlyingTokenName:
|
|
48
|
+
underlyingTokenName: getNativeToken(moneyInOutChainId),
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
const bridgeTimeInMS = getSocketBridgeTime({
|
|
47
|
-
moneyInOutChainId:
|
|
52
|
+
moneyInOutChainId: moneyInOutChainId,
|
|
48
53
|
}).bridgeTimeInMS;
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
return {
|
|
51
56
|
socketDepositFees: socketDepositFees,
|
|
52
57
|
bridgeTimeInMS: bridgeTimeInMS,
|
|
53
58
|
};
|
|
54
|
-
|
|
55
|
-
return result;
|
|
56
59
|
}
|
|
57
60
|
}
|