@triadxyz/triad-protocol 2.3.1-beta → 2.3.3-beta

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 (2) hide show
  1. package/dist/trade.js +8 -4
  2. package/package.json +1 -1
package/dist/trade.js CHANGED
@@ -735,21 +735,25 @@ class Trade {
735
735
  if (remainingUSDC.div(new bn_js_1.default(Math.pow(10, this.decimals))).toNumber() === 0)
736
736
  break;
737
737
  if (order.authority === this.program.provider.publicKey.toBase58()) {
738
- return;
738
+ continue;
739
739
  }
740
740
  const orderPrice = new bn_js_1.default(order.price);
741
- const availableShares = new bn_js_1.default(order.totalShares);
741
+ const availableShares = new bn_js_1.default(order.totalShares).sub(new bn_js_1.default(order.filledShares));
742
742
  let adjustedPrice = orderPrice;
743
743
  if (feeBps > 0) {
744
744
  const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
745
- const fee = priceSpread.mul(new bn_js_1.default(feeBps)).div(new bn_js_1.default(10000));
745
+ const fee = priceSpread
746
+ .mul(new bn_js_1.default(feeBps))
747
+ .div(new bn_js_1.default(10000))
748
+ .mul(orderPrice)
749
+ .div(new bn_js_1.default(1000000));
746
750
  adjustedPrice = orderPrice.add(fee);
747
751
  }
748
752
  const maxSharesForPrice = remainingUSDC
749
753
  .mul(new bn_js_1.default(Math.pow(10, this.decimals)))
750
754
  .div(adjustedPrice);
751
755
  const sharesToBuy = bn_js_1.default.min(maxSharesForPrice, availableShares);
752
- if (sharesToBuy.lten(0))
756
+ if (sharesToBuy.lt(new bn_js_1.default(0)))
753
757
  continue;
754
758
  const usdcAmount = sharesToBuy
755
759
  .mul(adjustedPrice)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.3.1-beta",
3
+ "version": "2.3.3-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",