diff --git a/lib/contracts/handlers/puffer-vault-handler.test.ts b/lib/contracts/handlers/puffer-vault-handler.test.ts index 020d24c..99ba95d 100644 --- a/lib/contracts/handlers/puffer-vault-handler.test.ts +++ b/lib/contracts/handlers/puffer-vault-handler.test.ts @@ -121,4 +121,15 @@ describe('PufferVaultHandler', () => { expect(typeof (await estimate())).toBe('bigint'); expect(isHash(await transact())).toBe(true); }); + + it('should convert pufETH to WETH', async () => { + const mockPufETH = 10n; + const mockWETH = 20n; + + vaultTestingUtils.mockCall('convertToAssets', [mockWETH]); + + const wethAmount = await handler.convertToAssets(mockPufETH); + + expect(wethAmount).toBe(mockWETH); + }); }); diff --git a/lib/contracts/handlers/puffer-vault-handler.ts b/lib/contracts/handlers/puffer-vault-handler.ts index 8ace75b..0f8ddd8 100644 --- a/lib/contracts/handlers/puffer-vault-handler.ts +++ b/lib/contracts/handlers/puffer-vault-handler.ts @@ -235,4 +235,15 @@ export class PufferVaultHandler { return { transact, estimate }; } + + /** + * Gives exchange rate of pufETH relative to WETH. + * This does not include any fees, as compared to previewRedeem method. + * + * @param amount Amount of pufETH to convert. + * @returns Amount of equivalent WETH. + */ + public convertToAssets(amount: bigint) { + return this.getContract().read.convertToAssets([amount]); + } }