@alpha-arcade/sdk 0.2.1 → 0.2.3

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.cjs CHANGED
@@ -1419,7 +1419,8 @@ var calculateMatchingOrders = (orderbook, isBuying, isYes, quantity, price, slip
1419
1419
  matches.push({
1420
1420
  escrowAppId: counterParty.escrowAppId,
1421
1421
  quantity: amountToTake,
1422
- owner: counterParty.owner
1422
+ owner: counterParty.owner,
1423
+ price: counterParty.price
1423
1424
  });
1424
1425
  volumeLeft -= amountToTake;
1425
1426
  }
@@ -1559,11 +1560,14 @@ var createMarketOrder = async (config, params) => {
1559
1560
  );
1560
1561
  }
1561
1562
  const totalMatchedQuantity = matchingOrders.reduce((sum, o) => sum + o.quantity, 0);
1563
+ const matchedPrice = totalMatchedQuantity > 0 ? Math.round(
1564
+ matchingOrders.reduce((sum, o) => sum + (o.price ?? params.price) * o.quantity, 0) / totalMatchedQuantity
1565
+ ) : params.price;
1562
1566
  const result = await createOrder(config, {
1563
1567
  ...params,
1564
1568
  matchingOrders
1565
1569
  });
1566
- return { ...result, matchedQuantity: totalMatchedQuantity };
1570
+ return { ...result, matchedQuantity: totalMatchedQuantity, matchedPrice };
1567
1571
  };
1568
1572
  var createOrder = async (config, params) => {
1569
1573
  const { algodClient, indexerClient, signer, activeAddress, matcherAppId, usdcAssetId } = config;
@@ -1695,7 +1699,8 @@ var cancelOrder = async (config, params) => {
1695
1699
  const result = await atc.execute(algodClient, 4);
1696
1700
  return {
1697
1701
  success: true,
1698
- txIds: result.txIDs
1702
+ txIds: result.txIDs,
1703
+ confirmedRound: result.confirmedRound
1699
1704
  };
1700
1705
  };
1701
1706
  var proposeMatch = async (config, params) => {
@@ -1741,7 +1746,8 @@ var proposeMatch = async (config, params) => {
1741
1746
  const result = await atc.execute(algodClient, 4);
1742
1747
  return {
1743
1748
  success: true,
1744
- txIds: result.txIDs
1749
+ txIds: result.txIDs,
1750
+ confirmedRound: result.confirmedRound
1745
1751
  };
1746
1752
  };
1747
1753
  var splitShares = async (config, params) => {
@@ -1895,7 +1901,8 @@ var claim = async (config, params) => {
1895
1901
  return {
1896
1902
  success: true,
1897
1903
  txIds: result.txIDs,
1898
- confirmedRound: result.confirmedRound
1904
+ confirmedRound: result.confirmedRound,
1905
+ amountClaimed: tokenBalance
1899
1906
  };
1900
1907
  };
1901
1908
  var getPositions = async (config, walletAddress) => {
@@ -1932,14 +1939,17 @@ var getPositions = async (config, walletAddress) => {
1932
1939
  if (!rawState) continue;
1933
1940
  let yesAssetIdOnChain = 0;
1934
1941
  let noAssetIdOnChain = 0;
1942
+ let marketTitle = "";
1935
1943
  for (const item of rawState) {
1936
1944
  const key = Buffer.from(item.key, "base64").toString();
1937
1945
  if (key === "yes_asset_id") yesAssetIdOnChain = Number(item.value.uint);
1938
1946
  if (key === "no_asset_id") noAssetIdOnChain = Number(item.value.uint);
1947
+ if (key === "title") marketTitle = Buffer.from(item.value.bytes, "base64").toString();
1939
1948
  }
1940
1949
  if (yesAssetIdOnChain === 0 && noAssetIdOnChain === 0) continue;
1941
1950
  positions.set(marketAppId, {
1942
1951
  marketAppId,
1952
+ title: marketTitle,
1943
1953
  yesAssetId: yesAssetIdOnChain,
1944
1954
  noAssetId: noAssetIdOnChain,
1945
1955
  yesBalance: side === "Yes" ? amount : 0,