UNPKG

@firefly-exchange/library-sui

Version:

Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui

99 lines (98 loc) 3.4 kB
import { BigNumberable, Signer, SuiClient } from "../types"; import { Address, ID, NumStr } from "../types"; export type RFQuote = { vault: ID; id: string; taker: Address; token_in_amount: NumStr; token_out_amount: NumStr; token_in_type: string; token_out_type: string; expires_at: NumStr; created_at: NumStr; }; export declare const BcsQuote: import("@mysten/sui/bcs").BcsType<{ vault: string; id: string; taker: string; token_in_amount: string; token_out_amount: string; token_in_type: string; token_out_type: string; expires_at: string; created_at: string; }, { vault: any; id: string; taker: any; token_in_amount: string | number | bigint; token_out_amount: string | number | bigint; token_in_type: string; token_out_type: string; expires_at: string | number | bigint; created_at: string | number | bigint; }>; export declare const Signature: import("@mysten/sui/bcs").BcsType<{ sig: number[]; pk: number[]; scheme: number; }, { sig: Iterable<number> & { length: number; }; pk: Iterable<number> & { length: number; }; scheme: number; }>; export declare class Quote { readonly quote: RFQuote; constructor(quote: RFQuote); /** * * @param vault The id of the vault for which the quote is fo * @param account The account for which the quote is being created * @param token_in_amount The amount of token that will be going into the vault * @param token_out_amount The amount of output token the user will get (excludes protocol fee) * @param token_in_type The token/coin type of the input token * @param token_out_type The token/coin type of the output token * @param options optional arguments * @returns Quote */ static new(vault: ID | Address, taker: Address, token_in_amount: BigNumberable, token_out_amount: BigNumberable, token_in_type: string, token_out_type: string, options?: { id?: string; expires_at?: NumStr; created_at?: NumStr; }): Quote; /** * Bcs serializes the quote and returns its BCS representation * @returns BCS serialized Uint8Array of the quote */ serialize(): Uint8Array; /** * Signs the quote * @param signer The manager of the vault. Must be ED25519 or Secp wallet, other * wallets are not supported like Multisig, ZK * @returns Returns a base64 representation of signature containing: * 1. scheme (1 byte), * 2. signature (64 bytes) * 3. public key (32/33 bytes) */ sign(signer: Signer): Promise<string>; /** * Validates if the signature is for the provided quote * @param signature The base64 signature * @param signer The expected address of the signer * @returns True if the signature is created on the given quote and the sig creator is the one provided */ verify(signature: string, signer: Address): Promise<boolean>; /** * Performs a dry run contract call to verify the signature on-chain * @param signature The signature to be verified * @param client The Sui client * @param pkg The contract pkg to be used * @param verbose optional * @returns boolean */ onChainVerify(signature: string, client: SuiClient, pkg: string, verbose?: boolean): Promise<boolean>; }