UNPKG

@d8x/perpetuals-sdk

Version:

Node TypeScript SDK for D8X Perpetual Futures

62 lines (61 loc) 2.87 kB
/// <reference types="node" /> import { Buffer } from "buffer"; import { NodeSDKConfig } from "./nodeSDKTypes"; /** * * @param {string} s String to shorten/extend to 4 characters * @returns {string} String with 4 characters (or characters + null chars) */ export declare function to4Chars(s: string): string; /** * Converts string into 4-character bytes4 * uses to4Chars to first convert the string into * 4 characters. * Resulting buffer can be used with smart contract to * identify tokens (BTC, USDC, MATIC etc.) * @param {string} s String to encode into bytes4 * @returns {Buffer} 4-character bytes4. */ export declare function toBytes4(s: string): Buffer; /** * Decodes a buffer encoded with toBytes4 into * a string. The string is the result of to4Chars of the * originally encoded string stripped from null-chars * @param {Buffer} b Correctly encoded bytes4 buffer using toBytes4 * @returns {string} String decoded into to4Chars-type string without null characters */ export declare function fromBytes4(b: Buffer): string; /** * Decodes the bytes4 encoded string received from the * smart contract as a hex-number in string-format * @param {string} s string representing a hex-number ("0x...") * @returns {string} x of to4Chars(x) stripped from null-chars, * where x was originally encoded and * returned by the smart contract as bytes4 */ export declare function fromBytes4HexString(s: string): string; /** * * @param {string} s String representing a hex-number ("0x...") * @param {Object} mapping List of symbol and clean symbol pairs, e.g. [{symbol: "MATIC", cleanSymbol: "MATC"}, ...] * @returns {string} User friendly currency symbol, e.g. "MATIC" */ export declare function contractSymbolToSymbol(s: string, mapping: Map<string, string>): string; /** * * @param {string} s User friendly currency symbol, e.g. "MATIC" * @param {Object} mapping List of symbol and clean symbol pairs, e.g. [{symbol: "MATIC", cleanSymbol: "MATC"}, ...] * @returns {Buffer} Buffer that can be used with smart contract to identify tokens */ export declare function symbolToContractSymbol(s: string, mapping: Map<string, string>): Buffer; /** * Converts symbol or symbol combination into long format * @param {string} s symbol, e.g., USDC-MATC-USDC, MATC, USDC, ... * @param {Object} mapping list of symbol and clean symbol pairs, e.g. [{symbol: "MATIC", cleanSymbol: "MATC"}, ...] * @returns {string} long format e.g. MATIC. if not found the element is "" */ export declare function symbol4BToLongSymbol(s: string, mapping: Map<string, string>): string; export declare function combineFlags(f1: bigint, f2: bigint): bigint; export declare function containsFlag(f1: bigint, f2: bigint): boolean; export declare function loadConfigAbis(config: NodeSDKConfig): void; export declare function sleepForSec(seconds: number): Promise<unknown>;