diff --git a/Anchor.toml b/Anchor.toml index 18af468..c63473a 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -9,12 +9,17 @@ strategy_program = "EDA9ee5UKzdqrHgSd5v64bNnbCae1t7NJfUpvS7DZod" tokenized_vault = "8eDcyX8Z8yZXBQsuatwxDC1qzGbuUbP7wGERDBQoPmBH" faucet = "GUrM139EUwYkoEWebecqiTLJrvut4mDdHGTu9d87tgQC" +[programs.mainnet] +strategy_program = "FeMChq4ZCFP8UstbyHnVyme3ATa2vtteLNCwms4jLMAj" +tokenized_vault = "5R6bVKZfag4X9vW4nek6UNP8XXwH7cPaVohyAo1xfVEU" +faucet = "4rza9AifAapN4SKho3teAuLhc1TPpNWp9DHNPEMzVqgp" + [registry] url = "https://api.apr.dev" [provider] -cluster = "Localnet" -wallet = "~/.config/solana/id.json" +cluster = "mainnet" +wallet = "~/.config/solana/mainnet.json" [scripts] demo = "yarn run demo" @@ -27,6 +32,7 @@ init_faucet = "yarn run init_faucet" process_report = "yarn run process_report" init_trade_fi = "yarn run init_trade_fi" underlying_mint = "yarn run underlying_mint" +vault_init_share = "yarn run vault_init_share" [[test.genesis]] address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" diff --git a/README.md b/README.md index 6b2be64..96ae319 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Initialize the minting process for the underlying token by running: **Step 5.1: Capture the Mint Public Key** -After running the above command, capture the Underlying Token Mint Public Key from the output (e.g., "4dCLhR7U8PzwXau6qfjr73tKgp5SD42aLbyo3XQNzY4V"). You will use this public key in later steps. +After running the above command, capture the Underlying Token Mint Public Key from the output (e.g., "4N37FD6SU35ssX6yTu2AcCvzVbdS6z3YZTtk5gv7ejhE"). You will use this public key in later steps. ---------------------------------------------------------------------------------------- diff --git a/package.json b/package.json index 346f5ab..f396c40 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "process_report": "npx ts-node scripts/process_report.ts", "init_faucet": "npx ts-node scripts/init_faucet.ts", "init_trade_fi": "npx ts-node scripts/create_vault_with_trade_fi_strategy.ts", - "underlying_mint": "npx ts-node scripts/create-underlying-mint.ts" + "underlying_mint": "npx ts-node scripts/create-underlying-mint.ts", + "vault_init_share": "npx ts-node scripts/vault_init_share.ts" }, "dependencies": { "@coral-xyz/anchor": "^0.30.1", diff --git a/programs/faucet/src/lib.rs b/programs/faucet/src/lib.rs index 34a5bb8..3a115d8 100644 --- a/programs/faucet/src/lib.rs +++ b/programs/faucet/src/lib.rs @@ -6,7 +6,7 @@ pub mod error; pub use instructions::*; -declare_id!("GUrM139EUwYkoEWebecqiTLJrvut4mDdHGTu9d87tgQC"); +declare_id!("4rza9AifAapN4SKho3teAuLhc1TPpNWp9DHNPEMzVqgp"); #[program] pub mod faucet { diff --git a/programs/strategy_program/src/lib.rs b/programs/strategy_program/src/lib.rs index 1220fda..261f206 100644 --- a/programs/strategy_program/src/lib.rs +++ b/programs/strategy_program/src/lib.rs @@ -11,7 +11,7 @@ pub use constants::*; pub use instructions::*; pub use state::*; -declare_id!("EDA9ee5UKzdqrHgSd5v64bNnbCae1t7NJfUpvS7DZod"); +declare_id!("FeMChq4ZCFP8UstbyHnVyme3ATa2vtteLNCwms4jLMAj"); // we need to define a trait for the strategies // they aren't defined otherwise, because we work with unchecked accounts diff --git a/programs/tokenized_vault/src/lib.rs b/programs/tokenized_vault/src/lib.rs index f9556ab..fad48b9 100644 --- a/programs/tokenized_vault/src/lib.rs +++ b/programs/tokenized_vault/src/lib.rs @@ -11,7 +11,7 @@ pub use constants::*; pub use state::*; pub use instructions::*; -declare_id!("8eDcyX8Z8yZXBQsuatwxDC1qzGbuUbP7wGERDBQoPmBH"); +declare_id!("5R6bVKZfag4X9vW4nek6UNP8XXwH7cPaVohyAo1xfVEU"); #[program] pub mod tokenized_vault { diff --git a/scripts/create-underlying-mint.ts b/scripts/create-underlying-mint.ts index d8f586a..7c54b2d 100644 --- a/scripts/create-underlying-mint.ts +++ b/scripts/create-underlying-mint.ts @@ -12,7 +12,7 @@ async function main() { try { const provider = anchor.AnchorProvider.env(); - const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/id.json'); + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); const admin = anchor.web3.Keypair.fromSecretKey(secretKey); diff --git a/scripts/create_default_vault_with_strategy.ts b/scripts/create_default_vault_with_strategy.ts index 1d4c0cb..5725de0 100644 --- a/scripts/create_default_vault_with_strategy.ts +++ b/scripts/create_default_vault_with_strategy.ts @@ -15,7 +15,10 @@ const TOKEN_METADATA_PROGRAM_ID = new anchor.web3.PublicKey("metaqbxxUerdq28cj1R // Define the config function async function main() { try { - const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/id.json'); + const provider = anchor.AnchorProvider.env(); + anchor.setProvider(provider); + + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); const admin = anchor.web3.Keypair.fromSecretKey(secretKey); @@ -23,10 +26,10 @@ async function main() { const vaultProgram = anchor.workspace.TokenizedVault as Program; const strategyProgram = anchor.workspace.StrategyProgram as Program; - const underlyingMint = new anchor.web3.PublicKey("4dCLhR7U8PzwXau6qfjr73tKgp5SD42aLbyo3XQNzY4V"); + const underlyingMint = new anchor.web3.PublicKey("4N37FD6SU35ssX6yTu2AcCvzVbdS6z3YZTtk5gv7ejhE"); console.log("Underlying token mint public key:", underlyingMint.toBase58()); - const vault_index = 1; + const vault_index = 0; const vault = anchor.web3.PublicKey.findProgramAddressSync( [ diff --git a/scripts/create_vault_with_trade_fi_strategy.ts b/scripts/create_vault_with_trade_fi_strategy.ts index b553eeb..f889f40 100644 --- a/scripts/create_vault_with_trade_fi_strategy.ts +++ b/scripts/create_vault_with_trade_fi_strategy.ts @@ -18,7 +18,7 @@ async function main() { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/id.json'); + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); const admin = anchor.web3.Keypair.fromSecretKey(secretKey); @@ -26,7 +26,7 @@ async function main() { const vaultProgram = anchor.workspace.TokenizedVault as Program; const strategyProgram = anchor.workspace.StrategyProgram as Program; - const underlyingMint = new anchor.web3.PublicKey("4dCLhR7U8PzwXau6qfjr73tKgp5SD42aLbyo3XQNzY4V"); + const underlyingMint = new anchor.web3.PublicKey("4N37FD6SU35ssX6yTu2AcCvzVbdS6z3YZTtk5gv7ejhE"); console.log("Underlying token mint public key:", underlyingMint.toBase58()); const vault_index = 2; @@ -96,13 +96,15 @@ async function main() { //TODO: Depoit and lock period ends in 30 minutes + // deposit period end -> 1728568800 -> Thursday, October 10, 2024 6:00:00 PM GMT+04:00 + // lock period end -> 1728655200 -> Friday, October 11, 2024 6:00:00 PM GMT+04:00 const strategyType = { tradeFintech: {} }; const strategyConfig = new TradeFintechConfig({ depositLimit: new BN(1000), // deposit ends in 1 minute, epoch time in seconds - depositPeriodEnds: new BN(Date.now() / 1000 + 60 * 30), + depositPeriodEnds: new BN(1728568800), //Date.now() / 1000 + 60 * 30), // lock period ends in 2 minute - lockPeriodEnds: new BN(Date.now() / 1000 + 2 * 60 * 30), + lockPeriodEnds: new BN(1728655200),//Date.now() / 1000 + 2 * 60 * 30), performanceFee: new BN(1), feeManager: admin.publicKey }); diff --git a/scripts/init_faucet.ts b/scripts/init_faucet.ts index ef25068..2e86b1f 100644 --- a/scripts/init_faucet.ts +++ b/scripts/init_faucet.ts @@ -11,7 +11,7 @@ async function main() { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/id.json'); + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); const admin = anchor.web3.Keypair.fromSecretKey(secretKey); @@ -21,7 +21,7 @@ async function main() { let faucetProgram: Program = anchor.workspace.Faucet; console.log("Faucet program ID:", faucetProgram.programId.toBase58()); - const underlyingMint = new anchor.web3.PublicKey("4dCLhR7U8PzwXau6qfjr73tKgp5SD42aLbyo3XQNzY4V"); + const underlyingMint = new anchor.web3.PublicKey("4N37FD6SU35ssX6yTu2AcCvzVbdS6z3YZTtk5gv7ejhE"); const faucetData = anchor.web3.PublicKey.findProgramAddressSync( [Buffer.from("data")], diff --git a/scripts/set_roles.ts b/scripts/set_roles.ts index 609b56e..da8dec5 100644 --- a/scripts/set_roles.ts +++ b/scripts/set_roles.ts @@ -10,7 +10,7 @@ async function main() { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); - const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/id.json'); + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); const admin = anchor.web3.Keypair.fromSecretKey(secretKey); diff --git a/scripts/vault_init_share.ts b/scripts/vault_init_share.ts new file mode 100644 index 0000000..cb2e15b --- /dev/null +++ b/scripts/vault_init_share.ts @@ -0,0 +1,115 @@ +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import { TokenizedVault } from "../target/types/tokenized_vault"; +import * as fs from 'fs'; // Import fs module +import * as path from 'path'; // Import path module +import { BN } from "@coral-xyz/anchor"; +import { StrategyProgram } from "../target/types/strategy_program"; +import * as token from "@solana/spl-token"; + +// Define the config function +async function main() { + try { + const provider = anchor.AnchorProvider.env(); + anchor.setProvider(provider); + + const secretKeyPath = path.resolve(process.env.HOME, '.config/solana/mainnet.json'); + const secretKeyString = fs.readFileSync(secretKeyPath, 'utf8'); + const secretKey = Uint8Array.from(JSON.parse(secretKeyString)); + const admin = anchor.web3.Keypair.fromSecretKey(secretKey); + + const feeRecipient = anchor.web3.Keypair.generate(); + // const airdropSignature = await provider.connection.requestAirdrop(feeRecipient.publicKey, 10e9); + // await provider.connection.confirmTransaction(airdropSignature); + + + const vaultProgram = anchor.workspace.TokenizedVault as Program; + const strategyProgram = anchor.workspace.TokenizedVault as Program; + + let vault = anchor.web3.PublicKey.findProgramAddressSync( + [ + Buffer.from("vault"), + Buffer.from(new Uint8Array(new BigUint64Array([BigInt(0)]).buffer)) + ], + vaultProgram.programId + )[0]; + + console.log("Vault PDA:", vault.toBase58()); + + // const sharesMint = anchor.web3.PublicKey.findProgramAddressSync( + // [Buffer.from("shares"), vault.toBuffer()], + // vaultProgram.programId + // )[0]; + + + let vaultAccount = await vaultProgram.account.vault.fetch(vault); + console.log("Vault deposit limit: ", vaultAccount.depositLimit.toString()); + console.log("sharesBump: ", vaultAccount.sharesBump.toString()); + + // const underlyingMint = new anchor.web3.PublicKey("H6RLQCTDbiJdNP1K8Cjoc5MAabaAq5fEdcpdJjSwuXB4"); + + // console.log("1.1"); + + // const feeRecipientSharesAccount = await token.createAccount(provider.connection, feeRecipient, sharesMint, feeRecipient.publicKey); + // const feeRecipientTokenAccount = await token.createAccount(provider.connection, admin, underlyingMint, admin.publicKey); + + // console.log("1.2"); + + let strategy = anchor.web3.PublicKey.findProgramAddressSync( + [ + vault.toBuffer(), + Buffer.from(new Uint8Array([0])) + ], + strategyProgram.programId + )[0]; + + // console.log("2"); + + // let strategyTokenAccount = anchor.web3.PublicKey.findProgramAddressSync( + // [Buffer.from("underlying"), strategy.toBuffer()], + // strategyProgram.programId, + // )[0]; + + + // const strategyAccount = await strategyProgram.account.simpleStrategy.fetch(strategy); + // console.log("strategy vault:", strategyAccount.vault.toString()); + console.log("Vault strategies:", vaultAccount.strategies); + // console.log("3"); + + // await strategyProgram.methods.report() + // .accounts({ + // strategy, + // tokenAccount: strategyTokenAccount, + // signer: admin.publicKey, + // }) + // .remainingAccounts([ + // { pubkey: strategyTokenAccount, isWritable: true, isSigner: false }, + // ]) + // .signers([admin]) + // .rpc(); + + // console.log("4"); + + // await vaultProgram.methods.processReport() + // .accounts({ + // vault, + // strategy, + // signer: admin.publicKey, + // feeSharesRecipient: feeRecipientSharesAccount, + // }) + // .signers([admin]) + // .rpc(); + + // console.log("5"); + + //console.log("Updated depsotit limit to:", newDepositLimit.toString()); + } catch (error) { + console.error("Error occurred:", error); + } +} + +// Run the config function +main().catch((err) => { + console.error(err); + process.exit(1); +});