transferToTradingWallet

The transferToTradingWallet() method of Nectar instances transfers a token from the user's Web3 (funding) wallet (e.g., MetaMask Wallet) to the trading wallet.

Nectar utilizes a non-custodial trading wallet, governed by the DEX manager smart contract, to improve transaction efficiency and reduce costs. Therefore, users must transfer the tokens they wish to trade from their Web3 funding wallet to Nectar's trading wallet, ensuring a streamlined trading experience.

Usage

import { Nectar } from "@wasd3rplay/nectar-sdk";

const nectar = new Nectar();

const ticker = "WETH_ETHSEPOLIA";

const market = await nectar.getMarketByTicker(ticker);
const res = await nectar.transferToTradingWallet(ticker, "10.5", market, {
  retry: true,
  retryDelay: 5000,
});

Transfering Native Tokens Using ethers

One can also use ethers library to transfer native tokens.

import { Nectar } from "@wasd3rplay/nectar-sdk";
import { Wallet, ethers } from "ethers";

const nectar = new Nectar();

const symbol = "WETH_ETHSEPOLIA:USDT_ETHSEPOLIA";
const market = await nectar.getMarket(symbol);

const signer = new Wallet("...");

const transaction = signer.sendTransaction({
  to: market.chain.dex_manager_contract,
  value: ethers.utils.parseEther("0.1"), // 0.1 ETH
});

Transfering ERC20 Tokens

For the transfer of ERC20 tokens, the protocol requires users to first authorize the transfer amount to the DEX manager smart contract. This preparatory step enables the DEX manager smart contract to initiate the actual token transfer. This process involves two separate transactions, which can lead to a longer transfer duration compared to that of native tokens.

It is important to note that ERC20 tokens must possess an approve function to be supported by the platform.

Parameters

  • ticker: string

    • A ticker of the token to transfer.

    • It is a combination of a symbol, an underscore, and a chain symbol.

    • E.g., USDT_ETHSEPOLIA

  • amount: string

    • The amount of token to transfer.

  • market: Market

    • A market whose base ticker or quote ticker matches the given ticker.

Options

  • signer?: Wallet

    • Optional

    • Default to userWallet property of Nectar instances.

    • A wallet placing the order.

  • retry?: boolean | number

    • Optional

    • Defaults to true

    • This option is applicable only for transactions involving ERC20 tokens.

    • If false, the method does not monitor the transaction outcome (success or failure).

    • If true, the method continuously checks the transaction status until it is either executed successfully or fails.

    • If set to a number, it represents the count of attempts to check the transaction status before stopping.

  • retryDelay?: number

    • Optional

    • Defaults to 3000

    • A delay to apply before the next attempt in milliseconds.

Returns

  • NectarTransferResult

    • A result of the transaction.

Last updated