@reyaxyz/sdk 0.106.2 → 0.106.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,5 +6,5 @@
6
6
 
7
7
  | Statements | Branches | Functions | Lines |
8
8
  | --------------------------- | ----------------------- | ------------------------- | ----------------- |
9
- | ![Statements](https://img.shields.io/badge/statements-11.13%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-5.93%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-6.25%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-10.57%25-red.svg?style=flat) |
9
+ | ![Statements](https://img.shields.io/badge/statements-11.13%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-5.55%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-6.25%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-10.57%25-red.svg?style=flat) |
10
10
 
@@ -128,7 +128,7 @@ var ApiInteractionsModule = /** @class */ (function (_super) {
128
128
  signerWallet: signerWallet,
129
129
  nonce: nonce,
130
130
  signature: signature,
131
- status: common_1.StopLossOrderStatus.NEW,
131
+ status: common_1.StopLossOrderStatus.PENDING,
132
132
  })];
133
133
  });
134
134
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CASyB;AAYzB;IAAuC,qCAAU;IAAjD;;IAwCA,CAAC;IAvCO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;gBAEhC,GAAG,GAAG,uCAAuC,CAAC;gBACpD,uFAAuF;gBACvF,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,MAAM,EAAE,MAAM;wBACd,eAAe,iBAAA;wBACf,QAAQ,UAAA;q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C;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEK,IAAM,yBAAyB,GAAG;IACvC,IAAI,CAAC,gBAAgB;QACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC;AAEK,IAAM,wBAAwB,GAAG;IACtC,IAAI,CAAC,qBAAqB;QACxB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC","sourcesContent":["import {\n Address,\n API_CLIENT_CONFIGS,\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n StopLossOrderStatus,\n StopLossOrder,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\ntype AlphaTermsData = {\n walletAddress: Address;\n link: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ) {\n const uri = `/api/transaction-gelato/executeGelato`;\n // const uri = `/api/transaction/execute`; //switch between Gelato and internal relayer\n return this.post<TransactionExecutionOutput>(\n uri,\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class AlphaTermsModule extends RestClient {\n async registerAlphaSignature(params: AlphaTermsData): Promise<void> {\n // Build formData object.\n const formData = new FormData();\n formData.append('walletAddress', params.walletAddress);\n formData.append('signedLink', params.link);\n\n const uri = '/api/tos/alpha-signatures';\n return this.post(uri, undefined, formData, undefined);\n }\n}\n\nexport class ApiInteractionsModule extends RestClient {\n async createSLOrder(\n accountId: number,\n marketId: number,\n isLong: boolean,\n stopPrice: number,\n signerWallet: string,\n nonce: number,\n signature: string,\n ) {\n const uri = `/api/conditional-orders/sl/create-order`;\n return this.post<StopLossOrder>(\n uri,\n {},\n {\n accountId: accountId,\n marketId: marketId,\n isLong: isLong,\n stopPrice: stopPrice,\n signerWallet: signerWallet,\n nonce: nonce,\n signature: signature,\n status: StopLossOrderStatus.NEW,\n },\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet apiInteractionsModule: ApiInteractionsModule = new ApiInteractionsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\n\nlet sdkEnv: ServiceConfig['environment'] = 'test';\n\nexport const getSdkEnvironment = (): ServiceConfig['environment'] => {\n return sdkEnv;\n};\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n const config = API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n sdkEnv = environment;\n transactionModule = new TransactionModule(config.apiEndpoint);\n alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);\n apiInteractionsModule = new ApiInteractionsModule(config.apiEndpoint);\n};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n\nexport const getAlphaTermsModuleClient = (): AlphaTermsModule => {\n if (!alphaTermsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return alphaTermsModule;\n};\n\nexport const getApiInteractionsModule = (): ApiInteractionsModule => {\n if (!apiInteractionsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return apiInteractionsModule;\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CASyB;AAYzB;IAAuC,qCAAU;IAAjD;;IAwCA,CAAC;IAvCO,8CAAkB,GAAxB,UACE,MAAc,EACd,eAAuB,EACvB,QAAsC;;;;gBAEhC,GAAG,GAAG,uCAAuC,CAAC;gBACpD,uFAAuF;gBACvF,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,MAAM,EAAE,MAAM;wBACd,eAAe,iBAAA;wBACf,QAAQ,UAAA;qBACT,CACF,EAAC;;;KACH;IAEK,kDAAsB,GAA5B,UACE,eAAuB,EACvB,eAAuB,EACvB,aAAqB,EACrB,MAAc,EACd,OAAe,EACf,IAAY;;;;gBAEN,GAAG,GAAG,wBAAiB,eAAe,8BAA2B,CAAC;gBACxE,sBAAO,IAAI,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF;wBACE,OAAO,EAAE,eAAe;wBACxB,eAAe,EAAE,aAAa;wBAC9B,MAAM,QAAA;wBACN,QAAQ,EAAE,OAAO;wBACjB,IAAI,EAAE,IAAI;qBACX,CACF,EAAC;;;KACH;IACH,wBAAC;AAAD,CAAC,AAxCD,CAAuC,mBAAU,GAwChD;AAxCY,8CAAiB;AA0C9B;IAAsC,oCAAU;IAAhD;;IAUA,CAAC;IATO,iDAAsB,GAA5B,UAA6B,MAAsB;;;;gBAE3C,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAChC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;gBACvD,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAErC,GAAG,GAAG,2BAA2B,CAAC;gBACxC,sBAAO,IAAI,CA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,2BAAkB,CAAC,WAAW,CAAC,IAAI,2BAAkB,CAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,GAAG,WAAW,CAAC;IACrB,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9D,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC5D,qBAAqB,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEK,IAAM,0BAA0B,GAAG;IACxC,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEK,IAAM,yBAAyB,GAAG;IACvC,IAAI,CAAC,gBAAgB;QACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC;AAEK,IAAM,wBAAwB,GAAG;IACtC,IAAI,CAAC,qBAAqB;QACxB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC","sourcesContent":["import {\n Address,\n API_CLIENT_CONFIGS,\n RestClient,\n ServiceConfig,\n TransactionExecutionMetadata,\n TransactionExecutionOutput,\n StopLossOrderStatus,\n StopLossOrder,\n} from '@reyaxyz/common';\n\nexport type TxData = {\n to: string;\n data: string;\n};\n\ntype AlphaTermsData = {\n walletAddress: Address;\n link: string;\n};\n\nexport class TransactionModule extends RestClient {\n async executeTransaction(\n txData: TxData,\n contractAddress: string,\n metadata: TransactionExecutionMetadata,\n ) {\n const uri = `/api/transaction-gelato/executeGelato`;\n // const uri = `/api/transaction/execute`; //switch between Gelato and internal relayer\n return this.post<TransactionExecutionOutput>(\n uri,\n {},\n {\n txData: txData,\n contractAddress,\n metadata,\n },\n );\n }\n\n async pushPendingTransaction(\n marginAccountId: number,\n transactionHash: string,\n sourceChainId: number,\n amount: number,\n assetId: string,\n type: string,\n ) {\n const uri = `/api/accounts/${marginAccountId}/push-pending-transaction`;\n return this.post<{ successful: boolean }>(\n uri,\n {},\n {\n tx_hash: transactionHash,\n source_chain_id: sourceChainId,\n amount,\n asset_id: assetId,\n type: type,\n },\n );\n }\n}\n\nexport class AlphaTermsModule extends RestClient {\n async registerAlphaSignature(params: AlphaTermsData): Promise<void> {\n // Build formData object.\n const formData = new FormData();\n formData.append('walletAddress', params.walletAddress);\n formData.append('signedLink', params.link);\n\n const uri = '/api/tos/alpha-signatures';\n return this.post(uri, undefined, formData, undefined);\n }\n}\n\nexport class ApiInteractionsModule extends RestClient {\n async createSLOrder(\n accountId: number,\n marketId: number,\n isLong: boolean,\n stopPrice: number,\n signerWallet: string,\n nonce: string,\n signature: string,\n ) {\n const uri = `/api/conditional-orders/sl/create-order`;\n return this.post<StopLossOrder>(\n uri,\n {},\n {\n accountId: accountId,\n marketId: marketId,\n isLong: isLong,\n stopPrice: stopPrice,\n signerWallet: signerWallet,\n nonce: nonce,\n signature: signature,\n status: StopLossOrderStatus.PENDING,\n },\n );\n }\n}\n\n// Internal state\nlet transactionModule: TransactionModule = new TransactionModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet alphaTermsModule: AlphaTermsModule = new AlphaTermsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\nlet apiInteractionsModule: ApiInteractionsModule = new ApiInteractionsModule(\n API_CLIENT_CONFIGS['test'].apiEndpoint,\n);\n\nlet sdkEnv: ServiceConfig['environment'] = 'test';\n\nexport const getSdkEnvironment = (): ServiceConfig['environment'] => {\n return sdkEnv;\n};\n// Function to configure the SDK\nexport const configureSDK = (\n environment: ServiceConfig['environment'],\n): void => {\n const config = API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n sdkEnv = environment;\n transactionModule = new TransactionModule(config.apiEndpoint);\n alphaTermsModule = new AlphaTermsModule(config.apiEndpoint);\n apiInteractionsModule = new ApiInteractionsModule(config.apiEndpoint);\n};\n\nexport const getTransactionModuleClient = (): TransactionModule => {\n if (!transactionModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return transactionModule;\n};\n\nexport const getAlphaTermsModuleClient = (): AlphaTermsModule => {\n if (!alphaTermsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return alphaTermsModule;\n};\n\nexport const getApiInteractionsModule = (): ApiInteractionsModule => {\n if (!apiInteractionsModule)\n throw new Error('SDK is not configured! Call configureSDK()');\n return apiInteractionsModule;\n};\n"]}
@@ -94,6 +94,8 @@ var isolatedOrder = function (params) { return __awaiter(void 0, void 0, void 0,
94
94
  isNftWon: matchOrderResult.isNftWon,
95
95
  marginAccountId: createAccountResult.accountId,
96
96
  xpEarned: matchOrderResult.xpEarned,
97
+ executionPrice: matchOrderResult.executionPrice,
98
+ base: matchOrderResult.base,
97
99
  }];
98
100
  }
99
101
  });
