@dhedge/v2-sdk 1.0.0 → 1.2.0
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 +69 -3
- package/dist/config.d.ts +4 -0
- package/dist/entities/dhedge.d.ts +2 -1
- package/dist/entities/pool.d.ts +94 -13
- package/dist/entities/utils.d.ts +15 -0
- package/dist/services/claim-balancer/claim.service.d.ts +21 -0
- package/dist/services/claim-balancer/claim.worker.d.ts +4 -0
- package/dist/services/claim-balancer/ipfs.service.d.ts +4 -0
- package/dist/services/claim-balancer/types.d.ts +54 -0
- package/dist/test/constants.d.ts +12 -0
- package/dist/types.d.ts +17 -3
- package/dist/utils/contract.d.ts +14 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/merkle.d.ts +22 -0
- package/dist/v2-sdk.cjs.development.js +5066 -669
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +5065 -670
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +11 -2
- package/src/abi/IAaveIncentivesController.json +50 -0
- package/src/abi/IBalancerMerkleOrchard.json +353 -0
- package/src/abi/IBalancertV2Vault.json +938 -0
- package/src/abi/ILendingPool.json +807 -0
- package/src/config.ts +26 -3
- package/src/entities/dhedge.ts +7 -3
- package/src/entities/pool.ts +360 -35
- package/src/entities/utils.ts +201 -1
- package/src/services/claim-balancer/MultiTokenClaim.json +115 -0
- package/src/services/claim-balancer/claim.service.ts +324 -0
- package/src/services/claim-balancer/claim.worker.ts +32 -0
- package/src/services/claim-balancer/ipfs.service.ts +12 -0
- package/src/services/claim-balancer/types.ts +66 -0
- package/src/test/aave.test.ts +73 -0
- package/src/test/balancer.test.ts +109 -0
- package/src/test/constants.ts +13 -0
- package/src/test/dhedge.test.ts +20 -8
- package/src/test/oneInch.test.ts +56 -0
- package/src/test/pool.test.ts +11 -168
- package/src/test/sushi.test.ts +173 -0
- package/src/test/utils.test.ts +43 -17
- package/src/types.ts +18 -3
- package/src/utils/contract.ts +95 -0
- package/src/utils/index.ts +38 -0
- package/src/utils/merkle.ts +172 -0
package/README.md
CHANGED
|
@@ -117,6 +117,15 @@ const usdcDepositAmount = "100000"
|
|
|
117
117
|
const tx = await pool.deposit("USDC_TOKEN_ADDRESS", usdcDepositAmount);
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
### Withdraw from pool
|
|
121
|
+
|
|
122
|
+
Withdraw 1.00002975 pool tokens. Note that this cannot be called if set as Trader account
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
const poolTokensWithdrawAmount = "1000029750000000000"
|
|
126
|
+
const tx = await pool.withdraw(poolTokensWithdrawAmount);
|
|
127
|
+
```
|
|
128
|
+
|
|
120
129
|
### Approve pool asset for trading & staking
|
|
121
130
|
|
|
122
131
|
Before trading an asset on platforms like Sushiswap it needs to be approved.
|
|
@@ -133,17 +142,17 @@ const tx = await pool.approve(
|
|
|
133
142
|
|
|
134
143
|
### Trade pool assets
|
|
135
144
|
|
|
136
|
-
Trade 1 USDC into DAI on Sushiswap
|
|
145
|
+
Trade 1 USDC into DAI on Sushiswap (other options: QUICKSWAP, BALANCER, or ONEINCH)
|
|
137
146
|
|
|
138
147
|
```
|
|
139
148
|
const amountIn = "1000000"
|
|
140
|
-
const
|
|
149
|
+
const slippage = 0.5
|
|
141
150
|
const tx = await pool.trade(
|
|
142
151
|
Dapp.SUSHISWAP,
|
|
143
152
|
"USDC_TOKEN_ADDRESS",
|
|
144
153
|
"DAI_TOKEN_ADDRESS",
|
|
145
154
|
amountIn,
|
|
146
|
-
|
|
155
|
+
slippage
|
|
147
156
|
)
|
|
148
157
|
```
|
|
149
158
|
|
|
@@ -175,6 +184,28 @@ const tx = await pool.removeLiquidity(
|
|
|
175
184
|
)
|
|
176
185
|
```
|
|
177
186
|
|
|
187
|
+
Add 0.00002 WBTC, 1 USDC and 0.0002 WETH to a WBTC/USDC/WETH Balancer pool
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
const balancerPoolId = "0x03cd191f589d12b0582a99808cf19851e468e6b500010000000000000000000a"
|
|
191
|
+
const assets = [WBTC_TOKEN_ADDRESS, USDC_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS];
|
|
192
|
+
const amounts = ["2000", "1000000", "200000000000000"];
|
|
193
|
+
const tx = await pool.joinBalancerPool(balancerPoolId, assets, amounts)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Remove all tokens from WBTC/USDC/WETH Balancer pool
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
const amount = await dhedge.utils.getBalance(BALANCER_LP_TOKEN_ADDRESS, pool.address)
|
|
200
|
+
const tx = await pool.exitBalancerPool(balancerPoolId, assets, amount)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Harvest rewards from Balancer
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
const tx = await pool.harvestBalancerRewards()
|
|
207
|
+
```
|
|
208
|
+
|
|
178
209
|
### Staking
|
|
179
210
|
|
|
180
211
|
Approve unlimited amound of SLP USDC-DAI token for staking on Sushiswap
|
|
@@ -217,3 +248,38 @@ const tx = await pool.harvestRewards(
|
|
|
217
248
|
"SLP_USDC_DAI_TOKEN_ADDRESS"
|
|
218
249
|
)
|
|
219
250
|
```
|
|
251
|
+
|
|
252
|
+
### Lending/Borrowing Aave
|
|
253
|
+
|
|
254
|
+
Deposit 1 USDC into Aave lending pool
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
const tx = await pool.lend(Dapp.AAVE, USDC_TOKEN_ADDRESS, "1000000")
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Withdraw 1 USDC from Aave lending pool
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
const tx = await pool.withdrawDeposit(Dapp.AAVE, USDC_TOKEN_ADDRESS, "1000000")
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Borrow 0.0001 WETH from Aave lending pool
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
const tx = await pool.borrow(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Repay 0.0001 WETH to Aave lending pool
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
const tx = await pool.repay(Dapp.AAVE, WETH_TOKEN_ADDRESS, "100000000000000");
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Harvest rewards from Aave
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
const tx = await pool.harvestAaveRewards([
|
|
282
|
+
AAVE_USDC_ADDRESS,
|
|
283
|
+
AAVE_WETH_DEBT_ADDRESS
|
|
284
|
+
]);
|
|
285
|
+
```
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AddressNetworkMap, AddressDappNetworkMap } from "./types";
|
|
2
|
+
import { NetworkChainIdMap } from ".";
|
|
2
3
|
export declare const factoryAddress: AddressNetworkMap;
|
|
3
4
|
export declare const routerAddress: AddressDappNetworkMap;
|
|
4
5
|
export declare const dappFactoryAddress: AddressDappNetworkMap;
|
|
5
6
|
export declare const stakingAddress: AddressDappNetworkMap;
|
|
7
|
+
export declare const networkChainIdMap: NetworkChainIdMap;
|
|
8
|
+
export declare const balancerSubgraph: AddressNetworkMap;
|
|
9
|
+
export declare const multiCallAddress: AddressNetworkMap;
|
|
@@ -16,9 +16,10 @@ export declare class Dhedge {
|
|
|
16
16
|
* @param {string} symbol Token symbol
|
|
17
17
|
* @param {tuple[]} supportedAssets Enabled assets to trade
|
|
18
18
|
* @param {number|BigNumber} managerFeeNumerator Manger fee in percent
|
|
19
|
+
* @param {any} options Transaction options
|
|
19
20
|
* @returns {Pool} Created Pool
|
|
20
21
|
*/
|
|
21
|
-
createPool(managerName: string, poolName: string, symbol: string, supportedAssets: SupportedAsset[], managerFeeNumerator?: number): Promise<Pool>;
|
|
22
|
+
createPool(managerName: string, poolName: string, symbol: string, supportedAssets: SupportedAsset[], managerFeeNumerator?: number, options?: any): Promise<Pool>;
|
|
22
23
|
/**
|
|
23
24
|
* Load a pool based on the provided address
|
|
24
25
|
* @param {string} address Pool address
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -18,38 +18,43 @@ export declare class Pool {
|
|
|
18
18
|
* Approve the asset that can be deposited into a pool
|
|
19
19
|
* @param {string} nasset Address of deposit asset
|
|
20
20
|
* @param {BigNumber | string} amount Amount to be approved
|
|
21
|
+
* @param {any} options Transaction options
|
|
21
22
|
* @returns {Promise<any>} Transaction
|
|
22
23
|
*/
|
|
23
|
-
approveDeposit(asset: string, amount: BigNumber | string): Promise<any>;
|
|
24
|
+
approveDeposit(asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
24
25
|
/**
|
|
25
26
|
* Deposit asset into a pool
|
|
26
27
|
* @param {string} asset Address of asset
|
|
27
28
|
* @param {BigNumber | string} amount Amount to be deposited
|
|
29
|
+
* @param {any} options Transaction options
|
|
28
30
|
* @returns {Promise<any>} Transaction
|
|
29
31
|
*/
|
|
30
|
-
deposit(asset: string, amount: string | BigNumber): Promise<any>;
|
|
32
|
+
deposit(asset: string, amount: string | BigNumber, options?: any): Promise<any>;
|
|
31
33
|
/**
|
|
32
34
|
* Withdraw assets from a pool
|
|
33
35
|
* @param fundTokenAmount Amount of pool tokens to be withdrawn
|
|
36
|
+
* @param {any} options Transaction options
|
|
34
37
|
* @returns {Promise<any>} Transaction
|
|
35
38
|
*/
|
|
36
|
-
withdraw(fundTokenAmount: string | BigNumber): Promise<any>;
|
|
39
|
+
withdraw(fundTokenAmount: string | BigNumber, options?: any): Promise<any>;
|
|
37
40
|
/**
|
|
38
41
|
* Approve the asset for trading and providing liquidity
|
|
39
42
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
40
43
|
* @param {string} asset Address of asset
|
|
41
44
|
* @param @param {BigNumber | string} Amount to be approved
|
|
45
|
+
* @param {any} options Transaction options
|
|
42
46
|
* @returns {Promise<any>} Transaction
|
|
43
47
|
*/
|
|
44
|
-
approve(dapp: Dapp, asset: string, amount: BigNumber | string): Promise<any>;
|
|
48
|
+
approve(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
45
49
|
/**
|
|
46
50
|
* Approve the liquidity pool token for staking
|
|
47
51
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
48
52
|
* @param {string} asset Address of liquidity pool token
|
|
49
53
|
* @param {BigNumber | string} amount Aamount to be approved
|
|
54
|
+
* @param {any} options Transaction options
|
|
50
55
|
* @returns {Promise<any>} Transaction
|
|
51
56
|
*/
|
|
52
|
-
approveStaking(dapp: Dapp, asset: string, amount: BigNumber | string): Promise<any>;
|
|
57
|
+
approveStaking(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
53
58
|
/**
|
|
54
59
|
* Trade an asset into another asset
|
|
55
60
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
@@ -57,9 +62,10 @@ export declare class Pool {
|
|
|
57
62
|
* @param {string} assetTo Asset to trade into
|
|
58
63
|
* @param {BigNumber | string} amountIn Amount
|
|
59
64
|
* @param {BigNumber | string} minAmountOut Minumum amount to receive
|
|
65
|
+
* @param {any} options Transaction options
|
|
60
66
|
* @returns {Promise<any>} Transaction
|
|
61
67
|
*/
|
|
62
|
-
trade(dapp: Dapp, assetFrom: string, assetTo: string, amountIn: BigNumber | string,
|
|
68
|
+
trade(dapp: Dapp, assetFrom: string, assetTo: string, amountIn: BigNumber | string, slippage?: number, options?: any): Promise<any>;
|
|
63
69
|
/**
|
|
64
70
|
* Add liquidity to a liquidity pool
|
|
65
71
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
@@ -67,51 +73,126 @@ export declare class Pool {
|
|
|
67
73
|
* @param {string} assetB Second asset
|
|
68
74
|
* @param {BigNumber | string} amountA Amount first asset
|
|
69
75
|
* @param {BigNumber | string} amountB Amount second asset
|
|
76
|
+
* @param {any} options Transaction options
|
|
70
77
|
* @returns {Promise<any>} Transaction
|
|
71
78
|
*/
|
|
72
|
-
addLiquidity(dapp: Dapp, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string): Promise<any>;
|
|
79
|
+
addLiquidity(dapp: Dapp, assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, options?: any): Promise<any>;
|
|
73
80
|
/**
|
|
74
81
|
* Remove liquidity from a liquidity pool
|
|
75
82
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
76
83
|
* @param {string} assetA First asset
|
|
77
84
|
* @param {string} assetB Second asset
|
|
78
85
|
* @param {BigNumber | string} amount Amount of liquidity pool tokens
|
|
86
|
+
* @param {any} options Transaction options
|
|
79
87
|
* @returns {Promise<any>} Transaction
|
|
80
88
|
*/
|
|
81
|
-
removeLiquidity(dapp: Dapp, assetA: string, assetB: string, amount: string | BigNumber): Promise<any>;
|
|
89
|
+
removeLiquidity(dapp: Dapp, assetA: string, assetB: string, amount: string | BigNumber, options?: any): Promise<any>;
|
|
82
90
|
/**
|
|
83
91
|
* Stake liquidity pool tokens in a yield farm
|
|
84
92
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
85
93
|
* @param {string} asset Liquidity pool token
|
|
86
94
|
* @param {BigNumber | string} amount Amount of liquidity pool tokens
|
|
95
|
+
* @param {any} options Transaction options
|
|
87
96
|
* @returns {Promise<any>} Transaction
|
|
88
97
|
*/
|
|
89
|
-
stake(dapp: Dapp, asset: string, amount: BigNumber | string): Promise<any>;
|
|
98
|
+
stake(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
90
99
|
/**
|
|
91
100
|
* Unstake liquidity pool tokens from a yield farm
|
|
92
101
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
93
102
|
* @param {string} asset Liquidity pool token
|
|
94
103
|
* @param {BigNumber | string} amount Amount of liquidity pool tokens
|
|
104
|
+
* @param {any} options Transaction options
|
|
95
105
|
* @returns {Promise<any>} Transaction
|
|
96
106
|
*/
|
|
97
|
-
unStake(dapp: Dapp, asset: string, amount: BigNumber | string): Promise<any>;
|
|
107
|
+
unStake(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* Lend asset to a lending pool
|
|
110
|
+
* @param {Dapp} dapp Platform like Aave
|
|
111
|
+
* @param {string} asset Asset
|
|
112
|
+
* @param {BigNumber | string} amount Amount of asset to lend
|
|
113
|
+
* @param {any} options Transaction options
|
|
114
|
+
* @returns {Promise<any>} Transaction
|
|
115
|
+
*/
|
|
116
|
+
lend(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
117
|
+
/**
|
|
118
|
+
* Witdraw asset from a lending pool
|
|
119
|
+
* @param {Dapp} dapp Platform like Aave
|
|
120
|
+
* @param {string} asset Asset
|
|
121
|
+
* @param {BigNumber | string} amount Amount of asset to lend
|
|
122
|
+
* @param {any} options Transaction options
|
|
123
|
+
* @returns {Promise<any>} Transaction
|
|
124
|
+
*/
|
|
125
|
+
withdrawDeposit(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
126
|
+
/**
|
|
127
|
+
* Borrow asset from a lending pool
|
|
128
|
+
* @param {Dapp} dapp Platform like Aave
|
|
129
|
+
* @param {string} asset Asset
|
|
130
|
+
* @param {BigNumber | string} amount Amount of asset to lend
|
|
131
|
+
* @param {any} options Transaction options
|
|
132
|
+
* @returns {Promise<any>} Transaction
|
|
133
|
+
*/
|
|
134
|
+
borrow(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
* Repays borrowed asset to a lending pool
|
|
137
|
+
* @param {Dapp} dapp Platform like Aave
|
|
138
|
+
* @param {string} asset Asset
|
|
139
|
+
* @param {BigNumber | string} amount Amount of asset to lend
|
|
140
|
+
* @param {any} options Transaction options
|
|
141
|
+
* @returns {Promise<any>} Transaction
|
|
142
|
+
*/
|
|
143
|
+
repay(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
98
144
|
/**
|
|
99
145
|
* Claim rewards of staked liquidity pool tokens
|
|
100
146
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
101
147
|
* @param {string} asset Liquidity pool token
|
|
148
|
+
* @param {any} options Transaction options
|
|
102
149
|
* @returns {Promise<any>} Transaction
|
|
103
150
|
*/
|
|
104
|
-
harvestRewards(dapp: Dapp, asset: string): Promise<any>;
|
|
151
|
+
harvestRewards(dapp: Dapp, asset: string, options?: any): Promise<any>;
|
|
105
152
|
/**
|
|
106
153
|
* Change enabled pool assets
|
|
107
154
|
* @param {AssetEnabled[]} assets New pool assets
|
|
155
|
+
* @param {any} options Transaction options
|
|
108
156
|
* @returns {Promise<any>} Transaction
|
|
109
157
|
*/
|
|
110
|
-
changeAssets(assets: AssetEnabled[]): Promise<any>;
|
|
158
|
+
changeAssets(assets: AssetEnabled[], options?: any): Promise<any>;
|
|
111
159
|
/**
|
|
112
160
|
* Set a new trader with trading permissions
|
|
113
161
|
* @param {string} trader Address trader account
|
|
162
|
+
* @param {any} options Transaction options
|
|
163
|
+
* @returns {Promise<any>} Transaction
|
|
164
|
+
*/
|
|
165
|
+
setTrader(trader: string, options?: any): Promise<any>;
|
|
166
|
+
/**
|
|
167
|
+
* Invest into a Balancer pool
|
|
168
|
+
* @param {string} poolId Balancer pool id
|
|
169
|
+
* @param {string[] | } assetsIn Array of balancer pool assets
|
|
170
|
+
* @param {BigNumber[] | string[]} amountsIn Array of maximum amounts to provide to pool
|
|
171
|
+
* @param {any} options Transaction options
|
|
172
|
+
* @returns {Promise<any>} Transaction
|
|
173
|
+
*/
|
|
174
|
+
joinBalancerPool(poolId: string, assets: string[], amountsIn: string[] | BigNumber[], options?: any): Promise<any>;
|
|
175
|
+
/**
|
|
176
|
+
* Invest into a Balancer pool
|
|
177
|
+
* @param {string} poolId Balancer pool id
|
|
178
|
+
* @param {string[] | } assets Array of balancer pool assets
|
|
179
|
+
* @param {BigNumber | string } amount Amount of pool tokens to withdraw
|
|
180
|
+
* @param {any} options Transaction options
|
|
181
|
+
* @returns {Promise<any>} Transaction
|
|
182
|
+
*/
|
|
183
|
+
exitBalancerPool(poolId: string, assets: string[], amount: string | BigNumber, options?: any): Promise<any>;
|
|
184
|
+
/**
|
|
185
|
+
* Claim rewards from Balancer pools
|
|
186
|
+
* @param {string[]} assets Array of tokens being claimed
|
|
187
|
+
* @param {any} options Transaction options
|
|
188
|
+
* @returns {Promise<any>} Transaction
|
|
189
|
+
*/
|
|
190
|
+
harvestBalancerRewards(options?: any): Promise<any>;
|
|
191
|
+
/**
|
|
192
|
+
* Claim rewards from Aave platform
|
|
193
|
+
* @param {string[]} assets Aave tokens (deposit/debt) hold by pool
|
|
194
|
+
* @param {any} options Transaction options
|
|
114
195
|
* @returns {Promise<any>} Transaction
|
|
115
196
|
*/
|
|
116
|
-
|
|
197
|
+
harvestAaveRewards(assets: string[], options?: any): Promise<any>;
|
|
117
198
|
}
|
package/dist/entities/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers, Wallet } from "ethers";
|
|
2
2
|
import { Dapp, Network, Reserves } from "../types";
|
|
3
|
+
import { Pool } from ".";
|
|
3
4
|
export declare class Utils {
|
|
4
5
|
network: Network;
|
|
5
6
|
signer: Wallet;
|
|
@@ -29,4 +30,18 @@ export declare class Utils {
|
|
|
29
30
|
* @returns { BigNumber } Balance of asset
|
|
30
31
|
*/
|
|
31
32
|
getBalance(asset: string, owner: string): Promise<ethers.BigNumber>;
|
|
33
|
+
/**
|
|
34
|
+
* Return the minimum amount out for a trade between two assets
|
|
35
|
+
* given the trade amount and slippage
|
|
36
|
+
* @param {Dapp} dApp DApp like Uniswap or Sushiswap
|
|
37
|
+
* @param {string} assetFrom Asset to trade from
|
|
38
|
+
* @param {string} assetTo Asset to trade into
|
|
39
|
+
* @param {string | ethers.BigNumber} amountIn Trade amount
|
|
40
|
+
* @param { number} slippage Maximum slippage allowed
|
|
41
|
+
* @returns {Promise<ethers.BigNumber>} Reserves of the assets in BigNumber
|
|
42
|
+
*/
|
|
43
|
+
getMinAmountOut(dapp: Dapp, assetFrom: string, assetTo: string, amountIn: string | ethers.BigNumber, slippage: number): Promise<ethers.BigNumber>;
|
|
44
|
+
getBalancerSwapTx(pool: Pool, assetFrom: string, assetTo: string, amountIn: ethers.BigNumber | string, slippage: number): Promise<any>;
|
|
45
|
+
getBalancerJoinPoolTx(pool: Pool, balancerPoolId: string, assets: string[], amountsIn: string[] | ethers.BigNumber[]): Promise<any>;
|
|
46
|
+
getBalancerExitPoolTx(pool: Pool, balancerPoolId: string, assets: string[], amount: string | ethers.BigNumber): Promise<any>;
|
|
32
47
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ethers, Wallet } from "ethers";
|
|
2
|
+
import { MultiTokenCurrentRewardsEstimate, MultiTokenPendingClaims, TokenClaimInfo } from "./types";
|
|
3
|
+
import { Network } from "../../types";
|
|
4
|
+
export declare class ClaimService {
|
|
5
|
+
network: Network;
|
|
6
|
+
signer: ethers.Wallet;
|
|
7
|
+
constructor(network: Network, signer: Wallet);
|
|
8
|
+
getMultiTokensPendingClaims(account: string): Promise<MultiTokenPendingClaims[]>;
|
|
9
|
+
getTokenPendingClaims(tokenClaimInfo: TokenClaimInfo, account: string): Promise<MultiTokenPendingClaims>;
|
|
10
|
+
getMultiTokensCurrentRewardsEstimate(account: string): Promise<{
|
|
11
|
+
data: MultiTokenCurrentRewardsEstimate[];
|
|
12
|
+
timestamp: string | null;
|
|
13
|
+
}>;
|
|
14
|
+
multiTokenClaimRewards(account: string, multiTokenPendingClaims: MultiTokenPendingClaims[]): Promise<any>;
|
|
15
|
+
private computeClaimProofs;
|
|
16
|
+
private computeClaimProof;
|
|
17
|
+
private getTokenClaimsInfo;
|
|
18
|
+
private getSnapshot;
|
|
19
|
+
private getClaimStatus;
|
|
20
|
+
private getReports;
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface Claim {
|
|
2
|
+
id: string;
|
|
3
|
+
amount: string;
|
|
4
|
+
}
|
|
5
|
+
export declare type Snapshot = Record<number, string>;
|
|
6
|
+
export declare type TokenClaimInfo = {
|
|
7
|
+
label: string;
|
|
8
|
+
distributor: string;
|
|
9
|
+
token: string;
|
|
10
|
+
decimals: number;
|
|
11
|
+
manifest: string;
|
|
12
|
+
weekStart: number;
|
|
13
|
+
};
|
|
14
|
+
export declare type MultiTokenPendingClaims = {
|
|
15
|
+
claims: Claim[];
|
|
16
|
+
reports: Report;
|
|
17
|
+
tokenClaimInfo: TokenClaimInfo;
|
|
18
|
+
availableToClaim: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type ClaimStatus = boolean;
|
|
21
|
+
export declare type Report = Record<string, any>;
|
|
22
|
+
export declare type MultiTokenCurrentRewardsEstimateResponse = {
|
|
23
|
+
success: boolean;
|
|
24
|
+
result: {
|
|
25
|
+
current_timestamp: string;
|
|
26
|
+
"liquidity-providers": Array<{
|
|
27
|
+
snapshot_timestamp: string;
|
|
28
|
+
address: string;
|
|
29
|
+
token_address: string;
|
|
30
|
+
chain_id: number;
|
|
31
|
+
current_estimate: string;
|
|
32
|
+
velocity: string;
|
|
33
|
+
week: number;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare type MultiTokenCurrentRewardsEstimate = {
|
|
38
|
+
rewards: string;
|
|
39
|
+
velocity: string;
|
|
40
|
+
token: string;
|
|
41
|
+
};
|
|
42
|
+
export declare type ClaimProofTuple = [number, string, string, number, string[]];
|
|
43
|
+
export declare type ComputeClaimProofPayload = {
|
|
44
|
+
report: Report;
|
|
45
|
+
account: string;
|
|
46
|
+
claim: Claim;
|
|
47
|
+
distributor: string;
|
|
48
|
+
tokenIndex: number;
|
|
49
|
+
decimals: number;
|
|
50
|
+
};
|
|
51
|
+
export declare type ClaimWorkerMessage<P = any> = {
|
|
52
|
+
type: "computeClaimProof";
|
|
53
|
+
payload: P;
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
2
|
+
export declare const USDT = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
3
|
+
export declare const DAI = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
|
|
4
|
+
export declare const TUSD = "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756";
|
|
5
|
+
export declare const WETH = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
6
|
+
export declare const WBTC = "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6";
|
|
7
|
+
export declare const SUSHI = "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a";
|
|
8
|
+
export declare const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
|
|
9
|
+
export declare const BAL = "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3";
|
|
10
|
+
export declare const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
|
|
11
|
+
export declare const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
|
|
12
|
+
export declare const TEST_POOL = "0x3deeba9ca29e2dd98d32eed8dd559dac55014615";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
+
import { ChainId } from "@sushiswap/sdk";
|
|
1
2
|
import { BigNumber } from "ethers";
|
|
2
3
|
export declare enum Network {
|
|
3
4
|
POLYGON = "polygon"
|
|
4
5
|
}
|
|
5
6
|
export declare enum Dapp {
|
|
6
|
-
SUSHISWAP = "sushiswap"
|
|
7
|
+
SUSHISWAP = "sushiswap",
|
|
8
|
+
AAVE = "aave",
|
|
9
|
+
ONEINCH = "1inch",
|
|
10
|
+
QUICKSWAP = "quickswap",
|
|
11
|
+
BALANCER = "balancer"
|
|
7
12
|
}
|
|
8
13
|
export declare enum Transaction {
|
|
9
14
|
SWAP = "swapExactTokensForTokens",
|
|
10
15
|
ADD_LIQUIDITY = "addLiquidity",
|
|
11
16
|
DEPOSIT = "deposit",
|
|
12
17
|
HARVEST = "harvest",
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
CLAIM_DISTRIBIUTIONS = "claimDistributions",
|
|
19
|
+
CLAIM_REWARDS = "claimRewards",
|
|
20
|
+
REMOVE_LIQUIDITY = "removeLiquidity",
|
|
21
|
+
BORROW = "borrow",
|
|
22
|
+
REPAY = "repay",
|
|
23
|
+
WITHDRAW = "withdraw"
|
|
15
24
|
}
|
|
16
25
|
export declare type AddressNetworkMap = Readonly<Record<Network, string>>;
|
|
17
26
|
export declare type AddressDappMap = {
|
|
18
27
|
[Dapp.SUSHISWAP]?: string;
|
|
28
|
+
[Dapp.AAVE]?: string;
|
|
29
|
+
[Dapp.ONEINCH]?: string;
|
|
30
|
+
[Dapp.QUICKSWAP]?: string;
|
|
31
|
+
[Dapp.BALANCER]?: string;
|
|
19
32
|
};
|
|
20
33
|
export declare type AddressDappNetworkMap = Readonly<Record<Network, AddressDappMap>>;
|
|
21
34
|
export declare type SupportedAsset = [string, boolean];
|
|
@@ -33,3 +46,4 @@ export declare type Reserves = {
|
|
|
33
46
|
assetA: BigNumber;
|
|
34
47
|
assetB: BigNumber;
|
|
35
48
|
};
|
|
49
|
+
export declare type NetworkChainIdMap = Readonly<Record<Network, ChainId>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ethers, Network } from "..";
|
|
2
|
+
export declare function call(provider: ethers.Signer, abi: any[], call: any[], options?: any): Promise<any>;
|
|
3
|
+
export declare function multicall<T>(network: Network, provider: ethers.Signer, abi: any[], calls: any[], options?: any, requireSuccess?: boolean): Promise<(T | null)[]>;
|
|
4
|
+
export declare class Multicaller {
|
|
5
|
+
network: Network;
|
|
6
|
+
provider: ethers.Signer;
|
|
7
|
+
abi: any[];
|
|
8
|
+
options: any;
|
|
9
|
+
calls: any[];
|
|
10
|
+
paths: any[];
|
|
11
|
+
constructor(network: Network, provider: ethers.Signer, abi: any[]);
|
|
12
|
+
call(path: any, address: any, fn: any, params?: any): Multicaller;
|
|
13
|
+
execute(from?: any): Promise<any>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { MerkleTree } from "./merkle";
|
|
3
|
+
export declare function scale(input: BigNumber | string, decimalPlaces: number): BigNumber;
|
|
4
|
+
export declare function loadTree(balances: {
|
|
5
|
+
[x: string]: string | BigNumber;
|
|
6
|
+
}, decimals?: number): MerkleTree;
|
|
7
|
+
export declare function bnum(val: string | number | BigNumber): BigNumber;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
export declare class MerkleTree {
|
|
4
|
+
elements: any;
|
|
5
|
+
layers: any;
|
|
6
|
+
constructor(elements: any[]);
|
|
7
|
+
getLayers(elements: string | any[]): (string | any[])[];
|
|
8
|
+
getNextLayer(elements: any[]): any[];
|
|
9
|
+
combinedHash(first: any, second: any): any;
|
|
10
|
+
getRoot(): any;
|
|
11
|
+
getHexRoot(): string;
|
|
12
|
+
getProof(el: any): any;
|
|
13
|
+
getHexProof(_el: any): string[];
|
|
14
|
+
getPairElement(idx: number, layer: string | any[]): any;
|
|
15
|
+
bufIndexOf(el: string | any[], arr: string | any[]): number;
|
|
16
|
+
bufDedup(elements: any[]): any[];
|
|
17
|
+
bufArrToHexArr(arr: any[]): string[];
|
|
18
|
+
sortAndConcat(...args: any[]): Buffer;
|
|
19
|
+
}
|
|
20
|
+
export declare function loadTree(balances: {
|
|
21
|
+
[x: string]: string | BigNumber;
|
|
22
|
+
}, decimals?: number): MerkleTree;
|