diff --git a/README.md b/README.md index 55fb7685..f8f65c36 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ There are multiple ways to use ParaSwap SDK, ranging from a simple construct-and ### Simple SDK -Can be created by providing `chainId` and either `axios` or `window.fetch` (or alternative `fetch` implementation), and an optional `version` (`'5'` or `'6.2'`) parameter that corresponds to the API version SDK will be making requests to. The resulting SDK will be able to use all methods that query the API. +Can be created by providing `chainId` and either `axios` or `window.fetch` (or alternative `fetch` implementation), and an optional `version` (`'5'` or `'6.1'`) parameter that corresponds to the API version SDK will be making requests to. The resulting SDK will be able to use all methods that query the API. ```ts import { constructSimpleSDK } from '@paraswap/sdk'; diff --git a/docs/html/index.html b/docs/html/index.html index e2efc4ac..b1ce50f8 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -43,7 +43,7 @@

Using ParaSwap SDK

Simple SDK

-

Can be created by providing chainId and either axios or window.fetch (or alternative fetch implementation), and an optional version ('5' or '6.2') parameter that corresponds to the API version SDK will be making requests to. The resulting SDK will be able to use all methods that query the API.

+

Can be created by providing chainId and either axios or window.fetch (or alternative fetch implementation), and an optional version ('5' or '6.1') parameter that corresponds to the API version SDK will be making requests to. The resulting SDK will be able to use all methods that query the API.

  import { constructSimpleSDK } from '@paraswap/sdk';
import axios from 'axios';

// construct minimal SDK with fetcher only
const paraSwapMin = constructSimpleSDK({chainId: 1, axios});
// or
const paraSwapMin = constructSimpleSDK({chainId: 1, fetch: window.fetch, version: '5'});

const ETH = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F';

async function swapExample() {
// or any other signer/provider
const signer: JsonRpcSigner = ethers.Wallet.fromMnmemonic('__your_mnemonic__');
const senderAddress = signer.address;

const priceRoute = await paraSwapMin.swap.getRate({
srcToken: ETH,
destToken: DAI,
amount: srcAmount,
userAddress: senderAddress,
side: SwapSide.SELL,
});

const txParams = await paraSwapMin.swap.buildTx(
{
srcToken,
destToken,
srcAmount,
destAmount,
priceRoute,
userAddress: senderAddress,
partner: referrer,
}
);

const transaction = {
...txParams,
gasPrice: '0x' + new BigNumber(txParams.gasPrice).toString(16),
gasLimit: '0x' + new BigNumber(5000000).toString(16),
value: '0x' + new BigNumber(txParams.value).toString(16),
};

const txr = await signer.sendTransaction(transaction);
}

If optional providerOptions is provided as the second parameter, then the resulting SDK will also be able to approve Tokens for swap.

diff --git a/docs/html/types/GetRateFunctions.html b/docs/html/types/GetRateFunctions.html index a32539fa..1d54f3fb 100644 --- a/docs/html/types/GetRateFunctions.html +++ b/docs/html/types/GetRateFunctions.html @@ -22,7 +22,7 @@
getRate:
getRateByRoute: GetRateByRoute
+
  • Defined in src/methods/swap/rates.ts:197
  • +
  • Defined in src/methods/swap/rates.ts:169
  • +
  • Defined in src/methods/swap/rates.ts:183
  • +
  • Defined in src/methods/swap/rates.ts:192
  • +
  • Defined in src/methods/swap/rates.ts:188
  • +
  • Defined in src/methods/swap/rates.ts:178