@enzymefinance/testutils 4.0.0-next.1 → 4.0.0-next.6

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/declarations/src/assertions.d.ts +2 -2
  3. package/dist/declarations/src/deployment.d.ts +168 -64
  4. package/dist/declarations/src/gasRelayer.d.ts +14 -12
  5. package/dist/declarations/src/helpers.d.ts +5 -4
  6. package/dist/declarations/src/scaffolding/assets.d.ts +3 -3
  7. package/dist/declarations/src/scaffolding/chainlink.d.ts +2 -2
  8. package/dist/declarations/src/scaffolding/common.d.ts +1 -1
  9. package/dist/declarations/src/scaffolding/core.d.ts +4 -3
  10. package/dist/declarations/src/scaffolding/extensions/common.d.ts +4 -4
  11. package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +14 -5
  12. package/dist/declarations/src/scaffolding/extensions/external-positions/compound.d.ts +22 -22
  13. package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +1 -0
  14. package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +40 -7
  15. package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +99 -0
  16. package/dist/declarations/src/scaffolding/extensions/fees.d.ts +1 -1
  17. package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +4 -3
  18. package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +5 -5
  19. package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +108 -33
  20. package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +3 -3
  21. package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +3 -0
  22. package/dist/declarations/src/scaffolding/extensions/integrations/mock.d.ts +4 -4
  23. package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +17 -0
  24. package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV4.d.ts +6 -5
  25. package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV5.d.ts +23 -0
  26. package/dist/declarations/src/scaffolding/extensions/integrations/poolTogetherV4.d.ts +29 -0
  27. package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +11 -3
  28. package/dist/declarations/src/scaffolding/extensions/integrations/trackedAssets.d.ts +3 -3
  29. package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV2.d.ts +10 -10
  30. package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV3.d.ts +4 -4
  31. package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +3 -3
  32. package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +3 -3
  33. package/dist/declarations/src/scaffolding/extensions/policies.d.ts +1 -1
  34. package/dist/declarations/src/scaffolding/setup.d.ts +11 -9
  35. package/dist/declarations/src/scaffolding/shares.d.ts +4 -4
  36. package/dist/declarations/src/scaffolding/vaultCalls.d.ts +15 -6
  37. package/dist/declarations/src/whales.d.ts +20 -18
  38. package/dist/enzymefinance-testutils.browser.cjs.js +1783 -763
  39. package/dist/enzymefinance-testutils.browser.esm.js +1746 -757
  40. package/dist/enzymefinance-testutils.cjs.dev.js +1783 -763
  41. package/dist/enzymefinance-testutils.cjs.prod.js +1783 -763
  42. package/dist/enzymefinance-testutils.esm.js +1746 -757
  43. package/package.json +5 -5
  44. package/src/assertions.ts +5 -2
  45. package/src/deployment.ts +215 -111
  46. package/src/gasRelayer.ts +17 -18
  47. package/src/helpers.ts +6 -4
  48. package/src/scaffolding/assets.ts +7 -6
  49. package/src/scaffolding/chainlink.ts +2 -2
  50. package/src/scaffolding/common.ts +1 -1
  51. package/src/scaffolding/core.ts +30 -12
  52. package/src/scaffolding/extensions/common.ts +4 -4
  53. package/src/scaffolding/extensions/external-positions/actions.ts +33 -6
  54. package/src/scaffolding/extensions/external-positions/compound.ts +76 -96
  55. package/src/scaffolding/extensions/external-positions/index.ts +1 -0
  56. package/src/scaffolding/extensions/external-positions/mocks.ts +132 -10
  57. package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +290 -0
  58. package/src/scaffolding/extensions/fees.ts +1 -1
  59. package/src/scaffolding/extensions/integrations/aave.ts +6 -8
  60. package/src/scaffolding/extensions/integrations/compound.ts +10 -11
  61. package/src/scaffolding/extensions/integrations/curve.ts +333 -68
  62. package/src/scaffolding/extensions/integrations/idle.ts +9 -11
  63. package/src/scaffolding/extensions/integrations/index.ts +3 -0
  64. package/src/scaffolding/extensions/integrations/mock.ts +11 -13
  65. package/src/scaffolding/extensions/integrations/olympusV2.ts +71 -0
  66. package/src/scaffolding/extensions/integrations/paraSwapV4.ts +16 -11
  67. package/src/scaffolding/extensions/integrations/paraSwapV5.ts +73 -0
  68. package/src/scaffolding/extensions/integrations/poolTogetherV4.ts +117 -0
  69. package/src/scaffolding/extensions/integrations/synthetix.ts +45 -12
  70. package/src/scaffolding/extensions/integrations/trackedAssets.ts +3 -4
  71. package/src/scaffolding/extensions/integrations/uniswapV2.ts +31 -27
  72. package/src/scaffolding/extensions/integrations/uniswapV3.ts +9 -10
  73. package/src/scaffolding/extensions/integrations/yearn.ts +9 -11
  74. package/src/scaffolding/extensions/integrations/zeroExV2.ts +9 -7
  75. package/src/scaffolding/extensions/policies.ts +2 -1
  76. package/src/scaffolding/setup.ts +27 -13
  77. package/src/scaffolding/shares.ts +5 -4
  78. package/src/scaffolding/vaultCalls.ts +32 -2
  79. package/src/whales.ts +30 -17
  80. package/tsconfig.json +2 -1
