@alpha-arcade/sdk 0.2.11 → 0.3.1

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/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import algosdk, { Algodv2, Indexer, TransactionSigner } from 'algosdk';
1
+ import * as algosdk from 'algosdk';
2
+ import { Algodv2, Indexer, TransactionSigner } from 'algosdk';
2
3
 
3
4
  /** Configuration for initializing the AlphaClient */
4
5
  type AlphaClientConfig = {
@@ -146,6 +147,18 @@ type ProposeMatchParams = {
146
147
  /** Quantity to match in microunits */
147
148
  quantityMatched: number;
148
149
  };
150
+ /**
151
+ * Parameters for matching two existing limit orders (e.g. after an amend).
152
+ * The taker is the order placed last and pays the fee; the maker is the counterparty.
153
+ */
154
+ type ProcessMatchParams = {
155
+ /** Market app ID */
156
+ marketAppId: number;
157
+ /** Maker escrow app ID (existing order — was on the book first) */
158
+ makerEscrowAppId: number;
159
+ /** Taker escrow app ID (existing order — placed last, pays the fee) */
160
+ takerEscrowAppId: number;
161
+ };
149
162
  /** Parameters for amending (editing) an existing unfilled order */
150
163
  type AmendOrderParams = {
151
164
  /** Market app ID */
@@ -201,6 +214,15 @@ type ProposeMatchResult = {
201
214
  /** Confirmed round number */
202
215
  confirmedRound: number;
203
216
  };
217
+ /** Result of processing a match between two existing orders */
218
+ type ProcessMatchResult = {
219
+ /** Whether the match succeeded */
220
+ success: boolean;
221
+ /** Transaction IDs */
222
+ txIds: string[];
223
+ /** Confirmed round number */
224
+ confirmedRound: number;
225
+ };
204
226
  /** Result of amending an order */
205
227
  type AmendOrderResult = {
206
228
  /** Whether the amendment succeeded */
@@ -209,6 +231,10 @@ type AmendOrderResult = {
209
231
  txIds: string[];
210
232
  /** Confirmed round number */
211
233
  confirmedRound: number;
234
+ /** Total quantity matched against counterparty orders (if matching was performed) */
235
+ matchedQuantity?: number;
236
+ /** Volume-weighted average fill price in microunits (if any matches) */
237
+ matchedPrice?: number;
212
238
  };
213
239
  /** A single entry in the orderbook (one price level, one order) */
214
240
  type OrderbookEntry = {
@@ -360,7 +386,7 @@ type EscrowGlobalState = {
360
386
  * algodClient,
361
387
  * indexerClient,
362
388
  * signer,
363
- * activeAddress: account.addr,
389
+ * activeAddress: account.addr.toString(),
364
390
  * matcherAppId: 3078581851,
365
391
  * usdcAssetId: 31566704,
366
392
  * });
@@ -422,6 +448,17 @@ declare class AlphaClient {
422
448
  * @returns Whether the match succeeded
423
449
  */
424
450
  proposeMatch(params: ProposeMatchParams): Promise<ProposeMatchResult>;
451
+ /**
452
+ * Matches two existing limit orders (no create-escrow in the group).
453
+ *
454
+ * Calls the market app's process_potential_match(maker, taker). Use this
455
+ * after amending an order: the amended order is the taker (pays the fee),
456
+ * the counterparty is the maker.
457
+ *
458
+ * @param params - Process match params (marketAppId, makerEscrowAppId, takerEscrowAppId)
459
+ * @returns Whether the match succeeded
460
+ */
461
+ processMatch(params: ProcessMatchParams): Promise<ProcessMatchResult>;
425
462
  /**
426
463
  * Amends (edits) an existing unfilled order in-place.
427
464
  *
@@ -651,6 +688,7 @@ declare const calculateMatchingOrders: (orderbook: Orderbook, isBuying: boolean,
651
688
 
652
689
  /**
653
690
  * Decodes raw Algorand global state array into a key-value object.
691
+ * Supports both v2 (kebab-case) and v3 (camelCase) response shapes.
654
692
  *
655
693
  * @param rawState - The raw global-state array from algod/indexer
656
694
  * @returns Decoded key-value object
@@ -682,4 +720,4 @@ declare const getEscrowGlobalState: (indexerClient: algosdk.Indexer, escrowAppId
682
720
  */
683
721
  declare const checkAssetOptIn: (algodClient: algosdk.Algodv2, address: string, assetId: number) => Promise<boolean>;
684
722
 
685
- export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type AmendOrderParams, type AmendOrderResult, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_API_BASE_URL, 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 };
723
+ export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type AmendOrderParams, type AmendOrderResult, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_API_BASE_URL, 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 ProcessMatchParams, type ProcessMatchResult, 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
@@ -1,4 +1,5 @@
1
- import algosdk, { Algodv2, Indexer, TransactionSigner } from 'algosdk';
1
+ import * as algosdk from 'algosdk';
2
+ import { Algodv2, Indexer, TransactionSigner } from 'algosdk';
2
3
 
3
4
  /** Configuration for initializing the AlphaClient */
4
5
  type AlphaClientConfig = {
@@ -146,6 +147,18 @@ type ProposeMatchParams = {
146
147
  /** Quantity to match in microunits */
147
148
  quantityMatched: number;
148
149
  };
150
+ /**
151
+ * Parameters for matching two existing limit orders (e.g. after an amend).
152
+ * The taker is the order placed last and pays the fee; the maker is the counterparty.
153
+ */
154
+ type ProcessMatchParams = {
155
+ /** Market app ID */
156
+ marketAppId: number;
157
+ /** Maker escrow app ID (existing order — was on the book first) */
158
+ makerEscrowAppId: number;
159
+ /** Taker escrow app ID (existing order — placed last, pays the fee) */
160
+ takerEscrowAppId: number;
161
+ };
149
162
  /** Parameters for amending (editing) an existing unfilled order */
150
163
  type AmendOrderParams = {
151
164
  /** Market app ID */
@@ -201,6 +214,15 @@ type ProposeMatchResult = {
201
214
  /** Confirmed round number */
202
215
  confirmedRound: number;
203
216
  };
217
+ /** Result of processing a match between two existing orders */
218
+ type ProcessMatchResult = {
219
+ /** Whether the match succeeded */
220
+ success: boolean;
221
+ /** Transaction IDs */
222
+ txIds: string[];
223
+ /** Confirmed round number */
224
+ confirmedRound: number;
225
+ };
204
226
  /** Result of amending an order */
205
227
  type AmendOrderResult = {
206
228
  /** Whether the amendment succeeded */
@@ -209,6 +231,10 @@ type AmendOrderResult = {
209
231
  txIds: string[];
210
232
  /** Confirmed round number */
211
233
  confirmedRound: number;
234
+ /** Total quantity matched against counterparty orders (if matching was performed) */
235
+ matchedQuantity?: number;
236
+ /** Volume-weighted average fill price in microunits (if any matches) */
237
+ matchedPrice?: number;
212
238
  };
213
239
  /** A single entry in the orderbook (one price level, one order) */
214
240
  type OrderbookEntry = {
@@ -360,7 +386,7 @@ type EscrowGlobalState = {
360
386
  * algodClient,
361
387
  * indexerClient,
362
388
  * signer,
363
- * activeAddress: account.addr,
389
+ * activeAddress: account.addr.toString(),
364
390
  * matcherAppId: 3078581851,
365
391
  * usdcAssetId: 31566704,
366
392
  * });
@@ -422,6 +448,17 @@ declare class AlphaClient {
422
448
  * @returns Whether the match succeeded
423
449
  */
424
450
  proposeMatch(params: ProposeMatchParams): Promise<ProposeMatchResult>;
451
+ /**
452
+ * Matches two existing limit orders (no create-escrow in the group).
453
+ *
454
+ * Calls the market app's process_potential_match(maker, taker). Use this
455
+ * after amending an order: the amended order is the taker (pays the fee),
456
+ * the counterparty is the maker.
457
+ *
458
+ * @param params - Process match params (marketAppId, makerEscrowAppId, takerEscrowAppId)
459
+ * @returns Whether the match succeeded
460
+ */
461
+ processMatch(params: ProcessMatchParams): Promise<ProcessMatchResult>;
425
462
  /**
426
463
  * Amends (edits) an existing unfilled order in-place.
427
464
  *
@@ -651,6 +688,7 @@ declare const calculateMatchingOrders: (orderbook: Orderbook, isBuying: boolean,
651
688
 
652
689
  /**
653
690
  * Decodes raw Algorand global state array into a key-value object.
691
+ * Supports both v2 (kebab-case) and v3 (camelCase) response shapes.
654
692
  *
655
693
  * @param rawState - The raw global-state array from algod/indexer
656
694
  * @returns Decoded key-value object
@@ -682,4 +720,4 @@ declare const getEscrowGlobalState: (indexerClient: algosdk.Indexer, escrowAppId
682
720
  */
683
721
  declare const checkAssetOptIn: (algodClient: algosdk.Algodv2, address: string, assetId: number) => Promise<boolean>;
684
722
 
685
- export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type AmendOrderParams, type AmendOrderResult, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_API_BASE_URL, 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 };
723
+ export { type AggregatedOrderbook, type AggregatedOrderbookEntry, type AggregatedOrderbookSide, AlphaClient, type AlphaClientConfig, type AmendOrderParams, type AmendOrderResult, type CancelOrderParams, type CancelOrderResult, type ClaimParams, type ClaimResult, type CounterpartyMatch, type CreateLimitOrderParams, type CreateMarketOrderParams, type CreateOrderResult, DEFAULT_API_BASE_URL, 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 ProcessMatchParams, type ProcessMatchResult, type ProposeMatchParams, type ProposeMatchResult, type SplitMergeResult, type SplitSharesParams, type WalletPosition, calculateFee, calculateFeeFromTotal, calculateMatchingOrders, checkAssetOptIn, decodeGlobalState, getEscrowGlobalState, getLiveMarketsFromApi, getMarketFromApi, getMarketGlobalState, getMarketOnChain, getMarketsOnChain };