-
Notifications
You must be signed in to change notification settings - Fork 65
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
mkflow27
wants to merge
15
commits into
main
Choose a base branch
from
feat/create-lbp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: create lbp #605
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b1da4d2
feat: create lbp
mkflow27 cc3aa2f
Merge branch 'main' into feat/create-lbp
mkflow27 0aa14f4
refactor: use dedicated block number
mkflow27 d08991b
refactor: use block number
mkflow27 7d1bf56
docs: remove comments
mkflow27 b51ae15
refactor: move create validation to individual validators
mkflow27 72dfce5
fix: signature
mkflow27 23c8860
refactor: var naming & remove not relevant types
mkflow27 7760b49
Merge branch 'main' into feat/create-lbp
mkflow27 261237b
run pnpm i
mkflow27 621d00e
test: basic add remove tests
mkflow27 fad08c2
format: lint
mkflow27 f60a964
test: remove skip due to time based mining
mkflow27 2f21cc1
Delete pnpm-lock.yaml
mkflow27 17bdb87
chore: add lockfile
mkflow27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/entities/createPool/createPoolV3/liquidityBootstrapping/createLiquidityBootstrapping.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 withLint
checkThe cause was that my machine had pnpm
v9.x
globally installedThe fix was...
package.json