@dhedge/v2-sdk 1.2.0 → 1.4.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/dist/config.d.ts +5 -0
- package/dist/entities/pool.d.ts +72 -5
- package/dist/entities/utils.d.ts +6 -0
- package/dist/services/claim-balancer/claim.service.d.ts +1 -5
- package/dist/services/uniswap/V3Liquidity.d.ts +9 -0
- package/dist/services/uniswap/V3Trade.d.ts +4 -0
- package/dist/services/uniswap/types.d.ts +3 -0
- package/dist/test/constants.d.ts +3 -2
- package/dist/test/txOptions.d.ts +1 -0
- package/dist/types.d.ts +19 -10
- package/dist/v2-sdk.cjs.development.js +4172 -1593
- 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 +4175 -1596
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +4 -1
- package/src/abi/IArrakisV1RouterStaking.json +107 -0
- package/src/abi/IERC20.json +15 -1
- package/src/abi/ILiquidityGaugeV4.json +153 -0
- package/src/abi/INonfungiblePositionManager.json +1221 -0
- package/src/abi/ISynthetix.json +139 -0
- package/src/abi/IUniswapV3Quoter.json +195 -0
- package/src/abi/IUniswapV3Router.json +221 -0
- package/src/config.ts +40 -9
- package/src/entities/dhedge.ts +4 -2
- package/src/entities/pool.ts +316 -30
- package/src/entities/utils.ts +12 -0
- package/src/services/claim-balancer/claim.service.ts +14 -76
- package/src/services/uniswap/V3Liquidity.ts +134 -0
- package/src/services/uniswap/V3Trade.ts +47 -0
- package/src/services/uniswap/types.ts +16 -0
- package/src/test/aave.test.ts +53 -25
- package/src/test/arrakis.test.ts +89 -0
- package/src/test/constants.ts +10 -2
- package/src/test/oneInch.test.ts +13 -20
- package/src/test/synthetix.test.ts +34 -0
- package/src/test/txOptions.ts +15 -0
- package/src/test/uniswap.test.ts +125 -0
- package/src/test/wallet.ts +4 -0
- package/src/types.ts +19 -10
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export declare const factoryAddress: AddressNetworkMap;
|
|
|
4
4
|
export declare const routerAddress: AddressDappNetworkMap;
|
|
5
5
|
export declare const dappFactoryAddress: AddressDappNetworkMap;
|
|
6
6
|
export declare const stakingAddress: AddressDappNetworkMap;
|
|
7
|
+
export declare const nonfungiblePositionManagerAddress: AddressNetworkMap;
|
|
7
8
|
export declare const networkChainIdMap: NetworkChainIdMap;
|
|
8
9
|
export declare const balancerSubgraph: AddressNetworkMap;
|
|
9
10
|
export declare const multiCallAddress: AddressNetworkMap;
|
|
11
|
+
export declare const deadline: number;
|
|
12
|
+
export declare const MaxUint128 = "0xffffffffffffffffffffffffffffffff";
|
|
13
|
+
export declare const UNISWAPV3_QUOTER_ADDRESS = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";
|
|
14
|
+
export declare const SYNTHETIX_TRACKING_CODE = "0x4448454447450000000000000000000000000000000000000000000000000000";
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Contract, Wallet, BigNumber } from "ethers";
|
|
2
2
|
import { Dapp, FundComposition, AssetEnabled, Network } from "../types";
|
|
3
3
|
import { Utils } from "./utils";
|
|
4
|
+
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
4
5
|
export declare class Pool {
|
|
5
6
|
readonly poolLogic: Contract;
|
|
6
7
|
readonly managerLogic: Contract;
|
|
8
|
+
readonly factory: Contract;
|
|
7
9
|
readonly signer: Wallet;
|
|
8
10
|
readonly address: string;
|
|
9
11
|
readonly utils: Utils;
|
|
10
12
|
readonly network: Network;
|
|
11
|
-
constructor(network: Network, signer: Wallet, poolLogic: Contract, mangerLogic: Contract, utils: Utils);
|
|
13
|
+
constructor(network: Network, signer: Wallet, poolLogic: Contract, mangerLogic: Contract, utils: Utils, factory: Contract);
|
|
12
14
|
/**
|
|
13
15
|
* Return the assets with balances and deposit info of a pool
|
|
14
16
|
* @returns {Promise<FundComposition[]>} Composition of assets with balance, deposit info
|
|
@@ -55,13 +57,22 @@ export declare class Pool {
|
|
|
55
57
|
* @returns {Promise<any>} Transaction
|
|
56
58
|
*/
|
|
57
59
|
approveStaking(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Approve the liquidity pool token for staking
|
|
62
|
+
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
63
|
+
* @param {string} asset Address of liquidity pool token
|
|
64
|
+
* @param {BigNumber | string} amount Aamount to be approved
|
|
65
|
+
* @param {any} options Transaction options
|
|
66
|
+
* @returns {Promise<any>} Transaction
|
|
67
|
+
*/
|
|
68
|
+
approveUniswapV3Liquidity(asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
58
69
|
/**
|
|
59
70
|
* Trade an asset into another asset
|
|
60
71
|
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
61
72
|
* @param {string} assetFrom Asset to trade from
|
|
62
73
|
* @param {string} assetTo Asset to trade into
|
|
63
74
|
* @param {BigNumber | string} amountIn Amount
|
|
64
|
-
* @param {
|
|
75
|
+
* @param {number} slippage Slippage tolerance in %
|
|
65
76
|
* @param {any} options Transaction options
|
|
66
77
|
* @returns {Promise<any>} Transaction
|
|
67
78
|
*/
|
|
@@ -109,11 +120,12 @@ export declare class Pool {
|
|
|
109
120
|
* Lend asset to a lending pool
|
|
110
121
|
* @param {Dapp} dapp Platform like Aave
|
|
111
122
|
* @param {string} asset Asset
|
|
112
|
-
* @param
|
|
123
|
+
* @param {BigNumber | string} amount Amount of asset to lend
|
|
124
|
+
* @param {number} referrralCode Code from Aave referral program
|
|
113
125
|
* @param {any} options Transaction options
|
|
114
126
|
* @returns {Promise<any>} Transaction
|
|
115
127
|
*/
|
|
116
|
-
lend(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
128
|
+
lend(dapp: Dapp, asset: string, amount: BigNumber | string, referrralCode?: number, options?: any): Promise<any>;
|
|
117
129
|
/**
|
|
118
130
|
* Witdraw asset from a lending pool
|
|
119
131
|
* @param {Dapp} dapp Platform like Aave
|
|
@@ -128,10 +140,11 @@ export declare class Pool {
|
|
|
128
140
|
* @param {Dapp} dapp Platform like Aave
|
|
129
141
|
* @param {string} asset Asset
|
|
130
142
|
* @param {BigNumber | string} amount Amount of asset to lend
|
|
143
|
+
* @param {number} referrralCode Code from Aave referral program
|
|
131
144
|
* @param {any} options Transaction options
|
|
132
145
|
* @returns {Promise<any>} Transaction
|
|
133
146
|
*/
|
|
134
|
-
borrow(dapp: Dapp, asset: string, amount: BigNumber | string, options?: any): Promise<any>;
|
|
147
|
+
borrow(dapp: Dapp, asset: string, amount: BigNumber | string, referrralCode?: number, options?: any): Promise<any>;
|
|
135
148
|
/**
|
|
136
149
|
* Repays borrowed asset to a lending pool
|
|
137
150
|
* @param {Dapp} dapp Platform like Aave
|
|
@@ -195,4 +208,58 @@ export declare class Pool {
|
|
|
195
208
|
* @returns {Promise<any>} Transaction
|
|
196
209
|
*/
|
|
197
210
|
harvestAaveRewards(assets: string[], options?: any): Promise<any>;
|
|
211
|
+
/**
|
|
212
|
+
* Create UniswapV3 liquidity pool
|
|
213
|
+
* @param {string} assetA First asset
|
|
214
|
+
* @param {string} assetB Second asset
|
|
215
|
+
* @param {BigNumber | string} amountA Amount first asset
|
|
216
|
+
* @param {BigNumber | string} amountB Amount second asset
|
|
217
|
+
* @param { number } minPrice Lower price range (assetB per assetA)
|
|
218
|
+
* @param { number } maxPrice Upper price range (assetB per assetA)
|
|
219
|
+
* @param { number } minTick Lower tick range
|
|
220
|
+
* @param { number } maxTick Upper tick range
|
|
221
|
+
* @param { FeeAmount } feeAmount Fee tier (Low 0.05%, Medium 0.3%, High 1%)
|
|
222
|
+
* @param {any} options Transaction options
|
|
223
|
+
* @returns {Promise<any>} Transaction
|
|
224
|
+
*/
|
|
225
|
+
addLiquidityUniswapV3(assetA: string, assetB: string, amountA: BigNumber | string, amountB: BigNumber | string, minPrice: number | null, maxPrice: number | null, minTick: number | null, maxTick: number | null, feeAmount: FeeAmount, options?: any): Promise<any>;
|
|
226
|
+
/**
|
|
227
|
+
* Remove liquidity from an UniswapV3 or Arrakis liquidity pool
|
|
228
|
+
* @param {Dapp} dapp Platform either UniswapV3 or Arrakis
|
|
229
|
+
* @param {string} tokenId Token Id of UniswapV3 position
|
|
230
|
+
* @param {number} amount Amount in percent of assets to be removed
|
|
231
|
+
* @param {any} options Transaction options
|
|
232
|
+
* @returns {Promise<any>} Transaction
|
|
233
|
+
*/
|
|
234
|
+
decreaseLiquidity(dapp: Dapp, tokenId: string, amount?: number, options?: any): Promise<any>;
|
|
235
|
+
/**
|
|
236
|
+
* Increase liquidity of an UniswapV3 or Arrakis liquidity pool
|
|
237
|
+
* @param {Dapp} dapp Platform either UniswapV3 or Arrakis
|
|
238
|
+
* @param {string} tokenId Token Id of UniswapV3 position
|
|
239
|
+
* @param {BigNumber | string} amountA Amount first asset
|
|
240
|
+
* @param {BigNumber | string} amountB Amount second asset
|
|
241
|
+
* @param {any} options Transaction options
|
|
242
|
+
* @returns {Promise<any>} Transaction
|
|
243
|
+
*/
|
|
244
|
+
increaseLiquidity(dapp: Dapp, tokenId: string, amountA: BigNumber | string, amountB: BigNumber | string, options?: any): Promise<any>;
|
|
245
|
+
/**
|
|
246
|
+
* Claim fees of an UniswapV3 liquidity or Arrakis pool
|
|
247
|
+
* @param {Dapp} dapp Platform either UniswapV3 or Arrakis
|
|
248
|
+
* @param {string} tokenId Token Id of UniswapV3 or Arrakis position
|
|
249
|
+
* @param {any} options Transaction options
|
|
250
|
+
* @returns {Promise<any>} Transaction
|
|
251
|
+
*/
|
|
252
|
+
claimFees(dapp: Dapp, tokenId: string, options?: any): Promise<any>;
|
|
253
|
+
/**
|
|
254
|
+
* Trade an asset into another asset
|
|
255
|
+
* @param {Dapp} dapp Platform like Sushiswap or Uniswap
|
|
256
|
+
* @param {string} assetFrom Asset to trade from
|
|
257
|
+
* @param {string} assetTo Asset to trade into
|
|
258
|
+
* @param {BigNumber | string} amountIn Amount
|
|
259
|
+
* @param { FeeAmount } feeAmount Fee tier (Low 0.05%, Medium 0.3%, High 1%)
|
|
260
|
+
* @param {number} slippage Slippage tolerance in %
|
|
261
|
+
* @param {any} options Transaction options
|
|
262
|
+
* @returns {Promise<any>} Transaction
|
|
263
|
+
*/
|
|
264
|
+
tradeUniswapV3(assetFrom: string, assetTo: string, amountIn: BigNumber | string, feeAmount: FeeAmount, slippage?: number, options?: any): Promise<any>;
|
|
198
265
|
}
|
package/dist/entities/utils.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export declare class Utils {
|
|
|
30
30
|
* @returns { BigNumber } Balance of asset
|
|
31
31
|
*/
|
|
32
32
|
getBalance(asset: string, owner: string): Promise<ethers.BigNumber>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the decimals of an asset (ERC20) token
|
|
35
|
+
* @param {string} asset string token address
|
|
36
|
+
* @returns { number } Balance of asset
|
|
37
|
+
*/
|
|
38
|
+
getDecimals(asset: string): Promise<number>;
|
|
33
39
|
/**
|
|
34
40
|
* Return the minimum amount out for a trade between two assets
|
|
35
41
|
* given the trade amount and slippage
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers, Wallet } from "ethers";
|
|
2
|
-
import {
|
|
2
|
+
import { MultiTokenPendingClaims, TokenClaimInfo } from "./types";
|
|
3
3
|
import { Network } from "../../types";
|
|
4
4
|
export declare class ClaimService {
|
|
5
5
|
network: Network;
|
|
@@ -7,10 +7,6 @@ export declare class ClaimService {
|
|
|
7
7
|
constructor(network: Network, signer: Wallet);
|
|
8
8
|
getMultiTokensPendingClaims(account: string): Promise<MultiTokenPendingClaims[]>;
|
|
9
9
|
getTokenPendingClaims(tokenClaimInfo: TokenClaimInfo, account: string): Promise<MultiTokenPendingClaims>;
|
|
10
|
-
getMultiTokensCurrentRewardsEstimate(account: string): Promise<{
|
|
11
|
-
data: MultiTokenCurrentRewardsEstimate[];
|
|
12
|
-
timestamp: string | null;
|
|
13
|
-
}>;
|
|
14
10
|
multiTokenClaimRewards(account: string, multiTokenPendingClaims: MultiTokenPendingClaims[]): Promise<any>;
|
|
15
11
|
private computeClaimProofs;
|
|
16
12
|
private computeClaimProof;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Price, Token } from "@uniswap/sdk-core";
|
|
2
|
+
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
import { Pool } from "../..";
|
|
5
|
+
import { UniswapV3MintParams } from "./types";
|
|
6
|
+
export declare function tryParsePrice(baseToken: Token, quoteToken: Token, value: string): Price<Token, Token>;
|
|
7
|
+
export declare function tryParseTick(baseToken: Token, quoteToken: Token, feeAmount: FeeAmount, value: string): number;
|
|
8
|
+
export declare function getUniswapV3MintParams(pool: Pool, assetA: string, assetB: string, amountA: string | ethers.BigNumber, amountB: string | ethers.BigNumber, minPrice: number | null, maxPrice: number | null, minTick: number | null, maxTick: number | null, feeAmount: FeeAmount): Promise<UniswapV3MintParams>;
|
|
9
|
+
export declare function getUniswapV3Liquidity(tokenId: string, pool: Pool): Promise<ethers.BigNumber>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
import { Pool } from "../..";
|
|
4
|
+
export declare function getUniswapV3SwapTxData(pool: Pool, assetA: string, assetB: string, amountIn: string | ethers.BigNumber, slippage: number, feeAmount: FeeAmount): Promise<any>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FeeAmount } from "@uniswap/v3-sdk";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
export declare type UniswapV3MintParams = [string, string, FeeAmount, number, number, ethers.BigNumber | string, ethers.BigNumber | string, ethers.BigNumber | string, ethers.BigNumber | string, string, number];
|
package/dist/test/constants.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export declare const USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
2
|
+
export declare const WETH = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
2
3
|
export declare const USDT = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
3
4
|
export declare const DAI = "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063";
|
|
4
5
|
export declare const TUSD = "0x2e1ad108ff1d8c782fcbbb89aad783ac49586756";
|
|
5
|
-
export declare const WETH = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
6
6
|
export declare const WBTC = "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6";
|
|
7
7
|
export declare const SUSHI = "0x0b3f868e0be5597d5db7feb59e1cadbb0fdda50a";
|
|
8
8
|
export declare const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
|
|
9
9
|
export declare const BAL = "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3";
|
|
10
10
|
export declare const AMUSDC = "0x1a13f4ca1d028320a707d99520abfefca3998b7f";
|
|
11
11
|
export declare const VDEBTWETH = "0xede17e9d79fc6f9ff9250d9eefbdb88cc18038b5";
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const ARRAKIS_USDC_WETH_GAUGE = "0x33d1ad9Cd88A509397CD924C2d7613C285602C20";
|
|
13
|
+
export declare const TEST_POOL = "TEST_POOL_ADDRESS";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTxOptions: () => Promise<any>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { ChainId } from "@sushiswap/sdk";
|
|
2
1
|
import { BigNumber } from "ethers";
|
|
3
2
|
export declare enum Network {
|
|
4
|
-
POLYGON = "polygon"
|
|
3
|
+
POLYGON = "polygon",
|
|
4
|
+
OPTIMISM = "optimism"
|
|
5
5
|
}
|
|
6
6
|
export declare enum Dapp {
|
|
7
7
|
SUSHISWAP = "sushiswap",
|
|
8
8
|
AAVE = "aave",
|
|
9
9
|
ONEINCH = "1inch",
|
|
10
10
|
QUICKSWAP = "quickswap",
|
|
11
|
-
BALANCER = "balancer"
|
|
11
|
+
BALANCER = "balancer",
|
|
12
|
+
UNISWAPV3 = "uniswapV3",
|
|
13
|
+
SYNTHETIX = "synthetix",
|
|
14
|
+
AAVEV3 = "aavev3",
|
|
15
|
+
ARRAKIS = "arrakis"
|
|
12
16
|
}
|
|
13
17
|
export declare enum Transaction {
|
|
14
18
|
SWAP = "swapExactTokensForTokens",
|
|
@@ -18,17 +22,22 @@ export declare enum Transaction {
|
|
|
18
22
|
CLAIM_DISTRIBIUTIONS = "claimDistributions",
|
|
19
23
|
CLAIM_REWARDS = "claimRewards",
|
|
20
24
|
REMOVE_LIQUIDITY = "removeLiquidity",
|
|
25
|
+
DECREASE_LIQUIDITY = "decreaseLiquidity",
|
|
26
|
+
INCREASE_LIQUIDITY = "increaseLiquidity",
|
|
27
|
+
COLLECT = "collect",
|
|
28
|
+
MULTI_CALL = "multicall",
|
|
21
29
|
BORROW = "borrow",
|
|
22
30
|
REPAY = "repay",
|
|
23
|
-
WITHDRAW = "withdraw"
|
|
31
|
+
WITHDRAW = "withdraw",
|
|
32
|
+
MINT = "mint",
|
|
33
|
+
BURN = "burn",
|
|
34
|
+
SWAP_SYNTHS = "exchangeWithTracking",
|
|
35
|
+
ADD_LIQUIDITY_STAKE = "addLiquidityAndStake",
|
|
36
|
+
REMOVE_LIQUIDITY_UNSTAKE = "removeLiquidityAndUnstake"
|
|
24
37
|
}
|
|
25
38
|
export declare type AddressNetworkMap = Readonly<Record<Network, string>>;
|
|
26
39
|
export declare type AddressDappMap = {
|
|
27
|
-
[Dapp
|
|
28
|
-
[Dapp.AAVE]?: string;
|
|
29
|
-
[Dapp.ONEINCH]?: string;
|
|
30
|
-
[Dapp.QUICKSWAP]?: string;
|
|
31
|
-
[Dapp.BALANCER]?: string;
|
|
40
|
+
[key in Dapp]?: string;
|
|
32
41
|
};
|
|
33
42
|
export declare type AddressDappNetworkMap = Readonly<Record<Network, AddressDappMap>>;
|
|
34
43
|
export declare type SupportedAsset = [string, boolean];
|
|
@@ -46,4 +55,4 @@ export declare type Reserves = {
|
|
|
46
55
|
assetA: BigNumber;
|
|
47
56
|
assetB: BigNumber;
|
|
48
57
|
};
|
|
49
|
-
export declare type NetworkChainIdMap = Readonly<Record<Network,
|
|
58
|
+
export declare type NetworkChainIdMap = Readonly<Record<Network, number>>;
|