@hyperionxyz/sdk
Version:
This SDK allows you to interact with the Hyperion API. You can use it to request data, create pools/positions and more.
131 lines • 5.26 kB
TypeScript
import { HyperionSDK } from '..';
import { AggregateSwapHelper, AggregateSwapRouteArgs } from '../helper/aggregateSwap';
import { AggregateSwapInfoResult } from '../helper/aggregateSwap/type';
import { AptosScriptComposer } from '@aptos-labs/script-composer-sdk';
export interface SwapTransactionPayloadArgs {
currencyA: string;
currencyB: string;
currencyAAmount: number | string;
currencyBAmount: number | string;
slippage: number | string;
poolRoute: string[];
recipient: string;
}
export interface EstFromAmountArgs {
amount: number | string;
from: string;
to: string;
safeMode?: boolean;
}
export declare class Swap {
protected _sdk: HyperionSDK;
protected _aggregateSwapHelper: AggregateSwapHelper;
constructor(sdk: HyperionSDK);
/**
* Generate the transaction payload for swap
* @param args SwapTransactionPayloadArgs
* @param args.currencyA The FA address of currency
* @param args.currencyB The FA address of currency
* @param args.currencyAAmount The amount of the input token
* @param args.currencyBAmount The amount of the output token
* @param args.slippage The slippage tolerance
* @param args.poolRoute The pool route
* @param args.recipient The recipient address
* @returns The transaction payload for swap
*/
swapTransactionPayload(args: SwapTransactionPayloadArgs): any;
/**
* Generate the transaction payload for swap with partnership
* @param args SwapTransactionPayloadArgs & { partnership: string }
* @param args.currencyA The FA address of currency
* @param args.currencyB The FA address of currency
* @param args.currencyAAmount The amount of the input token
* @param args.currencyBAmount The amount of the output token
* @param args.slippage The slippage tolerance
* @param args.poolRoute The pool route
* @param args.recipient The recipient address
* @param args.partnership The partnership address
* @returns
*/
swapWithPartnershipTransactionPayload(args: SwapTransactionPayloadArgs & {
partnership: string;
}): {
function: string;
typeArguments: never[];
functionArguments: (string | number | string[])[];
};
/**
* Estimate the amount of currency A from currency B
* @param args EstFromAmountArgs
* @param args.amount The amount of the input token
* @param args.from The address of the input token
* @param args.to The address of the output token
* @param args.safeMode Whether to use safe mode, only work on MAINNET
* @returns
*/
estFromAmount(args: EstFromAmountArgs): Promise<any>;
/**
* Estimate the amount of currency B from currency A
* @param args EstFromAmountArgs
* @param args.amount The amount of the input token
* @param args.from The address of the input token
* @param args.to The address of the output token
* @param args.safeMode Whether to use safe mode, only work on MAINNET
* @returns
*/
estToAmount(args: EstFromAmountArgs): Promise<any>;
/**
* Estimate the amount of currency A from currency B by aggregate swap
* @param args AggregateSwapRouteArgs
* @param args.amount The amount of the input token
* @param args.from The address of the input token
* @param args.input The address of the input token, either equals to args.from or args.to
* @param args.slippage The slippage tolerance
* @param args.to The address of the output token
* @returns The result of aggregate swap
*
* @example
* ```ts
* // Estimate the result of currency A from currency B by aggregate swap
* const result = await SDK.Swap.estAmountByAggregateSwap({
* amount: "10000000",
* from: "A_AssetType",
* input: "B_AssetType",
* slippage: 0.1,
* to: "B_AssetType",
* });
* console.log(result);
* ```
*
* or
* ```ts
* // Estimate the result of currency B from currency A by aggregate swap
* const result = await SDK.Swap.estAmountByAggregateSwap({
* amount: "10000000",
* from: "B_AssetType",
* input: "A_AssetType",
* slippage: 0.1,
* to: "A_AssetType",
* });
* console.log(result);
* ```
*/
estAmountByAggregateSwap(args: AggregateSwapRouteArgs): Promise<AggregateSwapInfoResult>;
/**
* Generate the transaction script for aggregate swap
* @param args AggregateSwapRouteArgs
* @param args.amount The amount of the input token
* @param args.from The address of the input token
* @param args.input The address of the input token, either equals to args.from or args.to
* @param args.slippage The slippage tolerance
* @param args.to The address of the output token
* @param args.builder The builder of the transaction
* @param args.partnershipId The partnership ID, only work on MAINNET
* @returns The transaction script for aggregate swap
*/
generateAggregateSwapTransactionScript(args: AggregateSwapInfoResult & {
builder: AptosScriptComposer;
partnershipId?: string;
}): Promise<void>;
}
//# sourceMappingURL=swapModule.d.ts.map