@enzymefinance/testutils 4.0.0-next.5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +40 -0
- package/dist/declarations/src/deployment.d.ts +34 -27
- package/dist/declarations/src/scaffolding/assets.d.ts +1 -1
- package/dist/declarations/src/scaffolding/core.d.ts +2 -3
- package/dist/declarations/src/scaffolding/extensions/external-positions/aave-debt.d.ts +51 -0
- package/dist/declarations/src/scaffolding/extensions/external-positions/actions.d.ts +2 -1
- package/dist/declarations/src/scaffolding/extensions/external-positions/index.d.ts +1 -0
- package/dist/declarations/src/scaffolding/extensions/external-positions/mocks.d.ts +4 -1
- package/dist/declarations/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.d.ts +12 -11
- package/dist/declarations/src/scaffolding/extensions/fees.d.ts +3 -3
- package/dist/declarations/src/scaffolding/extensions/integrations/aave.d.ts +2 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/compound.d.ts +30 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/curve.d.ts +63 -229
- package/dist/declarations/src/scaffolding/extensions/integrations/idle.d.ts +3 -3
- package/dist/declarations/src/scaffolding/extensions/integrations/index.d.ts +1 -1
- package/dist/declarations/src/scaffolding/extensions/integrations/olympusV2.d.ts +17 -0
- package/dist/declarations/src/scaffolding/extensions/integrations/synthetix.d.ts +5 -10
- package/dist/declarations/src/scaffolding/extensions/integrations/yearn.d.ts +2 -2
- package/dist/declarations/src/scaffolding/extensions/integrations/zeroExV2.d.ts +1 -1
- package/dist/declarations/src/scaffolding/extensions/policies.d.ts +8 -8
- package/dist/declarations/src/whales.d.ts +12 -5
- package/dist/enzymefinance-testutils.browser.cjs.js +826 -721
- package/dist/enzymefinance-testutils.browser.esm.js +809 -692
- package/dist/enzymefinance-testutils.cjs.dev.js +826 -721
- package/dist/enzymefinance-testutils.cjs.prod.js +826 -721
- package/dist/enzymefinance-testutils.esm.js +809 -692
- package/package.json +6 -6
- package/src/deployment.ts +39 -31
- package/src/scaffolding/assets.ts +1 -1
- package/src/scaffolding/core.ts +3 -9
- package/src/scaffolding/extensions/external-positions/aave-debt.ts +179 -0
- package/src/scaffolding/extensions/external-positions/actions.ts +6 -1
- package/src/scaffolding/extensions/external-positions/index.ts +1 -0
- package/src/scaffolding/extensions/external-positions/mocks.ts +7 -10
- package/src/scaffolding/extensions/external-positions/uniswap-v3-liquidity.ts +18 -24
- package/src/scaffolding/extensions/integrations/compound.ts +163 -2
- package/src/scaffolding/extensions/integrations/curve.ts +152 -783
- package/src/scaffolding/extensions/integrations/index.ts +1 -1
- package/src/scaffolding/extensions/integrations/olympusV2.ts +71 -0
- package/src/scaffolding/extensions/integrations/synthetix.ts +6 -25
- package/src/types.d.ts +1 -0
- package/src/whales.ts +14 -5
- package/dist/declarations/src/scaffolding/extensions/integrations/paraSwapV4.d.ts +0 -23
- package/src/scaffolding/extensions/integrations/paraSwapV4.ts +0 -70
@@ -3,7 +3,7 @@ export * from './compound';
|
|
3
3
|
export * from './curve';
|
4
4
|
export * from './idle';
|
5
5
|
export * from './mock';
|
6
|
-
export * from './
|
6
|
+
export * from './olympusV2';
|
7
7
|
export * from './paraSwapV5';
|
8
8
|
export * from './poolTogetherV4';
|
9
9
|
export * from './synthetix';
|
@@ -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
|
+
}
|
@@ -2,7 +2,6 @@ import type { AddressLike } from '@enzymefinance/ethers';
|
|
2
2
|
import type {
|
3
3
|
ComptrollerLib,
|
4
4
|
IntegrationManager,
|
5
|
-
ISynthetixAddressResolver,
|
6
5
|
StandardToken,
|
7
6
|
SynthetixAdapter,
|
8
7
|
VaultLib,
|
@@ -22,39 +21,24 @@ import { utils } from 'ethers';
|
|
22
21
|
|
23
22
|
export async function synthetixAssignExchangeDelegate({
|
24
23
|
comptrollerProxy,
|
25
|
-
|
24
|
+
synthetixDelegateApprovals,
|
26
25
|
fundOwner,
|
27
26
|
delegate,
|
28
27
|
}: {
|
29
28
|
comptrollerProxy: ComptrollerLib;
|
30
|
-
|
29
|
+
synthetixDelegateApprovals: AddressLike;
|
31
30
|
fundOwner: Signer;
|
32
31
|
delegate: AddressLike;
|
33
32
|
}) {
|
34
|
-
const delegateApprovals = await synthetixResolveAddress({
|
35
|
-
addressResolver,
|
36
|
-
name: 'DelegateApprovals',
|
37
|
-
});
|
38
|
-
|
39
33
|
await comptrollerProxy
|
40
34
|
.connect(fundOwner)
|
41
35
|
.vaultCallOnContract(
|
42
|
-
|
36
|
+
synthetixDelegateApprovals,
|
43
37
|
synthetixAssignExchangeDelegateSelector,
|
44
38
|
encodeArgs(['address'], [delegate]),
|
45
39
|
);
|
46
40
|
}
|
47
41
|
|
48
|
-
export async function synthetixResolveAddress({
|
49
|
-
addressResolver,
|
50
|
-
name,
|
51
|
-
}: {
|
52
|
-
addressResolver: ISynthetixAddressResolver;
|
53
|
-
name: string;
|
54
|
-
}) {
|
55
|
-
return addressResolver.requireAndGetAddress(utils.formatBytes32String(name), `Missing ${name}`);
|
56
|
-
}
|
57
|
-
|
58
42
|
export async function synthetixRedeem({
|
59
43
|
comptrollerProxy,
|
60
44
|
integrationManager,
|
@@ -91,8 +75,7 @@ export async function synthetixTakeOrder({
|
|
91
75
|
synthetixAdapter,
|
92
76
|
outgoingAsset,
|
93
77
|
outgoingAssetAmount = utils.parseEther('1'),
|
94
|
-
|
95
|
-
minIncomingAssetAmount = utils.parseEther('1'),
|
78
|
+
minIncomingSusdAmount = utils.parseEther('1'),
|
96
79
|
seedFund = false,
|
97
80
|
}: {
|
98
81
|
comptrollerProxy: ComptrollerLib;
|
@@ -102,8 +85,7 @@ export async function synthetixTakeOrder({
|
|
102
85
|
synthetixAdapter: SynthetixAdapter;
|
103
86
|
outgoingAsset: StandardToken;
|
104
87
|
outgoingAssetAmount?: BigNumberish;
|
105
|
-
|
106
|
-
minIncomingAssetAmount?: BigNumberish;
|
88
|
+
minIncomingSusdAmount?: BigNumberish;
|
107
89
|
seedFund?: boolean;
|
108
90
|
}) {
|
109
91
|
if (seedFund) {
|
@@ -112,8 +94,7 @@ export async function synthetixTakeOrder({
|
|
112
94
|
}
|
113
95
|
|
114
96
|
const takeOrderArgs = synthetixTakeOrderArgs({
|
115
|
-
|
116
|
-
minIncomingAssetAmount,
|
97
|
+
minIncomingSusdAmount,
|
117
98
|
outgoingAsset,
|
118
99
|
outgoingAssetAmount,
|
119
100
|
});
|
package/src/types.d.ts
CHANGED
package/src/whales.ts
CHANGED
@@ -12,12 +12,15 @@ const whales = {
|
|
12
12
|
crv: '0x4ce799e6eD8D64536b67dD428565d52A531B3640',
|
13
13
|
dai: '0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503',
|
14
14
|
knc: '0x09d51654bd9efbfcb56da3491989cc1444095fff',
|
15
|
+
ldo: '0x3dba737ccc50a32a1764b493285dd51c8af6c278',
|
15
16
|
link: '0xbe6977e08d4479c0a6777539ae0e8fa27be4e9d6',
|
16
17
|
mana: '0xefb94ac00f1cee8a89d5c3f49faa799da6f03024',
|
17
18
|
mln: '0xd8f8a53945bcfbbc19da162aa405e662ef71c40d',
|
19
|
+
ohm: '0x71a53aff36a699110d66d6bdfff2320caf8d2d59',
|
18
20
|
rep: '0xc6a043b07d33b6f30d8cb501026c391cfd25abe1',
|
19
21
|
ren: '0xbe0eb53f46cd790cd13851d5eff43d12404d33e8',
|
20
22
|
susd: '0xa5f7a39e55d7878bc5bd754ee5d6bd7a7662355b',
|
23
|
+
sohm: '0xf280f037cdbda99727ddf5dfede91e68fa78605c',
|
21
24
|
uni: '0x47173b170c64d16393a52e6c480b3ad8c302ba1e',
|
22
25
|
usdc: '0xae2d4617c862309a3d75a0ffb358c7a5009c673f',
|
23
26
|
usdt: '0x5041ed759dd4afc3a72b8192c143f72f4724081a',
|
@@ -25,23 +28,29 @@ const whales = {
|
|
25
28
|
zrx: '0x206376e8940e42538781cd94ef024df3c1e0fd43',
|
26
29
|
// aTokens
|
27
30
|
ausdc: '0x3DdfA8eC3052539b6C9549F12cEA2C295cfF5296',
|
31
|
+
ausdt: '0x7d6149ad9a573a6e2ca6ebf7d4897c1b766841b4',
|
28
32
|
// cTokens
|
29
33
|
ccomp: '0xd74f186194ab9219fafac5c2fe4b3270169666db',
|
30
34
|
cdai: '0xab4ce310054a11328685ece1043211b68ba5d082',
|
31
35
|
ceth: '0x8aceab8167c80cb8b3de7fa6228b889bb1130ee8',
|
32
36
|
cuni: '0x39d8014b4f40d2cbc441137011d32023f4f1fd87',
|
33
|
-
cusdc: '
|
37
|
+
cusdc: '0xe1ed4da4284924ddaf69983b4d813fb1be58c380',
|
38
|
+
// fTokens
|
39
|
+
fdai7: '0x88884e35d7006ae84efef09ee6bc6a43dd8e2bb8',
|
40
|
+
feth7: '0xcd2ba6a4d50745b0b4096186f925115387852c15',
|
41
|
+
fdai8: '0x93f3f612a525a59523e91cc5552f718df9fc0746',
|
42
|
+
ftribe8: '0xdb5ac83c137321da29a59a7592232bc4ed461730',
|
34
43
|
// ptTokens
|
35
44
|
ptUsdc: '0xd18236cd213f39d078177b6f6908f0e44e88e4aa',
|
36
|
-
// synths
|
45
|
+
// synths (unsupported)
|
37
46
|
seth: '0xc34a7c65aa08cb36744bda8eeec7b8e9891e147c',
|
38
|
-
seur: '0xc3f2f91723b16b95bef0619b2504c049075d5b0b',
|
39
47
|
sxag: '0x40d68c490bf7262ec40048099aec23535f734be2',
|
40
48
|
sxau: '0x92eb453b7b5b8d41edb44e2c8b8b53eb70a482c7',
|
41
49
|
// misc
|
42
50
|
lidoSteth: '0x31f644e2dd5d74f5c8d6d9de89dd517474d51800',
|
43
|
-
|
44
|
-
|
51
|
+
ust: '0xf584f8728b874a6a5c7a8d4d387c9aae9172d621',
|
52
|
+
// Curve steth pool related
|
53
|
+
stecrv: '0x56c915758ad3f76fd287fff7563ee313142fb663',
|
45
54
|
} as const;
|
46
55
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
47
56
|
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import type { AddressLike } from '@enzymefinance/ethers';
|
2
|
-
import type { SignerWithAddress } from '@enzymefinance/hardhat';
|
3
|
-
import type { ComptrollerLib, IntegrationManager, ParaSwapV4Adapter, ParaSwapV4Path, StandardToken } from '@enzymefinance/protocol';
|
4
|
-
import type { BigNumberish } from 'ethers';
|
5
|
-
import { utils } from 'ethers';
|
6
|
-
export declare function paraSwapV4GenerateDummyPaths({ toTokens }: {
|
7
|
-
toTokens: AddressLike[];
|
8
|
-
}): {
|
9
|
-
routes: never[];
|
10
|
-
to: AddressLike;
|
11
|
-
totalNetworkFee: number;
|
12
|
-
}[];
|
13
|
-
export declare function paraSwapV4TakeOrder({ comptrollerProxy, integrationManager, fundOwner, paraSwapV4Adapter, outgoingAsset, outgoingAssetAmount, minIncomingAssetAmount, expectedIncomingAssetAmount, paths, }: {
|
14
|
-
comptrollerProxy: ComptrollerLib;
|
15
|
-
integrationManager: IntegrationManager;
|
16
|
-
fundOwner: SignerWithAddress;
|
17
|
-
paraSwapV4Adapter: ParaSwapV4Adapter;
|
18
|
-
outgoingAsset: StandardToken;
|
19
|
-
outgoingAssetAmount?: BigNumberish;
|
20
|
-
minIncomingAssetAmount?: BigNumberish;
|
21
|
-
expectedIncomingAssetAmount?: BigNumberish;
|
22
|
-
paths: ParaSwapV4Path[];
|
23
|
-
}): Promise<import("@enzymefinance/ethers").ContractReceipt<import("@enzymefinance/ethers").SendFunction<[_extension: AddressLike, _actionId: BigNumberish, _callArgs: utils.BytesLike], void, ComptrollerLib>>>;
|
@@ -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
|
-
}
|