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

@ajna-finance/sdk

v0.4.3

Published

A typescript SDK that can be used to create Dapps in Ajna ecosystem.

Downloads

72

Readme

Ajna SDK

A typescript SDK that can be used to create Dapps and keepers in the Ajna ecosystem.

Unit Tests Lint

Setup

  • Install/select Node.js ^18 using your preferred package/version manager. Note that CI runs against Node 18.
  • yarn install installs dependencies.
  • yarn build builds the app at build, cleaning the folder first.

Design

Exception handling

To improve responsiveness, the SDK may raise an SdkException locally if it knows the transaction will not succeed with the current state. The SDK traps reverts to decode and and throw an exception revealing the reason. The SDK does not attempt to handle connectivity errors. As such, the consumer should assume all onchain calls could throw an exception.

Usage

Prerequisites

Instructions assume basic knowledge of TypeScript, Ethers.js, and interacting with blockchains which use the Ethereum Virtual Machine (EVM).

Working with numeric types

Quantities and prices in Ajna are represented in WAD (18-decimal) precision. Ethers.js v5 models this using BigNumber. To convert to and from these scaled values, toWad and fromWad are provided. Do not explicitly multiply or divide by 10^18.

toWad allows conversions from both number and string values. fromWad converts to string values, such that precision is not lost.

Price buckets in Ajna are identified by an integer bucket index, between 1 (highest price) and 7388 (lowest price). To convert to and from bucket indicies, priceToIndex and indexToPrice functions are provided. The SDK uses number type to model bucket indices.

Examples

Example scripts are provided in the examples/ directory.

Development

Documentation

To build documentation, run yarn document. HTML will be generated in the sdk-api/docs directory.

Unit testing

Unit tests run against a dockerized Ajna testnet. Addresses and keys in test configuration are publicly known. Do not attempt to use those addresses on a public network!

yarn test runs jest tests once. yarn test:dev runs the jest tests in watch mode, waiting for file changes.

To pass parameters to jest, run using npx.

Note that test suites must be --runInBand because ganache requests to jump time, mine empty blocks, and reset to a checkpoint will impact unrelated tests. It also enables us to use the same account in multiple suites without worrying about nonce conflicts.

Maintenance

This package offers a facility to translate ABIs as compiled to a format consumable by Ethers.js. To use:

  • Set AJNA_ABIS environment var to the location where your compiler has generated the JSON ABI files. This assumes all ABIs reside in a single directory.
  • Run yarn update-abis to overwrite current ABIs in src/abis.

This facility was tested against brownie compilation output.

After updating ABIs, run yarn typechain-abis to generate typescript wrappers around contracts. Be sure to prettify generated code before committing.

After updating docker-compose.yml to point to a new testchain:

  • Update Ajna deployment addresses in tests/test-constants.ts
  • Update token and pool addresses in each test (tests/*.spec.ts).

Publishing

  • Authenticate with your npm account using either npm login or an npm token.
  • Run yarn publish to release a new version adhering to SemVer 2.0.
  • Commit the updated package.json.

Contributing

If you have suggestions for how SDK library boilerplate could be improved, or want to report a bug, open an issue! We'd love all and any contributions.