@reyaxyz/sdk 0.88.1 → 0.89.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.
@@ -91,6 +91,8 @@ var isolatedOrder = function (params) { return __awaiter(void 0, void 0, void 0,
91
91
  return [2 /*return*/, {
92
92
  transactionHash: (matchOrderResult === null || matchOrderResult === void 0 ? void 0 : matchOrderResult.transactionHash) || null,
93
93
  xpBoost: matchOrderResult.xpBoost,
94
+ // TODO: costin please fix implementation
95
+ isNftWon: Math.random() < 0.5,
94
96
  }];
95
97
  }
96
98
  });
@@ -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,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;oBAClC,IAAI,EAAE,wBAAwB;iBAC/B,CAAC,EAAA;;gBAJI,mBAAmB,GAAG,SAI1B;gBAEF,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;gBAC5E,CAAC;sBAIgD,EAA5B,KAAA,MAAM,CAAC,qBAAqB;;;qBAA5B,CAAA,cAA4B,CAAA;gBAAtC,MAAM;gBACf,6FAA6F;gBAC7F,qBAAM,IAAA,+CAA6B,EAAC;wBAClC,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;wBAC/C,iBAAiB,EAAE,mBAAmB,CAAC,SAAS;wBAChD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC;wBACxC,YAAY,EAAE,MAAM,CAAC,iBAAiB;qBACvC,CAAC,EAAA;;gBARF,6FAA6F;gBAC7F,SAOE,CAAC;;;gBATgB,IAA4B,CAAA;;;gBAkB3C,oBAAoB,GAGtB;oBACF,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC;oBAC3C,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;iBAC9B,CAAC;gBAGuB,qBAAM,IAAA,mBAAU,EAAC;wBACxC,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,KAAK,EAAE,oBAAoB;wBAC3B,eAAe,EAAE,mBAAmB,CAAC,SAAS;wBAC9C,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;wBAC/C,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,OAAO,EAAE,gBAAgB,CAAC,OAAO;qBAClC,EAAC;;;KACH,CAAC;AA5DW,QAAA,aAAa,iBA4DxB","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 signer: params.signer,\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 snappedAmountInBase: params.snappedAmountInBase,\n market: params.market,\n });\n\n return {\n transactionHash: matchOrderResult?.transactionHash || null,\n xpBoost: matchOrderResult.xpBoost,\n };\n};\n"]}
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,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;oBAClC,IAAI,EAAE,wBAAwB;iBAC/B,CAAC,EAAA;;gBAJI,mBAAmB,GAAG,SAI1B;gBAEF,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;gBAC5E,CAAC;sBAIgD,EAA5B,KAAA,MAAM,CAAC,qBAAqB;;;qBAA5B,CAAA,cAA4B,CAAA;gBAAtC,MAAM;gBACf,6FAA6F;gBAC7F,qBAAM,IAAA,+CAA6B,EAAC;wBAClC,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;wBACnB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;wBAC/C,iBAAiB,EAAE,mBAAmB,CAAC,SAAS;wBAChD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC;wBACxC,YAAY,EAAE,MAAM,CAAC,iBAAiB;qBACvC,CAAC,EAAA;;gBARF,6FAA6F;gBAC7F,SAOE,CAAC;;;gBATgB,IAA4B,CAAA;;;gBAkB3C,oBAAoB,GAGtB;oBACF,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC;oBAC3C,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;iBAC9B,CAAC;gBAGuB,qBAAM,IAAA,mBAAU,EAAC;wBACxC,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,KAAK,EAAE,oBAAoB;wBAC3B,eAAe,EAAE,mBAAmB,CAAC,SAAS;wBAC9C,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;wBAC/C,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,OAAO,EAAE,gBAAgB,CAAC,OAAO;wBACjC,yCAAyC;wBACzC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG;qBAC9B,EAAC;;;KACH,CAAC;AA9DW,QAAA,aAAa,iBA8DxB","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 signer: params.signer,\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 snappedAmountInBase: params.snappedAmountInBase,\n market: params.market,\n });\n\n return {\n transactionHash: matchOrderResult?.transactionHash || null,\n xpBoost: matchOrderResult.xpBoost,\n // TODO: costin please fix implementation\n isNftWon: Math.random() < 0.5,\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 snappedAmountInBase: number; // todo: p2: use type from simulation in api-sdk via common dep\n market: MarketParams;\n};\n\nexport type IsolatedOrderResult = {\n transactionHash: string | null;\n xpBoost: 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 snappedAmountInBase: number; // todo: p2: use type from simulation in api-sdk via common dep\n market: MarketParams;\n};\n\nexport type IsolatedOrderResult = {\n transactionHash: string | null;\n xpBoost: number;\n isNftWon: boolean;\n};\n"]}
@@ -67,6 +67,7 @@ var matchOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
67
67
  return [4 /*yield*/, (0, signAndBroadcastTransaction_1.signAndBroadcastTransaction)(params.signer, data, value, chainId, common_2.ContractType.PERIPHERY_PROXY, {
68
68
  action: 'matchOrder',
69
69
  accountId: params.marginAccountId,
70
+ marketId: params.market.id,
70
71
  })];
71
72
  case 3:
72
73
  result = _d.sent();
@@ -97,14 +98,17 @@ var closeOrder = function (params) { return __awaiter(void 0, void 0, void 0, fu
97
98
  case 2:
98
99
  _a = _d.sent(), data = _a.calldata, value = _a.value;
99
100
  return [4 /*yield*/, (0, signAndBroadcastTransaction_1.signAndBroadcastTransaction)(params.signer, data, value, chainId, common_2.ContractType.PERIPHERY_PROXY, {
100
- accountId: params.marginAccountId,
101
101
  action: 'closeOrder',
102
+ accountId: params.marginAccountId,
103
+ marketId: params.market.id,
102
104
  })];
103
105
  case 3:
104
106
  result = _d.sent();
105
107
  return [2 /*return*/, {
106
108
  transactionHash: (result === null || result === void 0 ? void 0 : result.txHash) || null,
107
109
  xpBoost: ((_c = result.miscellaneous) === null || _c === void 0 ? void 0 : _c.tradeXpBoost) || 0,
110
+ // TODO: Costin please fix implementation
111
+ isNftWon: Math.random() < 0.5,
108
112
  }];
109
113
  }
110
114
  });
