0.2.15 • Published 14 days ago

@axotrade/swaps v0.2.15

Weekly downloads
-
License
-
Repository
-
Last release
14 days ago

Axo partner widgets

Axo Swaps

Screenshot

Basket Buy

Screenshot

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

npm i @axotrade/swaps @emurgo/cardano-serialization-lib-browser@11.5.0

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

NameRequiredTypeDefaultDescription
lefttruestring-The left asset to use for the swap. Can be a subject, policy ID or ticker.
righttruestring-The right asset to use for the swap. Can be a subject, policy ID or ticker.
networktrue'mainnet' | 'preprod'-The network to use for the swap. Use 'mainnet' for Cardano Mainnet, 'preprod' for Cardano pre-prod.
partnerKeytruestring-The partner key to use for the swap.
walletNamefalseWalletName-The name of the connected wallet. Supported values: eternl, nami, flint, yoroi, typhoncip30, nufi and gerowallet. If no wallet connected, pass undefined.
onClickWalletConnectfalseVoidFunction-A function to call when the wallet connect button is clicked.

Configuration - Basket buy

NameRequiredTypeDefaultDescription
payloadfalsePayloadEntry[]-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
hostApiKeyfalsestring-The host api key to use for the host's api (needs to be used in conjunction with hostBaseApiURL)
hostBaseApiURLfalsestring-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)
networktrue'mainnet' | 'preprod'-The network to use for the swap. Use 'mainnet' for Cardano Mainnet, 'preprod' for Cardano pre-prod.
partnerKeytruestring-The partner key to use for the swap.
walletNamefalseWalletName-The name of the connected wallet. Supported values: eternl, nami, flint, yoroi, typhoncip30, nufi and gerowallet. If no wallet connected, pass undefined.
onClickWalletConnectfalseVoidFunction-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

Prod

0.2.15

14 days ago

0.2.14

19 days ago

0.2.13

20 days ago

0.2.12

26 days ago

0.2.11

26 days ago

0.2.10

26 days ago

0.2.9

26 days ago

0.2.8

27 days ago

0.2.7

1 month ago

0.2.6

1 month ago

0.2.5

1 month ago

0.2.4

1 month ago

0.2.3

1 month ago

0.2.1-rc.1

2 months ago

0.2.1-rc.2

2 months ago

0.2.1

2 months ago

0.2.0

2 months ago

0.1.15

2 months ago

0.1.14

2 months ago

0.1.10

3 months ago

0.1.11

3 months ago

0.1.12

3 months ago

0.1.13

3 months ago

0.1.9

3 months ago

0.1.8

3 months ago

0.1.7

3 months ago

0.1.6

3 months ago

0.1.5

3 months ago

0.1.4

3 months ago

0.1.3

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.1.0

3 months ago