@enzymefinance/testutils 4.0.0-next.7 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +1553 -0
- package/dist/index.js +3352 -0
- package/dist/index.mjs +3352 -0
- package/package.json +74 -11
- package/CHANGELOG.md +0 -60
- package/dist/declarations/src/assertions.d.ts +0 -4
- package/dist/declarations/src/deployment.d.ts +0 -195
- package/dist/declarations/src/gasRelayer.d.ts +0 -56
- package/dist/declarations/src/helpers.d.ts +0 -16
- package/dist/declarations/src/index.d.ts +0 -6
- package/dist/declarations/src/scaffolding/assets.d.ts +0 -10
- package/dist/declarations/src/scaffolding/chainlink.d.ts +0 -3
- package/dist/declarations/src/scaffolding/common.d.ts +0 -7
- package/dist/declarations/src/scaffolding/core.d.ts +0 -16
- package/dist/declarations/src/scaffolding/extensions/common.d.ts +0 -11
- package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +0 -36
- package/dist/declarations/src/scaffolding/extensions/external-positions/compound.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +0 -4
- package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +0 -100
- package/dist/declarations/src/scaffolding/extensions/fees.d.ts +0 -12
- package/dist/declarations/src/scaffolding/extensions/index.d.ts +0 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +0 -20
- package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +0 -56
- package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +0 -288
- package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +0 -28
- package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +0 -15
- package/dist/declarations/src/scaffolding/extensions/integrations/mock.d.ts +0 -32
- package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +0 -17
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV4.d.ts +0 -23
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV5.d.ts +0 -23
- package/dist/declarations/src/scaffolding/extensions/integrations/poolTogetherV4.d.ts +0 -29
- package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +0 -28
- package/dist/declarations/src/scaffolding/extensions/integrations/trackedAssets.d.ts +0 -15
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV2.d.ts +0 -46
- package/dist/declarations/src/scaffolding/extensions/integrations/uniswapV3.d.ts +0 -15
- package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +0 -22
- package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +0 -12
- package/dist/declarations/src/scaffolding/extensions/policies.d.ts +0 -17
- package/dist/declarations/src/scaffolding/index.d.ts +0 -8
- package/dist/declarations/src/scaffolding/setup.d.ts +0 -77
- package/dist/declarations/src/scaffolding/shares.d.ts +0 -35
- package/dist/declarations/src/scaffolding/vaultCalls.d.ts +0 -32
- package/dist/declarations/src/whales.d.ts +0 -49
- package/dist/enzymefinance-testutils.browser.cjs.js +0 -4428
- package/dist/enzymefinance-testutils.browser.esm.js +0 -4281
- package/dist/enzymefinance-testutils.cjs.d.ts +0 -1
- package/dist/enzymefinance-testutils.cjs.dev.js +0 -4428
- package/dist/enzymefinance-testutils.cjs.js +0 -7
- package/dist/enzymefinance-testutils.cjs.prod.js +0 -4428
- package/dist/enzymefinance-testutils.esm.js +0 -4281
- package/src/assertions.ts +0 -23
- package/src/deployment.ts +0 -289
- package/src/gasRelayer.ts +0 -95
- package/src/helpers.ts +0 -39
- package/src/index.ts +0 -6
- package/src/scaffolding/assets.ts +0 -37
- package/src/scaffolding/chainlink.ts +0 -8
- package/src/scaffolding/common.ts +0 -11
- package/src/scaffolding/core.ts +0 -103
- package/src/scaffolding/extensions/common.ts +0 -30
- package/src/scaffolding/extensions/external-positions/actions.ts +0 -108
- package/src/scaffolding/extensions/external-positions/compound.ts +0 -190
- package/src/scaffolding/extensions/external-positions/index.ts +0 -4
- package/src/scaffolding/extensions/external-positions/mocks.ts +0 -191
- package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +0 -284
- package/src/scaffolding/extensions/fees.ts +0 -70
- package/src/scaffolding/extensions/index.ts +0 -5
- package/src/scaffolding/extensions/integrations/aave.ts +0 -78
- package/src/scaffolding/extensions/integrations/compound.ts +0 -255
- package/src/scaffolding/extensions/integrations/curve.ts +0 -1029
- package/src/scaffolding/extensions/integrations/idle.ts +0 -104
- package/src/scaffolding/extensions/integrations/index.ts +0 -15
- package/src/scaffolding/extensions/integrations/mock.ts +0 -116
- package/src/scaffolding/extensions/integrations/olympusV2.ts +0 -71
- package/src/scaffolding/extensions/integrations/paraSwapV4.ts +0 -70
- package/src/scaffolding/extensions/integrations/paraSwapV5.ts +0 -73
- package/src/scaffolding/extensions/integrations/poolTogetherV4.ts +0 -117
- package/src/scaffolding/extensions/integrations/synthetix.ts +0 -111
- package/src/scaffolding/extensions/integrations/trackedAssets.ts +0 -48
- package/src/scaffolding/extensions/integrations/uniswapV2.ts +0 -175
- package/src/scaffolding/extensions/integrations/uniswapV3.ts +0 -55
- package/src/scaffolding/extensions/integrations/yearn.ts +0 -79
- package/src/scaffolding/extensions/integrations/zeroExV2.ts +0 -47
- package/src/scaffolding/extensions/policies.ts +0 -112
- package/src/scaffolding/index.ts +0 -8
- package/src/scaffolding/setup.ts +0 -243
- package/src/scaffolding/shares.ts +0 -80
- package/src/scaffolding/vaultCalls.ts +0 -105
- package/src/types.d.ts +0 -2
- package/src/whales.ts +0 -82
- package/tsconfig.json +0 -5
@@ -1,104 +0,0 @@
|
|
1
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
2
|
-
import type { ComptrollerLib, IdleAdapter, IntegrationManager, StandardToken } from '@enzymefinance/protocol';
|
3
|
-
import {
|
4
|
-
callOnIntegrationArgs,
|
5
|
-
claimRewardsSelector,
|
6
|
-
idleClaimRewardsArgs,
|
7
|
-
idleLendArgs,
|
8
|
-
idleRedeemArgs,
|
9
|
-
IntegrationManagerActionId,
|
10
|
-
lendSelector,
|
11
|
-
redeemSelector,
|
12
|
-
} from '@enzymefinance/protocol';
|
13
|
-
import type { BigNumberish } from 'ethers';
|
14
|
-
import { BigNumber } from 'ethers';
|
15
|
-
|
16
|
-
export async function idleClaimRewards({
|
17
|
-
comptrollerProxy,
|
18
|
-
integrationManager,
|
19
|
-
fundOwner,
|
20
|
-
idleAdapter,
|
21
|
-
idleToken,
|
22
|
-
}: {
|
23
|
-
comptrollerProxy: ComptrollerLib;
|
24
|
-
integrationManager: IntegrationManager;
|
25
|
-
fundOwner: SignerWithAddress;
|
26
|
-
idleAdapter: IdleAdapter;
|
27
|
-
idleToken: StandardToken;
|
28
|
-
}) {
|
29
|
-
const callArgs = callOnIntegrationArgs({
|
30
|
-
adapter: idleAdapter,
|
31
|
-
encodedCallArgs: idleClaimRewardsArgs({
|
32
|
-
idleToken,
|
33
|
-
}),
|
34
|
-
selector: claimRewardsSelector,
|
35
|
-
});
|
36
|
-
|
37
|
-
return comptrollerProxy
|
38
|
-
.connect(fundOwner)
|
39
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
40
|
-
}
|
41
|
-
|
42
|
-
export async function idleLend({
|
43
|
-
comptrollerProxy,
|
44
|
-
integrationManager,
|
45
|
-
fundOwner,
|
46
|
-
idleAdapter,
|
47
|
-
idleToken,
|
48
|
-
outgoingUnderlyingAmount,
|
49
|
-
minIncomingIdleTokenAmount = BigNumber.from(1),
|
50
|
-
}: {
|
51
|
-
comptrollerProxy: ComptrollerLib;
|
52
|
-
integrationManager: IntegrationManager;
|
53
|
-
fundOwner: SignerWithAddress;
|
54
|
-
idleAdapter: IdleAdapter;
|
55
|
-
idleToken: StandardToken;
|
56
|
-
outgoingUnderlyingAmount: BigNumberish;
|
57
|
-
minIncomingIdleTokenAmount?: BigNumberish;
|
58
|
-
}) {
|
59
|
-
const callArgs = callOnIntegrationArgs({
|
60
|
-
adapter: idleAdapter,
|
61
|
-
encodedCallArgs: idleLendArgs({
|
62
|
-
idleToken,
|
63
|
-
minIncomingIdleTokenAmount,
|
64
|
-
outgoingUnderlyingAmount,
|
65
|
-
}),
|
66
|
-
selector: lendSelector,
|
67
|
-
});
|
68
|
-
|
69
|
-
return comptrollerProxy
|
70
|
-
.connect(fundOwner)
|
71
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
72
|
-
}
|
73
|
-
|
74
|
-
export async function idleRedeem({
|
75
|
-
comptrollerProxy,
|
76
|
-
integrationManager,
|
77
|
-
fundOwner,
|
78
|
-
idleAdapter,
|
79
|
-
idleToken,
|
80
|
-
outgoingIdleTokenAmount,
|
81
|
-
minIncomingUnderlyingAmount = BigNumber.from(1),
|
82
|
-
}: {
|
83
|
-
comptrollerProxy: ComptrollerLib;
|
84
|
-
integrationManager: IntegrationManager;
|
85
|
-
fundOwner: SignerWithAddress;
|
86
|
-
idleAdapter: IdleAdapter;
|
87
|
-
idleToken: StandardToken;
|
88
|
-
outgoingIdleTokenAmount: BigNumberish;
|
89
|
-
minIncomingUnderlyingAmount?: BigNumberish;
|
90
|
-
}) {
|
91
|
-
const callArgs = callOnIntegrationArgs({
|
92
|
-
adapter: idleAdapter,
|
93
|
-
encodedCallArgs: idleRedeemArgs({
|
94
|
-
idleToken,
|
95
|
-
minIncomingUnderlyingAmount,
|
96
|
-
outgoingIdleTokenAmount,
|
97
|
-
}),
|
98
|
-
selector: redeemSelector,
|
99
|
-
});
|
100
|
-
|
101
|
-
return comptrollerProxy
|
102
|
-
.connect(fundOwner)
|
103
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
104
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
export * from './aave';
|
2
|
-
export * from './compound';
|
3
|
-
export * from './curve';
|
4
|
-
export * from './idle';
|
5
|
-
export * from './mock';
|
6
|
-
export * from './olympusV2';
|
7
|
-
export * from './paraSwapV4';
|
8
|
-
export * from './paraSwapV5';
|
9
|
-
export * from './poolTogetherV4';
|
10
|
-
export * from './synthetix';
|
11
|
-
export * from './trackedAssets';
|
12
|
-
export * from './uniswapV2';
|
13
|
-
export * from './uniswapV3';
|
14
|
-
export * from './yearn';
|
15
|
-
export * from './zeroExV2';
|
@@ -1,116 +0,0 @@
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
3
|
-
import type {
|
4
|
-
ComptrollerLib,
|
5
|
-
IntegrationManager,
|
6
|
-
MockGenericAdapter,
|
7
|
-
StandardToken,
|
8
|
-
VaultLib,
|
9
|
-
} from '@enzymefinance/protocol';
|
10
|
-
import { callOnIntegrationArgs, encodeArgs, IntegrationManagerActionId, sighash } from '@enzymefinance/protocol';
|
11
|
-
import type { BigNumberish, BytesLike } from 'ethers';
|
12
|
-
import { utils } from 'ethers';
|
13
|
-
|
14
|
-
export const mockGenericRemoveOnlySelector = sighash(
|
15
|
-
utils.FunctionFragment.fromString('removeOnly(address,bytes,bytes)'),
|
16
|
-
);
|
17
|
-
|
18
|
-
export const mockGenericSwapASelector = sighash(utils.FunctionFragment.fromString('swapA(address,bytes,bytes)'));
|
19
|
-
|
20
|
-
export const mockGenericSwapBSelector = sighash(utils.FunctionFragment.fromString('swapB(address,bytes,bytes)'));
|
21
|
-
|
22
|
-
export const mockGenericSwapDirectFromVaultSelector = sighash(
|
23
|
-
utils.FunctionFragment.fromString('swapDirectFromVault(address,bytes,bytes)'),
|
24
|
-
);
|
25
|
-
|
26
|
-
export const mockGenericSwapViaApprovalSelector = sighash(
|
27
|
-
utils.FunctionFragment.fromString('swapViaApproval(address,bytes,bytes)'),
|
28
|
-
);
|
29
|
-
|
30
|
-
export function mockGenericSwapArgs({
|
31
|
-
spendAssets = [],
|
32
|
-
actualSpendAssetAmounts = [],
|
33
|
-
maxSpendAssetAmounts = actualSpendAssetAmounts,
|
34
|
-
incomingAssets = [],
|
35
|
-
actualIncomingAssetAmounts = [],
|
36
|
-
minIncomingAssetAmounts = actualIncomingAssetAmounts,
|
37
|
-
}: {
|
38
|
-
spendAssets?: AddressLike[];
|
39
|
-
maxSpendAssetAmounts?: BigNumberish[];
|
40
|
-
actualSpendAssetAmounts?: BigNumberish[];
|
41
|
-
incomingAssets?: AddressLike[];
|
42
|
-
minIncomingAssetAmounts?: BigNumberish[];
|
43
|
-
actualIncomingAssetAmounts?: BigNumberish[];
|
44
|
-
}) {
|
45
|
-
return encodeArgs(
|
46
|
-
['address[]', 'uint256[]', 'uint256[]', 'address[]', 'uint256[]', 'uint256[]'],
|
47
|
-
[
|
48
|
-
spendAssets,
|
49
|
-
maxSpendAssetAmounts,
|
50
|
-
actualSpendAssetAmounts,
|
51
|
-
incomingAssets,
|
52
|
-
minIncomingAssetAmounts,
|
53
|
-
actualIncomingAssetAmounts,
|
54
|
-
],
|
55
|
-
);
|
56
|
-
}
|
57
|
-
|
58
|
-
export async function mockGenericSwap({
|
59
|
-
comptrollerProxy,
|
60
|
-
vaultProxy,
|
61
|
-
integrationManager,
|
62
|
-
fundOwner,
|
63
|
-
mockGenericAdapter,
|
64
|
-
selector = mockGenericSwapASelector,
|
65
|
-
spendAssets = [],
|
66
|
-
actualSpendAssetAmounts = [],
|
67
|
-
maxSpendAssetAmounts = actualSpendAssetAmounts,
|
68
|
-
incomingAssets = [],
|
69
|
-
actualIncomingAssetAmounts = [],
|
70
|
-
minIncomingAssetAmounts = actualIncomingAssetAmounts,
|
71
|
-
seedFund = false,
|
72
|
-
}: {
|
73
|
-
comptrollerProxy: ComptrollerLib;
|
74
|
-
vaultProxy: VaultLib;
|
75
|
-
integrationManager: IntegrationManager;
|
76
|
-
fundOwner: SignerWithAddress;
|
77
|
-
mockGenericAdapter: MockGenericAdapter;
|
78
|
-
selector?: BytesLike;
|
79
|
-
spendAssets?: StandardToken[];
|
80
|
-
maxSpendAssetAmounts?: BigNumberish[];
|
81
|
-
actualSpendAssetAmounts?: BigNumberish[];
|
82
|
-
incomingAssets?: StandardToken[];
|
83
|
-
minIncomingAssetAmounts?: BigNumberish[];
|
84
|
-
actualIncomingAssetAmounts?: BigNumberish[];
|
85
|
-
seedFund?: boolean;
|
86
|
-
}) {
|
87
|
-
// Seed the VaultProxy with enough spendAssets for the tx
|
88
|
-
if (seedFund) {
|
89
|
-
for (const key in spendAssets) {
|
90
|
-
await spendAssets[key].transfer(vaultProxy, maxSpendAssetAmounts[key]);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
const swapArgs = mockGenericSwapArgs({
|
95
|
-
actualIncomingAssetAmounts,
|
96
|
-
actualSpendAssetAmounts,
|
97
|
-
incomingAssets,
|
98
|
-
maxSpendAssetAmounts,
|
99
|
-
minIncomingAssetAmounts,
|
100
|
-
spendAssets,
|
101
|
-
});
|
102
|
-
|
103
|
-
const callArgs = callOnIntegrationArgs({
|
104
|
-
adapter: mockGenericAdapter,
|
105
|
-
encodedCallArgs: swapArgs,
|
106
|
-
selector,
|
107
|
-
});
|
108
|
-
|
109
|
-
const swapTx = comptrollerProxy
|
110
|
-
.connect(fundOwner)
|
111
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
112
|
-
|
113
|
-
await expect(swapTx).resolves.toBeReceipt();
|
114
|
-
|
115
|
-
return swapTx;
|
116
|
-
}
|
@@ -1,71 +0,0 @@
|
|
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,70 +0,0 @@
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
3
|
-
import type {
|
4
|
-
ComptrollerLib,
|
5
|
-
IntegrationManager,
|
6
|
-
ParaSwapV4Adapter,
|
7
|
-
ParaSwapV4Path,
|
8
|
-
StandardToken,
|
9
|
-
} from '@enzymefinance/protocol';
|
10
|
-
import {
|
11
|
-
callOnIntegrationArgs,
|
12
|
-
IntegrationManagerActionId,
|
13
|
-
paraSwapV4TakeOrderArgs,
|
14
|
-
takeOrderSelector,
|
15
|
-
} from '@enzymefinance/protocol';
|
16
|
-
import type { BigNumberish } from 'ethers';
|
17
|
-
import { utils } from 'ethers';
|
18
|
-
|
19
|
-
// ParaSwapV4Path
|
20
|
-
export function paraSwapV4GenerateDummyPaths({ toTokens }: { toTokens: AddressLike[] }) {
|
21
|
-
return toTokens.map((toToken) => {
|
22
|
-
return {
|
23
|
-
// Not supported in our protocol
|
24
|
-
routes: [],
|
25
|
-
|
26
|
-
to: toToken,
|
27
|
-
totalNetworkFee: 0, // Can ignore this param in the dummy
|
28
|
-
};
|
29
|
-
});
|
30
|
-
}
|
31
|
-
|
32
|
-
export async function paraSwapV4TakeOrder({
|
33
|
-
comptrollerProxy,
|
34
|
-
integrationManager,
|
35
|
-
fundOwner,
|
36
|
-
paraSwapV4Adapter,
|
37
|
-
outgoingAsset,
|
38
|
-
outgoingAssetAmount = utils.parseEther('1'),
|
39
|
-
minIncomingAssetAmount = 1,
|
40
|
-
expectedIncomingAssetAmount = minIncomingAssetAmount,
|
41
|
-
paths,
|
42
|
-
}: {
|
43
|
-
comptrollerProxy: ComptrollerLib;
|
44
|
-
integrationManager: IntegrationManager;
|
45
|
-
fundOwner: SignerWithAddress;
|
46
|
-
paraSwapV4Adapter: ParaSwapV4Adapter;
|
47
|
-
outgoingAsset: StandardToken;
|
48
|
-
outgoingAssetAmount?: BigNumberish;
|
49
|
-
minIncomingAssetAmount?: BigNumberish;
|
50
|
-
expectedIncomingAssetAmount?: BigNumberish;
|
51
|
-
paths: ParaSwapV4Path[];
|
52
|
-
}) {
|
53
|
-
const takeOrderArgs = paraSwapV4TakeOrderArgs({
|
54
|
-
expectedIncomingAssetAmount,
|
55
|
-
minIncomingAssetAmount,
|
56
|
-
outgoingAsset,
|
57
|
-
outgoingAssetAmount,
|
58
|
-
paths,
|
59
|
-
});
|
60
|
-
|
61
|
-
const callArgs = callOnIntegrationArgs({
|
62
|
-
adapter: paraSwapV4Adapter,
|
63
|
-
encodedCallArgs: takeOrderArgs,
|
64
|
-
selector: takeOrderSelector,
|
65
|
-
});
|
66
|
-
|
67
|
-
return comptrollerProxy
|
68
|
-
.connect(fundOwner)
|
69
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
70
|
-
}
|
@@ -1,73 +0,0 @@
|
|
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
|
-
}
|
@@ -1,117 +0,0 @@
|
|
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,111 +0,0 @@
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
2
|
-
import type {
|
3
|
-
ComptrollerLib,
|
4
|
-
IntegrationManager,
|
5
|
-
StandardToken,
|
6
|
-
SynthetixAdapter,
|
7
|
-
VaultLib,
|
8
|
-
} from '@enzymefinance/protocol';
|
9
|
-
import {
|
10
|
-
callOnIntegrationArgs,
|
11
|
-
encodeArgs,
|
12
|
-
IntegrationManagerActionId,
|
13
|
-
redeemSelector,
|
14
|
-
synthetixAssignExchangeDelegateSelector,
|
15
|
-
synthetixRedeemArgs,
|
16
|
-
synthetixTakeOrderArgs,
|
17
|
-
takeOrderSelector,
|
18
|
-
} from '@enzymefinance/protocol';
|
19
|
-
import type { BigNumberish, Signer } from 'ethers';
|
20
|
-
import { utils } from 'ethers';
|
21
|
-
|
22
|
-
export async function synthetixAssignExchangeDelegate({
|
23
|
-
comptrollerProxy,
|
24
|
-
synthetixDelegateApprovals,
|
25
|
-
fundOwner,
|
26
|
-
delegate,
|
27
|
-
}: {
|
28
|
-
comptrollerProxy: ComptrollerLib;
|
29
|
-
synthetixDelegateApprovals: AddressLike;
|
30
|
-
fundOwner: Signer;
|
31
|
-
delegate: AddressLike;
|
32
|
-
}) {
|
33
|
-
await comptrollerProxy
|
34
|
-
.connect(fundOwner)
|
35
|
-
.vaultCallOnContract(
|
36
|
-
synthetixDelegateApprovals,
|
37
|
-
synthetixAssignExchangeDelegateSelector,
|
38
|
-
encodeArgs(['address'], [delegate]),
|
39
|
-
);
|
40
|
-
}
|
41
|
-
|
42
|
-
export async function synthetixRedeem({
|
43
|
-
comptrollerProxy,
|
44
|
-
integrationManager,
|
45
|
-
signer,
|
46
|
-
synthetixAdapter,
|
47
|
-
synths,
|
48
|
-
}: {
|
49
|
-
comptrollerProxy: ComptrollerLib;
|
50
|
-
integrationManager: IntegrationManager;
|
51
|
-
signer: Signer;
|
52
|
-
synthetixAdapter: SynthetixAdapter;
|
53
|
-
synths: AddressLike[];
|
54
|
-
}) {
|
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);
|
68
|
-
}
|
69
|
-
|
70
|
-
export async function synthetixTakeOrder({
|
71
|
-
comptrollerProxy,
|
72
|
-
vaultProxy,
|
73
|
-
integrationManager,
|
74
|
-
fundOwner,
|
75
|
-
synthetixAdapter,
|
76
|
-
outgoingAsset,
|
77
|
-
outgoingAssetAmount = utils.parseEther('1'),
|
78
|
-
minIncomingSusdAmount = utils.parseEther('1'),
|
79
|
-
seedFund = false,
|
80
|
-
}: {
|
81
|
-
comptrollerProxy: ComptrollerLib;
|
82
|
-
vaultProxy: VaultLib;
|
83
|
-
integrationManager: IntegrationManager;
|
84
|
-
fundOwner: Signer;
|
85
|
-
synthetixAdapter: SynthetixAdapter;
|
86
|
-
outgoingAsset: StandardToken;
|
87
|
-
outgoingAssetAmount?: BigNumberish;
|
88
|
-
minIncomingSusdAmount?: BigNumberish;
|
89
|
-
seedFund?: boolean;
|
90
|
-
}) {
|
91
|
-
if (seedFund) {
|
92
|
-
// Seed the VaultProxy with enough outgoingAsset for the tx
|
93
|
-
await outgoingAsset.transfer(vaultProxy, outgoingAssetAmount);
|
94
|
-
}
|
95
|
-
|
96
|
-
const takeOrderArgs = synthetixTakeOrderArgs({
|
97
|
-
minIncomingSusdAmount,
|
98
|
-
outgoingAsset,
|
99
|
-
outgoingAssetAmount,
|
100
|
-
});
|
101
|
-
|
102
|
-
const callArgs = await callOnIntegrationArgs({
|
103
|
-
adapter: synthetixAdapter,
|
104
|
-
encodedCallArgs: takeOrderArgs,
|
105
|
-
selector: takeOrderSelector,
|
106
|
-
});
|
107
|
-
|
108
|
-
return comptrollerProxy
|
109
|
-
.connect(fundOwner)
|
110
|
-
.callOnExtension(integrationManager, IntegrationManagerActionId.CallOnIntegration, callArgs);
|
111
|
-
}
|