1.4.1 • Published 1 year ago

@o3swap/v2-sdk v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

O3 SDK

npm version

Setup

Install from npm:

npm install @o3swap/v2-sdk

Init

const o3swap = await new O3Swap().init();
// You can use the RPC provided by us, or use your own RPC
o3swap.setRPC(chainId, '');

Quoter

const bscUSDC: Token = {
  hash: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
  chainId: 56,
};
const bscBNB: Token = {
  hash: '0x0000000000000000000000000000000000000000',
  chainId: 56,
};
const amount = '1000000000000000000'; // 1
const o3swap = await new O3Swap().init();
// Quoter BNB Chain 1 USDC -> BNB
const quoterResult = await o3swap.swapQuoter.quoter(bscUSDC, bscBNB, amount);

Swap

const quoterItem = quoterResult?.[0];
if (quoterItem) {
  const callParams = await o3swap.swap.exchange({
    quoter: quoterItem,
    deadlineSeconds: 600,
    toAddress: walletAddress,
    slip: 0.05,
  });

  // You need check approve by yourself

  (window as any).ethereum.request({
    method: 'eth_sendTransaction',
    params: [
      {
        from: '',
        to: callParams.contract,
        value: callParams.value,
        data: callParams.callData,
      },
    ],
  });
}
1.4.1

1 year ago

1.2.5

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago