Skip to content
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

Mainnet deployment #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

----------------------------------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion programs/faucet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod error;

pub use instructions::*;

declare_id!("GUrM139EUwYkoEWebecqiTLJrvut4mDdHGTu9d87tgQC");
declare_id!("4rza9AifAapN4SKho3teAuLhc1TPpNWp9DHNPEMzVqgp");

#[program]
pub mod faucet {
Expand Down
2 changes: 1 addition & 1 deletion programs/strategy_program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion programs/tokenized_vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use constants::*;
pub use state::*;
pub use instructions::*;

declare_id!("8eDcyX8Z8yZXBQsuatwxDC1qzGbuUbP7wGERDBQoPmBH");
declare_id!("5R6bVKZfag4X9vW4nek6UNP8XXwH7cPaVohyAo1xfVEU");

#[program]
pub mod tokenized_vault {
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-underlying-mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions scripts/create_default_vault_with_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ 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);

const vaultProgram = anchor.workspace.TokenizedVault as Program<TokenizedVault>;
const strategyProgram = anchor.workspace.StrategyProgram as Program<StrategyProgram>;

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(
[
Expand Down
10 changes: 6 additions & 4 deletions scripts/create_vault_with_trade_fi_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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);

const vaultProgram = anchor.workspace.TokenizedVault as Program<TokenizedVault>;
const strategyProgram = anchor.workspace.StrategyProgram as Program<StrategyProgram>;

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;
Expand Down Expand Up @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/init_faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -21,7 +21,7 @@ async function main() {
let faucetProgram: Program<Faucet> = 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")],
Expand Down
2 changes: 1 addition & 1 deletion scripts/set_roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
115 changes: 115 additions & 0 deletions scripts/vault_init_share.ts
Original file line number Diff line number Diff line change
@@ -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<TokenizedVault>;
const strategyProgram = anchor.workspace.TokenizedVault as Program<StrategyProgram>;

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);
});