@drift-labs/sdk 2.115.0-beta.0 → 2.115.0-beta.10

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.
Files changed (436) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/constants/perpMarkets.js +2 -2
  3. package/lib/browser/dlob/DLOB.d.ts +3 -3
  4. package/lib/browser/dlob/DLOB.js +8 -5
  5. package/lib/browser/dlob/DLOBNode.d.ts +5 -5
  6. package/lib/browser/dlob/DLOBNode.js +12 -13
  7. package/lib/browser/dlob/DLOBSubscriber.d.ts +2 -1
  8. package/lib/browser/dlob/DLOBSubscriber.js +8 -2
  9. package/lib/browser/dlob/NodeList.d.ts +2 -2
  10. package/lib/browser/dlob/NodeList.js +2 -2
  11. package/lib/browser/dlob/types.d.ts +6 -1
  12. package/lib/browser/driftClient.d.ts +4 -4
  13. package/lib/browser/driftClient.js +23 -17
  14. package/lib/browser/idl/drift.json +16 -1
  15. package/lib/browser/math/orders.d.ts +3 -2
  16. package/lib/browser/math/orders.js +22 -10
  17. package/lib/browser/math/protectedMakerParams.d.ts +4 -0
  18. package/lib/browser/math/protectedMakerParams.js +32 -0
  19. package/lib/browser/openbook/openbookV2Subscriber.d.ts +2 -0
  20. package/lib/browser/openbook/openbookV2Subscriber.js +16 -6
  21. package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -2
  22. package/lib/browser/orderSubscriber/OrderSubscriber.js +4 -4
  23. package/lib/browser/phoenix/phoenixSubscriber.d.ts +2 -0
  24. package/lib/browser/phoenix/phoenixSubscriber.js +19 -10
  25. package/lib/browser/types.d.ts +8 -1
  26. package/lib/browser/userMap/userMap.d.ts +2 -2
  27. package/lib/browser/userMap/userMap.js +2 -2
  28. package/lib/node/accounts/basicUserAccountSubscriber.d.ts +1 -0
  29. package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -0
  30. package/lib/node/accounts/bulkAccountLoader.d.ts +1 -0
  31. package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -0
  32. package/lib/node/accounts/bulkUserStatsSubscription.d.ts +1 -0
  33. package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -0
  34. package/lib/node/accounts/bulkUserSubscription.d.ts +1 -0
  35. package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -0
  36. package/lib/node/accounts/fetch.d.ts +1 -0
  37. package/lib/node/accounts/fetch.d.ts.map +1 -0
  38. package/lib/node/accounts/grpcAccountSubscriber.d.ts +1 -0
  39. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -0
  40. package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +1 -0
  41. package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts.map +1 -0
  42. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +1 -0
  43. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
  44. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +1 -0
  45. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -0
  46. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +1 -0
  47. package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -0
  48. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +1 -0
  49. package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -0
  50. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +1 -0
  51. package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -0
  52. package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +1 -0
  53. package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts.map +1 -0
  54. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +1 -0
  55. package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts.map +1 -0
  56. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +1 -0
  57. package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
  58. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +1 -0
  59. package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -0
  60. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +1 -0
  61. package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -0
  62. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +1 -0
  63. package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -0
  64. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +1 -0
  65. package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -0
  66. package/lib/node/accounts/testBulkAccountLoader.d.ts +1 -0
  67. package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -0
  68. package/lib/node/accounts/types.d.ts +1 -0
  69. package/lib/node/accounts/types.d.ts.map +1 -0
  70. package/lib/node/accounts/utils.d.ts +1 -0
  71. package/lib/node/accounts/utils.d.ts.map +1 -0
  72. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +1 -0
  73. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -0
  74. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +1 -0
  75. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -0
  76. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +1 -0
  77. package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts.map +1 -0
  78. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +1 -0
  79. package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
  80. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +1 -0
  81. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -0
  82. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +1 -0
  83. package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -0
  84. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +1 -0
  85. package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -0
  86. package/lib/node/addresses/marketAddresses.d.ts +1 -0
  87. package/lib/node/addresses/marketAddresses.d.ts.map +1 -0
  88. package/lib/node/addresses/pda.d.ts +1 -0
  89. package/lib/node/addresses/pda.d.ts.map +1 -0
  90. package/lib/node/adminClient.d.ts +1 -0
  91. package/lib/node/adminClient.d.ts.map +1 -0
  92. package/lib/node/assert/assert.d.ts +1 -0
  93. package/lib/node/assert/assert.d.ts.map +1 -0
  94. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -0
  95. package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -0
  96. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -0
  97. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -0
  98. package/lib/node/auctionSubscriber/index.d.ts +1 -0
  99. package/lib/node/auctionSubscriber/index.d.ts.map +1 -0
  100. package/lib/node/auctionSubscriber/types.d.ts +1 -0
  101. package/lib/node/auctionSubscriber/types.d.ts.map +1 -0
  102. package/lib/node/bankrun/bankrunConnection.d.ts +1 -0
  103. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -0
  104. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -0
  105. package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -0
  106. package/lib/node/blockhashSubscriber/index.d.ts +1 -0
  107. package/lib/node/blockhashSubscriber/index.d.ts.map +1 -0
  108. package/lib/node/blockhashSubscriber/types.d.ts +1 -0
  109. package/lib/node/blockhashSubscriber/types.d.ts.map +1 -0
  110. package/lib/node/clock/clockSubscriber.d.ts +1 -0
  111. package/lib/node/clock/clockSubscriber.d.ts.map +1 -0
  112. package/lib/node/config.d.ts +1 -0
  113. package/lib/node/config.d.ts.map +1 -0
  114. package/lib/node/constants/numericConstants.d.ts +1 -0
  115. package/lib/node/constants/numericConstants.d.ts.map +1 -0
  116. package/lib/node/constants/perpMarkets.d.ts +1 -0
  117. package/lib/node/constants/perpMarkets.d.ts.map +1 -0
  118. package/lib/node/constants/perpMarkets.js +2 -2
  119. package/lib/node/constants/spotMarkets.d.ts +1 -0
  120. package/lib/node/constants/spotMarkets.d.ts.map +1 -0
  121. package/lib/node/constants/txConstants.d.ts +1 -0
  122. package/lib/node/constants/txConstants.d.ts.map +1 -0
  123. package/lib/node/decode/phoenix.d.ts +1 -0
  124. package/lib/node/decode/phoenix.d.ts.map +1 -0
  125. package/lib/node/decode/user.d.ts +1 -0
  126. package/lib/node/decode/user.d.ts.map +1 -0
  127. package/lib/node/dlob/DLOB.d.ts +4 -3
  128. package/lib/node/dlob/DLOB.d.ts.map +1 -0
  129. package/lib/node/dlob/DLOB.js +8 -5
  130. package/lib/node/dlob/DLOBNode.d.ts +6 -5
  131. package/lib/node/dlob/DLOBNode.d.ts.map +1 -0
  132. package/lib/node/dlob/DLOBNode.js +12 -13
  133. package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
  134. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -0
  135. package/lib/node/dlob/DLOBSubscriber.js +8 -2
  136. package/lib/node/dlob/NodeList.d.ts +3 -2
  137. package/lib/node/dlob/NodeList.d.ts.map +1 -0
  138. package/lib/node/dlob/NodeList.js +2 -2
  139. package/lib/node/dlob/orderBookLevels.d.ts +1 -0
  140. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -0
  141. package/lib/node/dlob/types.d.ts +7 -1
  142. package/lib/node/dlob/types.d.ts.map +1 -0
  143. package/lib/node/driftClient.d.ts +5 -4
  144. package/lib/node/driftClient.d.ts.map +1 -0
  145. package/lib/node/driftClient.js +23 -17
  146. package/lib/node/driftClientConfig.d.ts +1 -0
  147. package/lib/node/driftClientConfig.d.ts.map +1 -0
  148. package/lib/node/events/eventList.d.ts +1 -0
  149. package/lib/node/events/eventList.d.ts.map +1 -0
  150. package/lib/node/events/eventSubscriber.d.ts +1 -0
  151. package/lib/node/events/eventSubscriber.d.ts.map +1 -0
  152. package/lib/node/events/eventsServerLogProvider.d.ts +1 -0
  153. package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -0
  154. package/lib/node/events/fetchLogs.d.ts +1 -0
  155. package/lib/node/events/fetchLogs.d.ts.map +1 -0
  156. package/lib/node/events/parse.d.ts +1 -0
  157. package/lib/node/events/parse.d.ts.map +1 -0
  158. package/lib/node/events/pollingLogProvider.d.ts +1 -0
  159. package/lib/node/events/pollingLogProvider.d.ts.map +1 -0
  160. package/lib/node/events/sort.d.ts +1 -0
  161. package/lib/node/events/sort.d.ts.map +1 -0
  162. package/lib/node/events/txEventCache.d.ts +1 -0
  163. package/lib/node/events/txEventCache.d.ts.map +1 -0
  164. package/lib/node/events/types.d.ts +1 -0
  165. package/lib/node/events/types.d.ts.map +1 -0
  166. package/lib/node/events/webSocketLogProvider.d.ts +1 -0
  167. package/lib/node/events/webSocketLogProvider.d.ts.map +1 -0
  168. package/lib/node/factory/bigNum.d.ts +1 -0
  169. package/lib/node/factory/bigNum.d.ts.map +1 -0
  170. package/lib/node/factory/oracleClient.d.ts +1 -0
  171. package/lib/node/factory/oracleClient.d.ts.map +1 -0
  172. package/lib/node/fastlane/fastlaneOrderSubscriber.d.ts +1 -0
  173. package/lib/node/fastlane/fastlaneOrderSubscriber.d.ts.map +1 -0
  174. package/lib/node/fastlane/grpcSignedMsgUserAccountSubscriber.d.ts +1 -0
  175. package/lib/node/fastlane/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -0
  176. package/lib/node/fastlane/index.d.ts +1 -0
  177. package/lib/node/fastlane/index.d.ts.map +1 -0
  178. package/lib/node/fastlane/signedMsgUserAccountSubscriber.d.ts +1 -0
  179. package/lib/node/fastlane/signedMsgUserAccountSubscriber.d.ts.map +1 -0
  180. package/lib/node/idl/drift.json +16 -1
  181. package/lib/node/index.d.ts +1 -0
  182. package/lib/node/index.d.ts.map +1 -0
  183. package/lib/node/isomorphic/grpc.browser.d.ts.map +1 -0
  184. package/lib/node/isomorphic/grpc.d.ts +1 -0
  185. package/lib/node/isomorphic/grpc.d.ts.map +1 -0
  186. package/lib/node/isomorphic/grpc.node.d.ts +1 -0
  187. package/lib/node/isomorphic/grpc.node.d.ts.map +1 -0
  188. package/lib/node/jupiter/jupiterClient.d.ts +1 -0
  189. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -0
  190. package/lib/node/keypair.d.ts +1 -0
  191. package/lib/node/keypair.d.ts.map +1 -0
  192. package/lib/node/marinade/index.d.ts +1 -0
  193. package/lib/node/marinade/index.d.ts.map +1 -0
  194. package/lib/node/marinade/types.d.ts +1 -0
  195. package/lib/node/marinade/types.d.ts.map +1 -0
  196. package/lib/node/math/amm.d.ts +1 -0
  197. package/lib/node/math/amm.d.ts.map +1 -0
  198. package/lib/node/math/auction.d.ts +1 -0
  199. package/lib/node/math/auction.d.ts.map +1 -0
  200. package/lib/node/math/bankruptcy.d.ts +1 -0
  201. package/lib/node/math/bankruptcy.d.ts.map +1 -0
  202. package/lib/node/math/conversion.d.ts +1 -0
  203. package/lib/node/math/conversion.d.ts.map +1 -0
  204. package/lib/node/math/exchangeStatus.d.ts +1 -0
  205. package/lib/node/math/exchangeStatus.d.ts.map +1 -0
  206. package/lib/node/math/fuel.d.ts +1 -0
  207. package/lib/node/math/fuel.d.ts.map +1 -0
  208. package/lib/node/math/funding.d.ts +1 -0
  209. package/lib/node/math/funding.d.ts.map +1 -0
  210. package/lib/node/math/insurance.d.ts +1 -0
  211. package/lib/node/math/insurance.d.ts.map +1 -0
  212. package/lib/node/math/liquidation.d.ts +1 -0
  213. package/lib/node/math/liquidation.d.ts.map +1 -0
  214. package/lib/node/math/margin.d.ts +1 -0
  215. package/lib/node/math/margin.d.ts.map +1 -0
  216. package/lib/node/math/market.d.ts +1 -0
  217. package/lib/node/math/market.d.ts.map +1 -0
  218. package/lib/node/math/oracles.d.ts +1 -0
  219. package/lib/node/math/oracles.d.ts.map +1 -0
  220. package/lib/node/math/orders.d.ts +4 -2
  221. package/lib/node/math/orders.d.ts.map +1 -0
  222. package/lib/node/math/orders.js +22 -10
  223. package/lib/node/math/position.d.ts +1 -0
  224. package/lib/node/math/position.d.ts.map +1 -0
  225. package/lib/node/math/protectedMakerParams.d.ts +5 -0
  226. package/lib/node/math/protectedMakerParams.d.ts.map +1 -0
  227. package/lib/node/math/protectedMakerParams.js +32 -0
  228. package/lib/node/math/repeg.d.ts +1 -0
  229. package/lib/node/math/repeg.d.ts.map +1 -0
  230. package/lib/node/math/spotBalance.d.ts +1 -0
  231. package/lib/node/math/spotBalance.d.ts.map +1 -0
  232. package/lib/node/math/spotMarket.d.ts +1 -0
  233. package/lib/node/math/spotMarket.d.ts.map +1 -0
  234. package/lib/node/math/spotPosition.d.ts +1 -0
  235. package/lib/node/math/spotPosition.d.ts.map +1 -0
  236. package/lib/node/math/state.d.ts +1 -0
  237. package/lib/node/math/state.d.ts.map +1 -0
  238. package/lib/node/math/superStake.d.ts +1 -0
  239. package/lib/node/math/superStake.d.ts.map +1 -0
  240. package/lib/node/math/tiers.d.ts +1 -0
  241. package/lib/node/math/tiers.d.ts.map +1 -0
  242. package/lib/node/math/trade.d.ts +1 -0
  243. package/lib/node/math/trade.d.ts.map +1 -0
  244. package/lib/node/math/userStatus.d.ts +1 -0
  245. package/lib/node/math/userStatus.d.ts.map +1 -0
  246. package/lib/node/math/utils.d.ts +1 -0
  247. package/lib/node/math/utils.d.ts.map +1 -0
  248. package/lib/node/memcmp.d.ts +1 -0
  249. package/lib/node/memcmp.d.ts.map +1 -0
  250. package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts +1 -0
  251. package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts.map +1 -0
  252. package/lib/node/openbook/openbookV2Subscriber.d.ts +3 -0
  253. package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -0
  254. package/lib/node/openbook/openbookV2Subscriber.js +16 -6
  255. package/lib/node/oracles/oracleClientCache.d.ts +1 -0
  256. package/lib/node/oracles/oracleClientCache.d.ts.map +1 -0
  257. package/lib/node/oracles/oracleId.d.ts +1 -0
  258. package/lib/node/oracles/oracleId.d.ts.map +1 -0
  259. package/lib/node/oracles/prelaunchOracleClient.d.ts +1 -0
  260. package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -0
  261. package/lib/node/oracles/pythClient.d.ts +1 -0
  262. package/lib/node/oracles/pythClient.d.ts.map +1 -0
  263. package/lib/node/oracles/pythLazerClient.d.ts +1 -0
  264. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -0
  265. package/lib/node/oracles/pythPullClient.d.ts +1 -0
  266. package/lib/node/oracles/pythPullClient.d.ts.map +1 -0
  267. package/lib/node/oracles/quoteAssetOracleClient.d.ts +1 -0
  268. package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -0
  269. package/lib/node/oracles/strictOraclePrice.d.ts +1 -0
  270. package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -0
  271. package/lib/node/oracles/switchboardClient.d.ts +1 -0
  272. package/lib/node/oracles/switchboardClient.d.ts.map +1 -0
  273. package/lib/node/oracles/switchboardOnDemandClient.d.ts +1 -0
  274. package/lib/node/oracles/switchboardOnDemandClient.d.ts.map +1 -0
  275. package/lib/node/oracles/types.d.ts +1 -0
  276. package/lib/node/oracles/types.d.ts.map +1 -0
  277. package/lib/node/orderParams.d.ts +1 -0
  278. package/lib/node/orderParams.d.ts.map +1 -0
  279. package/lib/node/orderSubscriber/OrderSubscriber.d.ts +4 -2
  280. package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -0
  281. package/lib/node/orderSubscriber/OrderSubscriber.js +4 -4
  282. package/lib/node/orderSubscriber/PollingSubscription.d.ts +1 -0
  283. package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -0
  284. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +1 -0
  285. package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -0
  286. package/lib/node/orderSubscriber/grpcSubscription.d.ts +1 -0
  287. package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -0
  288. package/lib/node/orderSubscriber/index.d.ts +1 -0
  289. package/lib/node/orderSubscriber/index.d.ts.map +1 -0
  290. package/lib/node/orderSubscriber/types.d.ts +1 -0
  291. package/lib/node/orderSubscriber/types.d.ts.map +1 -0
  292. package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts +1 -0
  293. package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts.map +1 -0
  294. package/lib/node/phoenix/phoenixSubscriber.d.ts +3 -0
  295. package/lib/node/phoenix/phoenixSubscriber.d.ts.map +1 -0
  296. package/lib/node/phoenix/phoenixSubscriber.js +19 -10
  297. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
  298. package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -0
  299. package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
  300. package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -0
  301. package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts +1 -0
  302. package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts.map +1 -0
  303. package/lib/node/priorityFee/ewmaStrategy.d.ts +1 -0
  304. package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -0
  305. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -0
  306. package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -0
  307. package/lib/node/priorityFee/index.d.ts +1 -0
  308. package/lib/node/priorityFee/index.d.ts.map +1 -0
  309. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
  310. package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -0
  311. package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
  312. package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -0
  313. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -0
  314. package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -0
  315. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +1 -0
  316. package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -0
  317. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -0
  318. package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -0
  319. package/lib/node/priorityFee/types.d.ts +1 -0
  320. package/lib/node/priorityFee/types.d.ts.map +1 -0
  321. package/lib/node/serum/serumFulfillmentConfigMap.d.ts +1 -0
  322. package/lib/node/serum/serumFulfillmentConfigMap.d.ts.map +1 -0
  323. package/lib/node/serum/serumSubscriber.d.ts +1 -0
  324. package/lib/node/serum/serumSubscriber.d.ts.map +1 -0
  325. package/lib/node/serum/types.d.ts +1 -0
  326. package/lib/node/serum/types.d.ts.map +1 -0
  327. package/lib/node/slot/SlotSubscriber.d.ts +1 -0
  328. package/lib/node/slot/SlotSubscriber.d.ts.map +1 -0
  329. package/lib/node/slot/SlothashSubscriber.d.ts +1 -0
  330. package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -0
  331. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +1 -0
  332. package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -0
  333. package/lib/node/swift/index.d.ts +1 -0
  334. package/lib/node/swift/index.d.ts.map +1 -0
  335. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +1 -0
  336. package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -0
  337. package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -0
  338. package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -0
  339. package/lib/node/testClient.d.ts +1 -0
  340. package/lib/node/testClient.d.ts.map +1 -0
  341. package/lib/node/token/index.d.ts +1 -0
  342. package/lib/node/token/index.d.ts.map +1 -0
  343. package/lib/node/tokenFaucet.d.ts +1 -0
  344. package/lib/node/tokenFaucet.d.ts.map +1 -0
  345. package/lib/node/tx/baseTxSender.d.ts +1 -0
  346. package/lib/node/tx/baseTxSender.d.ts.map +1 -0
  347. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +1 -0
  348. package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -0
  349. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +1 -0
  350. package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -0
  351. package/lib/node/tx/blockhashFetcher/types.d.ts +1 -0
  352. package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -0
  353. package/lib/node/tx/fastSingleTxSender.d.ts +1 -0
  354. package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -0
  355. package/lib/node/tx/forwardOnlyTxSender.d.ts +1 -0
  356. package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -0
  357. package/lib/node/tx/priorityFeeCalculator.d.ts +1 -0
  358. package/lib/node/tx/priorityFeeCalculator.d.ts.map +1 -0
  359. package/lib/node/tx/reportTransactionError.d.ts +1 -0
  360. package/lib/node/tx/reportTransactionError.d.ts.map +1 -0
  361. package/lib/node/tx/retryTxSender.d.ts +1 -0
  362. package/lib/node/tx/retryTxSender.d.ts.map +1 -0
  363. package/lib/node/tx/txHandler.d.ts +1 -0
  364. package/lib/node/tx/txHandler.d.ts.map +1 -0
  365. package/lib/node/tx/txParamProcessor.d.ts +1 -0
  366. package/lib/node/tx/txParamProcessor.d.ts.map +1 -0
  367. package/lib/node/tx/types.d.ts +1 -0
  368. package/lib/node/tx/types.d.ts.map +1 -0
  369. package/lib/node/tx/utils.d.ts +1 -0
  370. package/lib/node/tx/utils.d.ts.map +1 -0
  371. package/lib/node/tx/whileValidTxSender.d.ts +1 -0
  372. package/lib/node/tx/whileValidTxSender.d.ts.map +1 -0
  373. package/lib/node/types.d.ts +9 -1
  374. package/lib/node/types.d.ts.map +1 -0
  375. package/lib/node/user.d.ts +1 -0
  376. package/lib/node/user.d.ts.map +1 -0
  377. package/lib/node/userConfig.d.ts +1 -0
  378. package/lib/node/userConfig.d.ts.map +1 -0
  379. package/lib/node/userMap/PollingSubscription.d.ts +1 -0
  380. package/lib/node/userMap/PollingSubscription.d.ts.map +1 -0
  381. package/lib/node/userMap/WebsocketSubscription.d.ts +1 -0
  382. package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -0
  383. package/lib/node/userMap/grpcSubscription.d.ts +1 -0
  384. package/lib/node/userMap/grpcSubscription.d.ts.map +1 -0
  385. package/lib/node/userMap/referrerMap.d.ts +1 -0
  386. package/lib/node/userMap/referrerMap.d.ts.map +1 -0
  387. package/lib/node/userMap/userMap.d.ts +3 -2
  388. package/lib/node/userMap/userMap.d.ts.map +1 -0
  389. package/lib/node/userMap/userMap.js +2 -2
  390. package/lib/node/userMap/userMapConfig.d.ts +1 -0
  391. package/lib/node/userMap/userMapConfig.d.ts.map +1 -0
  392. package/lib/node/userMap/userStatsMap.d.ts +1 -0
  393. package/lib/node/userMap/userStatsMap.d.ts.map +1 -0
  394. package/lib/node/userName.d.ts +1 -0
  395. package/lib/node/userName.d.ts.map +1 -0
  396. package/lib/node/userStats.d.ts +1 -0
  397. package/lib/node/userStats.d.ts.map +1 -0
  398. package/lib/node/userStatsConfig.d.ts +1 -0
  399. package/lib/node/userStatsConfig.d.ts.map +1 -0
  400. package/lib/node/util/TransactionConfirmationManager.d.ts +1 -0
  401. package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -0
  402. package/lib/node/util/chainClock.d.ts +1 -0
  403. package/lib/node/util/chainClock.d.ts.map +1 -0
  404. package/lib/node/util/computeUnits.d.ts +1 -0
  405. package/lib/node/util/computeUnits.d.ts.map +1 -0
  406. package/lib/node/util/digest.d.ts +1 -0
  407. package/lib/node/util/digest.d.ts.map +1 -0
  408. package/lib/node/util/ed25519Utils.d.ts +1 -0
  409. package/lib/node/util/ed25519Utils.d.ts.map +1 -0
  410. package/lib/node/util/promiseTimeout.d.ts +1 -0
  411. package/lib/node/util/promiseTimeout.d.ts.map +1 -0
  412. package/lib/node/util/pythOracleUtils.d.ts +1 -0
  413. package/lib/node/util/pythOracleUtils.d.ts.map +1 -0
  414. package/lib/node/util/tps.d.ts +1 -0
  415. package/lib/node/util/tps.d.ts.map +1 -0
  416. package/lib/node/wallet.d.ts +1 -0
  417. package/lib/node/wallet.d.ts.map +1 -0
  418. package/package.json +2 -2
  419. package/src/constants/perpMarkets.ts +2 -2
  420. package/src/dlob/DLOB.ts +14 -6
  421. package/src/dlob/DLOBNode.ts +25 -15
  422. package/src/dlob/DLOBSubscriber.ts +10 -2
  423. package/src/dlob/NodeList.ts +3 -3
  424. package/src/dlob/types.ts +10 -1
  425. package/src/driftClient.ts +39 -20
  426. package/src/idl/drift.json +16 -1
  427. package/src/math/orders.ts +39 -9
  428. package/src/math/protectedMakerParams.ts +37 -0
  429. package/src/openbook/openbookV2Subscriber.ts +20 -10
  430. package/src/orderSubscriber/OrderSubscriber.ts +5 -5
  431. package/src/phoenix/phoenixSubscriber.ts +28 -16
  432. package/src/types.ts +9 -1
  433. package/src/userMap/userMap.ts +3 -2
  434. package/tests/dlob/helpers.ts +6 -0
  435. package/tests/dlob/test.ts +4 -0
  436. package/tsconfig.json +2 -1
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.115.0-beta.0
1
+ 2.115.0-beta.10
@@ -58,9 +58,9 @@ exports.DevnetPerpMarkets = [
58
58
  symbol: '1MBONK-PERP',
59
59
  baseAssetSymbol: '1MBONK',
60
60
  marketIndex: 4,
61
- oracle: new web3_js_1.PublicKey('GojbSnJuPdKDT1ZuHuAM5t9oz6bxTo1xhUKpTua2F72p'),
61
+ oracle: new web3_js_1.PublicKey('BERaNi6cpEresbq6HC1EQGaB1H1UjvEo4NGnmYSSJof4'),
62
62
  launchTs: 1677068931000,
63
- oracleSource: __1.OracleSource.PYTH_1M_PULL,
63
+ oracleSource: __1.OracleSource.PYTH_LAZER_1M,
64
64
  pythFeedId: '0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419',
65
65
  pythLazerId: 9,
66
66
  },
