@mento-protocol/mento-sdk 1.17.1-beta.0 → 1.18.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.
Files changed (118) hide show
  1. package/README.md +19 -19
  2. package/package.json +1 -1
  3. package/dist/cjs/ChainClient.d.ts +0 -9
  4. package/dist/cjs/ChainClient.js +0 -58
  5. package/dist/cjs/TestChainClient.d.ts +0 -7
  6. package/dist/cjs/TestChainClient.js +0 -41
  7. package/dist/cjs/constants/addresses.d.ts +0 -4
  8. package/dist/cjs/constants/addresses.js +0 -59
  9. package/dist/cjs/constants/currencies.d.ts +0 -5
  10. package/dist/cjs/constants/currencies.js +0 -29
  11. package/dist/cjs/constants/index.d.ts +0 -4
  12. package/dist/cjs/constants/index.js +0 -20
  13. package/dist/cjs/constants/tokens.11142220.d.ts +0 -2
  14. package/dist/cjs/constants/tokens.11142220.js +0 -128
  15. package/dist/cjs/constants/tokens.42220.d.ts +0 -2
  16. package/dist/cjs/constants/tokens.42220.js +0 -128
  17. package/dist/cjs/constants/tokens.d.ts +0 -65
  18. package/dist/cjs/constants/tokens.js +0 -170
  19. package/dist/cjs/constants/tradablePairs.11142220.d.ts +0 -2
  20. package/dist/cjs/constants/tradablePairs.11142220.js +0 -7391
  21. package/dist/cjs/constants/tradablePairs.42220.d.ts +0 -2
  22. package/dist/cjs/constants/tradablePairs.42220.js +0 -7391
  23. package/dist/cjs/constants/tradablePairs.d.ts +0 -16
  24. package/dist/cjs/constants/tradablePairs.js +0 -53
  25. package/dist/cjs/enums/chainId.d.ts +0 -4
  26. package/dist/cjs/enums/chainId.js +0 -8
  27. package/dist/cjs/enums/index.d.ts +0 -3
  28. package/dist/cjs/enums/index.js +0 -19
  29. package/dist/cjs/enums/proposalState.d.ts +0 -10
  30. package/dist/cjs/enums/proposalState.js +0 -14
  31. package/dist/cjs/enums/tradingMode.d.ts +0 -17
  32. package/dist/cjs/enums/tradingMode.js +0 -21
  33. package/dist/cjs/governance.d.ts +0 -62
  34. package/dist/cjs/governance.js +0 -151
  35. package/dist/cjs/index.d.ts +0 -7
  36. package/dist/cjs/index.js +0 -23
  37. package/dist/cjs/interfaces/IChainClient.d.ts +0 -6
  38. package/dist/cjs/interfaces/IChainClient.js +0 -2
  39. package/dist/cjs/interfaces/index.d.ts +0 -4
  40. package/dist/cjs/interfaces/index.js +0 -20
  41. package/dist/cjs/interfaces/tradingLimit.d.ts +0 -7
  42. package/dist/cjs/interfaces/tradingLimit.js +0 -2
  43. package/dist/cjs/interfaces/tradingLimitsConfig.d.ts +0 -10
  44. package/dist/cjs/interfaces/tradingLimitsConfig.js +0 -2
  45. package/dist/cjs/interfaces/tradingLimitsState.d.ts +0 -9
  46. package/dist/cjs/interfaces/tradingLimitsState.js +0 -2
  47. package/dist/cjs/limits.d.ts +0 -33
  48. package/dist/cjs/limits.js +0 -130
  49. package/dist/cjs/mento.d.ts +0 -287
  50. package/dist/cjs/mento.js +0 -699
  51. package/dist/cjs/routeUtils.d.ts +0 -304
  52. package/dist/cjs/routeUtils.js +0 -372
  53. package/dist/cjs/types/contractAddressMap.d.ts +0 -4
  54. package/dist/cjs/types/contractAddressMap.js +0 -2
  55. package/dist/cjs/types/contractAddresses.d.ts +0 -23
  56. package/dist/cjs/types/contractAddresses.js +0 -2
  57. package/dist/cjs/types/index.d.ts +0 -2
  58. package/dist/cjs/types/index.js +0 -18
  59. package/dist/cjs/utils.d.ts +0 -80
  60. package/dist/cjs/utils.js +0 -177
  61. package/dist/esm/ChainClient.d.ts +0 -9
  62. package/dist/esm/ChainClient.js +0 -54
  63. package/dist/esm/TestChainClient.d.ts +0 -7
  64. package/dist/esm/TestChainClient.js +0 -37
  65. package/dist/esm/constants/addresses.d.ts +0 -4
  66. package/dist/esm/constants/addresses.js +0 -55
  67. package/dist/esm/constants/currencies.d.ts +0 -5
  68. package/dist/esm/constants/currencies.js +0 -26
  69. package/dist/esm/constants/index.d.ts +0 -4
  70. package/dist/esm/constants/index.js +0 -4
  71. package/dist/esm/constants/tokens.11142220.d.ts +0 -2
  72. package/dist/esm/constants/tokens.11142220.js +0 -125
  73. package/dist/esm/constants/tokens.42220.d.ts +0 -2
  74. package/dist/esm/constants/tokens.42220.js +0 -125
  75. package/dist/esm/constants/tokens.d.ts +0 -65
  76. package/dist/esm/constants/tokens.js +0 -142
  77. package/dist/esm/constants/tradablePairs.11142220.d.ts +0 -2
  78. package/dist/esm/constants/tradablePairs.11142220.js +0 -7388
  79. package/dist/esm/constants/tradablePairs.42220.d.ts +0 -2
  80. package/dist/esm/constants/tradablePairs.42220.js +0 -7388
  81. package/dist/esm/constants/tradablePairs.d.ts +0 -16
  82. package/dist/esm/constants/tradablePairs.js +0 -26
  83. package/dist/esm/enums/chainId.d.ts +0 -4
  84. package/dist/esm/enums/chainId.js +0 -5
  85. package/dist/esm/enums/index.d.ts +0 -3
  86. package/dist/esm/enums/index.js +0 -3
  87. package/dist/esm/enums/proposalState.d.ts +0 -10
  88. package/dist/esm/enums/proposalState.js +0 -11
  89. package/dist/esm/enums/tradingMode.d.ts +0 -17
  90. package/dist/esm/enums/tradingMode.js +0 -18
  91. package/dist/esm/governance.d.ts +0 -62
  92. package/dist/esm/governance.js +0 -147
  93. package/dist/esm/index.d.ts +0 -7
  94. package/dist/esm/index.js +0 -7
  95. package/dist/esm/interfaces/IChainClient.d.ts +0 -6
  96. package/dist/esm/interfaces/IChainClient.js +0 -1
  97. package/dist/esm/interfaces/index.d.ts +0 -4
  98. package/dist/esm/interfaces/index.js +0 -4
  99. package/dist/esm/interfaces/tradingLimit.d.ts +0 -7
  100. package/dist/esm/interfaces/tradingLimit.js +0 -1
  101. package/dist/esm/interfaces/tradingLimitsConfig.d.ts +0 -10
  102. package/dist/esm/interfaces/tradingLimitsConfig.js +0 -1
  103. package/dist/esm/interfaces/tradingLimitsState.d.ts +0 -9
  104. package/dist/esm/interfaces/tradingLimitsState.js +0 -1
  105. package/dist/esm/limits.d.ts +0 -33
  106. package/dist/esm/limits.js +0 -123
  107. package/dist/esm/mento.d.ts +0 -287
  108. package/dist/esm/mento.js +0 -671
  109. package/dist/esm/routeUtils.d.ts +0 -304
  110. package/dist/esm/routeUtils.js +0 -362
  111. package/dist/esm/types/contractAddressMap.d.ts +0 -4
  112. package/dist/esm/types/contractAddressMap.js +0 -1
  113. package/dist/esm/types/contractAddresses.d.ts +0 -23
  114. package/dist/esm/types/contractAddresses.js +0 -1
  115. package/dist/esm/types/index.d.ts +0 -2
  116. package/dist/esm/types/index.js +0 -2
  117. package/dist/esm/utils.d.ts +0 -80
  118. package/dist/esm/utils.js +0 -162
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getLimitId = exports.getLimits = exports.getLimitsState = exports.getLimitsConfig = void 0;
13
- const assert_1 = require("assert");
14
- const ethers_1 = require("ethers");
15
- /**
16
- * Returns the limit configuration in the broker for the given exchange and asset
17
- * @param broker an instance of the broker
18
- * @param exchangeId the id of the exchange
19
- * @param asset the address of the limited asset
20
- * @returns the limit configuration
21
- */
22
- function getLimitsConfig(broker, exchangeId, asset) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const limitId = getLimitId(exchangeId, asset);
25
- const cfg = yield broker.tradingLimitsConfig(limitId);
26
- return {
27
- asset,
28
- timestep0: cfg['timestep0'],
29
- timestep1: cfg['timestep1'],
30
- limit0: cfg['limit0'],
31
- limit1: cfg['limit1'],
32
- limitGlobal: cfg['limitGlobal'],
33
- flags: cfg['flags'],
34
- };
35
- });
36
- }
37
- exports.getLimitsConfig = getLimitsConfig;
38
- /**
39
- * Returns the limit state in the broker for the given exchange and asset
40
- * @param broker an instance of the broker
41
- * @param exchangeId the id of the exchange
42
- * @param asset the address of the limited asset
43
- * @returns the limit state
44
- */
45
- function getLimitsState(broker, exchangeId, asset) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const limitId = getLimitId(exchangeId, asset);
48
- const [cfg, state] = yield Promise.all([
49
- getLimitsConfig(broker, exchangeId, asset),
50
- broker.tradingLimitsState(limitId),
51
- ]);
52
- const isL0Enabled = cfg.timestep0 > 0;
53
- const isL1Enabled = cfg.timestep1 > 0;
54
- const nowEpoch = Math.floor(Date.now() / 1000);
55
- const isL0Outdated = isL0Enabled && nowEpoch > state['lastUpdated0'] + cfg.timestep0;
56
- const isL1Outdated = isL1Enabled && nowEpoch > state['lastUpdated1'] + cfg.timestep1;
57
- return {
58
- asset,
59
- lastUpdated0: isL0Outdated ? nowEpoch : state['lastUpdated0'],
60
- lastUpdated1: isL1Outdated ? nowEpoch : state['lastUpdated1'],
61
- netflow0: isL0Outdated ? 0 : state['netflow0'],
62
- netflow1: isL1Outdated ? 0 : state['netflow1'],
63
- netflowGlobal: state['netflowGlobal'],
64
- };
65
- });
66
- }
67
- exports.getLimitsState = getLimitsState;
68
- /**
69
- * Returns a human-friendly representation of the limits for the given exchange and asset
70
- * @param broker an instance of the broker
71
- * @param exchangeId the id of the exchange
72
- * @param asset the address of the asset with the limit
73
- * @returns a list of TradingLimit objects
74
- */
75
- function getLimits(broker, exchangeId, asset) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const [cfg, state] = yield Promise.all([
78
- getLimitsConfig(broker, exchangeId, asset),
79
- getLimitsState(broker, exchangeId, asset),
80
- ]);
81
- const limits = [];
82
- if (cfg.limit0 > 0) {
83
- limits.push({
84
- asset: asset,
85
- maxIn: cfg.limit0 - state.netflow0,
86
- maxOut: cfg.limit0 + state.netflow0,
87
- until: state.lastUpdated0 + cfg.timestep0,
88
- });
89
- }
90
- if (cfg.limit1 > 0) {
91
- limits.push({
92
- asset: asset,
93
- maxIn: cfg.limit1 - state.netflow1,
94
- maxOut: cfg.limit1 + state.netflow1,
95
- until: state.lastUpdated1 + cfg.timestep1,
96
- });
97
- }
98
- if (cfg.limitGlobal > 0) {
99
- const timestampIn2030 = 1893456000; // a far away timestamp
100
- limits.push({
101
- asset: asset,
102
- maxIn: cfg.limitGlobal - state.netflowGlobal,
103
- maxOut: cfg.limitGlobal + state.netflowGlobal,
104
- until: timestampIn2030,
105
- });
106
- }
107
- // Limits with a smaller timeframe are restricted by the ones with a larger one
108
- // e.g: if maxIn is 0 in LG, it should also be 0 in L1 and L0
109
- for (let i = limits.length - 1; i > 0; i--) {
110
- limits[i - 1].maxIn = Math.min(limits[i - 1].maxIn, limits[i].maxIn);
111
- limits[i - 1].maxOut = Math.min(limits[i - 1].maxOut, limits[i].maxOut);
112
- }
113
- return limits;
114
- });
115
- }
116
- exports.getLimits = getLimits;
117
- /**
118
- * Returns the limit id for the given exchange and asset
119
- * @param exchangeId the id of the exchange
120
- * @param asset the address of the asset with the limit
121
- * @returns the limit id
122
- */
123
- function getLimitId(exchangeId, asset) {
124
- const assetBytes32 = ethers_1.utils.zeroPad(asset, 32);
125
- const exchangeIdBytes = ethers_1.utils.arrayify(exchangeId);
126
- const assetBytes = ethers_1.utils.arrayify(assetBytes32);
127
- (0, assert_1.strict)(exchangeIdBytes.length === assetBytes.length, 'exchangeId and asset0 must be the same length');
128
- return ethers_1.utils.hexlify(exchangeIdBytes.map((b, i) => b ^ assetBytes[i]));
129
- }
130
- exports.getLimitId = getLimitId;
@@ -1,287 +0,0 @@
1
- import { IBroker } from '@mento-protocol/mento-core-ts';
2
- import { BigNumber, BigNumberish, providers, Signer } from 'ethers';
3
- import { Address, TradingLimit, TradingLimitsConfig, TradingLimitsState } from './interfaces';
4
- import { Identifier } from './constants/addresses';
5
- import { TokenSymbol } from './constants/tokens';
6
- import { TradablePairWithSpread } from './constants/tradablePairs';
7
- import { TradingMode } from './enums';
8
- export { TokenSymbol } from './constants/tokens';
9
- export interface Exchange {
10
- providerAddr: Address;
11
- id: string;
12
- assets: Address[];
13
- }
14
- export interface Asset {
15
- address: Address;
16
- symbol: string;
17
- }
18
- export interface Token {
19
- address: Address;
20
- symbol: TokenSymbol;
21
- name: string;
22
- decimals: number;
23
- }
24
- export type TradablePairID = `${Address}-${Address}`;
25
- export interface TradablePair {
26
- id: TradablePairID;
27
- assets: [Asset, Asset];
28
- path: Array<{
29
- providerAddr: Address;
30
- id: string;
31
- assets: [Address, Address];
32
- }>;
33
- }
34
- export declare class Mento {
35
- private readonly signerOrProvider;
36
- private readonly broker;
37
- private readonly router;
38
- private exchanges;
39
- private cachedChainId;
40
- /**
41
- * This constructor is private, use the static create or createWithParams methods
42
- * to create a new Mento instance
43
- * @param signerOrProvider an ethers provider or connected signer
44
- * @param brokerAddress the address of the broker contract
45
- * @param exchanges exchange data for the broker
46
- */
47
- private constructor();
48
- /**
49
- * Creates a new Mento object instance.
50
- * When constructed with only a Provider only read-only operations are supported
51
- * @param signerOrProvider an ethers signer or provider. A signer is required to execute swaps
52
- * @returns a new Mento object instance
53
- */
54
- static create(signerOrProvider: Signer | providers.Provider): Promise<Mento>;
55
- /**
56
- * Create a new Mento object instance given a broker address and optional exchanges data
57
- * When constructed with a Provider, only read-only operations are supported
58
- * @param signerOrProvider an ethers signer or provider. A signer is required to execute swaps
59
- * @param brokerAddr the address of the broker contract
60
- * @param exchanges the exchanges data for the broker
61
- * @returns a new Mento object instance
62
- */
63
- static createWithParams(signerOrProvider: Signer | providers.Provider, brokerAddr: Address, routerAddr: Address, exchanges?: Exchange[]): Mento;
64
- /**
65
- * Returns a new Mento instance connected to the given signer
66
- * @param signer an ethers signer
67
- * @returns new Mento object instance
68
- */
69
- connectSigner(signer: Signer): Mento;
70
- /**
71
- * Get tradable pairs for backwards compatibility
72
- * @returns an array of Asset pairs
73
- */
74
- getTradablePairs({ cached, }?: {
75
- cached?: boolean;
76
- }): Promise<[Asset, Asset][]>;
77
- /**
78
- * Returns a list of all tradable pairs on Mento via direct exchanges.
79
- * Each pair is represented using the TradablePair interface, with its id
80
- * (a concatenation of the two asset symbols in alphabetical order),
81
- * the two Asset objects, and a path (an array with a single direct exchange hop).
82
- * @returns An array of direct TradablePair objects.
83
- */
84
- getDirectPairs(): Promise<TradablePair[]>;
85
- /**
86
- * Returns a list of all tradable pairs on Mento, including those achievable
87
- * via two-hop routes. For two-hop pairs, the path will contain two exchange hops.
88
- * Each TradablePair contains an id (the concatenation of the two asset symbols in alphabetical order),
89
- * the two Asset objects, and an array of exchange details for each hop.
90
- * @param options - Optional parameters
91
- * @param options.cached - Whether to use cached data (default: true)
92
- * @param options.returnAllRoutes - Whether to return all possible routes or just the best one per pair (default: false)
93
- * @returns An array of TradablePair objects representing available trade routes.
94
- */
95
- getTradablePairsWithPath({ cached, returnAllRoutes, }?: {
96
- cached?: boolean;
97
- returnAllRoutes?: boolean;
98
- }): Promise<readonly (TradablePair | TradablePairWithSpread)[]>;
99
- /**
100
- * Attempts to get cached tradable pairs for the current chain
101
- */
102
- private getCachedTradablePairs;
103
- /**
104
- * Returns a list of all unique tokens available on the current chain.
105
- * This method is synchronous and uses pre-cached token data.
106
- * For runtime fetching from the blockchain, use getTokensAsync().
107
- *
108
- * @returns An array of unique Token objects from the static cache.
109
- * @throws Error if no cached tokens are available for the current chain or if chainId is not yet initialized
110
- */
111
- getTokens(): Token[];
112
- /**
113
- * Fetches token metadata from the blockchain at runtime.
114
- * This method is async and makes blockchain calls to get fresh token data.
115
- * For synchronous access using cached data, use getTokens().
116
- *
117
- * @param options - Optional parameters
118
- * @param options.cached - Whether to use cached data (default: true).
119
- * If true, attempts to load from static cache first.
120
- * @returns A Promise resolving to an array of unique Token objects.
121
- */
122
- getTokensAsync({ cached, }?: {
123
- cached?: boolean;
124
- }): Promise<Token[]>;
125
- /**
126
- * Returns the amount of tokenIn to be sold to buy amountOut of tokenOut.
127
- * If the provided tradablePair has a single (direct) pricing path, then direct pricing is used.
128
- * Otherwise, routed pricing via the MentoRouter is applied.
129
- * @param tokenIn the token to be sold
130
- * @param tokenOut the token to be bought
131
- * @param amountOut the desired amount of tokenOut to be obtained
132
- * @param tradablePair the TradablePair object containing the pricing path information
133
- * @returns the amount of tokenIn to be sold
134
- */
135
- getAmountIn(tokenIn: Address, tokenOut: Address, amountOut: BigNumberish, tradablePair?: TradablePair): Promise<BigNumber>;
136
- /**
137
- * Returns the amount of tokenOut to be bought by selling amountIn of tokenIn.
138
- * If the provided tradablePair has a single (direct) pricing path, then direct pricing is used.
139
- * Otherwise, routed pricing via the MentoRouter is applied.
140
- * @param tokenIn the token to be sold
141
- * @param tokenOut the token to be bought
142
- * @param amountIn the amount of tokenIn to be sold
143
- * @param tradablePair the TradablePair object containing the pricing path information
144
- * @returns the amount of tokenOut to be bought
145
- */
146
- getAmountOut(tokenIn: Address, tokenOut: Address, amountIn: BigNumberish, tradablePair?: TradablePair): Promise<BigNumber>;
147
- /**
148
- * Internal method for direct pricing: retrieves the exchange for the given tokens
149
- * and returns the amountIn using the broker.
150
- */
151
- private getAmountInDirect;
152
- /**
153
- * Internal method for direct pricing: retrieves the exchange for the given tokens
154
- * and returns the amountOut using the broker.
155
- */
156
- private getAmountOutDirect;
157
- /**
158
- * Internal method for routed pricing: uses the MentoRouter to determine the required tokenIn
159
- * for obtaining amountOut through a multi-hop route specified in tradablePair.path.
160
- */
161
- private getAmountInRouted;
162
- /**
163
- * Internal method for routed pricing: uses the MentoRouter to determine the amountOut
164
- * obtainable by selling amountIn through a multi-hop route specified in tradablePair.path.
165
- */
166
- private getAmountOutRouted;
167
- /**
168
- * Increases the broker's trading allowance for the given token
169
- * @param token the token to increase the allowance for
170
- * @param amount the amount to increase the allowance by
171
- * @returns the populated TransactionRequest object
172
- */
173
- increaseTradingAllowance(tokenIn: Address, amount: BigNumberish, tradablePair?: TradablePair): Promise<providers.TransactionRequest>;
174
- /**
175
- * Returns a token swap populated tx object with a fixed amount of tokenIn and a minimum amount of tokenOut.
176
- * If the tradablePair contains a single-hop route, a direct swap is executed using swapExactTokensForTokens on the broker.
177
- * Otherwise, a routed swap is executed via the router.
178
- * @param tokenIn the token to be sold
179
- * @param tokenOut the token to be bought
180
- * @param amountIn the amount of tokenIn to be sold
181
- * @param amountOutMin the minimum amount of tokenOut to be bought
182
- * @param tradablePair the tradable pair details to determine routing
183
- * @returns the populated TransactionRequest object
184
- */
185
- swapIn(tokenIn: Address, tokenOut: Address, amountIn: BigNumberish, amountOutMin: BigNumberish, tradablePair?: TradablePair): Promise<providers.TransactionRequest>;
186
- private swapInDirect;
187
- private swapInRouted;
188
- /**
189
- * Returns a token swap populated tx object with a maximum amount of tokenIn and a fixed amount of tokenOut.
190
- * If the tradablePair contains a single-hop route, a direct swap is executed using swapTokensForExactTokens on the broker.
191
- * Otherwise, a routed swap is executed via the router.
192
- * @param tokenIn the token to be sold
193
- * @param tokenOut the token to be bought
194
- * @param amountOut the amount of tokenOut to be bought
195
- * @param amountInMax the maximum amount of tokenIn to be sold
196
- * @returns the populated TransactionRequest object
197
- */
198
- swapOut(tokenIn: Address, tokenOut: Address, amountOut: BigNumberish, amountInMax: BigNumberish, tradablePair?: TradablePair): Promise<providers.TransactionRequest>;
199
- private swapOutDirect;
200
- private swapOutRouted;
201
- /**
202
- * Helper method to build the steps for a routed swap, ensuring proper token ordering
203
- * through the path segments
204
- */
205
- private buildSteps;
206
- /**
207
- * Returns the mento instance's broker contract
208
- * @returns broker contract
209
- */
210
- getBroker(): IBroker;
211
- /**
212
- * Finds a tradable pair for the given input and output tokens
213
- * @param tokenIn the input token address
214
- * @param tokenOut the output token address
215
- * @returns the tradable pair containing the path between the tokens
216
- * @throws if no path is found between the tokens
217
- */
218
- findPairForTokens(tokenIn: Address, tokenOut: Address): Promise<TradablePair>;
219
- /**
220
- * Returns the list of exchanges available in Mento (cached)
221
- * @returns the list of exchanges
222
- */
223
- getExchanges(): Promise<Exchange[]>;
224
- /**
225
- * Returns the list of exchanges for a given exchange provider address
226
- * @returns list of exchanges
227
- */
228
- getExchangesForProvider(exchangeProviderAddr: Address): Promise<Exchange[]>;
229
- /**
230
- * Returns the Mento exchange (if any) for a given pair of tokens
231
- * @param token0 the address of the first token
232
- * @param token1 the address of the second token
233
- * @returns exchange
234
- */
235
- getExchangeForTokens(token0: Address, token1: Address): Promise<Exchange>;
236
- /**
237
- * Returns the Mento exchange for a given exchange id
238
- * @param exchangeId the id of the exchange
239
- * @returns the exchange with the given id
240
- */
241
- getExchangeById(exchangeId: string): Promise<Exchange>;
242
- /**
243
- * Returns whether trading is enabled in the given mode for a given exchange id
244
- * @param exchangeId the id of the exchange
245
- * @param mode the trading mode
246
- * @returns true if trading is enabled in the given mode, false otherwise
247
- */
248
- isTradingEnabled(exchangeId: string): Promise<boolean>;
249
- /**
250
- * Returns the current trading mode for a given rate feed
251
- * @param rateFeedId the address of the rate feed
252
- * @returns the current trading mode (BIDIRECTIONAL, HALTED, or DISABLED)
253
- */
254
- getRateFeedTradingMode(rateFeedId: Address): Promise<TradingMode>;
255
- /**
256
- * Checks if a trading pair is currently tradable (i.e., all rate feeds in the path are in BIDIRECTIONAL mode)
257
- * For multi-hop routes (e.g., CELO → cUSD → USDT), checks that all intermediate rate feeds are tradable
258
- * @param tokenIn the address of the token to sell
259
- * @param tokenOut the address of the token to buy
260
- * @returns true if the pair is tradable (all rate feeds in BIDIRECTIONAL mode), false otherwise
261
- */
262
- isPairTradable(tokenIn: Address, tokenOut: Address): Promise<boolean>;
263
- /**
264
- * Return the trading limits for a given exchange id. Each limit is an object with the following fields:
265
- * asset: the address of the asset with the limit
266
- * maxIn: the maximum amount of the asset that can be sold
267
- * maxOut: the maximum amount of the asset that can be bought
268
- * until: the timestamp until which the limit is valid
269
- * @param exchangeId the id of the exchange
270
- * @returns the list of trading limits
271
- */
272
- getTradingLimits(exchangeId: string): Promise<TradingLimit[]>;
273
- /**
274
- * Returns the trading limits configurations for a given exchange id
275
- * @param exchangeId the id of the exchange
276
- * @returns the trading limits configuration
277
- */
278
- getTradingLimitConfig(exchangeId: string): Promise<TradingLimitsConfig[]>;
279
- /**
280
- * Returns the trading limits state for a given exchange id
281
- * @param exchangeId the id of the exchange
282
- * @returns the trading limits state
283
- */
284
- getTradingLimitState(exchangeId: string): Promise<TradingLimitsState[]>;
285
- getAddress(identifier: Identifier): Promise<Address>;
286
- chainId(): Promise<number>;
287
- }