@@ -1 +1 @@
1
- {"version":3,"file":"order.js","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,mCAA4C;AAC5C,8EAA6E;AAC7E,0CAA8D;AAC9D,8DAAqC;AACrC,0CAA+C;AAC/C,0CAAwC;AAEjC,IAAM,UAAU,GAAG,UACxB,MAAwB;;;;;;gBAExB,IAAI,MAAM,CAAC,mBAAmB,KAAK,CAAC,EAAE,CAAC;oBACrC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAChD,CAAC;gBACK,eAAe,GAAG,IAAA,oCAA2B,EACjD,MAAM,CAAC,MAAM,CAAC,YAAY,EAC1B,MAAM,CAAC,mBAAmB,CAC3B,CAAC;gBAEI,SAAS,GAAG,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBACxC,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAEP,qBAAM,IAAA,yBAAgB,EACtD,MAAM,CAAC,MAAM,EACb,OAAO,EACP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G,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;gBAEP,qBAAM,IAAA,yBAAgB,EACtD,MAAM,CAAC,MAAM,EACb,OAAO,EACP,MAAM,CAAC,KAAK,CAAC,YAAY,EACzB,MAAM,CAAC,eAAe,EACtB,CAAC,IAAI,EACL,eAAe,EACf,MAAM,CAAC,MAAM,CAAC,sBAAsB,EACpC,MAAM,CAAC,MAAM,CAAC,EAAE,EAChB,MAAM,CAAC,MAAM,CAAC,UAAU,CACzB,EAAA;;gBAVK,KAA4B,SAUjC,EAViB,IAAI,cAAA,EAAE,KAAK,WAAA;gBAYd,qBAAM,IAAA,yDAA2B,EAC9C,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,OAAO,EACP,qBAAY,CAAC,eAAe,EAC5B;wBACE,SAAS,EAAE,MAAM,CAAC,eAAe;wBACjC,MAAM,EAAE,YAAY;qBACrB,CACF,EAAA;;gBAVK,MAAM,GAAG,SAUd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,IAAI;wBACvC,OAAO,EAAE,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,YAAY,KAAI,CAAC;qBACjD,EAAC;;;KACH,CAAC;AA5CW,QAAA,UAAU,cA4CrB","sourcesContent":["import {\n CloseOrderParams,\n CloseOrderResult,\n MatchOrderParams,\n MatchOrderResult,\n} from './types';\nimport { encodeMatchOrder } from './encode';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { calculatePriceLimitForTrade } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { ContractType } from '@reyaxyz/common';\nimport { scale } from '@reyaxyz/common';\n\nexport const matchOrder = async (\n params: MatchOrderParams,\n): Promise<MatchOrderResult> => {\n if (params.snappedAmountInBase === 0) {\n throw new Error('Position base can not be 0');\n }\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n params.snappedAmountInBase,\n );\n\n const orderBase = scale(18)(params.snappedAmountInBase);\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\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 },\n );\n\n return {\n transactionHash: result?.txHash || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 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 network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\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 accountId: params.marginAccountId,\n action: 'closeOrder',\n },\n );\n\n return {\n transactionHash: result?.txHash || null,\n xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n };\n};\n"]}
1
+ {"version":3,"file":"order.js","sourceRoot":"/","sources":["services/orders/order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,mCAA4C;AAC5C,8EAA6E;AAC7E,0CAA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J,KAAK,EACL,OAAO,EACP,qBAAY,CAAC,eAAe,EAC5B;wBACE,MAAM,EAAE,YAAY;wBACpB,SAAS,EAAE,MAAM,CAAC,eAAe;wBACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;qBAC3B,CACF,EAAA;;gBAXK,MAAM,GAAG,SAWd;gBAED,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,IAAI;wBACvC,OAAO,EAAE,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,YAAY,KAAI,CAAC;wBAChD,yCAAyC;wBACzC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG;qBAC9B,EAAC;;;KACH,CAAC;AA/CW,QAAA,UAAU,cA+CrB","sourcesContent":["import {\n CloseOrderParams,\n CloseOrderResult,\n MatchOrderParams,\n MatchOrderResult,\n} from './types';\nimport { encodeMatchOrder } from './encode';\nimport { signAndBroadcastTransaction } from '../signAndBroadcastTransaction';\nimport { calculatePriceLimitForTrade } from '@reyaxyz/common';\nimport BigNumber from 'bignumber.js';\nimport { ContractType } from '@reyaxyz/common';\nimport { scale } from '@reyaxyz/common';\n\nexport const matchOrder = async (\n params: MatchOrderParams,\n): Promise<MatchOrderResult> => {\n if (params.snappedAmountInBase === 0) {\n throw new Error('Position base can not be 0');\n }\n const orderPriceLimit = calculatePriceLimitForTrade(\n params.market.currentPrice,\n params.snappedAmountInBase,\n );\n\n const orderBase = scale(18)(params.snappedAmountInBase);\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\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 xpBoost: result.miscellaneous?.tradeXpBoost || 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 network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\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 xpBoost: result.miscellaneous?.tradeXpBoost || 0,\n // TODO: Costin please fix implementation\n isNftWon: Math.random() < 0.5,\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};\n\nexport type MatchOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n // TODO: make type of this SimulateTradeEntity['snappedAmountInBase']\n snappedAmountInBase: number;\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 xpBoost: number;\n};\n\nexport type CloseOrderResult = {\n transactionHash: string | null;\n xpBoost: 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};\n\nexport type MatchOrderParams = {\n signer: Signer | JsonRpcSigner;\n owner: Pick<OwnerMetadataEntity, 'coreSigNonce'>;\n marginAccountId: MarginAccountEntity['id'];\n // TODO: make type of this SimulateTradeEntity['snappedAmountInBase']\n snappedAmountInBase: number;\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 xpBoost: number;\n};\n\nexport type CloseOrderResult = {\n transactionHash: string | null;\n xpBoost: number;\n isNftWon: boolean;\n};\n"]}
@@ -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,CA0D7B,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,CA4D7B,CAAC"}
@@ -12,5 +12,6 @@ export type IsolatedOrderParams = {
12
12
  export type IsolatedOrderResult = {
13
13
  transactionHash: string | null;
14
14
  xpBoost: number;
15
+ isNftWon: boolean;
15
16
  };
16
17
  //# 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,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;IAC7D,mBAAmB,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;IAC9C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
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,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;IAC7D,mBAAmB,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,qBAAqB,EAAE,oBAAoB,EAAE,CAAC;IAC9C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,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;AAQjB,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CAyC1B,CAAC;AAEF,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CA0C1B,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;AAQjB,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CA0C1B,CAAC;AAEF,eAAO,MAAM,UAAU,WACb,gBAAgB,KACvB,QAAQ,gBAAgB,CA6C1B,CAAC"}
@@ -27,5 +27,6 @@ export type MatchOrderResult = {
27
27
  export type CloseOrderResult = {
28
28
  transactionHash: string | null;
29
29
  xpBoost: number;
30
+ isNftWon: boolean;
30
31
  };
31
32
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["services/orders/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,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,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IACjD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE3C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IACjD,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,SAAS,EAAE,cAAc,CAAC,MAAM,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IAC3C,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/sdk",
3
- "version": "0.88.1",
3
+ "version": "0.89.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "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.103.0",
32
+ "@reyaxyz/common": "0.104.0",
33
33
  "bignumber.js": "^9.1.2",
34
34
  "ethers": "6.9.0"
35
35
  },
36
36
  "packageManager": "pnpm@8.3.1",
37
- "gitHead": "da55f3d5ea1ea5bd1903927db6e6baba1adcbcc8"
37
+ "gitHead": "8d33152588bfff636ba1d7904935005d13db709c"
38
38
  }
@@ -65,5 +65,7 @@ export const isolatedOrder = async (
65
65
  return {
66
66
  transactionHash: matchOrderResult?.transactionHash || null,
67
67
  xpBoost: matchOrderResult.xpBoost,
68
+ // TODO: costin please fix implementation
69
+ isNftWon: Math.random() < 0.5,
68
70
  };
69
71
  };
@@ -18,4 +18,5 @@ export type IsolatedOrderParams = {
18
18
  export type IsolatedOrderResult = {
19
19
  transactionHash: string | null;
20
20
  xpBoost: number;
21
+ isNftWon: boolean;
21
22
  };
@@ -47,6 +47,7 @@ export const matchOrder = async (
47
47
  {
48
48
  action: 'matchOrder',
49
49
  accountId: params.marginAccountId,
50
+ marketId: params.market.id,
50
51
  },
51
52
  );
52
53
 
@@ -91,13 +92,16 @@ export const closeOrder = async (
91
92
  chainId,
92
93
  ContractType.PERIPHERY_PROXY,
93
94
  {
94
- accountId: params.marginAccountId,
95
95
  action: 'closeOrder',
96
+ accountId: params.marginAccountId,
97
+ marketId: params.market.id,
96
98
  },
97
99
  );
98
100
 
99
101
  return {
100
102
  transactionHash: result?.txHash || null,
101
103
  xpBoost: result.miscellaneous?.tradeXpBoost || 0,
104
+ // TODO: Costin please fix implementation
105
+ isNftWon: Math.random() < 0.5,
102
106
  };
103
107
  };
@@ -38,4 +38,5 @@ export type MatchOrderResult = {
38
38
  export type CloseOrderResult = {
39
39
  transactionHash: string | null;
40
40
  xpBoost: number;
41
+ isNftWon: boolean;
41
42
  };