-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TokenExtensions based position NFT (#341)
* initial impl position 2022 * allow TE mint at position ops * rename verify_position_authority fn * fix warnings, initialize MetadataPointer if metadata required * instruction name change issue on conversion between camel and snake (pos_2022 >> pos2022 >> pos2022) and generate wrong instruction disc code (instruction not found) * add test cases for open_position_with_token_extensions * add test cases for close_position_with_token_extensions * fix build error * add test cases (life cycle test) * refactor * cargo fmt * update rich client functions * add test cases for rich client * add test cases for rich client * fix lint error * add getAllPositionAccountsByOwner * add test cases for getAllPositionAccountsByOwner * update position NFT metadata URI * fix lint error * address review comments * fix getAllPositionAccountsByOwner test case (isolate test env) * increase accrue reward time to avoid accidental failure * eliminate fixed length account init by removing WP_2022_METADATA_MAX_LEN * fix lint error * reserve FreezeAuthority * switch withTokenExtensions to tokenProgramId on client * fix: not skip simulation on test * bump versions (contract & sdk) * bump sdk version 0.13.8
- Loading branch information
1 parent
69eb2f6
commit 5981063
Showing
50 changed files
with
4,320 additions
and
86 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
50 changes: 50 additions & 0 deletions
50
legacy-sdk/whirlpool/src/instructions/close-position-with-token-extensions-ix.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,50 @@ | ||
import type { Program } from "@coral-xyz/anchor"; | ||
import type { Instruction } from "@orca-so/common-sdk"; | ||
import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token"; | ||
import type { PublicKey } from "@solana/web3.js"; | ||
import type { Whirlpool } from "../artifacts/whirlpool"; | ||
|
||
/** | ||
* Parameters to close a position (based on Token-2022) in a Whirlpool. | ||
* | ||
* @category Instruction Types | ||
* @param receiver - PublicKey for the wallet that will receive the rented lamports. | ||
* @param position - PublicKey for the position. | ||
* @param positionMint - PublicKey for the mint token for the Position token. | ||
* @param positionTokenAccount - The associated token address for the position token in the owners wallet. | ||
* @param positionAuthority - Authority that owns the position token. | ||
*/ | ||
export type ClosePositionWithTokenExtensionsParams = { | ||
receiver: PublicKey; | ||
position: PublicKey; | ||
positionMint: PublicKey; | ||
positionTokenAccount: PublicKey; | ||
positionAuthority: PublicKey; | ||
}; | ||
|
||
/** | ||
* Close a position in a Whirlpool. Burns the position token in the owner's wallet. | ||
* Mint and TokenAccount are based on Token-2022. And Mint accout will be also closed. | ||
* | ||
* @category Instructions | ||
* @param context - Context object containing services required to generate the instruction | ||
* @param params - ClosePositionWithTokenExtensionsParams object | ||
* @returns - Instruction to perform the action. | ||
*/ | ||
export function closePositionWithTokenExtensionsIx( | ||
program: Program<Whirlpool>, | ||
params: ClosePositionWithTokenExtensionsParams, | ||
): Instruction { | ||
const ix = program.instruction.closePositionWithTokenExtensions({ | ||
accounts: { | ||
...params, | ||
token2022Program: TOKEN_2022_PROGRAM_ID, | ||
}, | ||
}); | ||
|
||
return { | ||
instructions: [ix], | ||
cleanupInstructions: [], | ||
signers: [], | ||
}; | ||
} |
Oops, something went wrong.