Skip to content

Commit

Permalink
Refactor types as Address
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoguerios committed Jan 29, 2025
1 parent c75286d commit ab82723
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/entities/addLiquidityBoosted/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class AddLiquidityBoostedV3 {
);

amountsIn = tokensIn.map((t, i) => {
const tokenInAddress = t.toLowerCase() as `0x${string}`;
const tokenInAddress = t.toLowerCase() as Address;
const { decimals } = poolStateTokenMap[tokenInAddress];
const token = new Token(
input.chainId,
Expand Down
7 changes: 2 additions & 5 deletions src/entities/inputValidator/boosted/inputValidatorBoosted.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Address } from 'viem';
import { PoolStateWithUnderlyings } from '@/entities/types';
import { InputValidatorBase } from '../inputValidatorBase';
import { AddLiquidityKind } from '@/entities/addLiquidity/types';
Expand All @@ -23,11 +24,7 @@ export class InputValidatorBoosted extends InputValidatorBase {
.filter(Boolean);

addLiquidityInput.amountsIn.forEach((a) => {
if (
!poolTokens.includes(
a.address.toLowerCase() as `0x${string}`,
)
) {
if (!poolTokens.includes(a.address.toLowerCase() as Address)) {
throw new Error(
`Address ${a.address} is not contained in the pool's parent or child tokens.`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('Boosted AddLiquidity', () => {
await setTokenBalances(
client,
testAddress,
[USDT.address, USDC.address] as Address[],
[USDT.address, USDC.address],
[USDT.slot, USDC.slot] as number[],
[
parseUnits('1000', USDT.decimals),
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Boosted AddLiquidity', () => {
await approveSpenderOnTokens(
client,
testAddress,
[USDT.address, USDC.address, stataUSDT.address] as Address[],
[USDT.address, USDC.address, stataUSDT.address],
PERMIT2[chainId],
);

Expand Down Expand Up @@ -508,8 +508,8 @@ describe('Boosted AddLiquidity', () => {
await sendTransactionGetBalances(
[
addLiquidityQueryOutput.bptOut.token.address,
USDC.address as `0x${string}`,
USDT.address as `0x${string}`,
USDC.address,
USDT.address,
],
client,
testAddress,
Expand Down Expand Up @@ -570,7 +570,7 @@ describe('Boosted AddLiquidity', () => {
});

const addLiquidityBuildCallOutput =
await addLiquidityBoosted.buildCallWithPermit2(
addLiquidityBoosted.buildCallWithPermit2(
addLiquidityBuildInput,
permit2,
);
Expand All @@ -579,8 +579,8 @@ describe('Boosted AddLiquidity', () => {
await sendTransactionGetBalances(
[
addLiquidityQueryOutput.bptOut.token.address,
USDC.address as `0x${string}`,
USDT.address as `0x${string}`,
USDC.address,
USDT.address,
],
client,
testAddress,
Expand Down Expand Up @@ -618,16 +618,8 @@ describe('Boosted AddLiquidity', () => {
// make sure to pass Tokens in correct order. Same as poolTokens but as underlyings instead
assertTokenMatch(
[
new Token(
111555111,
USDC.address as Address,
USDC.decimals,
),
new Token(
111555111,
USDT.address as Address,
USDT.decimals,
),
new Token(111555111, USDC.address, USDC.decimals),
new Token(111555111, USDT.address, USDT.decimals),
],
addLiquidityBuildCallOutput.maxAmountsIn.map(
(a) => a.token,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ describe('Buffer AddLiquidity', () => {

const { transactionReceipt, balanceDeltas } =
await sendTransactionGetBalances(
[
stataUSDC.address as `0x${string}`,
USDC.address as `0x${string}`,
],
[stataUSDC.address, USDC.address],
client,
testAddress,
addLiquidityBufferBuildCallOutput.to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ describe('remove liquidity boosted proportional', () => {

const { transactionReceipt, balanceDeltas } =
await sendTransactionGetBalances(
[
boostedPool_USDC_USDT.address,
USDC.address as `0x${string}`,
USDT.address as `0x${string}`,
],
[boostedPool_USDC_USDT.address, USDC.address, USDT.address],
client,
testAddress,
removeLiquidityBuildCallOutput.to,
Expand Down Expand Up @@ -293,8 +289,8 @@ describe('remove liquidity boosted proportional', () => {
await sendTransactionGetBalances(
[
boostedPool_USDC_USDT.address,
USDC.address as `0x${string}`,
stataUSDT.address as `0x${string}`,
USDC.address,
stataUSDT.address,
],
client,
testAddress,
Expand Down Expand Up @@ -397,11 +393,7 @@ describe('remove liquidity boosted proportional', () => {

const { transactionReceipt, balanceDeltas } =
await sendTransactionGetBalances(
[
boostedPool_USDC_USDT.address,
USDC.address as `0x${string}`,
USDT.address as `0x${string}`,
],
[boostedPool_USDC_USDT.address, USDC.address, USDT.address],
client,
testAddress,
removeLiquidityBuildCallOutput.to,
Expand Down

0 comments on commit ab82723

Please sign in to comment.