Giter Club home page Giter Club logo

anchor-earn's People

Contributors

alpac-4 avatar cosullivan avatar msntcs avatar nimishpatel19 avatar pfc-developer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

anchor-earn's Issues

minor: installation with npm fails: prepare script, git hooks, and dependencies

Once pulled, npm install gives sh: husky: command not found.
That's because husky 5 is both set as a dev dependency and part of prepare script in package.json.
yarn installs husky and doesn't give an error. However prepare is not the yarn 2+ lifecycle script anymore.

This shouldn't be the case for husky v4, but for v5 prepare could run a shell script executing husky installation with npx if no .husky folder is preset.
Also, if yarn is still recommended as per readme file, probably using getting rid of prepare and using prepublish only would unify the usage for both npm and yarn.

CustomSigner

Hi,
I'm trying to implement a CustomSigner as per example provided in the docs and get the following error:
error_msg: 'unauthorized: signature verification failed; please verify account number (xxxxx) and chain-id (columbus-5): unauthorized'
Everything else seems to be working, as long as I don't try to use a CustomSigner.

  • I can instantiate an account object
  • I can instantiate an AnchorEarn object using account object above
  • I can check balance on account
  • I can send from account to another wallet (using built in signer)

Any help would be greatly appreciated.
Thanks!

// vars
const terraWalltAddrTest = '...' //address of test wallet I'm using to test anchor earn api
const kucointerraWalletAddr = '...' //terra deposit address on kucoin.
const kucoinmemo = '...' //required memo ID for deposits to kucoin terra address
const sendAmnt = 1 //sending 1 UST to kucoin address.

// CustomSigner Code:
const testWalletSigner = async (tx) => {
const anchoracct = new anchor.MnemonicKey({
mnemonic: '...',
});

const terra = new LCDClient({
URL: 'https://lcd.terra.dev',
chainId: 'columbus-5',
});

const wallet = terra.wallet(anchoracct);

return await wallet.createAndSignTx({
msgs: tx,
// gasAdjustment: 2,
// gasPrices: { uusd: 0.15 },
memo: kucoinmemo,
});
};

// Instantiate Anchor Object:
const anchorEarn = new anchor.AnchorEarn({
chain: anchor.CHAINS.TERRA,
network: anchor.NETWORKS.COLUMBUS_5,
address: terraWalltAddrTest,
});

// Anchor Send Code:
const sendUst = await anchorEarn.send({
currency: anchor.DENOMS.UST,
recipient: kucointerraWalletAddr,
amount: sendAmnt,
log: (data) => {
console.log(data);
},
customSigner: testWalletSigner,
});

Returned APY is wrong

Hi, running the code below returns 16.5% as the Anchor APY, while the official website states 17.97%.

Which one is correct?

https://app.anchorprotocol.com/earn

Code:

import {
  AnchorEarn,
  NETWORKS,
  CHAINS,
  DENOMS,
} from '@anchor-protocol/anchor-earn' // yarn add @anchor-protocol/[email protected]

const anchorEarn = new AnchorEarn({
  chain: CHAINS.TERRA,
  network: NETWORKS.COLUMBUS_5,
  address: 'terra1mqs59fdv2t0cc3pmrtrgn83azvqv8dqz8q4063'
});

const checkMarket = async () => {
  const market = await anchorEarn.market({ // .balance
    currencies: [DENOMS.UST],
  })

  return market
}

console.log(await checkMarket())

// node test.mjs

Response:

MarketOutput {
  chain: 'terra',
  network: 'columbus-5',
  height: 7491758,
  markets: [
    {
      currency: 'UST',
      liquidity: '10914277436.565453',
      APY: '0.165471511176329490'
    }
  ],
  timestamp: 2022-05-03T12:15:49.748Z
}

"insufficient fee" when executing deposit using AnchorEarn

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?

throw new Error('Insufficient ust balance');

Hello folks, I my facing the above issue while implementing the code of deposit. If anyone could guide me for this error it would be great as I'm new in this field. thank you in advance. i had also entered my Mnemonickey but still it not works for me. It says throw new Error('Insufficient ust balance');

import { Account, AnchorEarn, CHAINS, NETWORKS, TxOutput } from '@anchor-protocol/anchor-earn/dist/facade';
import {MnemonicKey} from '@anchor-protocol/anchor-earn/dist/facade';
import {DENOMS} from '@anchor-protocol/anchor-earn/dist/address-provider'

/**
*
*For creating new account
*/
// const account = new Account(CHAINS.TERRA);
// console.log(account.toData());

const account = new MnemonicKey({
mnemonic:
'',
});

console.log(account.accAddress);

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

async function start() {
const deposit = await anchorEarn.deposit({
amount: '1.0',
currency: DENOMS.UST,
})

}

start();

TypeError: Cannot read property 'chainID' of undefined

const { Wallet, MnemonicKey, AnchorEarn } = require('@anchor-protocol/anchor-earn');
require('dotenv').config();

const account = new MnemonicKey({
  mnemonic: process.env.MNEMONIC,
});

const anchorEarn = new AnchorEarn({
    chain: "terra",
    network: "columbus-5",
    privateKey: process.env.PRIVATE_KEY,
    mnemonic: process.env.MNEMONIC,
    address: process.env.ADDRESS,
  });

Here is my code. What am I doing wrong?

anchorEarn.balance error

I got this error after query the balance with anchorEarn.balance

Cannot read property 'amount' of undefined
at TerraAnchorEarn. (\node_modules@anchor-protocol\anchor-earn\dist\facade\terra-anchor-earn.js:325:71)
at Generator.next ()
at fulfilled (\node_modules@anchor-protocol\anchor-earn\dist\facade\terra-anchor-earn.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5)

Can't withdraw full balance at once

I put 100.5 UST in my Anchor. I check the balance over time and it's increasing.
10 minutes in, I try to withdraw the 100.5. By now it's 100.500454.

However, I can only withdraw 80 UST at this time.
It throws me an error: Error: Cannot withdraw more than balance. 100500000 > 83228385

I withdraw 80.5 UST.
Then I try to withdraw the other 20 UST. I can withdraw only 16 UST now.
It throws me an error: Error: Cannot withdraw more than balance. 20000000 > 16563164

What am I missing? Why can't I withdraw the full balance?

(using 2.0.0 alpha1)

TypeError: userCoins.get is not a function

  • The address I'm using does indeed have funds.
  • After reverting this change it works (cc @ALPAC-4).
import Anchor from '@anchor-protocol/anchor-earn'; // v1.1.0

(async () => {
  const anchorEarn = new Anchor.AnchorEarn({
    address: '...',
    chain: Anchor.CHAINS.TERRA,
    network: Anchor.NETWORKS.COLUMBUS_5,
  });

  const { total_deposit_balance_in_ust: anchorBalance } =
    await anchorEarn.balance({ currencies: [Anchor.DENOMS.UST] });
})()

AnchorEarn is not a constructor

I'm importing the SDK like this
const AnchorEarn = require("@anchor-protocol/anchor-earn");

and then I initialize a new instance as per the guide

const anchorEarn = new AnchorEarn({
  chain: "terra",
  network: "columbus-5",
  address: "MY_ADDRESS",
});

But I get this error
AnchorEarn is not a constructor

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.