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

@ashswap/ash-sdk-js

v2.2.0

Published

AshSwap SDK for JavaScript and TypeScript

Downloads

1,055

Readme

AshSwap Sdk

Pool Contracts

The Pool Contract acts as an AMM for trading tokens. The AMM is based on Curve's algorithm used for the stable coin. Fee contains two types of fees: trading fee and admin fee.

The trading fee will stay in the liquidity pool to leverage LP holder interest. The admin fee will be sent to the veASH holder.

    //Example of swap
    const tokenIn = TOKENS_MAP["EGLD"]
    const tokenOut = TOKENS_MAP["ASH-a642d1"];
    const tokenPayment = TokenPayment.fungibleFromBigInteger(
        tokenIn.identifier,
        new BigNumber(10),
        tokenIn.decimals
    );

    const poolContract = ContractManager.getPoolContract(
        poolAddress
    );

    const tx = await poolContract.exchange(
        tokenPayment,
        tokenOut.identifier,
        new BigNumber(1),
    );

See more in example

Farm Contract

The Farm Contract is a contract where users can lock their LP token to receive ASH.

Following Maiar Exchange, the farm position is represented by Farm Token, which is a Semi-Fungible Token. The reasoning behind this is that to calculate the reward for the token owner without storing anything on a smart contract.

    //Example of stake

    const farm = FARMS_MAP[farmAddress];
    const farmContract = ContractManager.getFarmContract(
        farm.farm_address
    );
    const stakeAmt = new BigNumber(1);

    const farmTokenInWallet: IMetaESDT[] = [];

    const tokenPayments = farmTokenInWallet.map((t) =>
        TokenPayment.metaEsdtFromBigInteger(
            t.collection,
            t.nonce,
            t.balance,
            farm.farm_token_decimal
        )
    );
    tokenPayments.unshift(
        TokenPayment.fungibleFromBigInteger(
            farm.farming_token_id,
            stakeAmt,
            farm.farming_token_decimal
        )
    );
    const tx = await farmContract.enterFarm(
        Address.Zero().bech32(),
        tokenPayments,
    );

See more in example

Voting Escrow Contract (DAO)

Contract where users can lock their ASH token for pre-set periods to gain veASH (Votes). Votes have weight depending on time. A user who has veASH can receive an admin fee from Pool Contract as their reward.

Besides that, they can use their veASH as a voting weight in the DAO voting system.

    const contract = ContractManager.getVotingEscrowContract("erd1...");
    const tx = await contract.withdraw();

See more in example

Fee Distributor Contract

The contract contains the admin fee that is collected from Pools and distribute it into veASH owner.

    const contract = ContractManager.getFeeDistributorContract("erd1...");
    const tx = await contract.claim(new Address("erd1..."));

See more in example

Ashswap Aggregator service

Provide an abstraction service to get routes to swap between two assets,

    // Permit the user to convert one EGLD to ASH with a 0.1% slippage.
    // Based on the fee configuration, xPortal will also receive a small amount of fees.
    const xPortalProtocol = 'erd...';
    const agService = new Aggregator({chainId: ChainId.Mainnet, protocol: xPortalProtocol});
    const {sorResponse, getInteraction} = await agService.aggregate('EGLD', 'ASH-a642d1', 1e18, 100);
    // remember to set the sender (caller) before sending the tx
    const tx = await getInteraction(async (warning) => {
        console.log('tx warning:', warning);
        const swapAnyway = await openModal().then(() => true).catch(() => false);
        return swapAnyway;
    }).catch(() => null);
    if (!tx) return;
    tx.withSender(new Address('erd...')).check().buildTransaction();
    // sign and send tx to the network
    sendTransactions({
        transactions: [tx],
    })

See more in example