UNPKG

@d8x/perpetuals-sdk

Version:

Node TypeScript SDK for D8X Perpetual Futures

56 lines (55 loc) 2.62 kB
import { ContractTransactionResponse, Overrides, Provider, Signer } from "ethers"; import { PayableOverrides } from "./contracts/common"; import MarketData from "./marketData"; import { type NodeSDKConfig } from "./nodeSDKTypes"; import PerpetualDataHandler from "./perpetualDataHandler"; /** * This is a parent class for the classes that require * write access to the contracts. * This class requires a private key and executes smart-contract interaction that * require gas-payments. * @extends PerpetualDataHandler */ export default class WriteAccessHandler extends PerpetualDataHandler { protected privateKey: string | undefined; protected traderAddr: string; protected signer: Signer | null; protected gasLimit: number; /** * Constructor * @param {string | Signer} signer Private key or ethers Signer of the account */ constructor(config: NodeSDKConfig, signer: string | Signer); createProxyInstance(provider?: Provider, overrides?: Overrides): Promise<void>; createProxyInstance(marketData: MarketData): Promise<void>; /** * Set allowance for ar margin token (e.g., MATIC, ETH, USDC) * @param symbol token in 'long-form' such as MATIC, symbol also fine (ETH-USD-MATIC) * @param amount optional, amount to approve if not 'infinity' * @returns Contract Transaction */ setAllowance(symbol: string, amount?: number, overrides?: Overrides): Promise<ContractTransactionResponse>; protected static _setAllowance(tokenAddr: string, proxyAddr: string, signer: Signer, amount: bigint, overrides?: Overrides): Promise<ContractTransactionResponse>; /** * Address corresponding to the private key used to instantiate this class. * @returns {string} Address of this wallet. */ getAddress(): string; protected _getFeeData(overrides?: PayableOverrides): { maxFeePerGas: import("ethers").BigNumberish; maxPriorityFeePerGas: import("ethers").BigNumberish; gasPrice?: undefined; } | { gasPrice: import("ethers").BigNumberish | null | undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; }; /** * Converts a given amount of chain native currency (test MATIC) * into a mock token used for trading on testnet, with a rate of 1:100_000 * @param symbol Pool margin token e.g. MATIC * @param amountToPay Amount in chain currency, e.g. "0.1" for 0.1 MATIC * @returns Transaction object */ swapForMockToken(symbol: string, amountToPay: string, overrides?: PayableOverrides): Promise<ContractTransactionResponse>; }