@@ -1 +1 @@
1
- {"version":3,"file":"isolatedOrder.js","sourceRoot":"/","sources":["services/isolated-order/isolatedOrder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAG4B;AAC5B,oCAAuC;AAGhC,IAAM,aAAa,GAAG,UAC3B,MAA2B;;;;oBAQC,qBAAM,IAAA,+BAAa,EAAC;oBAC9C,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;oBAClC,IAAI,EAAE,wBAAwB;iBAC/B,CAAC,EAAA;;gBAHI,mBAAmB,GAAG,SAG1B;gBAEF,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;gBAC5E,CAAC;sBAIgD,EA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,QAAA,aAAa,iBA+DxB","sourcesContent":["import { IsolatedOrderParams, IsolatedOrderResult } from './types';\nimport {\n createAccount,\n transferMarginBetweenAccounts,\n} from '../margin-accounts';\nimport { matchOrder } from '../orders';\nimport { OwnerMetadataEntity } from '@reyaxyz/common';\n\nexport const isolatedOrder = async (\n params: IsolatedOrderParams,\n): Promise<IsolatedOrderResult> => {\n // todo: p2 consider performing all steps in api and only call one api function from here?\n\n // step 1: create new account\n\n // todo: p2: consider having a function that creates an account and auto-generates a name in one go, use it t&cs also\n // todo: p2: error handling & logging\n const createAccountResult = await createAccount({\n ownerAddress: params.owner.address,\n name: 'Isolated Trade Account',\n });\n\n if (!createAccountResult.accountId) {\n throw new Error('New Account Id not available to execute isolated trade');\n }\n\n // step 2: transfer margin from source to destination account\n\n for (const action of params.editCollateralActions) {\n // todo: p1: pack transfers into a single tx with multiple transfer commands (core sig issue)\n await transferMarginBetweenAccounts({\n signer: params.signer,\n owner: params.owner,\n fromMarginAccountId: params.fromMarginAccountId,\n toMarginAccountId: createAccountResult.accountId,\n amount: Math.abs(action.collateralDelta),\n tokenAddress: action.collateralAddress,\n });\n }\n\n // step 3: execute trade\n\n /*\n * We need to bump the nonce since we've just executed a transfer transaction\n * */\n\n const ownerWithBumpedNonce: Pick<\n OwnerMetadataEntity,\n 'coreSigNonce' | 'address'\n > = {\n coreSigNonce: params.owner.coreSigNonce + 1,\n address: params.owner.address,\n };\n\n // todo: p1: need to increase the nonce for this tx as well\n const matchOrderResult = await matchOrder({\n signer: params.signer,\n owner: ownerWithBumpedNonce,\n marginAccountId: createAccountResult.accountId,\n amountInBase: params.amountInBase,\n market: params.market,\n });\n\n return {\n transactionHash: matchOrderResult?.transactionHash || null,\n coreSigNonce: matchOrderResult.coreSigNonce,\n xpBoost: matchOrderResult.xpBoost,\n isNftWon: matchOrderResult.isNftWon,\n marginAccountId: createAccountResult.accountId,\n xpEarned: matchOrderResult.xpEarned,\n };\n};\n"]}
1
+ {"version":3,"file":"isolated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AS;wBAC9C,YAAY,EAAE,MAAM,CAAC,YAAY;wBACjC,MAAM,EAAE,MAAM,CAAC,MAAM;qBACtB,CAAC,EAAA;;gBANI,gBAAgB,GAAG,SAMvB;gBAEF,sBAAO;wBACL,eAAe,EAAE,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,eAAe,KAAI,IAAI;wBAC1D,YAAY,EAAE,gBAAgB,CAAC,YAAY;wBAC3C,OAAO,EAAE,gBAAgB,CAAC,OAAO;wBACjC,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;wBACnC,eAAe,EAAE,mBAAmB,CAAC,SAAS;wBAC9C,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;wBACnC,cAAc,EAAE,gBAAgB,CAAC,cAAc;wBAC/C,IAAI,EAAE,gBAAgB,CAAC,IAAI;qBAC5B,EAAC;;;KACH,CAAC;AAjEW,QAAA,aAAa,iBAiExB","sourcesContent":["import { IsolatedOrderParams, IsolatedOrderResult } from './types';\nimport {\n createAccount,\n transferMarginBetweenAccounts,\n} from '../margin-accounts';\nimport { matchOrder } from '../orders';\nimport { OwnerMetadataEntity } from '@reyaxyz/common';\n\nexport const isolatedOrder = async (\n params: IsolatedOrderParams,\n): Promise<IsolatedOrderResult> => {\n // todo: p2 consider performing all steps in api and only call one api function from here?\n\n // step 1: create new account\n\n // todo: p2: consider having a function that creates an account and auto-generates a name in one go, use it t&cs also\n // todo: p2: error handling & logging\n const createAccountResult = await createAccount({\n ownerAddress: params.owner.address,\n name: 'Isolated Trade Account',\n });\n\n if (!createAccountResult.accountId) {\n throw new Error('New Account Id not available to execute isolated trade');\n }\n\n // step 2: transfer margin from source to destination account\n\n for (const action of params.editCollateralActions) {\n // todo: p1: pack transfers into a single tx with multiple transfer commands (core sig issue)\n await transferMarginBetweenAccounts({\n signer: params.signer,\n owner: params.owner,\n fromMarginAccountId: params.fromMarginAccountId,\n toMarginAccountId: createAccountResult.accountId,\n amount: Math.abs(action.collateralDelta),\n tokenAddress: action.collateralAddress,\n });\n }\n\n // step 3: execute trade\n\n /*\n * We need to bump the nonce since we've just executed a transfer transaction\n * */\n\n const ownerWithBumpedNonce: Pick<\n OwnerMetadataEntity,\n 'coreSigNonce' | 'address'\n > = {\n coreSigNonce: params.owner.coreSigNonce + 1,\n address: params.owner.address,\n };\n\n // todo: p1: need to increase the nonce for this tx as well\n const matchOrderResult = await matchOrder({\n signer: params.signer,\n owner: ownerWithBumpedNonce,\n marginAccountId: createAccountResult.accountId,\n amountInBase: params.amountInBase,\n market: params.market,\n });\n\n return {\n transactionHash: matchOrderResult?.transactionHash || null,\n coreSigNonce: matchOrderResult.coreSigNonce,\n xpBoost: matchOrderResult.xpBoost,\n isNftWon: matchOrderResult.isNftWon,\n marginAccountId: createAccountResult.accountId,\n xpEarned: matchOrderResult.xpEarned,\n executionPrice: matchOrderResult.executionPrice,\n base: matchOrderResult.base,\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/isolated-order/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer, JsonRpcSigner } from 'ethers';\nimport {\n EditCollateralAction,\n MarginAccountEntity,\n OwnerMetadataEntity,\n} from '@reyaxyz/common';\nimport { MarketParams } from '../orders';\n\nexport type IsolatedOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce' | 'address'>;\n fromMarginAccountId: MarginAccountEntity['id'];\n editCollateralActions: EditCollateralAction[]; // todo: p2: consider abstracting this such that UI doesn't pass this\n amountInBase: number;\n market: MarketParams;\n};\n\nexport type IsolatedOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/isolated-order/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer, JsonRpcSigner } from 'ethers';\nimport {\n EditCollateralAction,\n MarginAccountEntity,\n OwnerMetadataEntity,\n} from '@reyaxyz/common';\nimport { MarketParams } from '../orders';\n\nexport type IsolatedOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce' | 'address'>;\n fromMarginAccountId: MarginAccountEntity['id'];\n editCollateralActions: EditCollateralAction[]; // todo: p2: consider abstracting this such that UI doesn't pass this\n amountInBase: number;\n market: MarketParams;\n};\n\nexport type IsolatedOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n executionPrice: number;\n base: number;\n};\n"]}
@@ -49,9 +49,9 @@ var common_3 = require("@reyaxyz/common");
49
49
  var config_1 = require("../../config");
50
50
  var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, function () {
51
51
  var snappedAmount, orderPriceLimit, orderBase, env, chainId, _a, data, value, result;
52
- var _b, _c, _d;
53
- return __generator(this, function (_e) {
54
- switch (_e.label) {
52
+ var _b, _c, _d, _e, _f;
53
+ return __generator(this, function (_g) {
54
+ switch (_g.label) {
55
55
  case 0:
56
56
  if (params.amountInBase === 0) {
57
57
  throw new Error('Position base can not be 0');
@@ -75,14 +75,14 @@ var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
75
75
  chainId = (0, common_1.getReyaNetwork)(env === 'production' ? 'production' : 'test');
76
76
  return [4 /*yield*/, (0, encode_1.encodeMatchOrder)(params.signer, chainId, params.owner.coreSigNonce, params.marginAccountId, orderBase, orderPriceLimit, params.market.counterpartyAccountIds, params.market.id, params.market.exchangeId)];
77
77
  case 1:
78
- _a = _e.sent(), data = _a.calldata, value = _a.value;
78
+ _a = _g.sent(), data = _a.calldata, value = _a.value;
79
79
  return [4 /*yield*/, (0, signAndBroadcastTransaction_1.signAndBroadcastTransaction)(params.signer, data, value, chainId, common_2.ContractType.PERIPHERY_PROXY, {
80
80
  action: 'matchOrder',
81
81
  accountId: params.marginAccountId,
82
82
  marketId: params.market.id,
83
83
  })];
84
84
  case 2:
85
- result = _e.sent();
85
+ result = _g.sent();
86
86
  return [2 /*return*/, {
87
87
  transactionHash: (result === null || result === void 0 ? void 0 : result.txHash) || null,
88
88
  coreSigNonce: Number(result === null || result === void 0 ? void 0 : result.coreSigNonce) || null,
@@ -90,6 +90,8 @@ var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
90
90
  isNftWon: ((_c = result.miscellaneous) === null || _c === void 0 ? void 0 : _c.xpNftAwarded) || false,
91
91
  marginAccountId: params.marginAccountId,
92
92
  xpEarned: ((_d = result.miscellaneous) === null || _d === void 0 ? void 0 : _d.xpEarned) || 0,
93
+ executionPrice: ((_e = result.tradeDetails) === null || _e === void 0 ? void 0 : _e.executionPrice) || 0,
94
+ base: ((_f = result.tradeDetails) === null || _f === void 0 ? void 0 : _f.base) || 0,
93
95
  }];
94
96
  }
95
97
  });
@@ -97,9 +99,9 @@ var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
97
99
  exports.matchOrder = matchOrder;
98
100
  var closeOrder = function (params) { return __awaiter(void 0, void 0, void 0, function () {
99
101
  var base, orderPriceLimit, env, chainId, _a, data, value, result;
100
- var _b, _c, _d;
101
- return __generator(this, function (_e) {
102
- switch (_e.label) {
102
+ var _b, _c, _d, _e, _f;
103
+ return __generator(this, function (_g) {
104
+ switch (_g.label) {
103
105
  case 0:
104
106
  if (params.orderBase === 0) {
105
107
  throw new Error('Position base can not be 0');
@@ -110,14 +112,14 @@ var closeOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
110
112
  chainId = (0, common_1.getReyaNetwork)(env === 'production' ? 'production' : 'test');
111
113
  return [4 /*yield*/, (0, encode_1.encodeMatchOrder)(params.signer, chainId, params.owner.coreSigNonce, params.marginAccountId, -base, orderPriceLimit, params.market.counterpartyAccountIds, params.market.id, params.market.exchangeId)];
112
114
  case 1:
113
- _a = _e.sent(), data = _a.calldata, value = _a.value;
115
+ _a = _g.sent(), data = _a.calldata, value = _a.value;
114
116
  return [4 /*yield*/, (0, signAndBroadcastTransaction_1.signAndBroadcastTransaction)(params.signer, data, value, chainId, common_2.ContractType.PERIPHERY_PROXY, {
115
117
  action: 'closeOrder',
116
118
  accountId: params.marginAccountId,
117
119
  marketId: params.market.id,
118
120
  })];
119
121
  case 2:
120
- result = _e.sent();
122
+ result = _g.sent();
121
123
  return [2 /*return*/, {
122
124
  transactionHash: (result === null || result === void 0 ? void 0 : result.txHash) || null,
123
125
  coreSigNonce: Number(result === null || result === void 0 ? void 0 : result.coreSigNonce) || null,
@@ -125,6 +127,8 @@ var closeOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
125
127
  isNftWon: ((_c = result.miscellaneous) === null || _c === void 0 ? void 0 : _c.xpNftAwarded) || false,
126
128
  marginAccountId: params.marginAccountId,
127
129
  xpEarned: ((_d = result.miscellaneous) === null || _d === void 0 ? void 0 : _d.xpEarned) || 0,
130
+ executionPrice: ((_e = result.tradeDetails) === null || _e === void 0 ? void 0 : _e.executionPrice) || 0,
131
+ base: ((_f = result.tradeDetails) === null || _f === void 0 ? void 0 : _f.base) || 0,
128
132
  }];
129
133
  }
130
134
  });
@@ -1 +1 @@
1
- {"version":3,"file":"order.js","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,mCAA4C;AAC5C,8EAA6E;AAC7E,0CAA8E;AAC9E,8DAAqC;AACrC,0CAA+C;AAC/C,0CAAwC;AACxC,uCAAiD;AAE1C,IAAM,UAAU,GAAG,UACxB,MAAwB;;;;;;gBAExB,IAAI,MAAM,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;oBAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAChD,CAAC;gBAEG,aAAa,GAAG,IAAA,sBAAS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AAA,MAAA,MAAM,CAAC,aAAa,0CAAE,QAAQ,KAAI,CAAC;qBAC9C,EAAC;;;KACH,CAAC;AAhDW,QAAA,UAAU,cAgDrB","sourcesContent":["import {\n CloseOrderParams,\n CloseOrderResult,\n MatchOrderParams,\n MatchOrderResult,\n} from './types';\nimport { encodeMatchOrder } from './encode';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { calculatePriceLimitForTrade, getReyaNetwork } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { ContractType } from '@reyaxyz/common';\nimport { scale } from '@reyaxyz/common';\nimport { getSdkEnvironment } from '../../config';\n\nexport const matchOrder = async (\n params: MatchOrderParams,\n): Promise<MatchOrderResult> => {\n if (params.amountInBase === 0) {\n throw new Error('Position base can not be 0');\n }\n\n let snappedAmount = BigNumber(params.amountInBase)\n .abs()\n .dividedBy(params.market.baseSpacing)\n .integerValue(BigNumber.ROUND_FLOOR)\n .multipliedBy(params.market.baseSpacing)\n .toNumber();\n\n if (params.amountInBase < 0) {\n snappedAmount = -snappedAmount;\n }\n\n if (Math.abs(snappedAmount) < params.market.minOrderSizeBase) {\n console.error(\n `Minimum trade amount ${params.market.minOrderSizeBase}. Entered amount ${snappedAmount}, ${params.amountInBase}`,\n );\n throw new Error(`Minimum trade amount ${params.market.minOrderSizeBase}`);\n }\n\n // add rounding here\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n snappedAmount,\n );\n\n const orderBase = scale(18)(snappedAmount);\n const env = getSdkEnvironment();\n const chainId = getReyaNetwork(env === 'production' ? 'production' : 'test');\n\n const { calldata: data, value } = await encodeMatchOrder(\n params.signer,\n chainId,\n params.owner.coreSigNonce,\n params.marginAccountId,\n orderBase,\n orderPriceLimit,\n params.market.counterpartyAccountIds,\n params.market.id,\n params.market.exchangeId,\n );\n\n const result = await signAndBroadcastTransaction(\n params.signer,\n data,\n value,\n chainId,\n ContractType.PERIPHERY_PROXY,\n {\n action: 'matchOrder',\n accountId: params.marginAccountId,\n marketId: params.market.id,\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n isNftWon: result.miscellaneous?.xpNftAwarded || false,\n marginAccountId: params.marginAccountId,\n xpEarned: result.miscellaneous?.xpEarned || 0,\n };\n};\n\nexport const closeOrder = async (\n params: CloseOrderParams,\n): Promise<CloseOrderResult> => {\n if (params.orderBase === 0) {\n throw new Error('Position base can not be 0');\n }\n\n const base = scale(18)(params.orderBase);\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n BigNumber(params.orderBase).negated().toNumber(), // used just because of sign\n );\n\n const env = getSdkEnvironment();\n const chainId = getReyaNetwork(env === 'production' ? 'production' : 'test');\n const { calldata: data, value } = await encodeMatchOrder(\n params.signer,\n chainId,\n params.owner.coreSigNonce,\n params.marginAccountId,\n -base,\n orderPriceLimit,\n params.market.counterpartyAccountIds,\n params.market.id,\n params.market.exchangeId,\n );\n\n const result = await signAndBroadcastTransaction(\n params.signer,\n data,\n value,\n chainId,\n ContractType.PERIPHERY_PROXY,\n {\n action: 'closeOrder',\n accountId: params.marginAccountId,\n marketId: params.market.id,\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n isNftWon: result.miscellaneous?.xpNftAwarded || false,\n marginAccountId: params.marginAccountId,\n xpEarned: result.miscellaneous?.xpEarned || 0,\n };\n};\n"]}
1
+ {"version":3,"file":"order.js","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,mCAA4C;AAC5C,8EAA6E;AAC7E,0CAA8E;AAC9E,8DAAqC;AACrC,0CAA+C;AAC/C,0CAAwC;AACxC,uCAAiD;AAE1C,IAAM,UAAU,GAAG,UACxB,MAAwB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I,IAAI;wBACvC,YAAY,EAAE,MAAM,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,IAAI,IAAI;wBAClD,OAAO,EAAE,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,YAAY,KAAI,CAAC;wBAChD,QAAQ,EAAE,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,YAAY,KAAI,KAAK;wBACrD,eAAe,EAAE,MAAM,CAAC,eAAe;wBACvC,QAAQ,EAAE,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,QAAQ,KAAI,CAAC;wBAC7C,cAAc,EAAE,CAAA,MAAA,MAAM,CAAC,YAAY,0CAAE,cAAc,KAAI,CAAC;wBACxD,IAAI,EAAE,CAAA,MAAA,MAAM,CAAC,YAAY,0CAAE,IAAI,KAAI,CAAC;qBACrC,EAAC;;;KACH,CAAC;AAlDW,QAAA,UAAU,cAkDrB","sourcesContent":["import {\n CloseOrderParams,\n CloseOrderResult,\n MatchOrderParams,\n MatchOrderResult,\n} from './types';\nimport { encodeMatchOrder } from './encode';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { calculatePriceLimitForTrade, getReyaNetwork } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { ContractType } from '@reyaxyz/common';\nimport { scale } from '@reyaxyz/common';\nimport { getSdkEnvironment } from '../../config';\n\nexport const matchOrder = async (\n params: MatchOrderParams,\n): Promise<MatchOrderResult> => {\n if (params.amountInBase === 0) {\n throw new Error('Position base can not be 0');\n }\n\n let snappedAmount = BigNumber(params.amountInBase)\n .abs()\n .dividedBy(params.market.baseSpacing)\n .integerValue(BigNumber.ROUND_FLOOR)\n .multipliedBy(params.market.baseSpacing)\n .toNumber();\n\n if (params.amountInBase < 0) {\n snappedAmount = -snappedAmount;\n }\n\n if (Math.abs(snappedAmount) < params.market.minOrderSizeBase) {\n console.error(\n `Minimum trade amount ${params.market.minOrderSizeBase}. Entered amount ${snappedAmount}, ${params.amountInBase}`,\n );\n throw new Error(`Minimum trade amount ${params.market.minOrderSizeBase}`);\n }\n\n // add rounding here\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n snappedAmount,\n );\n\n const orderBase = scale(18)(snappedAmount);\n const env = getSdkEnvironment();\n const chainId = getReyaNetwork(env === 'production' ? 'production' : 'test');\n\n const { calldata: data, value } = await encodeMatchOrder(\n params.signer,\n chainId,\n params.owner.coreSigNonce,\n params.marginAccountId,\n orderBase,\n orderPriceLimit,\n params.market.counterpartyAccountIds,\n params.market.id,\n params.market.exchangeId,\n );\n\n const result = await signAndBroadcastTransaction(\n params.signer,\n data,\n value,\n chainId,\n ContractType.PERIPHERY_PROXY,\n {\n action: 'matchOrder',\n accountId: params.marginAccountId,\n marketId: params.market.id,\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n isNftWon: result.miscellaneous?.xpNftAwarded || false,\n marginAccountId: params.marginAccountId,\n xpEarned: result.miscellaneous?.xpEarned || 0,\n executionPrice: result.tradeDetails?.executionPrice || 0,\n base: result.tradeDetails?.base || 0,\n };\n};\n\nexport const closeOrder = async (\n params: CloseOrderParams,\n): Promise<CloseOrderResult> => {\n if (params.orderBase === 0) {\n throw new Error('Position base can not be 0');\n }\n\n const base = scale(18)(params.orderBase);\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n BigNumber(params.orderBase).negated().toNumber(), // used just because of sign\n );\n\n const env = getSdkEnvironment();\n const chainId = getReyaNetwork(env === 'production' ? 'production' : 'test');\n const { calldata: data, value } = await encodeMatchOrder(\n params.signer,\n chainId,\n params.owner.coreSigNonce,\n params.marginAccountId,\n -base,\n orderPriceLimit,\n params.market.counterpartyAccountIds,\n params.market.id,\n params.market.exchangeId,\n );\n\n const result = await signAndBroadcastTransaction(\n params.signer,\n data,\n value,\n chainId,\n ContractType.PERIPHERY_PROXY,\n {\n action: 'closeOrder',\n accountId: params.marginAccountId,\n marketId: params.market.id,\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n coreSigNonce: Number(result?.coreSigNonce) || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n isNftWon: result.miscellaneous?.xpNftAwarded || false,\n marginAccountId: params.marginAccountId,\n xpEarned: result.miscellaneous?.xpEarned || 0,\n executionPrice: result.tradeDetails?.executionPrice || 0,\n base: result.tradeDetails?.base || 0,\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/orders/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer, JsonRpcSigner } from 'ethers';\nimport {\n MarginAccountEntity,\n MarketEntity,\n OwnerMetadataEntity,\n PositionEntity,\n} from '@reyaxyz/common';\n\nexport type MarketParams = {\n id: MarketEntity['id'];\n exchangeId: MarketEntity['orderInfo']['exchangeId'];\n counterpartyAccountIds: MarketEntity['orderInfo']['counterpartyAccountIds'];\n currentPrice: number;\n minOrderSizeBase: MarketEntity['minOrderSizeBase'];\n baseSpacing: MarketEntity['baseSpacing'];\n};\n\nexport type MatchOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n amountInBase: number; // amount in base\n market: MarketParams;\n};\n\nexport type CloseOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n orderBase: PositionEntity['base'];\n market: MarketParams;\n};\n\nexport type MatchOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n};\n\nexport type CloseOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["services/orders/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer, JsonRpcSigner } from 'ethers';\nimport {\n MarginAccountEntity,\n MarketEntity,\n OwnerMetadataEntity,\n PositionEntity,\n} from '@reyaxyz/common';\n\nexport type MarketParams = {\n id: MarketEntity['id'];\n exchangeId: MarketEntity['orderInfo']['exchangeId'];\n counterpartyAccountIds: MarketEntity['orderInfo']['counterpartyAccountIds'];\n currentPrice: number;\n minOrderSizeBase: MarketEntity['minOrderSizeBase'];\n baseSpacing: MarketEntity['baseSpacing'];\n};\n\nexport type MatchOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n amountInBase: number; // amount in base\n market: MarketParams;\n};\n\nexport type CloseOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n orderBase: PositionEntity['base'];\n market: MarketParams;\n};\n\nexport type MatchOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n executionPrice: number;\n base: number;\n};\n\nexport type CloseOrderResult = {\n transactionHash: string | null;\n coreSigNonce: OwnerMetadataEntity['coreSigNonce'] | null;\n xpBoost: number;\n isNftWon: boolean;\n marginAccountId: MarginAccountEntity['id'];\n xpEarned: number;\n executionPrice: number;\n base: number;\n};\n"]}
@@ -17,7 +17,7 @@ export declare class AlphaTermsModule extends RestClient {
17
17
  registerAlphaSignature(params: AlphaTermsData): Promise<void>;
18
18
  }
19
19
  export declare class ApiInteractionsModule extends RestClient {
20
- createSLOrder(accountId: number, marketId: number, isLong: boolean, stopPrice: number, signerWallet: string, nonce: number, signature: string): Promise<StopLossOrder>;
20
+ createSLOrder(accountId: number, marketId: number, isLong: boolean, stopPrice: number, signerWallet: string, nonce: string, signature: string): Promise<StopLossOrder>;
21
21
  }
22
22
  export declare const getSdkEnvironment: () => ServiceConfig['environment'];
23
23
  export declare const configureSDK: (environment: ServiceConfig['environment']) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"isolatedOrder.d.ts","sourceRoot":"/","sources":["services/isolated-order/isolatedOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnE,eAAO,MAAM,aAAa,WAChB,mBAAmB,KAC1B,QAAQ,mBAAmB,CA6D7B,CAAC"}
1
+ {"version":3,"file":"isolatedOrder.d.ts","sourceRoot":"/","sources":["services/isolated-order/isolatedOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnE,eAAO,MAAM,aAAa,WAChB,mBAAmB,KAC1B,QAAQ,mBAAmB,CA+D7B,CAAC"}
@@ -16,5 +16,7 @@ export type IsolatedOrderResult = {
16
16
  isNftWon: boolean;
17
17
  marginAccountId: MarginAccountEntity['id'];
18
18
  xpEarned: number;
19
+ executionPrice: number;
20
+ base: number;
19
21
  };
20
22
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/isolated-order/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,KAAK,EAAE,IA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IAAI,CAAC;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"order.d.ts","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AASjB,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CAkE1B,CAAC;AAEF,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CA8C1B,CAAC"}
1
+ {"version":3,"file":"order.d.ts","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AASjB,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CAoE1B,CAAC;AAEF,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CAgD1B,CAAC"}
@@ -29,6 +29,8 @@ export type MatchOrderResult = {
29
29
  isNftWon: boolean;
30
30
  marginAccountId: MarginAccountEntity['id'];
31
31
  xpEarned: number;
32
+ executionPrice: number;
33
+ base: number;
32
34
  };
33
35
  export type CloseOrderResult = {
34
36
  transactionHash: string | null;
@@ -37,5 +39,7 @@ export type CloseOrderResult = {
37
39
  isNftWon: boolean;
38
40
  marginAccountId: MarginAccountEntity['id'];
39
41
  xpEarned: number;
42
+ executionPrice: number;
43
+ base: number;
40
44
  };
41
45
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":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"https://registry.npmjs.org"
@@ -29,10 +29,10 @@
29
29
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
30
30
  },
31
31
  "dependencies": {
32
- "@reyaxyz/common": "0.155.1",
32
+ "@reyaxyz/common": "0.155.3",
33
33
  "bignumber.js": "^9.1.2",
34
34
  "ethers": "6.9.0"
35
35
  },
36
36
  "packageManager": "pnpm@8.3.1",
37
- "gitHead": "e2d795903d65a29bf2d214b0224c2ec10fda767a"
37
+ "gitHead": "d588a7b45d04c349ac09d10aff233fbc15c0833e"
38
38
  }
@@ -80,7 +80,7 @@ export class ApiInteractionsModule extends RestClient {
80
80
  isLong: boolean,
81
81
  stopPrice: number,
82
82
  signerWallet: string,
83
- nonce: number,
83
+ nonce: string,
84
84
  signature: string,
85
85
  ) {
86
86
  const uri = `/api/conditional-orders/sl/create-order`;
@@ -95,7 +95,7 @@ export class ApiInteractionsModule extends RestClient {
95
95
  signerWallet: signerWallet,
96
96
  nonce: nonce,
97
97
  signature: signature,
98
- status: StopLossOrderStatus.NEW,
98
+ status: StopLossOrderStatus.PENDING,
99
99
  },
100
100
  );
101
101
  }
@@ -68,5 +68,7 @@ export const isolatedOrder = async (
68
68
  isNftWon: matchOrderResult.isNftWon,
69
69
  marginAccountId: createAccountResult.accountId,
70
70
  xpEarned: matchOrderResult.xpEarned,
71
+ executionPrice: matchOrderResult.executionPrice,
72
+ base: matchOrderResult.base,
71
73
  };
72
74
  };
@@ -22,4 +22,6 @@ export type IsolatedOrderResult = {
22
22
  isNftWon: boolean;
23
23
  marginAccountId: MarginAccountEntity['id'];
24
24
  xpEarned: number;
25
+ executionPrice: number;
26
+ base: number;
25
27
  };
@@ -79,6 +79,8 @@ export const matchOrder = async (
79
79
  isNftWon: result.miscellaneous?.xpNftAwarded || false,
80
80
  marginAccountId: params.marginAccountId,
81
81
  xpEarned: result.miscellaneous?.xpEarned || 0,
82
+ executionPrice: result.tradeDetails?.executionPrice || 0,
83
+ base: result.tradeDetails?.base || 0,
82
84
  };
83
85
  };
84
86
 
@@ -129,5 +131,7 @@ export const closeOrder = async (
129
131
  isNftWon: result.miscellaneous?.xpNftAwarded || false,
130
132
  marginAccountId: params.marginAccountId,
131
133
  xpEarned: result.miscellaneous?.xpEarned || 0,
134
+ executionPrice: result.tradeDetails?.executionPrice || 0,
135
+ base: result.tradeDetails?.base || 0,
132
136
  };
133
137
  };
@@ -38,6 +38,8 @@ export type MatchOrderResult = {
38
38
  isNftWon: boolean;
39
39
  marginAccountId: MarginAccountEntity['id'];
40
40
  xpEarned: number;
41
+ executionPrice: number;
42
+ base: number;
41
43
  };
42
44
 
43
45
  export type CloseOrderResult = {
@@ -47,4 +49,6 @@ export type CloseOrderResult = {
47
49
  isNftWon: boolean;
48
50
  marginAccountId: MarginAccountEntity['id'];
49
51
  xpEarned: number;
52
+ executionPrice: number;
53
+ base: number;
50
54
  };