@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.7 → 0.1.0-beta.9
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 +14 -322
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -750
- package/dist/index.d.ts +3 -750
- package/dist/index.js +10 -315
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,285 +4,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
|
|
5
5
|
// src/lib/client.ts
|
|
6
6
|
import { ArchwayClient, SigningArchwayClient } from "@archwayhq/arch3.js";
|
|
7
|
+
import { BaseClient, InvalidTypeError, MissingParameterError } from "@bolt-liquidity-hq/core";
|
|
7
8
|
import {
|
|
8
9
|
CosmWasmClient,
|
|
9
10
|
SigningCosmWasmClient
|
|
10
11
|
} from "@cosmjs/cosmwasm-stargate";
|
|
11
12
|
|
|
12
|
-
// src/common/errors.ts
|
|
13
|
-
var BoltSdkErrorCode = /* @__PURE__ */ ((BoltSdkErrorCode2) => {
|
|
14
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["NOT_FOUND"] = 1e3] = "NOT_FOUND";
|
|
15
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["INVALID_OBJECT"] = 1001] = "INVALID_OBJECT";
|
|
16
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["INVALID_TYPE"] = 1002] = "INVALID_TYPE";
|
|
17
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["INSUFFICIENT_FUNDS"] = 2e3] = "INSUFFICIENT_FUNDS";
|
|
18
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["INVALID_ADDRESS"] = 2001] = "INVALID_ADDRESS";
|
|
19
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["TRANSACTION_FAILED"] = 2002] = "TRANSACTION_FAILED";
|
|
20
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["TRANSACTION_EVENT_NOT_FOUND"] = 2003] = "TRANSACTION_EVENT_NOT_FOUND";
|
|
21
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["NETWORK_ERROR"] = 3e3] = "NETWORK_ERROR";
|
|
22
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["INVALID_PARAMETER"] = 4e3] = "INVALID_PARAMETER";
|
|
23
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["MISSING_PARAMETER"] = 4001] = "MISSING_PARAMETER";
|
|
24
|
-
BoltSdkErrorCode2[BoltSdkErrorCode2["PARAMETER_OUT_OF_RANGE"] = 4002] = "PARAMETER_OUT_OF_RANGE";
|
|
25
|
-
return BoltSdkErrorCode2;
|
|
26
|
-
})(BoltSdkErrorCode || {});
|
|
27
|
-
var BoltSdkErrorBase = class extends Error {
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new BoltSdkErrorBase instance.
|
|
30
|
-
*
|
|
31
|
-
* @param code - The error code categorizing this error
|
|
32
|
-
* @param message - Human-readable error message
|
|
33
|
-
*/
|
|
34
|
-
constructor(code, message) {
|
|
35
|
-
super(message);
|
|
36
|
-
this.code = code;
|
|
37
|
-
this.name = this.constructor.name;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var NotFoundError = class extends BoltSdkErrorBase {
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new NotFoundError instance.
|
|
43
|
-
*
|
|
44
|
-
* @param resource - The type of resource that was not found
|
|
45
|
-
* @param details - Optional additional details about what was searched for
|
|
46
|
-
*/
|
|
47
|
-
constructor(resource, details) {
|
|
48
|
-
super(
|
|
49
|
-
1e3 /* NOT_FOUND */,
|
|
50
|
-
`Resource not found: ${resource}.${details ? ` Details: ${details}` : ""}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var InvalidObjectError = class extends BoltSdkErrorBase {
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new InvalidObjectError instance.
|
|
57
|
-
*
|
|
58
|
-
* @param details - Optional description of what is invalid about the object
|
|
59
|
-
*/
|
|
60
|
-
constructor(details) {
|
|
61
|
-
super(
|
|
62
|
-
1001 /* INVALID_OBJECT */,
|
|
63
|
-
`Invalid object or data structure!${details ? ` Details: ${details}` : ""}`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var InvalidTypeError = class extends BoltSdkErrorBase {
|
|
68
|
-
/**
|
|
69
|
-
* Creates a new InvalidTypeError instance.
|
|
70
|
-
*
|
|
71
|
-
* @param expectedType - The type that was expected
|
|
72
|
-
* @param receivedType - The actual type that was received
|
|
73
|
-
*/
|
|
74
|
-
constructor(expectedType, receivedType) {
|
|
75
|
-
super(
|
|
76
|
-
1002 /* INVALID_TYPE */,
|
|
77
|
-
`Invalid object type! Expected: ${expectedType}, Received: ${receivedType}`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var InsufficientFundsError = class extends BoltSdkErrorBase {
|
|
82
|
-
/**
|
|
83
|
-
* Creates a new InsufficientFundsError instance.
|
|
84
|
-
*
|
|
85
|
-
* @param required - The amount required for the operation
|
|
86
|
-
* @param available - The amount available in the account
|
|
87
|
-
*/
|
|
88
|
-
constructor(required, available) {
|
|
89
|
-
super(
|
|
90
|
-
2e3 /* INSUFFICIENT_FUNDS */,
|
|
91
|
-
`Insufficient funds to complete the transaction! Required: ${required}, Available: ${available}`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var InvalidAddressError = class extends BoltSdkErrorBase {
|
|
96
|
-
/**
|
|
97
|
-
* Creates a new InvalidAddressError instance.
|
|
98
|
-
*
|
|
99
|
-
* @param address - The invalid address that was provided
|
|
100
|
-
*/
|
|
101
|
-
constructor(address) {
|
|
102
|
-
super(2001 /* INVALID_ADDRESS */, `Invalid blockchain address provided: ${address}`);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
var TransactionFailedError = class extends BoltSdkErrorBase {
|
|
106
|
-
/**
|
|
107
|
-
* Creates a new TransactionFailedError instance.
|
|
108
|
-
*
|
|
109
|
-
* @param transactionId - The transaction hash or identifier
|
|
110
|
-
* @param details - Optional details about why the transaction failed
|
|
111
|
-
*/
|
|
112
|
-
constructor(transactionId, details) {
|
|
113
|
-
super(
|
|
114
|
-
2002 /* TRANSACTION_FAILED */,
|
|
115
|
-
`Transaction failed or was reverted! Transaction ID: ${transactionId}.${details ? ` Details: ${details}` : ""}`
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
var TransactionEventNotFoundError = class extends BoltSdkErrorBase {
|
|
120
|
-
/**
|
|
121
|
-
* Creates a new TransactionEventNotFoundError instance.
|
|
122
|
-
*
|
|
123
|
-
* @param eventName - The name of the event that was expected
|
|
124
|
-
* @param details - Optional details about the context
|
|
125
|
-
*/
|
|
126
|
-
constructor(eventName, details) {
|
|
127
|
-
super(
|
|
128
|
-
2003 /* TRANSACTION_EVENT_NOT_FOUND */,
|
|
129
|
-
`Transaction Event not found: ${eventName}.${details ? ` Details: ${details}` : ""}`
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
var NetworkError = class extends BoltSdkErrorBase {
|
|
134
|
-
/**
|
|
135
|
-
* Creates a new NetworkError instance.
|
|
136
|
-
*
|
|
137
|
-
* @param details - Optional details about the network failure
|
|
138
|
-
*/
|
|
139
|
-
constructor(details) {
|
|
140
|
-
super(
|
|
141
|
-
3e3 /* NETWORK_ERROR */,
|
|
142
|
-
`Network error occurred!${details ? ` Details: ${details}` : ""}`
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
var InvalidParameterError = class extends BoltSdkErrorBase {
|
|
147
|
-
/**
|
|
148
|
-
* Creates a new InvalidParameterError instance.
|
|
149
|
-
*
|
|
150
|
-
* @param parameterName - The name of the invalid parameter
|
|
151
|
-
* @param expected - Description of what was expected
|
|
152
|
-
* @param receivedValue - The actual value that was provided
|
|
153
|
-
* @param details - Optional additional details or constraints
|
|
154
|
-
*
|
|
155
|
-
* @template T - The type of the received value
|
|
156
|
-
*/
|
|
157
|
-
constructor(parameterName, expected, receivedValue, details) {
|
|
158
|
-
super(
|
|
159
|
-
4e3 /* INVALID_PARAMETER */,
|
|
160
|
-
`Invalid parameter '${parameterName}': expected ${expected}, received ${typeof receivedValue}${details ? `. ${details}` : ""}`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
var MissingParameterError = class extends BoltSdkErrorBase {
|
|
165
|
-
/**
|
|
166
|
-
* Creates a new MissingParameterError instance.
|
|
167
|
-
*
|
|
168
|
-
* @param parameterName - The name of the missing parameter
|
|
169
|
-
* @param context - Optional context about where the parameter was expected
|
|
170
|
-
*/
|
|
171
|
-
constructor(parameterName, context) {
|
|
172
|
-
super(
|
|
173
|
-
4001 /* MISSING_PARAMETER */,
|
|
174
|
-
`Required parameter '${parameterName}' is missing${context ? ` in ${context}` : ""}`
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var ParameterOutOfRangeError = class extends BoltSdkErrorBase {
|
|
179
|
-
/**
|
|
180
|
-
* Creates a new ParameterOutOfRangeError instance.
|
|
181
|
-
*
|
|
182
|
-
* @param parameterName - The name of the parameter that's out of range
|
|
183
|
-
* @param value - The actual value that was provided
|
|
184
|
-
* @param min - Optional minimum acceptable value (inclusive)
|
|
185
|
-
* @param max - Optional maximum acceptable value (inclusive)
|
|
186
|
-
* @param details - Optional additional details about the constraint
|
|
187
|
-
*/
|
|
188
|
-
constructor(parameterName, value, min, max, details) {
|
|
189
|
-
let rangeMessage = "";
|
|
190
|
-
if (min !== void 0 && max !== void 0) {
|
|
191
|
-
rangeMessage = ` Expected value between ${min} and ${max}, but received ${value}`;
|
|
192
|
-
} else if (min !== void 0) {
|
|
193
|
-
rangeMessage = ` Expected value >= ${min}, but received ${value}`;
|
|
194
|
-
} else if (max !== void 0) {
|
|
195
|
-
rangeMessage = ` Expected value <= ${max}, but received ${value}`;
|
|
196
|
-
}
|
|
197
|
-
super(
|
|
198
|
-
4002 /* PARAMETER_OUT_OF_RANGE */,
|
|
199
|
-
`Parameter '${parameterName}' is out of range.${rangeMessage}${details ? `. ${details}` : ""}`
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// src/common/helpers/asset.ts
|
|
205
|
-
var getCoinFromAmountWithDenomString = (amountWithDenom) => {
|
|
206
|
-
const match = amountWithDenom.match(/^(\d+)(.+)$/);
|
|
207
|
-
if (!match || !match[1] || !match[2]) {
|
|
208
|
-
throw new InvalidParameterError(
|
|
209
|
-
"amountWithDenom",
|
|
210
|
-
"a string with the amount followed by the denom",
|
|
211
|
-
amountWithDenom
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
return { amount: match[1], denom: match[2] };
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
// src/common/lib/client.ts
|
|
218
|
-
var BaseClient = class {
|
|
219
|
-
/**
|
|
220
|
-
* Creates a new instance of the BaseClient.
|
|
221
|
-
*
|
|
222
|
-
* @param config - (Optional) Configuration object for the client
|
|
223
|
-
* @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, and assets
|
|
224
|
-
* @param config.customOverride.chainConfig - (Optional) Chain configuration object
|
|
225
|
-
* @param config.customOverride.chainConfig.id - (Optional) The chain ID of the blockchain network (e.g., "archway-1")
|
|
226
|
-
* @param config.customOverride.chainConfig.name - (Optional) The human-readable name of the chain (e.g., "Archway")
|
|
227
|
-
* @param config.customOverride.chainConfig.rpcEndpoint - (Optional) RPC endpoint URL for the blockchain network
|
|
228
|
-
* @param config.customOverride.contracts - (Optional) Contract addresses for oracle and router
|
|
229
|
-
* @param config.customOverride.contracts.oracle - (Optional) Oracle contract address
|
|
230
|
-
* @param config.customOverride.contracts.router - (Optional) Router contract address
|
|
231
|
-
* @param config.customOverride.assetsConfig - (Optional) Configuration for supported assets indexed by symbol
|
|
232
|
-
*
|
|
233
|
-
* @throws {InvalidObjectError} Thrown when required configuration fields are missing
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* ```typescript
|
|
237
|
-
* const client = new ConcreteClient({
|
|
238
|
-
* customOverride: {
|
|
239
|
-
* chainConfig: {
|
|
240
|
-
* id: 'archway-1',
|
|
241
|
-
* name: 'Archway',
|
|
242
|
-
* rpcEndpoint: 'https://rpc.example.com'
|
|
243
|
-
* },
|
|
244
|
-
* contracts: {
|
|
245
|
-
* oracle: 'archway1oracle...',
|
|
246
|
-
* router: 'archway1router...'
|
|
247
|
-
* },
|
|
248
|
-
* assetsConfig: {
|
|
249
|
-
* 'ARCH': {
|
|
250
|
-
* symbol: 'ARCH',
|
|
251
|
-
* name: 'Archway',
|
|
252
|
-
* chainId: 'archway-1',
|
|
253
|
-
* denom: 'aarch',
|
|
254
|
-
* decimals: 18,
|
|
255
|
-
* logo: 'https://...',
|
|
256
|
-
* coingeckoId: 'archway'
|
|
257
|
-
* }
|
|
258
|
-
* }
|
|
259
|
-
* }
|
|
260
|
-
* });
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
constructor(config) {
|
|
264
|
-
/**
|
|
265
|
-
* The blockchain network configuration containing chain ID, name, and RPC endpoint
|
|
266
|
-
*/
|
|
267
|
-
__publicField(this, "chainConfig");
|
|
268
|
-
/**
|
|
269
|
-
* Smart contract addresses for making Bolt queries and transactions in the blockchain
|
|
270
|
-
*/
|
|
271
|
-
__publicField(this, "contracts");
|
|
272
|
-
/**
|
|
273
|
-
* Configuration mapping of supported assets indexed by their symbol
|
|
274
|
-
*/
|
|
275
|
-
__publicField(this, "assetsConfig");
|
|
276
|
-
const { customOverride: { chainConfig, contracts, assetsConfig } = {} } = config ?? {};
|
|
277
|
-
if (!chainConfig || !chainConfig?.id || !chainConfig?.name || !chainConfig?.rpcEndpoint || !contracts?.oracle || !contracts?.router || !assetsConfig) {
|
|
278
|
-
throw new InvalidObjectError("ClientConfig is missing fields");
|
|
279
|
-
}
|
|
280
|
-
this.chainConfig = chainConfig;
|
|
281
|
-
this.contracts = contracts;
|
|
282
|
-
this.assetsConfig = assetsConfig;
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
13
|
// src/config/archway-mainnet.ts
|
|
287
14
|
var ArchwayMainnetChainConfig = {
|
|
288
15
|
name: "Archway",
|
|
@@ -5764,6 +5491,7 @@ var parseQueryBaseLiquidityAllResponse = (response) => {
|
|
|
5764
5491
|
};
|
|
5765
5492
|
|
|
5766
5493
|
// src/lib/helpers/transactions.ts
|
|
5494
|
+
import { NotFoundError } from "@bolt-liquidity-hq/core";
|
|
5767
5495
|
var getSignerAddress = async (signer) => {
|
|
5768
5496
|
const accounts = await signer.getAccounts();
|
|
5769
5497
|
if (!accounts?.[0]) {
|
|
@@ -5844,6 +5572,12 @@ var getRouterConfig = async (client) => {
|
|
|
5844
5572
|
return parseQueryRouterConfigResponse(response);
|
|
5845
5573
|
};
|
|
5846
5574
|
|
|
5575
|
+
// src/lib/router/swap-exact-in.ts
|
|
5576
|
+
import {
|
|
5577
|
+
TransactionEventNotFoundError,
|
|
5578
|
+
getCoinFromAmountWithDenomString
|
|
5579
|
+
} from "@bolt-liquidity-hq/core";
|
|
5580
|
+
|
|
5847
5581
|
// src/lib/constants/events.ts
|
|
5848
5582
|
var BOLT_SWAP_EVENT_TYPE = "wasm-bolt_swap";
|
|
5849
5583
|
var BOLT_COIN_RECEIVED_EVENT_TYPE = "coin_received";
|
|
@@ -6155,32 +5889,7 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
6155
5889
|
async getAllAssets() {
|
|
6156
5890
|
return await getAllAssets(this);
|
|
6157
5891
|
}
|
|
6158
|
-
/**
|
|
6159
|
-
* Fetches the configuration settings for a pool identified by its base asset symbol.
|
|
6160
|
-
*
|
|
6161
|
-
* This is a convenience method that combines pool lookup and configuration retrieval.
|
|
6162
|
-
* It first finds the pool associated with the given base asset, then fetches that
|
|
6163
|
-
* pool's configuration parameters from its settlement contract.
|
|
6164
|
-
*
|
|
6165
|
-
* @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "ATOM")
|
|
6166
|
-
*
|
|
6167
|
-
* @returns A promise that resolves to a pool configuration object containing
|
|
6168
|
-
* settings such as fees, oracle address, LP addresses, and minimum trade amounts
|
|
6169
|
-
*
|
|
6170
|
-
* @throws Will throw an error if no pool exists for the specified base asset
|
|
6171
|
-
*
|
|
6172
|
-
* @example
|
|
6173
|
-
* ```typescript
|
|
6174
|
-
* // Get pool configuration for ARCH base asset
|
|
6175
|
-
* const poolConfig = await client.getPoolConfigByBaseAsset("ARCH");
|
|
6176
|
-
* console.log(`Oracle: ${poolConfig.priceOracleContract}`);
|
|
6177
|
-
* console.log(`Protocol fee: ${parseFloat(poolConfig.protocolFee) * 100}%`);
|
|
6178
|
-
* console.log(`LP fee: ${parseFloat(poolConfig.lpFee) * 100}%`);
|
|
6179
|
-
* console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
|
|
6180
|
-
* console.log(`Number of LPs: ${poolConfig.lps.length}`);
|
|
6181
|
-
* console.log(`Min base output: ${poolConfig.minBaseOut}`);
|
|
6182
|
-
* ```
|
|
6183
|
-
*/
|
|
5892
|
+
/** @inheritdoc */
|
|
6184
5893
|
async getPoolConfigByBaseAsset(baseAssetSymbol) {
|
|
6185
5894
|
return await getSettlementConfigForBase(this, baseAssetSymbol);
|
|
6186
5895
|
}
|
|
@@ -6217,20 +5926,6 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
6217
5926
|
}
|
|
6218
5927
|
};
|
|
6219
5928
|
export {
|
|
6220
|
-
|
|
6221
|
-
BoltCosmWasmClient,
|
|
6222
|
-
BoltSdkErrorBase,
|
|
6223
|
-
BoltSdkErrorCode,
|
|
6224
|
-
InsufficientFundsError,
|
|
6225
|
-
InvalidAddressError,
|
|
6226
|
-
InvalidObjectError,
|
|
6227
|
-
InvalidParameterError,
|
|
6228
|
-
InvalidTypeError,
|
|
6229
|
-
MissingParameterError,
|
|
6230
|
-
NetworkError,
|
|
6231
|
-
NotFoundError,
|
|
6232
|
-
ParameterOutOfRangeError,
|
|
6233
|
-
TransactionEventNotFoundError,
|
|
6234
|
-
TransactionFailedError
|
|
5929
|
+
BoltCosmWasmClient
|
|
6235
5930
|
};
|
|
6236
5931
|
//# sourceMappingURL=index.js.map
|