@enclavemoney/enclave-wallet-sdk
Version:
A simple enclave wallet SDK for React applications
393 lines (392 loc) • 11.4 kB
TypeScript
import { QuoteType, QuoteChoice } from "./services";
export interface IAction {
action: string | {
encodedData: string;
targetContractAddress: string;
value: string;
}[];
}
export interface getSourceTokensFromIdentifierRequest {
body: {
chainId: number;
tokenAddress: string;
};
}
export interface CalculateQuoteAmountInRequest {
body: {
username: string;
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
quoteType: QuoteType;
action?: IAction["action"];
};
}
export interface CalculateQuoteAmountOutRequest {
body: {
username: string;
fromTokens: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
quoteType: QuoteType;
action?: IAction["action"];
};
}
export interface UserBalance {
chainId: number;
address: string;
balance: string;
}
export interface CalculateQuoteAmountInInput {
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
action: IAction["action"];
}
export interface CalculateQuoteAmountInParams {
username: string;
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
quoteType: QuoteType;
action?: IAction["action"];
}
export interface ModifiedSpendPlan {
total_fees: string;
spend_distribution: Record<string, string>;
total_withdrawn: string;
remaining_balance: string;
enclave_fee_distribution: Record<string, string>;
enclave_fee: string;
}
export interface QuoteDetailsWithAction {
success: boolean;
provider: string;
fees: string;
estimatedTime: number;
inputDetails: {
amount: string;
amountUsd: string | number;
};
outputDetails: {
amount: string;
amountFormatted: string;
amountUsd: string;
minimumAmount: string;
};
rate: string;
modifiedSpendPlan: ModifiedSpendPlan;
}
export interface CalculateQuoteResponse {
success: boolean;
bestQuote: QuoteDetailsWithAction;
fastestQuote: QuoteDetailsWithAction;
}
export interface CalculateQuoteAmountOutInput {
fromTokens: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
quoteType: QuoteType;
action?: IAction["action"];
}
export interface CalculateQuoteAmountOutParams {
username: string;
fromTokens: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
quoteType: QuoteType;
action?: IAction["action"];
}
export interface ExecuteSwapAmountInRequest {
body: {
username: string;
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
};
}
export interface ExecuteSwapAmountInInput {
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export interface ExecuteSwapAmountInParams {
username: string;
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export interface ExecuteSwapAmountInResponse {
success: boolean;
transactionDetails?: {
multiTransactionId: string;
overallStatus: string;
};
}
export interface ExecuteSwapAmountOutRequest {
body: {
username: string;
fromTokens: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
};
}
export interface ExecuteSwapAmountOutInput {
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export interface ExecuteSwapAmountOutParams {
username: string;
fromTokens: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount: string;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export interface ExecuteSwapAmountOutResponse {
success: boolean;
transactionDetails?: {
multiTransactionId: string;
overallStatus: string;
};
}
export interface CalculateQuoteInput {
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount?: string;
};
quoteType: QuoteType;
action?: IAction["action"];
}
export interface CalculateQuoteParams {
username: string;
fromTokens: UserBalance[] | getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount?: string;
};
quoteType: QuoteType;
action?: IAction["action"];
}
export interface ExecuteSwapInput {
fromTokens: UserBalance[];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount?: string;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export interface ExecuteSwapParams {
username: string;
fromTokens: UserBalance[] | getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
outputAmount?: string;
};
isHeadless: boolean;
quoteChoice: QuoteChoice;
quoteType: QuoteType;
quoteId?: string;
action?: IAction["action"];
}
export type ExecuteSwapResponse = ExecuteSwapAmountInResponse | ExecuteSwapAmountOutResponse;
export interface CalculateQuoteForActionAmountOutRequest {
body: {
username: string;
fromTokens?: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
};
outputAmount: string;
quoteType: QuoteType;
action?: IAction["action"];
};
}
export interface GetQuoteForActionInput {
fromTokens?: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
};
outputAmount: string;
quoteType: QuoteType;
action?: IAction["action"];
}
export interface GetQuoteForActionParams {
username: string;
fromTokens?: getSourceTokensFromIdentifierRequest["body"][];
toToken: {
tokenAddress: string;
chainId: number;
};
outputAmount: string;
quoteType: QuoteType;
action?: IAction["action"];
}
export interface GetQuoteForActionResponse {
success: boolean;
bestQuote: QuoteDetailsWithAction;
fastestQuote: QuoteDetailsWithAction;
}
export interface ExecuteActionAmountOutRequest {
body: {
quoteChoice: QuoteChoice;
quoteId: string;
};
}
export interface ExecuteActionInput {
quoteChoice: QuoteChoice;
quoteId: string;
username: string;
fromTokens?: getSourceTokensFromIdentifierRequest["body"][];
toToken?: {
tokenAddress: string;
chainId: number;
};
outputAmount?: string;
action?: IAction["action"];
}
export interface ExecuteActionParams {
quoteChoice: QuoteChoice;
quoteId: string;
username: string;
fromTokens?: getSourceTokensFromIdentifierRequest["body"][];
toToken?: {
tokenAddress: string;
chainId: number;
};
outputAmount?: string;
action?: IAction["action"];
}
export interface ExecuteActionResponse {
success: boolean;
transactionDetails?: {
multiTransactionId: string;
overallStatus: string;
};
}
/**
* Calculates quote amount in with action
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The calculate quote amount in with action response
*/
export declare const calculateQuoteAmountIn: (params: CalculateQuoteAmountInParams, apiKey: string) => Promise<CalculateQuoteResponse | null>;
/**
* Calculates quote amount out
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The calculate quote amount out response
*/
export declare const calculateQuoteAmountOut: (params: CalculateQuoteAmountOutParams, apiKey: string) => Promise<CalculateQuoteResponse | null>;
/**
* Executes swap amount in
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The execute swap amount in response
*/
export declare const executeSwapAmountIn: (params: ExecuteSwapAmountInParams, apiKey: string) => Promise<ExecuteSwapAmountInResponse | null>;
/**
* Executes swap amount out
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The execute swap amount out response
*/
export declare const executeSwapAmountOut: (params: ExecuteSwapAmountOutParams, apiKey: string) => Promise<ExecuteSwapAmountOutResponse | null>;
/**
* Unified execute swap function that routes to appropriate endpoint based on quoteType
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The execute swap response
*/
export declare const executeSwapQuote: (params: ExecuteSwapParams, apiKey: string) => Promise<ExecuteSwapResponse | null>;
/**
* Unified calculate quote function that routes to appropriate endpoint based on quoteType
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The calculate quote response
*/
export declare const calculateQuote: (params: CalculateQuoteParams, apiKey: string) => Promise<CalculateQuoteResponse | null>;
/**
* Gets quote for action amount out
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The get quote for action response
*/
export declare const getQuoteForActionAmountOut: (params: GetQuoteForActionParams, apiKey: string) => Promise<GetQuoteForActionResponse | null>;
/**
* Executes action amount out
* @param params The request parameters
* @param apiKey The wallet SDK key for authorization
* @returns The execute action response
*/
export declare const executeActionAmountOut: (params: ExecuteActionParams, apiKey: string) => Promise<ExecuteActionResponse | null>;