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

feat: proportional v3 boosted adds #152

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
6b05613
feat: permit2 swaps
agualis Oct 21, 2024
9dadc80
Merge branch 'main' into feat/permit2Swaps
agualis Oct 21, 2024
c6b5343
Merge branch 'main' into feat/permit2Swaps
agualis Oct 23, 2024
e6decf2
Merge branch 'main' into feat/permit2Swaps
agualis Oct 25, 2024
38fb4b0
Merge branch 'main' into feat/permit2Swaps
agualis Oct 28, 2024
0fe1a3e
Merge branch 'main' into feat/permit2Swaps
agualis Oct 28, 2024
107ca37
fix: delete old function
agualis Oct 28, 2024
89c7204
refactor: permit2 callback
agualis Oct 28, 2024
f2c8789
chore: fix tsx format
agualis Oct 28, 2024
e5dcbb8
fix: add pool chain to swap state when isPoolSwap
agualis Oct 29, 2024
1f1c591
Merge branch 'main' into feat/permit2Swaps
agualis Oct 29, 2024
a1dc1f6
Merge branch 'main' into feat/permit2Swaps
agualis Oct 29, 2024
495397b
chore: merge with main
agualis Oct 30, 2024
20ad904
chore: merge with main2
agualis Oct 30, 2024
6f02b5d
chore: remove duplicated line
agualis Oct 30, 2024
ffc70ae
chore: refactor permit2 helper names
agualis Oct 30, 2024
1bd8278
chore: eslint
agualis Oct 30, 2024
6f5c51e
Empty commit
agualis Oct 30, 2024
d1da4aa
chore: add isBuffer to swap query
agualis Oct 30, 2024
49d9192
chore: disable gen cache
agualis Oct 30, 2024
879f96e
chore: enable gen cache again
agualis Oct 30, 2024
a0cee86
chore: fix isBuffer query
agualis Oct 30, 2024
3e89813
Merge branch 'main' into feat/permit2Swaps
agualis Oct 31, 2024
6652215
fix: returned selectedChain from SwapProvider
agualis Oct 31, 2024
221d6c9
refactor: replace deprecated API pool.allTokens by allPoolTokens func…
agualis Oct 31, 2024
181a0b5
chore: skip sepolia integration test
agualis Oct 31, 2024
4b482df
chore: bump b-sdk 0.30.0
agualis Oct 31, 2024
c67ff68
chore: Remove temporary workaround file after SDK update
agualis Oct 31, 2024
3fc0897
Merge branch 'chore/bumpSdk0.30.0' into feat/v3BoostedAdds
agualis Oct 31, 2024
23db892
refactor: router spender setup
agualis Oct 31, 2024
203c0c7
chore: move TokenCore type to pool.types
agualis Oct 31, 2024
46a35ee
chore: sync beets debug page
agualis Oct 31, 2024
4416ede
chore: bump SDK 0.30.1
agualis Oct 31, 2024
f6204ab
Merge branch 'main' into feat/permit2Swaps
agualis Oct 31, 2024
79f63ae
Merge branch 'main' into feat/replaceAllTokens
agualis Oct 31, 2024
9ecb42f
Merge branch 'main' into feat/v3BoostedAdds
agualis Oct 31, 2024
b06d9ac
chore: add comment for optional permit2
agualis Oct 31, 2024
214034c
Merge branch 'main' into feat/permit2Swaps
agualis Oct 31, 2024
4b0ede3
chore: improve comment
agualis Oct 31, 2024
acc0359
refactor: use balancer router for pool swaps
agualis Oct 31, 2024
bcd0820
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 1, 2024
5bb550d
chore: permit2 address from SDK
agualis Nov 1, 2024
315263f
chore: add index to TokenCore
agualis Nov 1, 2024
63e8483
Merge branch 'feat/replaceAllTokens' into feat/v3BoostedAdds
agualis Nov 1, 2024
9b0c97d
chore: remove trailing commas
agualis Nov 1, 2024
db3c7ed
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 1, 2024
ab2380a
feat: add Boosted unbalanced add handler
agualis Nov 1, 2024
53a938d
Merge branch 'main' into feat/permit2Swaps
agualis Nov 2, 2024
7b6611c
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 2, 2024
831202f
chore: update debug boosted pool
agualis Nov 2, 2024
d7c8183
chore: clean test
agualis Nov 2, 2024
f02f601
Merge branch 'main' into feat/permit2Swaps
agualis Nov 4, 2024
7480f46
refactor: integrate with b-sdk 0.31.1
agualis Nov 4, 2024
1a29237
Merge branch 'main' into feat/permit2Swaps
agualis Nov 5, 2024
b04a79a
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 5, 2024
79cb630
Merge branch 'main' into feat/permit2Swaps
agualis Nov 5, 2024
d31e02d
chore: update pnpm lock after merge
agualis Nov 5, 2024
1407d05
chore: move from userData to sender
agualis Nov 5, 2024
5588b7a
chore: bump sdk to 0.31.2
agualis Nov 5, 2024
d564953
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 5, 2024
790902c
Merge branch 'feat/permit2Swaps' into feat/v3BoostedAdds
agualis Nov 6, 2024
32b27ba
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 6, 2024
d34dc97
refactor: allPoolTokens function
agualis Nov 6, 2024
8968202
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 6, 2024
a45385b
fix: pnpm lock
agualis Nov 6, 2024
519f8e8
feat: unbalanced v3 boosted adds
agualis Nov 6, 2024
1a9314c
chore: skip sepolia test-api related tests
agualis Nov 6, 2024
b5821a7
chore: skip sepolia test-api related tests 2
agualis Nov 6, 2024
3fe398c
Merge branch 'main' into feat/v3BoostedAdds
agualis Nov 6, 2024
b8674af
fix: add wrapping tokens to boosted actionable
agualis Nov 7, 2024
b80f835
feat: explicit handler for boosted proportional removes
agualis Nov 7, 2024
55e8008
fix: use explicit boosted sign function
agualis Nov 7, 2024
51d6bb3
feat: proportional boosted adds
agualis Nov 7, 2024
0964bc5
chore: add test for boostedPoolStateWithBalances
agualis Nov 7, 2024
761e45b
chore: add test for boostedPoolStateWithBalances
agualis Nov 7, 2024
c639dea
feat: v3 proportional boosted adds
agualis Nov 7, 2024
6200b01
chore: comment unused line
agualis Nov 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

