@reyaxyz/api-sdk 0.137.5 → 0.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/clients/modules/conditional-orders/index.js +11 -0
- package/dist/clients/modules/conditional-orders/index.js.map +1 -1
- package/dist/clients/modules/conditional-orders/types.js.map +1 -1
- package/dist/clients/modules/trade.simulation/index.js +6 -0
- package/dist/clients/modules/trade.simulation/index.js.map +1 -1
- package/dist/clients/modules/trade.simulation/types.js.map +1 -1
- package/dist/types/clients/modules/conditional-orders/index.d.ts +2 -1
- package/dist/types/clients/modules/conditional-orders/index.d.ts.map +1 -1
- package/dist/types/clients/modules/conditional-orders/types.d.ts +4 -0
- package/dist/types/clients/modules/conditional-orders/types.d.ts.map +1 -1
- package/dist/types/clients/modules/trade.simulation/index.d.ts.map +1 -1
- package/dist/types/clients/modules/trade.simulation/types.d.ts +4 -0
- package/dist/types/clients/modules/trade.simulation/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/modules/conditional-orders/index.ts +10 -0
- package/src/clients/modules/conditional-orders/types.ts +5 -0
- package/src/clients/modules/trade.simulation/index.ts +11 -0
- package/src/clients/modules/trade.simulation/types.ts +4 -0
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -73,6 +73,17 @@ var ConditionalOrdersClient = /** @class */ (function (_super) {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
+
ConditionalOrdersClient.prototype.getConditionalOrdersHistoryForWalletAddress = function (params) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var uri;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
uri = "/api/conditional-orders/get-orders-by-wallet/".concat(params.walletAddress);
|
|
81
|
+
return [2 /*return*/, this.get(uri, {
|
|
82
|
+
limit: params.limit,
|
|
83
|
+
})];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
76
87
|
ConditionalOrdersClient.prototype.alreadyGaveTradePermissions = function (params) {
|
|
77
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
89
|
var uri, response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/conditional-orders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAWyB;AACzB,iCAAkC;AAgBlC,iCAAsC;AAEtC;IAAqD,2CAAU;IAG7D,iCAAY,WAAwB,EAAE,IAAY;QAChD,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QACZ,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACjC,CAAC;IAED,yCAAyC;IACnC,6EAA2C,GAAjD,UACE,MAAyD;;;;gBAEnD,GAAG,GAAG,wDAAiD,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAoD,GAAG,EAAE;wBACtE,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,6DAA2B,GAAjC,UACE,MAAwC;;;;;;wBAElC,GAAG,GAAG,wDAAiD,MAAM,CAAC,SAAS,CAAE,CAAC;wBAC/D,qBAAM,IAAI,CAAC,GAAG,CAAU,GAAG,CAAC,EAAA;;wBAAvC,QAAQ,GAAG,SAA4B;wBAE7C,sBAAO;gCACL,eAAe,EAAE,QAAQ;6BAC1B,EAAC;;;;KACH;IAEK,oEAAkC,GAAxC,UACE,MAAgD;;;;;;wBAE1C,GAAG,GAAG,kEAA2D,MAAM,CAAC,SAAS,cAAI,MAAM,CAAC,mBAAmB,CAAE,CAAC;wBACvG,qBAAM,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L,SAAS,WAAA;gCACT,kBAAkB,oBAAA;gCAClB,eAAe,iBAAA;gCACf,KAAK,OAAA;gCACL,QAAQ,EAAE,uCAA8B;gCACxC,mBAAmB,qBAAA;6BACpB,EAAC;;;;KACH;IACH,8BAAC;AAAD,CAAC,AAvOD,CAAqD,mBAAU,GAuO9D","sourcesContent":["import {\n calculateMaxPriceLimit,\n PositionEntity,\n RestClient,\n ReyaChainId,\n signConditionalOrder,\n signCancelConditionalOrder,\n ConditionalOrder,\n ConditionalOrderType,\n scale,\n CONDITIONAL_ORDER_SIG_DEADLINE,\n} from '@reyaxyz/common';\nimport { AbiCoder } from 'ethers';\nimport { Signer, JsonRpcSigner } from 'ethers';\nimport {\n AlreadyGaveTradePermissionParams,\n AlreadyGaveTradePermissionResult,\n CancelConditionalOrderParams,\n CancelConditionalOrderResult,\n GetConditionalOrdersHistoryForMarginAccountParams,\n GetConditionalOrdersHistoryForMarginAccountResult,\n RegisterConditionalOrderParams,\n RegisterConditionalOrderResult,\n UpdateConditionalOrderParams,\n UpdateConditionalOrderResult,\n AlreadyGaveTradePermissionToWalletParams,\n AlreadyGaveTradePermissionToWalletResult,\n} from './types';\nimport { createNonce } from './utils';\n\nexport default class ConditionalOrdersClient extends RestClient {\n private reyaChainId: ReyaChainId;\n\n constructor(reyaChainId: ReyaChainId, host: string) {\n super(host);\n this.reyaChainId = reyaChainId;\n }\n\n // ------ Conditional Orders History ---\n async getConditionalOrdersHistoryForMarginAccount(\n params: GetConditionalOrdersHistoryForMarginAccountParams,\n ): Promise<GetConditionalOrdersHistoryForMarginAccountResult> {\n const uri = `/api/conditional-orders/get-orders-by-account/${params.marginAccountId}`;\n return this.get<GetConditionalOrdersHistoryForMarginAccountResult>(uri, {\n limit: params.limit,\n });\n }\n\n async alreadyGaveTradePermissions(\n params: AlreadyGaveTradePermissionParams,\n ): Promise<AlreadyGaveTradePermissionResult> {\n const uri = `/api/conditional-orders/gave-trade-permission/${params.accountId}`;\n const response = await this.get<boolean>(uri);\n\n return {\n permissionGiven: response,\n };\n }\n\n async alreadyGaveTradePermissionToWallet(\n params: AlreadyGaveTradePermissionToWalletParams,\n ): Promise<AlreadyGaveTradePermissionToWalletResult> {\n const uri = `/api/conditional-orders/gave-trade-permission-to-wallet/${params.accountId}/${params.targetWalletAddress}`;\n const response = await this.get<boolean>(uri);\n\n return {\n permissionGiven: response,\n };\n }\n\n async cancelConditionalOrder(\n params: CancelConditionalOrderParams,\n ): Promise<CancelConditionalOrderResult> {\n const signature = await signCancelConditionalOrder(\n params.signer,\n params.orderId,\n );\n\n const uri = `/api/conditional-orders/cancel-order`;\n const res = await this.put<ConditionalOrder>(\n uri,\n {},\n {\n orderId: params.orderId,\n userSignature: signature,\n },\n );\n return res;\n }\n\n async registerConditionalOrder(\n params: RegisterConditionalOrderParams,\n ): Promise<RegisterConditionalOrderResult> {\n const inputs = await this.parseConditionalOrderInputs(\n params.signer,\n params.marginAccountId,\n params.marketId,\n params.orderType,\n params.triggerPrice,\n params.supportingParams.exchangeId,\n params.supportingParams.counterpartyAccountIds,\n params.amountInBase,\n );\n\n // create new entry\n const uri = `/api/conditional-orders/create-or-update-order`;\n\n const result = await this.post<ConditionalOrder>(\n uri,\n {},\n {\n accountId: params.marginAccountId,\n poolId: params.supportingParams.counterpartyAccountIds[0],\n deadline: inputs.deadline,\n exchangeId: params.supportingParams.exchangeId,\n isLong: inputs.actualAmountInBase > 0,\n marketId: params.marketId,\n nonce: inputs.nonce.toString(),\n orderPriceLimit: inputs.orderPriceLimit.toString(),\n orderType: params.orderType,\n signature: inputs.signature,\n signerWallet: await params.signer.getAddress(),\n timestampMs: inputs.creationTimestampMs,\n triggerPrice: params.triggerPrice,\n orderBase: params.amountInBase,\n },\n );\n return result;\n }\n\n async updateConditionalOrder(\n params: UpdateConditionalOrderParams,\n ): Promise<UpdateConditionalOrderResult> {\n const inputs = await this.parseConditionalOrderInputs(\n params.signer,\n params.marginAccountId,\n params.marketId,\n params.orderType,\n params.triggerPrice,\n params.supportingParams.exchangeId,\n params.supportingParams.counterpartyAccountIds,\n params.amountInBase,\n );\n\n // create new entry\n const uri = `/api/conditional-orders/create-or-update-order`;\n\n const result = await this.post<ConditionalOrder>(\n uri,\n {},\n {\n accountId: params.marginAccountId,\n poolId: params.supportingParams.counterpartyAccountIds[0],\n deadline: inputs.deadline,\n exchangeId: params.supportingParams.exchangeId,\n isLong: inputs.actualAmountInBase > 0,\n marketId: params.marketId,\n nonce: inputs.nonce.toString(),\n orderPriceLimit: inputs.orderPriceLimit.toString(),\n orderType: params.orderType,\n signature: inputs.signature,\n signerWallet: await params.signer.getAddress(),\n timestampMs: inputs.creationTimestampMs,\n triggerPrice: params.triggerPrice,\n cancelOrderId: params.cancelOrderId,\n orderBase: params.amountInBase,\n },\n );\n return result;\n }\n\n private async getPosition(\n accountId: number,\n marketId: number,\n ): Promise<PositionEntity> {\n const uri = `/api/accounts/marginAccount/position/${accountId}/${marketId}`;\n return this.get<PositionEntity>(uri);\n }\n\n private async parseConditionalOrderInputs(\n signer: Signer | JsonRpcSigner,\n accountId: number,\n marketId: number,\n orderType: ConditionalOrderType,\n triggerPrice: number,\n exchangeId: number,\n counterpartyAccountIds: number[],\n amountInBase?: number,\n ): Promise<{\n signature: string;\n actualAmountInBase: number;\n orderPriceLimit: bigint;\n nonce: bigint;\n deadline: number;\n creationTimestampMs: number;\n }> {\n let inputs: string;\n let actualAmountInBase: number;\n let isLongOrder: boolean;\n let orderPriceLimit: bigint;\n\n if (orderType === ConditionalOrderType.LIMIT_ORDER) {\n if (amountInBase === undefined) {\n throw new Error('Order base is required for limit orders');\n }\n\n if (amountInBase === 0) {\n throw new Error('Cannot create an empty limit order');\n }\n\n actualAmountInBase = amountInBase;\n isLongOrder = actualAmountInBase > 0;\n orderPriceLimit = calculateMaxPriceLimit(isLongOrder);\n\n inputs = AbiCoder.defaultAbiCoder().encode(\n ['int256', 'uint256'],\n [scale(18)(amountInBase), scale(18)(triggerPrice)],\n );\n } else {\n const position = await this.getPosition(accountId, marketId);\n const positionBase = position.base;\n\n if (positionBase === 0) {\n throw new Error('Cannot create SL or TP order for closed positions');\n }\n\n actualAmountInBase = -positionBase;\n isLongOrder = actualAmountInBase > 0;\n orderPriceLimit = calculateMaxPriceLimit(isLongOrder);\n\n inputs = AbiCoder.defaultAbiCoder().encode(\n ['bool', 'uint256', 'uint256'],\n [isLongOrder, scale(18)(triggerPrice), orderPriceLimit],\n );\n }\n\n const creationTimestampMs = Date.now();\n const nonce = createNonce(accountId, marketId, creationTimestampMs);\n\n const signature = await signConditionalOrder(\n signer,\n this.reyaChainId,\n accountId,\n marketId,\n exchangeId,\n counterpartyAccountIds,\n orderType,\n inputs,\n nonce,\n CONDITIONAL_ORDER_SIG_DEADLINE,\n );\n\n return {\n signature,\n actualAmountInBase,\n orderPriceLimit,\n nonce,\n deadline: CONDITIONAL_ORDER_SIG_DEADLINE,\n creationTimestampMs,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/conditional-orders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAWyB;AACzB,iCAAkC;AAiBlC,iCAAsC;AAEtC;IAAqD,2CAAU;IAG7D,iCAAY,WAAwB,EAAE,IAAY;QAChD,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QACZ,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;;IACjC,CAAC;IAED,yCAAyC;IACnC,6EAA2C,GAAjD,UACE,MAAyD;;;;gBAEnD,GAAG,GAAG,wDAAiD,MAAM,CAAC,eAAe,CAAE,CAAC;gBACtF,sBAAO,IAAI,CAAC,GAAG,CAAoD,GAAG,EAAE;wBACtE,KAAK,EAAE,MAAM,CAAC,KAAK;qBACpB,CAAC,EAAC;;;KACJ;IAEK,6EAA2C,GAAjD,UACE,MAAyD;;;;gBAEnD,GAAG,GAAG,uDAAgD,MAAM,CAAC,aAAa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AAC,MAAM,CACxC,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,EAC9B,CAAC,WAAW,EAAE,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,CACxD,CAAC;;;wBAGE,mBAAmB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;wBACjC,KAAK,GAAG,IAAA,mBAAW,EAAC,SAAS,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;wBAElD,qBAAM,IAAA,6BAAoB,EAC1C,MAAM,EACN,IAAI,CAAC,WAAW,EAChB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,sBAAsB,EACtB,SAAS,EACT,MAAM,EACN,KAAK,EACL,uCAA8B,CAC/B,EAAA;;wBAXK,SAAS,GAAG,SAWjB;wBAED,sBAAO;gCACL,SAAS,WAAA;gCACT,kBAAkB,oBAAA;gCAClB,eAAe,iBAAA;gCACf,KAAK,OAAA;gCACL,QAAQ,EAAE,uCAA8B;gCACxC,mBAAmB,qBAAA;6BACpB,EAAC;;;;KACH;IACH,8BAAC;AAAD,CAAC,AAhPD,CAAqD,mBAAU,GAgP9D","sourcesContent":["import {\n calculateMaxPriceLimit,\n PositionEntity,\n RestClient,\n ReyaChainId,\n signConditionalOrder,\n signCancelConditionalOrder,\n ConditionalOrder,\n ConditionalOrderType,\n scale,\n CONDITIONAL_ORDER_SIG_DEADLINE,\n} from '@reyaxyz/common';\nimport { AbiCoder } from 'ethers';\nimport { Signer, JsonRpcSigner } from 'ethers';\nimport {\n AlreadyGaveTradePermissionParams,\n AlreadyGaveTradePermissionResult,\n CancelConditionalOrderParams,\n CancelConditionalOrderResult,\n GetConditionalOrdersHistoryForMarginAccountParams,\n GetConditionalOrdersHistoryForMarginAccountResult,\n GetConditionalOrdersHistoryForWalletAddressParams,\n RegisterConditionalOrderParams,\n RegisterConditionalOrderResult,\n UpdateConditionalOrderParams,\n UpdateConditionalOrderResult,\n AlreadyGaveTradePermissionToWalletParams,\n AlreadyGaveTradePermissionToWalletResult,\n} from './types';\nimport { createNonce } from './utils';\n\nexport default class ConditionalOrdersClient extends RestClient {\n private reyaChainId: ReyaChainId;\n\n constructor(reyaChainId: ReyaChainId, host: string) {\n super(host);\n this.reyaChainId = reyaChainId;\n }\n\n // ------ Conditional Orders History ---\n async getConditionalOrdersHistoryForMarginAccount(\n params: GetConditionalOrdersHistoryForMarginAccountParams,\n ): Promise<GetConditionalOrdersHistoryForMarginAccountResult> {\n const uri = `/api/conditional-orders/get-orders-by-account/${params.marginAccountId}`;\n return this.get<GetConditionalOrdersHistoryForMarginAccountResult>(uri, {\n limit: params.limit,\n });\n }\n\n async getConditionalOrdersHistoryForWalletAddress(\n params: GetConditionalOrdersHistoryForWalletAddressParams,\n ): Promise<GetConditionalOrdersHistoryForMarginAccountResult> {\n const uri = `/api/conditional-orders/get-orders-by-wallet/${params.walletAddress}`;\n return this.get<GetConditionalOrdersHistoryForMarginAccountResult>(uri, {\n limit: params.limit,\n });\n }\n\n async alreadyGaveTradePermissions(\n params: AlreadyGaveTradePermissionParams,\n ): Promise<AlreadyGaveTradePermissionResult> {\n const uri = `/api/conditional-orders/gave-trade-permission/${params.accountId}`;\n const response = await this.get<boolean>(uri);\n\n return {\n permissionGiven: response,\n };\n }\n\n async alreadyGaveTradePermissionToWallet(\n params: AlreadyGaveTradePermissionToWalletParams,\n ): Promise<AlreadyGaveTradePermissionToWalletResult> {\n const uri = `/api/conditional-orders/gave-trade-permission-to-wallet/${params.accountId}/${params.targetWalletAddress}`;\n const response = await this.get<boolean>(uri);\n\n return {\n permissionGiven: response,\n };\n }\n\n async cancelConditionalOrder(\n params: CancelConditionalOrderParams,\n ): Promise<CancelConditionalOrderResult> {\n const signature = await signCancelConditionalOrder(\n params.signer,\n params.orderId,\n );\n\n const uri = `/api/conditional-orders/cancel-order`;\n const res = await this.put<ConditionalOrder>(\n uri,\n {},\n {\n orderId: params.orderId,\n userSignature: signature,\n },\n );\n return res;\n }\n\n async registerConditionalOrder(\n params: RegisterConditionalOrderParams,\n ): Promise<RegisterConditionalOrderResult> {\n const inputs = await this.parseConditionalOrderInputs(\n params.signer,\n params.marginAccountId,\n params.marketId,\n params.orderType,\n params.triggerPrice,\n params.supportingParams.exchangeId,\n params.supportingParams.counterpartyAccountIds,\n params.amountInBase,\n );\n\n // create new entry\n const uri = `/api/conditional-orders/create-or-update-order`;\n\n const result = await this.post<ConditionalOrder>(\n uri,\n {},\n {\n accountId: params.marginAccountId,\n poolId: params.supportingParams.counterpartyAccountIds[0],\n deadline: inputs.deadline,\n exchangeId: params.supportingParams.exchangeId,\n isLong: inputs.actualAmountInBase > 0,\n marketId: params.marketId,\n nonce: inputs.nonce.toString(),\n orderPriceLimit: inputs.orderPriceLimit.toString(),\n orderType: params.orderType,\n signature: inputs.signature,\n signerWallet: await params.signer.getAddress(),\n timestampMs: inputs.creationTimestampMs,\n triggerPrice: params.triggerPrice,\n orderBase: params.amountInBase,\n },\n );\n return result;\n }\n\n async updateConditionalOrder(\n params: UpdateConditionalOrderParams,\n ): Promise<UpdateConditionalOrderResult> {\n const inputs = await this.parseConditionalOrderInputs(\n params.signer,\n params.marginAccountId,\n params.marketId,\n params.orderType,\n params.triggerPrice,\n params.supportingParams.exchangeId,\n params.supportingParams.counterpartyAccountIds,\n params.amountInBase,\n );\n\n // create new entry\n const uri = `/api/conditional-orders/create-or-update-order`;\n\n const result = await this.post<ConditionalOrder>(\n uri,\n {},\n {\n accountId: params.marginAccountId,\n poolId: params.supportingParams.counterpartyAccountIds[0],\n deadline: inputs.deadline,\n exchangeId: params.supportingParams.exchangeId,\n isLong: inputs.actualAmountInBase > 0,\n marketId: params.marketId,\n nonce: inputs.nonce.toString(),\n orderPriceLimit: inputs.orderPriceLimit.toString(),\n orderType: params.orderType,\n signature: inputs.signature,\n signerWallet: await params.signer.getAddress(),\n timestampMs: inputs.creationTimestampMs,\n triggerPrice: params.triggerPrice,\n cancelOrderId: params.cancelOrderId,\n orderBase: params.amountInBase,\n },\n );\n return result;\n }\n\n private async getPosition(\n accountId: number,\n marketId: number,\n ): Promise<PositionEntity> {\n const uri = `/api/accounts/marginAccount/position/${accountId}/${marketId}`;\n return this.get<PositionEntity>(uri);\n }\n\n private async parseConditionalOrderInputs(\n signer: Signer | JsonRpcSigner,\n accountId: number,\n marketId: number,\n orderType: ConditionalOrderType,\n triggerPrice: number,\n exchangeId: number,\n counterpartyAccountIds: number[],\n amountInBase?: number,\n ): Promise<{\n signature: string;\n actualAmountInBase: number;\n orderPriceLimit: bigint;\n nonce: bigint;\n deadline: number;\n creationTimestampMs: number;\n }> {\n let inputs: string;\n let actualAmountInBase: number;\n let isLongOrder: boolean;\n let orderPriceLimit: bigint;\n\n if (orderType === ConditionalOrderType.LIMIT_ORDER) {\n if (amountInBase === undefined) {\n throw new Error('Order base is required for limit orders');\n }\n\n if (amountInBase === 0) {\n throw new Error('Cannot create an empty limit order');\n }\n\n actualAmountInBase = amountInBase;\n isLongOrder = actualAmountInBase > 0;\n orderPriceLimit = calculateMaxPriceLimit(isLongOrder);\n\n inputs = AbiCoder.defaultAbiCoder().encode(\n ['int256', 'uint256'],\n [scale(18)(amountInBase), scale(18)(triggerPrice)],\n );\n } else {\n const position = await this.getPosition(accountId, marketId);\n const positionBase = position.base;\n\n if (positionBase === 0) {\n throw new Error('Cannot create SL or TP order for closed positions');\n }\n\n actualAmountInBase = -positionBase;\n isLongOrder = actualAmountInBase > 0;\n orderPriceLimit = calculateMaxPriceLimit(isLongOrder);\n\n inputs = AbiCoder.defaultAbiCoder().encode(\n ['bool', 'uint256', 'uint256'],\n [isLongOrder, scale(18)(triggerPrice), orderPriceLimit],\n );\n }\n\n const creationTimestampMs = Date.now();\n const nonce = createNonce(accountId, marketId, creationTimestampMs);\n\n const signature = await signConditionalOrder(\n signer,\n this.reyaChainId,\n accountId,\n marketId,\n exchangeId,\n counterpartyAccountIds,\n orderType,\n inputs,\n nonce,\n CONDITIONAL_ORDER_SIG_DEADLINE,\n );\n\n return {\n signature,\n actualAmountInBase,\n orderPriceLimit,\n nonce,\n deadline: CONDITIONAL_ORDER_SIG_DEADLINE,\n creationTimestampMs,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/conditional-orders/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ConditionalOrder,\n UnifiedConditionalOrderType,\n ConditionalOrderType,\n} from '@reyaxyz/common';\nimport { Signer, JsonRpcSigner } from 'ethers';\nimport { MarginAccountEntity, MarketEntity, Address } from '@reyaxyz/common';\n\nexport type CancelConditionalOrderParams = {\n signer: Signer | JsonRpcSigner;\n orderId: string;\n};\n\nexport type CancelConditionalOrderResult = ConditionalOrder;\n\nexport type ConditionalOrderDetails = {\n accountId: number;\n marketId: number;\n exchangeId: number;\n counterpartyAccountIds: number[];\n orderType: number;\n inputs: string;\n signer: string;\n nonce: bigint;\n};\n\nexport type OrderSupportingParams = {\n exchangeId: MarketEntity['orderInfo']['exchangeId'];\n counterpartyAccountIds: MarketEntity['orderInfo']['counterpartyAccountIds'];\n currentPrice: number;\n};\n\nexport type RegisterConditionalOrderParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: MarginAccountEntity['id'];\n triggerPrice: number;\n orderType: ConditionalOrderType;\n marketId: number;\n supportingParams: OrderSupportingParams;\n amountInBase?: number;\n};\n\nexport type UpdateConditionalOrderParams = {\n cancelOrderId: string;\n} & RegisterConditionalOrderParams;\n\nexport type RegisterConditionalOrderResult = ConditionalOrder;\nexport type UpdateConditionalOrderResult = ConditionalOrder;\n\nexport type AlreadyGaveTradePermissionParams = {\n accountId: number;\n};\n\nexport type AlreadyGaveTradePermissionResult = {\n permissionGiven: boolean;\n};\n\nexport type AlreadyGaveTradePermissionToWalletParams = {\n accountId: number;\n targetWalletAddress: Address;\n};\n\nexport type AlreadyGaveTradePermissionToWalletResult = {\n permissionGiven: boolean;\n};\n\n// ---- Conditional Orders History ---\nexport type GetConditionalOrdersHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetConditionalOrdersHistoryForMarginAccountResult =\n UnifiedConditionalOrderType[];\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/conditional-orders/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ConditionalOrder,\n UnifiedConditionalOrderType,\n ConditionalOrderType,\n} from '@reyaxyz/common';\nimport { Signer, JsonRpcSigner } from 'ethers';\nimport { MarginAccountEntity, MarketEntity, Address } from '@reyaxyz/common';\n\nexport type CancelConditionalOrderParams = {\n signer: Signer | JsonRpcSigner;\n orderId: string;\n};\n\nexport type CancelConditionalOrderResult = ConditionalOrder;\n\nexport type ConditionalOrderDetails = {\n accountId: number;\n marketId: number;\n exchangeId: number;\n counterpartyAccountIds: number[];\n orderType: number;\n inputs: string;\n signer: string;\n nonce: bigint;\n};\n\nexport type OrderSupportingParams = {\n exchangeId: MarketEntity['orderInfo']['exchangeId'];\n counterpartyAccountIds: MarketEntity['orderInfo']['counterpartyAccountIds'];\n currentPrice: number;\n};\n\nexport type RegisterConditionalOrderParams = {\n signer: Signer | JsonRpcSigner;\n marginAccountId: MarginAccountEntity['id'];\n triggerPrice: number;\n orderType: ConditionalOrderType;\n marketId: number;\n supportingParams: OrderSupportingParams;\n amountInBase?: number;\n};\n\nexport type UpdateConditionalOrderParams = {\n cancelOrderId: string;\n} & RegisterConditionalOrderParams;\n\nexport type RegisterConditionalOrderResult = ConditionalOrder;\nexport type UpdateConditionalOrderResult = ConditionalOrder;\n\nexport type AlreadyGaveTradePermissionParams = {\n accountId: number;\n};\n\nexport type AlreadyGaveTradePermissionResult = {\n permissionGiven: boolean;\n};\n\nexport type AlreadyGaveTradePermissionToWalletParams = {\n accountId: number;\n targetWalletAddress: Address;\n};\n\nexport type AlreadyGaveTradePermissionToWalletResult = {\n permissionGiven: boolean;\n};\n\n// ---- Conditional Orders History ---\nexport type GetConditionalOrdersHistoryForMarginAccountParams = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n limit?: number;\n};\n\nexport type GetConditionalOrdersHistoryForWalletAddressParams = {\n walletAddress: string;\n limit?: number;\n};\n\nexport type GetConditionalOrdersHistoryForMarginAccountResult =\n UnifiedConditionalOrderType[];\n"]}
|
|
@@ -200,6 +200,8 @@ var TradeSimulationClient = /** @class */ (function () {
|
|
|
200
200
|
liquidationMarginRequirement: liquidationMarginRequirement,
|
|
201
201
|
});
|
|
202
202
|
var marginRatioHealth = common_1.ExposureCommand.evaluateHealthStatus(marginRatio * 100);
|
|
203
|
+
var xpEarnRangeMin = Math.round(Math.abs(snappedAmount) / common_2.INSTANT_TRADING_RATE_XP);
|
|
204
|
+
var xpEarnRangeMax = Math.round((100 * Math.abs(snappedAmount)) / common_2.INSTANT_TRADING_RATE_XP);
|
|
203
205
|
return {
|
|
204
206
|
fees: fees,
|
|
205
207
|
snappedAmount: snappedAmount,
|
|
@@ -210,6 +212,10 @@ var TradeSimulationClient = /** @class */ (function () {
|
|
|
210
212
|
availableMargin: availableMargin,
|
|
211
213
|
marginBalance: marginBalance,
|
|
212
214
|
requiredMargin: requiredMargin,
|
|
215
|
+
xpEarnRange: {
|
|
216
|
+
min: xpEarnRangeMin,
|
|
217
|
+
max: xpEarnRangeMax,
|
|
218
|
+
},
|
|
213
219
|
};
|
|
214
220
|
};
|
|
215
221
|
TradeSimulationClient.prototype.getMaxAmountForLimitOrder = function (params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,0CAMyB;AACzB,8DAAqC;AACrC,0CAA0D;AAE1D;IAUE,+BAAY,aAA4B;QAThC,aAAQ,GAAkB,IAAI,CAAC;QAC/B,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAIP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AC,sBAAS,CAAC,WAAW,CAAC;aACnC,YAAY,CAAC,WAAW,CAAC;aACzB,QAAQ,EAAE,CAAC;QAEd,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,aAAa,CAAC;QACxB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,2CAAW,GAAX,UAAY,KAAa;QACvB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAEO,IAAA,oBAAoB,GAAK,IAAI,CAAC,UAAU,qBAApB,CAAqB;QAEjD,eAAe;QACf,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,oBAAoB,CAAC,uBAAuB,CAAC,oBAAoB,CAC/D,QAAQ,CACT,GAAG,KAAK,CAAC;QACV,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACrE,KAAK,CAAC;IACV,CAAC;IACH,4BAAC;AAAD,CAAC,AAjfD,IAifC","sourcesContent":["import {\n EstimatedPriceParams,\n EstimatedPriceResult,\n LimitTradeMaxOrderSizeParams,\n LimitTradeMaxOrderSizeResult,\n SimulateLimitTradeEntity,\n SimulateTradeEntity,\n TradeSimulationConvertValueEstimatedPriceParams,\n TradeSimulationConvertValueParams,\n TradeSimulationConvertValueResult,\n TradeSimulationLoadDataParams,\n TradeSimulationSimulateLimitParams,\n TradeSimulationSimulateParams,\n} from './types';\nimport AccountClient from '../account';\nimport {\n amountNormalizer,\n ExposureCommand,\n MarginInfo,\n PositionInfo,\n TradeSimulationState,\n} from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { INSTANT_TRADING_RATE_XP } from '@reyaxyz/common';\n\nexport default class TradeSimulationClient {\n private marketId: number | null = null;\n private accountId: number | null = null;\n private loadedData: {\n tradeSimulationState: TradeSimulationState;\n userAccountExposure: ExposureCommand;\n passivePoolExposure: ExposureCommand;\n } | null = null;\n private accountClient: AccountClient;\n\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on marketId and accountId\n async arm(params: TradeSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n this.accountId = params.marginAccountId;\n\n const tradeSimulationState = await this.fetchMarketData(\n this.marketId,\n this.accountId,\n );\n\n const userAccountExposure = new ExposureCommand(\n tradeSimulationState.exposureDataAccount.accountId,\n tradeSimulationState.exposureDataAccount.rootCollateralPoolId,\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket,\n tradeSimulationState.exposureDataAccount.accountBalancePerAsset,\n tradeSimulationState.exposureDataAccount.groupedByCollateral,\n tradeSimulationState.exposureDataAccount.riskMultipliers,\n tradeSimulationState.exposureDataAccount.riskMatrices,\n tradeSimulationState.exposureDataAccount.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataAccount.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataAccount.uniqueTokenAddresses,\n tradeSimulationState.exposureDataAccount.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataAccount.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataAccount.realizedPnLSum,\n tradeSimulationState.exposureDataAccount.unrealizedPnLSum,\n tradeSimulationState.exposureDataAccount.mtmRpnlSum,\n tradeSimulationState.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n const passivePoolExposure = new ExposureCommand(\n tradeSimulationState.exposureDataPassivePool.accountId,\n tradeSimulationState.exposureDataPassivePool.rootCollateralPoolId,\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket,\n tradeSimulationState.exposureDataPassivePool.accountBalancePerAsset,\n tradeSimulationState.exposureDataPassivePool.groupedByCollateral,\n tradeSimulationState.exposureDataPassivePool.riskMultipliers,\n tradeSimulationState.exposureDataPassivePool.riskMatrices,\n tradeSimulationState.exposureDataPassivePool.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataPassivePool.uniqueTokenAddresses,\n tradeSimulationState.exposureDataPassivePool.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataPassivePool.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.realizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.unrealizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.mtmRpnlSum,\n tradeSimulationState.exposureDataPassivePool.collateralAddressToExchangePrice,\n );\n\n this.loadedData = {\n tradeSimulationState,\n userAccountExposure,\n passivePoolExposure,\n };\n }\n\n private async fetchMarketData(\n marketId: number,\n accountId: number,\n ): Promise<TradeSimulationState> {\n return this.accountClient.getTransactionSimulationInitialData({\n marginAccountId: accountId,\n marketId: marketId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure, passivePoolExposure } =\n this.loadedData;\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n }\n\n /*\n max amount of margin in rUSD terms that can be transferred from the source account to the destination account\n that performs the isolated position trade (PRE TRADE)\n */\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n const fees = ExposureCommand.calculateFee(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n amount,\n tradeSimulationState.feeParameter,\n );\n\n const {\n usdNodeMarginInfo: newMarginInfo,\n tokenMarginInfoPerAsset,\n positionInfoMarketConfiguration,\n } = userAccountExposure.getUsdNodeMarginInfoPostTrade(\n amount,\n tradeSimulationState.marketStorage.quote_collateral,\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage.risk_block_id,\n );\n\n const newQuoteTokenMarginInfo = tokenMarginInfoPerAsset.find(\n (marginInfo: MarginInfo) => {\n return (\n marginInfo.assetAddress ===\n tradeSimulationState.marketStorage.quote_collateral\n );\n },\n );\n\n const positionInfo = positionInfoMarketConfiguration.find(\n (positionInfo: PositionInfo) => {\n return (\n positionInfo.market_id ===\n tradeSimulationState.marketConfiguration.market_id\n );\n },\n );\n\n if (!newQuoteTokenMarginInfo) {\n throw new Error('Error performing simulation');\n }\n\n /*\n * Note, required margin is the initial margin requirement in rUSD terms of the account after the trade.\n * margin balance rusd - initial delta rusd = margin balance rusd - (margin balance rusd - imr rusd) = imr rusd\n * */\n\n const requiredMargin =\n newQuoteTokenMarginInfo.marginBalance -\n newQuoteTokenMarginInfo.initialDelta;\n\n const liquidationPrice = ExposureCommand.calculateLiquidation(\n newMarginInfo.marginBalance,\n newQuoteTokenMarginInfo.liquidationMarginRequirement,\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n BigNumber(positionInfo?.base || 0).toNumber(),\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * estimatedPrice;\n const xpEarnRangeMin = Math.round(\n Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,\n );\n const xpEarnRangeMax = Math.round(\n (100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,\n );\n\n return {\n estimatedPrice,\n estimatedSlippage: slippage * 100,\n fees,\n liquidationPrice: liquidationPrice.toNumber(),\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n marginBalance,\n availableMargin,\n requiredMargin,\n snappedAmount,\n snappedAmountInBase,\n xpEarnRange: {\n min: xpEarnRangeMin,\n max: xpEarnRangeMax,\n },\n maxSlippage: 1,\n } as SimulateTradeEntity;\n }\n\n getRiskMatrixElement(): number {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n const riskBlockId = tradeSimulationState.marketStorage.risk_block_id;\n const riskMatrices = tradeSimulationState.exposureDataAccount.riskMatrices;\n\n const riskMatrix = riskMatrices.find(\n (riskMatrix) => riskMatrix.risk_block_id === riskBlockId,\n );\n\n if (!riskMatrix) {\n throw new Error('Risk matrix not found');\n }\n\n const riskMatrixIndex =\n tradeSimulationState.marketConfiguration.risk_matrix_index;\n\n return Number(riskMatrix.matrix[riskMatrixIndex][riskMatrixIndex]);\n }\n\n // Synchronous method to simulate operations based on an amount\n simulateLimit(\n params: TradeSimulationSimulateLimitParams,\n ): SimulateLimitTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure } = this.loadedData;\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount).div(params.triggerPrice).toNumber();\n }\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * params.triggerPrice;\n\n const fees = ExposureCommand.calculateFee(\n params.triggerPrice,\n amount,\n tradeSimulationState.feeParameter,\n );\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const accountLMR =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement;\n const accountIMR = accountLMR * imrMultiplier;\n\n const limitOrderLMR =\n Math.sqrt(riskMatrixElement) * Math.abs(snappedAmount);\n const limitOrderIMR = limitOrderLMR * imrMultiplier;\n\n const requiredMargin = accountIMR + limitOrderIMR;\n\n const liquidationMarginRequirement =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement +\n limitOrderLMR;\n\n const marginRatio = ExposureCommand.getMarginRatio({\n marginBalance,\n liquidationMarginRequirement,\n });\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n return {\n fees,\n snappedAmount,\n snappedAmountInBase,\n estimatedPrice: params.triggerPrice,\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n availableMargin,\n marginBalance,\n requiredMargin,\n };\n }\n\n getMaxAmountForLimitOrder(\n params: LimitTradeMaxOrderSizeParams,\n ): LimitTradeMaxOrderSizeResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { userAccountExposure, tradeSimulationState } = this.loadedData;\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const maxAmountSize = Math.max(\n (availableMargin / Math.sqrt(riskMatrixElement) / imrMultiplier) * 0.97, // @todo implement dynamic buffer\n 0,\n );\n const maxAmountBase = maxAmountSize / params.triggerPrice;\n\n const minAmountBase = amountNormalizer(\n tradeSimulationState.marketConfiguration.minimum_order_base,\n ).toNumber();\n\n const minAmountSize = minAmountBase * params.triggerPrice;\n\n return {\n maxAmountBase,\n maxAmountSize,\n minAmountBase,\n minAmountSize,\n };\n }\n\n convertValue(\n params: TradeSimulationConvertValueParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n if (!params.fromBase)\n return BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n else\n return BigNumber(params.amount)\n .times(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n }\n\n convertValueEstimatedPrice(\n params: TradeSimulationConvertValueEstimatedPriceParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const amountForSlippage = params.fromBase\n ? params.amount\n : BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amountForSlippage).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n if (!params.fromBase)\n return BigNumber(params.amount).div(estimatedPrice).toNumber();\n else return BigNumber(params.amount).times(estimatedPrice).toNumber();\n }\n\n customLeverage(): number | null {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n return tradeSimulationState.customLeverage;\n }\n\n estimatedPrice(params: EstimatedPriceParams): EstimatedPriceResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(params.amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const price =\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ];\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n return {\n estimatedPrice,\n markPrice: price,\n };\n }\n\n roundToBaseSpacing(amount: number, baseSpacing: number): number {\n const snappedAmount = BigNumber(amount)\n .abs()\n .dividedBy(baseSpacing)\n .integerValue(BigNumber.ROUND_FLOOR)\n .multipliedBy(baseSpacing)\n .toNumber();\n\n if (amount < 0) {\n return -snappedAmount;\n }\n return snappedAmount;\n }\n\n updatePrice(price: number): void {\n if (!this.loadedData || !this.marketId) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n // update price\n const marketId = this.marketId;\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n marketId\n ] = price;\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[marketId] =\n price;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,0CAMyB;AACzB,8DAAqC;AACrC,0CAA0D;AAE1D;IAUE,+BAAY,aAA4B;QAThC,aAAQ,GAAkB,IAAI,CAAC;QAC/B,cAAS,GAAkB,IAAI,CAAC;QAChC,eAAU,GAIP,IAAI,CAAC;QAId,oBAAoB;QACpB,IAAI,CAAC,aA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AS,CACnD,EACD,QAAQ,CACT,CAAC;QAEF,OAAO;YACL,cAAc,gBAAA;YACd,SAAS,EAAE,KAAK;SACjB,CAAC;IACJ,CAAC;IAED,kDAAkB,GAAlB,UAAmB,MAAc,EAAE,WAAmB;QACpD,IAAM,aAAa,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC;aACpC,GAAG,EAAE;aACL,SAAS,CAAC,WAAW,CAAC;aACtB,YAAY,CAAC,sBAAS,CAAC,WAAW,CAAC;aACnC,YAAY,CAAC,WAAW,CAAC;aACzB,QAAQ,EAAE,CAAC;QAEd,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,aAAa,CAAC;QACxB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,2CAAW,GAAX,UAAY,KAAa;QACvB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAEO,IAAA,oBAAoB,GAAK,IAAI,CAAC,UAAU,qBAApB,CAAqB;QAEjD,eAAe;QACf,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,oBAAoB,CAAC,uBAAuB,CAAC,oBAAoB,CAC/D,QAAQ,CACT,GAAG,KAAK,CAAC;QACV,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACrE,KAAK,CAAC;IACV,CAAC;IACH,4BAAC;AAAD,CAAC,AA5fD,IA4fC","sourcesContent":["import {\n EstimatedPriceParams,\n EstimatedPriceResult,\n LimitTradeMaxOrderSizeParams,\n LimitTradeMaxOrderSizeResult,\n SimulateLimitTradeEntity,\n SimulateTradeEntity,\n TradeSimulationConvertValueEstimatedPriceParams,\n TradeSimulationConvertValueParams,\n TradeSimulationConvertValueResult,\n TradeSimulationLoadDataParams,\n TradeSimulationSimulateLimitParams,\n TradeSimulationSimulateParams,\n} from './types';\nimport AccountClient from '../account';\nimport {\n amountNormalizer,\n ExposureCommand,\n MarginInfo,\n PositionInfo,\n TradeSimulationState,\n} from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { INSTANT_TRADING_RATE_XP } from '@reyaxyz/common';\n\nexport default class TradeSimulationClient {\n private marketId: number | null = null;\n private accountId: number | null = null;\n private loadedData: {\n tradeSimulationState: TradeSimulationState;\n userAccountExposure: ExposureCommand;\n passivePoolExposure: ExposureCommand;\n } | null = null;\n private accountClient: AccountClient;\n\n constructor(accountClient: AccountClient) {\n // Constructor added\n this.accountClient = accountClient;\n }\n\n // Method to asynchronously load data based on marketId and accountId\n async arm(params: TradeSimulationLoadDataParams): Promise<void> {\n this.marketId = params.marketId;\n this.accountId = params.marginAccountId;\n\n const tradeSimulationState = await this.fetchMarketData(\n this.marketId,\n this.accountId,\n );\n\n const userAccountExposure = new ExposureCommand(\n tradeSimulationState.exposureDataAccount.accountId,\n tradeSimulationState.exposureDataAccount.rootCollateralPoolId,\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket,\n tradeSimulationState.exposureDataAccount.accountBalancePerAsset,\n tradeSimulationState.exposureDataAccount.groupedByCollateral,\n tradeSimulationState.exposureDataAccount.riskMultipliers,\n tradeSimulationState.exposureDataAccount.riskMatrices,\n tradeSimulationState.exposureDataAccount.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataAccount.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataAccount.uniqueTokenAddresses,\n tradeSimulationState.exposureDataAccount.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataAccount.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataAccount.realizedPnLSum,\n tradeSimulationState.exposureDataAccount.unrealizedPnLSum,\n tradeSimulationState.exposureDataAccount.mtmRpnlSum,\n tradeSimulationState.exposureDataAccount.collateralAddressToExchangePrice,\n );\n\n const passivePoolExposure = new ExposureCommand(\n tradeSimulationState.exposureDataPassivePool.accountId,\n tradeSimulationState.exposureDataPassivePool.rootCollateralPoolId,\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket,\n tradeSimulationState.exposureDataPassivePool.accountBalancePerAsset,\n tradeSimulationState.exposureDataPassivePool.groupedByCollateral,\n tradeSimulationState.exposureDataPassivePool.riskMultipliers,\n tradeSimulationState.exposureDataPassivePool.riskMatrices,\n tradeSimulationState.exposureDataPassivePool.exchangeInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.positionInfoMarketConfiguration,\n tradeSimulationState.exposureDataPassivePool.uniqueTokenAddresses,\n tradeSimulationState.exposureDataPassivePool.uniqueQuoteCollaterals,\n tradeSimulationState.exposureDataPassivePool.tokenMarginInfoPerAsset,\n tradeSimulationState.exposureDataPassivePool.realizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.unrealizedPnLSum,\n tradeSimulationState.exposureDataPassivePool.mtmRpnlSum,\n tradeSimulationState.exposureDataPassivePool.collateralAddressToExchangePrice,\n );\n\n this.loadedData = {\n tradeSimulationState,\n userAccountExposure,\n passivePoolExposure,\n };\n }\n\n private async fetchMarketData(\n marketId: number,\n accountId: number,\n ): Promise<TradeSimulationState> {\n return this.accountClient.getTransactionSimulationInitialData({\n marginAccountId: accountId,\n marketId: marketId,\n });\n }\n\n // Synchronous method to simulate operations based on an amount\n simulate(params: TradeSimulationSimulateParams): SimulateTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure, passivePoolExposure } =\n this.loadedData;\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n }\n\n /*\n max amount of margin in rUSD terms that can be transferred from the source account to the destination account\n that performs the isolated position trade (PRE TRADE)\n */\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n const fees = ExposureCommand.calculateFee(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n amount,\n tradeSimulationState.feeParameter,\n );\n\n const {\n usdNodeMarginInfo: newMarginInfo,\n tokenMarginInfoPerAsset,\n positionInfoMarketConfiguration,\n } = userAccountExposure.getUsdNodeMarginInfoPostTrade(\n amount,\n tradeSimulationState.marketStorage.quote_collateral,\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage.risk_block_id,\n );\n\n const newQuoteTokenMarginInfo = tokenMarginInfoPerAsset.find(\n (marginInfo: MarginInfo) => {\n return (\n marginInfo.assetAddress ===\n tradeSimulationState.marketStorage.quote_collateral\n );\n },\n );\n\n const positionInfo = positionInfoMarketConfiguration.find(\n (positionInfo: PositionInfo) => {\n return (\n positionInfo.market_id ===\n tradeSimulationState.marketConfiguration.market_id\n );\n },\n );\n\n if (!newQuoteTokenMarginInfo) {\n throw new Error('Error performing simulation');\n }\n\n /*\n * Note, required margin is the initial margin requirement in rUSD terms of the account after the trade.\n * margin balance rusd - initial delta rusd = margin balance rusd - (margin balance rusd - imr rusd) = imr rusd\n * */\n\n const requiredMargin =\n newQuoteTokenMarginInfo.marginBalance -\n newQuoteTokenMarginInfo.initialDelta;\n\n const liquidationPrice = ExposureCommand.calculateLiquidation(\n newMarginInfo.marginBalance,\n newQuoteTokenMarginInfo.liquidationMarginRequirement,\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n BigNumber(positionInfo?.base || 0).toNumber(),\n );\n\n const marginRatio = ExposureCommand.getMarginRatio(newMarginInfo);\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * estimatedPrice;\n const xpEarnRangeMin = Math.round(\n Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,\n );\n const xpEarnRangeMax = Math.round(\n (100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,\n );\n\n return {\n estimatedPrice,\n estimatedSlippage: slippage * 100,\n fees,\n liquidationPrice: liquidationPrice.toNumber(),\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n marginBalance,\n availableMargin,\n requiredMargin,\n snappedAmount,\n snappedAmountInBase,\n xpEarnRange: {\n min: xpEarnRangeMin,\n max: xpEarnRangeMax,\n },\n maxSlippage: 1,\n } as SimulateTradeEntity;\n }\n\n getRiskMatrixElement(): number {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n const riskBlockId = tradeSimulationState.marketStorage.risk_block_id;\n const riskMatrices = tradeSimulationState.exposureDataAccount.riskMatrices;\n\n const riskMatrix = riskMatrices.find(\n (riskMatrix) => riskMatrix.risk_block_id === riskBlockId,\n );\n\n if (!riskMatrix) {\n throw new Error('Risk matrix not found');\n }\n\n const riskMatrixIndex =\n tradeSimulationState.marketConfiguration.risk_matrix_index;\n\n return Number(riskMatrix.matrix[riskMatrixIndex][riskMatrixIndex]);\n }\n\n // Synchronous method to simulate operations based on an amount\n simulateLimit(\n params: TradeSimulationSimulateLimitParams,\n ): SimulateLimitTradeEntity {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, userAccountExposure } = this.loadedData;\n\n let amount;\n if (params.fromBase) {\n amount = params.amount;\n } else {\n amount = BigNumber(params.amount).div(params.triggerPrice).toNumber();\n }\n\n const baseSpacing = amountNormalizer(\n tradeSimulationState.marketConfiguration.base_spacing,\n ).toNumber();\n\n const snappedAmountInBase = this.roundToBaseSpacing(amount, baseSpacing);\n const snappedAmount = snappedAmountInBase * params.triggerPrice;\n\n const fees = ExposureCommand.calculateFee(\n params.triggerPrice,\n amount,\n tradeSimulationState.feeParameter,\n );\n\n const marginBalance =\n userAccountExposure.getUsdNodeMarginInfo.marginBalance;\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const accountLMR =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement;\n const accountIMR = accountLMR * imrMultiplier;\n\n const limitOrderLMR =\n Math.sqrt(riskMatrixElement) * Math.abs(snappedAmount);\n const limitOrderIMR = limitOrderLMR * imrMultiplier;\n\n const requiredMargin = accountIMR + limitOrderIMR;\n\n const liquidationMarginRequirement =\n userAccountExposure.getUsdNodeMarginInfo.liquidationMarginRequirement +\n limitOrderLMR;\n\n const marginRatio = ExposureCommand.getMarginRatio({\n marginBalance,\n liquidationMarginRequirement,\n });\n\n const marginRatioHealth = ExposureCommand.evaluateHealthStatus(\n marginRatio * 100,\n );\n\n const xpEarnRangeMin = Math.round(\n Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,\n );\n const xpEarnRangeMax = Math.round(\n (100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,\n );\n\n return {\n fees,\n snappedAmount,\n snappedAmountInBase,\n estimatedPrice: params.triggerPrice,\n marginRatio: marginRatio * 100,\n marginRatioHealth,\n availableMargin,\n marginBalance,\n requiredMargin,\n xpEarnRange: {\n min: xpEarnRangeMin,\n max: xpEarnRangeMax,\n },\n };\n }\n\n getMaxAmountForLimitOrder(\n params: LimitTradeMaxOrderSizeParams,\n ): LimitTradeMaxOrderSizeResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { userAccountExposure, tradeSimulationState } = this.loadedData;\n\n const riskMatrixElement = this.getRiskMatrixElement();\n\n const imrMultiplier = amountNormalizer(\n String(userAccountExposure.riskMultipliers.im_multiplier),\n ).toNumber();\n\n const availableMargin =\n userAccountExposure.getUsdNodeMarginInfo.initialDelta;\n\n const maxAmountSize = Math.max(\n (availableMargin / Math.sqrt(riskMatrixElement) / imrMultiplier) * 0.97, // @todo implement dynamic buffer\n 0,\n );\n const maxAmountBase = maxAmountSize / params.triggerPrice;\n\n const minAmountBase = amountNormalizer(\n tradeSimulationState.marketConfiguration.minimum_order_base,\n ).toNumber();\n\n const minAmountSize = minAmountBase * params.triggerPrice;\n\n return {\n maxAmountBase,\n maxAmountSize,\n minAmountBase,\n minAmountSize,\n };\n }\n\n convertValue(\n params: TradeSimulationConvertValueParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n if (!params.fromBase)\n return BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n else\n return BigNumber(params.amount)\n .times(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n }\n\n convertValueEstimatedPrice(\n params: TradeSimulationConvertValueEstimatedPriceParams,\n ): TradeSimulationConvertValueResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const amountForSlippage = params.fromBase\n ? params.amount\n : BigNumber(params.amount)\n .div(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n )\n .toNumber();\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(amountForSlippage).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n if (!params.fromBase)\n return BigNumber(params.amount).div(estimatedPrice).toNumber();\n else return BigNumber(params.amount).times(estimatedPrice).toNumber();\n }\n\n customLeverage(): number | null {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n return tradeSimulationState.customLeverage;\n }\n\n estimatedPrice(params: EstimatedPriceParams): EstimatedPriceResult {\n if (!this.loadedData) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState, passivePoolExposure } = this.loadedData;\n\n const slippage = passivePoolExposure.getSlippage(\n BigNumber(params.amount).negated().toNumber(),\n tradeSimulationState.marketConfiguration,\n tradeSimulationState.marketStorage,\n );\n\n const price =\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ];\n\n const estimatedPrice = ExposureCommand.calculateEstimatedPrice(\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n tradeSimulationState.marketConfiguration.market_id\n ],\n slippage,\n );\n\n return {\n estimatedPrice,\n markPrice: price,\n };\n }\n\n roundToBaseSpacing(amount: number, baseSpacing: number): number {\n const snappedAmount = BigNumber(amount)\n .abs()\n .dividedBy(baseSpacing)\n .integerValue(BigNumber.ROUND_FLOOR)\n .multipliedBy(baseSpacing)\n .toNumber();\n\n if (amount < 0) {\n return -snappedAmount;\n }\n return snappedAmount;\n }\n\n updatePrice(price: number): void {\n if (!this.loadedData || !this.marketId) {\n throw new Error('Data not loaded. Call arm() first.');\n }\n\n const { tradeSimulationState } = this.loadedData;\n\n // update price\n const marketId = this.marketId;\n tradeSimulationState.exposureDataPassivePool.oraclePricePerMarket[\n marketId\n ] = price;\n tradeSimulationState.exposureDataAccount.oraclePricePerMarket[marketId] =\n price;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';\n\nexport type TradeSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type TradeSimulationSimulateParams = {\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type TradeSimulationConvertValueParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type EstimatedPriceParams = {\n amount: number; // amount in base\n};\n\nexport type EstimatedPriceResult = {\n estimatedPrice: number;\n markPrice: number;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceResult = number;\n\nexport type SimulateTradeEntity = {\n liquidationPrice: number;\n fees: number;\n estimatedPrice: number;\n estimatedSlippage: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n xpEarnRange?: {\n min: number;\n max: number;\n };\n maxSlippage: number;\n};\n\nexport type TradeSimulationSimulateLimitParams = {\n triggerPrice: number;\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type SimulateLimitTradeEntity = {\n fees: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n estimatedPrice: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n};\n\nexport type LimitTradeMaxOrderSizeParams = {\n triggerPrice: number;\n};\n\nexport type LimitTradeMaxOrderSizeResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n minAmountBase: number;\n minAmountSize: number;\n};\n\nexport type TradeSimulationConvertValueResult = number;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"","sourcesContent":["import { MarginAccountEntity, MarketEntity } from '@reyaxyz/common';\n\nexport type TradeSimulationLoadDataParams = {\n marketId: MarketEntity['id'];\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport type TradeSimulationSimulateParams = {\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type TradeSimulationConvertValueParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type EstimatedPriceParams = {\n amount: number; // amount in base\n};\n\nexport type EstimatedPriceResult = {\n estimatedPrice: number;\n markPrice: number;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceParams = {\n amount: number;\n fromBase: boolean;\n};\n\nexport type TradeSimulationConvertValueEstimatedPriceResult = number;\n\nexport type SimulateTradeEntity = {\n liquidationPrice: number;\n fees: number;\n estimatedPrice: number;\n estimatedSlippage: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n xpEarnRange?: {\n min: number;\n max: number;\n };\n maxSlippage: number;\n};\n\nexport type TradeSimulationSimulateLimitParams = {\n triggerPrice: number;\n amount: number; // position size / base, + for long | - for short\n fromBase?: boolean;\n};\n\nexport type SimulateLimitTradeEntity = {\n fees: number;\n snappedAmount: number;\n snappedAmountInBase: number;\n estimatedPrice: number;\n marginRatio: MarginAccountEntity['marginRatioPercentage'];\n marginRatioHealth: MarginAccountEntity['marginRatioHealth'];\n availableMargin: number;\n marginBalance: number;\n requiredMargin: number;\n xpEarnRange: {\n min: number;\n max: number;\n };\n};\n\nexport type LimitTradeMaxOrderSizeParams = {\n triggerPrice: number;\n};\n\nexport type LimitTradeMaxOrderSizeResult = {\n maxAmountBase: number;\n maxAmountSize: number;\n minAmountBase: number;\n minAmountSize: number;\n};\n\nexport type TradeSimulationConvertValueResult = number;\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { RestClient, ReyaChainId } from '@reyaxyz/common';
|
|
2
|
-
import { AlreadyGaveTradePermissionParams, AlreadyGaveTradePermissionResult, CancelConditionalOrderParams, CancelConditionalOrderResult, GetConditionalOrdersHistoryForMarginAccountParams, GetConditionalOrdersHistoryForMarginAccountResult, RegisterConditionalOrderParams, RegisterConditionalOrderResult, UpdateConditionalOrderParams, UpdateConditionalOrderResult, AlreadyGaveTradePermissionToWalletParams, AlreadyGaveTradePermissionToWalletResult } from './types';
|
|
2
|
+
import { AlreadyGaveTradePermissionParams, AlreadyGaveTradePermissionResult, CancelConditionalOrderParams, CancelConditionalOrderResult, GetConditionalOrdersHistoryForMarginAccountParams, GetConditionalOrdersHistoryForMarginAccountResult, GetConditionalOrdersHistoryForWalletAddressParams, RegisterConditionalOrderParams, RegisterConditionalOrderResult, UpdateConditionalOrderParams, UpdateConditionalOrderResult, AlreadyGaveTradePermissionToWalletParams, AlreadyGaveTradePermissionToWalletResult } from './types';
|
|
3
3
|
export default class ConditionalOrdersClient extends RestClient {
|
|
4
4
|
private reyaChainId;
|
|
5
5
|
constructor(reyaChainId: ReyaChainId, host: string);
|
|
6
6
|
getConditionalOrdersHistoryForMarginAccount(params: GetConditionalOrdersHistoryForMarginAccountParams): Promise<GetConditionalOrdersHistoryForMarginAccountResult>;
|
|
7
|
+
getConditionalOrdersHistoryForWalletAddress(params: GetConditionalOrdersHistoryForWalletAddressParams): Promise<GetConditionalOrdersHistoryForMarginAccountResult>;
|
|
7
8
|
alreadyGaveTradePermissions(params: AlreadyGaveTradePermissionParams): Promise<AlreadyGaveTradePermissionResult>;
|
|
8
9
|
alreadyGaveTradePermissionToWallet(params: AlreadyGaveTradePermissionToWalletParams): Promise<AlreadyGaveTradePermissionToWalletResult>;
|
|
9
10
|
cancelConditionalOrder(params: CancelConditionalOrderParams): Promise<CancelConditionalOrderResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/conditional-orders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,WAAW,EAOZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,iDAAiD,EACjD,iDAAiD,EACjD,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,EAC5B,wCAAwC,EACxC,wCAAwC,EACzC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,OAAO,CAAC,WAAW,CAAc;gBAErB,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAM5C,2CAA2C,CAC/C,MAAM,EAAE,iDAAiD,GACxD,OAAO,CAAC,iDAAiD,CAAC;IAOvD,2BAA2B,CAC/B,MAAM,EAAE,gCAAgC,GACvC,OAAO,CAAC,gCAAgC,CAAC;IAStC,kCAAkC,CACtC,MAAM,EAAE,wCAAwC,GAC/C,OAAO,CAAC,wCAAwC,CAAC;IAS9C,sBAAsB,CAC1B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IAkBlC,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAsCpC,sBAAsB,CAC1B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,4BAA4B,CAAC;YAuC1B,WAAW;YAQX,2BAA2B;CAkF1C"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/conditional-orders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,WAAW,EAOZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,iDAAiD,EACjD,iDAAiD,EACjD,iDAAiD,EACjD,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,EAC5B,wCAAwC,EACxC,wCAAwC,EACzC,MAAM,SAAS,CAAC;AAGjB,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,OAAO,CAAC,WAAW,CAAc;gBAErB,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;IAM5C,2CAA2C,CAC/C,MAAM,EAAE,iDAAiD,GACxD,OAAO,CAAC,iDAAiD,CAAC;IAOvD,2CAA2C,CAC/C,MAAM,EAAE,iDAAiD,GACxD,OAAO,CAAC,iDAAiD,CAAC;IAOvD,2BAA2B,CAC/B,MAAM,EAAE,gCAAgC,GACvC,OAAO,CAAC,gCAAgC,CAAC;IAStC,kCAAkC,CACtC,MAAM,EAAE,wCAAwC,GAC/C,OAAO,CAAC,wCAAwC,CAAC;IAS9C,sBAAsB,CAC1B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IAkBlC,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAsCpC,sBAAsB,CAC1B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,4BAA4B,CAAC;YAuC1B,WAAW;YAQX,2BAA2B;CAkF1C"}
|
|
@@ -53,5 +53,9 @@ export type GetConditionalOrdersHistoryForMarginAccountParams = {
|
|
|
53
53
|
marginAccountId: MarginAccountEntity['id'];
|
|
54
54
|
limit?: number;
|
|
55
55
|
};
|
|
56
|
+
export type GetConditionalOrdersHistoryForWalletAddressParams = {
|
|
57
|
+
walletAddress: string;
|
|
58
|
+
limit?: number;
|
|
59
|
+
};
|
|
56
60
|
export type GetConditionalOrdersHistoryForMarginAccountResult = UnifiedConditionalOrderType[];
|
|
57
61
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/conditional-orders/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,gBAAgB,CAAC;AAE5D,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC;IACpD,sBAAsB,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,wBAAwB,CAAC,CAAC;IAC5E,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,eAAe,EAAE,mB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EAAE,MAAM,GAAG,MAAM;IAc/D,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAejC"}
|
|
@@ -56,6 +56,10 @@ export type SimulateLimitTradeEntity = {
|
|
|
56
56
|
availableMargin: number;
|
|
57
57
|
marginBalance: number;
|
|
58
58
|
requiredMargin: number;
|
|
59
|
+
xpEarnRange: {
|
|
60
|
+
min: number;
|
|
61
|
+
max: number;
|
|
62
|
+
};
|
|
59
63
|
};
|
|
60
64
|
export type LimitTradeMaxOrderSizeParams = {
|
|
61
65
|
triggerPrice: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/trade.simulation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+CAA+C,GAAG;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+CAA+C,GAAG,MAAM,CAAC;AAErE,MAAM,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AAM,kCAAkC,GAAG;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,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;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ws": "^8.16.0"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "17023b9a8c8cfba44cecf10591acdb713e93877d",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "8.5.10"
|
|
48
48
|
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
CancelConditionalOrderResult,
|
|
20
20
|
GetConditionalOrdersHistoryForMarginAccountParams,
|
|
21
21
|
GetConditionalOrdersHistoryForMarginAccountResult,
|
|
22
|
+
GetConditionalOrdersHistoryForWalletAddressParams,
|
|
22
23
|
RegisterConditionalOrderParams,
|
|
23
24
|
RegisterConditionalOrderResult,
|
|
24
25
|
UpdateConditionalOrderParams,
|
|
@@ -46,6 +47,15 @@ export default class ConditionalOrdersClient extends RestClient {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
async getConditionalOrdersHistoryForWalletAddress(
|
|
51
|
+
params: GetConditionalOrdersHistoryForWalletAddressParams,
|
|
52
|
+
): Promise<GetConditionalOrdersHistoryForMarginAccountResult> {
|
|
53
|
+
const uri = `/api/conditional-orders/get-orders-by-wallet/${params.walletAddress}`;
|
|
54
|
+
return this.get<GetConditionalOrdersHistoryForMarginAccountResult>(uri, {
|
|
55
|
+
limit: params.limit,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
49
59
|
async alreadyGaveTradePermissions(
|
|
50
60
|
params: AlreadyGaveTradePermissionParams,
|
|
51
61
|
): Promise<AlreadyGaveTradePermissionResult> {
|
|
@@ -71,5 +71,10 @@ export type GetConditionalOrdersHistoryForMarginAccountParams = {
|
|
|
71
71
|
limit?: number;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
export type GetConditionalOrdersHistoryForWalletAddressParams = {
|
|
75
|
+
walletAddress: string;
|
|
76
|
+
limit?: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
74
79
|
export type GetConditionalOrdersHistoryForMarginAccountResult =
|
|
75
80
|
UnifiedConditionalOrderType[];
|
|
@@ -336,6 +336,13 @@ export default class TradeSimulationClient {
|
|
|
336
336
|
marginRatio * 100,
|
|
337
337
|
);
|
|
338
338
|
|
|
339
|
+
const xpEarnRangeMin = Math.round(
|
|
340
|
+
Math.abs(snappedAmount) / INSTANT_TRADING_RATE_XP,
|
|
341
|
+
);
|
|
342
|
+
const xpEarnRangeMax = Math.round(
|
|
343
|
+
(100 * Math.abs(snappedAmount)) / INSTANT_TRADING_RATE_XP,
|
|
344
|
+
);
|
|
345
|
+
|
|
339
346
|
return {
|
|
340
347
|
fees,
|
|
341
348
|
snappedAmount,
|
|
@@ -346,6 +353,10 @@ export default class TradeSimulationClient {
|
|
|
346
353
|
availableMargin,
|
|
347
354
|
marginBalance,
|
|
348
355
|
requiredMargin,
|
|
356
|
+
xpEarnRange: {
|
|
357
|
+
min: xpEarnRangeMin,
|
|
358
|
+
max: xpEarnRangeMax,
|
|
359
|
+
},
|
|
349
360
|
};
|
|
350
361
|
}
|
|
351
362
|
|