aftermath-ts-sdk 1.2.63 → 1.2.64-docs.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 +61 -27
- package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
- package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
- package/dist/general/dynamicGas/dynamicGas.js +34 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
- package/dist/general/prices/prices.d.ts +73 -0
- package/dist/general/prices/prices.d.ts.map +1 -1
- package/dist/general/prices/prices.js +73 -0
- package/dist/general/providers/aftermath.d.ts +106 -25
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +108 -27
- package/dist/general/providers/aftermathApi.d.ts +127 -8
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +132 -12
- package/dist/general/types/castingTypes.d.ts +0 -7
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/castingTypes.js +6 -0
- package/dist/general/types/generalTypes.d.ts +228 -7
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/types/suiTypes.d.ts +0 -16
- package/dist/general/types/suiTypes.d.ts.map +1 -1
- package/dist/general/types/suiTypes.js +3 -25
- package/dist/general/utils/casting.d.ts +159 -3
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +162 -16
- package/dist/general/utils/fixedUtils.d.ts +89 -2
- package/dist/general/utils/fixedUtils.d.ts.map +1 -1
- package/dist/general/utils/fixedUtils.js +81 -4
- package/dist/general/utils/helpers.d.ts +320 -9
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +350 -89
- package/dist/general/utils/iFixedUtils.d.ts +64 -0
- package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
- package/dist/general/utils/iFixedUtils.js +64 -0
- package/dist/general/wallet/wallet.d.ts +75 -0
- package/dist/general/wallet/wallet.d.ts.map +1 -1
- package/dist/general/wallet/wallet.js +75 -5
- package/dist/packages/auth/auth.d.ts +113 -0
- package/dist/packages/auth/auth.d.ts.map +1 -1
- package/dist/packages/auth/auth.js +129 -15
- package/dist/packages/auth/authTypes.d.ts +66 -0
- package/dist/packages/auth/authTypes.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.js +28 -20
- package/dist/packages/coin/coin.d.ts +250 -0
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +238 -14
- package/dist/packages/coin/coinTypes.d.ts +93 -0
- package/dist/packages/coin/coinTypes.d.ts.map +1 -1
- package/dist/packages/dca/dca.d.ts +124 -35
- package/dist/packages/dca/dca.d.ts.map +1 -1
- package/dist/packages/dca/dca.js +127 -37
- package/dist/packages/dca/dcaTypes.d.ts +213 -28
- package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
- package/dist/packages/farms/farms.d.ts +184 -1
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farms.js +185 -11
- package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakedPosition.js +189 -144
- package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
- package/dist/packages/farms/farmsStakingPool.js +176 -70
- package/dist/packages/farms/farmsTypes.d.ts +283 -2
- package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
- package/dist/packages/farms/farmsTypes.js +18 -0
- package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
- package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
- package/dist/packages/limitOrders/limitOrders.js +110 -22
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.d.ts +33 -4
- package/dist/packages/multisig/multisig.d.ts.map +1 -1
- package/dist/packages/multisig/multisig.js +33 -4
- package/dist/packages/multisig/multisigTypes.d.ts +17 -0
- package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/pools/pool.d.ts +327 -85
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pool.js +333 -91
- package/dist/packages/pools/pools.d.ts +299 -37
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/pools/pools.js +306 -52
- package/dist/packages/pools/poolsTypes.d.ts +273 -8
- package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.d.ts +37 -0
- package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
- package/dist/packages/referralVault/referralVault.js +37 -0
- package/dist/packages/router/router.d.ts +213 -17
- package/dist/packages/router/router.d.ts.map +1 -1
- package/dist/packages/router/router.js +214 -18
- package/dist/packages/router/routerTypes.d.ts +198 -14
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/staking/staking.d.ts +301 -43
- package/dist/packages/staking/staking.d.ts.map +1 -1
- package/dist/packages/staking/staking.js +308 -51
- package/dist/packages/staking/stakingTypes.d.ts +426 -6
- package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
- package/dist/packages/staking/stakingTypes.js +19 -0
- package/dist/packages/sui/sui.d.ts +39 -0
- package/dist/packages/sui/sui.d.ts.map +1 -1
- package/dist/packages/sui/sui.js +39 -0
- package/dist/packages/userData/userData.d.ts +66 -12
- package/dist/packages/userData/userData.d.ts.map +1 -1
- package/dist/packages/userData/userData.js +66 -12
- package/dist/packages/userData/userDataTypes.d.ts +19 -0
- package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/package.json +1 -1
- package/dist/general/historicalData/historicalData.d.ts +0 -15
- package/dist/general/historicalData/historicalData.d.ts.map +0 -1
- package/dist/general/historicalData/historicalData.js +0 -45
- package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
- package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
- package/dist/general/historicalData/historicalDataTypes.js +0 -2
|
@@ -2,65 +2,315 @@ import { AnyObjectType, Balance, CallerConfig, CoinDecimal, CoinMetadaWithInfo,
|
|
|
2
2
|
import { Caller } from "../../general/utils/caller";
|
|
3
3
|
import { AftermathApi } from "../../general/providers";
|
|
4
4
|
import { CoinMetadata } from "@mysten/sui/client";
|
|
5
|
+
/**
|
|
6
|
+
* The `Coin` class provides functionality to manage and inspect coin types,
|
|
7
|
+
* retrieve metadata and prices, and convert balances with respect to coin decimals.
|
|
8
|
+
* It can be instantiated with or without a specific `coinType` for convenience.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
*
|
|
13
|
+
* const afSdk = new Aftermath("MAINNET");
|
|
14
|
+
* await afSdk.init(); // initialize provider
|
|
15
|
+
*
|
|
16
|
+
* const coin = afSdk.Coin("0x2::sui::SUI");
|
|
17
|
+
*
|
|
18
|
+
* const metadata = await coin.getCoinMetadata(); // fetch metadata for SUI coin
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
5
21
|
export declare class Coin extends Caller {
|
|
6
22
|
readonly coinType: CoinType | undefined;
|
|
7
23
|
private readonly Provider?;
|
|
24
|
+
/**
|
|
25
|
+
* Static configuration and defaults for Sui coin types, including the standard
|
|
26
|
+
* SUI coin type, default decimals, and coin object type path.
|
|
27
|
+
*/
|
|
8
28
|
static readonly constants: {
|
|
29
|
+
/**
|
|
30
|
+
* The canonical coin type string for SUI.
|
|
31
|
+
*/
|
|
9
32
|
suiCoinType: string;
|
|
33
|
+
/**
|
|
34
|
+
* The default number of decimals for SUI (9).
|
|
35
|
+
*/
|
|
10
36
|
suiCoinDecimals: number;
|
|
37
|
+
/**
|
|
38
|
+
* The canonical coin object type path for Sui's Move module, used in verifying coin objects.
|
|
39
|
+
*/
|
|
11
40
|
coinObjectType: string;
|
|
41
|
+
/**
|
|
42
|
+
* Default decimals for various blockchains or ecosystems. For instance,
|
|
43
|
+
* "sui" => 9, "evm" => 18, etc.
|
|
44
|
+
*/
|
|
12
45
|
defaultCoinDecimals: {
|
|
13
46
|
sui: number;
|
|
14
47
|
evm: number;
|
|
15
48
|
svm: number;
|
|
16
49
|
};
|
|
17
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* The Move package name portion of this coin type, e.g. the middle "module" from "0x2::sui::SUI".
|
|
53
|
+
* Will be empty if no `coinType` is provided.
|
|
54
|
+
*/
|
|
18
55
|
readonly coinTypePackageName: string;
|
|
56
|
+
/**
|
|
57
|
+
* The final part of the coin type (the "symbol" or short name) from "0x2::sui::SUI".
|
|
58
|
+
* Will be empty if no `coinType` is provided.
|
|
59
|
+
*/
|
|
19
60
|
readonly coinTypeSymbol: string;
|
|
61
|
+
/**
|
|
62
|
+
* If the coin type includes a generic argument (like `Coin<0x...>`), this is extracted. Else empty.
|
|
63
|
+
* E.g. "0x5::coin::Coin<0x2::sui::SUI>" => "0x2::sui::SUI".
|
|
64
|
+
*/
|
|
20
65
|
readonly innerCoinType: string;
|
|
66
|
+
/**
|
|
67
|
+
* An optional cached coin metadata object retrieved by `getCoinMetadata`.
|
|
68
|
+
*/
|
|
21
69
|
metadata: CoinMetadaWithInfo | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* An optional cached price info object retrieved by `getPrice`.
|
|
72
|
+
*/
|
|
22
73
|
priceInfo: CoinPriceInfo | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new instance of `Coin`.
|
|
76
|
+
*
|
|
77
|
+
* @param coinType - The coin's type string (e.g., "0x2::sui::SUI"). If omitted, methods that require a type will need it passed in manually.
|
|
78
|
+
* @param config - Optional caller configuration (network, access token).
|
|
79
|
+
* @param Provider - An optional `AftermathApi` instance for coin-specific API calls.
|
|
80
|
+
*/
|
|
23
81
|
constructor(coinType?: CoinType | undefined, config?: CallerConfig, Provider?: AftermathApi | undefined);
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the decimals for multiple coins by calling the Aftermath API for metadata
|
|
84
|
+
* and extracting the `decimals` property.
|
|
85
|
+
*
|
|
86
|
+
* @param inputs - An object containing an array of coin types.
|
|
87
|
+
* @returns An object mapping each coin type to a numeric decimal count.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const decimals = await coin.getCoinsToDecimals({ coins: ["0x2::sui::SUI", "0x<...>"] });
|
|
92
|
+
* console.log(decimals); // { "0x2::sui::SUI": 9, "0x<...>": 6 }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
24
95
|
getCoinsToDecimals(inputs: {
|
|
25
96
|
coins: CoinType[];
|
|
26
97
|
}): Promise<CoinsToDecimals>;
|
|
98
|
+
/**
|
|
99
|
+
* Fetches the metadata (name, symbol, decimals) for this coin type or a provided one,
|
|
100
|
+
* caching it if already requested.
|
|
101
|
+
*
|
|
102
|
+
* @param coin - Optionally override the constructor coinType.
|
|
103
|
+
* @returns The `CoinMetadaWithInfo` object containing metadata and optional external references.
|
|
104
|
+
* @throws If neither constructor nor argument coinType is available.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const metadata = await coin.getCoinMetadata("0x2::sui::SUI");
|
|
109
|
+
* console.log(metadata.name, metadata.symbol, metadata.decimals);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
27
112
|
getCoinMetadata(coin?: CoinType): Promise<CoinMetadaWithInfo>;
|
|
113
|
+
/**
|
|
114
|
+
* Fetches metadata for multiple coins at once, returning an array in the same order
|
|
115
|
+
* as the coin types requested.
|
|
116
|
+
*
|
|
117
|
+
* @param inputs - An object with `coins`, an array of coin types.
|
|
118
|
+
* @returns An array of `CoinMetadaWithInfo` with length matching `coins`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const metas = await coin.getCoinMetadatas({
|
|
123
|
+
* coins: ["0x2::sui::SUI", "0x<custom::TOKEN>"]
|
|
124
|
+
* });
|
|
125
|
+
* console.log(metas[0].symbol, metas[1].symbol);
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
28
128
|
getCoinMetadatas(inputs: {
|
|
29
129
|
coins: CoinType[];
|
|
30
130
|
}): Promise<CoinMetadaWithInfo[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Manually sets the metadata in this Coin instance, storing it in `this.metadata`.
|
|
133
|
+
*
|
|
134
|
+
* @param metadata - A `CoinMetadaWithInfo` object to cache in this instance.
|
|
135
|
+
*/
|
|
31
136
|
setCoinMetadata(metadata: CoinMetadaWithInfo): void;
|
|
137
|
+
/**
|
|
138
|
+
* Retrieves price information (including current price and 24h change) for this coin or a provided coin.
|
|
139
|
+
* If already fetched, it returns the cached data.
|
|
140
|
+
*
|
|
141
|
+
* @param coin - Optionally override the constructor coinType.
|
|
142
|
+
* @returns A `CoinPriceInfo` with `price` and `priceChange24HoursPercentage`.
|
|
143
|
+
* @throws If no valid coin type is present.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const priceInfo = await coin.getPrice("0x2::sui::SUI");
|
|
148
|
+
* console.log(priceInfo.price, priceInfo.priceChange24HoursPercentage);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
32
151
|
getPrice(coin?: CoinType): Promise<CoinPriceInfo>;
|
|
152
|
+
/**
|
|
153
|
+
* Manually sets the price info in this Coin instance, storing it in `this.priceInfo`.
|
|
154
|
+
*
|
|
155
|
+
* @param priceInfo - A `CoinPriceInfo` object to cache in this instance.
|
|
156
|
+
*/
|
|
33
157
|
setPriceInfo(priceInfo: CoinPriceInfo): void;
|
|
158
|
+
/**
|
|
159
|
+
* Fetches a list of "verified" coin types from the Aftermath backend. Verified coins
|
|
160
|
+
* typically pass certain safety or liquidity checks.
|
|
161
|
+
*
|
|
162
|
+
* @returns An array of `CoinType` strings that are considered verified.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const verified = await coin.getVerifiedCoins();
|
|
167
|
+
* console.log(verified); // e.g. ["0x2::sui::SUI", "0x...::MYCOIN", ...]
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
34
170
|
getVerifiedCoins(): Promise<string[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Extracts the Move package name portion from a coin type string.
|
|
173
|
+
* E.g., "0x2::sui::SUI" => "sui".
|
|
174
|
+
*
|
|
175
|
+
* @param coin - The coin type string (e.g., "0x2::sui::SUI").
|
|
176
|
+
* @returns The middle segment of the type or empty string if not parseable.
|
|
177
|
+
*/
|
|
35
178
|
static getCoinTypePackageName: (coin: CoinType) => string;
|
|
179
|
+
/**
|
|
180
|
+
* Extracts the final part of the coin type (the symbol or short name).
|
|
181
|
+
* For example, "0x2::sui::SUI" => "SUI".
|
|
182
|
+
*
|
|
183
|
+
* @param coin - The coin type string.
|
|
184
|
+
* @returns The extracted symbol or empty string if not found.
|
|
185
|
+
*/
|
|
36
186
|
static getCoinTypeSymbol: (coin: CoinType) => string;
|
|
187
|
+
/**
|
|
188
|
+
* Extracts the inner generic argument of a coin type if present. E.g.,
|
|
189
|
+
* "0x2::coin::Coin<0x2::sui::SUI>" => "0x2::sui::SUI".
|
|
190
|
+
*
|
|
191
|
+
* @param coin - The coin type with a possible `<...>` suffix.
|
|
192
|
+
* @returns The inner type or an empty string if not found.
|
|
193
|
+
*/
|
|
37
194
|
static getInnerCoinType: (coin: CoinType) => string;
|
|
195
|
+
/**
|
|
196
|
+
* If a `KeyType` string references a type in angle brackets, extracts the type
|
|
197
|
+
* inside. Typically for "0x2::coin::Coin<0x2::mycoin::MYCOIN>" -> "0x2::mycoin::MYCOIN".
|
|
198
|
+
*
|
|
199
|
+
* @param keyType - The key type string to parse.
|
|
200
|
+
* @returns The substring inside `<...>` or the original if no brackets found.
|
|
201
|
+
*/
|
|
38
202
|
static coinTypeFromKeyType: (keyType: KeyType) => string;
|
|
203
|
+
/**
|
|
204
|
+
* Checks if a coin type string corresponds to the canonical SUI coin.
|
|
205
|
+
*
|
|
206
|
+
* @param coin - A coin type string.
|
|
207
|
+
* @returns `true` if it matches "0x2::sui::SUI", otherwise `false`.
|
|
208
|
+
*/
|
|
39
209
|
static isSuiCoin: (coin: CoinType) => boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Checks if an object type string is a `Coin<...>` object from the standard Sui Move module.
|
|
212
|
+
*
|
|
213
|
+
* @param objectType - The object type to test.
|
|
214
|
+
* @returns `true` if it matches "0x2::coin::Coin<...>", otherwise `false`.
|
|
215
|
+
*/
|
|
40
216
|
static isCoinObjectType: (objectType: AnyObjectType) => boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Given a record of coin types => numeric amounts, filters out those
|
|
219
|
+
* with zero or negative amounts, returning only the positive pairs.
|
|
220
|
+
*
|
|
221
|
+
* @param coinAmounts - A record mapping coin types to numeric amounts.
|
|
222
|
+
* @returns An object with `coins` array and `amounts` array in matching indexes.
|
|
223
|
+
*/
|
|
41
224
|
static coinsAndAmountsOverZero: (coinAmounts: Record<CoinType, number>) => {
|
|
42
225
|
coins: string[];
|
|
43
226
|
amounts: number[];
|
|
44
227
|
};
|
|
228
|
+
/**
|
|
229
|
+
* Given a record of coin types => bigint balances, filters out those with zero
|
|
230
|
+
* or negative balances, returning only the positive pairs.
|
|
231
|
+
*
|
|
232
|
+
* @param coinsToBalance - A record mapping coin types to bigints.
|
|
233
|
+
* @returns An object with `coins` array and `balances` array in matching indexes.
|
|
234
|
+
*/
|
|
45
235
|
static coinsAndBalancesOverZero: (coinsToBalance: CoinsToBalance) => {
|
|
46
236
|
coins: string[];
|
|
47
237
|
balances: bigint[];
|
|
48
238
|
};
|
|
239
|
+
/**
|
|
240
|
+
* Filters a list of `coinTypes` by a textual query, matching against both zero-padded
|
|
241
|
+
* and non-padded forms as well as substring checks.
|
|
242
|
+
*
|
|
243
|
+
* @param inputs - Contains `filter` (the search string) and `coinTypes`.
|
|
244
|
+
* @returns An array of coin types that match the filter in either raw or zero-padded form.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const filtered = Coin.filterCoinsByType({
|
|
249
|
+
* filter: "sui",
|
|
250
|
+
* coinTypes: ["0x2::sui::SUI", "0x<...>"]
|
|
251
|
+
* });
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
49
254
|
static filterCoinsByType: (inputs: {
|
|
50
255
|
filter: string;
|
|
51
256
|
coinTypes: CoinType[];
|
|
52
257
|
}) => CoinType[];
|
|
258
|
+
/**
|
|
259
|
+
* Filters a record of coin metadata by a textual query, matching both the coin type
|
|
260
|
+
* and the metadata's name/symbol fields.
|
|
261
|
+
*
|
|
262
|
+
* @param inputs - An object containing `filter` and a record of `coinMetadatas`.
|
|
263
|
+
* @returns An array of coin types that match the search criteria.
|
|
264
|
+
*/
|
|
53
265
|
static filterCoinsByMetadata: (inputs: {
|
|
54
266
|
filter: string;
|
|
55
267
|
coinMetadatas: Record<CoinType, CoinMetadata>;
|
|
56
268
|
}) => CoinType[];
|
|
269
|
+
/**
|
|
270
|
+
* Converts a user-friendly decimal number (e.g., 1.5) to a raw on-chain
|
|
271
|
+
* integer representation by scaling with the given coin decimals.
|
|
272
|
+
* For example, `1.5` with `decimals = 9` => `1500000000n`.
|
|
273
|
+
*
|
|
274
|
+
* @param balance - The user-friendly balance as a number.
|
|
275
|
+
* @param decimals - Number of decimal places for this coin.
|
|
276
|
+
* @returns A bigint representing the raw on-chain balance.
|
|
277
|
+
*/
|
|
57
278
|
static normalizeBalance: (balance: number, decimals: CoinDecimal) => Balance;
|
|
279
|
+
/**
|
|
280
|
+
* Scales a raw bigint or numeric `amount` down by `decimals` to get a display-friendly float.
|
|
281
|
+
* For example, `1500000000n` with `decimals = 9` => `1.5`.
|
|
282
|
+
*
|
|
283
|
+
* @param amount - The raw on-chain amount as `bigint` or `number`.
|
|
284
|
+
* @param decimals - Number of decimal places for this coin.
|
|
285
|
+
* @returns The resulting float as an easily readable balance.
|
|
286
|
+
*/
|
|
58
287
|
static balanceWithDecimals: (amount: bigint | number, decimals: number) => number;
|
|
288
|
+
/**
|
|
289
|
+
* Scales a raw `amount` down by `decimals` and multiplies by a `price` in USD,
|
|
290
|
+
* returning a final USD value. E.g., `1500000000n`, `decimals=9`, `price=2.0` => `3.0`.
|
|
291
|
+
*
|
|
292
|
+
* @param amount - The raw balance as bigint or number.
|
|
293
|
+
* @param decimals - The coin decimals.
|
|
294
|
+
* @param price - The coin's price in USD.
|
|
295
|
+
* @returns The computed float in USD.
|
|
296
|
+
*/
|
|
59
297
|
static balanceWithDecimalsUsd: (amount: bigint | number, decimals: number, price: number) => number;
|
|
298
|
+
/**
|
|
299
|
+
* Looks up a coin's symbol if it is known in a provided `coinSymbolToCoinTypes`
|
|
300
|
+
* record. For instance, if "SUI" => `["0x2::sui::SUI"]`, we can find "SUI" from
|
|
301
|
+
* the coin type "0x2::sui::SUI".
|
|
302
|
+
*
|
|
303
|
+
* @param inputs - An object with `coinType` and `coinSymbolToCoinTypes`.
|
|
304
|
+
* @returns The coin symbol string or `undefined` if not found.
|
|
305
|
+
*/
|
|
60
306
|
static coinSymbolForCoinType: (inputs: {
|
|
61
307
|
coinType: CoinType;
|
|
62
308
|
coinSymbolToCoinTypes: CoinSymbolToCoinTypes;
|
|
63
309
|
}) => CoinSymbol | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* Internal method to retrieve a specialized coin-related API from `AftermathApi`.
|
|
312
|
+
* Throws an error if no provider is set.
|
|
313
|
+
*/
|
|
64
314
|
private useProvider;
|
|
65
315
|
}
|
|
66
316
|
//# sourceMappingURL=coin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/packages/coin/coin.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,eAAe,EACf,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,OAAO,EAGP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,qBAAa,IAAK,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../../src/packages/coin/coin.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,eAAe,EACf,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,OAAO,EAGP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,IAAK,SAAQ,MAAM;aA4Ed,QAAQ,EAAE,QAAQ,GAAG,SAAS;IAE9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAzE3B;;;OAGG;IACH,gBAAuB,SAAS;QAC/B;;WAEG;;QAGH;;WAEG;;QAEH;;WAEG;;QAGH;;;WAGG;;;;;;MAMF;IAMF;;;OAGG;IACH,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,SAAgB,aAAa,EAAE,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