Anchor-Protocol / anchor-earn

The Earn JavaScript SDK for Anchor Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"insufficient fee" when executing deposit using AnchorEarn

dosullivansoftware opened this issue · comments

Feel free to call me out if I'm missing something.
I'm developing a node app wrapping some functionality provided by Anchor. As a starting point, I would like to be able to execute stablecoin deposits of UST using the Anchor Earn SDK. I have used Terra Faucet to fund my testnet account with 10,000 UST. One of the modules in my app expose the following function:

import { AnchorEarn, CHAINS, NETWORKS, DENOMS, MnemonicKey } from '@anchor-protocol/anchor-earn';

async function executeDeposit(req, res) {
  const account = new MnemonicKey({
    mnemonic: "..."
  });

  const anchorEarn = new AnchorEarn({
    chain: CHAINS.TERRA,
    network: NETWORKS.TEQUILA_0004,
    privateKey: account.privateKey,
  });

  await anchorEarn.deposit({
    amount: '100.23',
    currency: DENOMS.UST,
    log: (data) => {
      console.log(data);
    }
  });
}

I get the following responses when logging the data in the callback function while executing the deposit:

{
  type: 'deposit',
  status: 'in-progress',
  currency: 'UST',
  amount: '100.23',
  txFee: '0.222247 UST',
  deductedTax: '0'
}
{
  type: 'send',
  chain: 'terra',
  network: 'tequila-0004',
  error_msg: 'insufficient fee: insufficient fee: insufficient fees; got: "222247uusd", required: "139758uaud,139758ucad,95624uchf,713501ucny,91946ueur,80913ugbp,8091248uinr,11769088ujpy,130967883ukrw,110336uluna,317490201umnt,74881usdr,147114usgd,332583uusd" = "139758uaud,139758ucad,95624uchf,713501ucny,91946ueur,80913ugbp,8091248uinr,11769088ujpy,130967883ukrw,110336uluna,317490201umnt,74881usdr,147114usgd,110336uusd"(gas) +"222247uusd"(stability)',
  status: 'unsuccessful'
}

It seems the deposit request is missing the gas fee (I think?). I have tried depositing small amounts using my mainnet account on the COLUMBUS_4 network also, but to receive the same error.

Is a custom signer required? Should I be using the anchor.js and terra.js libraries instead for this use case?

Seeing same issue. Looks like TX is only calculating stability tax and no gas fee.

@MSNTCS can you have a look?

Try to set gas parameters and fees. It's worked for me.

const gasParameters: OperationGasParameters = {
    gasAdjustment: 1.2,
    gasPrices: { uusd: 1 },
    fee: new StdFee(2_500_000, { uusd: 1_000_000 }),
}

@dosullivansoftware thank you for the report, we will put it in our queue to fix the issue. At the same time, I would be more than happy to see a PR that solves the issue. The issue is related to adjusting gas and gas_price.