Skip to content

balance() and balanceDisplay() shows balance = 0.0  #47

@HKby

Description

@HKby

Expected Behavior

Example wallet has balance in both ETH / USDC
ETH balance 0.012002096113860558
USDC balance 12.60609

Actual Behavior

ETH balance 0.0
USDC balance 0.0

Using the wallet() / walletDisplay() can do expected behaviour

Steps to Reproduce the Problem

  1. prepare reproduce.ts
import { CrocEnv } from '../croc';
import { ethers } from 'ethers';
import * as dotenv from 'dotenv';
// console.log({ path: __dirname+'/.env' })
dotenv.config();
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" // USDC on mainnet

// set up RPC 
    const wallet = new ethers.Wallet(KEY)
    console.log("Processing wallet", wallet.address)
    const croc = new CrocEnv("mainnet", wallet)

 // balance before swap 

    const ethBalance = await croc.tokenEth().balanceDisplay(wallet.address)
    console.log("ETH balance", ethBalance)

    const usdcBalance = await croc.token(USDC).balanceDisplay(wallet.address)
    console.log("USDC balance", usdcBalance)
  1. run in terminal
ts-node reproduce.ts

## Specifications

- Version: 0.3.9-3
- Platform: Mac OS
- ts-node version: v10.9.2
- other tsconfig.json and package.json same as sdk package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions