@berachain/berajs 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/BeraError-CfcNTfpH.d.ts +69 -0
- package/dist/BexStatusProvider-nS3NcdxI.d.ts +70 -0
- package/dist/RequestError-CtJLUaAc.d.ts +57 -0
- package/dist/abi/index.d.ts +26765 -0
- package/dist/abi/index.mjs +1 -0
- package/dist/actions/index.d.ts +1649 -0
- package/dist/actions/index.mjs +1 -0
- package/dist/aggregatorsRouter-Cny4B_MB.d.ts +593 -0
- package/dist/chunk-4IBBLGNS.mjs +1 -0
- package/dist/chunk-5GPS724E.mjs +1 -0
- package/dist/chunk-5UFI7X4U.mjs +1 -0
- package/dist/chunk-AHAZC5K3.mjs +1 -0
- package/dist/chunk-JQDPAEK2.mjs +2 -0
- package/dist/chunk-K4NZIO2Z.mjs +1 -0
- package/dist/chunk-MTBICGRP.mjs +1 -0
- package/dist/chunk-RNESAHY2.mjs +3 -0
- package/dist/chunk-SMZ3PG6A.mjs +1 -0
- package/dist/chunk-XX77QPIR.mjs +1 -0
- package/dist/chunk-YKNKCICU.mjs +1 -0
- package/dist/contexts/index.d.ts +81 -0
- package/dist/contexts/index.mjs +1 -0
- package/dist/defaultFlags-V-tJs2K8.d.ts +10 -0
- package/dist/dex-BD7Bq3pJ.d.ts +562 -0
- package/dist/dex-DreiokgL.d.ts +562 -0
- package/dist/enum/index.d.ts +31 -0
- package/dist/enum/index.mjs +1 -0
- package/dist/errors/index.d.ts +204 -0
- package/dist/errors/index.mjs +1 -0
- package/dist/getValidatorQueuedOperatorAddress--AXNo9IY.d.ts +440 -0
- package/dist/getValidatorQueuedOperatorAddress-DK2Xv19c.d.ts +440 -0
- package/dist/hooks/index.d.ts +1703 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/polling-BKnyavLI.d.ts +8 -0
- package/dist/pythWrapper-CBjsmmsK.d.ts +1958 -0
- package/dist/staking-Cggi38So.d.ts +246 -0
- package/dist/staking-DYbVFigB.d.ts +246 -0
- package/dist/txnEnum-BQKDfaeH.d.ts +81 -0
- package/dist/txnEnum-Diichv9Z.d.ts +80 -0
- package/dist/types/index.d.ts +56 -0
- package/dist/types/index.mjs +1 -0
- package/dist/useHoneySwapState-CW49RVci.d.ts +32 -0
- package/dist/useHoneySwapState-Ci8_c2bT.d.ts +32 -0
- package/dist/utils/index.d.ts +349 -0
- package/dist/utils/index.mjs +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { SwapKind } from '@berachain-foundation/berancer-sdk';
|
|
2
|
+
import { Address, PublicClient, Hex, Abi, ContractFunctionName, ContractFunctionArgs, TransactionReceipt, WalletCallReceipt, Account } from 'viem';
|
|
3
|
+
import { a as aggregatorsRouterAbi } from './aggregatorsRouter-Cny4B_MB.js';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import { Token as Token$1 } from '@berachain/graphql/pol/api';
|
|
7
|
+
import { Config, GetWalletClientReturnType } from '@wagmi/core';
|
|
8
|
+
import { SWRConfiguration, SWRResponse } from 'swr';
|
|
9
|
+
import { ChainId, BeraConfig } from '@berachain/config';
|
|
10
|
+
import { T as TransactionActionType } from './txnEnum-BQKDfaeH.js';
|
|
11
|
+
import { B as BeraError } from './BeraError-CfcNTfpH.js';
|
|
12
|
+
|
|
13
|
+
interface CollateralRates {
|
|
14
|
+
mintFee: number;
|
|
15
|
+
redeemFee: number;
|
|
16
|
+
}
|
|
17
|
+
interface HoneyFeeMap {
|
|
18
|
+
single: Record<Address, CollateralRates>;
|
|
19
|
+
basket: CollateralRates;
|
|
20
|
+
}
|
|
21
|
+
interface CollateralRatesArgs extends BeraJS.BaseFunctionArgs {
|
|
22
|
+
client: PublicClient;
|
|
23
|
+
collateralList: Token$1[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the mint and redeem rates for all collateral tokens and calculates the weighted basket rates
|
|
27
|
+
* @param {Object} params - The parameters object
|
|
28
|
+
* @param {PublicClient} params.client - The Viem public client instance
|
|
29
|
+
* @param {Address[]} params.collateralList - Array of collateral token addresses
|
|
30
|
+
* @returns {Promise<HoneyFeeMap | undefined>} Object containing individual collateral rates and weighted basket rates,
|
|
31
|
+
* or undefined if the operation fails
|
|
32
|
+
*/
|
|
33
|
+
declare function getHoneyFees({ client, collateralList, ...args }: CollateralRatesArgs): Promise<HoneyFeeMap>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Interface representing the latest Pyth price updates
|
|
37
|
+
* @interface PythLatestUpdates
|
|
38
|
+
* @property {`0x${string}`[]} calldata - Array of hex-encoded calldata for price updates
|
|
39
|
+
* @property {string[]} prices - Array of formatted price strings
|
|
40
|
+
*/
|
|
41
|
+
interface PythLatestUpdates {
|
|
42
|
+
calldata: `0x${string}`[];
|
|
43
|
+
prices: string[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Fetches the latest price updates from Pyth Network's Hermes service
|
|
47
|
+
* @param {Object} params - The parameters object
|
|
48
|
+
* @param {string[]} params.priceFeedId - Array of Pyth price feed IDs to fetch updates for
|
|
49
|
+
* @returns {Promise<PythLatestUpdates>} Promise resolving to the latest price updates
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const updates = await getPythLatestPrices({
|
|
53
|
+
* priceFeedId: ["0x123...", "0x456..."]
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function getPythLatestPrices({ priceFeedId, }: {
|
|
58
|
+
priceFeedId: string[];
|
|
59
|
+
}): Promise<PythLatestUpdates>;
|
|
60
|
+
|
|
61
|
+
declare enum HoneyPreviewMethod {
|
|
62
|
+
Mint = "previewMintHoney",
|
|
63
|
+
MintWithPrice = "previewMintHoneyWithPrices",
|
|
64
|
+
RequiredCollateral = "previewMintCollaterals",
|
|
65
|
+
RequiredCollateralWithPrice = "previewMintCollateralsWithPrices",
|
|
66
|
+
Redeem = "previewRedeemCollaterals",
|
|
67
|
+
RedeemWithPrice = "previewRedeemCollateralsWithPrices",
|
|
68
|
+
HoneyToRedeem = "previewRedeemHoney",
|
|
69
|
+
HoneyToRedeemWithPrice = "previewRedeemHoneyWithPrices"
|
|
70
|
+
}
|
|
71
|
+
interface HoneyPreviewArgs extends BeraJS.BaseFunctionArgs {
|
|
72
|
+
client: PublicClient;
|
|
73
|
+
collateral: Token;
|
|
74
|
+
collateralList: TokenWithOrder[];
|
|
75
|
+
amount: string;
|
|
76
|
+
method: HoneyPreviewMethod;
|
|
77
|
+
latestPrices?: PythLatestUpdates;
|
|
78
|
+
isPythWrapperEnabled: boolean;
|
|
79
|
+
}
|
|
80
|
+
interface HoneyPreviewResult {
|
|
81
|
+
collaterals: Record<Address, bigint>;
|
|
82
|
+
honey: bigint;
|
|
83
|
+
}
|
|
84
|
+
interface HoneyPreviewReadResult {
|
|
85
|
+
collaterals: bigint[];
|
|
86
|
+
honey: bigint;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Calculates preview amounts for Honey protocol operations including minting and redeeming.
|
|
90
|
+
* This function handles different preview methods to calculate either the amount of Honey tokens
|
|
91
|
+
* that can be minted with given collateral or the amount of collateral needed to mint/redeem Honey tokens.
|
|
92
|
+
*
|
|
93
|
+
* @param {Object} params - The parameters for the preview calculation
|
|
94
|
+
* @param {PublicClient} params.client - The Viem public client for blockchain interaction
|
|
95
|
+
* @param {Token} params.collateral - The primary collateral token being used
|
|
96
|
+
* @param {Address[]} params.collateralList - List of all supported collateral tokens
|
|
97
|
+
* @param {string} params.amount - The amount to calculate preview for (in token units)
|
|
98
|
+
* @param {HoneyPreviewMethod} params.method - The type of preview calculation to perform
|
|
99
|
+
* @param {PythLatestUpdates | undefined} params.latestPrices - Optional latest price updates from Pyth oracle
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<HoneyPreviewResult | undefined>} An object containing:
|
|
102
|
+
* - collaterals: Record mapping collateral token addresses to their respective amounts
|
|
103
|
+
* - honey: The amount of Honey tokens involved in the operation
|
|
104
|
+
*
|
|
105
|
+
* @throws {Error} If there's an error during the contract interaction or calculation
|
|
106
|
+
*/
|
|
107
|
+
declare function getHoneyPreview({ client, collateral, collateralList, amount, method, latestPrices, isPythWrapperEnabled, ...baseArgs }: HoneyPreviewArgs): Promise<HoneyPreviewResult | undefined>;
|
|
108
|
+
|
|
109
|
+
declare enum HoneySwapAction {
|
|
110
|
+
RESET_AMOUNTS = "RESET_AMOUNTS",
|
|
111
|
+
ACTION_TYPE_CHANGE = "ACTION_TYPE_CHANGE",
|
|
112
|
+
COLLATERALS_CHANGE = "COLLATERALS_CHANGE",
|
|
113
|
+
FROM_AMOUNT_CHANGE = "FROM_AMOUNT_CHANGE",
|
|
114
|
+
TO_AMOUNT_CHANGE = "TO_AMOUNT_CHANGE",
|
|
115
|
+
PREVIEW_CHANGE = "PREVIEW_CHANGE",
|
|
116
|
+
IS_BASKET_MODE_ENABLED_CHANGE = "IS_BASKET_MODE_ENABLED_CHANGE",
|
|
117
|
+
IS_TYPING_CHANGE = "IS_TYPING_CHANGE",
|
|
118
|
+
IS_SUBMITTING_CHANGE = "IS_SUBMITTING_CHANGE",
|
|
119
|
+
IS_LOADING_CHANGE = "IS_LOADING_CHANGE"
|
|
120
|
+
}
|
|
121
|
+
type PythPriceFeedMap = Record<Address, Hex>;
|
|
122
|
+
type HoneySwapActions = {
|
|
123
|
+
type: HoneySwapAction.RESET_AMOUNTS;
|
|
124
|
+
} | {
|
|
125
|
+
type: HoneySwapAction.ACTION_TYPE_CHANGE;
|
|
126
|
+
value: "mint" | "redeem";
|
|
127
|
+
} | {
|
|
128
|
+
type: HoneySwapAction.COLLATERALS_CHANGE;
|
|
129
|
+
value: TokenWithOrder[];
|
|
130
|
+
} | {
|
|
131
|
+
type: HoneySwapAction.FROM_AMOUNT_CHANGE;
|
|
132
|
+
index: number;
|
|
133
|
+
value: string;
|
|
134
|
+
} | {
|
|
135
|
+
type: HoneySwapAction.TO_AMOUNT_CHANGE;
|
|
136
|
+
index: number;
|
|
137
|
+
value: string;
|
|
138
|
+
} | {
|
|
139
|
+
type: HoneySwapAction.PREVIEW_CHANGE;
|
|
140
|
+
value: HoneyPreviewResult;
|
|
141
|
+
changedAsset: Address;
|
|
142
|
+
} | {
|
|
143
|
+
type: HoneySwapAction.IS_BASKET_MODE_ENABLED_CHANGE;
|
|
144
|
+
value: boolean;
|
|
145
|
+
} | {
|
|
146
|
+
type: HoneySwapAction.IS_TYPING_CHANGE;
|
|
147
|
+
value: boolean;
|
|
148
|
+
} | {
|
|
149
|
+
type: HoneySwapAction.IS_SUBMITTING_CHANGE;
|
|
150
|
+
value: boolean;
|
|
151
|
+
} | {
|
|
152
|
+
type: HoneySwapAction.IS_LOADING_CHANGE;
|
|
153
|
+
value: boolean;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
declare const HoneyConfigContext: react.Context<HoneyConfigContextReturn | undefined>;
|
|
157
|
+
type TokenWithOrder = TokenWithMetadata & {
|
|
158
|
+
order: number;
|
|
159
|
+
};
|
|
160
|
+
interface HoneyConfigContextReturn {
|
|
161
|
+
/**
|
|
162
|
+
* Map of the Pyth price feed ids for each collateral
|
|
163
|
+
*/
|
|
164
|
+
priceFeedMap: PythPriceFeedMap;
|
|
165
|
+
/**
|
|
166
|
+
* This is the list of all the collaterals that are supported by the Honey protocol
|
|
167
|
+
*/
|
|
168
|
+
collateralList: TokenWithOrder[];
|
|
169
|
+
/**
|
|
170
|
+
* This is the main collateral that is used to calculate the relative cap limit
|
|
171
|
+
*/
|
|
172
|
+
referenceCollateral: TokenWithOrder;
|
|
173
|
+
/**
|
|
174
|
+
* An object that maps the redeem/mint rate for each collateral and the weighted rates for the basket mode
|
|
175
|
+
*/
|
|
176
|
+
feeMap: HoneyFeeMap;
|
|
177
|
+
flags: {
|
|
178
|
+
/**
|
|
179
|
+
* If true, mint/redeem will also update pyth prices
|
|
180
|
+
*/
|
|
181
|
+
isPythWrapperEnabled: boolean;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Honey protocol configs
|
|
185
|
+
*/
|
|
186
|
+
protocol: {
|
|
187
|
+
/**
|
|
188
|
+
* Honey protocol paused state
|
|
189
|
+
*/
|
|
190
|
+
isPaused: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The label for the Honey protocol paused message
|
|
193
|
+
*/
|
|
194
|
+
pausedBannerLabel?: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
interface HoneyConfigProviderProps extends HoneyConfigContextReturn {
|
|
198
|
+
children: React.ReactNode;
|
|
199
|
+
}
|
|
200
|
+
declare function HoneyConfigProvider({ children, ...props }: HoneyConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
201
|
+
declare function useHoneyConfig(): HoneyConfigContextReturn;
|
|
202
|
+
|
|
203
|
+
interface UseContractWriteApi {
|
|
204
|
+
isLoading: boolean;
|
|
205
|
+
isSubmitting: boolean;
|
|
206
|
+
isSuccess: boolean;
|
|
207
|
+
isError: boolean;
|
|
208
|
+
write: IContractWriteFn;
|
|
209
|
+
reset: () => void;
|
|
210
|
+
}
|
|
211
|
+
type PropagatedArgs<args> = Omit<args, TxnEventKeys | "contractName"> & {
|
|
212
|
+
contractName?: string;
|
|
213
|
+
};
|
|
214
|
+
type TxnEventKeys = "onSuccess" | "onError" | "onLoading" | "onSubmission" | "onWarning";
|
|
215
|
+
interface IUseContractWriteArgs<abi extends Abi | undefined = undefined, functionName extends abi extends Abi ? ContractFunctionName<abi> : never = abi extends Abi ? ContractFunctionName<abi> : never, params extends abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never = abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never> {
|
|
216
|
+
onSuccess?: (receipts: TransactionReceipt | WalletCallReceipt<bigint, "success" | "reverted">,
|
|
217
|
+
/**
|
|
218
|
+
* Arguments that were used to call the write function.
|
|
219
|
+
*/
|
|
220
|
+
writeArgs: PropagatedArgs<IContractWrite<abi, functionName, params>>) => void;
|
|
221
|
+
onError?: (e: BeraError,
|
|
222
|
+
/**
|
|
223
|
+
* Arguments that were used to call the write function.
|
|
224
|
+
*/
|
|
225
|
+
writeArgs: PropagatedArgs<IContractWrite<abi, functionName, params>>) => void;
|
|
226
|
+
onLoading?: (
|
|
227
|
+
/**
|
|
228
|
+
* Arguments that were used to call the write function.
|
|
229
|
+
*/
|
|
230
|
+
writeArgs: PropagatedArgs<IContractWrite<abi, functionName, params>>) => void;
|
|
231
|
+
onSubmission?: (
|
|
232
|
+
/**
|
|
233
|
+
* @param args.id If request is a batch call, this will be the id of the request to the wallet provider
|
|
234
|
+
* @param args.txHash If request is a single transaction, this will be the hash of the transaction to wait for
|
|
235
|
+
*/
|
|
236
|
+
args: {
|
|
237
|
+
txHash: Hex;
|
|
238
|
+
id?: never;
|
|
239
|
+
} | {
|
|
240
|
+
id: string;
|
|
241
|
+
txHash?: never;
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Arguments that were used to call the write function.
|
|
245
|
+
*/
|
|
246
|
+
writeArgs: PropagatedArgs<IContractWrite<abi, functionName, params>>) => void;
|
|
247
|
+
/**
|
|
248
|
+
* Callback function executed when a transaction encounters a warning. Transaction will still be submitted.
|
|
249
|
+
*/
|
|
250
|
+
onWarning?: (e: BeraError, writeArgs: Omit<IContractWrite<abi, functionName, params>, TxnEventKeys>) => void;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
type DefaultHookOptions = {
|
|
254
|
+
opts?: SWRConfiguration & {
|
|
255
|
+
isEnabled?: boolean;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
type DefaultHookReturnType<T = any> = Omit<SWRResponse<T, any, any>, "mutate"> & {
|
|
259
|
+
refresh: () => void;
|
|
260
|
+
};
|
|
261
|
+
interface TokenBalance {
|
|
262
|
+
address: Address;
|
|
263
|
+
/**
|
|
264
|
+
* Balance in wei, should be string to be serializable in JSON
|
|
265
|
+
*/
|
|
266
|
+
balance: bigint | string;
|
|
267
|
+
formattedBalance: string;
|
|
268
|
+
/**
|
|
269
|
+
* Balance in USD
|
|
270
|
+
*/
|
|
271
|
+
usdValue?: number;
|
|
272
|
+
}
|
|
273
|
+
interface AllowanceToken extends Token {
|
|
274
|
+
allowance: bigint;
|
|
275
|
+
formattedAllowance: string;
|
|
276
|
+
}
|
|
277
|
+
type IContractWriteFn = <abi extends Abi | undefined = undefined, functionName extends abi extends Abi ? ContractFunctionName<abi> : never = abi extends Abi ? ContractFunctionName<abi> : never, params extends abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never = abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never>(props: IContractWrite<abi, functionName, params>) => Promise<TransactionReceipt | WalletCallReceipt<bigint, "success" | "reverted"> | undefined>;
|
|
278
|
+
/**
|
|
279
|
+
* Posthog must be able to serialize this. BigInts are not supported.
|
|
280
|
+
*/
|
|
281
|
+
type AllowedEventData = number | string | boolean | null | undefined;
|
|
282
|
+
type EventData = Record<string, AllowedEventData | AllowedEventData[] | Record<string, AllowedEventData | AllowedEventData[] | Record<string, AllowedEventData | AllowedEventData[]>>>;
|
|
283
|
+
/**
|
|
284
|
+
* A list of contract names that are not mapped in the devrel's contract mapping or that are generated by factories (e.g. RewardVault).
|
|
285
|
+
*/
|
|
286
|
+
declare enum ContractName {
|
|
287
|
+
ENSO_ROUTER = "enso.router",
|
|
288
|
+
POL_REWARD_VAULT = "pol.rewardVault",
|
|
289
|
+
BEX_POOL = "bex.pool",
|
|
290
|
+
ERC20 = "others.erc20",
|
|
291
|
+
BEX_EXPLOITED_FUND_DISTRIBUTOR = "bex.exploitedFundDistributor"
|
|
292
|
+
}
|
|
293
|
+
type IContractWrite<abi extends Abi | undefined = undefined, functionName extends abi extends Abi ? ContractFunctionName<abi> : never = abi extends Abi ? ContractFunctionName<abi> : never, params extends abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never = abi extends Abi ? ContractFunctionArgs<abi, "payable" | "nonpayable", functionName> : never> = {
|
|
294
|
+
/**
|
|
295
|
+
* A message that will be shown to user while the transaction is pending.
|
|
296
|
+
*
|
|
297
|
+
* @example "Sending approvals"
|
|
298
|
+
*/
|
|
299
|
+
message: string;
|
|
300
|
+
/**
|
|
301
|
+
* The chain ID of the transaction.
|
|
302
|
+
*
|
|
303
|
+
* @default berachainChainId
|
|
304
|
+
*/
|
|
305
|
+
chainId?: ChainId;
|
|
306
|
+
/**
|
|
307
|
+
* The type of transaction to be performed. It will be stored in the transaction history.
|
|
308
|
+
*
|
|
309
|
+
* Generally uses infinite tense.
|
|
310
|
+
* @example TransactionActionType.APPROVAL => "Approve tokens"
|
|
311
|
+
*/
|
|
312
|
+
actionType: TransactionActionType;
|
|
313
|
+
txnName?: string;
|
|
314
|
+
gasLimit?: bigint;
|
|
315
|
+
account?: Account | Address;
|
|
316
|
+
/**
|
|
317
|
+
* Wheter the transaction can be sent by any account. Before setting this to true, make sure smart contract doesn't rely on `msg.sender`.
|
|
318
|
+
*
|
|
319
|
+
* Only transaction with permissionless flag set to true can be sent with overriden account.
|
|
320
|
+
* Everything else will throw an error.
|
|
321
|
+
*/
|
|
322
|
+
permissionless?: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* The event to be tracked more specifically.
|
|
325
|
+
* If not provided, the event will be tracked with the message and actionType.
|
|
326
|
+
*/
|
|
327
|
+
track?: {
|
|
328
|
+
eventName: string;
|
|
329
|
+
eventData?: EventData;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* A wagmi config used to get wallet clients, switch chains, etc.
|
|
333
|
+
*
|
|
334
|
+
* This is preferred over providing clients as state updates are kept synched in this config object w/o re-rendering.
|
|
335
|
+
*/
|
|
336
|
+
wagmiConfig?: Config;
|
|
337
|
+
/**
|
|
338
|
+
* walletClient should only be provided for tests or scripts.
|
|
339
|
+
*
|
|
340
|
+
* Wagmi Config is preferred.
|
|
341
|
+
*/
|
|
342
|
+
walletClient?: GetWalletClientReturnType | undefined;
|
|
343
|
+
/**
|
|
344
|
+
* The name of the contract to be used for the transaction. By default, it will be devrel's contract mapping.
|
|
345
|
+
* Custom values will be ignored if the address is already mapped in the devrel's contract mapping.
|
|
346
|
+
*
|
|
347
|
+
* @example "pol.rewardVault"
|
|
348
|
+
*/
|
|
349
|
+
contractName?: ContractName;
|
|
350
|
+
/**
|
|
351
|
+
* This is a canonical list of ABIs that will be used to parse the error.
|
|
352
|
+
*
|
|
353
|
+
* This is an useful way to parse errors when providing raw data with no ABI.
|
|
354
|
+
*/
|
|
355
|
+
errorsAbi?: Abi;
|
|
356
|
+
} & IUseContractWriteArgs<abi, functionName, params> & (abi extends Abi ? {
|
|
357
|
+
abi: abi;
|
|
358
|
+
functionName: functionName;
|
|
359
|
+
params: params;
|
|
360
|
+
address: Address;
|
|
361
|
+
calls?: never;
|
|
362
|
+
value?: bigint;
|
|
363
|
+
} : {
|
|
364
|
+
data: Hex;
|
|
365
|
+
address: Address;
|
|
366
|
+
value?: bigint;
|
|
367
|
+
calls?: never;
|
|
368
|
+
} | {
|
|
369
|
+
value: bigint;
|
|
370
|
+
address: Address;
|
|
371
|
+
data?: Hex;
|
|
372
|
+
calls?: never;
|
|
373
|
+
} | {
|
|
374
|
+
value?: never;
|
|
375
|
+
address?: never;
|
|
376
|
+
calls: (Omit<IContractWrite, "calls" | "gasLimit" | "account" | "address" | "message" | "actionType" | TxnEventKeys> & {
|
|
377
|
+
address: Address;
|
|
378
|
+
})[];
|
|
379
|
+
});
|
|
380
|
+
declare global {
|
|
381
|
+
export namespace BeraJS {
|
|
382
|
+
type BaseFunctionArgs = {
|
|
383
|
+
/**
|
|
384
|
+
* If only chainId is provided, config will be inferred from it
|
|
385
|
+
*
|
|
386
|
+
* @default `import { defaultChainId } from "@berachain/config/internal";`
|
|
387
|
+
*/
|
|
388
|
+
chainId?: ChainId;
|
|
389
|
+
/**
|
|
390
|
+
* A config to infer the default values of the other arguments
|
|
391
|
+
*
|
|
392
|
+
* @default chainConfigs[chainId]
|
|
393
|
+
*/
|
|
394
|
+
config?: BeraConfig;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
type MinimalERC20 = {
|
|
400
|
+
address: Address;
|
|
401
|
+
decimals: number;
|
|
402
|
+
symbol: string;
|
|
403
|
+
name: string;
|
|
404
|
+
};
|
|
405
|
+
type TokenWithMetadata = MinimalERC20 & {
|
|
406
|
+
tags?: string[];
|
|
407
|
+
base64?: string;
|
|
408
|
+
logoURI?: string;
|
|
409
|
+
chainId?: number;
|
|
410
|
+
};
|
|
411
|
+
type Token = TokenWithMetadata & {
|
|
412
|
+
/**
|
|
413
|
+
* @deprecated
|
|
414
|
+
*/
|
|
415
|
+
default?: boolean;
|
|
416
|
+
totalSupply?: string;
|
|
417
|
+
weight?: number | string | null;
|
|
418
|
+
};
|
|
419
|
+
interface TokenPriceInfo {
|
|
420
|
+
price: number;
|
|
421
|
+
updatedAt: number;
|
|
422
|
+
}
|
|
423
|
+
type TokenCurrentPriceMap = Record<Lowercase<Address> | string, TokenPriceInfo | undefined>;
|
|
424
|
+
interface TokenWithAmount extends Token {
|
|
425
|
+
amount: string;
|
|
426
|
+
}
|
|
427
|
+
interface BalanceToken extends Token {
|
|
428
|
+
balance: bigint;
|
|
429
|
+
formattedBalance: string;
|
|
430
|
+
price?: number;
|
|
431
|
+
}
|
|
432
|
+
type BalanceTokenWithMetadata = BalanceToken & TokenWithMetadata;
|
|
433
|
+
interface TokenInput extends Token {
|
|
434
|
+
amount: string;
|
|
435
|
+
exceeding: boolean;
|
|
436
|
+
}
|
|
437
|
+
interface SwapRequest {
|
|
438
|
+
tokenIn: Address;
|
|
439
|
+
tokenOut: Address;
|
|
440
|
+
tokenInDecimals: number;
|
|
441
|
+
tokenOutDecimals: number;
|
|
442
|
+
amount: string;
|
|
443
|
+
wberaIsBera: boolean;
|
|
444
|
+
swapKind: SwapKind;
|
|
445
|
+
}
|
|
446
|
+
interface IUserPosition {
|
|
447
|
+
lpBalance?: TokenBalance;
|
|
448
|
+
tokenBalances?: TokenBalance[];
|
|
449
|
+
userSharePercentage?: number;
|
|
450
|
+
stakedBalance?: TokenBalance;
|
|
451
|
+
/**
|
|
452
|
+
* Just a utility to detect if there is a price for the LP token.
|
|
453
|
+
*/
|
|
454
|
+
lpTokenPrice?: number;
|
|
455
|
+
}
|
|
456
|
+
declare enum PoolCreationStep {
|
|
457
|
+
POOL_TYPE = "Pool Type",
|
|
458
|
+
SELECT_TOKENS = "Select Tokens",
|
|
459
|
+
DEPOSIT_LIQUIDITY = "Deposit Liquidity",
|
|
460
|
+
SET_PARAMETERS = "Set Parameters",
|
|
461
|
+
SET_INFO = "Set Info"
|
|
462
|
+
}
|
|
463
|
+
type BexStatus = {
|
|
464
|
+
protocol: {
|
|
465
|
+
/**
|
|
466
|
+
* If the whole protocol is paused (i.e. ~the~ vault contract) disable any functionality except withdrawing proportional
|
|
467
|
+
* liquidity (provided that pool's recovery mode is enabled). Specifically we disable swaps and pool creation.
|
|
468
|
+
*/
|
|
469
|
+
isPaused: boolean;
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Pool is undefined if pool status is still loading if no pool address was provided.
|
|
473
|
+
*/
|
|
474
|
+
pool?: {
|
|
475
|
+
/**
|
|
476
|
+
* Pool should be put into recovery mode if tx are reverting on-chain to do with fee computation or pool exits.
|
|
477
|
+
* It reduces the computation needed to withdraw liquidity and does not charge protocol fees on exits while enabled.
|
|
478
|
+
*
|
|
479
|
+
* NOTE: that you can potentially still do regular exits/joins/etc in recovery mode, but if the flag is true will only
|
|
480
|
+
* present the safe exit option to the user in FE.
|
|
481
|
+
*/
|
|
482
|
+
isInRecoveryMode: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* If the pool is paused you cannot do anything unless you also enable recovery mode (then you can withdraw safely).
|
|
485
|
+
*/
|
|
486
|
+
isPaused: boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Disable withdrawals for a pool due to a combination of pool and vault statuses.
|
|
489
|
+
*/
|
|
490
|
+
disablePoolWithdrawals: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* Disable deposits for a pool due to a combination of pool and vault statuses.
|
|
493
|
+
*/
|
|
494
|
+
disablePoolDeposits: boolean;
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
type IAggregatorArgs = {
|
|
498
|
+
tokenIn: string;
|
|
499
|
+
tokenOut: string;
|
|
500
|
+
tokenInDecimals?: number;
|
|
501
|
+
tokenOutDecimals?: number;
|
|
502
|
+
amount: string;
|
|
503
|
+
slippage: number;
|
|
504
|
+
account?: Address;
|
|
505
|
+
publicClient?: PublicClient;
|
|
506
|
+
aggregatorsFeeBps?: number;
|
|
507
|
+
proxyAggregatorsThroughVercel?: boolean;
|
|
508
|
+
referrer?: SwapReferrer;
|
|
509
|
+
/**
|
|
510
|
+
* If provided, the aggregator will stake into the reward vault after the swap.
|
|
511
|
+
*/
|
|
512
|
+
rewardVault?: Address;
|
|
513
|
+
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
514
|
+
};
|
|
515
|
+
declare enum Aggregators {
|
|
516
|
+
Oogabooga = "Oogabooga",
|
|
517
|
+
Fly = "Fly",
|
|
518
|
+
HubPools = "Hub Pools",
|
|
519
|
+
Wrap = "Wrap",
|
|
520
|
+
Unwrap = "Unwrap",
|
|
521
|
+
KyberSwap = "KyberSwap",
|
|
522
|
+
OpenOcean = "OpenOcean",
|
|
523
|
+
Haiku = "Haiku",
|
|
524
|
+
Enso = "Enso",
|
|
525
|
+
RedeemBgt = "RedeemBgt",
|
|
526
|
+
Honey = "Honey"
|
|
527
|
+
}
|
|
528
|
+
type IRawAggregatorQuote<isRoutedThroughAggregator = true> = {
|
|
529
|
+
amountOut: string;
|
|
530
|
+
amountIn: string;
|
|
531
|
+
name: Aggregators;
|
|
532
|
+
spender: Address | undefined;
|
|
533
|
+
/**
|
|
534
|
+
* True if it's bera wrap/unwrap or bgt redeem.
|
|
535
|
+
*/
|
|
536
|
+
isNativeSwap?: boolean;
|
|
537
|
+
priceImpactPercentage?: number;
|
|
538
|
+
swapFeeBps: number;
|
|
539
|
+
calldata?: isRoutedThroughAggregator extends true ? Omit<IContractWrite<typeof aggregatorsRouterAbi, "swap">, "message" | "actionType"> : {
|
|
540
|
+
params: readonly unknown[] | undefined;
|
|
541
|
+
functionName: string;
|
|
542
|
+
abi: Abi;
|
|
543
|
+
address: Address;
|
|
544
|
+
value?: bigint;
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
type IAggregatorQuote = IRawAggregatorQuote<false> & {
|
|
548
|
+
amountOut: string;
|
|
549
|
+
amountOutUsd: string;
|
|
550
|
+
amountIn: string;
|
|
551
|
+
amountInUsd: string;
|
|
552
|
+
priceImpactPercentage: number;
|
|
553
|
+
exchangeRate: number;
|
|
554
|
+
relativeLossPercentage: number;
|
|
555
|
+
isBest?: boolean;
|
|
556
|
+
};
|
|
557
|
+
declare enum SwapReferrer {
|
|
558
|
+
SWAP = "SWAP",
|
|
559
|
+
ZAP = "ZAP"
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export { Aggregators as A, type BalanceToken as B, type CollateralRates as C, type DefaultHookOptions as D, type DefaultHookReturnType as E, type IUserPosition as F, type BalanceTokenWithMetadata as G, type HoneySwapActions as H, type IRawAggregatorQuote as I, type TokenPriceInfo as J, type IUseContractWriteArgs as K, type TxnEventKeys as L, type MinimalERC20 as M, type SwapRequest as N, type BexStatus as O, type PythLatestUpdates as P, type IContractWriteFn as Q, ContractName as R, SwapReferrer as S, type TokenWithOrder as T, type UseContractWriteApi as U, HoneySwapAction as V, type Token as a, type TokenWithMetadata as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, type HoneyConfigProviderProps as e, HoneyConfigProvider as f, type IAggregatorQuote as g, type TokenBalance as h, type IAggregatorArgs as i, type PythPriceFeedMap as j, type TokenCurrentPriceMap as k, type AllowanceToken as l, type IContractWrite as m, type HoneyFeeMap as n, type CollateralRatesArgs as o, getHoneyFees as p, HoneyPreviewMethod as q, type HoneyPreviewArgs as r, type HoneyPreviewResult as s, type HoneyPreviewReadResult as t, useHoneyConfig as u, getHoneyPreview as v, getPythLatestPrices as w, type TokenInput as x, PoolCreationStep as y, type TokenWithAmount as z };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { P as POLLING } from '../polling-BKnyavLI.js';
|
|
2
|
+
export { T as TransactionActionType } from '../txnEnum-BQKDfaeH.js';
|
|
3
|
+
|
|
4
|
+
declare enum OwnershipType {
|
|
5
|
+
Governance = "Governance",
|
|
6
|
+
Fixed = "Fixed",
|
|
7
|
+
Custom = "Custom"
|
|
8
|
+
}
|
|
9
|
+
declare enum ParameterPreset {
|
|
10
|
+
USDBACKED = "USD-Backed Stablecoin",
|
|
11
|
+
ALGORITHMIC = "Algorithmic Stablecoin"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare const DEFAULT_SLIPPAGE: 0.5;
|
|
15
|
+
declare const SLIPPAGE_DEGEN_VALUE: 25;
|
|
16
|
+
/**
|
|
17
|
+
* Default
|
|
18
|
+
*/
|
|
19
|
+
declare const DEFAULT_DEADLINE: 60;
|
|
20
|
+
declare enum SLIPPAGE_MODE {
|
|
21
|
+
AUTO = "auto",
|
|
22
|
+
CUSTOM = "custom",
|
|
23
|
+
DEGEN = "degen"
|
|
24
|
+
}
|
|
25
|
+
declare enum TRANSACTION_MODE {
|
|
26
|
+
AUTO = "auto",
|
|
27
|
+
CUSTOM = "custom",
|
|
28
|
+
INFINITY = "infinity"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { DEFAULT_DEADLINE, DEFAULT_SLIPPAGE, OwnershipType, ParameterPreset, SLIPPAGE_DEGEN_VALUE, SLIPPAGE_MODE, TRANSACTION_MODE };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"../chunk-MTBICGRP.mjs";export{f as DEFAULT_DEADLINE,d as DEFAULT_SLIPPAGE,a as OwnershipType,c as POLLING,b as ParameterPreset,e as SLIPPAGE_DEGEN_VALUE,g as SLIPPAGE_MODE,h as TRANSACTION_MODE,i as TransactionActionType};
|