@@ -1,6 +1,6 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { NodeList } from './NodeList';
3
- import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
3
+ import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, ProtectMakerParamsMap, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
4
4
  import { PublicKey } from '@solana/web3.js';
5
5
  import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
6
6
  export type DLOBOrder = {
@@ -58,8 +58,8 @@ export declare class DLOB {
58
58
  orderLists: Map<MarketTypeStr, Map<number, MarketNodeLists>>;
59
59
  maxSlotForRestingLimitOrders: number;
60
60
  initialized: boolean;
61
- protectedMakerView: boolean;
62
- constructor(protectedMakerView?: boolean);
61
+ protectedMakerParamsMap: ProtectMakerParamsMap;
62
+ constructor(protectedMakerParamsMap?: ProtectMakerParamsMap);
63
63
  private init;
64
64
  clear(): void;
65
65
  /**
@@ -14,12 +14,15 @@ const SUPPORTED_ORDER_TYPES = [
14
14
  'oracle',
15
15
  ];
16
16
  class DLOB {
17
- constructor(protectedMakerView) {
17
+ constructor(protectedMakerParamsMap) {
18
18
  this.openOrders = new Map();
19
19
  this.orderLists = new Map();
20
20
  this.maxSlotForRestingLimitOrders = 0;
21
21
  this.initialized = false;
22
- this.protectedMakerView = protectedMakerView || false;
22
+ this.protectedMakerParamsMap = protectedMakerParamsMap || {
23
+ perp: new Map(),
24
+ spot: new Map(),
25
+ };
23
26
  this.init();
24
27
  }
25
28
  init() {
@@ -88,7 +91,7 @@ class DLOB {
88
91
  .get(marketType)
89
92
  .add((0, NodeList_1.getOrderSignature)(order.orderId, userAccount));
90
93
  }
91
- (_a = this.getListForOnChainOrder(order, slot, isUserProtectedMaker)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerView);
94
+ (_a = this.getListForOnChainOrder(order, slot, isUserProtectedMaker)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerParamsMap[marketType].get(order.marketIndex));
92
95
  if (onInsert) {
93
96
  onInsert();
94
97
  }
@@ -106,7 +109,7 @@ class DLOB {
106
109
  this.orderLists
107
110
  .get(marketType)
108
111
  .get(marketIndex)
109
- .signedMsg[bidOrAsk].insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerView);
112
+ .signedMsg[bidOrAsk].insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerParamsMap[marketType].get(order.marketIndex));
110
113
  if (onInsert) {
111
114
  onInsert();
112
115
  }
@@ -215,7 +218,7 @@ class DLOB {
215
218
  for (const nodeToUpdate of nodesToUpdate) {
216
219
  const { side, node } = nodeToUpdate;
217
220
  nodeLists.takingLimit[side].remove(node.order, node.userAccount);
218
- nodeLists.restingLimit[side].insert(node.order, marketTypeStr, node.userAccount, node.isProtectedMaker, this.protectedMakerView);
221
+ nodeLists.restingLimit[side].insert(node.order, marketTypeStr, node.userAccount, node.isProtectedMaker, this.protectedMakerParamsMap[marketTypeStr].get(node.order.marketIndex));
219
222
  }
220
223
  }
221
224
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="bn.js" />
2
- import { BN, OraclePriceData, Order } from '..';
2
+ import { BN, OraclePriceData, Order, ProtectedMakerParams } from '..';
3
3
  export interface DLOBNode {
4
4
  getPrice(oraclePriceData: OraclePriceData, slot: number): BN;
5
5
  isVammNode(): boolean;
@@ -8,7 +8,7 @@ export interface DLOBNode {
8
8
  haveFilled: boolean;
9
9
  userAccount: string | undefined;
10
10
  isProtectedMaker: boolean;
11
- applyProtectedMakerOffset: boolean;
11
+ protectedMakerParams?: ProtectedMakerParams;
12
12
  isSignedMsg: boolean | undefined;
13
13
  }
14
14
  export declare abstract class OrderNode implements DLOBNode {
@@ -18,9 +18,9 @@ export declare abstract class OrderNode implements DLOBNode {
18
18
  haveFilled: boolean;
19
19
  haveTrigger: boolean;
20
20
  isProtectedMaker: boolean;
21
- applyProtectedMakerOffset: boolean;
21
+ protectedMakerParams?: ProtectedMakerParams;
22
22
  isSignedMsg: boolean;
23
- constructor(order: Order, userAccount: string, isProtectedMaker: boolean, applyProtectedMakerOffset: boolean, isSignedMsg?: boolean);
23
+ constructor(order: Order, userAccount: string, isProtectedMaker: boolean, protectedMakerParams?: ProtectedMakerParams, isSignedMsg?: boolean);
24
24
  abstract getSortValue(order: Order): BN;
25
25
  getLabel(): string;
26
26
  getPrice(oraclePriceData: OraclePriceData, slot: number): BN;
@@ -68,4 +68,4 @@ export type DLOBNodeMap = {
68
68
  signedMsg: SignedMsgOrderNode;
69
69
  };
70
70
  export type DLOBNodeType = 'signedMsg' | 'restingLimit' | 'takingLimit' | 'floatingLimit' | 'protectedFloatingLimit' | 'market' | ('trigger' & keyof DLOBNodeMap);
71
- export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string, isProtectedMaker: boolean, applyProtectedMakerOffset: boolean): DLOBNodeMap[T];
71
+ export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string, isProtectedMaker: boolean, protectedMakerParams?: ProtectedMakerParams): DLOBNodeMap[T];
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNode = exports.SignedMsgOrderNode = exports.TriggerOrderNode = exports.MarketOrderNode = exports.FloatingLimitOrderNode = exports.RestingLimitOrderNode = exports.TakingLimitOrderNode = exports.OrderNode = void 0;
4
4
  const __1 = require("..");
5
- // import { PublicKey } from '@solana/web3.js';
6
5
  const NodeList_1 = require("./NodeList");
7
6
  class OrderNode {
8
- constructor(order, userAccount, isProtectedMaker, applyProtectedMakerOffset, isSignedMsg = false) {
7
+ constructor(order, userAccount, isProtectedMaker, protectedMakerParams, isSignedMsg = false) {
9
8
  this.haveFilled = false;
10
9
  this.haveTrigger = false;
11
10
  // Copy the order over to the node
@@ -13,7 +12,7 @@ class OrderNode {
13
12
  this.userAccount = userAccount;
14
13
  this.sortValue = this.getSortValue(order);
15
14
  this.isProtectedMaker = isProtectedMaker;
16
- this.applyProtectedMakerOffset = applyProtectedMakerOffset;
15
+ this.protectedMakerParams = protectedMakerParams;
17
16
  this.isSignedMsg = isSignedMsg;
18
17
  }
19
18
  getLabel() {
@@ -30,7 +29,7 @@ class OrderNode {
30
29
  return msg;
31
30
  }
32
31
  getPrice(oraclePriceData, slot) {
33
- return (0, __1.getLimitPrice)(this.order, oraclePriceData, slot, undefined, this.applyProtectedMakerOffset && this.isProtectedMaker);
32
+ return (0, __1.getLimitPrice)(this.order, oraclePriceData, slot, undefined, this.isProtectedMaker ? this.protectedMakerParams : undefined);
34
33
  }
35
34
  isBaseFilled() {
36
35
  return this.order.baseAssetAmountFilled.eq(this.order.baseAssetAmount);
@@ -49,7 +48,7 @@ exports.TakingLimitOrderNode = TakingLimitOrderNode;
49
48
  class RestingLimitOrderNode extends OrderNode {
50
49
  getSortValue(order) {
51
50
  let sortValue = order.price;
52
- if (this.applyProtectedMakerOffset && this.isProtectedMaker) {
51
+ if (this.protectedMakerParams && this.isProtectedMaker) {
53
52
  const offset = sortValue.divn(1000);
54
53
  if ((0, __1.isVariant)(order.direction, 'long')) {
55
54
  sortValue = sortValue.sub(offset);
@@ -83,27 +82,27 @@ exports.TriggerOrderNode = TriggerOrderNode;
83
82
  // We'll use the signedMsg uuid for the order id since it's not yet on-chain
84
83
  class SignedMsgOrderNode extends OrderNode {
85
84
  constructor(order, userAccount) {
86
- super(order, userAccount, false, false, true);
85
+ super(order, userAccount, false, undefined, true);
87
86
  }
88
87
  getSortValue(order) {
89
88
  return order.slot;
90
89
  }
91
90
  }
92
91
  exports.SignedMsgOrderNode = SignedMsgOrderNode;
93
- function createNode(nodeType, order, userAccount, isProtectedMaker, applyProtectedMakerOffset) {
92
+ function createNode(nodeType, order, userAccount, isProtectedMaker, protectedMakerParams) {
94
93
  switch (nodeType) {
95
94
  case 'floatingLimit':
96
- return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
95
+ return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
97
96
  case 'protectedFloatingLimit':
98
- return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
97
+ return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
99
98
  case 'restingLimit':
100
- return new RestingLimitOrderNode(order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
99
+ return new RestingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
101
100
  case 'takingLimit':
102
- return new TakingLimitOrderNode(order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
101
+ return new TakingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
103
102
  case 'market':
104
- return new MarketOrderNode(order, userAccount, isProtectedMaker, false);
103
+ return new MarketOrderNode(order, userAccount, isProtectedMaker, undefined);
105
104
  case 'trigger':
106
- return new TriggerOrderNode(order, userAccount, isProtectedMaker, false);
105
+ return new TriggerOrderNode(order, userAccount, isProtectedMaker, undefined);
107
106
  case 'signedMsg':
108
107
  return new SignedMsgOrderNode(order, userAccount);
109
108
  default:
@@ -3,7 +3,7 @@
3
3
  import { DLOB } from './DLOB';
4
4
  import { EventEmitter } from 'events';
5
5
  import StrictEventEmitter from 'strict-event-emitter-types';
6
- import { DLOBSource, DLOBSubscriberEvents, DLOBSubscriptionConfig, SlotSource } from './types';
6
+ import { DLOBSource, DLOBSubscriberEvents, DLOBSubscriptionConfig, ProtectMakerParamsMap, SlotSource } from './types';
7
7
  import { DriftClient } from '../driftClient';
8
8
  import { MarketType } from '../types';
9
9
  import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
@@ -18,6 +18,7 @@ export declare class DLOBSubscriber {
18
18
  protectedMakerView: boolean;
19
19
  constructor(config: DLOBSubscriptionConfig);
20
20
  subscribe(): Promise<void>;
21
+ getProtectedMakerParamsMap(): ProtectMakerParamsMap | undefined;
21
22
  updateDLOB(): Promise<void>;
22
23
  getDLOB(): DLOB;
23
24
  /**
@@ -5,6 +5,7 @@ const DLOB_1 = require("./DLOB");
5
5
  const events_1 = require("events");
6
6
  const types_1 = require("../types");
7
7
  const orderBookLevels_1 = require("./orderBookLevels");
8
+ const protectedMakerParams_1 = require("../math/protectedMakerParams");
8
9
  class DLOBSubscriber {
9
10
  constructor(config) {
10
11
  this.driftClient = config.driftClient;
@@ -12,7 +13,7 @@ class DLOBSubscriber {
12
13
  this.slotSource = config.slotSource;
13
14
  this.updateFrequency = config.updateFrequency;
14
15
  this.protectedMakerView = config.protectedMakerView || false;
15
- this.dlob = new DLOB_1.DLOB(this.protectedMakerView);
16
+ this.dlob = new DLOB_1.DLOB(this.getProtectedMakerParamsMap());
16
17
  this.eventEmitter = new events_1.EventEmitter();
17
18
  }
18
19
  async subscribe() {
@@ -30,8 +31,13 @@ class DLOBSubscriber {
30
31
  }
31
32
  }, this.updateFrequency);
32
33
  }
34
+ getProtectedMakerParamsMap() {
35
+ return this.protectedMakerView
36
+ ? (0, protectedMakerParams_1.getProtectedMakerParamsMap)(this.driftClient.getPerpMarketAccounts())
37
+ : undefined;
38
+ }
33
39
  async updateDLOB() {
34
- this.dlob = await this.dlobSource.getDLOB(this.slotSource.getSlot(), this.protectedMakerView);
40
+ this.dlob = await this.dlobSource.getDLOB(this.slotSource.getSlot(), this.getProtectedMakerParamsMap());
35
41
  }
36
42
  getDLOB() {
37
43
  return this.dlob;
@@ -1,4 +1,4 @@
1
- import { MarketTypeStr, Order } from '..';
1
+ import { MarketTypeStr, Order, ProtectedMakerParams } from '..';
2
2
  import { DLOBNode, DLOBNodeMap } from './DLOBNode';
3
3
  export type SortDirection = 'asc' | 'desc';
4
4
  export declare function getOrderSignature(orderId: number, userAccount: string): string;
@@ -13,7 +13,7 @@ export declare class NodeList<NodeType extends keyof DLOBNodeMap> implements DLO
13
13
  nodeMap: Map<string, DLOBNodeMap[NodeType]>;
14
14
  constructor(nodeType: NodeType, sortDirection: SortDirection);
15
15
  clear(): void;
16
- insert(order: Order, marketType: MarketTypeStr, userAccount: string, isProtectedMaker: boolean, applyProtectedMakerOffset: boolean): void;
16
+ insert(order: Order, marketType: MarketTypeStr, userAccount: string, isProtectedMaker: boolean, protectedMakerParamsMap?: ProtectedMakerParams): void;
17
17
  prependNode(currentNode: DLOBNodeMap[NodeType], newNode: DLOBNodeMap[NodeType]): boolean;
18
18
  update(order: Order, userAccount: string): void;
19
19
  remove(order: Order, userAccount: string): void;
@@ -19,11 +19,11 @@ class NodeList {
19
19
  this.length = 0;
20
20
  this.nodeMap.clear();
21
21
  }
22
- insert(order, marketType, userAccount, isProtectedMaker, applyProtectedMakerOffset) {
22
+ insert(order, marketType, userAccount, isProtectedMaker, protectedMakerParamsMap) {
23
23
  if (!(0, __1.isVariant)(order.status, 'open')) {
24
24
  return;
25
25
  }
26
- const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker, applyProtectedMakerOffset);
26
+ const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker, protectedMakerParamsMap);
27
27
  const orderSignature = getOrderSignature(order.orderId, userAccount);
28
28
  if (this.nodeMap.has(orderSignature)) {
29
29
  return;
@@ -1,5 +1,7 @@
1
1
  import { DLOB } from './DLOB';
2
2
  import { DriftClient } from '../driftClient';
3
+ import { ProtectedMakerParams } from '../types';
4
+ import { MarketTypeStr } from '../types';
3
5
  export type DLOBSubscriptionConfig = {
4
6
  driftClient: DriftClient;
5
7
  dlobSource: DLOBSource;
@@ -12,8 +14,11 @@ export interface DLOBSubscriberEvents {
12
14
  error: (e: Error) => void;
13
15
  }
14
16
  export interface DLOBSource {
15
- getDLOB(slot: number, protectedMakerView?: boolean): Promise<DLOB>;
17
+ getDLOB(slot: number, protectedMakerParamsMap?: ProtectMakerParamsMap): Promise<DLOB>;
16
18
  }
17
19
  export interface SlotSource {
18
20
  getSlot(): number;
19
21
  }
22
+ export type ProtectMakerParamsMap = {
23
+ [marketType in MarketTypeStr]: Map<number, ProtectedMakerParams>;
24
+ };
@@ -167,8 +167,8 @@ export declare class DriftClient {
167
167
  getInitializeUserStatsIx(): Promise<TransactionInstruction>;
168
168
  initializeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
169
169
  getInitializeSignedMsgUserOrdersAccountIx(authority: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
170
- resizeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
171
- getResizeSignedMsgUserOrdersInstruction(authority: PublicKey, numOrders: number): Promise<TransactionInstruction>;
170
+ resizeSignedMsgUserOrders(authority: PublicKey, numOrders: number, userSubaccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
171
+ getResizeSignedMsgUserOrdersInstruction(authority: PublicKey, numOrders: number, userSubaccountId?: number): Promise<TransactionInstruction>;
172
172
  initializeSignedMsgWsDelegatesAccount(authority: PublicKey, delegates?: PublicKey[], txParams?: TxParams): Promise<TransactionSignature>;
173
173
  getInitializeSignedMsgWsDelegatesAccountIx(authority: PublicKey, delegates?: PublicKey[]): Promise<TransactionInstruction>;
174
174
  addSignedMsgWsDelegate(authority: PublicKey, delegate: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
@@ -245,8 +245,8 @@ export declare class DriftClient {
245
245
  * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
246
246
  * @param subAccountId
247
247
  */
248
- forceGetUserAccount(subAccountId?: number): Promise<UserAccount | undefined>;
249
- getUserAccountAndSlot(subAccountId?: number): DataAndSlot<UserAccount> | undefined;
248
+ forceGetUserAccount(subAccountId?: number, authority?: PublicKey): Promise<UserAccount | undefined>;
249
+ getUserAccountAndSlot(subAccountId?: number, authority?: PublicKey): DataAndSlot<UserAccount> | undefined;
250
250
  getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
251
251
  getQuoteAssetTokenAmount(): BN;
252
252
  /**
@@ -642,7 +642,7 @@ class DriftClient {
642
642
  const initializeUserAccountIx = await this.program.instruction.initializeSignedMsgUserOrders(numOrders, {
643
643
  accounts: {
644
644
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
645
- authority: this.wallet.publicKey,
645
+ authority,
646
646
  payer: this.wallet.publicKey,
647
647
  rent: anchor.web3.SYSVAR_RENT_PUBKEY,
648
648
  systemProgram: anchor.web3.SystemProgram.programId,
@@ -650,19 +650,21 @@ class DriftClient {
650
650
  });
651
651
  return [signedMsgUserAccountPublicKey, initializeUserAccountIx];
652
652
  }
653
- async resizeSignedMsgUserOrders(authority, numOrders, txParams) {
654
- const resizeUserAccountIx = await this.getResizeSignedMsgUserOrdersInstruction(authority, numOrders);
653
+ async resizeSignedMsgUserOrders(authority, numOrders, userSubaccountId, txParams) {
654
+ const resizeUserAccountIx = await this.getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId);
655
655
  const tx = await this.buildTransaction([resizeUserAccountIx], txParams);
656
656
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
657
657
  return txSig;
658
658
  }
659
- async getResizeSignedMsgUserOrdersInstruction(authority, numOrders) {
659
+ async getResizeSignedMsgUserOrdersInstruction(authority, numOrders, userSubaccountId) {
660
660
  const signedMsgUserAccountPublicKey = (0, pda_1.getSignedMsgUserAccountPublicKey)(this.program.programId, authority);
661
661
  const resizeUserAccountIx = await this.program.instruction.resizeSignedMsgUserOrders(numOrders, {
662
662
  accounts: {
663
663
  signedMsgUserOrders: signedMsgUserAccountPublicKey,
664
- authority: this.wallet.publicKey,
664
+ authority,
665
+ payer: this.wallet.publicKey,
665
666
  systemProgram: anchor.web3.SystemProgram.programId,
667
+ user: await (0, pda_1.getUserAccountPublicKey)(this.program.programId, authority, userSubaccountId),
666
668
  },
667
669
  });
668
670
  return resizeUserAccountIx;
@@ -1193,12 +1195,12 @@ class DriftClient {
1193
1195
  * Forces a fetch to rpc before returning accounts. Useful for anchor tests.
1194
1196
  * @param subAccountId
1195
1197
  */
1196
- async forceGetUserAccount(subAccountId) {
1197
- await this.getUser(subAccountId).fetchAccounts();
1198
- return this.getUser(subAccountId).getUserAccount();
1198
+ async forceGetUserAccount(subAccountId, authority) {
1199
+ await this.getUser(subAccountId, authority).fetchAccounts();
1200
+ return this.getUser(subAccountId, authority).getUserAccount();
1199
1201
  }
1200
- getUserAccountAndSlot(subAccountId) {
1201
- return this.getUser(subAccountId).getUserAccountAndSlot();
1202
+ getUserAccountAndSlot(subAccountId, authority) {
1203
+ return this.getUser(subAccountId, authority).getUserAccountAndSlot();
1202
1204
  }
1203
1205
  getSpotPosition(marketIndex, subAccountId) {
1204
1206
  return this.getUserAccount(subAccountId).spotPositions.find((spotPosition) => spotPosition.marketIndex === marketIndex);
@@ -1271,7 +1273,11 @@ class DriftClient {
1271
1273
  var _a;
1272
1274
  const { oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap } = this.getRemainingAccountMapsForUsers(params.userAccounts);
1273
1275
  if (params.useMarketLastSlotCache) {
1274
- const lastUserSlot = (_a = this.getUserAccountAndSlot()) === null || _a === void 0 ? void 0 : _a.slot;
1276
+ const lastUserSlot = (_a = this.getUserAccountAndSlot(params.userAccounts.length > 0
1277
+ ? params.userAccounts[0].subAccountId
1278
+ : this.activeSubAccountId, params.userAccounts.length > 0
1279
+ ? params.userAccounts[0].authority
1280
+ : this.authority)) === null || _a === void 0 ? void 0 : _a.slot;
1275
1281
  for (const [marketIndex, slot,] of this.perpMarketLastSlotCache.entries()) {
1276
1282
  // if cache has more recent slot than user positions account slot, add market to remaining accounts
1277
1283
  // otherwise remove from slot
@@ -1469,7 +1475,7 @@ class DriftClient {
1469
1475
  let remainingAccounts = [];
1470
1476
  if (userInitialized) {
1471
1477
  remainingAccounts = this.getRemainingAccounts({
1472
- userAccounts: [await this.forceGetUserAccount()],
1478
+ userAccounts: [await this.forceGetUserAccount(subAccountId)],
1473
1479
  useMarketLastSlotCache: true,
1474
1480
  writableSpotMarketIndexes: [marketIndex],
1475
1481
  });
@@ -1854,8 +1860,8 @@ class DriftClient {
1854
1860
  return txSig;
1855
1861
  }
1856
1862
  async getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount) {
1857
- const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
1858
- const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
1863
+ const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, fromSubAccountId);
1864
+ const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, toSubAccountId);
1859
1865
  const remainingAccounts = this.getRemainingAccounts({
1860
1866
  userAccounts: [
1861
1867
  this.getUserAccount(fromSubAccountId),
@@ -3414,7 +3420,7 @@ class DriftClient {
3414
3420
  async getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams, marketIndex, takerInfo, precedingIxs = [], overrideCustomIxIndex) {
3415
3421
  const remainingAccounts = this.getRemainingAccounts({
3416
3422
  userAccounts: [takerInfo.takerUserAccount],
3417
- useMarketLastSlotCache: true,
3423
+ useMarketLastSlotCache: false,
3418
3424
  readablePerpMarketIndex: marketIndex,
3419
3425
  });
3420
3426
  const messageLengthBuffer = Buffer.alloc(2);
@@ -3456,7 +3462,7 @@ class DriftClient {
3456
3462
  this.getUserAccount(subAccountId),
3457
3463
  takerInfo.takerUserAccount,
3458
3464
  ],
3459
- useMarketLastSlotCache: true,
3465
+ useMarketLastSlotCache: false,
3460
3466
  writablePerpMarketIndexes: [orderParams.marketIndex],
3461
3467
  });
3462
3468
  if (referrerInfo) {
@@ -4860,7 +4866,7 @@ class DriftClient {
4860
4866
  this.sbProgramFeedConfigs.set(feed.toString(), feedConfig);
4861
4867
  }
4862
4868
  }
4863
- const [pullIxs, _responses, success] = await on_demand_1.PullFeed.fetchUpdateManyIx(program, {
4869
+ const [pullIxs, _responses, success] = await on_demand_1.PullFeed.fetchUpdateManyLightIx(program, {
4864
4870
  feeds,
4865
4871
  numSignatures,
4866
4872
  recentSlothashes: recentSlothash
@@ -104,7 +104,7 @@
104
104
  {
105
105
  "name": "authority",
106
106
  "isMut": false,
107
- "isSigner": true
107
+ "isSigner": false
108
108
  },
109
109
  {
110
110
  "name": "payer",
@@ -139,6 +139,16 @@
139
139
  },
140
140
  {
141
141
  "name": "authority",
142
+ "isMut": false,
143
+ "isSigner": false
144
+ },
145
+ {
146
+ "name": "user",
147
+ "isMut": false,
148
+ "isSigner": false
149
+ },
150
+ {
151
+ "name": "payer",
142
152
  "isMut": true,
143
153
  "isSigner": true
144
154
  },
@@ -14986,6 +14996,11 @@
14986
14996
  "code": 6312,
14987
14997
  "name": "InvalidTransferPerpPosition",
14988
14998
  "msg": "Invalid Transfer Perp Position"
14999
+ },
15000
+ {
15001
+ "code": 6313,
15002
+ "name": "InvalidSignedMsgUserOrdersResize",
15003
+ "msg": "Invalid SignedMsgUserOrders resize"
14989
15004
  }
14990
15005
  ],
14991
15006
  "metadata": {
@@ -1,6 +1,6 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { User } from '../user';
3
- import { PerpMarketAccount, AMM, Order, PositionDirection } from '../types';
3
+ import { PerpMarketAccount, AMM, Order, PositionDirection, ProtectedMakerParams } from '../types';
4
4
  import { BN } from '@coral-xyz/anchor';
5
5
  import { OraclePriceData } from '../oracles/types';
6
6
  export declare function isOrderRiskIncreasing(user: User, order: Order): boolean;
@@ -8,7 +8,8 @@ export declare function isOrderRiskIncreasingInSameDirection(user: User, order:
8
8
  export declare function isOrderReduceOnly(user: User, order: Order): boolean;
9
9
  export declare function standardizeBaseAssetAmount(baseAssetAmount: BN, stepSize: BN): BN;
10
10
  export declare function standardizePrice(price: BN, tickSize: BN, direction: PositionDirection): BN;
11
- export declare function getLimitPrice(order: Order, oraclePriceData: OraclePriceData, slot: number, fallbackPrice?: BN, protectedMaker?: boolean): BN | undefined;
11
+ export declare function getLimitPrice(order: Order, oraclePriceData: OraclePriceData, slot: number, fallbackPrice?: BN, protectedMakerParams?: ProtectedMakerParams): BN | undefined;
12
+ export declare function applyProtectedMakerParams(limitPrice: BN, direction: PositionDirection, protectedMakerParams: ProtectedMakerParams): BN;
12
13
  export declare function hasLimitPrice(order: Order, slot: number): boolean;
13
14
  export declare function hasAuctionPrice(order: Order, slot: number): boolean;
14
15
  export declare function isFillableByVAMM(order: Order, market: PerpMarketAccount, oraclePriceData: OraclePriceData, slot: number, ts: number, minAuctionDuration: number): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSignedMsgOrder = exports.isTakingOrder = exports.isRestingLimitOrder = exports.isTriggered = exports.mustBeTriggered = exports.isLimitOrder = exports.isMarketOrder = exports.isOrderExpired = exports.calculateBaseAssetAmountToFillUpToLimitPrice = exports.calculateBaseAssetAmountForAmmToFulfill = exports.isFillableByVAMM = exports.hasAuctionPrice = exports.hasLimitPrice = exports.getLimitPrice = exports.standardizePrice = exports.standardizeBaseAssetAmount = exports.isOrderReduceOnly = exports.isOrderRiskIncreasingInSameDirection = exports.isOrderRiskIncreasing = void 0;
3
+ exports.isSignedMsgOrder = exports.isTakingOrder = exports.isRestingLimitOrder = exports.isTriggered = exports.mustBeTriggered = exports.isLimitOrder = exports.isMarketOrder = exports.isOrderExpired = exports.calculateBaseAssetAmountToFillUpToLimitPrice = exports.calculateBaseAssetAmountForAmmToFulfill = exports.isFillableByVAMM = exports.hasAuctionPrice = exports.hasLimitPrice = exports.applyProtectedMakerParams = exports.getLimitPrice = exports.standardizePrice = exports.standardizeBaseAssetAmount = exports.isOrderReduceOnly = exports.isOrderRiskIncreasingInSameDirection = exports.isOrderRiskIncreasing = void 0;
4
4
  const types_1 = require("../types");
5
5
  const numericConstants_1 = require("../constants/numericConstants");
6
6
  const anchor_1 = require("@coral-xyz/anchor");
@@ -96,7 +96,7 @@ function standardizePrice(price, tickSize, direction) {
96
96
  }
97
97
  }
98
98
  exports.standardizePrice = standardizePrice;
99
- function getLimitPrice(order, oraclePriceData, slot, fallbackPrice, protectedMaker) {
99
+ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice, protectedMakerParams) {
100
100
  let limitPrice;
101
101
  if (hasAuctionPrice(order, slot)) {
102
102
  limitPrice = (0, auction_1.getAuctionPrice)(order, slot, oraclePriceData.price);
@@ -110,18 +110,30 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice, protectedMak
110
110
  else {
111
111
  limitPrice = order.price;
112
112
  }
113
- if (protectedMaker) {
114
- const offset = limitPrice.divn(1000);
115
- if ((0, types_1.isVariant)(order.direction, 'long')) {
116
- limitPrice = limitPrice.sub(offset);
117
- }
118
- else {
119
- limitPrice = limitPrice.add(offset);
120
- }
113
+ if (protectedMakerParams) {
114
+ limitPrice = applyProtectedMakerParams(limitPrice, order.direction, protectedMakerParams);
121
115
  }
122
116
  return limitPrice;
123
117
  }
124
118
  exports.getLimitPrice = getLimitPrice;
119
+ function applyProtectedMakerParams(limitPrice, direction, protectedMakerParams) {
120
+ const minOffset = protectedMakerParams.tickSize.muln(8);
121
+ let limitPriceBpsDivisor;
122
+ if (protectedMakerParams.limitPriceDivisor > 0) {
123
+ limitPriceBpsDivisor = 10000 / protectedMakerParams.limitPriceDivisor;
124
+ }
125
+ else {
126
+ limitPriceBpsDivisor = 1000;
127
+ }
128
+ const limitPriceOffset = anchor_1.BN.min(anchor_1.BN.max(anchor_1.BN.max(limitPrice.divn(limitPriceBpsDivisor), minOffset), protectedMakerParams.dynamicOffset), limitPrice.divn(20));
129
+ if ((0, types_1.isVariant)(direction, 'long')) {
130
+ return anchor_1.BN.max(limitPrice.sub(limitPriceOffset), protectedMakerParams.tickSize);
131
+ }
132
+ else {
133
+ return limitPrice.add(limitPriceOffset);
134
+ }
135
+ }
136
+ exports.applyProtectedMakerParams = applyProtectedMakerParams;
125
137
  function hasLimitPrice(order, slot) {
126
138
  return (order.price.gt(numericConstants_1.ZERO) ||
127
139
  order.oraclePriceOffset != 0 ||
@@ -0,0 +1,4 @@
1
+ import { ProtectMakerParamsMap } from '..';
2
+ import { PerpMarketAccount, ProtectedMakerParams } from '../types';
3
+ export declare function getProtectedMakerParams(perpMarket: PerpMarketAccount): ProtectedMakerParams;
4
+ export declare function getProtectedMakerParamsMap(perpMarkets: PerpMarketAccount[]): ProtectMakerParamsMap;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProtectedMakerParamsMap = exports.getProtectedMakerParams = void 0;
4
+ const __1 = require("..");
5
+ function getProtectedMakerParams(perpMarket) {
6
+ let dynamicOffset;
7
+ if (perpMarket.protectedMakerDynamicDivisor > 0) {
8
+ dynamicOffset = __1.BN.max(perpMarket.amm.oracleStd, perpMarket.amm.markStd).divn(perpMarket.protectedMakerDynamicDivisor);
9
+ }
10
+ else {
11
+ dynamicOffset = 0;
12
+ }
13
+ return {
14
+ tickSize: perpMarket.amm.orderTickSize,
15
+ limitPriceDivisor: perpMarket.protectedMakerLimitPriceDivisor,
16
+ dynamicOffset: dynamicOffset,
17
+ };
18
+ }
19
+ exports.getProtectedMakerParams = getProtectedMakerParams;
20
+ function getProtectedMakerParamsMap(perpMarkets) {
21
+ const map = {
22
+ perp: new Map(),
23
+ spot: new Map(),
24
+ };
25
+ for (const perpMarket of perpMarkets) {
26
+ const marketIndex = perpMarket.marketIndex;
27
+ const protectedMakerParams = getProtectedMakerParams(perpMarket);
28
+ map.perp.set(marketIndex, protectedMakerParams);
29
+ }
30
+ return map;
31
+ }
32
+ exports.getProtectedMakerParamsMap = getProtectedMakerParamsMap;
@@ -31,6 +31,8 @@ export declare class OpenbookV2Subscriber implements L2OrderBookGenerator {
31
31
  getBestAsk(): BN | undefined;
32
32
  getL2Bids(): Generator<L2Level>;
33
33
  getL2Asks(): Generator<L2Level>;
34
+ convertSizeInBaseLotsToMarketPrecision(sizeInLots: BN): BN;
35
+ convertPriceInLotsToPricePrecision(priceInLots: BN): BN;
34
36
  getL2Levels(side: 'bids' | 'asks'): Generator<L2Level>;
35
37
  unsubscribe(): Promise<void>;
36
38
  }
@@ -56,7 +56,7 @@ class OpenbookV2Subscriber {
56
56
  if (bestBid === undefined) {
57
57
  return undefined;
58
58
  }
59
- return new anchor_1.BN(Math.floor(bestBid.price * numericConstants_1.PRICE_PRECISION.toNumber()));
59
+ return this.convertPriceInLotsToPricePrecision(bestBid.priceLots);
60
60
  }
61
61
  getBestAsk() {
62
62
  var _a;
@@ -64,7 +64,7 @@ class OpenbookV2Subscriber {
64
64
  if (bestAsk === undefined) {
65
65
  return undefined;
66
66
  }
67
- return new anchor_1.BN(Math.floor(bestAsk.price * numericConstants_1.PRICE_PRECISION.toNumber()));
67
+ return this.convertPriceInLotsToPricePrecision(bestAsk.priceLots);
68
68
  }
69
69
  getL2Bids() {
70
70
  return this.getL2Levels('bids');
@@ -72,13 +72,23 @@ class OpenbookV2Subscriber {
72
72
  getL2Asks() {
73
73
  return this.getL2Levels('asks');
74
74
  }
75
+ convertSizeInBaseLotsToMarketPrecision(sizeInLots) {
76
+ return sizeInLots.mul(this.market.account.baseLotSize);
77
+ }
78
+ convertPriceInLotsToPricePrecision(priceInLots) {
79
+ const adjPrice = priceInLots
80
+ .mul(numericConstants_1.PRICE_PRECISION)
81
+ .muln(10 **
82
+ (this.market.account.baseDecimals - this.market.account.quoteDecimals))
83
+ .mul(this.market.account.quoteLotSize)
84
+ .div(this.market.account.baseLotSize);
85
+ return adjPrice;
86
+ }
75
87
  *getL2Levels(side) {
76
- const basePrecision = Math.ceil(1 / this.market.baseNativeFactor.toNumber());
77
- const pricePrecision = numericConstants_1.PRICE_PRECISION.toNumber();
78
88
  const levels = side === 'bids' ? this.market.bids : this.market.asks;
79
89
  for (const order of levels === null || levels === void 0 ? void 0 : levels.items()) {
80
- const size = new anchor_1.BN(order.size * basePrecision);
81
- const price = new anchor_1.BN(order.price * pricePrecision);
90
+ const size = this.convertSizeInBaseLotsToMarketPrecision(order.sizeLots);
91
+ const price = this.convertPriceInLotsToPricePrecision(order.priceLots);
82
92
  yield {
83
93
  price,
84
94
  size,