Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,868 changes: 1,246 additions & 622 deletions abi/defi-wrapper/Factory.ts

Large diffs are not rendered by default.

92 changes: 50 additions & 42 deletions abi/defi-wrapper/StvStETHPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,19 +636,6 @@ export const StvStETHPoolAbi = [
],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'forcedRebalanceThresholdBP',
inputs: [],
outputs: [
{
name: 'threshold',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'getAllowListAddresses',
Expand Down Expand Up @@ -982,6 +969,32 @@ export const StvStETHPoolAbi = [
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'poolForcedRebalanceThresholdBP',
inputs: [],
outputs: [
{
name: 'threshold',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'poolReserveRatioBP',
inputs: [],
outputs: [
{
name: 'reserveRatio',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'poolType',
Expand Down Expand Up @@ -1081,6 +1094,25 @@ export const StvStETHPoolAbi = [
],
stateMutability: 'view',
},
{
type: 'function',
name: 'rebalanceExceedingMintedStethShares',
inputs: [
{
name: '_stethShares',
type: 'uint256',
internalType: 'uint256',
},
],
outputs: [
{
name: 'stvBurned',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'rebalanceMintedStethSharesForWithdrawalQueue',
Expand Down Expand Up @@ -1180,19 +1212,6 @@ export const StvStETHPoolAbi = [
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'reserveRatioBP',
inputs: [],
outputs: [
{
name: 'reserveRatio',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'resumeDeposits',
Expand Down Expand Up @@ -2056,22 +2075,6 @@ export const StvStETHPoolAbi = [
},
],
},
{
type: 'error',
name: 'ArraysLengthMismatch',
inputs: [
{
name: 'firstArrayLength',
type: 'uint256',
internalType: 'uint256',
},
{
name: 'secondArrayLength',
type: 'uint256',
internalType: 'uint256',
},
],
},
{
type: 'error',
name: 'CannotRebalanceWithdrawalQueue',
Expand Down Expand Up @@ -2200,6 +2203,11 @@ export const StvStETHPoolAbi = [
name: 'InsufficientBalance',
inputs: [],
},
{
type: 'error',
name: 'InsufficientExceedingShares',
inputs: [],
},
{
type: 'error',
name: 'InsufficientMintedShares',
Expand Down
1 change: 1 addition & 0 deletions docs/cli/commands/defi-wrapper/contracts/Factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ yarn start defi-wrapper contracts factory -h
| create-pool-ggv \<address> | initiates deployment of a GGV strategy pool |
| create-pool-stv \<address> | initiates deployment of a STV staking pool |
| create-pool-stv-steth \<address> | initiates deployment of a STV-STETH pool with minting enabled |
| create-pool-custom \<address> | initiates deployment of a custom pool |
29 changes: 16 additions & 13 deletions features/defi-wrapper/create-vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
type VaultConfig,
} from './defi-wrapper-factory.js';

const MIN_TIME_IN_HOURS = 60 * 60; // 1 hour
const MAX_TIME_IN_HOURS = 24 * 60 * 60 * 30; // 30 days
const MIN_TIME_IN_SECONDS = 60 * 60; // 1 hour
const MAX_TIME_IN_SECONDS = 60 * 60 * 24 * 30; // 30 days

const MAX_POOL_TOKEN_NAME_LENGTH = 14;
const MIN_POOL_TOKEN_NAME_LENGTH = 3;
Expand Down Expand Up @@ -56,9 +56,14 @@ const validatePoolTokenName = (name: string) => {
* @param name - The name of the time
* @throws Error if the time is invalid
*/
const validateTimeInHours = (timeInHours: number, name: string) => {
const minInHours = MIN_TIME_IN_HOURS / 3600;
const maxInHours = MAX_TIME_IN_HOURS / 3600;
const validateTimeInHours = (
timeInHours: number,
name: string,
minTimeSeconds?: number,
maxTimeSeconds?: number,
) => {
const minInHours = (minTimeSeconds ?? MIN_TIME_IN_SECONDS) / 3600;
const maxInHours = (maxTimeSeconds ?? MAX_TIME_IN_SECONDS) / 3600;

if (timeInHours < minInHours)
throw new Error(
Expand All @@ -83,7 +88,7 @@ export const getMinWithdrawalDelayTime = async (
): Promise<number> => {
if (!minWithdrawalDelayTime) {
const minWithdrawalDelayTimeValue = await numberPrompt(
`Enter the min withdrawal delay time (in hours) (min: ${MIN_TIME_IN_HOURS / 3600} hours, max: ${MAX_TIME_IN_HOURS / 3600} hours)`,
`Enter the min withdrawal delay time (in hours) (min: ${MIN_TIME_IN_SECONDS / 3600} hours, max: ${MAX_TIME_IN_SECONDS / 3600} hours)`,
'value',
);
if (!minWithdrawalDelayTimeValue.value)
Expand Down Expand Up @@ -115,18 +120,16 @@ export const getMinDelaySeconds = async (
): Promise<number> => {
if (!minDelaySeconds) {
const minDelaySecondsValue = await numberPrompt(
`Enter the min execution delay for timelock governance (min: ${MIN_TIME_IN_HOURS / 3600} hours, max: ${MAX_TIME_IN_HOURS / 3600} hours)`,
`Enter the min execution delay for timelock governance (min: 0, max: ${MAX_TIME_IN_SECONDS / 3600} hours)`,
'value',
);
if (!minDelaySecondsValue.value)
throw new Error('Invalid min delay seconds');

validateTimeInHours(minDelaySecondsValue.value, 'Min delay seconds');
if (typeof minDelaySecondsValue.value !== 'number')
throw new Error('Invalid min timelock delay ');

return minDelaySecondsValue.value * 3600;
minDelaySeconds = minDelaySecondsValue.value * 3600;
}

validateTimeInHours(minDelaySeconds / 3600, 'Min delay seconds');
validateTimeInHours(minDelaySeconds / 3600, 'Min delay seconds', 0);

return minDelaySeconds;
};
Expand Down
2 changes: 1 addition & 1 deletion features/defi-wrapper/defi-wrapper-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const logCreatePoolEventData = async (
logInfo('Auxiliary Config');
logResult({
data: [
['Allowlist Enabled', eventData.auxiliaryConfig?.allowlistEnabled],
['Allowlist Enabled', eventData.auxiliaryConfig?.allowListEnabled],
['Minting Enabled', eventData.auxiliaryConfig?.mintingEnabled],
['Reserve Ratio Gap BP', eventData.auxiliaryConfig?.reserveRatioGapBP],
],
Expand Down
12 changes: 6 additions & 6 deletions features/defi-wrapper/pool-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const getStvStethPoolInfo = async (address: Address) => {
WSTETH,
RESERVE_RATIO_GAP_BP,
totalMintedStethShares,
reserveRatioBP,
forcedRebalanceThresholdBP,
poolReserveRatioBP,
poolForcedRebalanceThresholdBP,
totalExceedingMintedStethShares,
totalExceedingMintedSteth,
maxLossSocializationBP,
Expand All @@ -99,8 +99,8 @@ const getStvStethPoolInfo = async (address: Address) => {
contract.read.WSTETH(),
contract.read.RESERVE_RATIO_GAP_BP(),
contract.read.totalMintedStethShares(),
contract.read.reserveRatioBP(),
contract.read.forcedRebalanceThresholdBP(),
contract.read.poolReserveRatioBP(),
contract.read.poolForcedRebalanceThresholdBP(),
contract.read.totalExceedingMintedStethShares(),
contract.read.totalExceedingMintedSteth(),
contract.read.maxLossSocializationBP(),
Expand All @@ -117,8 +117,8 @@ const getStvStethPoolInfo = async (address: Address) => {
WSTETH,
RESERVE_RATIO_GAP_BP,
totalMintedStethShares,
reserveRatioBP,
forcedRebalanceThresholdBP,
poolReserveRatioBP,
poolForcedRebalanceThresholdBP,
totalExceedingMintedStethShares,
totalExceedingMintedSteth,
maxLossSocializationBP,
Expand Down
Loading