From 84cb8947f2b5631e59551aca7d78727e2d106648 Mon Sep 17 00:00:00 2001 From: Krishna kumar S Date: Wed, 14 Aug 2024 19:26:11 +0530 Subject: [PATCH] fix: audit build --- packages/api/src/modules/vaults/vaults.service.ts | 4 ++-- packages/ops/src/create-vault.ts | 2 +- packages/ops/src/deposit.ts | 2 +- packages/ops/src/redeem-with-upside.ts | 4 ++-- packages/ops/src/redeem.ts | 4 ++-- packages/sdk/test/src/multi-user-deposit.spec.ts | 2 +- .../sdk/test/src/multi-user-upside-deposit.spec.ts | 2 +- packages/sdk/test/src/utils/contracts.ts | 10 ++++++---- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/api/src/modules/vaults/vaults.service.ts b/packages/api/src/modules/vaults/vaults.service.ts index 5a4ac3684..9587d2978 100644 --- a/packages/api/src/modules/vaults/vaults.service.ts +++ b/packages/api/src/modules/vaults/vaults.service.ts @@ -113,7 +113,7 @@ export class VaultsService { private createVaultParams( params: VaultParamsDto, upside: boolean = false, - collateralPercentage?: number, + upsidePercentage?: number, ): FixedYieldVault.FixedYieldVaultParamsStruct | UpsideVault.UpsideVaultParamsStruct { const vaultParams = { asset: params.asset, @@ -172,7 +172,7 @@ export class VaultsService { const upsideVaultParams: UpsideVault.UpsideVaultParamsStruct = { fixedYieldVault: fixedYieldVaultParams, cblToken: params.token, - collateralPercentage: collateralPercentage as unknown as BigNumber, + upsidePercentage: upsidePercentage as unknown as BigNumber, }; return upsideVaultParams; diff --git a/packages/ops/src/create-vault.ts b/packages/ops/src/create-vault.ts index 8a7842265..f9a229225 100644 --- a/packages/ops/src/create-vault.ts +++ b/packages/ops/src/create-vault.ts @@ -249,7 +249,7 @@ export async function createVault( if (isMatured) { const vault = CredbullFixedYieldVault__factory.connect(created.address, adminSigner); - const toggleTx = await vault.toggleWindowCheck(false); + const toggleTx = await vault.toggleWindowCheck(); await toggleTx.wait(); console.log(' Toggled Window Check OFF for Vault: ', created.address); } diff --git a/packages/ops/src/deposit.ts b/packages/ops/src/deposit.ts index 77d060d30..a20c620e8 100644 --- a/packages/ops/src/deposit.ts +++ b/packages/ops/src/deposit.ts @@ -70,7 +70,7 @@ export async function deposit(config: any) { await approveTx.wait(); console.log(" Bob approves transfers of the Vault's USDC."); - const toggleTx = await vault.connect(userAdmin.signer).toggleWindowCheck(false); + const toggleTx = await vault.connect(userAdmin.signer).toggleWindowCheck(); await toggleTx.wait(); console.log(' Admin disables the Vault Window Check'); diff --git a/packages/ops/src/redeem-with-upside.ts b/packages/ops/src/redeem-with-upside.ts index f268aea4c..ca8b92e19 100644 --- a/packages/ops/src/redeem-with-upside.ts +++ b/packages/ops/src/redeem-with-upside.ts @@ -68,9 +68,9 @@ export async function redeemWithUpside(config: any): Promise { config.secret.ADMIN_PRIVATE_KEY, ); const adminVault = vault.connect(userAdmin.signer); - const windowCheckTx = await adminVault.toggleWindowCheck(false); + const windowCheckTx = await adminVault.toggleWindowCheck(); await windowCheckTx.wait(); - const maturityCheckTx = await adminVault.toggleMaturityCheck(false); + const maturityCheckTx = await adminVault.setMaturityCheck(false); await maturityCheckTx.wait(); console.log(' Admin disables the Vault Maturity and Window Checks'); diff --git a/packages/ops/src/redeem.ts b/packages/ops/src/redeem.ts index a95eab3d4..0b0d77368 100644 --- a/packages/ops/src/redeem.ts +++ b/packages/ops/src/redeem.ts @@ -67,9 +67,9 @@ export async function redeem(config: any): Promise { config.secret.ADMIN_PRIVATE_KEY, ); const adminVault = vault.connect(userAdmin.signer); - const windowCheckTx = await adminVault.toggleWindowCheck(false); + const windowCheckTx = await adminVault.toggleWindowCheck(); await windowCheckTx.wait(); - const maturityCheckTx = await adminVault.toggleMaturityCheck(false); + const maturityCheckTx = await adminVault.setMaturityCheck(false); await maturityCheckTx.wait(); console.log(' Admin disables the Vault Maturity and Window Checks'); diff --git a/packages/sdk/test/src/multi-user-deposit.spec.ts b/packages/sdk/test/src/multi-user-deposit.spec.ts index 057f42c30..530a377ef 100644 --- a/packages/sdk/test/src/multi-user-deposit.spec.ts +++ b/packages/sdk/test/src/multi-user-deposit.spec.ts @@ -137,7 +137,7 @@ test.describe('Multi user Interaction - Fixed', async () => { const usdcBalanceBeofreRedeemB = await usdc.balanceOf(bob.address); await vault.connect(testSigners.operator.getDelegate()).mature(); - await toggleWindowCheck(admin, vault, false); + await toggleWindowCheck(admin, vault); const redeemPreviewA = await vault.previewRedeem(shares); diff --git a/packages/sdk/test/src/multi-user-upside-deposit.spec.ts b/packages/sdk/test/src/multi-user-upside-deposit.spec.ts index cfae1af2b..51377c251 100644 --- a/packages/sdk/test/src/multi-user-upside-deposit.spec.ts +++ b/packages/sdk/test/src/multi-user-upside-deposit.spec.ts @@ -171,7 +171,7 @@ test.describe.skip('Multi user Interaction - Upside', async () => { //Skip checks await vault.connect(testSigners.operator.getDelegate()).mature(); - await toggleWindowCheck(admin, vault, false); + await toggleWindowCheck(admin, vault); const redeemPreviewA = await vault.previewRedeem(shares); await alice.sdk.redeem(vaultAddress, shares, alice.address); diff --git a/packages/sdk/test/src/utils/contracts.ts b/packages/sdk/test/src/utils/contracts.ts index 9b1559a2b..d8f826c1f 100644 --- a/packages/sdk/test/src/utils/contracts.ts +++ b/packages/sdk/test/src/utils/contracts.ts @@ -34,13 +34,15 @@ export async function toggleMaturityCheck( vault: CredbullFixedYieldVault | CredbullFixedYieldVaultWithUpside, value: boolean, ): Promise { - return vault.connect(admin.testSigner.getDelegate()).toggleMaturityCheck(value); + return vault.connect(admin.testSigner.getDelegate()).setMaturityCheck(value); } export async function toggleWindowCheck( admin: User, vault: CredbullFixedYieldVault | CredbullFixedYieldVaultWithUpside, - value: boolean, -): Promise { - return vault.connect(admin.testSigner.getDelegate()).toggleWindowCheck(value); +) { + const previousValue = await vault.checkWindow(); + if (previousValue) { + return vault.connect(admin.testSigner.getDelegate()).toggleWindowCheck(); + } }