@enzymefinance/testutils 4.0.0-next.2 → 4.0.0-next.7
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/CHANGELOG.md +32 -0
- package/dist/declarations/src/assertions.d.ts +2 -2
- package/dist/declarations/src/deployment.d.ts +172 -68
- package/dist/declarations/src/gasRelayer.d.ts +14 -12
- package/dist/declarations/src/helpers.d.ts +5 -4
- package/dist/declarations/src/scaffolding/assets.d.ts +4 -4
- package/dist/declarations/src/scaffolding/chainlink.d.ts +2 -2
- package/dist/declarations/src/scaffolding/common.d.ts +1 -1
- package/dist/declarations/src/scaffolding/core.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/common.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +8 -6
- package/dist/declarations/src/scaffolding/extensions/external-positions/compound.d.ts +5 -5
- package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +1 -0
- package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +16 -12
- package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +100 -0
- package/dist/declarations/src/scaffolding/extensions/fees.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +6 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +33 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +101 -84
- package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +6 -6
- package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +3 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/mock.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +17 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV4.d.ts +6 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV5.d.ts +23 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/poolTogetherV4.d.ts +29 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +15 -12
- package/dist/declarations/src/scaffolding/extensions/integrations/trackedAssets.d.ts +3 -3
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV2.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV3.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +5 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +4 -4
- package/dist/declarations/src/scaffolding/extensions/policies.d.ts +9 -9
- package/dist/declarations/src/scaffolding/setup.d.ts +11 -9
- package/dist/declarations/src/scaffolding/shares.d.ts +4 -4
- package/dist/declarations/src/scaffolding/vaultCalls.d.ts +11 -2
- package/dist/declarations/src/whales.d.ts +24 -19
- package/dist/enzymefinance-testutils.browser.cjs.js +1541 -673
- package/dist/enzymefinance-testutils.browser.esm.js +1502 -655
- package/dist/enzymefinance-testutils.cjs.dev.js +1541 -673
- package/dist/enzymefinance-testutils.cjs.prod.js +1541 -673
- package/dist/enzymefinance-testutils.esm.js +1502 -655
- package/package.json +6 -6
- package/src/assertions.ts +5 -2
- package/src/deployment.ts +221 -120
- package/src/gasRelayer.ts +17 -18
- package/src/helpers.ts +6 -4
- package/src/scaffolding/assets.ts +7 -6
- package/src/scaffolding/chainlink.ts +2 -2
- package/src/scaffolding/common.ts +1 -1
- package/src/scaffolding/core.ts +4 -8
- package/src/scaffolding/extensions/common.ts +4 -4
- package/src/scaffolding/extensions/external-positions/actions.ts +14 -9
- package/src/scaffolding/extensions/external-positions/compound.ts +28 -29
- package/src/scaffolding/extensions/external-positions/index.ts +1 -0
- package/src/scaffolding/extensions/external-positions/mocks.ts +32 -36
- package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +284 -0
- package/src/scaffolding/extensions/fees.ts +1 -1
- package/src/scaffolding/extensions/integrations/aave.ts +6 -8
- package/src/scaffolding/extensions/integrations/compound.ts +171 -11
- package/src/scaffolding/extensions/integrations/curve.ts +303 -255
- package/src/scaffolding/extensions/integrations/idle.ts +9 -11
- package/src/scaffolding/extensions/integrations/index.ts +3 -0
- package/src/scaffolding/extensions/integrations/mock.ts +11 -13
- package/src/scaffolding/extensions/integrations/olympusV2.ts +71 -0
- package/src/scaffolding/extensions/integrations/paraSwapV4.ts +16 -11
- package/src/scaffolding/extensions/integrations/paraSwapV5.ts +73 -0
- package/src/scaffolding/extensions/integrations/poolTogetherV4.ts +117 -0
- package/src/scaffolding/extensions/integrations/synthetix.ts +45 -31
- package/src/scaffolding/extensions/integrations/trackedAssets.ts +3 -4
- package/src/scaffolding/extensions/integrations/uniswapV2.ts +22 -19
- package/src/scaffolding/extensions/integrations/uniswapV3.ts +9 -10
- package/src/scaffolding/extensions/integrations/yearn.ts +9 -11
- package/src/scaffolding/extensions/integrations/zeroExV2.ts +9 -7
- package/src/scaffolding/extensions/policies.ts +2 -1
- package/src/scaffolding/setup.ts +27 -13
- package/src/scaffolding/shares.ts +5 -4
- package/src/scaffolding/vaultCalls.ts +32 -2
- package/src/types.d.ts +1 -0
- package/src/whales.ts +36 -18
|
@@ -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 {
|
|
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
|
-
|
|
10
|
-
callOnIntegrationArgs,
|
|
11
|
-
encodeArgs,
|
|
12
|
-
IntegrationManagerActionId,
|
|
8
|
+
VaultLib,
|
|
13
9
|
} from '@enzymefinance/protocol';
|
|
14
|
-
import {
|
|
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
|
-
|
|
98
|
-
maxSpendAssetAmounts,
|
|
95
|
+
actualIncomingAssetAmounts,
|
|
99
96
|
actualSpendAssetAmounts,
|
|
100
97
|
incomingAssets,
|
|
98
|
+
maxSpendAssetAmounts,
|
|
101
99
|
minIncomingAssetAmounts,
|
|
102
|
-
|
|
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
|
|
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, //
|
|
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,53 +1,70 @@
|
|
|
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
|
-
ISynthetixAddressResolver,
|
|
9
5
|
StandardToken,
|
|
10
6
|
SynthetixAdapter,
|
|
7
|
+
VaultLib,
|
|
8
|
+
} from '@enzymefinance/protocol';
|
|
9
|
+
import {
|
|
10
|
+
callOnIntegrationArgs,
|
|
11
|
+
encodeArgs,
|
|
12
|
+
IntegrationManagerActionId,
|
|
13
|
+
redeemSelector,
|
|
11
14
|
synthetixAssignExchangeDelegateSelector,
|
|
15
|
+
synthetixRedeemArgs,
|
|
12
16
|
synthetixTakeOrderArgs,
|
|
13
17
|
takeOrderSelector,
|
|
14
|
-
VaultLib,
|
|
15
18
|
} from '@enzymefinance/protocol';
|
|
16
|
-
import { BigNumberish, Signer
|
|
19
|
+
import type { BigNumberish, Signer } from 'ethers';
|
|
20
|
+
import { utils } from 'ethers';
|
|
17
21
|
|
|
18
22
|
export async function synthetixAssignExchangeDelegate({
|
|
19
23
|
comptrollerProxy,
|
|
20
|
-
|
|
24
|
+
synthetixDelegateApprovals,
|
|
21
25
|
fundOwner,
|
|
22
26
|
delegate,
|
|
23
27
|
}: {
|
|
24
28
|
comptrollerProxy: ComptrollerLib;
|
|
25
|
-
|
|
29
|
+
synthetixDelegateApprovals: AddressLike;
|
|
26
30
|
fundOwner: Signer;
|
|
27
31
|
delegate: AddressLike;
|
|
28
32
|
}) {
|
|
29
|
-
const delegateApprovals = await synthetixResolveAddress({
|
|
30
|
-
addressResolver,
|
|
31
|
-
name: 'DelegateApprovals',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
33
|
await comptrollerProxy
|
|
35
34
|
.connect(fundOwner)
|
|
36
35
|
.vaultCallOnContract(
|
|
37
|
-
|
|
36
|
+
synthetixDelegateApprovals,
|
|
38
37
|
synthetixAssignExchangeDelegateSelector,
|
|
39
38
|
encodeArgs(['address'], [delegate]),
|
|
40
39
|
);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
export async function
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
export async function synthetixRedeem({
|
|
43
|
+
comptrollerProxy,
|
|
44
|
+
integrationManager,
|
|
45
|
+
signer,
|
|
46
|
+
synthetixAdapter,
|
|
47
|
+
synths,
|
|
46
48
|
}: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
comptrollerProxy: ComptrollerLib;
|
|
50
|
+
integrationManager: IntegrationManager;
|
|
51
|
+
signer: Signer;
|
|
52
|
+
synthetixAdapter: SynthetixAdapter;
|
|
53
|
+
synths: AddressLike[];
|
|
49
54
|
}) {
|
|
50
|
-
|
|
55
|
+
const redeemArgs = synthetixRedeemArgs({
|
|
56
|
+
synths,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const callArgs = callOnIntegrationArgs({
|
|
60
|
+
adapter: synthetixAdapter,
|
|
61
|
+
encodedCallArgs: redeemArgs,
|
|
62
|
+
selector: redeemSelector,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return comptrollerProxy
|
|
66
|
+
.connect(signer)
|
|
67
|
+
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
|
51
68
|
}
|
|
52
69
|
|
|
53
70
|
export async function synthetixTakeOrder({
|
|
@@ -58,8 +75,7 @@ export async function synthetixTakeOrder({
|
|
|
58
75
|
synthetixAdapter,
|
|
59
76
|
outgoingAsset,
|
|
60
77
|
outgoingAssetAmount = utils.parseEther('1'),
|
|
61
|
-
|
|
62
|
-
minIncomingAssetAmount = utils.parseEther('1'),
|
|
78
|
+
minIncomingSusdAmount = utils.parseEther('1'),
|
|
63
79
|
seedFund = false,
|
|
64
80
|
}: {
|
|
65
81
|
comptrollerProxy: ComptrollerLib;
|
|
@@ -69,8 +85,7 @@ export async function synthetixTakeOrder({
|
|
|
69
85
|
synthetixAdapter: SynthetixAdapter;
|
|
70
86
|
outgoingAsset: StandardToken;
|
|
71
87
|
outgoingAssetAmount?: BigNumberish;
|
|
72
|
-
|
|
73
|
-
minIncomingAssetAmount?: BigNumberish;
|
|
88
|
+
minIncomingSusdAmount?: BigNumberish;
|
|
74
89
|
seedFund?: boolean;
|
|
75
90
|
}) {
|
|
76
91
|
if (seedFund) {
|
|
@@ -79,16 +94,15 @@ export async function synthetixTakeOrder({
|
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
const takeOrderArgs = synthetixTakeOrderArgs({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
outgoingAssetAmount: outgoingAssetAmount,
|
|
97
|
+
minIncomingSusdAmount,
|
|
98
|
+
outgoingAsset,
|
|
99
|
+
outgoingAssetAmount,
|
|
86
100
|
});
|
|
87
101
|
|
|
88
102
|
const callArgs = await callOnIntegrationArgs({
|
|
89
103
|
adapter: synthetixAdapter,
|
|
90
|
-
selector: takeOrderSelector,
|
|
91
104
|
encodedCallArgs: takeOrderArgs,
|
|
105
|
+
selector: takeOrderSelector,
|
|
92
106
|
});
|
|
93
107
|
|
|
94
108
|
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,22 +1,25 @@
|
|
|
1
|
-
import { AddressLike, Call, Contract,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
UniswapV2ExchangeAdapter,
|
|
13
|
-
UniswapV2LiquidityAdapter,
|
|
14
18
|
uniswapV2LendArgs,
|
|
15
19
|
uniswapV2RedeemArgs,
|
|
16
20
|
uniswapV2TakeOrderArgs,
|
|
17
|
-
VaultLib,
|
|
18
21
|
} from '@enzymefinance/protocol';
|
|
19
|
-
import { BigNumberish } from 'ethers';
|
|
22
|
+
import type { BigNumberish } from 'ethers';
|
|
20
23
|
|
|
21
24
|
export interface UniswapV2Factory extends Contract<UniswapV2Factory> {
|
|
22
25
|
createPair: Send<(_token0: AddressLike, _token1: AddressLike) => AddressLike>;
|
|
@@ -64,19 +67,19 @@ export async function uniswapV2Lend({
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
const lendArgs = uniswapV2LendArgs({
|
|
67
|
-
tokenA,
|
|
68
|
-
tokenB,
|
|
69
70
|
amountADesired,
|
|
70
|
-
amountBDesired,
|
|
71
71
|
amountAMin,
|
|
72
|
+
amountBDesired,
|
|
72
73
|
amountBMin,
|
|
73
74
|
minPoolTokenAmount,
|
|
75
|
+
tokenA,
|
|
76
|
+
tokenB,
|
|
74
77
|
});
|
|
75
78
|
|
|
76
79
|
const callArgs = callOnIntegrationArgs({
|
|
77
80
|
adapter: uniswapV2LiquidityAdapter,
|
|
78
|
-
selector: lendSelector,
|
|
79
81
|
encodedCallArgs: lendArgs,
|
|
82
|
+
selector: lendSelector,
|
|
80
83
|
});
|
|
81
84
|
|
|
82
85
|
const lendTx = comptrollerProxy
|
|
@@ -109,16 +112,16 @@ export async function uniswapV2Redeem({
|
|
|
109
112
|
amountBMin: BigNumberish;
|
|
110
113
|
}) {
|
|
111
114
|
const redeemArgs = uniswapV2RedeemArgs({
|
|
115
|
+
amountAMin,
|
|
116
|
+
amountBMin,
|
|
112
117
|
poolTokenAmount,
|
|
113
118
|
tokenA,
|
|
114
119
|
tokenB,
|
|
115
|
-
amountAMin,
|
|
116
|
-
amountBMin,
|
|
117
120
|
});
|
|
118
121
|
const callArgs = callOnIntegrationArgs({
|
|
119
122
|
adapter: uniswapV2LiquidityAdapter,
|
|
120
|
-
selector: redeemSelector,
|
|
121
123
|
encodedCallArgs: redeemArgs,
|
|
124
|
+
selector: redeemSelector,
|
|
122
125
|
});
|
|
123
126
|
|
|
124
127
|
const redeemTx = comptrollerProxy
|
|
@@ -156,14 +159,14 @@ export async function uniswapV2TakeOrder({
|
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
const takeOrderArgs = uniswapV2TakeOrderArgs({
|
|
159
|
-
path,
|
|
160
|
-
outgoingAssetAmount,
|
|
161
162
|
minIncomingAssetAmount,
|
|
163
|
+
outgoingAssetAmount,
|
|
164
|
+
path,
|
|
162
165
|
});
|
|
163
166
|
const callArgs = callOnIntegrationArgs({
|
|
164
167
|
adapter: uniswapV2ExchangeAdapter,
|
|
165
|
-
selector: takeOrderSelector,
|
|
166
168
|
encodedCallArgs: takeOrderArgs,
|
|
169
|
+
selector: takeOrderSelector,
|
|
167
170
|
});
|
|
168
171
|
|
|
169
172
|
return comptrollerProxy
|