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: create lbp #605

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
5,470 changes: 2,278 additions & 3,192 deletions pnpm-lock.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Should be no change to the pnpm-lock file.

Copy link
Member

@MattPereira MattPereira Mar 4, 2025

Choose a reason for hiding this comment

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

@mkflow27 I ran into the same lockfileVerison: '9.0' change causing problem with Lint check

The cause was that my machine had pnpm v9.x globally installed

The fix was...

  1. global install of verison that matches our package.json
npm install -g pnpm@8.6.0
  1. revert the lock file back to state of latest commit on main branch
git checkout de8956de -- pnpm-lock.yaml
  1. run install again
pnpm install

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/abi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './stablePoolFactory.V3';
export * from './balancerCompositeLiquidityRouterNested';
export * from './balancerCompositeLiquidityRouterBoosted';
export * from './stableSurgeFactory';
export * from './liquidityBootstrappingFactory';
323 changes: 323 additions & 0 deletions src/abi/liquidityBootstrappingFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
export const liquidityBoostrappingFactoryAbi = [
{
inputs: [
{ internalType: 'contract IVault', name: 'vault', type: 'address' },
{
internalType: 'uint32',
name: 'pauseWindowDuration',
type: 'uint32',
},
{ internalType: 'string', name: 'factoryVersion', type: 'string' },
{ internalType: 'string', name: 'poolVersion', type: 'string' },
{ internalType: 'address', name: 'trustedRouter', type: 'address' },
],
stateMutability: 'nonpayable',
type: 'constructor',
},
{ inputs: [], name: 'Create2EmptyBytecode', type: 'error' },
{ inputs: [], name: 'Create2FailedDeployment', type: 'error' },
{
inputs: [
{ internalType: 'uint256', name: 'balance', type: 'uint256' },
{ internalType: 'uint256', name: 'needed', type: 'uint256' },
],
name: 'Create2InsufficientBalance',
type: 'error',
},
{ inputs: [], name: 'Disabled', type: 'error' },
{
inputs: [
{
internalType: 'uint256',
name: 'resolvedStartTime',
type: 'uint256',
},
{ internalType: 'uint256', name: 'endTime', type: 'uint256' },
],
name: 'GradualUpdateTimeTravel',
type: 'error',
},
{ inputs: [], name: 'IndexOutOfBounds', type: 'error' },
{ inputs: [], name: 'InvalidOwner', type: 'error' },
{ inputs: [], name: 'InvalidTrustedRouter', type: 'error' },
{ inputs: [], name: 'MinWeight', type: 'error' },
{ inputs: [], name: 'NormalizedWeightInvariant', type: 'error' },
{ inputs: [], name: 'PoolPauseWindowDurationOverflow', type: 'error' },
{ inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' },
{ inputs: [], name: 'SenderNotAllowed', type: 'error' },
{ inputs: [], name: 'StandardPoolWithCreator', type: 'error' },
{ anonymous: false, inputs: [], name: 'FactoryDisabled', type: 'event' },
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'pool',
type: 'address',
},
{
indexed: true,
internalType: 'contract IERC20',
name: 'projectToken',
type: 'address',
},
{
indexed: true,
internalType: 'contract IERC20',
name: 'reserveToken',
type: 'address',
},
],
name: 'LBPoolCreated',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'pool',
type: 'address',
},
],
name: 'PoolCreated',
type: 'event',
},
{
inputs: [
{ internalType: 'string', name: 'name', type: 'string' },
{ internalType: 'string', name: 'symbol', type: 'string' },
{
components: [
{ internalType: 'address', name: 'owner', type: 'address' },
{
internalType: 'contract IERC20',
name: 'projectToken',
type: 'address',
},
{
internalType: 'contract IERC20',
name: 'reserveToken',
type: 'address',
},
{
internalType: 'uint256',
name: 'projectTokenStartWeight',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'reserveTokenStartWeight',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'projectTokenEndWeight',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'reserveTokenEndWeight',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'startTime',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'endTime',
type: 'uint256',
},
{
internalType: 'bool',
name: 'blockProjectTokenSwapsIn',
type: 'bool',
},
],
internalType: 'struct LBPParams',
name: 'lbpParams',
type: 'tuple',
},
{
internalType: 'uint256',
name: 'swapFeePercentage',
type: 'uint256',
},
{ internalType: 'bytes32', name: 'salt', type: 'bytes32' },
],
name: 'create',
outputs: [{ internalType: 'address', name: 'pool', type: 'address' }],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'disable',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'bytes4', name: 'selector', type: 'bytes4' }],
name: 'getActionId',
outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getAuthorizer',
outputs: [
{ internalType: 'contract IAuthorizer', name: '', type: 'address' },
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getDefaultLiquidityManagement',
outputs: [
{
components: [
{
internalType: 'bool',
name: 'disableUnbalancedLiquidity',
type: 'bool',
},
{
internalType: 'bool',
name: 'enableAddLiquidityCustom',
type: 'bool',
},
{
internalType: 'bool',
name: 'enableRemoveLiquidityCustom',
type: 'bool',
},
{
internalType: 'bool',
name: 'enableDonation',
type: 'bool',
},
],
internalType: 'struct LiquidityManagement',
name: 'liquidityManagement',
type: 'tuple',
},
],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [],
name: 'getDefaultPoolHooksContract',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [
{ internalType: 'bytes', name: 'constructorArgs', type: 'bytes' },
{ internalType: 'bytes32', name: 'salt', type: 'bytes32' },
],
name: 'getDeploymentAddress',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getNewPoolPauseWindowEndTime',
outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getOriginalPauseWindowEndTime',
outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getPauseWindowDuration',
outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getPoolCount',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getPoolVersion',
outputs: [{ internalType: 'string', name: '', type: 'string' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getPools',
outputs: [{ internalType: 'address[]', name: '', type: 'address[]' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256', name: 'start', type: 'uint256' },
{ internalType: 'uint256', name: 'count', type: 'uint256' },
],
name: 'getPoolsInRange',
outputs: [
{ internalType: 'address[]', name: 'pools', type: 'address[]' },
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getTrustedRouter',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'getVault',
outputs: [
{ internalType: 'contract IVault', name: '', type: 'address' },
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'isDisabled',
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [{ internalType: 'address', name: 'pool', type: 'address' }],
name: 'isPoolFromFactory',
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'version',
outputs: [{ internalType: 'string', name: '', type: 'string' }],
stateMutability: 'view',
type: 'function',
},
];
3 changes: 3 additions & 0 deletions src/entities/createPool/createPoolV3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { CreatePoolWeightedV3 } from './weighted/createPoolWeighted';
import { CreatePoolStableV3 } from './stable/createPoolStable';
import { CreatePoolStableSurge } from './stableSurge/createStableSurge';
import { CreatePoolLiquidityBootstrapping } from './liquidityBootstrapping/createLiquidityBootstrapping';

export class CreatePoolV3 implements CreatePoolBase {
private readonly createPoolTypes: Record<string, CreatePoolBase> = {};
Expand All @@ -16,6 +17,8 @@ export class CreatePoolV3 implements CreatePoolBase {
[PoolType.Weighted]: new CreatePoolWeightedV3(),
[PoolType.Stable]: new CreatePoolStableV3(),
[PoolType.StableSurge]: new CreatePoolStableSurge(),
[PoolType.LiquidityBootstrapping]:
new CreatePoolLiquidityBootstrapping(),
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { getRandomBytes32 } from '@/entities/utils/getRandomBytes32';
import { encodeFunctionData } from 'viem';

import {
CreatePoolBase,
CreatePoolBuildCallOutput,
CreatePoolLiquidityBootstrappingInput,
} from '../../types';

import { liquidityBoostrappingFactoryAbi } from '@/abi/liquidityBootstrappingFactory';
import { LIQUIDITY_BOOTSTRAPPING_FACTORY } from '@/utils';

import { Hex } from '@/types';

export class CreatePoolLiquidityBootstrapping implements CreatePoolBase {
public buildCall(
input: CreatePoolLiquidityBootstrappingInput,
): CreatePoolBuildCallOutput {
const callData = this.encodeCall(input);
return {
callData,
to: LIQUIDITY_BOOTSTRAPPING_FACTORY[input.chainId],
};
}

private encodeCall(input: CreatePoolLiquidityBootstrappingInput): Hex {
const args = [
input.name,
input.symbol,
input.lbpParams,
input.swapFeePercentage,
input.salt || getRandomBytes32(),
];
return encodeFunctionData({
abi: liquidityBoostrappingFactoryAbi,
functionName: 'create',
args,
});
}
}
Loading
Loading