-
Notifications
You must be signed in to change notification settings - Fork 116
feat(v4-sdk): additional options when migrating #276
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
Open
dianakocsis
wants to merge
16
commits into
main
Choose a base branch
from
more-migrating-params
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.
Open
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ce3bb3c
additional options when migrating
dianakocsis ad62981
lint
dianakocsis 81c86a1
re-structure
dianakocsis 616bc64
Merge branch 'main' into more-migrating-params
dianakocsis 88c1c4c
fix test
dianakocsis b3e1f44
merge main
dianakocsis b669682
comment
dianakocsis eb869ab
migrating to position that needs eth
dianakocsis af3398f
Update sdks/v4-sdk/src/PositionManager.ts
dianakocsis 034362c
naming and comment
dianakocsis 74b11e4
fix
dianakocsis 542273f
migrate specific options
dianakocsis 40df03d
test for transferring extra currency that is not eth
dianakocsis 08c1256
Merge branch 'main' into more-migrating-params
dianakocsis aad7a8c
separate mgirate options
dianakocsis ab18592
Merge branch 'main' into more-migrating-params
dianakocsis 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
This file contains hidden or 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 |
---|---|---|
|
@@ -59,11 +59,6 @@ export interface MintSpecificOptions { | |
* Initial price to set on the pool if creating | ||
*/ | ||
sqrtPriceX96?: BigintIsh | ||
|
||
/** | ||
* Whether the mint is part of a migration from V3 to V4. | ||
*/ | ||
migrate?: boolean | ||
} | ||
|
||
/** | ||
|
@@ -130,6 +125,23 @@ export interface TransferOptions { | |
tokenId: BigintIsh | ||
} | ||
|
||
export interface MigrateSpecificOptions { | ||
/** | ||
* Whether the mint is part of a migration from V3 to V4. | ||
*/ | ||
migrate: boolean | ||
|
||
/** | ||
* Whether the migrate needs additional transfer or not | ||
*/ | ||
additionalTransfer?: AdditionalTransferDetails | ||
} | ||
|
||
export interface AdditionalTransferDetails { | ||
neededCurrency: Currency | ||
neededAmount: BigintIsh | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not too bad it seems on the Trading API side to send in; curious how to derive the amount, seems it wouldnt bee to tedious to compute from earlier convos |
||
|
||
export interface PermitDetails { | ||
token: string | ||
amount: BigintIsh | ||
|
@@ -182,9 +194,10 @@ export interface NFTPermitData { | |
} | ||
|
||
export type MintOptions = CommonOptions & CommonAddLiquidityOptions & MintSpecificOptions | ||
export type MigrateOptions = MintOptions & MigrateSpecificOptions | ||
export type IncreaseLiquidityOptions = CommonOptions & CommonAddLiquidityOptions & ModifyPositionSpecificOptions | ||
|
||
export type AddLiquidityOptions = MintOptions | IncreaseLiquidityOptions | ||
export type AddLiquidityOptions = MintOptions | IncreaseLiquidityOptions | MigrateOptions | ||
|
||
export type RemoveLiquidityOptions = CommonOptions & RemoveLiquiditySpecificOptions & ModifyPositionSpecificOptions | ||
|
||
|
@@ -195,6 +208,10 @@ function isMint(options: AddLiquidityOptions): options is MintOptions { | |
return Object.keys(options).some((k) => k === 'recipient') | ||
} | ||
|
||
function isMigrate(options: AddLiquidityOptions): options is MigrateOptions { | ||
return Object.keys(options).some((k) => k === 'migrate') | ||
} | ||
|
||
function shouldCreatePool(options: MintOptions): boolean { | ||
if (options.createPool) { | ||
invariant(options.sqrtPriceX96 !== undefined, NO_SQRT_PRICE) | ||
|
@@ -275,7 +292,7 @@ export abstract class V4PositionManager { | |
} | ||
|
||
// If migrating, we need to settle and sweep both currencies individually | ||
if (isMint(options) && options.migrate) { | ||
if (isMigrate(options) && options.migrate) { | ||
// payer is v4 positiion manager | ||
planner.addSettle(position.pool.currency0, false) | ||
planner.addSettle(position.pool.currency1, false) | ||
|
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.
looks like we are pulling out migrate into its own object; might need to change trading api impl