@shogun-sdk/money-legos
Version:
Shogun Money Legos: clients and types for quotes, memes, prices, balances, fees, validations, etc.
80 lines • 3.92 kB
TypeScript
import { Connection } from '@solana/web3.js';
import { type Chain, createPublicClient } from 'viem';
import { SupportedChainId } from '../config/chains.js';
import type { EVMPublicClient } from '../types/client.js';
import type { QuoteTypes } from '../types/index.js';
import { ethers } from 'ethers';
export declare const MIN_NATIVE_TOKEN_BALANCE: {
[chainId: number]: bigint;
};
export declare const MIN_BRIDGE_FEE_NATIVE_TOKEN: {
[chainId: number]: bigint;
};
export declare const getEthChainViem: (network: number) => Chain;
export declare const getEvmJsonRpcProvider: (network: number) => ReturnType<typeof createPublicClient>;
/**
* Calculates gasLimit based on estimated transaction gas cost.
* Increasing gasLimit to cover unexpected expenses
* @param estimatedGas Estimated transaction gas cost
*/
export declare const getAdjustedGasLimit: (network: number, estimatedGas: bigint | number) => bigint;
/**
* @deprecated This method uses legacy gas estimation logic and may not reflect
* current network conditions accurately. Prefer using `getAdjustedFeesPerGas`
* with up-to-date block and pending fee data instead.
*/
export declare const getAdjustedFeesPerGasOld: (provider: EVMPublicClient, userPriorityFeeGwei: bigint) => Promise<{
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
}>;
/**
* Calculates adjusted `maxFeePerGas` and `maxPriorityFeePerGas` for EIP-1559 transactions
* based on a user-defined priority fee in GWEI.
*
* Ensures the priority fee meets a minimum threshold (0.1 gwei),
* and computes `maxFeePerGas` as (baseFee + priorityFee).
*
* @param provider - An EVM-compatible viem public client (supports `estimateFeesPerGas`)
* @param userPriorityFeeGwei - Desired priority fee in wei (e.g., 150_000_000n for 0.15 gwei)
* @returns An object containing `maxFeePerGas` and `maxPriorityFeePerGas` in wei
*/
export declare const getAdjustedFeesPerGas: (provider: EVMPublicClient, userPriorityFeeGwei: bigint) => Promise<{
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
}>;
export declare const getAdjustedMaxFeePerGas: (maxFeePerGas: bigint | number, gasMultiplier: number) => bigint;
export declare const GAS_LIMIT_MULTIPLIER_ARBITRUM = 3;
export declare const fetchProviderEstimation: (provider: EVMPublicClient, quote: QuoteTypes, from?: string) => Promise<any>;
export declare const getQuoteNativeBridgeFee: (quote: QuoteTypes) => {
bridgeFee: bigint;
isNativeIncludedInAmountIn: boolean;
isBridgeFeeInValue: boolean;
};
export declare const estimateEvmTransaction: (network: number, quote: QuoteTypes, from: string, userDefinedFeeGwei: number) => Promise<{
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
gasLimit: bigint;
estimatedFees: bigint;
minimumNativeBalance: bigint;
provider: EVMPublicClient;
value: bigint;
bridgeFee: bigint;
}>;
/**
* Creates a EVM connection using ethers with fallback RPC URLs.
* Attempts to connect to each RPC URL in order until a working connection is established.
* @returns ethers.JsonRpcProvider - a working EVM connection
* @throws Error if no RPC URLs are defined or if all connections fail
*/
export declare const getEVMEthersProviderWithFallback: (chainId: SupportedChainId) => Promise<ethers.JsonRpcProvider>;
/**
* Creates a Solana connection with fallback RPC URLs.
* Attempts to connect to each RPC URL in order until a working connection is established.
* @returns Promise<Connection> A working Solana connection
* @throws Error if no RPC URLs are defined or if all connections fail
*/
export declare const getSolanaProviderWithFallback: () => Promise<Connection>;
export declare const getSolanaProvider: () => Promise<Connection>;
export declare const ZERO_BALANCE: bigint;
export declare const getTokenBalanceRpc: (walletAddress: string, tokenAddress: string, network: number) => Promise<bigint>;
//# sourceMappingURL=rpc.d.ts.map