Skip to content

Commit b75fc0a

Browse files
authored
Merge pull request #150 from lidofinance/feature/si-2336-defi-wrapper-cli-scope
Migrate wrapper testnet and add custom pool factory
2 parents ca9004f + 7cfceb3 commit b75fc0a

File tree

11 files changed

+1528
-734
lines changed

11 files changed

+1528
-734
lines changed

abi/defi-wrapper/Factory.ts

Lines changed: 1246 additions & 622 deletions
Large diffs are not rendered by default.

abi/defi-wrapper/StvStETHPool.ts

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -636,19 +636,6 @@ export const StvStETHPoolAbi = [
636636
],
637637
stateMutability: 'nonpayable',
638638
},
639-
{
640-
type: 'function',
641-
name: 'forcedRebalanceThresholdBP',
642-
inputs: [],
643-
outputs: [
644-
{
645-
name: 'threshold',
646-
type: 'uint256',
647-
internalType: 'uint256',
648-
},
649-
],
650-
stateMutability: 'view',
651-
},
652639
{
653640
type: 'function',
654641
name: 'getAllowListAddresses',
@@ -982,6 +969,32 @@ export const StvStETHPoolAbi = [
982969
outputs: [],
983970
stateMutability: 'nonpayable',
984971
},
972+
{
973+
type: 'function',
974+
name: 'poolForcedRebalanceThresholdBP',
975+
inputs: [],
976+
outputs: [
977+
{
978+
name: 'threshold',
979+
type: 'uint256',
980+
internalType: 'uint256',
981+
},
982+
],
983+
stateMutability: 'view',
984+
},
985+
{
986+
type: 'function',
987+
name: 'poolReserveRatioBP',
988+
inputs: [],
989+
outputs: [
990+
{
991+
name: 'reserveRatio',
992+
type: 'uint256',
993+
internalType: 'uint256',
994+
},
995+
],
996+
stateMutability: 'view',
997+
},
985998
{
986999
type: 'function',
9871000
name: 'poolType',
@@ -1081,6 +1094,25 @@ export const StvStETHPoolAbi = [
10811094
],
10821095
stateMutability: 'view',
10831096
},
1097+
{
1098+
type: 'function',
1099+
name: 'rebalanceExceedingMintedStethShares',
1100+
inputs: [
1101+
{
1102+
name: '_stethShares',
1103+
type: 'uint256',
1104+
internalType: 'uint256',
1105+
},
1106+
],
1107+
outputs: [
1108+
{
1109+
name: 'stvBurned',
1110+
type: 'uint256',
1111+
internalType: 'uint256',
1112+
},
1113+
],
1114+
stateMutability: 'nonpayable',
1115+
},
10841116
{
10851117
type: 'function',
10861118
name: 'rebalanceMintedStethSharesForWithdrawalQueue',
@@ -1180,19 +1212,6 @@ export const StvStETHPoolAbi = [
11801212
outputs: [],
11811213
stateMutability: 'nonpayable',
11821214
},
1183-
{
1184-
type: 'function',
1185-
name: 'reserveRatioBP',
1186-
inputs: [],
1187-
outputs: [
1188-
{
1189-
name: 'reserveRatio',
1190-
type: 'uint256',
1191-
internalType: 'uint256',
1192-
},
1193-
],
1194-
stateMutability: 'view',
1195-
},
11961215
{
11971216
type: 'function',
11981217
name: 'resumeDeposits',
@@ -2056,22 +2075,6 @@ export const StvStETHPoolAbi = [
20562075
},
20572076
],
20582077
},
2059-
{
2060-
type: 'error',
2061-
name: 'ArraysLengthMismatch',
2062-
inputs: [
2063-
{
2064-
name: 'firstArrayLength',
2065-
type: 'uint256',
2066-
internalType: 'uint256',
2067-
},
2068-
{
2069-
name: 'secondArrayLength',
2070-
type: 'uint256',
2071-
internalType: 'uint256',
2072-
},
2073-
],
2074-
},
20752078
{
20762079
type: 'error',
20772080
name: 'CannotRebalanceWithdrawalQueue',
@@ -2200,6 +2203,11 @@ export const StvStETHPoolAbi = [
22002203
name: 'InsufficientBalance',
22012204
inputs: [],
22022205
},
2206+
{
2207+
type: 'error',
2208+
name: 'InsufficientExceedingShares',
2209+
inputs: [],
2210+
},
22032211
{
22042212
type: 'error',
22052213
name: 'InsufficientMintedShares',

docs/cli/commands/defi-wrapper/contracts/Factory.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ yarn start defi-wrapper contracts factory -h
5858
| create-pool-ggv \<address> | initiates deployment of a GGV strategy pool |
5959
| create-pool-stv \<address> | initiates deployment of a STV staking pool |
6060
| create-pool-stv-steth \<address> | initiates deployment of a STV-STETH pool with minting enabled |
61+
| create-pool-custom \<address> | initiates deployment of a custom pool |

features/defi-wrapper/create-vault.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
type VaultConfig,
88
} from './defi-wrapper-factory.js';
99

10-
const MIN_TIME_IN_HOURS = 60 * 60; // 1 hour
11-
const MAX_TIME_IN_HOURS = 24 * 60 * 60 * 30; // 30 days
10+
const MIN_TIME_IN_SECONDS = 60 * 60; // 1 hour
11+
const MAX_TIME_IN_SECONDS = 60 * 60 * 24 * 30; // 30 days
1212

1313
const MAX_POOL_TOKEN_NAME_LENGTH = 14;
1414
const MIN_POOL_TOKEN_NAME_LENGTH = 3;
@@ -56,9 +56,14 @@ const validatePoolTokenName = (name: string) => {
5656
* @param name - The name of the time
5757
* @throws Error if the time is invalid
5858
*/
59-
const validateTimeInHours = (timeInHours: number, name: string) => {
60-
const minInHours = MIN_TIME_IN_HOURS / 3600;
61-
const maxInHours = MAX_TIME_IN_HOURS / 3600;
59+
const validateTimeInHours = (
60+
timeInHours: number,
61+
name: string,
62+
minTimeSeconds?: number,
63+
maxTimeSeconds?: number,
64+
) => {
65+
const minInHours = (minTimeSeconds ?? MIN_TIME_IN_SECONDS) / 3600;
66+
const maxInHours = (maxTimeSeconds ?? MAX_TIME_IN_SECONDS) / 3600;
6267

6368
if (timeInHours < minInHours)
6469
throw new Error(
@@ -83,7 +88,7 @@ export const getMinWithdrawalDelayTime = async (
8388
): Promise<number> => {
8489
if (!minWithdrawalDelayTime) {
8590
const minWithdrawalDelayTimeValue = await numberPrompt(
86-
`Enter the min withdrawal delay time (in hours) (min: ${MIN_TIME_IN_HOURS / 3600} hours, max: ${MAX_TIME_IN_HOURS / 3600} hours)`,
91+
`Enter the min withdrawal delay time (in hours) (min: ${MIN_TIME_IN_SECONDS / 3600} hours, max: ${MAX_TIME_IN_SECONDS / 3600} hours)`,
8792
'value',
8893
);
8994
if (!minWithdrawalDelayTimeValue.value)
@@ -115,18 +120,16 @@ export const getMinDelaySeconds = async (
115120
): Promise<number> => {
116121
if (!minDelaySeconds) {
117122
const minDelaySecondsValue = await numberPrompt(
118-
`Enter the min execution delay for timelock governance (min: ${MIN_TIME_IN_HOURS / 3600} hours, max: ${MAX_TIME_IN_HOURS / 3600} hours)`,
123+
`Enter the min execution delay for timelock governance (min: 0, max: ${MAX_TIME_IN_SECONDS / 3600} hours)`,
119124
'value',
120125
);
121-
if (!minDelaySecondsValue.value)
122-
throw new Error('Invalid min delay seconds');
123-
124-
validateTimeInHours(minDelaySecondsValue.value, 'Min delay seconds');
126+
if (typeof minDelaySecondsValue.value !== 'number')
127+
throw new Error('Invalid min timelock delay ');
125128

126-
return minDelaySecondsValue.value * 3600;
129+
minDelaySeconds = minDelaySecondsValue.value * 3600;
127130
}
128131

129-
validateTimeInHours(minDelaySeconds / 3600, 'Min delay seconds');
132+
validateTimeInHours(minDelaySeconds / 3600, 'Min delay seconds', 0);
130133

131134
return minDelaySeconds;
132135
};

features/defi-wrapper/defi-wrapper-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export const logCreatePoolEventData = async (
198198
logInfo('Auxiliary Config');
199199
logResult({
200200
data: [
201-
['Allowlist Enabled', eventData.auxiliaryConfig?.allowlistEnabled],
201+
['Allowlist Enabled', eventData.auxiliaryConfig?.allowListEnabled],
202202
['Minting Enabled', eventData.auxiliaryConfig?.mintingEnabled],
203203
['Reserve Ratio Gap BP', eventData.auxiliaryConfig?.reserveRatioGapBP],
204204
],

features/defi-wrapper/pool-info.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ const getStvStethPoolInfo = async (address: Address) => {
8989
WSTETH,
9090
RESERVE_RATIO_GAP_BP,
9191
totalMintedStethShares,
92-
reserveRatioBP,
93-
forcedRebalanceThresholdBP,
92+
poolReserveRatioBP,
93+
poolForcedRebalanceThresholdBP,
9494
totalExceedingMintedStethShares,
9595
totalExceedingMintedSteth,
9696
maxLossSocializationBP,
@@ -99,8 +99,8 @@ const getStvStethPoolInfo = async (address: Address) => {
9999
contract.read.WSTETH(),
100100
contract.read.RESERVE_RATIO_GAP_BP(),
101101
contract.read.totalMintedStethShares(),
102-
contract.read.reserveRatioBP(),
103-
contract.read.forcedRebalanceThresholdBP(),
102+
contract.read.poolReserveRatioBP(),
103+
contract.read.poolForcedRebalanceThresholdBP(),
104104
contract.read.totalExceedingMintedStethShares(),
105105
contract.read.totalExceedingMintedSteth(),
106106
contract.read.maxLossSocializationBP(),
@@ -117,8 +117,8 @@ const getStvStethPoolInfo = async (address: Address) => {
117117
WSTETH,
118118
RESERVE_RATIO_GAP_BP,
119119
totalMintedStethShares,
120-
reserveRatioBP,
121-
forcedRebalanceThresholdBP,
120+
poolReserveRatioBP,
121+
poolForcedRebalanceThresholdBP,
122122
totalExceedingMintedStethShares,
123123
totalExceedingMintedSteth,
124124
maxLossSocializationBP,

0 commit comments

Comments
 (0)