@dhedge/v2-sdk 1.10.13 → 1.10.15
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/test/constants.d.ts +2 -0
- package/dist/v2-sdk.cjs.development.js +15 -12
- 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 +15 -12
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +3 -1
- package/src/entities/pool.ts +47 -47
- package/src/services/flatmoney/keeperFee.ts +1 -1
- package/src/test/constants.ts +4 -2
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -97,7 +97,9 @@ export const stakingAddress: AddressDappNetworkMap = {
|
|
|
97
97
|
[Network.BASE]: {
|
|
98
98
|
[Dapp.PANCAKECL]: "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3"
|
|
99
99
|
},
|
|
100
|
-
[Network.SONIC]: {
|
|
100
|
+
[Network.SONIC]: {
|
|
101
|
+
[Dapp.SHADOWCL]: "0xe879d0E44e6873cf4ab71686055a4f6817685f02" //specific for wS/USDC CL
|
|
102
|
+
}
|
|
101
103
|
};
|
|
102
104
|
|
|
103
105
|
export const aaveAddressProvider: AddressDappNetworkMap = {
|
package/src/entities/pool.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
nonfungiblePositionManagerAddress,
|
|
20
20
|
routerAddress,
|
|
21
21
|
stakingAddress,
|
|
22
|
-
SYNTHETIX_TRACKING_CODE
|
|
22
|
+
SYNTHETIX_TRACKING_CODE,
|
|
23
23
|
} from "../config";
|
|
24
24
|
import {
|
|
25
25
|
Dapp,
|
|
@@ -30,60 +30,60 @@ import {
|
|
|
30
30
|
LyraOptionMarket,
|
|
31
31
|
LyraOptionType,
|
|
32
32
|
LyraTradeType,
|
|
33
|
-
LyraPosition
|
|
33
|
+
LyraPosition,
|
|
34
34
|
} from "../types";
|
|
35
35
|
|
|
36
36
|
import { Utils } from "./utils";
|
|
37
37
|
import {
|
|
38
38
|
getDecreaseLiquidityTxData,
|
|
39
39
|
getIncreaseLiquidityTxData,
|
|
40
|
-
getUniswapV3MintTxData
|
|
40
|
+
getUniswapV3MintTxData,
|
|
41
41
|
} from "../services/uniswap/V3Liquidity";
|
|
42
42
|
import { getUniswapV3SwapTxData } from "../services/uniswap/V3Trade";
|
|
43
43
|
import {
|
|
44
44
|
getCompleteWithdrawalTxData,
|
|
45
|
-
getEasySwapperTxData
|
|
45
|
+
getEasySwapperTxData,
|
|
46
46
|
} from "../services/toros/easySwapper";
|
|
47
47
|
import { getAaveV3ClaimTxData } from "../services/aave/incentives";
|
|
48
48
|
import {
|
|
49
49
|
getClOwner,
|
|
50
50
|
getVelodromeAddLiquidityTxData,
|
|
51
|
-
getVelodromeRemoveLiquidityTxData
|
|
51
|
+
getVelodromeRemoveLiquidityTxData,
|
|
52
52
|
} from "../services/velodrome/liquidity";
|
|
53
53
|
import {
|
|
54
54
|
getVelodromeClaimTxData,
|
|
55
55
|
getVelodromeCLClaimTxData,
|
|
56
|
-
getVelodromeStakeTxData
|
|
56
|
+
getVelodromeStakeTxData,
|
|
57
57
|
} from "../services/velodrome/staking";
|
|
58
58
|
import { getLyraOptionTxData } from "../services/lyra/trade";
|
|
59
59
|
import { getOptionPositions } from "../services/lyra/positions";
|
|
60
60
|
import { getDeadline } from "../utils/deadline";
|
|
61
61
|
import {
|
|
62
62
|
getFuturesChangePositionTxData,
|
|
63
|
-
getFuturesChangeMarginTxData
|
|
63
|
+
getFuturesChangeMarginTxData,
|
|
64
64
|
} from "../services/futures";
|
|
65
65
|
import { getFuturesCancelOrderTxData } from "../services/futures/trade";
|
|
66
66
|
import { getOneInchSwapTxData } from "../services/oneInch";
|
|
67
67
|
import {
|
|
68
68
|
getCreateVestTxData,
|
|
69
69
|
getExitVestTxData,
|
|
70
|
-
getRewardsTxDta
|
|
70
|
+
getRewardsTxDta,
|
|
71
71
|
} from "../services/ramses/vesting";
|
|
72
72
|
import { getPoolTxOrGasEstimate } from "../utils/contract";
|
|
73
73
|
import {
|
|
74
74
|
cancelOrderViaFlatMoney,
|
|
75
75
|
mintUnitViaFlatMoney,
|
|
76
|
-
redeemUnitViaFlatMoney
|
|
76
|
+
redeemUnitViaFlatMoney,
|
|
77
77
|
} from "../services/flatmoney/stableLp";
|
|
78
78
|
import {
|
|
79
79
|
getCompoundV3LendTxData,
|
|
80
|
-
getCompoundV3WithdrawTxData
|
|
80
|
+
getCompoundV3WithdrawTxData,
|
|
81
81
|
} from "../services/compound/lending";
|
|
82
82
|
import { getCompoundV3ClaimTxData } from "../services/compound/rewards";
|
|
83
83
|
import {
|
|
84
84
|
getPancakeHarvestClaimTxData,
|
|
85
85
|
getPancakeStakeTxData,
|
|
86
|
-
getPancakeUnStakeTxData
|
|
86
|
+
getPancakeUnStakeTxData,
|
|
87
87
|
} from "../services/pancake/staking";
|
|
88
88
|
import { getOdosSwapTxData } from "../services/odos";
|
|
89
89
|
|
|
@@ -130,7 +130,7 @@ export class Pool {
|
|
|
130
130
|
asset: asset,
|
|
131
131
|
isDeposit: isDeposit,
|
|
132
132
|
balance: result[1][index],
|
|
133
|
-
rate: result[2][index]
|
|
133
|
+
rate: result[2][index],
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
);
|
|
@@ -225,7 +225,7 @@ export class Pool {
|
|
|
225
225
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
226
226
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
227
227
|
routerAddress[this.network][dapp],
|
|
228
|
-
amount
|
|
228
|
+
amount,
|
|
229
229
|
]);
|
|
230
230
|
const tx = await getPoolTxOrGasEstimate(
|
|
231
231
|
this,
|
|
@@ -254,7 +254,7 @@ export class Pool {
|
|
|
254
254
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
255
255
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
256
256
|
stakingAddress[this.network][dapp],
|
|
257
|
-
amount
|
|
257
|
+
amount,
|
|
258
258
|
]);
|
|
259
259
|
const tx = await getPoolTxOrGasEstimate(
|
|
260
260
|
this,
|
|
@@ -282,7 +282,7 @@ export class Pool {
|
|
|
282
282
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
283
283
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
284
284
|
nonfungiblePositionManagerAddress[this.network][Dapp.UNISWAPV3],
|
|
285
|
-
amount
|
|
285
|
+
amount,
|
|
286
286
|
]);
|
|
287
287
|
const tx = await getPoolTxOrGasEstimate(
|
|
288
288
|
this,
|
|
@@ -311,7 +311,7 @@ export class Pool {
|
|
|
311
311
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
312
312
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
313
313
|
spender,
|
|
314
|
-
amount
|
|
314
|
+
amount,
|
|
315
315
|
]);
|
|
316
316
|
const tx = await getPoolTxOrGasEstimate(
|
|
317
317
|
this,
|
|
@@ -340,7 +340,7 @@ export class Pool {
|
|
|
340
340
|
const iERC721 = new ethers.utils.Interface(IERC721.abi);
|
|
341
341
|
const approveTxData = iERC721.encodeFunctionData("approve", [
|
|
342
342
|
spender,
|
|
343
|
-
tokenId
|
|
343
|
+
tokenId,
|
|
344
344
|
]);
|
|
345
345
|
const tx = await getPoolTxOrGasEstimate(
|
|
346
346
|
this,
|
|
@@ -392,7 +392,7 @@ export class Pool {
|
|
|
392
392
|
break;
|
|
393
393
|
case Dapp.SYNTHETIX:
|
|
394
394
|
const iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
|
|
395
|
-
const assets = [assetFrom, assetTo].map(asset =>
|
|
395
|
+
const assets = [assetFrom, assetTo].map((asset) =>
|
|
396
396
|
ethers.utils.formatBytes32String(asset)
|
|
397
397
|
);
|
|
398
398
|
const daoAddress = await this.factory.owner();
|
|
@@ -401,7 +401,7 @@ export class Pool {
|
|
|
401
401
|
amountIn,
|
|
402
402
|
assets[1],
|
|
403
403
|
daoAddress,
|
|
404
|
-
SYNTHETIX_TRACKING_CODE
|
|
404
|
+
SYNTHETIX_TRACKING_CODE,
|
|
405
405
|
]);
|
|
406
406
|
break;
|
|
407
407
|
case Dapp.TOROS:
|
|
@@ -438,7 +438,7 @@ export class Pool {
|
|
|
438
438
|
minAmountOut,
|
|
439
439
|
[assetFrom, assetTo],
|
|
440
440
|
this.address,
|
|
441
|
-
await getDeadline(this)
|
|
441
|
+
await getDeadline(this),
|
|
442
442
|
]);
|
|
443
443
|
}
|
|
444
444
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -480,7 +480,7 @@ export class Pool {
|
|
|
480
480
|
0,
|
|
481
481
|
0,
|
|
482
482
|
this.address,
|
|
483
|
-
await getDeadline(this)
|
|
483
|
+
await getDeadline(this),
|
|
484
484
|
]
|
|
485
485
|
);
|
|
486
486
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -543,7 +543,7 @@ export class Pool {
|
|
|
543
543
|
const stakeTxData = iMiniChefV2.encodeFunctionData(Transaction.DEPOSIT, [
|
|
544
544
|
poolId,
|
|
545
545
|
amount,
|
|
546
|
-
this.address
|
|
546
|
+
this.address,
|
|
547
547
|
]);
|
|
548
548
|
const tx = await getPoolTxOrGasEstimate(
|
|
549
549
|
this,
|
|
@@ -576,7 +576,7 @@ export class Pool {
|
|
|
576
576
|
IBalancerRewardsGauge.abi
|
|
577
577
|
);
|
|
578
578
|
stakeTxData = rewardsGauge.encodeFunctionData("deposit(uint256)", [
|
|
579
|
-
amount
|
|
579
|
+
amount,
|
|
580
580
|
]);
|
|
581
581
|
break;
|
|
582
582
|
case Dapp.VELODROME:
|
|
@@ -628,7 +628,7 @@ export class Pool {
|
|
|
628
628
|
const unStakeTxData = iMiniChefV2.encodeFunctionData(Transaction.WITHDRAW, [
|
|
629
629
|
poolId,
|
|
630
630
|
amount,
|
|
631
|
-
this.address
|
|
631
|
+
this.address,
|
|
632
632
|
]);
|
|
633
633
|
const tx = await getPoolTxOrGasEstimate(
|
|
634
634
|
this,
|
|
@@ -661,7 +661,7 @@ export class Pool {
|
|
|
661
661
|
unstakeTxData = getPancakeUnStakeTxData(this, amount.toString());
|
|
662
662
|
} else {
|
|
663
663
|
unstakeTxData = rewardsGauge.encodeFunctionData("withdraw(uint256)", [
|
|
664
|
-
amount
|
|
664
|
+
amount,
|
|
665
665
|
]);
|
|
666
666
|
}
|
|
667
667
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -695,7 +695,7 @@ export class Pool {
|
|
|
695
695
|
asset,
|
|
696
696
|
amount,
|
|
697
697
|
this.address,
|
|
698
|
-
referralCode
|
|
698
|
+
referralCode,
|
|
699
699
|
]);
|
|
700
700
|
|
|
701
701
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -812,7 +812,7 @@ export class Pool {
|
|
|
812
812
|
amount,
|
|
813
813
|
2,
|
|
814
814
|
referralCode,
|
|
815
|
-
this.address
|
|
815
|
+
this.address,
|
|
816
816
|
]);
|
|
817
817
|
const tx = await getPoolTxOrGasEstimate(
|
|
818
818
|
this,
|
|
@@ -843,7 +843,7 @@ export class Pool {
|
|
|
843
843
|
asset,
|
|
844
844
|
amount,
|
|
845
845
|
2,
|
|
846
|
-
this.address
|
|
846
|
+
this.address,
|
|
847
847
|
]);
|
|
848
848
|
const tx = await getPoolTxOrGasEstimate(
|
|
849
849
|
this,
|
|
@@ -871,7 +871,7 @@ export class Pool {
|
|
|
871
871
|
const poolId = await this.utils.getLpPoolId(dapp, asset);
|
|
872
872
|
const harvestTxData = iMiniChefV2.encodeFunctionData(Transaction.HARVEST, [
|
|
873
873
|
poolId,
|
|
874
|
-
this.address
|
|
874
|
+
this.address,
|
|
875
875
|
]);
|
|
876
876
|
const tx = await getPoolTxOrGasEstimate(
|
|
877
877
|
this,
|
|
@@ -894,12 +894,12 @@ export class Pool {
|
|
|
894
894
|
estimateGas = false
|
|
895
895
|
): Promise<any> {
|
|
896
896
|
const currentAssetsEnabled = await this.getComposition();
|
|
897
|
-
const currentAssets = currentAssetsEnabled.map(e =>
|
|
897
|
+
const currentAssets = currentAssetsEnabled.map((e) =>
|
|
898
898
|
e.asset.toLocaleLowerCase()
|
|
899
899
|
);
|
|
900
|
-
const newAssets = assets.map(e => e.asset.toLocaleLowerCase());
|
|
901
|
-
const removedAssets = currentAssets.filter(e => !newAssets.includes(e));
|
|
902
|
-
const changedAssets = assets.map(e => [e.asset, e.isDeposit]);
|
|
900
|
+
const newAssets = assets.map((e) => e.asset.toLocaleLowerCase());
|
|
901
|
+
const removedAssets = currentAssets.filter((e) => !newAssets.includes(e));
|
|
902
|
+
const changedAssets = assets.map((e) => [e.asset, e.isDeposit]);
|
|
903
903
|
|
|
904
904
|
if (estimateGas) {
|
|
905
905
|
return await this.managerLogic.estimateGas.changeAssets(
|
|
@@ -1056,7 +1056,7 @@ export class Pool {
|
|
|
1056
1056
|
[
|
|
1057
1057
|
stakingAddress[this.network][Dapp.AAVEV3] as string,
|
|
1058
1058
|
claimTxData,
|
|
1059
|
-
options
|
|
1059
|
+
options,
|
|
1060
1060
|
],
|
|
1061
1061
|
estimateGas
|
|
1062
1062
|
);
|
|
@@ -1081,7 +1081,7 @@ export class Pool {
|
|
|
1081
1081
|
[
|
|
1082
1082
|
stakingAddress[this.network][Dapp.COMPOUNDV3] as string,
|
|
1083
1083
|
claimTxData,
|
|
1084
|
-
options
|
|
1084
|
+
options,
|
|
1085
1085
|
],
|
|
1086
1086
|
estimateGas
|
|
1087
1087
|
);
|
|
@@ -1151,7 +1151,7 @@ export class Pool {
|
|
|
1151
1151
|
[
|
|
1152
1152
|
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1153
1153
|
mintTxData,
|
|
1154
|
-
options
|
|
1154
|
+
options,
|
|
1155
1155
|
],
|
|
1156
1156
|
estimateGas
|
|
1157
1157
|
);
|
|
@@ -1382,13 +1382,13 @@ export class Pool {
|
|
|
1382
1382
|
options: any = null,
|
|
1383
1383
|
estimateGas = false
|
|
1384
1384
|
): Promise<any> {
|
|
1385
|
+
const claimAddress =
|
|
1386
|
+
dapp === Dapp.SHADOWCL
|
|
1387
|
+
? stakingAddress[this.network][dapp] //specific for wS/USDC CL
|
|
1388
|
+
: nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1385
1389
|
const tx = await getPoolTxOrGasEstimate(
|
|
1386
1390
|
this,
|
|
1387
|
-
[
|
|
1388
|
-
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1389
|
-
getRewardsTxDta(tokenId, rewards),
|
|
1390
|
-
options
|
|
1391
|
-
],
|
|
1391
|
+
[claimAddress, getRewardsTxDta(tokenId, rewards), options],
|
|
1392
1392
|
estimateGas
|
|
1393
1393
|
);
|
|
1394
1394
|
return tx;
|
|
@@ -1463,7 +1463,7 @@ export class Pool {
|
|
|
1463
1463
|
amountB,
|
|
1464
1464
|
isStable
|
|
1465
1465
|
),
|
|
1466
|
-
options
|
|
1466
|
+
options,
|
|
1467
1467
|
],
|
|
1468
1468
|
estimateGas
|
|
1469
1469
|
);
|
|
@@ -1499,7 +1499,7 @@ export class Pool {
|
|
|
1499
1499
|
amount,
|
|
1500
1500
|
isStable
|
|
1501
1501
|
),
|
|
1502
|
-
options
|
|
1502
|
+
options,
|
|
1503
1503
|
],
|
|
1504
1504
|
estimateGas
|
|
1505
1505
|
);
|
|
@@ -1538,7 +1538,7 @@ export class Pool {
|
|
|
1538
1538
|
amountB,
|
|
1539
1539
|
isStable
|
|
1540
1540
|
),
|
|
1541
|
-
options
|
|
1541
|
+
options,
|
|
1542
1542
|
],
|
|
1543
1543
|
estimateGas
|
|
1544
1544
|
);
|
|
@@ -1574,7 +1574,7 @@ export class Pool {
|
|
|
1574
1574
|
amount,
|
|
1575
1575
|
isStable
|
|
1576
1576
|
),
|
|
1577
|
-
options
|
|
1577
|
+
options,
|
|
1578
1578
|
],
|
|
1579
1579
|
estimateGas
|
|
1580
1580
|
);
|
|
@@ -1615,7 +1615,7 @@ export class Pool {
|
|
|
1615
1615
|
amountB,
|
|
1616
1616
|
isStable
|
|
1617
1617
|
),
|
|
1618
|
-
options
|
|
1618
|
+
options,
|
|
1619
1619
|
],
|
|
1620
1620
|
estimateGas
|
|
1621
1621
|
);
|
|
@@ -1653,7 +1653,7 @@ export class Pool {
|
|
|
1653
1653
|
amount,
|
|
1654
1654
|
isStable
|
|
1655
1655
|
),
|
|
1656
|
-
options
|
|
1656
|
+
options,
|
|
1657
1657
|
],
|
|
1658
1658
|
estimateGas
|
|
1659
1659
|
);
|
|
@@ -38,7 +38,7 @@ export const getKeeperFee = async (
|
|
|
38
38
|
const keeperFeeContract = await getKeeperFeeContract(pool);
|
|
39
39
|
|
|
40
40
|
const feeHistory = await (pool.signer
|
|
41
|
-
.provider as JsonRpcProvider).send("eth_feeHistory", [1, "latest"]);
|
|
41
|
+
.provider as JsonRpcProvider).send("eth_feeHistory", [1, "latest", []]);
|
|
42
42
|
|
|
43
43
|
const gasPrice = Number(feeHistory.baseFeePerGas[0]);
|
|
44
44
|
|
package/src/test/constants.ts
CHANGED
|
@@ -42,7 +42,8 @@ export const TEST_POOL = {
|
|
|
42
42
|
[Network.POLYGON]: "0x699fd4d6eadb216704c7e355cfa0a12f51813163",
|
|
43
43
|
[Network.OPTIMISM]: "0x12573bfdf764ab9d52aca20e2827497a66829716",
|
|
44
44
|
[Network.ARBITRUM]: "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14",
|
|
45
|
-
[Network.BASE]: "0x4842b42F68524383F609aa46eAfc18c1459cE3cD"
|
|
45
|
+
[Network.BASE]: "0x4842b42F68524383F609aa46eAfc18c1459cE3cD",
|
|
46
|
+
[Network.SONIC]: ""
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
export const CONTRACT_ADDRESS = {
|
|
@@ -151,7 +152,8 @@ export const CONTRACT_ADDRESS = {
|
|
|
151
152
|
VELODROME_CL_USDC_WETH_GAUGE: "",
|
|
152
153
|
VELO: "",
|
|
153
154
|
COMPOUNDV3_WETH: "",
|
|
154
|
-
TOROS: ""
|
|
155
|
+
TOROS: "",
|
|
156
|
+
UNIT: ""
|
|
155
157
|
}
|
|
156
158
|
};
|
|
157
159
|
|