@@ -1,19 +1,17 @@
1
- import { SignerWithAddress } from '@enzymefinance/hardhat';
1
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
2
+ import type { ComptrollerLib, IdleAdapter, IntegrationManager, StandardToken } from '@enzymefinance/protocol';
2
3
  import {
3
4
  callOnIntegrationArgs,
4
5
  claimRewardsSelector,
5
- ComptrollerLib,
6
- IdleAdapter,
7
6
  idleClaimRewardsArgs,
8
7
  idleLendArgs,
9
8
  idleRedeemArgs,
10
- IntegrationManager,
11
9
  IntegrationManagerActionId,
12
10
  lendSelector,
13
11
  redeemSelector,
14
- StandardToken,
15
12
  } from '@enzymefinance/protocol';
16
- import { BigNumber, BigNumberish } from 'ethers';
13
+ import type { BigNumberish } from 'ethers';
14
+ import { BigNumber } from 'ethers';
17
15
 
18
16
  export async function idleClaimRewards({
19
17
  comptrollerProxy,
@@ -30,10 +28,10 @@ export async function idleClaimRewards({
30
28
  }) {
31
29
  const callArgs = callOnIntegrationArgs({
32
30
  adapter: idleAdapter,
33
- selector: claimRewardsSelector,
34
31
  encodedCallArgs: idleClaimRewardsArgs({
35
32
  idleToken,
36
33
  }),
34
+ selector: claimRewardsSelector,
37
35
  });
38
36
 
39
37
  return comptrollerProxy
@@ -60,12 +58,12 @@ export async function idleLend({
60
58
  }) {
61
59
  const callArgs = callOnIntegrationArgs({
62
60
  adapter: idleAdapter,
63
- selector: lendSelector,
64
61
  encodedCallArgs: idleLendArgs({
65
62
  idleToken,
66
- outgoingUnderlyingAmount,
67
63
  minIncomingIdleTokenAmount,
64
+ outgoingUnderlyingAmount,
68
65
  }),
66
+ selector: lendSelector,
69
67
  });
70
68
 
71
69
  return comptrollerProxy
@@ -92,12 +90,12 @@ export async function idleRedeem({
92
90
  }) {
93
91
  const callArgs = callOnIntegrationArgs({
94
92
  adapter: idleAdapter,
95
- selector: redeemSelector,
96
93
  encodedCallArgs: idleRedeemArgs({
97
94
  idleToken,
98
- outgoingIdleTokenAmount,
99
95
  minIncomingUnderlyingAmount,
96
+ outgoingIdleTokenAmount,
100
97
  }),
98
+ selector: redeemSelector,
101
99
  });
102
100
 
103
101
  return comptrollerProxy
@@ -3,7 +3,10 @@ export * from './compound';
3
3
  export * from './curve';
4
4
  export * from './idle';
5
5
  export * from './mock';
6
+ export * from './olympusV2';
6
7
  export * from './paraSwapV4';
8
+ export * from './paraSwapV5';
9
+ export * from './poolTogetherV4';
7
10
  export * from './synthetix';
8
11
  export * from './trackedAssets';
9
12
  export * from './uniswapV2';
@@ -1,17 +1,15 @@
1
- import { AddressLike } from '@enzymefinance/ethers';
2
- import { SignerWithAddress } from '@enzymefinance/hardhat';
3
- import {
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
3
+ import type {
4
4
  ComptrollerLib,
5
5
  IntegrationManager,
6
- VaultLib,
7
6
  MockGenericAdapter,
8
7
  StandardToken,
9
- sighash,
10
- callOnIntegrationArgs,
11
- encodeArgs,
12
- IntegrationManagerActionId,
8
+ VaultLib,
13
9
  } from '@enzymefinance/protocol';
14
- import { BigNumberish, BytesLike, utils } from 'ethers';
10
+ import { callOnIntegrationArgs, encodeArgs, IntegrationManagerActionId, sighash } from '@enzymefinance/protocol';
11
+ import type { BigNumberish, BytesLike } from 'ethers';
12
+ import { utils } from 'ethers';
15
13
 
16
14
  export const mockGenericRemoveOnlySelector = sighash(
17
15
  utils.FunctionFragment.fromString('removeOnly(address,bytes,bytes)'),
@@ -94,18 +92,18 @@ export async function mockGenericSwap({
94
92
  }
95
93
 
96
94
  const swapArgs = mockGenericSwapArgs({
97
- spendAssets,
98
- maxSpendAssetAmounts,
95
+ actualIncomingAssetAmounts,
99
96
  actualSpendAssetAmounts,
100
97
  incomingAssets,
98
+ maxSpendAssetAmounts,
101
99
  minIncomingAssetAmounts,
102
- actualIncomingAssetAmounts,
100
+ spendAssets,
103
101
  });
104
102
 
105
103
  const callArgs = callOnIntegrationArgs({
106
104
  adapter: mockGenericAdapter,
107
- selector,
108
105
  encodedCallArgs: swapArgs,
106
+ selector,
109
107
  });
110
108
 
111
109
  const swapTx = comptrollerProxy
@@ -0,0 +1,71 @@
1
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
2
+ import type { ComptrollerLib, IntegrationManager, OlympusV2Adapter } from '@enzymefinance/protocol';
3
+ import {
4
+ callOnIntegrationArgs,
5
+ IntegrationManagerActionId,
6
+ olympusV2StakeArgs,
7
+ olympusV2UnstakeArgs,
8
+ stakeSelector,
9
+ unstakeSelector,
10
+ } from '@enzymefinance/protocol';
11
+ import type { BigNumberish } from 'ethers';
12
+
13
+ export async function olympusV2Stake({
14
+ comptrollerProxy,
15
+ integrationManager,
16
+ signer,
17
+ olympusV2Adapter,
18
+ amount,
19
+ }: {
20
+ comptrollerProxy: ComptrollerLib;
21
+ integrationManager: IntegrationManager;
22
+ signer: SignerWithAddress;
23
+ olympusV2Adapter: OlympusV2Adapter;
24
+ amount: BigNumberish;
25
+ }) {
26
+ const stakeArgs = olympusV2StakeArgs({
27
+ amount,
28
+ });
29
+
30
+ const callArgs = callOnIntegrationArgs({
31
+ adapter: olympusV2Adapter,
32
+ encodedCallArgs: stakeArgs,
33
+ selector: stakeSelector,
34
+ });
35
+
36
+ const stakeTx = comptrollerProxy
37
+ .connect(signer)
38
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
39
+
40
+ return stakeTx;
41
+ }
42
+
43
+ export async function olympusV2Unstake({
44
+ comptrollerProxy,
45
+ integrationManager,
46
+ signer,
47
+ olympusV2Adapter,
48
+ amount,
49
+ }: {
50
+ comptrollerProxy: ComptrollerLib;
51
+ integrationManager: IntegrationManager;
52
+ signer: SignerWithAddress;
53
+ olympusV2Adapter: OlympusV2Adapter;
54
+ amount: BigNumberish;
55
+ }) {
56
+ const unstakeArgs = olympusV2UnstakeArgs({
57
+ amount,
58
+ });
59
+
60
+ const callArgs = callOnIntegrationArgs({
61
+ adapter: olympusV2Adapter,
62
+ encodedCallArgs: unstakeArgs,
63
+ selector: unstakeSelector,
64
+ });
65
+
66
+ const unstakeTx = comptrollerProxy
67
+ .connect(signer)
68
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
69
+
70
+ return unstakeTx;
71
+ }
@@ -1,25 +1,30 @@
1
- import { AddressLike } from '@enzymefinance/ethers';
2
- import { SignerWithAddress } from '@enzymefinance/hardhat';
3
- import {
4
- callOnIntegrationArgs,
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
3
+ import type {
5
4
  ComptrollerLib,
6
5
  IntegrationManager,
7
- IntegrationManagerActionId,
8
6
  ParaSwapV4Adapter,
9
7
  ParaSwapV4Path,
10
- paraSwapV4TakeOrderArgs,
11
8
  StandardToken,
9
+ } from '@enzymefinance/protocol';
10
+ import {
11
+ callOnIntegrationArgs,
12
+ IntegrationManagerActionId,
13
+ paraSwapV4TakeOrderArgs,
12
14
  takeOrderSelector,
13
15
  } from '@enzymefinance/protocol';
14
- import { BigNumberish, utils } from 'ethers';
16
+ import type { BigNumberish } from 'ethers';
17
+ import { utils } from 'ethers';
15
18
 
16
19
  // ParaSwapV4Path
17
20
  export function paraSwapV4GenerateDummyPaths({ toTokens }: { toTokens: AddressLike[] }) {
18
21
  return toTokens.map((toToken) => {
19
22
  return {
23
+ // Not supported in our protocol
24
+ routes: [],
25
+
20
26
  to: toToken,
21
- totalNetworkFee: 0, // Not supported in our protocol
22
- routes: [], // Can ignore this param in the dummy
27
+ totalNetworkFee: 0, // Can ignore this param in the dummy
23
28
  };
24
29
  });
25
30
  }
@@ -46,8 +51,8 @@ export async function paraSwapV4TakeOrder({
46
51
  paths: ParaSwapV4Path[];
47
52
  }) {
48
53
  const takeOrderArgs = paraSwapV4TakeOrderArgs({
49
- minIncomingAssetAmount,
50
54
  expectedIncomingAssetAmount,
55
+ minIncomingAssetAmount,
51
56
  outgoingAsset,
52
57
  outgoingAssetAmount,
53
58
  paths,
@@ -55,8 +60,8 @@ export async function paraSwapV4TakeOrder({
55
60
 
56
61
  const callArgs = callOnIntegrationArgs({
57
62
  adapter: paraSwapV4Adapter,
58
- selector: takeOrderSelector,
59
63
  encodedCallArgs: takeOrderArgs,
64
+ selector: takeOrderSelector,
60
65
  });
61
66
 
62
67
  return comptrollerProxy
@@ -0,0 +1,73 @@
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
3
+ import type {
4
+ ComptrollerLib,
5
+ IntegrationManager,
6
+ ParaSwapV5Adapter,
7
+ ParaSwapV5Path,
8
+ StandardToken,
9
+ } from '@enzymefinance/protocol';
10
+ import {
11
+ callOnIntegrationArgs,
12
+ IntegrationManagerActionId,
13
+ paraSwapV5TakeOrderArgs,
14
+ takeOrderSelector,
15
+ } from '@enzymefinance/protocol';
16
+ import type { BigNumberish, BytesLike } from 'ethers';
17
+ import { utils } from 'ethers';
18
+
19
+ // ParaSwapV5Path
20
+ export function paraSwapV5GenerateDummyPaths({ toTokens }: { toTokens: AddressLike[] }) {
21
+ return toTokens.map((toToken) => {
22
+ return {
23
+ // Not supported in our protocol
24
+ adapters: [],
25
+
26
+ to: toToken,
27
+ totalNetworkFee: 0, // Can ignore this param in the dummy
28
+ };
29
+ });
30
+ }
31
+
32
+ export async function paraSwapV5TakeOrder({
33
+ comptrollerProxy,
34
+ integrationManager,
35
+ fundOwner,
36
+ paraSwapV5Adapter,
37
+ outgoingAsset,
38
+ outgoingAssetAmount,
39
+ minIncomingAssetAmount = 1,
40
+ expectedIncomingAssetAmount = minIncomingAssetAmount,
41
+ uuid = utils.randomBytes(16),
42
+ paths,
43
+ }: {
44
+ comptrollerProxy: ComptrollerLib;
45
+ integrationManager: IntegrationManager;
46
+ fundOwner: SignerWithAddress;
47
+ paraSwapV5Adapter: ParaSwapV5Adapter;
48
+ outgoingAsset: StandardToken;
49
+ outgoingAssetAmount: BigNumberish;
50
+ minIncomingAssetAmount?: BigNumberish;
51
+ expectedIncomingAssetAmount?: BigNumberish;
52
+ uuid?: BytesLike;
53
+ paths: ParaSwapV5Path[];
54
+ }) {
55
+ const takeOrderArgs = paraSwapV5TakeOrderArgs({
56
+ expectedIncomingAssetAmount,
57
+ minIncomingAssetAmount,
58
+ outgoingAsset,
59
+ outgoingAssetAmount,
60
+ paths,
61
+ uuid,
62
+ });
63
+
64
+ const callArgs = callOnIntegrationArgs({
65
+ adapter: paraSwapV5Adapter,
66
+ encodedCallArgs: takeOrderArgs,
67
+ selector: takeOrderSelector,
68
+ });
69
+
70
+ return comptrollerProxy
71
+ .connect(fundOwner)
72
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
73
+ }
@@ -0,0 +1,117 @@
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
3
+ import type { ComptrollerLib, IntegrationManager, PoolTogetherV4Adapter, StandardToken } from '@enzymefinance/protocol';
4
+ import {
5
+ callOnIntegrationArgs,
6
+ claimRewardsSelector,
7
+ IntegrationManagerActionId,
8
+ lendSelector,
9
+ poolTogetherV4ClaimRewardsArgs,
10
+ poolTogetherV4LendArgs,
11
+ poolTogetherV4RedeemArgs,
12
+ redeemSelector,
13
+ } from '@enzymefinance/protocol';
14
+ import type { BigNumberish, BytesLike } from 'ethers';
15
+ import { utils } from 'ethers';
16
+
17
+ export async function poolTogetherV4Lend({
18
+ comptrollerProxy,
19
+ integrationManager,
20
+ fundOwner,
21
+ poolTogetherV4Adapter,
22
+ ptToken,
23
+ amount = utils.parseEther('1'),
24
+ }: {
25
+ comptrollerProxy: ComptrollerLib;
26
+ integrationManager: IntegrationManager;
27
+ fundOwner: SignerWithAddress;
28
+ poolTogetherV4Adapter: PoolTogetherV4Adapter;
29
+ ptToken: StandardToken;
30
+ amount?: BigNumberish;
31
+ }) {
32
+ const lendArgs = poolTogetherV4LendArgs({
33
+ amount,
34
+ ptToken,
35
+ });
36
+
37
+ const callArgs = callOnIntegrationArgs({
38
+ adapter: poolTogetherV4Adapter,
39
+ encodedCallArgs: lendArgs,
40
+ selector: lendSelector,
41
+ });
42
+
43
+ const lendTx = comptrollerProxy
44
+ .connect(fundOwner)
45
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
46
+
47
+ return lendTx;
48
+ }
49
+
50
+ export async function poolTogetherV4Redeem({
51
+ comptrollerProxy,
52
+ integrationManager,
53
+ fundOwner,
54
+ poolTogetherV4Adapter,
55
+ ptToken,
56
+ amount = utils.parseEther('1'),
57
+ }: {
58
+ comptrollerProxy: ComptrollerLib;
59
+ integrationManager: IntegrationManager;
60
+ fundOwner: SignerWithAddress;
61
+ poolTogetherV4Adapter: PoolTogetherV4Adapter;
62
+ ptToken: StandardToken;
63
+ amount?: BigNumberish;
64
+ }) {
65
+ const redeemArgs = poolTogetherV4RedeemArgs({
66
+ amount,
67
+ ptToken,
68
+ });
69
+
70
+ const callArgs = callOnIntegrationArgs({
71
+ adapter: poolTogetherV4Adapter,
72
+ encodedCallArgs: redeemArgs,
73
+ selector: redeemSelector,
74
+ });
75
+
76
+ const redeemTx = comptrollerProxy
77
+ .connect(fundOwner)
78
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
79
+
80
+ return redeemTx;
81
+ }
82
+
83
+ export async function poolTogetherV4ClaimRewards({
84
+ comptrollerProxy,
85
+ integrationManager,
86
+ fundOwner,
87
+ poolTogetherV4Adapter,
88
+ prizeDistributor,
89
+ drawIds,
90
+ winningPicks,
91
+ }: {
92
+ comptrollerProxy: ComptrollerLib;
93
+ integrationManager: IntegrationManager;
94
+ fundOwner: SignerWithAddress;
95
+ poolTogetherV4Adapter: PoolTogetherV4Adapter;
96
+ prizeDistributor: AddressLike;
97
+ drawIds: BigNumberish[];
98
+ winningPicks: BytesLike;
99
+ }) {
100
+ const claimRewardsArgs = poolTogetherV4ClaimRewardsArgs({
101
+ drawIds,
102
+ prizeDistributor,
103
+ winningPicks,
104
+ });
105
+
106
+ const callArgs = callOnIntegrationArgs({
107
+ adapter: poolTogetherV4Adapter,
108
+ encodedCallArgs: claimRewardsArgs,
109
+ selector: claimRewardsSelector,
110
+ });
111
+
112
+ const claimTx = comptrollerProxy
113
+ .connect(fundOwner)
114
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
115
+
116
+ return claimTx;
117
+ }
@@ -1,19 +1,24 @@
1
- import { AddressLike } from '@enzymefinance/ethers';
2
- import {
3
- callOnIntegrationArgs,
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type {
4
3
  ComptrollerLib,
5
- encodeArgs,
6
4
  IntegrationManager,
7
- IntegrationManagerActionId,
8
5
  ISynthetixAddressResolver,
9
6
  StandardToken,
10
7
  SynthetixAdapter,
8
+ VaultLib,
9
+ } from '@enzymefinance/protocol';
10
+ import {
11
+ callOnIntegrationArgs,
12
+ encodeArgs,
13
+ IntegrationManagerActionId,
14
+ redeemSelector,
11
15
  synthetixAssignExchangeDelegateSelector,
16
+ synthetixRedeemArgs,
12
17
  synthetixTakeOrderArgs,
13
18
  takeOrderSelector,
14
- VaultLib,
15
19
  } from '@enzymefinance/protocol';
16
- import { BigNumberish, Signer, utils } from 'ethers';
20
+ import type { BigNumberish, Signer } from 'ethers';
21
+ import { utils } from 'ethers';
17
22
 
18
23
  export async function synthetixAssignExchangeDelegate({
19
24
  comptrollerProxy,
@@ -50,6 +55,34 @@ export async function synthetixResolveAddress({
50
55
  return addressResolver.requireAndGetAddress(utils.formatBytes32String(name), `Missing ${name}`);
51
56
  }
52
57
 
58
+ export async function synthetixRedeem({
59
+ comptrollerProxy,
60
+ integrationManager,
61
+ signer,
62
+ synthetixAdapter,
63
+ synths,
64
+ }: {
65
+ comptrollerProxy: ComptrollerLib;
66
+ integrationManager: IntegrationManager;
67
+ signer: Signer;
68
+ synthetixAdapter: SynthetixAdapter;
69
+ synths: AddressLike[];
70
+ }) {
71
+ const redeemArgs = synthetixRedeemArgs({
72
+ synths,
73
+ });
74
+
75
+ const callArgs = callOnIntegrationArgs({
76
+ adapter: synthetixAdapter,
77
+ encodedCallArgs: redeemArgs,
78
+ selector: redeemSelector,
79
+ });
80
+
81
+ return comptrollerProxy
82
+ .connect(signer)
83
+ .callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
84
+ }
85
+
53
86
  export async function synthetixTakeOrder({
54
87
  comptrollerProxy,
55
88
  vaultProxy,
@@ -79,16 +112,16 @@ export async function synthetixTakeOrder({
79
112
  }
80
113
 
81
114
  const takeOrderArgs = synthetixTakeOrderArgs({
82
- incomingAsset: incomingAsset,
83
- minIncomingAssetAmount: minIncomingAssetAmount,
84
- outgoingAsset: outgoingAsset,
85
- outgoingAssetAmount: outgoingAssetAmount,
115
+ incomingAsset,
116
+ minIncomingAssetAmount,
117
+ outgoingAsset,
118
+ outgoingAssetAmount,
86
119
  });
87
120
 
88
121
  const callArgs = await callOnIntegrationArgs({
89
122
  adapter: synthetixAdapter,
90
- selector: takeOrderSelector,
91
123
  encodedCallArgs: takeOrderArgs,
124
+ selector: takeOrderSelector,
92
125
  });
93
126
 
94
127
  return comptrollerProxy
@@ -1,9 +1,8 @@
1
- import { AddressLike } from '@enzymefinance/ethers';
2
- import { SignerWithAddress } from '@enzymefinance/hardhat';
1
+ import type { AddressLike } from '@enzymefinance/ethers';
2
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
3
+ import type { ComptrollerLib, IntegrationManager } from '@enzymefinance/protocol';
3
4
  import {
4
5
  addTrackedAssetsToVaultArgs,
5
- ComptrollerLib,
6
- IntegrationManager,
7
6
  IntegrationManagerActionId,
8
7
  removeTrackedAssetsFromVaultArgs,
9
8
  } from '@enzymefinance/protocol';
@@ -1,21 +1,25 @@
1
- import { AddressLike, Call, Contract, contract, Send } from '@enzymefinance/ethers';
2
- import { SignerWithAddress } from '@enzymefinance/hardhat';
3
- import {
4
- callOnIntegrationArgs,
1
+ import type { AddressLike, Call, Contract, Send } from '@enzymefinance/ethers';
2
+ import { contract } from '@enzymefinance/ethers';
3
+ import type { SignerWithAddress } from '@enzymefinance/hardhat';
4
+ import type {
5
5
  ComptrollerLib,
6
6
  IntegrationManager,
7
+ StandardToken,
8
+ UniswapV2ExchangeAdapter,
9
+ UniswapV2LiquidityAdapter,
10
+ VaultLib,
11
+ } from '@enzymefinance/protocol';
12
+ import {
13
+ callOnIntegrationArgs,
7
14
  IntegrationManagerActionId,
8
15
  lendSelector,
9
16
  redeemSelector,
10
- StandardToken,
11
17
  takeOrderSelector,
12
- UniswapV2Adapter,
13
18
  uniswapV2LendArgs,
14
19
  uniswapV2RedeemArgs,
15
20
  uniswapV2TakeOrderArgs,
16
- VaultLib,
17
21
  } from '@enzymefinance/protocol';
18
- import { BigNumberish } from 'ethers';
22
+ import type { BigNumberish } from 'ethers';
19
23
 
20
24
  export interface UniswapV2Factory extends Contract<UniswapV2Factory> {
21
25
  createPair: Send<(_token0: AddressLike, _token1: AddressLike) => AddressLike>;
@@ -32,7 +36,7 @@ export async function uniswapV2Lend({
32
36
  vaultProxy,
33
37
  integrationManager,
34
38
  fundOwner,
35
- uniswapV2Adapter,
39
+ uniswapV2LiquidityAdapter,
36
40
  tokenA,
37
41
  tokenB,
38
42
  amountADesired,
@@ -46,7 +50,7 @@ export async function uniswapV2Lend({
46
50
  vaultProxy: VaultLib;
47
51
  integrationManager: IntegrationManager;
48
52
  fundOwner: SignerWithAddress;
49
- uniswapV2Adapter: UniswapV2Adapter;
53
+ uniswapV2LiquidityAdapter: UniswapV2LiquidityAdapter;
50
54
  tokenA: StandardToken;
51
55
  tokenB: StandardToken;
52
56
  amountADesired: BigNumberish;
@@ -63,19 +67,19 @@ export async function uniswapV2Lend({
63
67
  }
64
68
 
65
69
  const lendArgs = uniswapV2LendArgs({
66
- tokenA,
67
- tokenB,
68
70
  amountADesired,
69
- amountBDesired,
70
71
  amountAMin,
72
+ amountBDesired,
71
73
  amountBMin,
72
74
  minPoolTokenAmount,
75
+ tokenA,
76
+ tokenB,
73
77
  });
74
78
 
75
79
  const callArgs = callOnIntegrationArgs({
76
- adapter: uniswapV2Adapter,
77
- selector: lendSelector,
80
+ adapter: uniswapV2LiquidityAdapter,
78
81
  encodedCallArgs: lendArgs,
82
+ selector: lendSelector,
79
83
  });
80
84
 
81
85
  const lendTx = comptrollerProxy
@@ -90,7 +94,7 @@ export async function uniswapV2Redeem({
90
94
  comptrollerProxy,
91
95
  integrationManager,
92
96
  fundOwner,
93
- uniswapV2Adapter,
97
+ uniswapV2LiquidityAdapter,
94
98
  poolTokenAmount,
95
99
  tokenA,
96
100
  tokenB,
@@ -100,7 +104,7 @@ export async function uniswapV2Redeem({
100
104
  comptrollerProxy: ComptrollerLib;
101
105
  integrationManager: IntegrationManager;
102
106
  fundOwner: SignerWithAddress;
103
- uniswapV2Adapter: UniswapV2Adapter;
107
+ uniswapV2LiquidityAdapter: UniswapV2LiquidityAdapter;
104
108
  poolTokenAmount: BigNumberish;
105
109
  tokenA: AddressLike;
106
110
  tokenB: AddressLike;
@@ -108,16 +112,16 @@ export async function uniswapV2Redeem({
108
112
  amountBMin: BigNumberish;
109
113
  }) {
110
114
  const redeemArgs = uniswapV2RedeemArgs({
115
+ amountAMin,
116
+ amountBMin,
111
117
  poolTokenAmount,
112
118
  tokenA,
113
119
  tokenB,
114
- amountAMin,
115
- amountBMin,
116
120
  });
117
121
  const callArgs = callOnIntegrationArgs({
118
- adapter: uniswapV2Adapter,
119
- selector: redeemSelector,
122
+ adapter: uniswapV2LiquidityAdapter,
120
123
  encodedCallArgs: redeemArgs,
124
+ selector: redeemSelector,
121
125
  });
122
126
 
123
127
  const redeemTx = comptrollerProxy
@@ -133,7 +137,7 @@ export async function uniswapV2TakeOrder({
133
137
  vaultProxy,
134
138
  integrationManager,
135
139
  fundOwner,
136
- uniswapV2Adapter,
140
+ uniswapV2ExchangeAdapter,
137
141
  path,
138
142
  outgoingAssetAmount,
139
143
  minIncomingAssetAmount,
@@ -143,7 +147,7 @@ export async function uniswapV2TakeOrder({
143
147
  vaultProxy: VaultLib;
144
148
  integrationManager: IntegrationManager;
145
149
  fundOwner: SignerWithAddress;
146
- uniswapV2Adapter: UniswapV2Adapter;
150
+ uniswapV2ExchangeAdapter: UniswapV2ExchangeAdapter;
147
151
  path: StandardToken[];
148
152
  outgoingAssetAmount: BigNumberish;
149
153
  minIncomingAssetAmount: BigNumberish;
@@ -155,14 +159,14 @@ export async function uniswapV2TakeOrder({
155
159
  }
156
160
 
157
161
  const takeOrderArgs = uniswapV2TakeOrderArgs({
158
- path,
159
- outgoingAssetAmount,
160
162
  minIncomingAssetAmount,
163
+ outgoingAssetAmount,
164
+ path,
161
165
  });
162
166
  const callArgs = callOnIntegrationArgs({
163
- adapter: uniswapV2Adapter,
164
- selector: takeOrderSelector,
167
+ adapter: uniswapV2ExchangeAdapter,
165
168
  encodedCallArgs: takeOrderArgs,
169
+ selector: takeOrderSelector,
166
170
  });
167
171
 
168
172
  return comptrollerProxy