npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@equilab/utils

v1.2.34

Published

utils for equilab project

Downloads

125

Readme

EQ Utils

Convenience Types

  • type Undef<T> = T | undefined;
  • type Unwrap<T> = T extends Undef<infer D> ? D : T;
  • type UnwrapArray<T> = T extends Array<infer D> ? D : T;
  • type UnwrapPromise<T> = T extends Promise<infer D> ? D : T;

Async helpers

  • Mutex
export { Mutex } from "@equilab/utils";

const mutex = new Mutex();

const release = await mutex.acquire(); // if mutex is acquired by another task then pause execution

release(); // release mutex to let it be acquired

API

Get borrower LTV

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript

{"namespace": "portfolio", "method": "ltv", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

When debt exists and ltv computable then response should look like

HTTP/1.1 200 OK

{
  "success": true,
  "payload": "2.740757"
}

Ltv is 2.74 or 274%.

When borrower account does not exist (user never borrowed or deposited funds to borrow)

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Borrower account not found"
}

When account has no debt

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "No debt on account"
}

Get latest margincall info

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript

{"namespace": "portfolio", "method": "margincall", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

When there info about latest margin call you will recieve response with block, block timestamp and tokens transferred during margin call

HTTP/1.1 200 OK

{
  "success": true,
  "payload": {
    "timestamp": 1611652206000,
    "block": 69115,
    "tokens": [
      {
        "currency": "Btc",
        "amount": 0.009759895
      },
      {
        "currency": "Eos",
        "amount": 1
      }
    ]
  }
}

When borrower account does not exist (user never borrowed or deposited funds to borrow)

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Borrower account not found"
}

Get EQ balance

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript

{"namespace": "portfolio", "method": "eqbalance", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

Balance is returned as string

HTTP/1.1 200 OK

{
  "success": true,
  "payload": "1"
}

When borrower account does not exist (user never borrowed or deposited funds to borrow)

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Borrower account not found"
}

Get fees paid

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript

{"namespace": "fees", "method": "interestpaid", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

If you have active borrower and/or bailsman role


{
  "success": true,
  "payload": "26.674442518"
}

This means you paid 26.67 EQ

When you don't have borrower and bailsman role:

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Borrower or bailsman account not found"
}

Get current borrowing rate

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript
Cache-Control: no-cache

{"namespace": "fees", "method": "borrowingrate", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

HTTP/1.1 200 OK

{
  "success": true,
  "payload": "0.3992476577010985651225"
}

When you don't have borrower and bailsman role:

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Borrower or bailsman account not found"
}

Get interest earned (by bailsman)

Request example

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript
Cache-Control: no-cache

{"namespace": "fees", "method": "interestearned", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

HTTP/1.1 200 OK

{
  "success": true,
  "payload": {
    "EQ": "53.750042915",
    "Btc": "0.000118141"
  }
}

When bailsman account doesn't exist

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Bailsman account not found"
}

Current savings rate (for bailsman)

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript
Cache-Control: no-cache

{"namespace": "fees", "method": "savingsrate", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

HTTP/1.1 200 OK

{
  "success": true,
  "payload": "0.07932925850387014265"
}

When bailsman account doesn't exist

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Bailsman account not found"
}

Received assets (for bailsman)

POST https://app.equilibrium.io/testnet/service HTTP/1.1
Content-Type: application/x-javascript
Cache-Control: no-cache

{"namespace": "portfolio", "method": "recievedassets", "payload": {"address": "5GN3sWbQxyZJ7Q47rnFVyWXxwe14LtRJiqrMmKeqmf6FDM9Y"}}

Responses

HTTP/1.1 200 OK

{
  "success": true,
  "payload": [
    {
      "timestamp": 1612528116000,
      "blockNumber": 57783,
      "currency": "Usd",
      "amount": "4.270045693"
    }
  ]
}

When bailsman account doesn't exist

HTTP/1.1 500 Internal Server Error

{
  "success": false,
  "error": "Bailsman account not found"
}