Giter Club home page Giter Club logo

anchor.js's People

Contributors

cosullivan avatar davidvuong avatar ezaanm avatar ggomma avatar hanjukim avatar kjessec avatar msntcs avatar pmannle avatar r-amiri avatar ratik 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  avatar  avatar  avatar

anchor.js's Issues

Update Documentation

The current Readme is aligned with the previous version of the code. We need to update Readme and message fabricators' names. The following change must happen:

  • Change Readme
  • Publish the new version
  • Update anchor documentation

get error when running estimateFee with an anchor borrow tx

i create an borrow msg with api in anchor.js,

the message is :

{ coins:[], contract: "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal", execute_msg:{borrow_stable:{borrow_amount: "2155939304",to: "terra130pmlk768prw66rhszqj6qq02sdtf3mlchknap"}}, sender: "terra130pmlk768prw66rhszqj6qq02sdtf3mlchknap" }

when i running estimateFee, i get the error,

failed to execute message; message index: 0: Generic error: Querier contract error: Generic error: Price is too old: contract query failed: execute wasm contract failed: invalid request

'anchor.borrow.getCollateralValue' occurs an error with a random address.

Code

const address = 'terra1fpnt5t2094g3amcwdv3akl60jg9uafgtc38px8';


const borrowedValue = await anchor.borrow.getBorrowedValue({
  market: MARKET_DENOMS.UUSD,
  address,
});

const borrowLimit = await anchor.borrow.getBorrowLimit({
  market: MARKET_DENOMS.UUSD,
  address,
});

console.log(borrowedValue);
console.log(borrowLimit);

Output

0.000000000000000000
0.000000000000000000

It works but

Code

const address = 'terra1fpnt5t2094g3amcwdv3akl60jg9uafgtc38px8';

const collateralValue = await anchor.borrow.getCollateralValue({
  market: MARKET_DENOMS.UUSD,
  address,
});

console.log(collateralValue);

Output

TypeError: Cannot read property 'collateral' of null
    at C:\Users\HSK\programming\anchor-command-tools\node_modules\@anchor-protocol\anchor.js\src\facade\borrow\borrow.ts:95:39
    at Array.find (<anonymous>)
    at C:\Users\HSK\programming\anchor-command-tools\node_modules\@anchor-protocol\anchor.js\src\facade\borrow\borrow.ts:94:50
    at Array.reduce (<anonymous>)
    at Borrow.<anonymous> (C:\Users\HSK\programming\anchor-command-tools\node_modules\@anchor-protocol\anchor.js\src\facade\borrow\borrow.ts:93:31)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\HSK\programming\anchor-command-tools\node_modules\@anchor-protocol\anchor.js\dist\facade\borrow\borrow.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

This code occurs an error.
I used a random address that were in my wallet history for test.
I changed the address to my wallet address. It worked well.

Are there addresses that can't get collateral value?

js example to bond LUNA

Is there any JS example that shows how to use Anchor and Terra sdk to Bond LUNA for bLUNA (staking and unstaking)

Thanks

anchor.borrow.getCollateralValue fails

Other functions return correct values, but getCollateralValue fails:


const main = async (): Promise<void> => {

    const wallet = new Wallet(lcd, key) 
    const anchor = new Anchor(lcd, addressProvider)

    const walletDenom = {
        address: wallet.key.accAddress,
        market: MARKET_DENOMS.UUSD,
    }

    try {

        const totalDeposits = await anchor.earn.getTotalDeposit(walletDenom)
    
        const borrowedValue = await anchor.borrow.getBorrowedValue(walletDenom)
        
        const collateralValue = await anchor.borrow.getCollateralValue(walletDenom)

        // console.log(totalDeposits) // returns correct value 
        // console.log(borrowedValue) // returns correct value
        console.log(collateralValue) // data: { error: 'decoding bech32 failed: invalid separator index -1' }

    } catch(error) {
        console.log(error)
    }

}

Transaction Fee

Hi,

How or where can I get the transaction fee value?
Like here:
Screen Shot 2021-04-07 at 2 26 52 AM

Thanks

SyntaxError: Named export 'OperationGasParameters' not found.

I was trying this :
import { Anchor, columbus5, AddressProviderFromJson, MARKET_DENOMS, OperationGasParameters } from '@anchor-protocol/anchor.js'
which has thrown me this error:

SyntaxError: Named export 'OperationGasParameters' not found. The requested module '@anchor-protocol/anchor.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@anchor-protocol/anchor.js';
const { Anchor, columbus5, AddressProviderFromJson, MARKET_DENOMS, OperationGasParameters } = pkg;

Any idea why it's happening?

Lock and unlock collaterals for bETH

CurrentlyfabricateProvideCollateral includes lock_collateral for both collaterals (bluna and bEth), but there is no individual fabricator for bETH lock_collateral/ unlock_collateral. We need to introduce new fabricators for these two functions.

How should I call a function 'getBorrowedValue'?

