@axis-markets/client 0.3.0 → 0.4.0

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  JavaScript SDK for [AXIS](https://axis.markets) Stellar DEX.
4
4
 
5
5
  - **`AxisContractClient`** — wraps the on-chain AXIS smart contract for order management and trading (sign & send transactions, read orders).
6
- - **`ApiClient`** — a dependency-free HTTP client for the AXIS Aggregator and Indexer REST API (quotes, orderbook depth, candles, ticker, market/order/trade data).
6
+ - **`AxisApiClient`** — a dependency-free HTTP client for the AXIS Aggregator and Indexer REST API (quotes, orderbook depth, candles, ticker, market/order/trade data).
7
7
 
8
8
  ## Installation
9
9
 
@@ -13,7 +13,6 @@ npm i @axis-markets/client
13
13
 
14
14
  Requires Node.js 20+ (or any modern browser).
15
15
 
16
-
17
16
  ## AxisContractClient
18
17
 
19
18
  Wraps the on-chain AXIS smart contract for trading and order management.
@@ -51,15 +50,165 @@ await client.cancel([lastId], 'G...')
51
50
 
52
51
  See [`src/index.d.ts`](src/index.d.ts) for the full typed API (`buy`, `sell`, `swap`, `fill_order`, `cancel`, `order`, `last`).
53
52
 
53
+ ### Methods
54
+
55
+ | Method | Description |
56
+ |---|---|
57
+ | `last()` | Retrieve the last created order id. Returns `Promise<bigint>`. |
58
+ | `order(id)` | Fetch an order by id from on-chain storage. Returns `Promise<Order>`. |
59
+ | `cancel(ids, trader)` | Cancel existing orders (`ids` is a `bigint[]`, `trader` is the owner address). Returns `Promise<void>`. |
60
+ | `fill_order(trader, takerOrderId, orders)` | Fill existing orders using another matching order from the orderbook. Returns `Promise<[sold, bought]>`. |
61
+ | `buy(params)` | Trade with the DEX and create a buy limit order if the quote is not fully executed (`params: BuyTradeArguments`). Returns `Promise<[sold, bought, newOrderId]>`. |
62
+ | `sell(params)` | Trade with the DEX and create a sell limit order if the quote is not fully executed (`params: SellTradeArguments`). Returns `Promise<[sold, bought, newOrderId]>`. |
63
+ | `swap(params)` | Swap tokens across several markets along a route (`params: SwapArguments`). Returns `Promise<[sold, bought]>`. |
64
+
65
+ ### Types
66
+
67
+ #### `OrderKind`
68
+
69
+ Trading order type — instructions to the contract on how to execute the trade.
70
+
71
+ | Value | Numeric | Description |
72
+ |---|---|---|
73
+ | `Limit` | `1` | Execute the trade, creating a limit order if not executed in full. |
74
+ | `Fill` | `2` | Execute the trade without creating a limit order. |
75
+ | `FillOrKill` | `3` | Execute the trade, cancel if it was not executed in full. |
76
+
77
+ #### `TradeDirection`
78
+
79
+ Trade direction instructions.
80
+
81
+ | Value | Numeric | Description |
82
+ |---|---|---|
83
+ | `Sell` | `1` | Sell the base asset. |
84
+ | `Buy` | `2` | Buy the base asset. |
85
+
86
+ #### `ClientInitializationParams`
87
+
88
+ Parameters passed to the `AxisContractClient` constructor.
89
+
90
+ | Property | Type | Description |
91
+ |---|---|---|
92
+ | `publicKey` | `string` | Public key of the account that will interact with the contract. |
93
+ | `signTransaction` | `SignTransactionCallback` | Callback for signing transactions generated by the client. |
94
+ | `rpcUrl` | `string` | URL of the RPC server. |
95
+ | `contractId` | `string` | DEX contract id. |
96
+ | `networkPassphrase?` | `string` | Network passphrase (Pubnet passphrase by default). |
97
+ | `fee?` | `string` | Transaction fee (0.1 XLM by default). |
98
+
99
+ #### `SignTransactionCallback`
100
+
101
+ `(tx: string, context: {network, networkPassphrase, accountToSign}) => Promise<{signedTxXdr, signerAddress?}>`
102
+
103
+ Callback for signing transactions generated by the client. Receives the transaction XDR to sign plus the signing context, and resolves to the signed transaction response.
104
+
105
+ #### `TradeArguments`
106
+
107
+ Base arguments shared by `buy` and `sell`.
108
+
109
+ | Property | Type | Description |
110
+ |---|---|---|
111
+ | `kind` | `OrderKind` | Trading order behavior. |
112
+ | `trader` | `string` | Trader address. |
113
+ | `amount` | `bigint` | Tokens amount. |
114
+ | `selling` | `string` | Selling token address. |
115
+ | `buying` | `string` | Buying token address. |
116
+ | `price` | `bigint` | Price a trader is willing to accept. |
117
+ | `orders` | `bigint[]` | List of order IDs to match before creating the order on-chain. |
118
+
119
+ #### `SellTradeArguments`
120
+
121
+ Extends `TradeArguments` (passed to `sell`).
122
+
123
+ | Property | Type | Description |
124
+ |---|---|---|
125
+ | `amount` | `bigint` | Amount of `selling` tokens to sell. |
126
+ | `price` | `bigint` | Price a trader is willing to accept — minimum `buying` tokens per 1 `selling`. |
127
+
128
+ #### `BuyTradeArguments`
129
+
130
+ Extends `TradeArguments` (passed to `buy`).
131
+
132
+ | Property | Type | Description |
133
+ |---|---|---|
134
+ | `amount` | `bigint` | Amount of `buying` tokens to acquire. |
135
+ | `price` | `bigint` | Price a trader is willing to accept — maximum `selling` tokens per 1 `buying`. |
136
+
137
+ #### `TradeStep`
138
+
139
+ A trade step in a multi-market swap path.
140
+
141
+ | Property | Type | Description |
142
+ |---|---|---|
143
+ | `asset` | `string` | Asset to buy at this step. |
144
+ | `orders` | `bigint[]` | Maker order IDs to match. |
145
+
146
+ #### `SwapArguments`
147
+
148
+ Arguments passed to `swap`.
149
+
150
+ | Property | Type | Description |
151
+ |---|---|---|
152
+ | `direction` | `TradeDirection` | Trade direction: `Sell` or `Buy`. |
153
+ | `trader` | `string` | Trader address. |
154
+ | `selling` | `string` | Token address sent by the trader. |
155
+ | `sellingAmount` | `bigint` | Maximum amount of selling tokens to send. |
156
+ | `buyingAmount` | `bigint` | Minimum amount of buying tokens to receive. |
157
+ | `path` | `TradeStep[]` | Ordered list of the trade route steps. |
158
+
159
+ #### `Order`
160
+
161
+ Order properties, stored on-chain (returned by `order()` call).
162
+
163
+ | Property | Type | Description |
164
+ |---|---|---|
165
+ | `id` | `bigint` | Order ID. |
166
+ | `kind` | `OrderKind` | Trading behavior. |
167
+ | `owner` | `string` | Owner of the order. |
168
+ | `selling` | `string` | Selling token address. |
169
+ | `buying` | `string` | Buying token address. |
170
+ | `amount` | `bigint` | Amount of tokens to sell. |
171
+ | `price` | `bigint` | Price of the order. |
172
+ | `quote` | `bigint` | Total amount of tokens to buy. |
173
+ | `expires` | `bigint` | Expiration time of the order. |
174
+
175
+ #### `TradeContractEvent`
176
+
177
+ Orderbook trade event emitted by the contract.
178
+
179
+ | Property | Type | Description |
180
+ |---|---|---|
181
+ | `id` | `bigint` | Unique trade id. |
182
+ | `order` | `bigint` | Order id. |
183
+ | `taker` | `string` | Trader account address. |
184
+ | `maker` | `string` | Seller account address. |
185
+ | `selling` | `string` | Sold asset address. |
186
+ | `buying` | `string` | Bought asset address. |
187
+ | `sold` | `bigint` | Sold tokens amount. |
188
+ | `bought` | `bigint` | Bought tokens amount. |
189
+
190
+ #### `SwapContractEvent`
191
+
192
+ Orderbook swap event emitted by the contract.
193
+
194
+ | Property | Type | Description |
195
+ |---|---|---|
196
+ | `id` | `bigint` | Unique swap id (last trade id assigned while settling the swap legs). |
197
+ | `trader` | `string` | Trader account address. |
198
+ | `selling` | `string` | Sold asset address. |
199
+ | `buying` | `string` | Bought asset address. |
200
+ | `sold` | `bigint` | Amount of `selling` tokens sold. |
201
+ | `bought` | `bigint` | Amount of `buying` tokens received. |
202
+
54
203
 
55
- ## ApiClient
204
+ ## AxisApiClient
56
205
 
57
206
  HTTP client for the AXIS Aggregator REST API. Uses the standard `fetch` API - no extra dependencies.
58
207
 
59
208
  ```js
60
- import {ApiClient, AxisApiError} from '@axis-markets/client'
209
+ import {AxisApiClient, AxisApiError} from '@axis-markets/client'
61
210
 
62
- const api = new ApiClient('https://aggregator.axis.markets')
211
+ const api = new AxisApiClient('https://aggregator.axis.markets')
63
212
 
64
213
  // Quote: sell a fixed amount of the source asset (strict send)
65
214
  const sellQuote = await api.quoteSell({
@@ -85,7 +234,7 @@ const candles = await api.getCandles({market: 'XLM/USDC', resolution: '1h', orde
85
234
  const {ticker} = await api.getTicker24h()
86
235
  ```
87
236
 
88
- ### ApiClient Methods
237
+ ### AxisApiClient Methods
89
238
 
90
239
  | Method | Description |
91
240
  |---|---|
@@ -0,0 +1,2 @@
1
+ !function(A,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@stellar/stellar-sdk")):"function"==typeof define&&define.amd?define(["@stellar/stellar-sdk"],t):"object"==typeof exports?exports.axisClient=t(require("@stellar/stellar-sdk")):A.axisClient=t(A["@stellar/stellar-sdk"])}(this,A=>(()=>{"use strict";var t={346(t){t.exports=A}},l={};function c(A){var e=l[A];if(void 0!==e)return e.exports;var r=l[A]={exports:{}};return t[A](r,r.exports,c),r.exports}c.d=(A,t)=>{for(var l in t)c.o(t,l)&&!c.o(A,l)&&Object.defineProperty(A,l,{enumerable:!0,get:t[l]})},c.o=(A,t)=>Object.prototype.hasOwnProperty.call(A,t);var e={};c.d(e,{default:()=>g});var r=c(346);class G extends r.contract.Client{options;constructor(A){super(new r.contract.Spec(["AAAAAAAAADJHZXQgbGF0IG9yZGVyIGlkCgojIFJldHVybnMKCkxhc3QgY3JlYXRlZCBvcmRlciBpZAAAAAAABGxhc3QAAAAAAAAAAQAAAAY=","AAAAAAAAA4ZTd2FwIHRva2VucyBhY3Jvc3Mgc2V2ZXJhbCBtYXJrZXRzLgpUaGUgc3dhcCBleGVjdXRlcyB3aXRoaW4gdGhlIGJvdW5kYXJpZXMsIG90aGVyd2lzZSB0cmFkZSBnZXQgY2FuY2VsZWQ6CiogYFNlbGxgOiBleGFjdGx5IGBzZWxsaW5nX2Ftb3VudGAgc29sZCwgdGhlIHJlY2VpdmVkIGFtb3VudCBpcyBgPj0gYnV5aW5nX2Ftb3VudGAKKiBgQnV5YDogZXhhY3RseSBgYnV5aW5nX2Ftb3VudGAgcmVjZWl2ZWQsIHRoZSBzcGVudCBhbW91bnQgaXMgYDw9IHNlbGxpbmdfYW1vdW50YAoKCiMgQXJndW1lbnRzCiogYGRpcmVjdGlvbmAgLSBUcmFkZSBkaXJlY3Rpb246IGBTZWxsYCBvciBgQnV5YAoqIGB0cmFkZXJgIC0gVHJhZGVyIGFkZHJlc3MKKiBgc2VsbGluZ2AgLSBUb2tlbiBhZGRyZXNzIHNlbnQgYnkg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),A),this.options=A}fromJSON={last:this.txFromJSON,order:this.txFromJSON,cancel:this.txFromJSON,trade:this.txFromJSON,swap:this.txFromJSON,fill_order:this.txFromJSON}}const s={701:{message:"NotAuthorized"},702:{message:"InsufficientBalance"},703:{message:"OrderNotFound"},704:{message:"Overflow"},705:{message:"InvalidMatch"},706:{message:"InvalidPrice"}};function Z(A){if(A.simulation.error){const t=/HostError: Error\(Contract, #(\d+)\)/.exec(A.simulation.error);if(t){const A=t[1],l=s[A];if(l)throw new Error(`Contract execution error: #${A} ${l.message} `)}throw A.simulation.error}}class B extends Error{constructor(A,t){super(A),this.name="AxisApiError",this.status=t}status}const a={Sell:1,Buy:2};async function d(A,t,l){const c={direction:t,kind:A.kind,trader:A.trader,amount:A.amount,selling:A.selling,buying:A.buying,price:A.price,orders:A.orders},e=await l.client.trade(c,{fee:l.fee});Z(e);const{result:r}=await e.signAndSend();return[r[0],r[1],r[2]]}const g={AxisContractClient:class{constructor(A){const t={publicKey:A.publicKey,signTransaction:A.signTransaction,rpcUrl:A.rpcUrl,allowHttp:!0,networkPassphrase:A.networkPassphrase||r.Networks.PUBLIC,contractId:A.contractId};this.client=new G(t),this.fee=A.fee||"100000"}async last(){const A=await this.client.last();return Z(A),A.result}async order(A){const t=await this.client.order({id:A});return Z(t),t.result}async cancel(A,t){const l=await this.client.cancel({ids:A,trader:t},{fee:this.fee});Z(l),await l.signAndSend()}async fill_order(A,t,l){const c=await this.client.fill_order({trader:A,taker_order_id:t,orders:l},{fee:this.fee});Z(c);const e=await c.signAndSend();return[e.result.sold,e.result.bought]}async buy(A){return await d(A,a.Buy,this)}async sell(A){return await d(A,a.Sell,this)}async swap(A){const t=await this.client.swap({direction:A.direction,trader:A.trader,selling:A.selling,selling_amount:A.sellingAmount,buying_amount:A.buyingAmount,path:A.path.map(A=>({asset:A.asset,orders:A.orders}))},{fee:this.fee});Z(t);const l=await t.signAndSend();return[l.result.sold,l.result.bought]}},ContractErrors:s,TradeDirection:a,OrderKind:{Limit:1,Fill:2,FillOrKill:3},AxisApiClient:class{constructor(A){if(!A||"string"!=typeof A)throw new TypeError("Aggregator server URL is required");this.serverUrl=A.replace(/\/+$/,"")}serverUrl;async quoteSell(A){return this.quote(A,"strict_send")}async quoteBuy(A){return this.quote(A,"strict_receive")}async quote({sellingAsset:A,buyingAsset:t,amount:l,direct:c},e){return this.request("/quote",{sellingAsset:A,buyingAsset:t,amount:l,direction:e,direct:c})}async getDepth({market:A,depth:t}){return this.request("/depth",{market:A,depth:t})}async getCandles({market:A,from:t,to:l,resolution:c,order:e}){return this.request("/candles",{market:A,from:t,to:l,resolution:c,order:e})}async getTicker24h(){return this.request("/ticker/24h")}async getMarkets({cursor:A,limit:t}={}){return this.request("/markets",{cursor:A,limit:t})}async getOrders({owner:A,asset:t,cursor:l,limit:c}={}){return this.request("/order",{owner:A,asset:t,cursor:l,limit:c})}async getOrder(A){return this.request(`/order/${encodeURIComponent(A.toString())}`)}async getOrderHistory({owner:A,pair:t,cursor:l,limit:c}={}){return this.request("/order-history",{owner:A,pair:t,cursor:l,limit:c})}async getTrades({trader:A,pair:t,cursor:l,limit:c}={}){return this.request("/trades",{trader:A,pair:t,cursor:l,limit:c})}async request(A,t){let l=this.serverUrl+A;if(t){const A=new URLSearchParams;for(const[l,c]of Object.entries(t))if(null!=c)if(Array.isArray(c))for(const t of c)A.append(l,t);else A.append(l,c);const c=A.toString();c&&(l+="?"+c)}const c=await fetch(l);let e;try{e=await c.json()}catch(A){e=null}if(!c.ok)throw new B(e?.error||c.statusText,e?.status||c.status);return e}},AxisApiError:B};return e.default})());
2
+ //# sourceMappingURL=axis-client.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axis-client.cjs","mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,yBACA,mBAAAC,QAAAA,OAAAC,IACAD,OAAA,yBAAAJ,GACA,iBAAAC,QACAA,QAAA,WAAAD,EAAA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CAAC,GAC7C,OAAO3H,KAAKgH,QAAQ,UAAW,CAACnD,SAAQqE,OAAMR,SAAQC,SAC1D,CAUA,aAAMX,CAAQlB,EAAMsC,GAChB,IAAIC,EAAMrI,KAAKuG,UAAYT,EAC3B,GAAIsC,EAAO,CACP,MAAME,EAAS,IAAIC,gBACnB,IAAK,MAAO7H,EAAK8H,KAAU5H,OAAO6H,QAAQL,GACtC,GAAII,QAEJ,GAAIE,MAAMC,QAAQH,GACd,IAAK,MAAMI,KAAQJ,EACfF,EAAOO,OAAOnI,EAAKkI,QAEvBN,EAAOO,OAAOnI,EAAK8H,GAG3B,MAAMM,EAAKR,EAAON,WACdc,IACAT,GAAO,IAAMS,EACrB,CACA,MAAMC,QAAiBC,MAAMX,GAC7B,IAAIY,EACJ,IACIA,QAAaF,EAASG,MAC1B,CAAE,MAAOC,GAELF,EAAO,IACX,CACA,IAAKF,EAASK,GACV,MAAM,IAAIpG,EAAaiG,GAAMvG,OAASqG,EAASM,WAAYJ,GAAMhG,QAAU8F,EAAS9F,QACxF,OAAOgG,CACX,GEpL8FjG,aAAYA","sources":["webpack://axisClient/webpack/universalModuleDefinition","webpack://axisClient/external umd \"@stellar/stellar-sdk\"","webpack://axisClient/webpack/bootstrap","webpack://axisClient/webpack/runtime/define property getters","webpack://axisClient/webpack/runtime/hasOwnProperty shorthand","webpack://axisClient/./src/contract-client.js","webpack://axisClient/./src/errors.js","webpack://axisClient/./src/api-client.js","webpack://axisClient/./src/index.js","webpack://axisClient/./src/cjs.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@stellar/stellar-sdk\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@stellar/stellar-sdk\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axisClient\"] = factory(require(\"@stellar/stellar-sdk\"));\n\telse\n\t\troot[\"axisClient\"] = factory(root[\"@stellar/stellar-sdk\"]);\n})(this, (__WEBPACK_EXTERNAL_MODULE__346__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__346__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import {contract} from '@stellar/stellar-sdk'\r\n\r\nexport default class ContractClient extends contract.Client {\r\n options\r\n\r\n constructor(options) {\r\n super(new contract.Spec([\r\n \"AAAAAAAAADJHZXQgbGF0IG9yZGVyIGlkCgojIFJldHVybnMKCkxhc3QgY3JlYXRlZCBvcmRlciBpZAAAAAAABGxhc3QAAAAAAAAAAQAAAAY=\",\r\n \"AAAAAAAAA4ZTd2FwIHRva2VucyBhY3Jvc3Mgc2V2ZXJhbCBtYXJrZXRzLgpUaGUgc3dhcCBleGVjdXRlcyB3aXRoaW4gdGhlIGJvdW5kYXJpZXMsIG90aGVyd2lzZSB0cmFkZSBnZXQgY2FuY2VsZWQ6CiogYFNlbGxgOiBleGFjdGx5IGBzZWxsaW5nX2Ftb3VudGAgc29sZCwgdGhlIHJlY2VpdmVkIGFtb3VudCBpcyBgPj0gYnV5aW5nX2Ftb3VudGAKKiBgQnV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3MAAAAGYnV5aW5nAAAAAAATAAAAAQAAAA1PcmRlciBkZXRhaWxzAAAAAAAABW9yZGVyAAAAAAAH0AAAAAVPcmRlcgAAAAAAAAAAAAAA\",\r\n \"AAAABQAAAAAAAAAAAAAAClRyYWRlRXZlbnQAAAAAAAIAAAAEQVhJUwAAAAV0cmFkZQAAAAAAAAMAAAASU29sZCBhc3NldCBhZGRyZXNzAAAAAAAHc2VsbGluZwAAAAATAAAAAQAAABRCb3VnaHQgYXNzZXQgYWRkcmVzcwAAAAZidXlpbmcAAAAAABMAAAABAAAADVRyYWRlIGRldGFpbHMAAAAAAAAFdHJhZGUAAAAAAAfQAAAABVRyYWRlAAAAAAAAAAAAAAA=\"\r\n ]), options)\r\n this.options = options\r\n }\r\n\r\n fromJSON = {\r\n last: this.txFromJSON,\r\n order: this.txFromJSON,\r\n cancel: this.txFromJSON,\r\n trade: this.txFromJSON,\r\n swap: this.txFromJSON,\r\n fill_order: this.txFromJSON\r\n }\r\n}","/**\r\n * Standard contract errors\r\n */\r\nexport const ContractErrors = {\r\n 701: {message: \"NotAuthorized\"},\r\n 702: {message: \"InsufficientBalance\"},\r\n 703: {message: \"OrderNotFound\"},\r\n 704: {message: \"Overflow\"},\r\n 705: {message: \"InvalidMatch\"},\r\n 706: {message: \"InvalidPrice\"}\r\n}\r\n/**\r\n * Handle simulation errors if any\r\n * @param {AssembledTransaction} tx\r\n * @internal\r\n */\r\nexport function processSimulationErrors(tx) {\r\n if (tx.simulation.error) {\r\n const contractErrorMatch = /HostError: Error\\(Contract, #(\\d+)\\)/.exec(tx.simulation.error)\r\n if (contractErrorMatch) {\r\n const code = contractErrorMatch[1]\r\n const err = ContractErrors[code]\r\n if (err) {\r\n throw new Error(`Contract execution error: #${code} ${err.message} `)\r\n }\r\n }\r\n throw tx.simulation.error\r\n }\r\n}","/**\n * Error thrown when the Aggregator API responds with a non-success HTTP status\n */\nexport class AxisApiError extends Error {\n /**\n * @param {string} message - Error message returned by the API\n * @param {number} status - HTTP status code\n */\n constructor(message, status) {\n super(message)\n this.name = 'AxisApiError'\n this.status = status\n }\n\n /**\n * HTTP status code associated with the error\n * @type {number}\n * @readonly\n */\n status\n}\n\n/**\n * HTTP client for the AXIS Aggregator REST API\n */\nexport class AxisApiClient {\n /**\n * @param {string} serverUrl - Base URL of the Aggregator server\n */\n constructor(serverUrl) {\n if (!serverUrl || typeof serverUrl !== 'string')\n throw new TypeError('Aggregator server URL is required')\n //trim trailing slashes to avoid double slashes when building request paths\n this.serverUrl = serverUrl.replace(/\\/+$/, '')\n }\n\n /**\n * Base URL of the Aggregator server\n * @type {string}\n * @readonly\n */\n serverUrl\n\n /**\n * Price quote and candidate trade routes for selling a fixed amount of the source asset\n * @param {QuoteParams} params - Quote request parameters\n * @return {Promise<QuoteResult>} - Best routes ranked by profitability\n * @throws {AxisApiError} - If the server is not ready or there is not enough liquidity\n */\n async quoteSell(params) {\n return this.quote(params, 'strict_send')\n }\n\n /**\n * Price quote and candidate trade routes for buying a fixed amount of the destination asset\n * @param {QuoteParams} params - Quote request parameters\n * @return {Promise<QuoteResult>} - Best routes ranked by profitability\n * @throws {AxisApiError} - If the server is not ready or there is not enough liquidity\n */\n async quoteBuy(params) {\n return this.quote(params, 'strict_receive')\n }\n\n /**\n * Find viable multi-hop paths between two assets, simulate trades on each path, and return the best routes\n * @param {QuoteParams} params - Quote request parameters\n * @param {'strict_send'|'strict_receive'} direction - Trade direction\n * @return {Promise<QuoteResult>}\n * @private\n */\n async quote({sellingAsset, buyingAsset, amount, direct}, direction) {\n return this.request('/quote', {sellingAsset, buyingAsset, amount, direction, direct})\n }\n\n /**\n * Order book depth aggregated into price buckets around the mid price\n * @param {DepthParams} params - Depth request parameters\n * @return {Promise<OrderbookDepth>} - Aggregated bids and asks\n */\n async getDepth({market, depth}) {\n return this.request('/depth', {market, depth})\n }\n\n /**\n * OHLCVT candlestick data (open, high, low, close, base volume, quote volume, trade count)\n * @param {CandlesParams} params - Candles request parameters\n * @return {Promise<Candle[]>} - Time-bucketed candles, max 200 per response\n */\n async getCandles({market, from, to, resolution, order}) {\n return this.request('/candles', {market, from, to, resolution, order})\n }\n\n /**\n * 24-hour ticker statistics for every available market\n * @return {Promise<Ticker24hResult>} - Aggregated 24h stats per market\n */\n async getTicker24h() {\n return this.request('/ticker/24h')\n }\n\n /**\n * List all active markets with pagination\n * @param {MarketsParams} [params] - Pagination parameters\n * @return {Promise<MarketInfo[]>} - Active markets\n */\n async getMarkets({cursor, limit} = {}) {\n return this.request('/markets', {cursor, limit})\n }\n\n /**\n * Retrieve active orders, filterable by owner or asset\n * @param {OrdersParams} [params] - Filter parameters\n * @return {Promise<ApiOrder[]>} - Active orders matching the filter\n */\n async getOrders({owner, asset, cursor, limit} = {}) {\n return this.request('/order', {owner, asset, cursor, limit})\n }\n\n /**\n * Retrieve a single order by ID\n * @param {bigint|string|number} id - Order ID\n * @return {Promise<ApiOrder|null>} - Order, or null if not found\n */\n async getOrder(id) {\n return this.request(`/order/${encodeURIComponent(id.toString())}`)\n }\n\n /**\n * Retrieve archived/historical orders\n * @param {OrderHistoryParams} [params] - Filter parameters\n * @return {Promise<ApiOrder[]>} - Archived orders matching the filter\n */\n async getOrderHistory({owner, pair, cursor, limit} = {}) {\n return this.request('/order-history', {owner, pair, cursor, limit})\n }\n\n /**\n * Retrieve recent trades\n * @param {TradesParams} [params] - Filter parameters\n * @return {Promise<ApiTrade[]>} - Recent trades matching the filter\n */\n async getTrades({trader, pair, cursor, limit} = {}) {\n return this.request('/trades', {trader, pair, cursor, limit})\n }\n\n /**\n * Execute a GET request against the Aggregator API\n * @param {string} path - Relative route path\n * @param {object} [query] - Query parameters (undefined/null values skipped, arrays expanded to repeated params)\n * @return {Promise<*>} - Parsed JSON response\n * @throws {AxisApiError} - If the API responds with a non-success status\n * @private\n */\n async request(path, query) {\n let url = this.serverUrl + path\n if (query) {\n const search = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null)\n continue\n if (Array.isArray(value)) {\n for (const item of value)\n search.append(key, item)\n } else {\n search.append(key, value)\n }\n }\n const qs = search.toString()\n if (qs)\n url += '?' + qs\n }\n const response = await fetch(url)\n let body\n try {\n body = await response.json()\n } catch (e) {\n //non-JSON response (e.g. proxy/gateway error) - fall back to status text\n body = null\n }\n if (!response.ok)\n throw new AxisApiError(body?.error || response.statusText, body?.status || response.status)\n return body\n }\n}\n\n/**\n * @typedef {{}} QuoteParams\n * @property {string} sellingAsset - Asset to sell (`XLM` | `CODE:Issuer` | `CODE-Issuer` | contractId)\n * @property {string} buyingAsset - Asset to buy (same format as `sellingAsset`)\n * @property {string|number} amount - Trade amount in stroops (1 unit = 10,000,000 stroops)\n * @property {boolean} [direct] - Restrict to the direct market only (no intermediate-asset routes)\n */\n\n/**\n * @typedef {{}} QuoteResult\n * @property {string} id - Base58-encoded quote id\n * @property {'success'|'unfeasible'|'rejected'} status - Quote status\n * @property {'strict_send'|'strict_receive'} direction - Trade direction\n * @property {string} sellingAsset - Selling asset contract id\n * @property {string} buyingAsset - Buying asset contract id\n * @property {number} ledger - Ledger sequence the quote was computed for\n * @property {QuotePath[]} paths - Candidate routes ranked by profitability (up to 10)\n * @property {string} [error] - Error message (present only if status is not `success`)\n */\n\n/**\n * @typedef {{}} QuotePath\n * @property {string} sold - Amount sold, in stroops\n * @property {string} bought - Amount bought, in stroops\n * @property {QuotePathStep[]} path - Ordered list of hops in the route\n */\n\n/**\n * @typedef {{}} QuotePathStep\n * @property {string} selling - Selling asset contract id at this hop\n * @property {string} buying - Buying asset contract id at this hop\n * @property {string[]} orders - Maker order IDs matched at this hop\n */\n\n/**\n * @typedef {{}} DepthParams\n * @property {string} market - Market identifier `BASE/QUOTE`\n * @property {number} [depth] - Percentage band (±) around the center price (0 < depth ≤ 100, default 20)\n */\n\n/**\n * @typedef {{}} OrderbookDepth\n * @property {number} ledger - Ledger sequence\n * @property {number} timestamp - UNIX timestamp (seconds)\n * @property {Array<[string, string]>} bids - `[price, quantity]` pairs sorted descending by price\n * @property {Array<[string, string]>} asks - `[price, quantity]` pairs sorted ascending by price\n */\n\n/**\n * @typedef {{}} CandlesParams\n * @property {string} market - Market identifier `BASE/QUOTE`\n * @property {number} [from] - Lower boundary (UNIX seconds, default 0)\n * @property {number} [to] - Upper boundary (UNIX seconds, defaults to `from + resolution * 200`)\n * @property {number|string} [resolution] - Resolution in seconds or alias (`5m`,`15m`,`30m`,`1h`,`2h`,`4h`,`12h`,`1d`,`3d`,`1w`,`2w`, default `auto`)\n * @property {'asc'|'desc'} [order] - Sort order (default `desc`)\n */\n\n/**\n * OHLCVT candle row: `[timestamp, open, high, low, close, baseVolume, quoteVolume, tradeCount]`\n * @typedef {[number, string, string, string, string, string, string, number]} Candle\n */\n\n/**\n * @typedef {{}} Ticker24hResult\n * @property {number} ledger - Ledger sequence\n * @property {number} timestamp - UNIX timestamp (seconds)\n * @property {TickerEntry[]} ticker - Per-market 24h stats, sorted by trade count descending\n */\n\n/**\n * @typedef {{}} TickerEntry\n * @property {string} symbol - Market symbol `BASE/QUOTE`\n * @property {string} openPrice - Opening price 24h ago\n * @property {string} highPrice - Highest price in the 24h window\n * @property {string} lowPrice - Lowest price in the 24h window\n * @property {string} lastPrice - Most recent trade price\n * @property {string} volume - 24h base asset volume\n * @property {string} quoteVolume - 24h quote asset volume\n * @property {number} change - 24h price change (percent)\n * @property {string} avgPrice - Volume-weighted average price\n * @property {number} trades - 24h trade count\n */\n\n/**\n * @typedef {{}} MarketsParams\n * @property {string} [cursor] - Pagination cursor (`baseAsset-quoteAsset`)\n * @property {number|string} [limit] - Max markets to return\n */\n\n/**\n * @typedef {{}} MarketInfo\n * @property {string} baseAsset - Base asset contract id\n * @property {string} quoteAsset - Quote asset contract id\n * @property {string} cursor - Pagination cursor for this market\n * @property {string[]} orderTypes - Supported order types\n */\n\n/**\n * @typedef {{}} OrdersParams\n * @property {string} [owner] - Filter by order owner address\n * @property {string|string[]} [asset] - Filter by asset(s) - matches orders selling or buying any of them\n * @property {string|bigint} [cursor] - Pagination cursor (order id)\n * @property {number|string} [limit] - Max orders to return\n */\n\n/**\n * @typedef {{}} OrderHistoryParams\n * @property {string} [owner] - Filter by order owner address\n * @property {string[]} [pair] - Asset pair `[base, quote]` (contract ids)\n * @property {string|bigint} [cursor] - Pagination cursor (order id)\n * @property {number|string} [limit] - Max orders to return\n */\n\n/**\n * @typedef {{}} TradesParams\n * @property {string} [trader] - Filter by trader address\n * @property {string[]} [pair] - Asset pair `[base, quote]` (contract ids)\n * @property {string|bigint} [cursor] - Pagination cursor (trade id)\n * @property {number|string} [limit] - Max trades to return\n */\n\n/**\n * @typedef {{}} ApiOrder - Serialized order returned by the API\n * @property {string} id - Order ID\n * @property {string} status - Order status (`ACTIVE`|`FILLED`|`CANCELED`)\n * @property {string} kind - Order kind (`LIMIT`)\n * @property {string} buying - Buying asset contract id\n * @property {string} selling - Selling asset contract id\n * @property {string} price - Order price\n * @property {string} rprice - Rational price representation\n * @property {string} quote - Total quote amount\n * @property {string} amount - Amount left to sell/buy\n * @property {string} owner - Maker address\n * @property {string} [expires] - Expiration timestamp (UTC)\n * @property {string} [iceberg] - Iceberg amount\n * @property {string} [stop] - Stop price\n * @property {string} [created] - Creation timestamp (UTC)\n * @property {string} [updated] - Last update timestamp (UTC)\n * @property {string} [cursor] - Pagination cursor\n */\n\n/**\n * @typedef {{}} ApiTrade - Serialized trade returned by the API\n * @property {string} id - Trade ID\n * @property {string} order - Matched order ID\n * @property {string} taker - Taker account address\n * @property {string} maker - Maker account address\n * @property {string} soldAsset - Sold asset contract id\n * @property {string} boughtAsset - Bought asset contract id\n * @property {string} sold - Sold tokens amount\n * @property {string} bought - Bought tokens amount\n * @property {string} price - Approximate trade price\n * @property {string} [cursor] - Pagination cursor\n * @property {string} timestamp - Trade timestamp (UTC)\n */\n","import {Networks} from '@stellar/stellar-sdk'\r\nimport ContractClient from './contract-client.js'\r\nimport {ContractErrors, processSimulationErrors} from './errors.js'\r\nimport {AxisApiClient, AxisApiError} from './api-client.js'\r\n\r\nexport {ContractErrors, AxisApiClient, AxisApiError}\r\n\r\n/** Trading order type - instructions to contract how to execute the trade */\r\nexport const OrderKind = {\r\n /** Execute trade, create a limit order if not executed in full */\r\n Limit: 1,\r\n /** Execute trade without creating a limit order */\r\n Fill: 2,\r\n /** Execute trade, cancel if was not executed in full */\r\n FillOrKill: 3\r\n}\r\n\r\n/** Trade direction instructions */\r\nexport const TradeDirection = {\r\n Sell: 1,\r\n Buy: 2\r\n}\r\n\r\n/**\r\n * Smart contract client for trading with AXIS DEX\r\n */\r\nexport class AxisContractClient {\r\n /**\r\n * @param {ClientInitializationParams} params\r\n */\r\n constructor(params) {\r\n const options = {\r\n publicKey: params.publicKey,\r\n signTransaction: params.signTransaction,\r\n rpcUrl: params.rpcUrl,\r\n allowHttp: true,\r\n networkPassphrase: params.networkPassphrase || Networks.PUBLIC,\r\n contractId: params.contractId\r\n }\r\n this.client = new ContractClient(options)\r\n this.fee = params.fee || '100000'\r\n }\r\n\r\n /**\r\n * Retrieve last order id\r\n * @return {Promise<bigint>} - Last created order id\r\n */\r\n async last() {\r\n const tx = await this.client.last()\r\n processSimulationErrors(tx)\r\n return tx.result\r\n }\r\n\r\n /**\r\n * @param {bigint} id - ID of the order to fetch\r\n * @return {Promise<Order>} - Order fetched from the storage\r\n */\r\n async order(id) {\r\n const tx = await this.client.order({id})\r\n processSimulationErrors(tx)\r\n return tx.result\r\n }\r\n\r\n /**\r\n * Cancel existing order\r\n * @param {bigint[]} ids - ID of the order to cancel\r\n * @param {string} trader - Trader address\r\n * @return {Promise<void>}\r\n * @throws {Error} - If trader is not the owner of the order\r\n */\r\n async cancel(ids, trader) {\r\n const tx = await this.client.cancel({ids, trader}, {fee: this.fee})\r\n processSimulationErrors(tx)\r\n await tx.signAndSend()\r\n }\r\n\r\n /**\r\n * Fill existing orders using another matching order from the orderbook\r\n * @param {string} trader - Trader address\r\n * @param {bigint} takerOrderId - ID of the order that serves as a taker\r\n * @param {bigint[]} orders - List of order IDs to match before creating the order on chain\r\n * @return {Promise<[bigint, bigint]>} - Amount of sold and bought tokens\r\n * @throws {Error} - If the taker order was not found\r\n * @throws {Error} - If any of the orders provided do not match selling/buying asset\r\n * @throws {Error} - If the trade causes an overflow\r\n */\r\n async fill_order(trader, takerOrderId, orders) {\r\n const tx = await this.client.fill_order({trader, taker_order_id: takerOrderId, orders}, {fee: this.fee})\r\n processSimulationErrors(tx)\r\n const res = await tx.signAndSend()\r\n return [res.result.sold, res.result.bought]\r\n }\r\n\r\n /**\r\n * Trade with DEX and create buy limit order if quote not executed in full\r\n * @param {BuyTradeArguments} params\r\n * @return {Promise<[bigint, bigint, bigint]>} - Amount of sold and bought tokens, ID of the newly created order if any\r\n * @throws {Error} - If the trader has insufficient balance\r\n * @throws {Error} - If any of the orders provided do not match selling/buying asset\r\n * @throws {Error} - If the trade causes an overflow\r\n */\r\n async buy(params) {\r\n return await execTrade(params, TradeDirection.Buy, this)\r\n }\r\n\r\n /**\r\n * Trade with DEX and create sell limit order if quote not executed in full\r\n * @param {SellTradeArguments} params\r\n * @return {Promise<[bigint, bigint, bigint]>} - Amount of sold and bought tokens, ID of the newly created order if any\r\n * @throws {Error} - If the trader has insufficient balance\r\n * @throws {Error} - If any of the orders provided do not match selling/buying asset\r\n * @throws {Error} - If the trade causes an overflow\r\n */\r\n async sell(params) {\r\n return await execTrade(params, TradeDirection.Sell, this)\r\n }\r\n\r\n async swap(params) {\r\n const tx = await this.client.swap({\r\n direction: params.direction,\r\n trader: params.trader,\r\n selling: params.selling,\r\n selling_amount: params.sellingAmount,\r\n buying_amount: params.buyingAmount,\r\n path: params.path.map(step => ({asset: step.asset, orders: step.orders}))\r\n }, {fee: this.fee})\r\n processSimulationErrors(tx)\r\n const res = await tx.signAndSend()\r\n return [res.result.sold, res.result.bought]\r\n }\r\n}\r\n\r\nasync function execTrade(params, direction, context) {\r\n const payload = {\r\n direction: direction,\r\n kind: params.kind,\r\n trader: params.trader,\r\n amount: params.amount,\r\n selling: params.selling,\r\n buying: params.buying,\r\n price: params.price,\r\n orders: params.orders\r\n }\r\n const tx = await context.client.trade(payload, {fee: context.fee})\r\n processSimulationErrors(tx)\r\n const {result} = await tx.signAndSend()\r\n return [result[0], result[1], result[2]]\r\n}\r\n\r\n/**\r\n * @typedef {{}} ClientInitializationParams\r\n * @property {string} publicKey - Public key of the account that will interact with the contract\r\n * @property {SignTransactionCallback} signTransaction - Callback for signing transactions generated by the client\r\n * @property {string} rpcUrl - URL of the RPC server\r\n * @property {string} contractId - DEX contract ID\r\n * @property {string} [networkPassphrase] - Network passphrase (Pubnet passphrase by default)\r\n * @property {string} [fee] - Transaction fee (0.1 XLM by default)\r\n */\r\n\r\n/**\r\n * @callback SignTransactionCallback - Callback for signing transactions generated by the client\r\n * @param {string} tx - Transaction XDR to sign\r\n * @param {{network: string, networkPassphrase: string, accountToSign: string}} context - Signing context\r\n * @return {Promise<{signedTxXdr: string, [signerAddress]: string}>} - Signed transaction response\r\n */\r\n\r\n/**\r\n * @typedef {{}} TradeArguments\r\n * @property {OrderKind} kind - Trading order behavior\r\n * @property {string} trader - Trader address\r\n * @property {bigint} amount - Tokens amount\r\n * @property {string} selling - Selling token address\r\n * @property {string} buying - Buying token address\r\n * @property {bigint} price - Price a trader willing to accept\r\n * @property {Array<bigint>} orders - List of order IDs to match before creating the order on-chain\r\n */\r\n\r\n/**\r\n * @typedef {{}} SellTradeArguments\r\n * @extends TradeArguments\r\n * @property {bigint} amount - Amount of `selling` tokens to sell\r\n * @property {bigint} price - Price a trader willing to accept, minimum `buying` tokens per 1 `selling`\r\n */\r\n\r\n/**\r\n * @typedef {{}} BuyTradeArguments\r\n * @extends TradeArguments\r\n * @property {bigint} amount - Amount of `buying` tokens to acquire\r\n * @property {bigint} price - Price a trader willing to accept, maximum `selling` tokens per 1 `buying`\r\n */\r\n\r\n/**\r\n * @typedef {{}} TradeStep - A trade step in a multi-market swap path\r\n * @property {string} asset - Asset to buy at this step\r\n * @property {Array<bigint>} orders - Maker order IDs to match\r\n */\r\n\r\n/**\r\n * @typedef {{}} SwapArguments\r\n * @property {TradeDirection} direction - Trade direction: `Sell` or `Buy`\r\n * @property {string} trader - Trader address\r\n * @property {string} selling - Token address sent by the trader\r\n * @property {bigint} selling_amount - Maximum amount of selling tokens to send\r\n * @property {bigint} buying_amount - Minimum amount of buying tokens to receive\r\n * @property {Array<TradeStep>} path - Ordered list of the trade route steps\r\n */\r\n\r\n/**\r\n * @typedef {{}} MethodOptions\r\n * @property {string} [fee] - Transaction fee (0.1 XLM by default)\r\n */\r\n\r\n/**\r\n * @typedef {{}} Order - Order properties, stored on-chain\r\n * @property {bigint} id - Order ID\r\n * @property {OrderKind} kind - Trading behavior\r\n * @property {string} owner - Owner of the order\r\n * @property {string} selling - Selling token address\r\n * @property {string} buying - Buying token address\r\n * @property {bigint} amount - Amount of tokens to sell\r\n * @property {bigint} price - Price of the order\r\n * @property {bigint} quote - Total amount of tokens to buy\r\n * @property {bigint} expires - Expiration time of the order\r\n */\r\n\r\n/**\r\n* @typedef {object} TradeContractEvent - Orderbook trade event\r\n* @property {bigint} bought - Bought tokens amount\r\n* @property {string} buying - Bought asset address\r\n* @property {bigint} id - Unique trade id\r\n* @property {string} maker - Seller account address\r\n* @property {bigint} order - Order id\r\n* @property {string} selling - Sold asset address\r\n* @property {bigint} sold - Sold tokens amount\r\n* @property {string} taker - Trader account address\r\n*/\r\n\r\n/**\r\n * @typedef {object} SwapContractEvent - Orderbook swap event\r\n * @property {bigint} id - Unique swap id (last trade id assigned while settling the swap legs)\r\n * @property {string} trader - Trader account address\r\n * @property {string} selling - Sold asset address\r\n * @property {string} buying - Bought asset address\r\n * @property {bigint} sold - Amount of `selling` tokens sold\r\n * @property {bigint} bought - Amount of `buying` tokens received\r\n */","import {AxisContractClient, ContractErrors, TradeDirection, OrderKind, AxisApiClient, AxisApiError} from './index.js'\r\n\r\nconst axisClient = {AxisContractClient, ContractErrors, TradeDirection, OrderKind, AxisApiClient, AxisApiError}\r\n\r\nexport default axisClient"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__346__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","ContractClient","stellar_sdk_","contract","Client","options","constructor","super","Spec","fromJSON","last","txFromJSON","order","cancel","trade","swap","fill_order","ContractErrors","message","processSimulationErrors","tx","simulation","error","contractErrorMatch","exec","code","err","Error","AxisApiError","status","name","TradeDirection","Sell","Buy","async","execTrade","params","direction","context","payload","kind","trader","amount","selling","buying","price","orders","client","fee","result","signAndSend","cjs","AxisContractClient","publicKey","signTransaction","rpcUrl","allowHttp","networkPassphrase","Networks","PUBLIC","contractId","id","ids","takerOrderId","taker_order_id","res","sold","bought","buy","sell","selling_amount","sellingAmount","buying_amount","buyingAmount","path","map","step","asset","OrderKind","Limit","Fill","FillOrKill","AxisApiClient","serverUrl","TypeError","replace","quoteSell","quote","quoteBuy","sellingAsset","buyingAsset","direct","request","getDepth","market","depth","getCandles","from","to","resolution","getTicker24h","getMarkets","cursor","limit","getOrders","owner","getOrder","encodeURIComponent","toString","getOrderHistory","pair","getTrades","query","url","search","URLSearchParams","value","entries","Array","isArray","item","append","qs","response","fetch","body","json","e","ok","statusText"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@axis-markets/client",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "AXIS contract and API client",
5
5
  "author": "team@stellar.expert",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "types": "lib/index.d.ts",
9
- "main": "lib/axisContractClient.js",
8
+ "types": "src/index.d.ts",
9
+ "main": "lib/axis-client.cjs",
10
10
  "module": "src/index.js",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/index.d.ts",
14
+ "import": "./src/index.js",
15
+ "require": "./lib/axis-client.cjs"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
11
19
  "homepage": "https://axis.markets",
12
20
  "repository": {
13
21
  "type": "git",
@@ -18,7 +26,10 @@
18
26
  "prepare": "webpack --mode=production --config webpack.config.cjs"
19
27
  },
20
28
  "peerDependencies": {
21
- "@stellar/stellar-sdk": ">=15"
29
+ "@stellar/stellar-sdk": ">=16"
30
+ },
31
+ "engines": {
32
+ "node": ">=22"
22
33
  },
23
34
  "devDependencies": {
24
35
  "@babel/core": "^8.0.1",
@@ -31,6 +42,7 @@
31
42
  },
32
43
  "files": [
33
44
  "src/",
45
+ "lib/",
34
46
  "!src/cjs.js"
35
47
  ]
36
48
  }
package/src/api-client.js CHANGED
@@ -23,7 +23,7 @@ export class AxisApiError extends Error {
23
23
  /**
24
24
  * HTTP client for the AXIS Aggregator REST API
25
25
  */
26
- export class ApiClient {
26
+ export class AxisApiClient {
27
27
  /**
28
28
  * @param {string} serverUrl - Base URL of the Aggregator server
29
29
  */
@@ -14,7 +14,7 @@ export default class ContractClient extends contract.Client {
14
14
  "AAAAAQAAACFPcmRlciBwcm9wZXJ0aWVzLCBzdG9yZWQgb24tY2hhaW4AAAAAAAAAAAAABU9yZGVyAAAAAAAACQAAABdBbW91bnQgbGVmdCB0byBzZWxsL2J1eQAAAAAGYW1vdW50AAAAAAALAAAAFEJ1eWluZyB0b2tlbiBhZGRyZXNzAAAABmJ1eWluZwAAAAAAEwAAABRleHBpcmF0aW9uIHRpbWVzdGFtcAAAAAdleHBpcmVzAAAAAAYAAAAXVW5pcXVlIG9yZGVyIGlkZW50aWZpZXIAAAAAAmlkAAAAAAAGAAAACk9yZGVyIHR5cGUAAAAAAARraW5kAAAH0AAAAAlPcmRlcktpbmQAAAAAAAANTWFrZXIgYWRkcmVzcwAAAAAAAAVvd25lcgAAAAAAABMAAAALT3JkZXIgcHJpY2UAAAAABXByaWNlAAAAAAAACwAAAB1Jbml0aWFsIHNlbGxpbmcvYnV5aW5nIGFtb3VudAAAAAAAAAVxdW90ZQAAAAAAAAsAAAA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gAAAAGb3JkZXJzAAAAAAPqAAAABg==",
20
20
  "AAAABAAAABhTdGFuZGFyZCBjb250cmFjdCBlcnJvcnMAAAAAAAAADk9yZGVyYm9va0Vycm9yAAAAAAAGAAAAAAAAAA1Ob3RBdXRob3JpemVkAAAAAAACvQAAAAAAAAATSW5zdWZmaWNpZW50QmFsYW5jZQAAAAK+AAAAAAAAAA1PcmRlck5vdEZvdW5kAAAAAAACvwAAAAAAAAAIT3ZlcmZsb3cAAALAAAAAAAAAAAxJbnZhbGlkTWF0Y2gAAALBAAAAAAAAAAxJbnZhbGlkUHJpY2UAAALC",
package/src/index.d.ts CHANGED
@@ -1,134 +1,83 @@
1
- /**
2
- * Trading order type - instructions to contract how to execute the trade
3
- */
1
+ /** Trading order type - instructions to contract how to execute the trade */
4
2
  export enum OrderKind {
5
3
  Limit = 1,
6
4
  Fill = 2,
7
5
  FillOrKill = 3,
8
6
  }
9
- /**
10
- * Trade direction instructions
11
- */
7
+
8
+ /** Trade direction instructions */
12
9
  export enum TradeDirection {
13
10
  Sell = 1,
14
11
  Buy = 2,
15
12
  }
16
13
 
17
- /**
18
- * Order properties, stored on-chain
19
- */
14
+ /** Order properties, stored on-chain */
20
15
  export interface Order {
21
- /**
22
- * Amount left to sell/buy
23
- */
16
+ /** Amount left to sell/buy */
24
17
  amount: bigint;
25
- /**
26
- * Buying token address
27
- */
18
+ /** Buying token address */
28
19
  buying: string;
29
- /**
30
- * expiration timestamp
31
- */
20
+ /** expiration timestamp */
32
21
  expires: bigint;
33
- /**
34
- * Unique order identifier
35
- */
22
+ /** Unique order identifier */
36
23
  id: bigint;
37
- /**
38
- * Order type
39
- */
24
+ /** Order type */
40
25
  kind: OrderKind;
41
- /**
42
- * Maker address
43
- */
26
+ /** Maker address */
44
27
  owner: string;
45
- /**
46
- * Order price
47
- */
28
+ /** Order price */
48
29
  price: bigint;
49
- /**
50
- * Initial selling/buying amount
51
- */
30
+ /** Initial selling/buying amount */
52
31
  quote: bigint;
53
- /**
54
- * Selling token address
55
- */
32
+ /** Selling token address */
56
33
  selling: string;
57
34
  }
58
35
 
59
- /**
60
- * Orderbook trade event
61
- */
62
- export interface Trade {
63
- /**
64
- * Bought tokens amount
65
- */
36
+ /** Orderbook trade event */
37
+ export interface TradeContractEvent {
38
+ /** Bought tokens amount */
66
39
  bought: bigint;
67
- /**
68
- * Bought asset address
69
- */
40
+ /** Bought asset address */
70
41
  buying: string;
71
- /**
72
- * Unique trade id
73
- */
42
+ /** Unique trade id */
74
43
  id: bigint;
75
- /**
76
- * Seller account address
77
- */
44
+ /** Seller account address */
78
45
  maker: string;
79
- /**
80
- * Order id
81
- */
46
+ /** Order id */
82
47
  order: bigint;
83
- /**
84
- * Sold asset address
85
- */
48
+ /** Sold asset address */
86
49
  selling: string;
87
- /**
88
- * Sold tokens amount
89
- */
50
+ /** Sold tokens amount */
90
51
  sold: bigint;
91
- /**
92
- * Trader account address
93
- */
52
+ /** Trader account address */
94
53
  taker: string;
95
54
  }
96
55
 
97
- /**
98
- * A trade step in a multi-market swap path.
99
- */
56
+ /** Orderbook swap event */
57
+ export interface SwapContractEvent {
58
+ /** Unique swap id (last trade id assigned while settling the swap legs) */
59
+ id: bigint;
60
+ /** Trader account address */
61
+ trader: string;
62
+ /** Sold asset address */
63
+ selling: string;
64
+ /** Bought asset address */
65
+ buying: string;
66
+ /** Amount of `selling` tokens sold */
67
+ sold: bigint;
68
+ /** Amount of `buying` tokens received */
69
+ bought: bigint;
70
+ }
71
+
72
+ /** A trade step in a multi-market swap path. */
100
73
  export interface TradeStep {
101
- /**
102
- * Asset to buy at this step
103
- */
74
+ /** Asset to buy at this step */
104
75
  asset: string;
105
- /**
106
- * Maker order IDs to match
107
- */
76
+ /** Maker order IDs to match */
108
77
  orders: Array<bigint>;
109
78
  }
110
79
 
111
- /**
112
- * Orderbook swap event
113
- */
114
- export interface Swap {
115
- /**
116
- * Amount of `buying` tokens received
117
- */
118
- bought: bigint;
119
- /**
120
- * Amount of `selling` tokens sold
121
- */
122
- sold: bigint;
123
- /**
124
- * Trader account address
125
- */
126
- trader: string;
127
- }
128
-
129
- /**
130
- * Standard contract errors
131
- */
80
+ /** Standard contract errors */
132
81
  export declare const ContractErrors: {
133
82
  701: {message: "NotAuthorized"};
134
83
  702: {message: "InsufficientBalance"};
@@ -258,9 +207,7 @@ export declare class AxisContractClient {
258
207
  swap(params: SwapArguments): Promise<[bigint, bigint]>;
259
208
  }
260
209
 
261
- /**
262
- * Error thrown when the Aggregator API responds with a non-success HTTP status
263
- */
210
+ /** Error thrown when the Aggregator API responds with a non-success HTTP status */
264
211
  export declare class AxisApiError extends Error {
265
212
  constructor(message: string, status: number);
266
213
 
@@ -347,9 +294,7 @@ export interface CandlesParams {
347
294
  order?: 'asc' | 'desc';
348
295
  }
349
296
 
350
- /**
351
- * OHLCVT candle row: `[timestamp, open, high, low, close, baseVolume, quoteVolume, tradeCount]`
352
- */
297
+ /** OHLCVT candle row: `[timestamp, open, high, low, close, baseVolume, quoteVolume, tradeCount]` */
353
298
  export type Candle = [number, string, string, string, string, string, string, number];
354
299
 
355
300
  export interface TickerEntry {
@@ -435,9 +380,7 @@ export interface TradesParams {
435
380
  limit?: number | string;
436
381
  }
437
382
 
438
- /**
439
- * Serialized order returned by the API
440
- */
383
+ /** Serialized order returned by the API */
441
384
  export interface ApiOrder {
442
385
  /** Order ID */
443
386
  id: string;
@@ -473,9 +416,7 @@ export interface ApiOrder {
473
416
  cursor?: string;
474
417
  }
475
418
 
476
- /**
477
- * Serialized trade returned by the API
478
- */
419
+ /** Serialized trade returned by the API */
479
420
  export interface ApiTrade {
480
421
  /** Trade ID */
481
422
  id: string;
@@ -501,13 +442,9 @@ export interface ApiTrade {
501
442
  timestamp: string;
502
443
  }
503
444
 
504
- /**
505
- * HTTP client for the AXIS Aggregator REST API
506
- */
507
- export declare class ApiClient {
508
- /**
509
- * @param serverUrl - Base URL of the Aggregator server
510
- */
445
+ /** HTTP client for the AXIS Aggregator REST API */
446
+ export declare class AxisApiClient {
447
+ /** @param serverUrl - Base URL of the Aggregator server */
511
448
  constructor(serverUrl: string);
512
449
 
513
450
  /** Base URL of the Aggregator server */
package/src/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {Networks} from '@stellar/stellar-sdk'
2
2
  import ContractClient from './contract-client.js'
3
3
  import {ContractErrors, processSimulationErrors} from './errors.js'
4
- import {ApiClient, AxisApiError} from './api-client.js'
4
+ import {AxisApiClient, AxisApiError} from './api-client.js'
5
5
 
6
- export {ContractErrors, ApiClient, AxisApiError}
6
+ export {ContractErrors, AxisApiClient, AxisApiError}
7
7
 
8
8
  /** Trading order type - instructions to contract how to execute the trade */
9
9
  export const OrderKind = {
@@ -223,3 +223,24 @@ async function execTrade(params, direction, context) {
223
223
  * @property {bigint} expires - Expiration time of the order
224
224
  */
225
225
 
226
+ /**
227
+ * @typedef {object} TradeContractEvent - Orderbook trade event
228
+ * @property {bigint} bought - Bought tokens amount
229
+ * @property {string} buying - Bought asset address
230
+ * @property {bigint} id - Unique trade id
231
+ * @property {string} maker - Seller account address
232
+ * @property {bigint} order - Order id
233
+ * @property {string} selling - Sold asset address
234
+ * @property {bigint} sold - Sold tokens amount
235
+ * @property {string} taker - Trader account address
236
+ */
237
+
238
+ /**
239
+ * @typedef {object} SwapContractEvent - Orderbook swap event
240
+ * @property {bigint} id - Unique swap id (last trade id assigned while settling the swap legs)
241
+ * @property {string} trader - Trader account address
242
+ * @property {string} selling - Sold asset address
243
+ * @property {string} buying - Bought asset address
244
+ * @property {bigint} sold - Amount of `selling` tokens sold
245
+ * @property {bigint} bought - Amount of `buying` tokens received
246
+ */
@@ -1,2 +0,0 @@
1
- !function(A,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@stellar/stellar-sdk")):"function"==typeof define&&define.amd?define(["@stellar/stellar-sdk"],t):"object"==typeof exports?exports.axisContractClient=t(require("@stellar/stellar-sdk")):A.axisContractClient=t(A["@stellar/stellar-sdk"])}(this,A=>(()=>{"use strict";var t={346(t){t.exports=A}},l={};function e(A){var c=l[A];if(void 0!==c)return c.exports;var r=l[A]={exports:{}};return t[A](r,r.exports,e),r.exports}e.d=(A,t)=>{for(var l in t)e.o(t,l)&&!e.o(A,l)&&Object.defineProperty(A,l,{enumerable:!0,get:t[l]})},e.o=(A,t)=>Object.prototype.hasOwnProperty.call(A,t);var c={};e.d(c,{default:()=>i});var r=e(346);class G extends r.contract.Client{options;constructor(A){super(new r.contract.Spec(["AAAAAAAAADJHZXQgbGF0IG9yZGVyIGlkCgojIFJldHVybnMKCkxhc3QgY3JlYXRlZCBvcmRlciBpZAAAAAAABGxhc3QAAAAAAAAAAQAAAAY=","AAAAAAAAA4ZTd2FwIHRva2VucyBhY3Jvc3Mgc2V2ZXJhbCBtYXJrZXRzLgpUaGUgc3dhcCBleGVjdXRlcyB3aXRoaW4gdGhlIGJvdW5kYXJpZXMsIG90aGVyd2lzZSB0cmFkZSBnZXQgY2FuY2VsZWQ6CiogYFNlbGxgOiBleGFjdGx5IGBzZWxsaW5nX2Ftb3VudGAgc29sZCwgdGhlIHJlY2VpdmVkIGFtb3VudCBpcyBgPj0gYnV5aW5nX2Ftb3VudGAKKiBgQnV5YDogZXhhY3RseSBgYnV5aW5nX2Ftb3VudGAgcmVjZWl2ZWQsIHRoZSBzcGVudCBhbW91bnQgaXMgYDw9IHNlbGxpbmdfYW1vdW50YAoKCiMgQXJndW1lbnRzCiogYGRpcmVjdGlvbmAgLSBUcmFkZSBkaXJlY3Rpb246IGBTZWxsYCBvciBgQnV5YAoqIGB0cmFkZXJgIC0gVHJhZGVyIGFkZHJlc3MKKiBgc2VsbGluZ2AgLSBUb2tlbiBhZGRyZXNzIHNlbnQgYnkgdGhlIHRyYWRlcgoqIGBzZWxsaW5nX2Ftb3VudGAgLSBNYXhpbXVtIGFtb3VudCBvZiBzZWxsaW5nIHRva2VucyB0byBzZW5kCiogYGJ1eWluZ19hbW91bnRgIC0gTWluaW11bSBhbW91bnQgb2YgYnV5aW5nIHRva2Vucy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XRhaWxzAAAABHN3YXAAAAfQAAAABFN3YXAAAAAAAAAAAA==","AAAABQAAAAAAAAAAAAAACk9yZGVyRXZlbnQAAAAAAAIAAAAEQVhJUwAAAAVvcmRlcgAAAAAAAAQAAAAwT3JkZXIgY2hhbmdlIHR5cGU6ICJjcmVhdGVkInwidXBkYXRlZCJ8InJlbW92ZWQiAAAABmFjdGlvbgAAAAAAEQAAAAEAAAAVU2VsbGluZyBhc3NldCBhZGRyZXNzAAAAAAAAB3NlbGxpbmcAAAAAEwAAAAEAAAAUQnV5aW5nIGFzc2V0IGFkZHJlc3MAAAAGYnV5aW5nAAAAAAATAAAAAQAAAA1PcmRlciBkZXRhaWxzAAAAAAAABW9yZGVyAAAAAAAH0AAAAAVPcmRlcgAAAAAAAAAAAAAA","AAAABQAAAAAAAAAAAAAAClRyYWRlRXZlbnQAAAAAAAIAAAAEQVhJUwAAAAV0cmFkZQAAAAAAAAMAAAASU29sZCBhc3NldCBhZGRyZXNzAAAAAAAHc2VsbGluZwAAAAATAAAAAQAAABRCb3VnaHQgYXNzZXQgYWRkcmVzcwAAAAZidXlpbmcAAAAAABMAAAABAAAADVRyYWRlIGRldGFpbHMAAAAAAAAFdHJhZGUAAAAAAAfQAAAABVRyYWRlAAAAAAAAAAAAAAA="]),A),this.options=A}fromJSON={last:this.txFromJSON,order:this.txFromJSON,cancel:this.txFromJSON,trade:this.txFromJSON,swap:this.txFromJSON,fill_order:this.txFromJSON}}const s={701:{message:"NotAuthorized"},702:{message:"InsufficientBalance"},703:{message:"OrderNotFound"},704:{message:"Overflow"},705:{message:"InvalidMatch"},706:{message:"InvalidPrice"}};function Z(A){if(A.simulation.error){const t=/HostError: Error\(Contract, #(\d+)\)/.exec(A.simulation.error);if(t){const A=t[1],l=s[A];if(l)throw new Error(`Contract execution error: #${A} ${l.message} `)}throw A.simulation.error}}class B extends Error{constructor(A,t){super(A),this.name="AxisApiError",this.status=t}status}const a={Sell:1,Buy:2};async function n(A,t,l){const e={direction:t,kind:A.kind,trader:A.trader,amount:A.amount,selling:A.selling,buying:A.buying,price:A.price,orders:A.orders},c=await l.client.trade(e,{fee:l.fee});Z(c);const{result:r}=await c.signAndSend();return[r[0],r[1],r[2]]}const i={AxisContractClient:class{constructor(A){const t={publicKey:A.publicKey,signTransaction:A.signTransaction,rpcUrl:A.rpcUrl,allowHttp:!0,networkPassphrase:A.networkPassphrase||r.Networks.PUBLIC,contractId:A.contractId};this.client=new G(t),this.fee=A.fee||"100000"}async last(){const A=await this.client.last();return Z(A),A.result}async order(A){const t=await this.client.order({id:A});return Z(t),t.result}async cancel(A,t){const l=await this.client.cancel({ids:A,trader:t},{fee:this.fee});Z(l),await l.signAndSend()}async fill_order(A,t,l){const e=await this.client.fill_order({trader:A,taker_order_id:t,orders:l},{fee:this.fee});Z(e);const c=await e.signAndSend();return[c.result.sold,c.result.bought]}async buy(A){return await n(A,a.Buy,this)}async sell(A){return await n(A,a.Sell,this)}async swap(A){const t=await this.client.swap({direction:A.direction,trader:A.trader,selling:A.selling,selling_amount:A.sellingAmount,buying_amount:A.buyingAmount,path:A.path.map(A=>({asset:A.asset,orders:A.orders}))},{fee:this.fee});Z(t);const l=await t.signAndSend();return[l.result.sold,l.result.bought]}},ContractErrors:s,TradeDirection:a,OrderKind:{Limit:1,Fill:2,FillOrKill:3},ApiClient:class{constructor(A){if(!A||"string"!=typeof A)throw new TypeError("Aggregator server URL is required");this.serverUrl=A.replace(/\/+$/,"")}serverUrl;async quoteSell(A){return this.quote(A,"strict_send")}async quoteBuy(A){return this.quote(A,"strict_receive")}async quote({sellingAsset:A,buyingAsset:t,amount:l,direct:e},c){return this.request("/quote",{sellingAsset:A,buyingAsset:t,amount:l,direction:c,direct:e})}async getDepth({market:A,depth:t}){return this.request("/depth",{market:A,depth:t})}async getCandles({market:A,from:t,to:l,resolution:e,order:c}){return this.request("/candles",{market:A,from:t,to:l,resolution:e,order:c})}async getTicker24h(){return this.request("/ticker/24h")}async getMarkets({cursor:A,limit:t}={}){return this.request("/markets",{cursor:A,limit:t})}async getOrders({owner:A,asset:t,cursor:l,limit:e}={}){return this.request("/order",{owner:A,asset:t,cursor:l,limit:e})}async getOrder(A){return this.request(`/order/${encodeURIComponent(A.toString())}`)}async getOrderHistory({owner:A,pair:t,cursor:l,limit:e}={}){return this.request("/order-history",{owner:A,pair:t,cursor:l,limit:e})}async getTrades({trader:A,pair:t,cursor:l,limit:e}={}){return this.request("/trades",{trader:A,pair:t,cursor:l,limit:e})}async request(A,t){let l=this.serverUrl+A;if(t){const A=new URLSearchParams;for(const[l,e]of Object.entries(t))if(null!=e)if(Array.isArray(e))for(const t of e)A.append(l,t);else A.append(l,e);const e=A.toString();e&&(l+="?"+e)}const e=await fetch(l);let c;try{c=await e.json()}catch(A){c=null}if(!e.ok)throw new B(c?.error||e.statusText,c?.status||e.status);return c}},AxisApiError:B};return c.default})());
2
- //# sourceMappingURL=axisContractClient.js.map