From 8983527087867f144bee88689aa698317f32f6cd Mon Sep 17 00:00:00 2001 From: jrooks7 Date: Fri, 8 Aug 2025 11:10:27 -0700 Subject: [PATCH 1/3] first pass at addition of sdk --- Cargo.lock | 3 +- sdk/.gitignore | 2 + sdk/package.json | 32 ++ sdk/src/index.ts | 1 + sdk/src/v0.1/TokenMigratorClient.ts | 254 ++++++++++ sdk/src/v0.1/constants.ts | 21 + sdk/src/v0.1/idl/token_migrator.json | 662 +++++++++++++++++++++++++++ sdk/src/v0.1/index.ts | 1 + sdk/src/v0.1/types/index.ts | 26 ++ sdk/src/v0.1/types/token_migrator.ts | 645 ++++++++++++++++++++++++++ sdk/src/v0.1/utils/pda.ts | 50 ++ sdk/tsconfig.json | 37 ++ sdk/yarn.lock | 464 +++++++++++++++++++ 13 files changed, 2197 insertions(+), 1 deletion(-) create mode 100644 sdk/.gitignore create mode 100644 sdk/package.json create mode 100644 sdk/src/index.ts create mode 100644 sdk/src/v0.1/TokenMigratorClient.ts create mode 100644 sdk/src/v0.1/constants.ts create mode 100644 sdk/src/v0.1/idl/token_migrator.json create mode 100644 sdk/src/v0.1/index.ts create mode 100644 sdk/src/v0.1/types/index.ts create mode 100644 sdk/src/v0.1/types/token_migrator.ts create mode 100644 sdk/src/v0.1/utils/pda.ts create mode 100644 sdk/tsconfig.json create mode 100644 sdk/yarn.lock diff --git a/Cargo.lock b/Cargo.lock index 3a21609..95fe300 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aead" @@ -2617,6 +2617,7 @@ version = "0.1.0" dependencies = [ "anchor-lang", "anchor-spl", + "solana-security-txt", ] [[package]] diff --git a/sdk/.gitignore b/sdk/.gitignore new file mode 100644 index 0000000..7bd11f8 --- /dev/null +++ b/sdk/.gitignore @@ -0,0 +1,2 @@ +dist +tsconfig.tsbuildinfo diff --git a/sdk/package.json b/sdk/package.json new file mode 100644 index 0000000..2214cc7 --- /dev/null +++ b/sdk/package.json @@ -0,0 +1,32 @@ +{ + "name": "@metadaoproject/token-migrator", + "version": "0.1.0-alpha.0", + "type": "module", + "main": "dist/index.js", + "module": "dist/index.js", + "types": "dist/index.d.ts", + "license": "BSL-1.0", + "files": [ + "/dist" + ], + "exports": { + ".": "./dist/index.js", + "./v0.1": "./dist/v0.1/index.js" + }, + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", + "build": "rm -rf ./dist && mkdir -p ./src/v0.1/idl ./src/v0.1/types && cp ../target/types/* ./src/v0.1/types || true && cp ../target/idl/token_migrator.json ./src/v0.1/idl/ || true && yarn lint:fix && yarn tsc" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.31.1", + "@solana/web3.js": "^1.95.0", + "bn.js": "^5.2.1" + }, + "devDependencies": { + "@types/chai": "^5.2.2", + "@types/mocha": "^10.0.10", + "prettier": "^3.3.3", + "typescript": "^5.5.5" + } +} diff --git a/sdk/src/index.ts b/sdk/src/index.ts new file mode 100644 index 0000000..bfa636c --- /dev/null +++ b/sdk/src/index.ts @@ -0,0 +1 @@ +export { sha256 } from "@noble/hashes/sha256"; diff --git a/sdk/src/v0.1/TokenMigratorClient.ts b/sdk/src/v0.1/TokenMigratorClient.ts new file mode 100644 index 0000000..9682808 --- /dev/null +++ b/sdk/src/v0.1/TokenMigratorClient.ts @@ -0,0 +1,254 @@ +import { AnchorProvider, Program } from "@coral-xyz/anchor"; +import { PublicKey, AccountInfo } from "@solana/web3.js"; +// Import TypeScript types from the generated types file +import type { TokenMigrator } from "./types/token_migrator.js"; +// Import the JSON IDL with the required type assertion for ESM +import TokenMigratorIDL from "./idl/token_migrator.json" with { type: "json" }; +import { TOKEN_MIGRATOR_ADMIN, TOKEN_PROGRAM_ID } from "./constants.js"; +import { + createAssociatedTokenAccountIdempotentInstruction, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import BN from "bn.js"; +import { Vault, Strategy, MigrateEvent } from "./types/index.js"; +import { + getVaultAddr, + getVaultFromAtaAddr, + getVaultToAtaAddr, + getEventAuthorityAddr, +} from "./utils/pda.js"; + +export type CreateTokenMigratorClientParams = { + provider: AnchorProvider; + tokenMigratorProgramId?: PublicKey; +}; + +export class TokenMigratorClient { + public tokenMigrator: Program; + public provider: AnchorProvider; + + private constructor(params: CreateTokenMigratorClientParams) { + this.provider = params.provider; + this.tokenMigrator = new Program(TokenMigratorIDL as any, this.provider); + } + + static createClient( + params: CreateTokenMigratorClientParams, + ): TokenMigratorClient { + return new TokenMigratorClient(params); + } + + getProgramId(): PublicKey { + return this.tokenMigrator.programId; + } + + async getVault(vault: PublicKey): Promise { + return await this.tokenMigrator.account.vault.fetch(vault); + } + + async fetchVault(vault: PublicKey): Promise { + return await this.tokenMigrator.account.vault.fetchNullable(vault); + } + + deserializeVault(accountInfo: AccountInfo): Vault { + return this.tokenMigrator.coder.accounts.decode("vault", accountInfo.data); + } + + deserializeMigrateEvent(data: Buffer): any { + // Returns the raw decoded event - cast to MigrateEvent type as needed + return this.tokenMigrator.coder.events.decode(data.toString("hex")); + } + + /** + * Creates a ProRata strategy object + */ + createProRataStrategy(): Strategy { + return { proRata: {} }; + } + + /** + * Creates a Fixed strategy object with specified exponent + * @param e - The exponent for 10^e scaling + */ + createFixedStrategy(e: number): Strategy { + return { fixed: { e } }; + } + + /** + * Initialize a new token migration vault (admin only) + * @param mintFrom - The mint we are migrating from + * @param mintTo - The mint we are migrating to + * @param strategy - The migration strategy (ProRata or Fixed) + * @param payer - The payer for account creation (defaults to provider.publicKey) + */ + initializeIx( + mintFrom: PublicKey, + mintTo: PublicKey, + strategy: Strategy, + payer: PublicKey = this.provider.publicKey, + ) { + const [vault] = getVaultAddr( + this.tokenMigrator.programId, + TOKEN_MIGRATOR_ADMIN, + mintFrom, + mintTo, + ); + + const [vaultFromAta] = getVaultFromAtaAddr( + vault, + mintFrom, + TOKEN_PROGRAM_ID, + ); + + const [vaultToAta] = getVaultToAtaAddr(vault, mintTo, TOKEN_PROGRAM_ID); + + return this.tokenMigrator.methods + .initialize(mintFrom, mintTo, strategy) + .accounts({ + admin: TOKEN_MIGRATOR_ADMIN, + }) + .preInstructions([ + // Create vault's token accounts if they don't exist + createAssociatedTokenAccountIdempotentInstruction( + payer, + vaultFromAta, + vault, + mintFrom, + ), + createAssociatedTokenAccountIdempotentInstruction( + payer, + vaultToAta, + vault, + mintTo, + ), + ]); + } + + /** + * Migrate tokens from old mint to new mint + * @param mintFrom - The mint we are migrating from + * @param mintTo - The mint we are migrating to + * @param amount - The amount of tokens to migrate + * @param user - The user performing the migration (defaults to provider.publicKey) + * @param payer - The payer for account creation (defaults to provider.publicKey) + */ + migrateIx( + mintFrom: PublicKey, + mintTo: PublicKey, + amount: BN, + user: PublicKey = this.provider.publicKey, + payer: PublicKey = this.provider.publicKey, + ) { + const [vault] = getVaultAddr( + this.tokenMigrator.programId, + TOKEN_MIGRATOR_ADMIN, + mintFrom, + mintTo, + ); + + const [vaultFromAta] = getVaultFromAtaAddr( + vault, + mintFrom, + TOKEN_PROGRAM_ID, + ); + + const [vaultToAta] = getVaultToAtaAddr(vault, mintTo, TOKEN_PROGRAM_ID); + + const userFromTa = getAssociatedTokenAddressSync(mintFrom, user, true); + + const userToTa = getAssociatedTokenAddressSync(mintTo, user, true); + + const [eventAuthority] = getEventAuthorityAddr( + this.tokenMigrator.programId, + ); + + return this.tokenMigrator.methods + .migrate(amount) + .accounts({ + user, + mintFrom, + mintTo, + userFromTa, + userToTa, + program: this.tokenMigrator.programId, + }) + .preInstructions([ + // Create user's destination token account if it doesn't exist + createAssociatedTokenAccountIdempotentInstruction( + payer, + userToTa, + user, + mintTo, + ), + ]); + } + + /** + * Helper method to calculate expected output amount for a migration + * @param vault - The vault account data + * @param amount - The input amount + * @param mintFromSupply - Total supply of the from mint (for ProRata) + * @param mintToSupply - Total supply of the to mint (for ProRata) + * @param mintFromDecimals - Decimals of the from mint (for Fixed) + * @param mintToDecimals - Decimals of the to mint (for Fixed) + */ + calculateMigrationAmount( + vault: Vault, + amount: BN, + mintFromSupply?: BN, + mintToSupply?: BN, + mintFromDecimals?: number, + mintToDecimals?: number, + ): BN { + if ("proRata" in vault.strategy) { + if (!mintFromSupply || !mintToSupply) { + throw new Error("Mint supplies required for ProRata strategy"); + } + // ProRata: withdraw_amount = (amount * mintToSupply) / mintFromSupply + return amount.mul(mintToSupply).div(mintFromSupply); + } else if ("fixed" in vault.strategy) { + const e = vault.strategy.fixed.e; + // Fixed: withdraw_amount = amount * 10^e + if (e >= 0) { + return amount.mul(new BN(10).pow(new BN(e))); + } else { + return amount.div(new BN(10).pow(new BN(-e))); + } + } + throw new Error("Unknown strategy type"); + } + + /** + * Fetch all vaults initialized by the admin + */ + async getAllVaults(): Promise< + Array<{ + publicKey: PublicKey; + account: Vault; + }> + > { + const vaults = await this.tokenMigrator.account.vault.all([ + { + memcmp: { + offset: 8, // After discriminator + bytes: TOKEN_MIGRATOR_ADMIN.toBase58(), + }, + }, + ]); + return vaults; + } + + /** + * Check if a vault exists for a given migration pair + */ + async vaultExists(mintFrom: PublicKey, mintTo: PublicKey): Promise { + const [vault] = getVaultAddr( + this.tokenMigrator.programId, + TOKEN_MIGRATOR_ADMIN, + mintFrom, + mintTo, + ); + const vaultAccount = await this.fetchVault(vault); + return vaultAccount !== null; + } +} diff --git a/sdk/src/v0.1/constants.ts b/sdk/src/v0.1/constants.ts new file mode 100644 index 0000000..02acb98 --- /dev/null +++ b/sdk/src/v0.1/constants.ts @@ -0,0 +1,21 @@ +import { PublicKey } from "@solana/web3.js"; + +export const TOKEN_MIGRATOR_PROGRAM_ID = new PublicKey( + "gr8tqq2ripsM6N46gLWpSDXtdrH6J9jaXoyya1ELC9t", +); + +export const TOKEN_MIGRATOR_ADMIN = new PublicKey( + "ELT1uRmtFvYP6WSrc4mCZaW7VVbcdkcKAj39aHSVCmwH", +); + +export const TOKEN_PROGRAM_ID = new PublicKey( + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", +); + +export const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey( + "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", +); + +export const SYSTEM_PROGRAM_ID = new PublicKey( + "11111111111111111111111111111111", +); diff --git a/sdk/src/v0.1/idl/token_migrator.json b/sdk/src/v0.1/idl/token_migrator.json new file mode 100644 index 0000000..192726b --- /dev/null +++ b/sdk/src/v0.1/idl/token_migrator.json @@ -0,0 +1,662 @@ +{ + "address": "gr8tqq2ripsM6N46gLWpSDXtdrH6J9jaXoyya1ELC9t", + "metadata": { + "name": "token_migrator", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "initialize", + "docs": [ + "# Initialize", + "This instruction allows the `admin` keypair defined in `constants.rs` to initialize a new token migration strategy. It takes in 3 parameters:", + "", + "`mint_from` - the `Mint` we are migrating from.", + "`mint_to` - the `Mint` we are migrating to.", + "`strategy` - the `Strategy` we are using for migration.", + "", + "It assumes the `vaultFromAta` and `vaultToAta` accounts for this migration are initialized and the `vaultToAta` is correctly funded ahead of time. It performs these checks in the account struct." + ], + "discriminator": [ + 1 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "vault_from_ata", + "pda": { + "seeds": [ + { + "kind": "account", + "path": "vault" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "arg", + "path": "mint_from" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault_to_ata", + "pda": { + "seeds": [ + { + "kind": "account", + "path": "vault" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "arg", + "path": "mint_to" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "admin" + }, + { + "kind": "arg", + "path": "mint_from" + }, + { + "kind": "arg", + "path": "mint_to" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "mint_from", + "type": "pubkey" + }, + { + "name": "mint_to", + "type": "pubkey" + }, + { + "name": "strategy", + "type": { + "defined": { + "name": "Strategy" + } + } + } + ] + }, + { + "name": "migrate", + "docs": [ + "# Migrate", + "This instruction alows a user to migrate their token from the old token to the new one based upon a predefined token migration strategy. It assumes `userToTa` has been created ahead of time. It takes in a single parameter:", + "", + "`amount` - the amount of tokens the user wishes to migrate from the `mint_from` token.", + "", + "It also emits a `MigrationEvent` event to enable easy traceability onchain of all token migrations by users." + ], + "discriminator": [ + 0 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "signer": true + }, + { + "name": "mint_from" + }, + { + "name": "mint_to" + }, + { + "name": "user_from_ta", + "writable": true + }, + { + "name": "user_to_ta", + "writable": true + }, + { + "name": "vault_from_ata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "vault" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint_from" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault_to_ata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "vault" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint_to" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "vault.admin", + "account": "Vault" + }, + { + "kind": "account", + "path": "mint_from" + }, + { + "kind": "account", + "path": "mint_to" + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Vault", + "discriminator": [ + 1 + ] + } + ], + "events": [ + { + "name": "MigrateEvent", + "discriminator": [ + 0 + ] + } + ], + "types": [ + { + "name": "MigrateEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "mint_from", + "type": "pubkey" + }, + { + "name": "mint_to", + "type": "pubkey" + }, + { + "name": "deposit_amount", + "type": "u64" + }, + { + "name": "withdraw_amount", + "type": "u64" + } + ] + } + }, + { + "name": "Strategy", + "docs": [ + "# Strategy", + "", + "Defines the strategy by which we perform a migration. There are two cases:", + "", + "`ProRata` - Calculates a `withdraw_amount` based upon pro-rated supply of both tokens.", + "`Fixed(i8)` - Calculates `withdraw_amount` by scaling the `amount` deposited up or down by `10^e`. Useful for decimal redenomination." + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "ProRata" + }, + { + "name": "Fixed", + "fields": [ + { + "name": "e", + "type": "i8" + } + ] + } + ] + } + }, + { + "name": "Vault", + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "type": "pubkey" + }, + { + "name": "mint_from", + "type": "pubkey" + }, + { + "name": "mint_to", + "type": "pubkey" + }, + { + "name": "strategy", + "type": { + "defined": { + "name": "Strategy" + } + } + }, + { + "name": "bump", + "type": { + "array": [ + "u8", + 1 + ] + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/sdk/src/v0.1/index.ts b/sdk/src/v0.1/index.ts new file mode 100644 index 0000000..2a4ba11 --- /dev/null +++ b/sdk/src/v0.1/index.ts @@ -0,0 +1 @@ +export * from "./TokenMigratorClient.js"; diff --git a/sdk/src/v0.1/types/index.ts b/sdk/src/v0.1/types/index.ts new file mode 100644 index 0000000..109621a --- /dev/null +++ b/sdk/src/v0.1/types/index.ts @@ -0,0 +1,26 @@ +export type { TokenMigrator } from "./token_migrator.js"; + +// Account types +export type Vault = { + admin: PublicKey; + mintFrom: PublicKey; + mintTo: PublicKey; + strategy: Strategy; + bump: number[]; +}; + +// Event types +export type MigrateEvent = { + user: PublicKey; + mintFrom: PublicKey; + mintTo: PublicKey; + depositAmount: BN; + withdrawAmount: BN; +}; + +// Strategy enum type +export type Strategy = { proRata: {} } | { fixed: { e: number } }; + +// Re-export PublicKey and BN for convenience +import { PublicKey } from "@solana/web3.js"; +import BN from "bn.js"; diff --git a/sdk/src/v0.1/types/token_migrator.ts b/sdk/src/v0.1/types/token_migrator.ts new file mode 100644 index 0000000..97675cc --- /dev/null +++ b/sdk/src/v0.1/types/token_migrator.ts @@ -0,0 +1,645 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/token_migrator.json`. + */ +export type TokenMigrator = { + address: "gr8tqq2ripsM6N46gLWpSDXtdrH6J9jaXoyya1ELC9t"; + metadata: { + name: "tokenMigrator"; + version: "0.1.0"; + spec: "0.1.0"; + description: "Created with Anchor"; + }; + instructions: [ + { + name: "initialize"; + docs: [ + "# Initialize", + "This instruction allows the `admin` keypair defined in `constants.rs` to initialize a new token migration strategy. It takes in 3 parameters:", + "", + "`mint_from` - the `Mint` we are migrating from.", + "`mint_to` - the `Mint` we are migrating to.", + "`strategy` - the `Strategy` we are using for migration.", + "", + "It assumes the `vaultFromAta` and `vaultToAta` accounts for this migration are initialized and the `vaultToAta` is correctly funded ahead of time. It performs these checks in the account struct.", + ]; + discriminator: [1]; + accounts: [ + { + name: "admin"; + writable: true; + signer: true; + }, + { + name: "vaultFromAta"; + pda: { + seeds: [ + { + kind: "account"; + path: "vault"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169, + ]; + }, + { + kind: "arg"; + path: "mintFrom"; + }, + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89, + ]; + }; + }; + }, + { + name: "vaultToAta"; + pda: { + seeds: [ + { + kind: "account"; + path: "vault"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169, + ]; + }, + { + kind: "arg"; + path: "mintTo"; + }, + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89, + ]; + }; + }; + }, + { + name: "vault"; + writable: true; + pda: { + seeds: [ + { + kind: "const"; + value: [118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "admin"; + }, + { + kind: "arg"; + path: "mintFrom"; + }, + { + kind: "arg"; + path: "mintTo"; + }, + ]; + }; + }, + { + name: "systemProgram"; + address: "11111111111111111111111111111111"; + }, + ]; + args: [ + { + name: "mintFrom"; + type: "pubkey"; + }, + { + name: "mintTo"; + type: "pubkey"; + }, + { + name: "strategy"; + type: { + defined: { + name: "strategy"; + }; + }; + }, + ]; + }, + { + name: "migrate"; + docs: [ + "# Migrate", + "This instruction alows a user to migrate their token from the old token to the new one based upon a predefined token migration strategy. It assumes `userToTa` has been created ahead of time. It takes in a single parameter:", + "", + "`amount` - the amount of tokens the user wishes to migrate from the `mint_from` token.", + "", + "It also emits a `MigrationEvent` event to enable easy traceability onchain of all token migrations by users.", + ]; + discriminator: [0]; + accounts: [ + { + name: "user"; + writable: true; + signer: true; + }, + { + name: "mintFrom"; + }, + { + name: "mintTo"; + }, + { + name: "userFromTa"; + writable: true; + }, + { + name: "userToTa"; + writable: true; + }, + { + name: "vaultFromAta"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "vault"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169, + ]; + }, + { + kind: "account"; + path: "mintFrom"; + }, + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89, + ]; + }; + }; + }, + { + name: "vaultToAta"; + writable: true; + pda: { + seeds: [ + { + kind: "account"; + path: "vault"; + }, + { + kind: "const"; + value: [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169, + ]; + }, + { + kind: "account"; + path: "mintTo"; + }, + ]; + program: { + kind: "const"; + value: [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89, + ]; + }; + }; + }, + { + name: "vault"; + pda: { + seeds: [ + { + kind: "const"; + value: [118, 97, 117, 108, 116]; + }, + { + kind: "account"; + path: "vault.admin"; + account: "vault"; + }, + { + kind: "account"; + path: "mintFrom"; + }, + { + kind: "account"; + path: "mintTo"; + }, + ]; + }; + }, + { + name: "tokenProgram"; + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + }, + { + name: "eventAuthority"; + pda: { + seeds: [ + { + kind: "const"; + value: [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121, + ]; + }, + ]; + }; + }, + { + name: "program"; + }, + ]; + args: [ + { + name: "amount"; + type: "u64"; + }, + ]; + }, + ]; + accounts: [ + { + name: "vault"; + discriminator: [1]; + }, + ]; + events: [ + { + name: "migrateEvent"; + discriminator: [0]; + }, + ]; + types: [ + { + name: "migrateEvent"; + type: { + kind: "struct"; + fields: [ + { + name: "user"; + type: "pubkey"; + }, + { + name: "mintFrom"; + type: "pubkey"; + }, + { + name: "mintTo"; + type: "pubkey"; + }, + { + name: "depositAmount"; + type: "u64"; + }, + { + name: "withdrawAmount"; + type: "u64"; + }, + ]; + }; + }, + { + name: "strategy"; + docs: [ + "# Strategy", + "", + "Defines the strategy by which we perform a migration. There are two cases:", + "", + "`ProRata` - Calculates a `withdraw_amount` based upon pro-rated supply of both tokens.", + "`Fixed(i8)` - Calculates `withdraw_amount` by scaling the `amount` deposited up or down by `10^e`. Useful for decimal redenomination.", + ]; + type: { + kind: "enum"; + variants: [ + { + name: "proRata"; + }, + { + name: "fixed"; + fields: [ + { + name: "e"; + type: "i8"; + }, + ]; + }, + ]; + }; + }, + { + name: "vault"; + type: { + kind: "struct"; + fields: [ + { + name: "admin"; + type: "pubkey"; + }, + { + name: "mintFrom"; + type: "pubkey"; + }, + { + name: "mintTo"; + type: "pubkey"; + }, + { + name: "strategy"; + type: { + defined: { + name: "strategy"; + }; + }; + }, + { + name: "bump"; + type: { + array: ["u8", 1]; + }; + }, + ]; + }; + }, + ]; +}; diff --git a/sdk/src/v0.1/utils/pda.ts b/sdk/src/v0.1/utils/pda.ts new file mode 100644 index 0000000..1bde23b --- /dev/null +++ b/sdk/src/v0.1/utils/pda.ts @@ -0,0 +1,50 @@ +import { PublicKey } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; + +export const getVaultAddr = ( + programId: PublicKey, + admin: PublicKey, + mintFrom: PublicKey, + mintTo: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode("vault"), + admin.toBuffer(), + mintFrom.toBuffer(), + mintTo.toBuffer(), + ], + programId, + ); +}; + +export const getVaultFromAtaAddr = ( + vault: PublicKey, + mintFrom: PublicKey, + tokenProgramId: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [vault.toBuffer(), tokenProgramId.toBuffer(), mintFrom.toBuffer()], + new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), // Associated Token Program + ); +}; + +export const getVaultToAtaAddr = ( + vault: PublicKey, + mintTo: PublicKey, + tokenProgramId: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [vault.toBuffer(), tokenProgramId.toBuffer(), mintTo.toBuffer()], + new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), + ); +}; + +export const getEventAuthorityAddr = ( + programId: PublicKey, +): [PublicKey, number] => { + return PublicKey.findProgramAddressSync( + [anchor.utils.bytes.utf8.encode("__event_authority")], + programId, + ); +}; diff --git a/sdk/tsconfig.json b/sdk/tsconfig.json new file mode 100644 index 0000000..e8e7bf9 --- /dev/null +++ b/sdk/tsconfig.json @@ -0,0 +1,37 @@ +{ + "compilerOptions": { + "types": [ + "mocha", + "chai" + ], + "paths": { + "@metadaoproject/token-migrator/v0.5": ["./dist/v0.1/types/index.d.ts"] + }, + "typeRoots": [ + "./node_modules/@types" + ], + "lib": [ + "esnext" + ], + "module": "NodeNext", + "target": "esnext", + "esModuleInterop": true, + "skipLibCheck": true, + "moduleResolution": "nodenext", + "sourceMap": true, + "outDir": "dist", + "strict": true, + "declaration": true, + "resolveJsonModule": true, + }, + "include": [ + "src/*", + "src/v0.1/*" + ], + "exclude": [ + "node_modules", + "target", + "tests", + "migrations" + ] +} diff --git a/sdk/yarn.lock b/sdk/yarn.lock new file mode 100644 index 0000000..66f857c --- /dev/null +++ b/sdk/yarn.lock @@ -0,0 +1,464 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/runtime@^7.25.0": + version "7.28.2" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.2.tgz#2ae5a9d51cc583bd1f5673b3bb70d6d819682473" + integrity sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA== + +"@coral-xyz/anchor-errors@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.31.1.tgz#d635cbac2533973ae6bfb5d3ba1de89ce5aece2d" + integrity sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ== + +"@coral-xyz/anchor@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" + integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== + dependencies: + "@coral-xyz/anchor-errors" "^0.31.1" + "@coral-xyz/borsh" "^0.31.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.69.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + pako "^2.0.3" + superstruct "^0.15.4" + toml "^3.0.0" + +"@coral-xyz/borsh@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.31.1.tgz#5328e1e0921b75d7f4a62dd3f61885a938bc7241" + integrity sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw== + dependencies: + bn.js "^5.1.2" + buffer-layout "^1.2.0" + +"@noble/curves@^1.4.2": + version "1.9.6" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.6.tgz#b45ebedca85bb75782f6be7e7f120f0c423c99e0" + integrity sha512-GIKz/j99FRthB8icyJQA51E8Uk5hXmdyThjgQXRKiv9h0zeRlzSCLIzFw6K1LotZ3XuB7yzlf76qk7uBmTdFqA== + dependencies: + "@noble/hashes" "1.8.0" + +"@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.4.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a" + integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A== + +"@solana/buffer-layout@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" + integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== + dependencies: + buffer "~6.0.3" + +"@solana/codecs-core@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.3.0.tgz#6bf2bb565cb1ae880f8018635c92f751465d8695" + integrity sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw== + dependencies: + "@solana/errors" "2.3.0" + +"@solana/codecs-numbers@^2.1.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.3.0.tgz#ac7e7f38aaf7fcd22ce2061fbdcd625e73828dc6" + integrity sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg== + dependencies: + "@solana/codecs-core" "2.3.0" + "@solana/errors" "2.3.0" + +"@solana/errors@2.3.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.3.0.tgz#4ac9380343dbeffb9dffbcb77c28d0e457c5fa31" + integrity sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ== + dependencies: + chalk "^5.4.1" + commander "^14.0.0" + +"@solana/web3.js@^1.69.0", "@solana/web3.js@^1.95.0": + version "1.98.4" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" + integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + "@solana/codecs-numbers" "^2.1.0" + agentkeepalive "^4.5.0" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + +"@swc/helpers@^0.5.11": + version "0.5.17" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.17.tgz#5a7be95ac0f0bf186e7e6e890e7a6f6cda6ce971" + integrity sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A== + dependencies: + tslib "^2.8.0" + +"@types/chai@^5.2.2": + version "5.2.2" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-5.2.2.tgz#6f14cea18180ffc4416bc0fd12be05fdd73bdd6b" + integrity sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg== + dependencies: + "@types/deep-eql" "*" + +"@types/connect@^3.4.33": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/deep-eql@*": + version "4.0.2" + resolved "https://registry.yarnpkg.com/@types/deep-eql/-/deep-eql-4.0.2.tgz#334311971d3a07121e7eb91b684a605e7eea9cbd" + integrity sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw== + +"@types/mocha@^10.0.10": + version "10.0.10" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.10.tgz#91f62905e8d23cbd66225312f239454a23bebfa0" + integrity sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q== + +"@types/node@*": + version "24.2.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.2.1.tgz#83e41543f0a518e006594bb394e2cd961de56727" + integrity sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ== + dependencies: + undici-types "~7.10.0" + +"@types/node@^12.12.54": + version "12.20.55" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" + integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== + +"@types/uuid@^8.3.4": + version "8.3.4" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" + integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== + +"@types/ws@^7.4.4": + version "7.4.7" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" + integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== + dependencies: + "@types/node" "*" + +"@types/ws@^8.2.2": + version "8.18.1" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.18.1.tgz#48464e4bf2ddfd17db13d845467f6070ffea4aa9" + integrity sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg== + dependencies: + "@types/node" "*" + +agentkeepalive@^4.5.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.6.0.tgz#35f73e94b3f40bf65f105219c623ad19c136ea6a" + integrity sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ== + dependencies: + humanize-ms "^1.2.1" + +base-x@^3.0.2: + version "3.0.11" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff" + integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: + version "5.2.2" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.2.tgz#82c09f9ebbb17107cd72cb7fd39bd1f9d0aaa566" + integrity sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw== + +borsh@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" + integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== + dependencies: + bn.js "^5.2.0" + bs58 "^4.0.0" + text-encoding-utf-8 "^1.0.2" + +bs58@^4.0.0, bs58@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== + dependencies: + base-x "^3.0.2" + +buffer-layout@^1.2.0, buffer-layout@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" + integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== + +buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +bufferutil@^4.0.1: + version "4.0.9" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.9.tgz#6e81739ad48a95cad45a279588e13e95e24a800a" + integrity sha512-WDtdLmJvAuNNPzByAYpRo2rF1Mmradw6gvWsQKf63476DDXmomT9zUiGypLcG4ibIM67vhAj8jJRdbmEws2Aqw== + dependencies: + node-gyp-build "^4.3.0" + +camelcase@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +chalk@^5.4.1: + version "5.5.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.5.0.tgz#67ada1df5ca809dc84c9b819d76418ddcf128428" + integrity sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg== + +commander@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.0.tgz#f244fc74a92343514e56229f16ef5c5e22ced5e9" + integrity sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA== + +commander@^2.20.3: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +cross-fetch@^3.1.5: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.2.0.tgz#34e9192f53bc757d6614304d9e5e6fb4edb782e3" + integrity sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q== + dependencies: + node-fetch "^2.7.0" + +delay@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" + integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== + +es6-promise@^4.0.3: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ== + dependencies: + es6-promise "^4.0.3" + +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + +eyes@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" + integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ== + +fast-stable-stringify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" + integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== + +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== + dependencies: + ms "^2.0.0" + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +isomorphic-ws@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" + integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== + +jayson@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.2.0.tgz#b71762393fa40bc9637eaf734ca6f40d3b8c0c93" + integrity sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg== + dependencies: + "@types/connect" "^3.4.33" + "@types/node" "^12.12.54" + "@types/ws" "^7.4.4" + commander "^2.20.3" + delay "^5.0.0" + es6-promisify "^5.0.0" + eyes "^0.1.8" + isomorphic-ws "^4.0.1" + json-stringify-safe "^5.0.1" + stream-json "^1.9.1" + uuid "^8.3.2" + ws "^7.5.10" + +json-stringify-safe@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== + +ms@^2.0.0: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +node-fetch@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +node-gyp-build@^4.3.0: + version "4.8.4" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.4.tgz#8a70ee85464ae52327772a90d66c6077a900cfc8" + integrity sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ== + +pako@^2.0.3: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== + +prettier@^3.3.3: + version "3.6.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393" + integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ== + +rpc-websockets@^9.0.2: + version "9.1.3" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.1.3.tgz#6805dfc01232389dab043861ab9fbfe9d1d75572" + integrity sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA== + dependencies: + "@swc/helpers" "^0.5.11" + "@types/uuid" "^8.3.4" + "@types/ws" "^8.2.2" + buffer "^6.0.3" + eventemitter3 "^5.0.1" + uuid "^8.3.2" + ws "^8.5.0" + optionalDependencies: + bufferutil "^4.0.1" + utf-8-validate "^5.0.2" + +safe-buffer@^5.0.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +stream-chain@^2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/stream-chain/-/stream-chain-2.2.5.tgz#b30967e8f14ee033c5b9a19bbe8a2cba90ba0d09" + integrity sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA== + +stream-json@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/stream-json/-/stream-json-1.9.1.tgz#e3fec03e984a503718946c170db7d74556c2a187" + integrity sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw== + dependencies: + stream-chain "^2.2.5" + +superstruct@^0.15.4: + version "0.15.5" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" + integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== + +superstruct@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-2.0.2.tgz#3f6d32fbdc11c357deff127d591a39b996300c54" + integrity sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A== + +text-encoding-utf-8@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" + integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== + +toml@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" + integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +tslib@^2.8.0: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + +typescript@^5.5.5: + version "5.9.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.2.tgz#d93450cddec5154a2d5cabe3b8102b83316fb2a6" + integrity sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A== + +undici-types@~7.10.0: + version "7.10.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.10.0.tgz#4ac2e058ce56b462b056e629cc6a02393d3ff350" + integrity sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag== + +utf-8-validate@^5.0.2: + version "5.0.10" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" + integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== + dependencies: + node-gyp-build "^4.3.0" + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +ws@^7.5.10: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + +ws@^8.5.0: + version "8.18.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" + integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== From 5b014ed3b5790287c181acce5b43877d882f6edc Mon Sep 17 00:00:00 2001 From: jrooks7 Date: Fri, 8 Aug 2025 11:42:40 -0700 Subject: [PATCH 2/3] pinned verisoning and removed redundant fields --- package.json | 6 +++--- sdk/package.json | 4 ++-- sdk/src/v0.1/TokenMigratorClient.ts | 24 +----------------------- sdk/yarn.lock | 4 ++-- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 4895bde..dc66706 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" }, "dependencies": { - "@coral-xyz/anchor": "0.31.1", - "@solana/spl-token": "^0.4.13", - "@solana/web3.js": "^1.98.4" + "@coral-xyz/anchor": "=0.31.1", + "@solana/spl-token": "=0.4.13", + "@solana/web3.js": "=1.98.4" }, "devDependencies": { "@types/bn.js": "5.2.0", diff --git a/sdk/package.json b/sdk/package.json index 2214cc7..2cf33d7 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -19,8 +19,8 @@ "build": "rm -rf ./dist && mkdir -p ./src/v0.1/idl ./src/v0.1/types && cp ../target/types/* ./src/v0.1/types || true && cp ../target/idl/token_migrator.json ./src/v0.1/idl/ || true && yarn lint:fix && yarn tsc" }, "dependencies": { - "@coral-xyz/anchor": "^0.31.1", - "@solana/web3.js": "^1.95.0", + "@coral-xyz/anchor": "=0.31.1", + "@solana/web3.js": "=1.98.4", "bn.js": "^5.2.1" }, "devDependencies": { diff --git a/sdk/src/v0.1/TokenMigratorClient.ts b/sdk/src/v0.1/TokenMigratorClient.ts index 9682808..9d808ba 100644 --- a/sdk/src/v0.1/TokenMigratorClient.ts +++ b/sdk/src/v0.1/TokenMigratorClient.ts @@ -10,12 +10,11 @@ import { getAssociatedTokenAddressSync, } from "@solana/spl-token"; import BN from "bn.js"; -import { Vault, Strategy, MigrateEvent } from "./types/index.js"; +import { Vault, Strategy } from "./types/index.js"; import { getVaultAddr, getVaultFromAtaAddr, getVaultToAtaAddr, - getEventAuthorityAddr, } from "./utils/pda.js"; export type CreateTokenMigratorClientParams = { @@ -139,29 +138,10 @@ export class TokenMigratorClient { user: PublicKey = this.provider.publicKey, payer: PublicKey = this.provider.publicKey, ) { - const [vault] = getVaultAddr( - this.tokenMigrator.programId, - TOKEN_MIGRATOR_ADMIN, - mintFrom, - mintTo, - ); - - const [vaultFromAta] = getVaultFromAtaAddr( - vault, - mintFrom, - TOKEN_PROGRAM_ID, - ); - - const [vaultToAta] = getVaultToAtaAddr(vault, mintTo, TOKEN_PROGRAM_ID); - const userFromTa = getAssociatedTokenAddressSync(mintFrom, user, true); const userToTa = getAssociatedTokenAddressSync(mintTo, user, true); - const [eventAuthority] = getEventAuthorityAddr( - this.tokenMigrator.programId, - ); - return this.tokenMigrator.methods .migrate(amount) .accounts({ @@ -197,8 +177,6 @@ export class TokenMigratorClient { amount: BN, mintFromSupply?: BN, mintToSupply?: BN, - mintFromDecimals?: number, - mintToDecimals?: number, ): BN { if ("proRata" in vault.strategy) { if (!mintFromSupply || !mintToSupply) { diff --git a/sdk/yarn.lock b/sdk/yarn.lock index 66f857c..f9eefb7 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -12,7 +12,7 @@ resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.31.1.tgz#d635cbac2533973ae6bfb5d3ba1de89ce5aece2d" integrity sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ== -"@coral-xyz/anchor@^0.31.1": +"@coral-xyz/anchor@=0.31.1": version "0.31.1" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== @@ -81,7 +81,7 @@ chalk "^5.4.1" commander "^14.0.0" -"@solana/web3.js@^1.69.0", "@solana/web3.js@^1.95.0": +"@solana/web3.js@=1.98.4", "@solana/web3.js@^1.69.0": version "1.98.4" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== From e96a77cfb8a07860a245528d9519f19a87aa94b1 Mon Sep 17 00:00:00 2001 From: jrooks7 Date: Fri, 8 Aug 2025 11:45:33 -0700 Subject: [PATCH 3/3] shifted program ids to spl-token and removed them from constants --- sdk/src/v0.1/TokenMigratorClient.ts | 3 ++- sdk/src/v0.1/constants.ts | 12 ------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/sdk/src/v0.1/TokenMigratorClient.ts b/sdk/src/v0.1/TokenMigratorClient.ts index 9d808ba..f1cdc0e 100644 --- a/sdk/src/v0.1/TokenMigratorClient.ts +++ b/sdk/src/v0.1/TokenMigratorClient.ts @@ -4,10 +4,11 @@ import { PublicKey, AccountInfo } from "@solana/web3.js"; import type { TokenMigrator } from "./types/token_migrator.js"; // Import the JSON IDL with the required type assertion for ESM import TokenMigratorIDL from "./idl/token_migrator.json" with { type: "json" }; -import { TOKEN_MIGRATOR_ADMIN, TOKEN_PROGRAM_ID } from "./constants.js"; +import { TOKEN_MIGRATOR_ADMIN } from "./constants.js"; import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, + TOKEN_PROGRAM_ID, } from "@solana/spl-token"; import BN from "bn.js"; import { Vault, Strategy } from "./types/index.js"; diff --git a/sdk/src/v0.1/constants.ts b/sdk/src/v0.1/constants.ts index 02acb98..e6a14fe 100644 --- a/sdk/src/v0.1/constants.ts +++ b/sdk/src/v0.1/constants.ts @@ -7,15 +7,3 @@ export const TOKEN_MIGRATOR_PROGRAM_ID = new PublicKey( export const TOKEN_MIGRATOR_ADMIN = new PublicKey( "ELT1uRmtFvYP6WSrc4mCZaW7VVbcdkcKAj39aHSVCmwH", ); - -export const TOKEN_PROGRAM_ID = new PublicKey( - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", -); - -export const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey( - "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", -); - -export const SYSTEM_PROGRAM_ID = new PublicKey( - "11111111111111111111111111111111", -);