anchor-protocol / anchor-earn Goto Github PK
View Code? Open in Web Editor NEWThe Earn JavaScript SDK for Anchor Protocol.
License: Apache License 2.0
The Earn JavaScript SDK for Anchor Protocol.
License: Apache License 2.0
Version: v1.1.1
Recently, I encountered an TypeScript build error while try using anchor-earn.
node_modules/@anchor-protocol/anchor-earn/dist/facade/types.d.ts:7:24 - error TS2305: Module '"@terra-money/terra.js"' has no exported member 'StdTx'.
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
.
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.
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,
});
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
}
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?
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();
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?
Let my people go..!! In Jesus name
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)
I would expect this to withdraw 0.5 UST
and not 0.5 aUST
This was with 1.1.0-alpha.2
and using bombay-12
.
This is how I was calling the function:
fabricateMarketRedeemStable({
address: 'terra1cq8l6fxx5gfs9qde80f2rcp7n0j020zwffrlx0',
currency: DENOMS.UST,
amount: '0.5'
})(addressProvider);
And here is the tx:
https://finder.terra.money/bombay-12/address/terra1cq8l6fxx5gfs9qde80f2rcp7n0j020zwffrlx0
Godislove
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)
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] });
})()
this occurred while querying for anchorEarn.balance
When I call deposit method the promise never resolves.
Version: 2.0.0
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.