// Unskip when sepolia V3 pools are available in production api
describe.skip('Liquidity helpers for V3 Boosted pools', async () => {
const poolId = '0x6dbdd7a36d900083a5b86a55583d90021e9f33e8' // Sepolia stataEthUSDC stataEthUSDT
// const poolId = '0x6dbdd7a36d900083a5b86a55583d90021e9f33e8' // Sepolia stataEthUSDC stataEthUSDT

const usdcSepoliaAddress = '0x94a9d9ac8a22534e3faca9f4e7f2e2cf85d5e4c8'
const usdtSepoliaAddress = '0xaa8e23fb1079ea71e0a56f48a2aa51851d8433d0'
Expand Down Expand Up @@ -210,11 +210,36 @@
type: 'Stable',
})
})

it('poolStateWithBalances (that calls boostedPoolStateWithBalances underneath)', async () => {
const helpers = new LiquidityActionHelpers(v3Pool)
expect(helpers.poolStateWithBalances).toEqual({
address: '0x6dbdd7a36d900083a5b86a55583d90021e9f33e8',
id: '0x6dbdd7a36d900083a5b86a55583d90021e9f33e8',
protocolVersion: 3,
tokens: [
{
address: '0x94a9d9ac8a22534e3faca9f4e7f2e2cf85d5e4c8',
balance: expect.any(String),
decimals: 6,
index: 0,
},
{
address: '0xaa8e23fb1079ea71e0a56f48a2aa51851d8433d0',
balance: expect.any(String),
decimals: 6,
index: 1,
},
],
totalShares: expect.any(String),
type: 'Stable',
})
})
})

