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

@axotrade/swaps

v0.3.0

Published

## Axo Swaps

Downloads

116

Readme

Axo partner widgets

Axo Swaps

Screenshot

Basket Buy

Screenshot

Installing the package and peer dependecies (applicable to all widgets)

npm i @axotrade/swaps @emurgo/[email protected]

Make sure that your that your build config supports importing WASM modules.

Importing styles (applicable to all widgets)

import `@axotrade/swaps/dist/style.css';

Integration

Integrating in Create React App (or similar client only config) - Axo Swaps

import { AxoSwaps, SwapConfig } from '@axotrade/swaps'

const config: SwapConfig = {
    left={"<asset-subject>" | "<asset-ticker>" | "<asset-policy-id>"}
    right={"<asset-subject>" | "<asset-ticker>" | "<asset-policy-id>"}
    network={"mainnet" | "preprod"}
    partnerKey="<api-key>"
    walletName={"<wallet-name>" | undefined}
    onClickWalletConnect={() => console.log('Wallet connect button clicked')}
}

const App = () => <AxoSwaps {...config} />

Integrating in Create React App (or similar client only config) - Basket buy

import { AxoBasket, BasketBuyConfig } from '@axotrade/swaps'

const config: BasketBuyConfig = {
    payload="<basket-buy-payload>"
    hostApiKey="<host-api-key>"
    hostBaseApiURL="<host-base-api-url>"
    network={"mainnet" | "preprod"}
    partnerKey="<api-key>"
    walletName={"<wallet-name>" | undefined}
    onClickWalletConnect={() => console.log('Wallet connect button clicked')}
}

const App = () => <AxoBasket {...config} />

Integrating in NextJS - Axo Swaps

'use client';
import dynamic from "next/dynamic"
import type { SwapConfig } from '@axotrade/swaps'

const AxoSwaps = dynamic(
  () => import('@axotrade/swaps').then((module) => module.AxoSwaps),
  { ssr: false },
);

const config: SwapConfig = {
    left={"<asset-subject>" | "<asset-ticker>" | "<asset-policy-id>"}
    right={"<asset-subject>" | "<asset-ticker>" | "<asset-policy-id>"}
    network={"mainnet" | "preprod"}
    partnerKey="<api-key>"
    walletName={"<wallet-name>" | undefined}
    onClickWalletConnect={() => console.log('Wallet connect button clicked')}
}

const App = () => <AxoSwaps {...config} />

Integrating in NextJS - Basket Buy

'use client';
import dynamic from "next/dynamic"
import type { BasketBuyConfig } from '@axotrade/swaps'

const AxoBasket = dynamic(
  () => import('@axotrade/swaps').then((module) => module.AxoBasket),
  { ssr: false },
);

const config: BasketBuyConfig = {
    payload="<basket-buy-payload>"
    hostApiKey="<host-api-key>"
    hostBaseApiURL="<host-base-api-url>"
    network={"mainnet" | "preprod"}
    partnerKey="<api-key>"
    walletName={"<wallet-name>" | undefined}
    onClickWalletConnect={() => console.log('Wallet connect button clicked')}
}

const App = () => <AxoBasket {...config} />

Configuration - Axo Swaps

| Name | Required | Type | Default | Description | | -------------------- | ------------ | ---------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | left | true | string | - | The left asset to use for the swap. Can be a subject, policy ID or ticker. | | right | true | string | - | The right asset to use for the swap. Can be a subject, policy ID or ticker. | | network | true | 'mainnet' | 'preprod' | - | The network to use for the swap. Use 'mainnet' for Cardano Mainnet, 'preprod' for Cardano pre-prod. | | partnerKey | true | string | - | The partner key to use for the swap. | | walletName | false | WalletName | - | The name of the connected wallet. Supported values: eternl, nami, flint, yoroi, typhoncip30, nufi and gerowallet. If no wallet connected, pass undefined. | | onClickWalletConnect | false | VoidFunction | - | A function to call when the wallet connect button is clicked. |

Configuration - Basket buy

| Name | Required | Type | Default | Description | | -------------------- | ------------ | ---------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | payload | false | PayloadEntry[] | - | Subjects, tickers (asset_name) and weights provided by host to use instead of the host's api. When hostApiKey, hostBaseApiURL and payload are provided, the payload will take precedence | | hostApiKey | false | string | - | The host api key to use for the host's api (needs to be used in conjunction with hostBaseApiURL) | | hostBaseApiURL | false | string | - | The host base api url to connect to host's api to query the payload, example: https://api.host-domain.com/v1 (needs to be used in conjunction with hostApiKey) | | network | true | 'mainnet' | 'preprod' | - | The network to use for the swap. Use 'mainnet' for Cardano Mainnet, 'preprod' for Cardano pre-prod. | | partnerKey | true | string | - | The partner key to use for the swap. | | walletName | false | WalletName | - | The name of the connected wallet. Supported values: eternl, nami, flint, yoroi, typhoncip30, nufi and gerowallet. If no wallet connected, pass undefined. | | onClickWalletConnect | false | VoidFunction | - | A function to call when the wallet connect jtton is clicked. |

const type PayloadEntry = {
  asset_name: string;
  subject: string | undefined;
  weight: number;
}

Pre-prod network configuration (applicable to all widgets)

When using preprod, the component will use the Cardano Pre-prod network and the Axo preview environment.

This configuration is meant for testing your integration with Axo.

Prices and order book information will be sourced from Axo preview. The component will use tokens distributed from the preview faucet. If necessary, more tokens can be purchased with tADA in the application.

Demo

Preprod

  • Axo Swaps: https://app.axo-preview.trade/dev/partner-integration/axo-swaps
  • Basket Buy: https://app.axo-preview.trade/dev/partner-integration/basket-buy

Prod

  • Axo Swaps: https://app.axo.trade/dev/partner-integration