@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/dist/index.d.cts
CHANGED
|
@@ -158,13 +158,10 @@ type CreateOrderResult = {
|
|
|
158
158
|
txIds: string[];
|
|
159
159
|
/** Confirmed round number */
|
|
160
160
|
confirmedRound: number;
|
|
161
|
-
};
|
|
162
|
-
/** Result of creating a market order (includes match info) */
|
|
163
|
-
type CreateMarketOrderResult = CreateOrderResult & {
|
|
164
161
|
/** Total quantity that was matched */
|
|
165
|
-
matchedQuantity
|
|
162
|
+
matchedQuantity?: number;
|
|
166
163
|
/** Weighted average fill price in microunits (accounts for complementary matching) */
|
|
167
|
-
matchedPrice
|
|
164
|
+
matchedPrice?: number;
|
|
168
165
|
};
|
|
169
166
|
/** Result of cancelling an order */
|
|
170
167
|
type CancelOrderResult = {
|
|
@@ -375,7 +372,7 @@ declare class AlphaClient {
|
|
|
375
372
|
* @param params - Order parameters (marketAppId, position, price, quantity, isBuying, slippage)
|
|
376
373
|
* @returns The created escrow app ID, matched quantity, and transaction info
|
|
377
374
|
*/
|
|
378
|
-
createMarketOrder(params: CreateMarketOrderParams): Promise<
|
|
375
|
+
createMarketOrder(params: CreateMarketOrderParams): Promise<CreateOrderResult>;
|
|
379
376
|
/**
|
|
380
377
|
* Cancels an open order by deleting its escrow app.
|
|
381
378
|
*
|
|
@@ -629,4 +626,4 @@ declare const getEscrowGlobalState: (indexerClient: algosdk.Indexer, escrowAppId
|
|
|
629
626
|
*/
|
|
630
627
|
declare const checkAssetOptIn: (algodClient: algosdk.Algodv2, address: string, assetId: number) => Promise<boolean>;
|
|
631
628
|
|
|
632
|
-
export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type
|
|
629
|
+
export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_MARKET_CREATOR_ADDRESS, type EscrowGlobalState, type Market, type MarketGlobalState, type MarketOption, type MergeSharesParams, type OpenOrder, type OrderSide, type Orderbook, type OrderbookEntry, type OrderbookSide, type Position, type ProposeMatchParams, type ProposeMatchResult, type SplitMergeResult, type SplitSharesParams, type WalletPosition, calculateFee, calculateFeeFromTotal, calculateMatchingOrders, checkAssetOptIn, decodeGlobalState, getEscrowGlobalState, getLiveMarketsFromApi, getMarketFromApi, getMarketGlobalState, getMarketOnChain, getMarketsOnChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -158,13 +158,10 @@ type CreateOrderResult = {
|
|
|
158
158
|
txIds: string[];
|
|
159
159
|
/** Confirmed round number */
|
|
160
160
|
confirmedRound: number;
|
|
161
|
-
};
|
|
162
|
-
/** Result of creating a market order (includes match info) */
|
|
163
|
-
type CreateMarketOrderResult = CreateOrderResult & {
|
|
164
161
|
/** Total quantity that was matched */
|
|
165
|
-
matchedQuantity
|
|
162
|
+
matchedQuantity?: number;
|
|
166
163
|
/** Weighted average fill price in microunits (accounts for complementary matching) */
|
|
167
|
-
matchedPrice
|
|
164
|
+
matchedPrice?: number;
|
|
168
165
|
};
|
|
169
166
|
/** Result of cancelling an order */
|
|
170
167
|
type CancelOrderResult = {
|
|
@@ -375,7 +372,7 @@ declare class AlphaClient {
|
|
|
375
372
|
* @param params - Order parameters (marketAppId, position, price, quantity, isBuying, slippage)
|
|
376
373
|
* @returns The created escrow app ID, matched quantity, and transaction info
|
|
377
374
|
*/
|
|
378
|
-
createMarketOrder(params: CreateMarketOrderParams): Promise<
|
|
375
|
+
createMarketOrder(params: CreateMarketOrderParams): Promise<CreateOrderResult>;
|
|
379
376
|
/**
|
|
380
377
|
* Cancels an open order by deleting its escrow app.
|
|
381
378
|
*
|
|
@@ -629,4 +626,4 @@ declare const getEscrowGlobalState: (indexerClient: algosdk.Indexer, escrowAppId
|
|
|
629
626
|
*/
|
|
630
627
|
declare const checkAssetOptIn: (algodClient: algosdk.Algodv2, address: string, assetId: number) => Promise<boolean>;
|
|
631
628
|
|
|
632
|
-
export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type
|
|
629
|
+
export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_MARKET_CREATOR_ADDRESS, type EscrowGlobalState, type Market, type MarketGlobalState, type MarketOption, type MergeSharesParams, type OpenOrder, type OrderSide, type Orderbook, type OrderbookEntry, type OrderbookSide, type Position, type ProposeMatchParams, type ProposeMatchResult, type SplitMergeResult, type SplitSharesParams, type WalletPosition, calculateFee, calculateFeeFromTotal, calculateMatchingOrders, checkAssetOptIn, decodeGlobalState, getEscrowGlobalState, getLiveMarketsFromApi, getMarketFromApi, getMarketGlobalState, getMarketOnChain, getMarketsOnChain };
|
package/dist/index.js
CHANGED
|
@@ -1519,7 +1519,21 @@ var extractEscrowAppId = async (algodClient, indexerClient, targetTxId) => {
|
|
|
1519
1519
|
return 0;
|
|
1520
1520
|
};
|
|
1521
1521
|
var createLimitOrder = async (config, params) => {
|
|
1522
|
-
|
|
1522
|
+
const orderbook = await getOrderbook(config, params.marketAppId);
|
|
1523
|
+
const matchingOrders = calculateMatchingOrders(
|
|
1524
|
+
orderbook,
|
|
1525
|
+
params.isBuying,
|
|
1526
|
+
params.position === 1,
|
|
1527
|
+
params.quantity,
|
|
1528
|
+
params.price,
|
|
1529
|
+
0
|
|
1530
|
+
);
|
|
1531
|
+
const totalMatchedQuantity = matchingOrders.reduce((sum, o) => sum + o.quantity, 0);
|
|
1532
|
+
const matchedPrice = totalMatchedQuantity > 0 ? Math.round(
|
|
1533
|
+
matchingOrders.reduce((sum, o) => sum + (o.price ?? params.price) * o.quantity, 0) / totalMatchedQuantity
|
|
1534
|
+
) : params.price;
|
|
1535
|
+
const result = await createOrder(config, { ...params, slippage: 0, matchingOrders });
|
|
1536
|
+
return { ...result, matchedQuantity: totalMatchedQuantity, matchedPrice };
|
|
1523
1537
|
};
|
|
1524
1538
|
var createMarketOrder = async (config, params) => {
|
|
1525
1539
|
let matchingOrders = params.matchingOrders;
|