@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
129 lines • 5.55 kB
TypeScript
import type { Keypair } from '@solana/web3.js';
import { Address, Domain, Numberish } from '@hyperlane-xyz/utils';
import { EthJsonRpcBlockParameterTag } from '../../metadata/chainMetadataTypes.js';
import type { PredicateAttestation } from '../../predicate/PredicateApiClient.js';
import { TokenMetadata } from '../types.js';
export interface TransferParams {
weiAmountOrId: Numberish;
recipient: Address;
fromAccountOwner?: Address;
fromTokenAccount?: Address;
interchainGas?: InterchainGasQuote;
}
export interface TransferRemoteParams extends TransferParams {
destination: Domain;
customHook?: Address;
/** Optional Predicate attestation for compliance-gated warp routes */
attestation?: PredicateAttestation;
/** Optional extra signers for Sealevel transactions (e.g., randomWallet Keypair for dispatch PDA) */
extraSigners?: Keypair[];
}
export interface TransferRemoteToParams {
destination: Domain;
recipient: Address;
amount: Numberish;
targetRouter: Address;
interchainGas?: InterchainGasQuote;
fromAccountOwner?: Address;
extraSigners?: Keypair[];
/** Optional Predicate attestation for compliance-gated warp routes */
attestation?: PredicateAttestation;
}
export interface QuoteTransferRemoteParams {
destination: Domain;
sender?: Address;
customHook?: Address;
recipient?: Address;
amount?: bigint;
}
export interface Quote {
addressOrDenom?: string;
amount: bigint;
}
export interface InterchainGasQuote {
igpQuote: Quote;
tokenFeeQuote?: Quote;
}
export interface RateLimitMidPoint {
rateLimitPerSecond: bigint;
bufferCap: bigint;
lastBufferUsedTime: number;
bufferStored: bigint;
midPoint: bigint;
}
export interface xERC20Limits {
mint: bigint;
burn: bigint;
}
export interface ITokenAdapter<Tx> {
getBalance(address: Address): Promise<bigint>;
getTotalSupply(): Promise<bigint | undefined>;
getMetadata(isNft?: boolean): Promise<TokenMetadata>;
getMinimumTransferAmount(recipient: Address): Promise<bigint>;
isApproveRequired(owner: Address, spender: Address, weiAmountOrId: Numberish): Promise<boolean>;
isRevokeApprovalRequired(owner: Address, spender: Address): Promise<boolean>;
populateApproveTx(params: TransferParams): Promise<Tx>;
populateTransferTx(params: TransferParams): Promise<Tx>;
}
export interface IMovableCollateralRouterAdapter<Tx> extends ITokenAdapter<Tx> {
isRebalancer(address: Address): Promise<boolean>;
isBridgeAllowed(domain: Domain, bridge: Address): Promise<boolean>;
getAllowedDestination(domain: Domain): Promise<Address>;
getRebalanceQuotes(bridge: Address, domain: Domain, recipient: Address, amount: Numberish): Promise<InterchainGasQuote[]>;
getWrappedTokenAddress(): Promise<Address>;
populateRebalanceTx(domain: Domain, amount: Numberish, bridge: Address, quotes: InterchainGasQuote[]): Promise<Tx>;
}
export interface IHypTokenAdapter<Tx> extends ITokenAdapter<Tx> {
getDomains(): Promise<Domain[]>;
getRouterAddress(domain: Domain): Promise<Buffer>;
getAllRouters(): Promise<Array<{
domain: Domain;
address: Buffer;
}>>;
getBridgedSupply(options?: {
blockTag?: number | EthJsonRpcBlockParameterTag;
}): Promise<bigint | undefined>;
quoteTransferRemoteGas(params: QuoteTransferRemoteParams): Promise<InterchainGasQuote>;
populateTransferRemoteTx(p: TransferRemoteParams): Promise<Tx>;
}
export interface IHypXERC20Adapter<Tx> extends IHypTokenAdapter<Tx> {
getMintLimit(): Promise<bigint>;
getMintMaxLimit(): Promise<bigint>;
getBurnLimit(): Promise<bigint>;
getBurnMaxLimit(): Promise<bigint>;
}
export interface IHypVSXERC20Adapter<Tx> {
getRateLimits(): Promise<RateLimitMidPoint>;
populateSetBufferCapTx(newBufferCap: bigint): Promise<Tx>;
populateSetRateLimitPerSecondTx(newRateLimitPerSecond: bigint): Promise<Tx>;
populateAddBridgeTx(bufferCap: bigint, rateLimitPerSecond: bigint): Promise<Tx>;
}
export interface IXERC20VSAdapter<Tx> extends ITokenAdapter<Tx> {
getRateLimits(bridge: Address): Promise<RateLimitMidPoint>;
populateSetBufferCapTx(bridge: Address, newBufferCap: bigint): Promise<Tx>;
populateSetRateLimitPerSecondTx(bridge: Address, newRateLimitPerSecond: bigint): Promise<Tx>;
populateAddBridgeTx(bufferCap: bigint, rateLimitPerSecond: bigint, bridge: Address): Promise<Tx>;
}
export interface IXERC20Adapter<Tx> extends ITokenAdapter<Tx> {
getLimits(bridge: Address): Promise<xERC20Limits>;
}
export interface IHypCrossCollateralAdapter<Tx> extends IHypTokenAdapter<Tx> {
quoteTransferRemoteToGas(params: {
destination: Domain;
recipient: Address;
amount: Numberish;
targetRouter: Address;
sender?: Address;
}): Promise<InterchainGasQuote>;
populateTransferRemoteToTx(params: TransferRemoteToParams): Promise<Tx>;
}
export interface IPredicateAwareAdapter {
getPredicateWrapperAddress(): Promise<Address | null>;
supportsAttestation(): Promise<boolean>;
}
export declare function isPredicateCapableAdapter(adapter: IHypTokenAdapter<unknown>): adapter is IHypTokenAdapter<unknown> & IPredicateAwareAdapter;
export declare function isHypCrossCollateralAdapter(adapter: IHypTokenAdapter<unknown>): adapter is IHypCrossCollateralAdapter<unknown>;
export interface IHypCollateralFiatAdapter<Tx> extends IHypTokenAdapter<Tx> {
getMintLimit(): Promise<bigint>;
}
//# sourceMappingURL=ITokenAdapter.d.ts.map