@runesx/api-client 0.5.2 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runesx/api-client",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A Node.js client for interacting with the RunesX platform API and WebSocket",
5
5
  "main": "src/index.mjs",
6
6
  "type": "module",
package/src/api.mjs CHANGED
@@ -181,7 +181,8 @@ export function createApi(config) {
181
181
  async function postSwap({ amountIn, path, minAmountOut, idempotencyKey }) {
182
182
  try {
183
183
  const key = idempotencyKey || randomUUID();
184
- const response = await api.post('/swap', { amountIn, path, minAmountOut }, {
184
+ const cleanPath = path.map(({ from, to }) => ({ from, to }));
185
+ const response = await api.post('/swap', { amountIn, path: cleanPath, minAmountOut }, {
185
186
  headers: { 'X-Idempotency-Key': key },
186
187
  });
187
188
  return response.data;
package/src/index.mjs CHANGED
@@ -154,8 +154,12 @@ export function createRunesXClient(options = {}) {
154
154
  deleteYardMessage: api.deleteYardMessage,
155
155
 
156
156
  // ---- Client-side estimation utilities ----
157
- estimateSwap: (inputCoin, outputCoin, amountIn, maxHops = 6, algorithm = 'dfs') =>
158
- estimateSwap(inputCoin, outputCoin, amountIn, getPools(), getCoins(), maxHops, algorithm, getAllOrderBooks(), getUserOrders(), getClobFees(), getMarketByCoinKey()),
157
+ // skipSelfTradeCheck: pass true when estimating on behalf of a different user
158
+ // (e.g. tipbot swaps) the API key user's CLOB orders would incorrectly
159
+ // trigger self-trade prevention against bids/asks that the actual swap user
160
+ // (a Discord user with no CLOB orders) would freely fill.
161
+ estimateSwap: (inputCoin, outputCoin, amountIn, maxHops = 6, algorithm = 'dfs', { skipSelfTradeCheck = false } = {}) =>
162
+ estimateSwap(inputCoin, outputCoin, amountIn, getPools(), getCoins(), maxHops, algorithm, getAllOrderBooks(), skipSelfTradeCheck ? null : getUserOrders(), getClobFees(), getMarketByCoinKey()),
159
163
  estimateLiquidityFrontend,
160
164
  estimateDepositShares: ({ pool, amountA, amountB, slippagePercent } = {}) =>
161
165
  estimateDepositShares({ pool, amountA, amountB, slippagePercent }),