// Unskip when sepolia V3 pools are available in production api
describe.skip('Liquidity helpers for V3 NESTED pool', async () => {
const poolId = '0x0270daf4ee12ccb1abc8aa365054eecb1b7f4f6b' // Sepolia Balancer 50 WETH 50 USD

Check warning on line 242 in packages/lib/modules/pool/actions/LiquidityActionHelpers.integration.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

'poolId' is assigned a value but never used

const usdcSepoliaAddress = '0x94a9d9ac8a22534e3faca9f4e7f2e2cf85d5e4c8'
const usdtSepoliaAddress = '0xaa8e23fb1079ea71e0a56f48a2aa51851d8433d0'
Expand Down
37 changes: 36 additions & 1 deletion packages/lib/modules/pool/actions/LiquidityActionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
PoolState,
PoolStateWithBalances,
PoolStateWithUnderlyings,
PoolTokenWithBalance,
PoolTokenWithUnderlying,
Token,
TokenAmount,
Expand All @@ -35,6 +36,7 @@ import { Pool } from '../PoolProvider'
import {
allPoolTokens,
isAffectedByCspIssue,
isBoosted,
isComposableStableV1,
isCowAmmPool,
isGyro,
Expand Down Expand Up @@ -83,6 +85,7 @@ export class LiquidityActionHelpers {
(token, index) => ({
...token,
address: token.address as Address,
balance: token.balance as HumanAmount,
underlyingToken: {
...token.underlyingToken,
address: token.underlyingToken?.address as Address,
Expand All @@ -103,7 +106,39 @@ export class LiquidityActionHelpers {
}

public get poolStateWithBalances(): PoolStateWithBalances {
return toPoolStateWithBalances(this.pool)
return isBoosted(this.pool)
? this.boostedPoolStateWithBalances
: toPoolStateWithBalances(this.pool)
}

/* Used by calculateProportionalAmounts for V3 boosted proportional adds */
public get boostedPoolStateWithBalances(): PoolStateWithBalances {
const underlyingTokensWithBalance: PoolTokenWithBalance[] = this.pool.poolTokens.map(
(token, index) =>
token.underlyingToken
? {
address: token.underlyingToken?.address as Address,
decimals: token.underlyingToken?.decimals as number,
index,
// TODO: balance: token.underlyingToken?.balance * rate as HumanAmount,
balance: token.balance as HumanAmount,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garethfuller Note that this balance should be the underlying balance (wrappingToken.balance * priceRate) instead of just wrappingToken balance but I'm investigating why that's failing.
Related PR on top of this one:
#153

}
: {
address: token.address as Address,
decimals: token.decimals as number,
balance: token.balance as HumanAmount,
index,
}
)
const state: PoolStateWithBalances = {
id: this.pool.id as Hex,
address: this.pool.address as Address,
protocolVersion: 3,
type: mapPoolType(this.pool.type),
tokens: underlyingTokensWithBalance,
totalShares: this.pool.dynamicData.totalShares as HumanAmount,
}
return state
}

public get networkConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import { ConnectWallet } from '@repo/lib/modules/web3/ConnectWallet'
import { BalAlert } from '@repo/lib/shared/components/alerts/BalAlert'
import { SafeAppAlert } from '@repo/lib/shared/components/alerts/SafeAppAlert'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
import { isBoosted } from '../../../pool.helpers'

// small wrapper to prevent out of context error
export function AddLiquidityForm() {
Expand Down Expand Up @@ -189,11 +188,7 @@ function AddLiquidityMainForm() {
<BalAlert content="You cannot add because the pool has no liquidity" status="warning" />
)}
<SafeAppAlert />
{/* //TODO:
Avoid proportional inputs to avoid error above until SDK calculateProportionalAmounts for boosted is implemented
https://github.com/balancer/b-sdk/issues/468
*/}
{!nestedAddLiquidityEnabled && !isBoosted(pool) ? (
{!nestedAddLiquidityEnabled ? (
<TokenInputsWithAddable
requiresProportionalInput={requiresProportionalInput(pool)}
tokenSelectDisclosureOpen={() => tokenSelectDisclosure.onOpen()}
Expand Down
Loading