Skip to content

Commit 1d43780

Browse files
authored
fix: add typesafety to morpho build functions (#1858)
1 parent 8d7c5ad commit 1d43780

4 files changed

+14
-8
lines changed

src/earn/utils/buildDepositToMorphoTx.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import {
55
} from '@/earn/constants';
66
import { encodeFunctionData, parseUnits } from 'viem';
77
import { describe, expect, it } from 'vitest';
8-
import { buildDepositToMorphoTx } from './buildDepositToMorphoTx';
8+
import {
9+
type DepositToMorphoArgs,
10+
buildDepositToMorphoTx,
11+
} from './buildDepositToMorphoTx';
912

1013
describe('buildDepositToMorphoTx', () => {
11-
const mockArgs = {
14+
const mockArgs: DepositToMorphoArgs = {
1215
vaultAddress: '0xd63070114470f685b75B74D60EEc7c1113d33a3D',
1316
tokenAddress: USDC_ADDRESS,
1417
amount: parseUnits('1000', USDC_DECIMALS),
1518
receiverAddress: '0x9E95f497a7663B70404496dB6481c890C4825fe1',
16-
} as const;
19+
};
1720

1821
it('should return an array with two transactions', async () => {
1922
const result = buildDepositToMorphoTx(mockArgs);

src/earn/utils/buildDepositToMorphoTx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MORPHO_VAULT_ABI } from '@/earn/constants';
22
import type { Call } from '@/transaction/types';
33
import { type Address, encodeFunctionData, erc20Abi } from 'viem';
44

5-
type DepositToMorphoArgs = {
5+
export type DepositToMorphoArgs = {
66
/** The address of the Morpho vault */
77
vaultAddress: Address;
88
/** The address of the token to deposit */

src/earn/utils/buildWithdrawFromMorphoTx.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { MORPHO_VAULT_ABI, USDC_DECIMALS } from '@/earn/constants';
22
import { encodeFunctionData, parseUnits } from 'viem';
33
import { describe, expect, it } from 'vitest';
4-
import { buildWithdrawFromMorphoTx } from './buildWithdrawFromMorphoTx';
4+
import {
5+
type WithdrawFromMorphoArgs,
6+
buildWithdrawFromMorphoTx,
7+
} from './buildWithdrawFromMorphoTx';
58

69
describe('buildWithdrawFromMorphoTx', () => {
7-
const mockArgs = {
10+
const mockArgs: WithdrawFromMorphoArgs = {
811
vaultAddress: '0xd63070114470f685b75B74D60EEc7c1113d33a3D',
912
amount: parseUnits('1000', USDC_DECIMALS),
1013
receiverAddress: '0x9E95f497a7663B70404496dB6481c890C4825fe1',
11-
} as const;
14+
};
1215

1316
it('should return an array with one transaction', async () => {
1417
const result = await buildWithdrawFromMorphoTx(mockArgs);

src/earn/utils/buildWithdrawFromMorphoTx.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MORPHO_VAULT_ABI } from '@/earn/constants';
22
import type { Call } from '@/transaction/types';
33
import { type Address, encodeFunctionData } from 'viem';
44

5-
type WithdrawFromMorphoArgs = {
5+
export type WithdrawFromMorphoArgs = {
66
/** The address of the Morpho vault */
77
vaultAddress: Address;
88
/** The amount of tokens to withdraw */

0 commit comments

Comments
 (0)