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

abracadabra-sdk

v1.0.1

Published

SDK to interact with Abracadabra smart contracts.

Downloads

4

Readme

Unofficial Abracadabra SDK

abracadabra-sdk is a JavaScript SDK for writing applications that interact with the Abracadabra cauldron contracts. This SDK provides a layer of abstraction around querying the contracts and constructing positions on the blockchain.

This SDK aims to make it simple for developers to query contracts and answer questions like:

  • How much collateral is in the WBTC cauldron?
  • How much MIM has been lent out across ETH mainnet?
  • What is the LTV of a particular address on Arbitrum's GLP cauldron?

This SDK also aims to make it easier for developers to execute actions such as:

  • Borrowing MIM against wETH collateral
  • Repaying MIM to lower LTV
  • Creating a 3x leveraged position on the stUSDT cauldron

Installation

You can install the latest version of abracadabra-sdk through npm:

npm install abracadabra-sdk

Usage

Initializing the client

First, a client instance is needed in order to begin interacting with the Abracadabra smart contracts. The Abracadabra client can be initialized as follows:

import { ethers } from 'ethers';
import { Abracadabra } from './src';
import { ChainSymbol } from './src/util/interfaces';

const provider = new ethers.providers.JsonRpcProvider(process.env.TENDERLY_TEST_FORK);
const client = new Abracadabra(ChainSymbol.ethereum, { provider: provider });

Querying market information

Once initialized, the client can be used to query market information. Queries use multicall functionality to batch queries in a single request. This reduces the number of RPC calls being made to nodes.

let market = client.markets['wbtc'];
let marketInfo = await market.getMarketInfo();

console.log(marketInfo.totalCollateral.value.toString());
// 5599744955230399650578728 = $5.6M

Writing a cook

The client can also help you structure a cook call to interact with the protocol. For some example recipes, please see the examples folder. Here is what a function to deposit collateral into a cauldron might look like:

async function simpleDeposit(market: Market) {
  let cauldron = market.cauldron;
  let [bentoBox, collateral, masterContract, signatureCollector] = await Promise.all([
    cauldron.bentoBox(),
    cauldron.collateral(),
    cauldron.masterContract(),
    market.getSignatureCollector(),
  ]);

  console.log('Balance of wallet: ', (await collateral.balanceOf(wallet.address)).toString());

  // Deposit 0.1 (~$100) of yv-3Crypto
  const depositAmount = expandDecimals(17);

  // First, approve the BentoBox to spend the collateral.
  await collateral.approve(bentoBox.contractAddress, depositAmount.mul(1000));

  // Next, create the set of cook actions.
  let actions = [
    new BentoSetApproval(masterContract, wallet.address, await signatureCollector.parsedSignature()),
    new BentoDeposit(collateral.contractAddress, wallet.address, depositAmount),
    new AddCollateral(wallet.address, false),
  ];

  await cauldron.cook(actions);
}

Testing

Tests are done on a Tenderly fork with a fixed block set to 16617737. Test can be run with:

npm run test