@dolomite-exchange/zap-sdk 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -9
- package/__tests__/DolomiteZap.test.ts +601 -422
- package/__tests__/helpers/TestConstants.ts +19 -0
- package/__tests__/lib/Utils.test.ts +30 -0
- package/build/src/index.js +1 -3
- package/package-lock.json +11170 -0
- package/package.json +2 -1
- package/src/DolomiteZap.ts +12 -2
- package/src/abis/IIsolationModeFactory.json +902 -0
- package/src/clients/DolomiteClient.ts +30 -6
- package/src/clients/IsolationModeClient.ts +2 -2
- package/src/index.ts +0 -2
- package/src/lib/ApiTypes.ts +52 -39
- package/src/lib/Constants.ts +47 -6
- package/src/lib/Utils.ts +1 -1
- package/src/lib/estimators/PendlePtEstimator.ts +101 -0
- package/src/lib/estimators/StandardEstimator.ts +82 -22
- package/build/__tests__/DolomiteZap.test.d.ts +0 -1
- package/build/__tests__/DolomiteZap.test.js +0 -526
- package/build/__tests__/clients/DolomiteClient.test.d.ts +0 -1
- package/build/__tests__/clients/DolomiteClient.test.js +0 -100
- package/build/__tests__/clients/ParaswapAggregator.test.d.ts +0 -1
- package/build/__tests__/clients/ParaswapAggregator.test.js +0 -76
- package/build/__tests__/helpers/Setup.d.ts +0 -0
- package/build/__tests__/helpers/Setup.js +0 -6
- package/build/__tests__/helpers/TestConstants.d.ts +0 -9
- package/build/__tests__/helpers/TestConstants.js +0 -109
- package/build/__tests__/lib/LocalCache.test.d.ts +0 -1
- package/build/__tests__/lib/LocalCache.test.js +0 -78
- package/build/src/DolomiteZap.d.ts +0 -26
- package/build/src/DolomiteZap.js +0 -259
- package/build/src/abis/IDolomiteMarginExchangeWrapper.json +0 -80
- package/build/src/clients/AggregatorClient.d.ts +0 -7
- package/build/src/clients/AggregatorClient.js +0 -10
- package/build/src/clients/DolomiteClient.d.ts +0 -11
- package/build/src/clients/DolomiteClient.js +0 -225
- package/build/src/clients/IsolationModeClient.d.ts +0 -16
- package/build/src/clients/IsolationModeClient.js +0 -47
- package/build/src/clients/ParaswapAggregator.d.ts +0 -7
- package/build/src/clients/ParaswapAggregator.js +0 -150
- package/build/src/index.d.ts +0 -5
- package/build/src/lib/ApiTypes.d.ts +0 -113
- package/build/src/lib/ApiTypes.js +0 -16
- package/build/src/lib/Constants.d.ts +0 -17
- package/build/src/lib/Constants.js +0 -118
- package/build/src/lib/Environment.d.ts +0 -0
- package/build/src/lib/Environment.js +0 -3
- package/build/src/lib/GraphqlPageable.d.ts +0 -4
- package/build/src/lib/GraphqlPageable.js +0 -73
- package/build/src/lib/LocalCache.d.ts +0 -9
- package/build/src/lib/LocalCache.js +0 -29
- package/build/src/lib/Logger.d.ts +0 -3
- package/build/src/lib/Logger.js +0 -78
- package/build/src/lib/MathUtils.d.ts +0 -4
- package/build/src/lib/MathUtils.js +0 -16
- package/build/src/lib/Utils.d.ts +0 -5
- package/build/src/lib/Utils.js +0 -84
- package/build/src/lib/estimators/StandardEstimator.d.ts +0 -9
- package/build/src/lib/estimators/StandardEstimator.js +0 -89
- package/build/src/lib/graphql-types.d.ts +0 -17
- package/build/src/lib/graphql-types.js +0 -3
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<p style="text-align: center"><img src="https://github.com/dolomite-exchange/dolomite-margin/raw/master/docs/dolomite-logo.png" width="256" alt="Dolomite Logo" /></p>
|
|
2
2
|
|
|
3
3
|
<div style="text-align: center">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
<a href='https://coveralls.io/github/dolomite-exchange/zap-sdk?branch=master'>
|
|
5
|
+
<img src='https://coveralls.io/repos/github/dolomite-exchange/zap-sdk/badge.svg?branch=master&t=ZbXsH3' alt='Coverage Status' />
|
|
6
|
+
</a>
|
|
7
|
+
<a href='https://github.com/dolomite-exchange/zap-sdk/blob/master/LICENSE' style="text-decoration:none;">
|
|
8
|
+
<img src='https://img.shields.io/github/license/dolomite-exchange/zap-sdk.svg?longCache=true' alt='License' />
|
|
9
|
+
</a>
|
|
10
|
+
<a href='https://t.me/dolomite-official' style="text-decoration:none;">
|
|
11
|
+
<img src='https://img.shields.io/badge/chat-on%20telegram-9cf.svg?longCache=true' alt='Telegram' />
|
|
12
|
+
</a>
|
|
13
13
|
</div>
|
|
14
14
|
|
|
15
15
|
# Dolomite Zap SDK
|
|
@@ -18,5 +18,57 @@ SDK for zapping any asset to any asset on Dolomite.
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @dolomite-exchange/zap-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
or if you use `yarn`
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @dolomite-exchange/zap-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Initialization
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Network } from './ApiTypes';
|
|
37
|
+
import { DolomiteZap } from './DolomiteZap';
|
|
38
|
+
|
|
39
|
+
const network = Network.ARBITRUM_ONE;
|
|
40
|
+
const subgraphUrl = procses.env.SUBGRAPH_URL; // TODO replace with a URL to the Dolomite subgraph
|
|
41
|
+
const web3Provider = window.ethereum; // TODO replace with a web3 provider
|
|
42
|
+
const cacheSeconds = 60 * 60; // 1 hour
|
|
43
|
+
const zap = new DolomiteZap(
|
|
44
|
+
network,
|
|
45
|
+
subgraphUrl,
|
|
46
|
+
web3Provider,
|
|
47
|
+
cacheSeconds,
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Zapping
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { DolomiteZap } from './DolomiteZap';
|
|
55
|
+
|
|
56
|
+
let zap: DolomiteZap;
|
|
57
|
+
|
|
58
|
+
const tokenIn = WETH_MARKET;
|
|
59
|
+
const tokenOut = USDC_MARKET;
|
|
60
|
+
const txOrigin = web3WalletAddress;
|
|
61
|
+
|
|
62
|
+
const outputParams = await zap.getSwapExactTokensForTokensParams(
|
|
63
|
+
tokenIn,
|
|
64
|
+
amountIn,
|
|
65
|
+
tokenOut,
|
|
66
|
+
minAmountOut,
|
|
67
|
+
txOrigin,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// You can now use outputParams for calling Dolomite's GenericTraderProxy or LiquidatorProxyV4 contracts
|
|
71
|
+
```
|
|
72
|
+
|
|
21
73
|
## Overview
|
|
22
74
|
|