Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump b-sdk 0.30.1 #123

Merged
merged 3 commits into from
Oct 31, 2024
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
27 changes: 13 additions & 14 deletions packages/lib/modules/pool/actions/LiquidityActionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {
InputAmount,
MinimalToken,
NestedPoolState,
PoolGetPool,
PoolState,
PoolStateWithBalances,
Token,
TokenAmount,
mapPoolToNestedPoolState,
mapPoolToNestedPoolStateV2,
mapPoolType,
} from '@balancer/sdk'
import BigNumber from 'bignumber.js'
Expand Down Expand Up @@ -58,9 +59,7 @@ export class LiquidityActionHelpers {

/* Used by default nested SDK handlers */
public get nestedPoolState(): NestedPoolState {
// TODO: PoolGetPool should be exposed by the SDK
type PoolGetPool = Parameters<typeof mapPoolToNestedPoolState>[0]
const result = mapPoolToNestedPoolState(this.pool as PoolGetPool)
const result = mapPoolToNestedPoolStateV2(this.pool as PoolGetPool)
result.protocolVersion = 2
return result
}
Expand All @@ -79,7 +78,7 @@ export class LiquidityActionHelpers {

public getAmountsToApprove(
humanAmountsIn: HumanTokenAmountWithAddress[],
isPermit2 = false,
isPermit2 = false
): TokenAmountToApprove[] {
return this.toInputAmounts(humanAmountsIn).map(({ address, rawAmount }) => {
return {
Expand Down Expand Up @@ -110,8 +109,8 @@ export class LiquidityActionHelpers {
if (!token) {
throw new Error(
`Provided token address ${tokenAddress} not found in pool tokens [${Object.keys(
this.pool.allTokens.map(t => t.address),
).join(' , \n')}]`,
this.pool.allTokens.map(t => t.address)
).join(' , \n')}]`
)
}
return {
Expand Down Expand Up @@ -162,14 +161,14 @@ export function toHumanAmount(tokenAmount: TokenAmount): HumanAmount {

export function ensureLastQueryResponse<Q>(
liquidityActionDescription: string,
queryResponse?: Q,
queryResponse?: Q
): Q {
if (!queryResponse) {
// This should never happen but this is a check against potential regression bugs
console.error(`Missing queryResponse in ${liquidityActionDescription}`)
throw new SentryError(
`Missing queryResponse.
It looks that you tried to call useBuildCallData before the last query finished generating queryResponse`,
It looks that you tried to call useBuildCallData before the last query finished generating queryResponse`
)
}

Expand Down Expand Up @@ -246,13 +245,13 @@ export function toPoolStateWithBalances(pool: Pool): PoolStateWithBalances {
export function filterHumanAmountsIn(
humanAmountsIn: HumanTokenAmountWithAddress[],
tokenAddress: Address,
chain: GqlChain,
chain: GqlChain
) {
return humanAmountsIn.filter(
amountIn =>
!isSameAddress(amountIn.tokenAddress, tokenAddress) &&
!(isNativeAsset(tokenAddress, chain) && isWrappedNativeAsset(amountIn.tokenAddress, chain)) &&
!(isNativeAsset(amountIn.tokenAddress, chain) && isWrappedNativeAsset(tokenAddress, chain)),
!(isNativeAsset(amountIn.tokenAddress, chain) && isWrappedNativeAsset(tokenAddress, chain))
)
}

Expand Down Expand Up @@ -280,7 +279,7 @@ export function shouldShowNativeWrappedSelector(token: GqlToken, poolType: GqlPo

export function replaceWrappedWithNativeAsset(
validTokens: GqlToken[],
nativeAsset: GqlToken | undefined,
nativeAsset: GqlToken | undefined
) {
if (!nativeAsset) return validTokens
return validTokens.map(token => {
Expand All @@ -295,10 +294,10 @@ export function replaceWrappedWithNativeAsset(
export function injectNativeAsset(
validTokens: GqlToken[],
nativeAsset: GqlToken | undefined,
pool: Pool,
pool: Pool
) {
const isWrappedNativeAssetInPool = validTokens.find(token =>
isWrappedNativeAsset(token.address as Address, pool.chain),
isWrappedNativeAsset(token.address as Address, pool.chain)
)

if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AddLiquidityNested,
AddLiquidityNestedCallInputV2,
AddLiquidityNestedInput,
ChainId,
PriceImpact,
Expand All @@ -12,7 +13,6 @@ import { Pool } from '../../../PoolProvider'
import { LiquidityActionHelpers, areEmptyAmounts } from '../../LiquidityActionHelpers'
import { NestedBuildAddLiquidityInput, NestedQueryAddLiquidityOutput } from '../add-liquidity.types'
import { AddLiquidityHandler } from './AddLiquidity.handler'
import { AddLiquidityNestedCallInputV2 } from './TemporaryNestedSdkTypes'

/**
* NestedAddLiquidityHandler is a handler that implements the
Expand All @@ -39,7 +39,7 @@ export class NestedAddLiquidityHandler implements AddLiquidityHandler {
}

public async simulate(
humanAmountsIn: HumanTokenAmountWithAddress[],
humanAmountsIn: HumanTokenAmountWithAddress[]
): Promise<NestedQueryAddLiquidityOutput> {
const addLiquidity = new AddLiquidityNested()

Expand Down Expand Up @@ -80,7 +80,7 @@ export class NestedAddLiquidityHandler implements AddLiquidityHandler {
* PRIVATE METHODS
*/
private constructSdkInput(
humanAmountsIn: HumanTokenAmountWithAddress[],
humanAmountsIn: HumanTokenAmountWithAddress[]
): AddLiquidityNestedInput {
const amountsIn = this.helpers.toSdkInputAmounts(humanAmountsIn)

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@apollo/client": "^3.11.8",
"@balancer/sdk": "^0.29.0",
"@balancer/sdk": "^0.30.1",
"@chakra-ui/anatomy": "^2.2.2",
"@chakra-ui/hooks": "^2.2.1",
"@chakra-ui/icons": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { aNested50Weth503Pool } from './gqlPoolElement.builders'
import { NestedPoolState, mapPoolToNestedPoolState } from '@balancer/sdk'
import { NestedPoolState, PoolGetPool, mapPoolToNestedPoolStateV2 } from '@balancer/sdk'
import { daiAddress, usdcAddress, usdtAddress, wETHAddress } from '@repo/lib/debug-helpers'

// Unskip when SDK is migrated to new API schema
test.skip('aNested50Weth503Pool builds a proper nested pool mock', () => {
type PoolGetPool = Parameters<typeof mapPoolToNestedPoolState>[0]

const nestedPoolState: NestedPoolState = mapPoolToNestedPoolState(
test('aNested50Weth503Pool builds a proper nested pool mock', () => {
const nestedPoolState: NestedPoolState = mapPoolToNestedPoolStateV2(
aNested50Weth503Pool() as unknown as PoolGetPool
)

Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading