@alpha-arcade/sdk 0.2.5 → 0.2.6
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 +2 -2
- package/dist/index.cjs +15 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ const result = await client.createLimitOrder({
|
|
|
91
91
|
quantity: 2_000_000, // 2 shares in microunits
|
|
92
92
|
isBuying: true,
|
|
93
93
|
});
|
|
94
|
-
// result: { escrowAppId, txIds, confirmedRound }
|
|
94
|
+
// result: { escrowAppId, txIds, confirmedRound, matchedQuantity?, matchedPrice? }
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
#### `createMarketOrder(params)`
|
|
@@ -107,7 +107,7 @@ const result = await client.createMarketOrder({
|
|
|
107
107
|
isBuying: true,
|
|
108
108
|
slippage: 50_000, // $0.05 slippage tolerance
|
|
109
109
|
});
|
|
110
|
-
// result: { escrowAppId,
|
|
110
|
+
// result: { escrowAppId, txIds, confirmedRound, matchedQuantity, matchedPrice }
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
#### `cancelOrder(params)`
|
package/dist/index.cjs
CHANGED
|
@@ -1544,7 +1544,21 @@ var extractEscrowAppId = async (algodClient, indexerClient, targetTxId) => {
|
|
|
1544
1544
|
return 0;
|
|
1545
1545
|
};
|
|
1546
1546
|
var createLimitOrder = async (config, params) => {
|
|
1547
|
-
|
|
1547
|
+
const orderbook = await getOrderbook(config, params.marketAppId);
|
|
1548
|
+
const matchingOrders = calculateMatchingOrders(
|
|
1549
|
+
orderbook,
|
|
1550
|
+
params.isBuying,
|
|
1551
|
+
params.position === 1,
|
|
1552
|
+
params.quantity,
|
|
1553
|
+
params.price,
|
|
1554
|
+
0
|
|
1555
|
+
);
|
|
1556
|
+
const totalMatchedQuantity = matchingOrders.reduce((sum, o) => sum + o.quantity, 0);
|
|
1557
|
+
const matchedPrice = totalMatchedQuantity > 0 ? Math.round(
|
|
1558
|
+
matchingOrders.reduce((sum, o) => sum + (o.price ?? params.price) * o.quantity, 0) / totalMatchedQuantity
|
|
1559
|
+
) : params.price;
|
|
1560
|
+
const result = await createOrder(config, { ...params, slippage: 0, matchingOrders });
|
|
1561
|
+
return { ...result, matchedQuantity: totalMatchedQuantity, matchedPrice };
|
|
1548
1562
|
};
|
|
1549
1563
|
var createMarketOrder = async (config, params) => {
|
|
1550
1564
|
let matchingOrders = params.matchingOrders;
|