@firefly-exchange/library-sui
Version:
Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui
70 lines (69 loc) • 3.04 kB
TypeScript
import { StoredOrder, ZkPayload } from "../src/interfaces";
import { Order } from "../src/interfaces";
import { Ed25519Keypair, Keypair, SigPK, SignatureScheme, SuiClient } from "./types";
export declare function writeFile(filePath: string, jsonData: any): void;
export declare function readFile(filePath: string): any;
export declare function getProvider(rpcURL: string): SuiClient;
export declare function getKeyPairFromSeed(seed: string, scheme?: SignatureScheme): Keypair;
export declare function keypairFromSecretKey(privateKeyBase64: string): Ed25519Keypair;
export declare function getKeyPairFromPvtKey(key: string, scheme?: SignatureScheme): Keypair;
export declare function getSignerFromSeed(seed: string, scheme?: SignatureScheme): Keypair;
export declare const verifyZkAddress: (signature: any, userAddress: any) => boolean;
export declare const verifyZkPublicKey: ({ signature, publicKey }: {
signature: any;
publicKey: any;
}) => boolean;
export declare const decodeZkSignature: (decodedSignature: string) => {
zkSignature: string;
publicKey: string;
scheme: string;
};
export declare function createOrder(params?: {
market?: string;
maker?: string;
isBuy?: boolean;
price?: number;
quantity?: number;
leverage?: number;
reduceOnly?: boolean;
postOnly?: boolean;
ioc?: boolean;
orderbookOnly?: boolean;
expiration?: number;
salt?: number;
}): Order;
export declare function printOrder(order: Order): void;
/**
* Consumes an order of type StoredOrder and returns a SuiOrder that can be sent to on-chain for settlement
* @param order StoredOrder to be transformed
* @param perpetualID market/perpetual address
* @param orderbookOnly (optional) true by default as all orders going through our exchange have orderbook only true
*/
export declare function storedOrderToSui(order: StoredOrder, perpetualID: string, orderbookOnly?: boolean): Order;
export declare function requestGas(address: string): Promise<false | Response>;
export declare function getRandomInt(min: number, max: number): number;
export declare function getSalt(): number;
export declare const createZkSignature: ({ userSignature, zkPayload }: {
userSignature: string;
zkPayload: ZkPayload;
}) => string;
export declare const parseAndShapeSignedData: ({ signature, isParsingRequired }: {
signature: string;
isParsingRequired?: boolean;
}) => SigPK;
/**
* Validates if the provided signature is created using the data and public key provided
* @param signature hex encoded signature
* @param data data bytes
* @param publicKey public key bytes
* @returns True if signature is valid
*/
export declare function verifySECP(signature: string, data: Uint8Array, publicKey: Uint8Array): boolean;
/**
* Ensures that an address string starts with "0x".
* If it doesn't, the function prepends "0x" to the address.
*
* @param address - The token string to check.
* @returns The address string with a "0x" prefix.
*/
export declare function addPrefix(address: string): string;