import { LCDClient } from '@terra-money/terra.js';
import {
  Anchor,
  columbus4,
  AddressProviderFromJson,
  MARKET_DENOMS,
} from '@anchor-protocol/anchor.js';

const walletAddress = '[my wallet address]';

const main = async () => {
  const addressProvider = new AddressProviderFromJson(columbus4);
  const lcd = new LCDClient({
    URL: 'https://lcd.terra.dev',
    chainID: 'columbus-4',
  });

  const anchor = new Anchor(lcd, addressProvider);

  try {
    const price = await anchor.anchorToken.getANCPrice();

    const borrowedValue = await anchor.borrow.getBorrowedValue(
      MARKET_DENOMS.UUSD,
      walletAddress
    );

    console.log('price', price);
    console.log('borrowedValue', borrowedValue);
  } catch (err) {
    console.error(err);
  }
};

main();

The method getANCPrice works well. but
Calling a method 'getBorrowedValue' occurs an error.

contract query failed: parsing moneymarket::market::QueryMsg: unknown variant `loan_amount`, expected one of `config`, `state`, `epoch_state`, `borrower_info`, `borrower_infos`

I think I might've called in a wrong way. but I don't know why it doesn't work.
How should I call this function? (I don't want to use a mnemonic)

Incorrect return annotation on `queryLiquidationQueueBidPoolsByCollateral`

Currently:

interface Option {
    lcd: LCDClient;
    collateral_token: string;
    start_after: number | undefined;
    limit: number | undefined;
}
export interface BidPoolResponse {
    sum_snapshot: string;
    product_snapshot: string;
    total_bid_amount: string;
    premium_rate: string;
    current_epoch: string;
    current_scale: string;
}
export declare const queryLiquidationQueueBidPoolsByCollateral: ({ lcd, collateral_token, start_after, limit }: Option) => (addressProvider: AddressProvider) => Promise<BidPoolResponse[]>;

The return type of queryLiquidationQueueBidPoolsByCollateral should be:

export interface BidPoolsByCollateralResponse {
  bid_pools: BidPoolResponse[]
}

Version:

"@anchor-protocol/anchor.js": "^5.0.2"

Documentation: https://docs.anchorprotocol.com/smart-contracts/liquidations/liquidation-queue-contract#bidpoolsbycollateralresponse

Example response in documentation:

{
  "bid_pools": [
    {
      "sum_snapshot": "1.0",
      "product_snapshot": "1.0",
      "total_bid_amount": "1000000",
      "premium_rate": "0.1",
      "current_epoch": "0",
      "current_scale": "0"
    }, 
    {
      "sum_snapshot": "1.0",
      "product_snapshot": "1.0",
      "total_bid_amount": "2000000",
      "premium_rate": "0.2",
      "current_epoch": "0",
      "current_scale": "0"
    }
  ]
}

[Question] Get `borrower_info` of previous block heights

Hello, not sure if this is the right place for this question.
I am trying to get borrowed amount of previous block heights to calculate the occurred loan fees over time.

WIthout previous knowledge, I just was trying within dev tools to change the request as follows but it always returns the current block height. Ideas?

height=5971055;
address="terra...";
(await (await fetch("https://mantle.terra.dev/?borrow--borrower", {
  "headers": {
    "accept": "application/json",
    "content-type": "application/json"
  },
  "referrer": "https://app.anchorprotocol.com/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": "{\"query\":\"{\\n  marketBorrowerInfo: WasmContractsContractAddressStore(\\n    ContractAddress: \\\"terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s\\\"\\n    QueryMsg: \\\"{\\\\\\\"borrower_info\\\\\\\":{\\\\\\\"borrower\\\\\\\":\\\\\\\""+address+"\\\\\\\",\\\\\\\"block_height\\\\\\\":"+height+"}}\\\"\\n  ) {\\n    Result\\n    Height\\n  }\\n}\\n\",\"variables\":{}}",
  "method": "POST",
  "mode": "cors",
  "credentials": "omit"
})).json()).data.marketBorrowerInfo

SSL Certification Expired

Hi,

I'm testing terra.js and always getting an error:

I'm at https://soju-lcd.terra.dev

 code: 'CERT_HAS_EXPIRED',
  config: {
    url: '/bank/balances/terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v',
    method: 'get',
    headers: { Accept: 'application/json', 'User-Agent': 'axios/0.21.1' },

...

Screen Shot 2021-03-31 at 4 33 59 AM

Thanks for your assistance.
Kind regards!

Can't Install the package

I tried to install the package.

npm i @anchor-protocol/anchor.js

then I encountered messages.

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@anchor-protocol%2fanchor.js - Not found
npm ERR! 404
npm ERR! 404  '@anchor-protocol/anchor.js@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

When I access the package in npmjs.com, they ask me to login.
But even I logged in , there is a message '404 not found'.

How can I install the anchor.js package
Or Is it not possible yet? do I have to wait for v1.x version?

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.