-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathsdk.ts
39 lines (32 loc) · 979 Bytes
/
sdk.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable @typescript-eslint/no-unused-vars */
import axios from 'axios';
import { ethers } from 'ethersV5';
import {
constructPartialSDK,
constructFullSDK,
constructGetAdapters,
constructEthersV5ContractCaller,
constructAxiosFetcher,
} from '..';
const fetcher = constructAxiosFetcher(axios);
const provider = ethers.getDefaultProvider(1);
const contractCaller = constructEthersV5ContractCaller({
ethersProviderOrSigner: provider,
EthersContract: ethers.Contract,
});
const paraswap = constructFullSDK({
apiURL: '',
chainId: 1,
fetcher,
contractCaller,
});
const res = paraswap.swap.getAdapters();
// type Promise<ContractTransaction>
const txResponse = paraswap.swap.approveToken('1', '0x...');
// type Promise<ContractTransaction[]>
const txResponses = paraswap.swap.approveTokenBulk('1', ['0x...']);
const partial = constructPartialSDK(
{ apiURL: '', chainId: 1, fetcher },
constructGetAdapters
);
const res1 = partial.getAdapters();