diff --git a/package-lock.json b/package-lock.json index b9017f172..7d8ba0e87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "@project-serum/anchor": "0.26.0", "@solana/spl-token": "0.3.7", "@solana/web3.js": "1.73.0", - "@uxd-protocol/uxd-client": "9.0.0-rc2" + "@uxd-protocol/uxd-client": "9.0.0-rc6" }, "devDependencies": { "@types/bn.js": "^5.1.1", @@ -278,9 +278,9 @@ "dev": true }, "node_modules/@uxd-protocol/uxd-client": { - "version": "9.0.0-rc2", - "resolved": "https://registry.npmjs.org/@uxd-protocol/uxd-client/-/uxd-client-9.0.0-rc2.tgz", - "integrity": "sha512-f19rgseag7gMglV42nrfxzjACS0yvbDqmWlZddzVEScJwz3cqW0T0CIupHSKpFOcDehEiSl7Q2aBdE+76Y1hqQ==", + "version": "9.0.0-rc6", + "resolved": "https://registry.npmjs.org/@uxd-protocol/uxd-client/-/uxd-client-9.0.0-rc6.tgz", + "integrity": "sha512-hnanayJLoqhFXDt7rKrEpzUDlH/66afQa2dWASX2W1aryLxoA0q+gMYTEPo8nL+dAli2ItilizuNlRPeA9I49A==", "dependencies": { "@project-serum/anchor": "0.26.0", "@solana/spl-token": "0.3.7", @@ -2908,9 +2908,9 @@ "dev": true }, "@uxd-protocol/uxd-client": { - "version": "9.0.0-rc2", - "resolved": "https://registry.npmjs.org/@uxd-protocol/uxd-client/-/uxd-client-9.0.0-rc2.tgz", - "integrity": "sha512-f19rgseag7gMglV42nrfxzjACS0yvbDqmWlZddzVEScJwz3cqW0T0CIupHSKpFOcDehEiSl7Q2aBdE+76Y1hqQ==", + "version": "9.0.0-rc6", + "resolved": "https://registry.npmjs.org/@uxd-protocol/uxd-client/-/uxd-client-9.0.0-rc6.tgz", + "integrity": "sha512-hnanayJLoqhFXDt7rKrEpzUDlH/66afQa2dWASX2W1aryLxoA0q+gMYTEPo8nL+dAli2ItilizuNlRPeA9I49A==", "requires": { "@project-serum/anchor": "0.26.0", "@solana/spl-token": "0.3.7", diff --git a/package.json b/package.json index b69c842e1..ce0744ac3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "@project-serum/anchor": "0.26.0", "@solana/spl-token": "0.3.7", "@solana/web3.js": "1.73.0", - "@uxd-protocol/uxd-client": "9.0.0-rc2" + "@uxd-protocol/uxd-client": "9.0.0-rc6" }, "devDependencies": { "@types/bn.js": "^5.1.1", diff --git a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-devnet.so b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-devnet.so index cdd637d68..b5d38ff2d 100644 Binary files a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-devnet.so and b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-devnet.so differ diff --git a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-mainnet-beta.so b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-mainnet-beta.so index 507514314..812e7e198 100644 Binary files a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-mainnet-beta.so and b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-mainnet-beta.so differ diff --git a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-pre-mainnet.so b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-pre-mainnet.so index d7309618e..c4d35110d 100644 Binary files a/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-pre-mainnet.so and b/programs/uxd/tests/integration_tests/api/program_credix/binaries/executable-pre-mainnet.so differ diff --git a/scripts/trigger_rebalance_alloyx.ts b/scripts/trigger_rebalance_alloyx.ts new file mode 100644 index 000000000..14d057c09 --- /dev/null +++ b/scripts/trigger_rebalance_alloyx.ts @@ -0,0 +1,167 @@ +import { + AlloyxVaultDepository, + UXDClient, + nativeToUi, +} from '@uxd-protocol/uxd-client'; +import { Transaction, ComputeBudgetProgram } from '@solana/web3.js'; +import { web3 } from '@project-serum/anchor'; +import { + createCredixLpDepositoryMainnet, + createIdentityDepositoryMainnet, + createMercurialVaultDepositoryMainnet, + createAlloyxVaultDepositoryMainnet, + getConnectionMainnet, + payer, + TXN_OPTS, + createControllerMainnet, + uxdProgramIdMainnet, +} from './common'; + +async function main() { + console.log(); + console.log('------------------------------ ------------------------------'); + console.log('------------------------ PREPARATION ------------------------'); + console.log('------------------------------ ------------------------------'); + console.log(); + + const controller = createControllerMainnet(); + const identityDepository = createIdentityDepositoryMainnet(); + const mercurialVaultDepository = + await createMercurialVaultDepositoryMainnet(); + const credixLpDepository = await createCredixLpDepositoryMainnet(); + const alloyxVaultDepository = await createAlloyxVaultDepositoryMainnet(); + + controller.info(); + identityDepository.info(); + mercurialVaultDepository.info(); + credixLpDepository.info(); + alloyxVaultDepository.info(); + + const alloyxVaultDepositoryAccount = + await alloyxVaultDepository.getOnchainAccount( + getConnectionMainnet(), + TXN_OPTS + ); + + const profitsBeneficiaryCollateral = + alloyxVaultDepositoryAccount.profitsBeneficiaryCollateral; + console.log( + 'profitsBeneficiaryCollateral', + profitsBeneficiaryCollateral.toBase58() + ); + + const uxdClient = new UXDClient(uxdProgramIdMainnet); + + console.log(); + console.log('------------------------------ ------------------------------'); + console.log('---------------------- ALLOYX REBALANCE ---------------------'); + console.log('------------------------------ ------------------------------'); + console.log(); + + const rebalanceInstruction = + uxdClient.createRebalanceAlloyxVaultDepositoryInstruction( + controller, + identityDepository, + mercurialVaultDepository, + credixLpDepository, + alloyxVaultDepository, + payer.publicKey, + profitsBeneficiaryCollateral, + TXN_OPTS + ); + const rebalanceCreateTransaction = new Transaction(); + rebalanceCreateTransaction.add(rebalanceInstruction); + rebalanceCreateTransaction.add( + ComputeBudgetProgram.setComputeUnitLimit({ + units: 400_000, + }) + ); + rebalanceCreateTransaction.feePayer = payer.publicKey; + + try { + const rebalanceResult = await web3.sendAndConfirmTransaction( + getConnectionMainnet(), + rebalanceCreateTransaction, + [payer], + TXN_OPTS + ); + console.log('rebalanceResult', rebalanceResult); + } catch (rebalanceError) { + console.log('rebalanceError', rebalanceError); + } + + console.log(); + console.log('------------------------------ ------------------------------'); + console.log('------------------- LATEST ON-CHAIN STATE -------------------'); + console.log('------------------------------ ------------------------------'); + console.log(); + + const alloyxProgram = AlloyxVaultDepository.getAlloyxProgram( + getConnectionMainnet(), + alloyxVaultDepository.alloyxProgramId + ); + + const alloyxVaultInfo = await AlloyxVaultDepository.getAlloyxVaultInfoAccount( + alloyxProgram, + alloyxVaultDepository.alloyxVaultInfo + ); + console.log('> alloyxVaultInfo'); + console.log( + 'alloyxVaultInfo.walletDeskUsdcValue', + nativeToUi( + alloyxVaultInfo.walletDeskUsdcValue, + alloyxVaultDepository.collateralDecimals + ) + ); + console.log(); + + const alloyxVaultPass = await AlloyxVaultDepository.getAlloyxVaultPassAccount( + alloyxProgram, + alloyxVaultDepository.alloyxVaultPass + ); + console.log('> alloyxVaultPass'); + console.log('alloyxVaultPass.investor', alloyxVaultPass.investor.toBase58()); + console.log(); + + const alloyxVaultMint = await getConnectionMainnet().getTokenSupply( + alloyxVaultInfo.alloyxMint + ); + console.log('> alloyxVaultMint'); + console.log('alloyxVaultMint.supply', alloyxVaultMint.value.uiAmount); + console.log(); + + const alloyxVaultCollateral = + await getConnectionMainnet().getTokenAccountBalance( + alloyxVaultDepository.alloyxVaultCollateral + ); + console.log('> alloyxVaultCollateral'); + console.log( + 'alloyxVaultCollateral.amount', + alloyxVaultCollateral.value.uiAmount + ); + console.log(); + + const depositoryCollateralAccount = + await getConnectionMainnet().getTokenAccountBalance( + alloyxVaultDepository.depositoryCollateral + ); + console.log('> depositoryCollateral'); + console.log( + 'depositoryCollateral.amount', + depositoryCollateralAccount.value.uiAmount + ); + console.log(); + + const depositorySharesAccount = + await getConnectionMainnet().getTokenAccountBalance( + alloyxVaultDepository.depositoryShares + ); + console.log('> depositoryShares'); + console.log( + 'depositoryShares.amount', + depositorySharesAccount.value.uiAmount + ); + console.log(); +} + +main();