@reyaxyz/api-sdk 0.169.5 → 0.169.7
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 +0 -149
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/modules/account/index.js +0 -20
- package/dist/clients/modules/account/index.js.map +1 -1
- package/dist/clients/modules/account/types.js.map +1 -1
- package/dist/clients/modules/lp/index.js +0 -9
- package/dist/clients/modules/lp/index.js.map +1 -1
- package/dist/clients/modules/lp/types.js.map +1 -1
- package/dist/clients/types.js +0 -7
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/api-client.d.ts +0 -106
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/modules/account/index.d.ts +2 -4
- package/dist/types/clients/modules/account/index.d.ts.map +1 -1
- package/dist/types/clients/modules/account/types.d.ts +0 -8
- package/dist/types/clients/modules/account/types.d.ts.map +1 -1
- package/dist/types/clients/modules/lp/index.d.ts +2 -3
- package/dist/types/clients/modules/lp/index.d.ts.map +1 -1
- package/dist/types/clients/modules/lp/types.d.ts +1 -4
- package/dist/types/clients/modules/lp/types.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +0 -7
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/clients/api-client.ts +0 -159
- package/src/clients/modules/account/index.ts +1 -24
- package/src/clients/modules/account/types.ts +0 -14
- package/src/clients/modules/lp/index.ts +1 -13
- package/src/clients/modules/lp/types.ts +0 -5
- package/src/clients/types.ts +0 -7
- package/dist/clients/modules/binance/index.js +0 -104
- package/dist/clients/modules/binance/index.js.map +0 -1
- package/dist/clients/modules/binance/types.js +0 -3
- package/dist/clients/modules/binance/types.js.map +0 -1
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js +0 -117
- package/dist/clients/modules/deposit-existing-MA.simulation/index.js.map +0 -1
- package/dist/clients/modules/deposit-existing-MA.simulation/types.js +0 -3
- package/dist/clients/modules/deposit-existing-MA.simulation/types.js.map +0 -1
- package/dist/clients/modules/deposit-new-MA.simulation/index.js +0 -67
- package/dist/clients/modules/deposit-new-MA.simulation/index.js.map +0 -1
- package/dist/clients/modules/deposit-new-MA.simulation/types.js +0 -3
- package/dist/clients/modules/deposit-new-MA.simulation/types.js.map +0 -1
- package/dist/clients/modules/depth-chart.simulation/index.js +0 -142
- package/dist/clients/modules/depth-chart.simulation/index.js.map +0 -1
- package/dist/clients/modules/depth-chart.simulation/types.js +0 -3
- package/dist/clients/modules/depth-chart.simulation/types.js.map +0 -1
- package/dist/clients/modules/edit-collateral.simulation/index.js +0 -92
- package/dist/clients/modules/edit-collateral.simulation/index.js.map +0 -1
- package/dist/clients/modules/edit-collateral.simulation/types.js +0 -3
- package/dist/clients/modules/edit-collateral.simulation/types.js.map +0 -1
- package/dist/clients/modules/transfer-MA-Pool.simulation/index.js +0 -74
- package/dist/clients/modules/transfer-MA-Pool.simulation/index.js.map +0 -1
- package/dist/clients/modules/transfer-MA-Pool.simulation/types.js +0 -3
- package/dist/clients/modules/transfer-MA-Pool.simulation/types.js.map +0 -1
- package/dist/clients/modules/transfer-margin-between-MAs.simulation/index.js +0 -90
- package/dist/clients/modules/transfer-margin-between-MAs.simulation/index.js.map +0 -1
- package/dist/clients/modules/transfer-margin-between-MAs.simulation/types.js +0 -3
- package/dist/clients/modules/transfer-margin-between-MAs.simulation/types.js.map +0 -1
- package/dist/clients/modules/withdraw-MA.simulation/index.js +0 -120
- package/dist/clients/modules/withdraw-MA.simulation/index.js.map +0 -1
- package/dist/clients/modules/withdraw-MA.simulation/types.js +0 -3
- package/dist/clients/modules/withdraw-MA.simulation/types.js.map +0 -1
- package/dist/types/clients/modules/binance/index.d.ts +0 -7
- package/dist/types/clients/modules/binance/index.d.ts.map +0 -1
- package/dist/types/clients/modules/binance/types.d.ts +0 -10
- package/dist/types/clients/modules/binance/types.d.ts.map +0 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/index.d.ts +0 -11
- package/dist/types/clients/modules/deposit-existing-MA.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts +0 -15
- package/dist/types/clients/modules/deposit-existing-MA.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/deposit-new-MA.simulation/index.d.ts +0 -9
- package/dist/types/clients/modules/deposit-new-MA.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/deposit-new-MA.simulation/types.d.ts +0 -4
- package/dist/types/clients/modules/deposit-new-MA.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/depth-chart.simulation/index.d.ts +0 -14
- package/dist/types/clients/modules/depth-chart.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts +0 -22
- package/dist/types/clients/modules/depth-chart.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/edit-collateral.simulation/index.d.ts +0 -13
- package/dist/types/clients/modules/edit-collateral.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts +0 -13
- package/dist/types/clients/modules/edit-collateral.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/transfer-MA-Pool.simulation/index.d.ts +0 -9
- package/dist/types/clients/modules/transfer-MA-Pool.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/transfer-MA-Pool.simulation/types.d.ts +0 -12
- package/dist/types/clients/modules/transfer-MA-Pool.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/index.d.ts +0 -11
- package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/types.d.ts +0 -16
- package/dist/types/clients/modules/transfer-margin-between-MAs.simulation/types.d.ts.map +0 -1
- package/dist/types/clients/modules/withdraw-MA.simulation/index.d.ts +0 -12
- package/dist/types/clients/modules/withdraw-MA.simulation/index.d.ts.map +0 -1
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts +0 -16
- package/dist/types/clients/modules/withdraw-MA.simulation/types.d.ts.map +0 -1
- package/src/clients/modules/binance/index.ts +0 -50
- package/src/clients/modules/binance/types.ts +0 -25
- package/src/clients/modules/deposit-existing-MA.simulation/index.ts +0 -82
- package/src/clients/modules/deposit-existing-MA.simulation/types.ts +0 -23
- package/src/clients/modules/deposit-new-MA.simulation/index.ts +0 -30
- package/src/clients/modules/deposit-new-MA.simulation/types.ts +0 -9
- package/src/clients/modules/depth-chart.simulation/index.ts +0 -131
- package/src/clients/modules/depth-chart.simulation/types.ts +0 -25
- package/src/clients/modules/edit-collateral.simulation/index.ts +0 -86
- package/src/clients/modules/edit-collateral.simulation/types.ts +0 -15
- package/src/clients/modules/transfer-MA-Pool.simulation/index.ts +0 -38
- package/src/clients/modules/transfer-MA-Pool.simulation/types.ts +0 -15
- package/src/clients/modules/transfer-margin-between-MAs.simulation/index.ts +0 -65
- package/src/clients/modules/transfer-margin-between-MAs.simulation/types.ts +0 -18
- package/src/clients/modules/withdraw-MA.simulation/index.ts +0 -94
- package/src/clients/modules/withdraw-MA.simulation/types.ts +0 -23
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var common_1 = require("@reyaxyz/common");
|
|
55
|
-
var common_2 = require("@reyaxyz/common");
|
|
56
|
-
var DepositExistingMASimulationClient = /** @class */ (function (_super) {
|
|
57
|
-
__extends(DepositExistingMASimulationClient, _super);
|
|
58
|
-
function DepositExistingMASimulationClient(editCollateralClient, host, apiTimeout) {
|
|
59
|
-
var _this = _super.call(this, host, apiTimeout) || this;
|
|
60
|
-
_this.socketDepositFeesList = [];
|
|
61
|
-
_this.editCollateralClient = editCollateralClient;
|
|
62
|
-
return _this;
|
|
63
|
-
}
|
|
64
|
-
// Method to asynchronously load data based on accountId
|
|
65
|
-
DepositExistingMASimulationClient.prototype.arm = function (params) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var _a;
|
|
68
|
-
return __generator(this, function (_b) {
|
|
69
|
-
switch (_b.label) {
|
|
70
|
-
case 0: return [4 /*yield*/, this.editCollateralClient.arm({
|
|
71
|
-
marginAccountId: params.marginAccountId,
|
|
72
|
-
})];
|
|
73
|
-
case 1:
|
|
74
|
-
_b.sent();
|
|
75
|
-
_a = this;
|
|
76
|
-
return [4 /*yield*/, this.get("/api/socket/deposit-fees")];
|
|
77
|
-
case 2:
|
|
78
|
-
_a.socketDepositFeesList = _b.sent();
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
// Synchronous method to simulate operations based on an amount
|
|
85
|
-
DepositExistingMASimulationClient.prototype.simulate = function (params) {
|
|
86
|
-
var moneyInOutChainId = params.moneyInOutChainId;
|
|
87
|
-
var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress, moneyInOutChainId);
|
|
88
|
-
var socketDepositFeesEntry = this.socketDepositFeesList.find(function (socketDepositFeesEntry) {
|
|
89
|
-
return socketDepositFeesEntry.moneyInOutChainId === moneyInOutChainId &&
|
|
90
|
-
socketDepositFeesEntry.tokenName === tokenInfo.name;
|
|
91
|
-
});
|
|
92
|
-
if (!socketDepositFeesEntry) {
|
|
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)"));
|
|
94
|
-
}
|
|
95
|
-
var socketDepositFees = {
|
|
96
|
-
fees: socketDepositFeesEntry.fees,
|
|
97
|
-
feesInUnderlyingToken: (0, common_1.descale)(18)(socketDepositFeesEntry.fees),
|
|
98
|
-
underlyingTokenName: (0, common_2.getNativeToken)(moneyInOutChainId),
|
|
99
|
-
};
|
|
100
|
-
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
101
|
-
signedAmount: params.amount,
|
|
102
|
-
tokenAddress: params.tokenAddress,
|
|
103
|
-
});
|
|
104
|
-
var bridgeTimeInMS = (0, common_1.getSocketBridgeTime)({
|
|
105
|
-
moneyInOutChainId: moneyInOutChainId,
|
|
106
|
-
}).bridgeTimeInMS;
|
|
107
|
-
return {
|
|
108
|
-
socketDepositFees: socketDepositFees,
|
|
109
|
-
bridgeTimeInMS: bridgeTimeInMS,
|
|
110
|
-
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
111
|
-
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
return DepositExistingMASimulationClient;
|
|
115
|
-
}(common_1.RestClient));
|
|
116
|
-
exports.default = DepositExistingMASimulationClient;
|
|
117
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,GAA6B,EAAE,CAAC;QAQ3D,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,sBAAsB,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAC5D,UAAC,sBAAsB;YACrB,OAAA,sBAAsB,CAAC,iBAAiB,KAAK,iBAAiB;gBAC9D,sBAAsB,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI;QADnD,CACmD,CACtD,CAAC;QACF,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,wCAAiC,iBAAiB,wBAAc,SAAS,CAAC,IAAI,iGAA8F,CAC7K,CAAC;QACJ,CAAC;QACD,IAAM,iBAAiB,GAAsB;YAC3C,IAAI,EAAE,sBAAsB,CAAC,IAAI;YACjC,qBAAqB,EAAE,IAAA,gBAAO,EAAC,EAAE,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC;YAC/D,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 SocketDepositFeesEntry,\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: SocketDepositFeesEntry[] = [];\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<SocketDepositFeesEntry[]>(\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 socketDepositFeesEntry = this.socketDepositFeesList.find(\n (socketDepositFeesEntry) =>\n socketDepositFeesEntry.moneyInOutChainId === moneyInOutChainId &&\n socketDepositFeesEntry.tokenName === tokenInfo.name,\n );\n if (!socketDepositFeesEntry) {\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: socketDepositFeesEntry.fees,\n feesInUnderlyingToken: descale(18)(socketDepositFeesEntry.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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-existing-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MarginRatioHealth,\n MoneyInOutChainId,\n SocketDepositFees,\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 socketDepositFees: SocketDepositFees;\n bridgeTimeInMS: number;\n marginRatio: number;\n marginRatioHealth: MarginRatioHealth;\n};\n"]}
|
|
@@ -1,67 +0,0 @@
|
|
|
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 common_1 = require("@reyaxyz/common");
|
|
40
|
-
var DepositNewMASimulationClient = /** @class */ (function () {
|
|
41
|
-
function DepositNewMASimulationClient(depositExistingMASimulationClient) {
|
|
42
|
-
// Constructor added
|
|
43
|
-
this.depositExistingMASimulationClient = depositExistingMASimulationClient;
|
|
44
|
-
}
|
|
45
|
-
// Method to asynchronously load data based on accountId
|
|
46
|
-
DepositNewMASimulationClient.prototype.arm = function () {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0: return [4 /*yield*/, this.depositExistingMASimulationClient.arm({
|
|
51
|
-
marginAccountId: common_1.MAX_UINT128, // account ids are increasing one by one in Core
|
|
52
|
-
})];
|
|
53
|
-
case 1:
|
|
54
|
-
_a.sent();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
// Synchronous method to simulate operations based on an amount
|
|
61
|
-
DepositNewMASimulationClient.prototype.simulate = function (params) {
|
|
62
|
-
return this.depositExistingMASimulationClient.simulate(params);
|
|
63
|
-
};
|
|
64
|
-
return DepositNewMASimulationClient;
|
|
65
|
-
}());
|
|
66
|
-
exports.default = DepositNewMASimulationClient;
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/deposit-new-MA.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA8C;AAO9C;IAEE,sCACE,iCAAoE;QAEpE,oBAAoB;QACpB,IAAI,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC7E,CAAC;IAED,wDAAwD;IAClD,0CAAG,GAAT;;;;4BACE,qBAAM,IAAI,CAAC,iCAAiC,CAAC,GAAG,CAAC;4BAC/C,eAAe,EAAE,oBAAW,EAAE,gDAAgD;yBAC/E,CAAC,EAAA;;wBAFF,SAEE,CAAC;;;;;KACJ;IAED,+DAA+D;IAC/D,+CAAQ,GAAR,UACE,MAA4C;QAE5C,OAAO,IAAI,CAAC,iCAAiC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IACH,mCAAC;AAAD,CAAC,AAtBD,IAsBC","sourcesContent":["import { MAX_UINT128 } from '@reyaxyz/common';\nimport DepositExistingMASimulationClient from '../deposit-existing-MA.simulation';\nimport {\n DepositNewMASimulationSimulateParams,\n SimulateDepositNewMAEntity,\n} from './types';\n\nexport default class DepositNewMASimulationClient {\n private depositExistingMASimulationClient: DepositExistingMASimulationClient;\n constructor(\n depositExistingMASimulationClient: DepositExistingMASimulationClient,\n ) {\n // Constructor added\n this.depositExistingMASimulationClient = depositExistingMASimulationClient;\n }\n\n // Method to asynchronously load data based on accountId\n async arm(): Promise<void> {\n await this.depositExistingMASimulationClient.arm({\n marginAccountId: MAX_UINT128, // account ids are increasing one by one in Core\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(\n params: DepositNewMASimulationSimulateParams,\n ): SimulateDepositNewMAEntity {\n return this.depositExistingMASimulationClient.simulate(params);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/deposit-new-MA.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n DepositExistingMASimulationSimulateParams,\n SimulateDepositExistingMAEntity,\n} from '../deposit-existing-MA.simulation/types';\n\nexport type DepositNewMASimulationSimulateParams =\n DepositExistingMASimulationSimulateParams;\n\nexport type SimulateDepositNewMAEntity = SimulateDepositExistingMAEntity;\n"]}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var common_1 = require("@reyaxyz/common");
|
|
43
|
-
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
|
-
var DepthChartSimulationClient = /** @class */ (function () {
|
|
45
|
-
function DepthChartSimulationClient(lpClient) {
|
|
46
|
-
this.marketId = null;
|
|
47
|
-
this.loadedData = null;
|
|
48
|
-
// Constructor added
|
|
49
|
-
this.lpClient = lpClient;
|
|
50
|
-
}
|
|
51
|
-
// Method to asynchronously load data based on marketId
|
|
52
|
-
DepthChartSimulationClient.prototype.arm = function (params) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var _a;
|
|
55
|
-
return __generator(this, function (_b) {
|
|
56
|
-
switch (_b.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
this.marketId = params.marketId;
|
|
59
|
-
_a = this;
|
|
60
|
-
return [4 /*yield*/, this.fetchPoolData(this.marketId)];
|
|
61
|
-
case 1:
|
|
62
|
-
_a.loadedData = _b.sent();
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
DepthChartSimulationClient.prototype.fetchPoolData = function (marketId) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
return __generator(this, function (_a) {
|
|
71
|
-
return [2 /*return*/, this.lpClient.getLpPoolDepthChartSimulationData({
|
|
72
|
-
marketId: marketId,
|
|
73
|
-
})];
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
DepthChartSimulationClient.prototype.getDepthChart = function (params) {
|
|
78
|
-
if (!this.loadedData) {
|
|
79
|
-
throw new Error('Data not loaded. Call arm() first.');
|
|
80
|
-
}
|
|
81
|
-
// Adjust initial step size based on max exposures
|
|
82
|
-
var maxExposure = Math.max(this.loadedData.maxOrderSizeLong, Math.abs(this.loadedData.maxOrderSizeShort));
|
|
83
|
-
var maxPriceImpact = 0.035; // 3.5%
|
|
84
|
-
var maxSize = (0, bignumber_js_1.default)(this.loadedData.netExposure)
|
|
85
|
-
.plus((0, bignumber_js_1.default)(maxExposure)
|
|
86
|
-
.times((0, common_1.amountNormalizer)(this.loadedData.depthFactor))
|
|
87
|
-
.times(maxPriceImpact)
|
|
88
|
-
.div(1 + maxPriceImpact))
|
|
89
|
-
.toNumber();
|
|
90
|
-
var maxDisplayedSize = maxExposure < maxSize ? maxExposure : maxSize;
|
|
91
|
-
var initialStepSize = maxDisplayedSize / ((params === null || params === void 0 ? void 0 : params.initialSteps) || 100);
|
|
92
|
-
var step = (params === null || params === void 0 ? void 0 : params.step) || initialStepSize;
|
|
93
|
-
var leftResults = [];
|
|
94
|
-
var rightResults = [];
|
|
95
|
-
// Simplified loop conditions to focus on reaching maxExposure limits efficiently
|
|
96
|
-
var delta = 0;
|
|
97
|
-
while (Math.abs(delta) < maxDisplayedSize) {
|
|
98
|
-
delta -= step;
|
|
99
|
-
var result = this.calculate(delta);
|
|
100
|
-
leftResults.push(result);
|
|
101
|
-
// Adjust currentStep based on your liquidity model or other factors
|
|
102
|
-
}
|
|
103
|
-
delta = 0; // Reset for the right side
|
|
104
|
-
while (Math.abs(delta) < maxDisplayedSize) {
|
|
105
|
-
delta += step;
|
|
106
|
-
var result = this.calculate(delta);
|
|
107
|
-
rightResults.push(result);
|
|
108
|
-
// Adjust currentStep similarly
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
leftChart: leftResults.reverse(),
|
|
112
|
-
rightChart: rightResults,
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
DepthChartSimulationClient.prototype.calculate = function (delta) {
|
|
116
|
-
if (!this.loadedData) {
|
|
117
|
-
throw new Error('Data not loaded. Call arm() first.');
|
|
118
|
-
}
|
|
119
|
-
var n0Delta = (0, bignumber_js_1.default)(this.loadedData.netExposure).plus(delta);
|
|
120
|
-
var maxOrderSize = n0Delta.gt(0)
|
|
121
|
-
? (0, bignumber_js_1.default)(this.loadedData.maxOrderSizeLong)
|
|
122
|
-
: (0, bignumber_js_1.default)(this.loadedData.maxOrderSizeShort);
|
|
123
|
-
var currentPrice = (0, bignumber_js_1.default)(this.loadedData.spotPrice).times((0, bignumber_js_1.default)(1).minus(n0Delta.div((0, bignumber_js_1.default)(n0Delta).plus(maxOrderSize.times((0, common_1.amountNormalizer)(this.loadedData.depthFactor))))));
|
|
124
|
-
var size = (0, bignumber_js_1.default)(delta).div(this.loadedData.spotPrice).abs();
|
|
125
|
-
return {
|
|
126
|
-
price: currentPrice.toNumber(),
|
|
127
|
-
totalSize: size.toNumber(),
|
|
128
|
-
totalCost: size.times(currentPrice).toNumber(),
|
|
129
|
-
priceImpact: DepthChartSimulationClient.calculatePriceChangePercentage(this.loadedData.spotPrice, currentPrice.toNumber()),
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
DepthChartSimulationClient.calculatePriceChangePercentage = function (price, estimatedPrice) {
|
|
133
|
-
// Calculate the price difference
|
|
134
|
-
var priceDifference = estimatedPrice - price;
|
|
135
|
-
var absPriceDifference = Math.abs(priceDifference);
|
|
136
|
-
// Calculate the percentage change
|
|
137
|
-
return (absPriceDifference / Math.abs(price)) * 100;
|
|
138
|
-
};
|
|
139
|
-
return DepthChartSimulationClient;
|
|
140
|
-
}());
|
|
141
|
-
exports.default = DepthChartSimulationClient;
|
|
142
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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;QACjC,IAAM,eAAe,GAAG,cAAc,GAAG,KAAK,CAAC;QAE/C,IAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACrD,kCAAkC;QAClC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;IACtD,CAAC;IACH,iCAAC;AAAD,CAAC,AAvHD,IAuHC","sourcesContent":["import {\n GetDepthChartParams,\n GetDepthChartResult,\n DepthSimulationLoadDataParams,\n SimulateDepthEntity,\n} from './types';\n\nimport LpClient from '../lp';\nimport { DepthSimulationState, amountNormalizer } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\n\nexport default class DepthChartSimulationClient {\n private marketId: number | null = null;\n private loadedData: DepthSimulationState | null = null;\n private lpClient: LpClient;\n constructor(lpClient: LpClient) {\n // Constructor added\n this.lpClient = lpClient;\n }\n\n // Method to asynchronously load data based on marketId\n async arm(params: DepthSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n\n this.loadedData = await this.fetchPoolData(this.marketId);\n }\n\n private async fetchPoolData(marketId: number): Promise<DepthSimulationState> {\n return this.lpClient.getLpPoolDepthChartSimulationData({\n marketId: marketId,\n });\n }\n\n getDepthChart(params?: GetDepthChartParams): GetDepthChartResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n // Adjust initial step size based on max exposures\n const maxExposure = Math.max(\n this.loadedData.maxOrderSizeLong,\n Math.abs(this.loadedData.maxOrderSizeShort),\n );\n\n const maxPriceImpact = 0.035; // 3.5%\n const maxSize = BigNumber(this.loadedData.netExposure)\n .plus(\n BigNumber(maxExposure)\n .times(amountNormalizer(this.loadedData.depthFactor))\n .times(maxPriceImpact)\n .div(1 + maxPriceImpact),\n )\n .toNumber();\n\n const maxDisplayedSize = maxExposure < maxSize ? maxExposure : maxSize;\n\n const initialStepSize = maxDisplayedSize / (params?.initialSteps || 100);\n\n const step = params?.step || initialStepSize;\n\n const leftResults: SimulateDepthEntity[] = [];\n const rightResults: SimulateDepthEntity[] = [];\n\n // Simplified loop conditions to focus on reaching maxExposure limits efficiently\n let delta = 0;\n while (Math.abs(delta) < maxDisplayedSize) {\n delta -= step;\n const result = this.calculate(delta);\n leftResults.push(result);\n // Adjust currentStep based on your liquidity model or other factors\n }\n\n delta = 0; // Reset for the right side\n while (Math.abs(delta) < maxDisplayedSize) {\n delta += step;\n const result = this.calculate(delta);\n rightResults.push(result);\n // Adjust currentStep similarly\n }\n\n return {\n leftChart: leftResults.reverse(),\n rightChart: rightResults,\n };\n }\n\n private calculate(delta: number): SimulateDepthEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const n0Delta = BigNumber(this.loadedData.netExposure).plus(delta);\n const maxOrderSize = n0Delta.gt(0)\n ? BigNumber(this.loadedData.maxOrderSizeLong)\n : BigNumber(this.loadedData.maxOrderSizeShort);\n\n const currentPrice = BigNumber(this.loadedData.spotPrice).times(\n BigNumber(1).minus(\n n0Delta.div(\n BigNumber(n0Delta).plus(\n maxOrderSize.times(amountNormalizer(this.loadedData.depthFactor)),\n ),\n ),\n ),\n );\n\n const size = BigNumber(delta).div(this.loadedData.spotPrice).abs();\n\n return {\n price: currentPrice.toNumber(),\n totalSize: size.toNumber(),\n totalCost: size.times(currentPrice).toNumber(),\n priceImpact: DepthChartSimulationClient.calculatePriceChangePercentage(\n this.loadedData.spotPrice,\n currentPrice.toNumber(),\n ),\n };\n }\n\n static calculatePriceChangePercentage(\n price: number,\n estimatedPrice: number,\n ): number {\n // Calculate the price difference\n const priceDifference = estimatedPrice - price;\n\n const absPriceDifference = Math.abs(priceDifference);\n // Calculate the percentage change\n return (absPriceDifference / Math.abs(price)) * 100;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/depth-chart.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarketEntity } from '@reyaxyz/common';\n\nexport type DepthSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n};\n\nexport type SimulateDepthEntity = {\n price: number;\n totalSize: number;\n totalCost: number;\n priceImpact: number;\n};\n\nexport type GetDepthChartResult = {\n leftChart: SimulateDepthEntity[];\n rightChart: SimulateDepthEntity[];\n};\n\nexport type GetDepthChartParams = {\n step?: number;\n percentageChange?: number;\n maxPoints?: number;\n dynamicStepIncreaseFactor?: number;\n initialSteps?: number;\n};\n"]}
|
|
@@ -1,92 +0,0 @@
|
|
|
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 common_1 = require("@reyaxyz/common");
|
|
40
|
-
var EditCollateralSimulationClient = /** @class */ (function () {
|
|
41
|
-
function EditCollateralSimulationClient(reyaChainId, accountClient) {
|
|
42
|
-
this.accountId = null;
|
|
43
|
-
this.loadedData = null;
|
|
44
|
-
// Constructor added
|
|
45
|
-
this.reyaChainId = reyaChainId;
|
|
46
|
-
this.accountClient = accountClient;
|
|
47
|
-
}
|
|
48
|
-
// Method to asynchronously load data based on accountId
|
|
49
|
-
EditCollateralSimulationClient.prototype.arm = function (params) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var _a;
|
|
52
|
-
return __generator(this, function (_b) {
|
|
53
|
-
switch (_b.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
this.accountId = params.marginAccountId;
|
|
56
|
-
_a = this;
|
|
57
|
-
return [4 /*yield*/, this.accountClient.getEditCollateralSimulationInitialData({
|
|
58
|
-
marginAccountId: this.accountId,
|
|
59
|
-
})];
|
|
60
|
-
case 1:
|
|
61
|
-
_a.loadedData =
|
|
62
|
-
_b.sent();
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
// Synchronous method to simulate operations based on an amount
|
|
69
|
-
EditCollateralSimulationClient.prototype.simulate = function (params) {
|
|
70
|
-
if (!this.loadedData) {
|
|
71
|
-
throw new Error('Data not loaded. Call arm() first.');
|
|
72
|
-
}
|
|
73
|
-
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.mtmRpnlSum, this.loadedData.exposureDataAccount.collateralAddressToExchangePrice);
|
|
74
|
-
var tokenInfo = (0, common_1.getTokenInfoByAddress)(params.tokenAddress);
|
|
75
|
-
if (tokenInfo.isRUSDUnderlying) {
|
|
76
|
-
tokenInfo = (0, common_1.getTokenInfoByName)('RUSD', this.reyaChainId);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
tokenInfo = (0, common_1.getTokenInfoByName)(tokenInfo.name, this.reyaChainId);
|
|
80
|
-
}
|
|
81
|
-
var newMarginInfo = userAccountExposure.getUsdNodeMarginInfoPostEditCollateral(params.signedAmount, tokenInfo.address);
|
|
82
|
-
var marginRatio = common_1.ExposureCommand.getMarginRatio(newMarginInfo);
|
|
83
|
-
var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio * 100);
|
|
84
|
-
return {
|
|
85
|
-
marginRatio: marginRatio * 100,
|
|
86
|
-
marginRatioHealth: marginRatioHealth,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
return EditCollateralSimulationClient;
|
|
90
|
-
}());
|
|
91
|
-
exports.default = EditCollateralSimulationClient;
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,iDAA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3D,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,GAAG,GAAG,CAClB,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.mtmRpnlSum,\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 * 100,\n );\n\n return {\n marginRatio: marginRatio * 100,\n marginRatioHealth: marginRatioHealth,\n } as SimulateEditCollateralEntity;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/edit-collateral.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginRatioHealth, TokenEntity } from '@reyaxyz/common';\n\nexport type EditCollateralSimulationLoadDataParams = {\n marginAccountId: number;\n};\n\nexport type EditCollateralSimulationSimulateParams = {\n signedAmount: number; // + for deposit, - for withdraw\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateEditCollateralEntity = {\n marginRatio: number;\n marginRatioHealth: MarginRatioHealth;\n};\n"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
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 TransferMAPoolSimulationClient = /** @class */ (function () {
|
|
40
|
-
function TransferMAPoolSimulationClient(editCollateralClient) {
|
|
41
|
-
// Constructor added
|
|
42
|
-
this.editCollateralClient = editCollateralClient;
|
|
43
|
-
}
|
|
44
|
-
// Method to asynchronously load data based on accountId
|
|
45
|
-
TransferMAPoolSimulationClient.prototype.arm = function (params) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0: return [4 /*yield*/, this.editCollateralClient.arm({
|
|
50
|
-
marginAccountId: params.marginAccountId,
|
|
51
|
-
})];
|
|
52
|
-
case 1:
|
|
53
|
-
_a.sent();
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
// Synchronous method to simulate operations based on an amount
|
|
60
|
-
TransferMAPoolSimulationClient.prototype.simulate = function (params) {
|
|
61
|
-
var simulateEditCollateralEntity = this.editCollateralClient.simulate({
|
|
62
|
-
signedAmount: -params.amount,
|
|
63
|
-
tokenAddress: params.tokenAddress,
|
|
64
|
-
});
|
|
65
|
-
var result = {
|
|
66
|
-
marginRatio: simulateEditCollateralEntity.marginRatio,
|
|
67
|
-
marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,
|
|
68
|
-
};
|
|
69
|
-
return result;
|
|
70
|
-
};
|
|
71
|
-
return TransferMAPoolSimulationClient;
|
|
72
|
-
}());
|
|
73
|
-
exports.default = TransferMAPoolSimulationClient;
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/transfer-MA-Pool.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;IAEE,wCAAY,oBAA0C;QACpD,oBAAoB;QACpB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED,wDAAwD;IAClD,4CAAG,GAAT,UAAU,MAA8C;;;;4BACtD,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,iDAAQ,GAAR,UACE,MAA8C;QAE9C,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,MAAM,GAAiC;YAC3C,WAAW,EAAE,4BAA4B,CAAC,WAAW;YACrD,iBAAiB,EAAE,4BAA4B,CAAC,iBAAiB;SAClE,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,qCAAC;AAAD,CAAC,AA9BD,IA8BC","sourcesContent":["import EditCollateralClient from '../edit-collateral.simulation';\nimport {\n TransferMAPoolSimulationLoadDataParams,\n TransferMAPoolSimulationSimulateParams,\n SimulateTransferMAPoolEntity,\n} from './types';\n\nexport default class TransferMAPoolSimulationClient {\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: TransferMAPoolSimulationLoadDataParams): 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: TransferMAPoolSimulationSimulateParams,\n ): SimulateTransferMAPoolEntity {\n const simulateEditCollateralEntity = this.editCollateralClient.simulate({\n signedAmount: -params.amount,\n tokenAddress: params.tokenAddress,\n });\n\n const result: SimulateTransferMAPoolEntity = {\n marginRatio: simulateEditCollateralEntity.marginRatio,\n marginRatioHealth: simulateEditCollateralEntity.marginRatioHealth,\n };\n\n return result;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/transfer-MA-Pool.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginRatioHealth, TokenEntity } from '@reyaxyz/common';\nimport { EditCollateralSimulationLoadDataParams } from '../edit-collateral.simulation/types';\n\nexport type TransferMAPoolSimulationLoadDataParams =\n EditCollateralSimulationLoadDataParams;\n\nexport type TransferMAPoolSimulationSimulateParams = {\n amount: number;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type SimulateTransferMAPoolEntity = {\n marginRatio: number;\n marginRatioHealth: MarginRatioHealth;\n};\n"]}
|