@haven-fi/solauto-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/index.d.ts +2 -0
- package/dist/clients/index.d.ts.map +1 -0
- package/dist/clients/index.js +17 -0
- package/dist/clients/solautoClient.d.ts +73 -0
- package/dist/clients/solautoClient.d.ts.map +1 -0
- package/dist/clients/solautoClient.js +416 -0
- package/dist/clients/solautoMarginfiClient.d.ts +40 -0
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -0
- package/dist/clients/solautoMarginfiClient.js +313 -0
- package/dist/constants/generalAccounts.d.ts +5 -0
- package/dist/constants/generalAccounts.d.ts.map +1 -0
- package/dist/constants/generalAccounts.js +8 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/marginfiAccounts.d.ts +7 -0
- package/dist/constants/marginfiAccounts.d.ts.map +1 -0
- package/dist/constants/marginfiAccounts.js +23 -0
- package/dist/constants/pythConstants.d.ts +5 -0
- package/dist/constants/pythConstants.d.ts.map +1 -0
- package/dist/constants/pythConstants.js +10 -0
- package/dist/constants/solautoConstants.d.ts +19 -0
- package/dist/constants/solautoConstants.d.ts.map +1 -0
- package/dist/constants/solautoConstants.js +35 -0
- package/dist/constants/tokenConstants.d.ts +3 -0
- package/dist/constants/tokenConstants.d.ts.map +1 -0
- package/dist/constants/tokenConstants.js +10 -0
- package/dist/generated/accounts/index.d.ts +10 -0
- package/dist/generated/accounts/index.d.ts.map +1 -0
- package/dist/generated/accounts/index.js +25 -0
- package/dist/generated/accounts/referralState.d.ts +37 -0
- package/dist/generated/accounts/referralState.d.ts.map +1 -0
- package/dist/generated/accounts/referralState.js +73 -0
- package/dist/generated/accounts/solautoPosition.d.ts +58 -0
- package/dist/generated/accounts/solautoPosition.d.ts.map +1 -0
- package/dist/generated/accounts/solautoPosition.js +82 -0
- package/dist/generated/errors/index.d.ts +9 -0
- package/dist/generated/errors/index.d.ts.map +1 -0
- package/dist/generated/errors/index.js +24 -0
- package/dist/generated/errors/solauto.d.ts +91 -0
- package/dist/generated/errors/solauto.d.ts.map +1 -0
- package/dist/generated/errors/solauto.js +163 -0
- package/dist/generated/index.d.ts +14 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +29 -0
- package/dist/generated/instructions/cancelDCA.d.ts +26 -0
- package/dist/generated/instructions/cancelDCA.d.ts.map +1 -0
- package/dist/generated/instructions/cancelDCA.js +92 -0
- package/dist/generated/instructions/claimReferralFees.d.ts +26 -0
- package/dist/generated/instructions/claimReferralFees.d.ts.map +1 -0
- package/dist/generated/instructions/claimReferralFees.js +87 -0
- package/dist/generated/instructions/closePosition.d.ts +28 -0
- package/dist/generated/instructions/closePosition.d.ts.map +1 -0
- package/dist/generated/instructions/closePosition.js +102 -0
- package/dist/generated/instructions/convertReferralFees.d.ts +27 -0
- package/dist/generated/instructions/convertReferralFees.d.ts.map +1 -0
- package/dist/generated/instructions/convertReferralFees.js +96 -0
- package/dist/generated/instructions/index.d.ts +18 -0
- package/dist/generated/instructions/index.d.ts.map +1 -0
- package/dist/generated/instructions/index.js +33 -0
- package/dist/generated/instructions/marginfiOpenPosition.d.ts +46 -0
- package/dist/generated/instructions/marginfiOpenPosition.d.ts.map +1 -0
- package/dist/generated/instructions/marginfiOpenPosition.js +161 -0
- package/dist/generated/instructions/marginfiProtocolInteraction.d.ts +42 -0
- package/dist/generated/instructions/marginfiProtocolInteraction.d.ts.map +1 -0
- package/dist/generated/instructions/marginfiProtocolInteraction.js +150 -0
- package/dist/generated/instructions/marginfiRebalance.d.ts +49 -0
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -0
- package/dist/generated/instructions/marginfiRebalance.js +164 -0
- package/dist/generated/instructions/marginfiRefreshData.d.ts +27 -0
- package/dist/generated/instructions/marginfiRefreshData.d.ts.map +1 -0
- package/dist/generated/instructions/marginfiRefreshData.js +84 -0
- package/dist/generated/instructions/updatePosition.d.ts +30 -0
- package/dist/generated/instructions/updatePosition.d.ts.map +1 -0
- package/dist/generated/instructions/updatePosition.js +87 -0
- package/dist/generated/instructions/updateReferralStates.d.ts +30 -0
- package/dist/generated/instructions/updateReferralStates.d.ts.map +1 -0
- package/dist/generated/instructions/updateReferralStates.js +77 -0
- package/dist/generated/programs/index.d.ts +9 -0
- package/dist/generated/programs/index.d.ts.map +1 -0
- package/dist/generated/programs/index.js +24 -0
- package/dist/generated/programs/solauto.d.ts +13 -0
- package/dist/generated/programs/solauto.d.ts.map +1 -0
- package/dist/generated/programs/solauto.js +36 -0
- package/dist/generated/shared/index.d.ts +54 -0
- package/dist/generated/shared/index.d.ts.map +1 -0
- package/dist/generated/shared/index.js +70 -0
- package/dist/generated/types/automationSettings.d.ts +26 -0
- package/dist/generated/types/automationSettings.d.ts.map +1 -0
- package/dist/generated/types/automationSettings.js +22 -0
- package/dist/generated/types/automationSettingsInp.d.ts +22 -0
- package/dist/generated/types/automationSettingsInp.d.ts.map +1 -0
- package/dist/generated/types/automationSettingsInp.js +20 -0
- package/dist/generated/types/dCASettings.d.ts +21 -0
- package/dist/generated/types/dCASettings.d.ts.map +1 -0
- package/dist/generated/types/dCASettings.js +20 -0
- package/dist/generated/types/dCASettingsInp.d.ts +19 -0
- package/dist/generated/types/dCASettingsInp.d.ts.map +1 -0
- package/dist/generated/types/dCASettingsInp.js +19 -0
- package/dist/generated/types/feeType.d.ts +15 -0
- package/dist/generated/types/feeType.d.ts.map +1 -0
- package/dist/generated/types/feeType.js +20 -0
- package/dist/generated/types/index.d.ts +26 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +41 -0
- package/dist/generated/types/lendingPlatform.d.ts +16 -0
- package/dist/generated/types/lendingPlatform.d.ts.map +1 -0
- package/dist/generated/types/lendingPlatform.js +23 -0
- package/dist/generated/types/podBool.d.ts +14 -0
- package/dist/generated/types/podBool.d.ts.map +1 -0
- package/dist/generated/types/podBool.js +17 -0
- package/dist/generated/types/positionData.d.ts +32 -0
- package/dist/generated/types/positionData.d.ts.map +1 -0
- package/dist/generated/types/positionData.js +25 -0
- package/dist/generated/types/positionState.d.ts +35 -0
- package/dist/generated/types/positionState.d.ts.map +1 -0
- package/dist/generated/types/positionState.js +27 -0
- package/dist/generated/types/positionTokenUsage.d.ts +36 -0
- package/dist/generated/types/positionTokenUsage.d.ts.map +1 -0
- package/dist/generated/types/positionTokenUsage.js +27 -0
- package/dist/generated/types/rebalanceData.d.ts +29 -0
- package/dist/generated/types/rebalanceData.d.ts.map +1 -0
- package/dist/generated/types/rebalanceData.js +24 -0
- package/dist/generated/types/solautoAction.d.ts +44 -0
- package/dist/generated/types/solautoAction.d.ts.map +1 -0
- package/dist/generated/types/solautoAction.js +51 -0
- package/dist/generated/types/solautoRebalanceType.d.ts +17 -0
- package/dist/generated/types/solautoRebalanceType.d.ts.map +1 -0
- package/dist/generated/types/solautoRebalanceType.js +24 -0
- package/dist/generated/types/solautoSettingsParameters.d.ts +31 -0
- package/dist/generated/types/solautoSettingsParameters.d.ts.map +1 -0
- package/dist/generated/types/solautoSettingsParameters.js +25 -0
- package/dist/generated/types/solautoSettingsParametersInp.d.ts +28 -0
- package/dist/generated/types/solautoSettingsParametersInp.d.ts.map +1 -0
- package/dist/generated/types/solautoSettingsParametersInp.js +23 -0
- package/dist/generated/types/tokenAmount.d.ts +18 -0
- package/dist/generated/types/tokenAmount.d.ts.map +1 -0
- package/dist/generated/types/tokenAmount.js +18 -0
- package/dist/generated/types/tokenBalanceAmount.d.ts +27 -0
- package/dist/generated/types/tokenBalanceAmount.d.ts.map +1 -0
- package/dist/generated/types/tokenBalanceAmount.js +33 -0
- package/dist/generated/types/updatePositionData.d.ts +22 -0
- package/dist/generated/types/updatePositionData.d.ts.map +1 -0
- package/dist/generated/types/updatePositionData.js +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/marginfi-sdk/accounts/bank.d.ts +136 -0
- package/dist/marginfi-sdk/accounts/bank.d.ts.map +1 -0
- package/dist/marginfi-sdk/accounts/bank.js +124 -0
- package/dist/marginfi-sdk/accounts/index.d.ts +11 -0
- package/dist/marginfi-sdk/accounts/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/accounts/index.js +26 -0
- package/dist/marginfi-sdk/accounts/marginfiAccount.d.ts +58 -0
- package/dist/marginfi-sdk/accounts/marginfiAccount.d.ts.map +1 -0
- package/dist/marginfi-sdk/accounts/marginfiAccount.js +76 -0
- package/dist/marginfi-sdk/accounts/marginfiGroup.d.ts +35 -0
- package/dist/marginfi-sdk/accounts/marginfiGroup.d.ts.map +1 -0
- package/dist/marginfi-sdk/accounts/marginfiGroup.js +71 -0
- package/dist/marginfi-sdk/errors/index.d.ts +9 -0
- package/dist/marginfi-sdk/errors/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/errors/index.js +24 -0
- package/dist/marginfi-sdk/errors/marginfi.d.ts +283 -0
- package/dist/marginfi-sdk/errors/marginfi.d.ts.map +1 -0
- package/dist/marginfi-sdk/errors/marginfi.js +515 -0
- package/dist/marginfi-sdk/index.d.ts +14 -0
- package/dist/marginfi-sdk/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/index.js +29 -0
- package/dist/marginfi-sdk/instructions/index.d.ts +32 -0
- package/dist/marginfi-sdk/instructions/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/index.js +47 -0
- package/dist/marginfi-sdk/instructions/lendingAccountBorrow.d.ts +30 -0
- package/dist/marginfi-sdk/instructions/lendingAccountBorrow.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountBorrow.js +83 -0
- package/dist/marginfi-sdk/instructions/lendingAccountCloseBalance.d.ts +22 -0
- package/dist/marginfi-sdk/instructions/lendingAccountCloseBalance.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountCloseBalance.js +53 -0
- package/dist/marginfi-sdk/instructions/lendingAccountDeposit.d.ts +29 -0
- package/dist/marginfi-sdk/instructions/lendingAccountDeposit.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountDeposit.js +81 -0
- package/dist/marginfi-sdk/instructions/lendingAccountEndFlashloan.d.ts +20 -0
- package/dist/marginfi-sdk/instructions/lendingAccountEndFlashloan.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountEndFlashloan.js +50 -0
- package/dist/marginfi-sdk/instructions/lendingAccountLiquidate.d.ts +32 -0
- package/dist/marginfi-sdk/instructions/lendingAccountLiquidate.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountLiquidate.js +100 -0
- package/dist/marginfi-sdk/instructions/lendingAccountRepay.d.ts +31 -0
- package/dist/marginfi-sdk/instructions/lendingAccountRepay.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountRepay.js +82 -0
- package/dist/marginfi-sdk/instructions/lendingAccountSettleEmissions.d.ts +20 -0
- package/dist/marginfi-sdk/instructions/lendingAccountSettleEmissions.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountSettleEmissions.js +46 -0
- package/dist/marginfi-sdk/instructions/lendingAccountStartFlashloan.d.ts +25 -0
- package/dist/marginfi-sdk/instructions/lendingAccountStartFlashloan.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountStartFlashloan.js +62 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdraw.d.ts +32 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdraw.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdraw.js +87 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdrawEmissions.d.ts +27 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdrawEmissions.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingAccountWithdrawEmissions.js +86 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAccrueBankInterest.d.ts +20 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAccrueBankInterest.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAccrueBankInterest.js +46 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBank.d.ts +37 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBank.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBank.js +127 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBankWithSeed.d.ts +39 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBankWithSeed.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolAddBankWithSeed.js +128 -0
- package/dist/marginfi-sdk/instructions/lendingPoolCollectBankFees.d.ts +25 -0
- package/dist/marginfi-sdk/instructions/lendingPoolCollectBankFees.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolCollectBankFees.js +76 -0
- package/dist/marginfi-sdk/instructions/lendingPoolConfigureBank.d.ts +46 -0
- package/dist/marginfi-sdk/instructions/lendingPoolConfigureBank.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolConfigureBank.js +67 -0
- package/dist/marginfi-sdk/instructions/lendingPoolHandleBankruptcy.d.ts +26 -0
- package/dist/marginfi-sdk/instructions/lendingPoolHandleBankruptcy.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolHandleBankruptcy.js +81 -0
- package/dist/marginfi-sdk/instructions/lendingPoolSetupEmissions.d.ts +35 -0
- package/dist/marginfi-sdk/instructions/lendingPoolSetupEmissions.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolSetupEmissions.js +97 -0
- package/dist/marginfi-sdk/instructions/lendingPoolUpdateEmissionsParameters.d.ts +33 -0
- package/dist/marginfi-sdk/instructions/lendingPoolUpdateEmissionsParameters.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/lendingPoolUpdateEmissionsParameters.js +85 -0
- package/dist/marginfi-sdk/instructions/marginfiAccountInitialize.d.ts +23 -0
- package/dist/marginfi-sdk/instructions/marginfiAccountInitialize.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/marginfiAccountInitialize.js +76 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupConfigure.d.ts +24 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupConfigure.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupConfigure.js +52 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupInitialize.d.ts +21 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupInitialize.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/marginfiGroupInitialize.js +57 -0
- package/dist/marginfi-sdk/instructions/setAccountFlag.d.ts +26 -0
- package/dist/marginfi-sdk/instructions/setAccountFlag.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/setAccountFlag.js +60 -0
- package/dist/marginfi-sdk/instructions/setNewAccountAuthority.d.ts +23 -0
- package/dist/marginfi-sdk/instructions/setNewAccountAuthority.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/setNewAccountAuthority.js +69 -0
- package/dist/marginfi-sdk/instructions/unsetAccountFlag.d.ts +26 -0
- package/dist/marginfi-sdk/instructions/unsetAccountFlag.d.ts.map +1 -0
- package/dist/marginfi-sdk/instructions/unsetAccountFlag.js +57 -0
- package/dist/marginfi-sdk/programs/index.d.ts +9 -0
- package/dist/marginfi-sdk/programs/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/programs/index.js +24 -0
- package/dist/marginfi-sdk/programs/marginfi.d.ts +13 -0
- package/dist/marginfi-sdk/programs/marginfi.d.ts.map +1 -0
- package/dist/marginfi-sdk/programs/marginfi.js +36 -0
- package/dist/marginfi-sdk/shared/index.d.ts +54 -0
- package/dist/marginfi-sdk/shared/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/shared/index.js +70 -0
- package/dist/marginfi-sdk/types/accountEventHeader.d.ts +23 -0
- package/dist/marginfi-sdk/types/accountEventHeader.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/accountEventHeader.js +20 -0
- package/dist/marginfi-sdk/types/balance.d.ts +32 -0
- package/dist/marginfi-sdk/types/balance.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/balance.js +25 -0
- package/dist/marginfi-sdk/types/balanceDecreaseType.d.ts +17 -0
- package/dist/marginfi-sdk/types/balanceDecreaseType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/balanceDecreaseType.js +24 -0
- package/dist/marginfi-sdk/types/balanceIncreaseType.d.ts +17 -0
- package/dist/marginfi-sdk/types/balanceIncreaseType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/balanceIncreaseType.js +24 -0
- package/dist/marginfi-sdk/types/balanceSide.d.ts +15 -0
- package/dist/marginfi-sdk/types/balanceSide.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/balanceSide.js +22 -0
- package/dist/marginfi-sdk/types/bankConfig.d.ts +67 -0
- package/dist/marginfi-sdk/types/bankConfig.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/bankConfig.js +32 -0
- package/dist/marginfi-sdk/types/bankConfigCompact.d.ts +65 -0
- package/dist/marginfi-sdk/types/bankConfigCompact.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/bankConfigCompact.js +31 -0
- package/dist/marginfi-sdk/types/bankOperationalState.d.ts +16 -0
- package/dist/marginfi-sdk/types/bankOperationalState.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/bankOperationalState.js +23 -0
- package/dist/marginfi-sdk/types/bankVaultType.d.ts +16 -0
- package/dist/marginfi-sdk/types/bankVaultType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/bankVaultType.js +23 -0
- package/dist/marginfi-sdk/types/groupEventHeader.d.ts +19 -0
- package/dist/marginfi-sdk/types/groupEventHeader.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/groupEventHeader.js +18 -0
- package/dist/marginfi-sdk/types/index.d.ts +31 -0
- package/dist/marginfi-sdk/types/index.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/index.js +46 -0
- package/dist/marginfi-sdk/types/interestRateConfig.d.ts +31 -0
- package/dist/marginfi-sdk/types/interestRateConfig.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/interestRateConfig.js +25 -0
- package/dist/marginfi-sdk/types/interestRateConfigCompact.d.ts +29 -0
- package/dist/marginfi-sdk/types/interestRateConfigCompact.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/interestRateConfigCompact.js +24 -0
- package/dist/marginfi-sdk/types/interestRateConfigOpt.d.ts +30 -0
- package/dist/marginfi-sdk/types/interestRateConfigOpt.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/interestRateConfigOpt.js +24 -0
- package/dist/marginfi-sdk/types/lendingAccount.d.ts +19 -0
- package/dist/marginfi-sdk/types/lendingAccount.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/lendingAccount.js +19 -0
- package/dist/marginfi-sdk/types/liquidationBalances.d.ts +17 -0
- package/dist/marginfi-sdk/types/liquidationBalances.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/liquidationBalances.js +20 -0
- package/dist/marginfi-sdk/types/oracleConfig.d.ts +20 -0
- package/dist/marginfi-sdk/types/oracleConfig.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/oracleConfig.js +19 -0
- package/dist/marginfi-sdk/types/oraclePriceType.d.ts +15 -0
- package/dist/marginfi-sdk/types/oraclePriceType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/oraclePriceType.js +22 -0
- package/dist/marginfi-sdk/types/oracleSetup.d.ts +17 -0
- package/dist/marginfi-sdk/types/oracleSetup.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/oracleSetup.js +24 -0
- package/dist/marginfi-sdk/types/priceBias.d.ts +15 -0
- package/dist/marginfi-sdk/types/priceBias.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/priceBias.js +22 -0
- package/dist/marginfi-sdk/types/requirementType.d.ts +16 -0
- package/dist/marginfi-sdk/types/requirementType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/requirementType.js +23 -0
- package/dist/marginfi-sdk/types/riskRequirementType.d.ts +16 -0
- package/dist/marginfi-sdk/types/riskRequirementType.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/riskRequirementType.js +23 -0
- package/dist/marginfi-sdk/types/riskTier.d.ts +15 -0
- package/dist/marginfi-sdk/types/riskTier.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/riskTier.js +22 -0
- package/dist/marginfi-sdk/types/wrappedI80F48.d.ts +16 -0
- package/dist/marginfi-sdk/types/wrappedI80F48.d.ts.map +1 -0
- package/dist/marginfi-sdk/types/wrappedI80F48.js +17 -0
- package/dist/transactions/index.d.ts +3 -0
- package/dist/transactions/index.d.ts.map +1 -0
- package/dist/transactions/index.js +18 -0
- package/dist/transactions/transactionUtils.d.ts +12 -0
- package/dist/transactions/transactionUtils.d.ts.map +1 -0
- package/dist/transactions/transactionUtils.js +262 -0
- package/dist/transactions/transactionsManager.d.ts +42 -0
- package/dist/transactions/transactionsManager.d.ts.map +1 -0
- package/dist/transactions/transactionsManager.js +246 -0
- package/dist/types/accounts.d.ts +8 -0
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/accounts.js +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/utils/accountUtils.d.ts +11 -0
- package/dist/utils/accountUtils.d.ts.map +1 -0
- package/dist/utils/accountUtils.js +60 -0
- package/dist/utils/deleteme.d.ts +2 -0
- package/dist/utils/deleteme.d.ts.map +1 -0
- package/dist/utils/deleteme.js +21 -0
- package/dist/utils/generalUtils.d.ts +11 -0
- package/dist/utils/generalUtils.d.ts.map +1 -0
- package/dist/utils/generalUtils.js +107 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/jitoUtils.d.ts +15 -0
- package/dist/utils/jitoUtils.d.ts.map +1 -0
- package/dist/utils/jitoUtils.js +108 -0
- package/dist/utils/jupiterUtils.d.ts +21 -0
- package/dist/utils/jupiterUtils.d.ts.map +1 -0
- package/dist/utils/jupiterUtils.js +61 -0
- package/dist/utils/local/shared.d.ts +3 -0
- package/dist/utils/local/shared.d.ts.map +1 -0
- package/dist/utils/local/shared.js +63 -0
- package/dist/utils/local/updateMarginfiLUT.d.ts +2 -0
- package/dist/utils/local/updateMarginfiLUT.d.ts.map +1 -0
- package/dist/utils/local/updateMarginfiLUT.js +22 -0
- package/dist/utils/local/updateSolautoLUT.d.ts +2 -0
- package/dist/utils/local/updateSolautoLUT.d.ts.map +1 -0
- package/dist/utils/local/updateSolautoLUT.js +13 -0
- package/dist/utils/marginfiUtils.d.ts +14 -0
- package/dist/utils/marginfiUtils.d.ts.map +1 -0
- package/dist/utils/marginfiUtils.js +201 -0
- package/dist/utils/numberUtils.d.ts +9 -0
- package/dist/utils/numberUtils.d.ts.map +1 -0
- package/dist/utils/numberUtils.js +62 -0
- package/dist/utils/solanaUtils.d.ts +18 -0
- package/dist/utils/solanaUtils.d.ts.map +1 -0
- package/dist/utils/solanaUtils.js +183 -0
- package/dist/utils/solauto/generalUtils.d.ts +51 -0
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -0
- package/dist/utils/solauto/generalUtils.js +271 -0
- package/dist/utils/solauto/index.d.ts +3 -0
- package/dist/utils/solauto/index.d.ts.map +1 -0
- package/dist/utils/solauto/index.js +18 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts +17 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -0
- package/dist/utils/solauto/rebalanceUtils.js +199 -0
- package/package.json +37 -0
- package/src/clients/index.ts +1 -0
- package/src/clients/solautoClient.ts +684 -0
- package/src/clients/solautoMarginfiClient.ts +496 -0
- package/src/constants/README.md +9 -0
- package/src/constants/generalAccounts.ts +8 -0
- package/src/constants/index.ts +5 -0
- package/src/constants/marginfiAccounts.ts +24 -0
- package/src/constants/pythConstants.ts +10 -0
- package/src/constants/solautoConstants.ts +54 -0
- package/src/constants/tokenConstants.ts +9 -0
- package/src/generated/accounts/index.ts +10 -0
- package/src/generated/accounts/referralState.ts +159 -0
- package/src/generated/accounts/solautoPosition.ts +205 -0
- package/src/generated/errors/index.ts +9 -0
- package/src/generated/errors/solauto.ts +228 -0
- package/src/generated/index.ts +14 -0
- package/src/generated/instructions/cancelDCA.ts +161 -0
- package/src/generated/instructions/claimReferralFees.ts +159 -0
- package/src/generated/instructions/closePosition.ts +176 -0
- package/src/generated/instructions/convertReferralFees.ts +172 -0
- package/src/generated/instructions/index.ts +18 -0
- package/src/generated/instructions/marginfiOpenPosition.ts +275 -0
- package/src/generated/instructions/marginfiProtocolInteraction.ts +257 -0
- package/src/generated/instructions/marginfiRebalance.ts +274 -0
- package/src/generated/instructions/marginfiRefreshData.ts +147 -0
- package/src/generated/instructions/updatePosition.ts +173 -0
- package/src/generated/instructions/updateReferralStates.ts +166 -0
- package/src/generated/programs/index.ts +9 -0
- package/src/generated/programs/solauto.ts +52 -0
- package/src/generated/shared/index.ts +117 -0
- package/src/generated/types/automationSettings.ts +52 -0
- package/src/generated/types/automationSettingsInp.ts +43 -0
- package/src/generated/types/dCASettings.ts +45 -0
- package/src/generated/types/dCASettingsInp.ts +37 -0
- package/src/generated/types/feeType.ts +23 -0
- package/src/generated/types/index.ts +26 -0
- package/src/generated/types/lendingPlatform.ts +26 -0
- package/src/generated/types/podBool.ts +19 -0
- package/src/generated/types/positionData.ts +69 -0
- package/src/generated/types/positionState.ts +72 -0
- package/src/generated/types/positionTokenUsage.ts +67 -0
- package/src/generated/types/rebalanceData.ts +60 -0
- package/src/generated/types/solautoAction.ts +101 -0
- package/src/generated/types/solautoRebalanceType.ts +27 -0
- package/src/generated/types/solautoSettingsParameters.ts +62 -0
- package/src/generated/types/solautoSettingsParametersInp.ts +58 -0
- package/src/generated/types/tokenAmount.ts +29 -0
- package/src/generated/types/tokenBalanceAmount.ts +67 -0
- package/src/generated/types/updatePositionData.ts +49 -0
- package/src/index.ts +6 -0
- package/src/marginfi-sdk/accounts/bank.ts +311 -0
- package/src/marginfi-sdk/accounts/index.ts +11 -0
- package/src/marginfi-sdk/accounts/marginfiAccount.ts +195 -0
- package/src/marginfi-sdk/accounts/marginfiGroup.ts +164 -0
- package/src/marginfi-sdk/errors/index.ts +9 -0
- package/src/marginfi-sdk/errors/marginfi.ts +650 -0
- package/src/marginfi-sdk/index.ts +14 -0
- package/src/marginfi-sdk/instructions/index.ts +32 -0
- package/src/marginfi-sdk/instructions/lendingAccountBorrow.ts +167 -0
- package/src/marginfi-sdk/instructions/lendingAccountCloseBalance.ts +118 -0
- package/src/marginfi-sdk/instructions/lendingAccountDeposit.ts +164 -0
- package/src/marginfi-sdk/instructions/lendingAccountEndFlashloan.ts +113 -0
- package/src/marginfi-sdk/instructions/lendingAccountLiquidate.ts +186 -0
- package/src/marginfi-sdk/instructions/lendingAccountRepay.ts +171 -0
- package/src/marginfi-sdk/instructions/lendingAccountSettleEmissions.ts +108 -0
- package/src/marginfi-sdk/instructions/lendingAccountStartFlashloan.ts +138 -0
- package/src/marginfi-sdk/instructions/lendingAccountWithdraw.ts +177 -0
- package/src/marginfi-sdk/instructions/lendingAccountWithdrawEmissions.ts +160 -0
- package/src/marginfi-sdk/instructions/lendingPoolAccrueBankInterest.ts +108 -0
- package/src/marginfi-sdk/instructions/lendingPoolAddBank.ts +226 -0
- package/src/marginfi-sdk/instructions/lendingPoolAddBankWithSeed.ts +231 -0
- package/src/marginfi-sdk/instructions/lendingPoolCollectBankFees.ts +147 -0
- package/src/marginfi-sdk/instructions/lendingPoolConfigureBank.ts +181 -0
- package/src/marginfi-sdk/instructions/lendingPoolHandleBankruptcy.ts +154 -0
- package/src/marginfi-sdk/instructions/lendingPoolSetupEmissions.ts +190 -0
- package/src/marginfi-sdk/instructions/lendingPoolUpdateEmissionsParameters.ts +176 -0
- package/src/marginfi-sdk/instructions/marginfiAccountInitialize.ts +146 -0
- package/src/marginfi-sdk/instructions/marginfiGroupConfigure.ts +129 -0
- package/src/marginfi-sdk/instructions/marginfiGroupInitialize.ts +126 -0
- package/src/marginfi-sdk/instructions/setAccountFlag.ts +132 -0
- package/src/marginfi-sdk/instructions/setNewAccountAuthority.ts +137 -0
- package/src/marginfi-sdk/instructions/unsetAccountFlag.ts +130 -0
- package/src/marginfi-sdk/programs/index.ts +9 -0
- package/src/marginfi-sdk/programs/marginfi.ts +52 -0
- package/src/marginfi-sdk/shared/index.ts +117 -0
- package/src/marginfi-sdk/types/accountEventHeader.ts +44 -0
- package/src/marginfi-sdk/types/balance.ts +61 -0
- package/src/marginfi-sdk/types/balanceDecreaseType.ts +27 -0
- package/src/marginfi-sdk/types/balanceIncreaseType.ts +27 -0
- package/src/marginfi-sdk/types/balanceSide.ts +25 -0
- package/src/marginfi-sdk/types/bankConfig.ts +117 -0
- package/src/marginfi-sdk/types/bankConfigCompact.ts +114 -0
- package/src/marginfi-sdk/types/bankOperationalState.ts +26 -0
- package/src/marginfi-sdk/types/bankVaultType.ts +26 -0
- package/src/marginfi-sdk/types/groupEventHeader.ts +38 -0
- package/src/marginfi-sdk/types/index.ts +31 -0
- package/src/marginfi-sdk/types/interestRateConfig.ts +60 -0
- package/src/marginfi-sdk/types/interestRateConfigCompact.ts +52 -0
- package/src/marginfi-sdk/types/interestRateConfigOpt.ts +57 -0
- package/src/marginfi-sdk/types/lendingAccount.ts +38 -0
- package/src/marginfi-sdk/types/liquidationBalances.ts +33 -0
- package/src/marginfi-sdk/types/oracleConfig.ts +36 -0
- package/src/marginfi-sdk/types/oraclePriceType.ts +25 -0
- package/src/marginfi-sdk/types/oracleSetup.ts +27 -0
- package/src/marginfi-sdk/types/priceBias.ts +22 -0
- package/src/marginfi-sdk/types/requirementType.ts +26 -0
- package/src/marginfi-sdk/types/riskRequirementType.ts +26 -0
- package/src/marginfi-sdk/types/riskTier.ts +22 -0
- package/src/marginfi-sdk/types/wrappedI80F48.ts +22 -0
- package/src/transactions/index.ts +2 -0
- package/src/transactions/transactionUtils.ts +518 -0
- package/src/transactions/transactionsManager.ts +344 -0
- package/src/types/accounts.ts +7 -0
- package/src/types/index.ts +1 -0
- package/src/utils/accountUtils.ts +92 -0
- package/src/utils/deleteme.ts +40 -0
- package/src/utils/generalUtils.ts +123 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/jitoUtils.ts +192 -0
- package/src/utils/jupiterUtils.ts +114 -0
- package/src/utils/local/shared.ts +85 -0
- package/src/utils/local/updateMarginfiLUT.ts +33 -0
- package/src/utils/local/updateSolautoLUT.ts +15 -0
- package/src/utils/marginfiUtils.ts +383 -0
- package/src/utils/numberUtils.ts +77 -0
- package/src/utils/solanaUtils.ts +333 -0
- package/src/utils/solauto/generalUtils.ts +371 -0
- package/src/utils/solauto/index.ts +2 -0
- package/src/utils/solauto/rebalanceUtils.ts +359 -0
- package/tests/shared.ts +15 -0
- package/tests/transactions/solautoMarginfi.ts +144 -0
- package/tests/unit/lookupTables.ts +40 -0
- package/tests/unit/rebalanceCalculations.ts +432 -0
- package/tsconfig.json +22 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
import { assert } from "chai";
|
2
|
+
import { SolautoClient } from "../clients/solautoClient";
|
3
|
+
import { Keypair, PublicKey, VersionedTransaction } from "@solana/web3.js";
|
4
|
+
import { SimulatedBundleTransactionResult } from "jito-ts";
|
5
|
+
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
6
|
+
import {
|
7
|
+
JITO_BLOCK_ENGINE,
|
8
|
+
JITO_CONNECTION,
|
9
|
+
UMI,
|
10
|
+
} from "../constants/solautoConstants";
|
11
|
+
import {
|
12
|
+
Signer,
|
13
|
+
transactionBuilder,
|
14
|
+
TransactionBuilder,
|
15
|
+
WrappedInstruction,
|
16
|
+
} from "@metaplex-foundation/umi";
|
17
|
+
import {
|
18
|
+
assembleFinalTransaction,
|
19
|
+
getComputeUnitPriceEstimate,
|
20
|
+
getSecretKey,
|
21
|
+
setComputeUnitLimitUmiIx,
|
22
|
+
setComputeUnitPriceUmiIx,
|
23
|
+
systemTransferUmiIx,
|
24
|
+
} from "./solanaUtils";
|
25
|
+
import { Bundle } from "jito-ts/dist/sdk/block-engine/types";
|
26
|
+
import {
|
27
|
+
SearcherClient,
|
28
|
+
searcherClient,
|
29
|
+
} from "jito-ts/dist/sdk/block-engine/searcher";
|
30
|
+
import { BundleResult } from "jito-ts/dist/gen/block-engine/bundle";
|
31
|
+
|
32
|
+
export function getSearcherClient(): SearcherClient {
|
33
|
+
return searcherClient(
|
34
|
+
JITO_BLOCK_ENGINE,
|
35
|
+
Keypair.fromSecretKey(getSecretKey("jito-bundles"))
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
39
|
+
export async function getRandomTipAccount(): Promise<PublicKey> {
|
40
|
+
const tipAccounts = await getSearcherClient().getTipAccounts();
|
41
|
+
const randomInt = Math.floor(Math.random() * tipAccounts.length);
|
42
|
+
return new PublicKey(tipAccounts[randomInt]);
|
43
|
+
}
|
44
|
+
|
45
|
+
export async function waitUntilJitoNextLeader(
|
46
|
+
distanceFromJitoSlot: number = 5
|
47
|
+
) {
|
48
|
+
let searcher = getSearcherClient();
|
49
|
+
let isLeaderSlot = false;
|
50
|
+
|
51
|
+
while (!isLeaderSlot) {
|
52
|
+
const nextLeader = await searcher.getNextScheduledLeader();
|
53
|
+
const numSlots = nextLeader.nextLeaderSlot - nextLeader.currentSlot;
|
54
|
+
isLeaderSlot = numSlots <= distanceFromJitoSlot && numSlots > 1;
|
55
|
+
console.log(`Next jito leader slot in ${numSlots} slots`);
|
56
|
+
await new Promise((r) => setTimeout(r, 500));
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
async function getTipInstruction(
|
61
|
+
client: SolautoClient,
|
62
|
+
tipLamports: number
|
63
|
+
): Promise<WrappedInstruction> {
|
64
|
+
return systemTransferUmiIx(
|
65
|
+
client.signer,
|
66
|
+
await getRandomTipAccount(),
|
67
|
+
BigInt(tipLamports)
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
async function simulateJitoBundle(
|
72
|
+
txs: VersionedTransaction[]
|
73
|
+
): Promise<SimulatedBundleTransactionResult[]> {
|
74
|
+
const simulationResult = await JITO_CONNECTION.simulateBundle(txs, {
|
75
|
+
preExecutionAccountsConfigs: txs.map((x) => null),
|
76
|
+
postExecutionAccountsConfigs: txs.map((x) => null),
|
77
|
+
skipSigVerify: true,
|
78
|
+
});
|
79
|
+
|
80
|
+
simulationResult.value.transactionResults.forEach((tx) => {
|
81
|
+
if (tx.err) {
|
82
|
+
tx.logs?.forEach((x) => {
|
83
|
+
console.log(x);
|
84
|
+
});
|
85
|
+
}
|
86
|
+
assert.equal(tx.err, undefined);
|
87
|
+
});
|
88
|
+
|
89
|
+
return simulationResult.value.transactionResults;
|
90
|
+
}
|
91
|
+
|
92
|
+
async function umiToVersionedTransactions(
|
93
|
+
signer: Signer,
|
94
|
+
txs: TransactionBuilder[],
|
95
|
+
feeEstimates: number[],
|
96
|
+
computeUnitLimits?: number[]
|
97
|
+
): Promise<VersionedTransaction[]> {
|
98
|
+
return await Promise.all(
|
99
|
+
txs.map(async (tx, i) => {
|
100
|
+
const versionedTx = toWeb3JsTransaction(
|
101
|
+
await (
|
102
|
+
await assembleFinalTransaction(
|
103
|
+
signer,
|
104
|
+
tx,
|
105
|
+
feeEstimates[i],
|
106
|
+
computeUnitLimits ? computeUnitLimits[i] : undefined
|
107
|
+
).setLatestBlockhash(UMI)
|
108
|
+
).buildAndSign(UMI)
|
109
|
+
);
|
110
|
+
return versionedTx;
|
111
|
+
})
|
112
|
+
);
|
113
|
+
}
|
114
|
+
|
115
|
+
async function sendJitoBundle(bundle: Bundle): Promise<BundleResult> {
|
116
|
+
await waitUntilJitoNextLeader();
|
117
|
+
let searcher = getSearcherClient();
|
118
|
+
|
119
|
+
console.log("Sending bundle...");
|
120
|
+
try {
|
121
|
+
const resp = await searcher.sendBundle(bundle);
|
122
|
+
console.log("Send bundle response:", resp);
|
123
|
+
} catch (e) {
|
124
|
+
console.error("Error sending bundle:", e);
|
125
|
+
}
|
126
|
+
|
127
|
+
return await new Promise((resolve, reject) => {
|
128
|
+
searcher.onBundleResult(
|
129
|
+
(res) => {
|
130
|
+
if (res.accepted || res.processed || res.finalized) {
|
131
|
+
resolve(res);
|
132
|
+
} else {
|
133
|
+
console.log(res);
|
134
|
+
return reject("Bundle not accepted");
|
135
|
+
}
|
136
|
+
},
|
137
|
+
(err) => {
|
138
|
+
console.log("Error: ", err);
|
139
|
+
return reject(err);
|
140
|
+
}
|
141
|
+
);
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
interface JitoTransactionsResult {
|
146
|
+
bundleResult: BundleResult;
|
147
|
+
txSigs: Uint8Array[];
|
148
|
+
}
|
149
|
+
|
150
|
+
export async function sendJitoBundledTransactions(
|
151
|
+
client: SolautoClient,
|
152
|
+
txs: TransactionBuilder[],
|
153
|
+
simulateOnly?: boolean
|
154
|
+
): Promise<JitoTransactionsResult | undefined> {
|
155
|
+
client.log("Sending Jito bundle...");
|
156
|
+
client.log("Transactions: ", txs.length);
|
157
|
+
client.log(
|
158
|
+
"Transaction sizes: ",
|
159
|
+
txs.map((x) => x.getTransactionSize(UMI))
|
160
|
+
);
|
161
|
+
|
162
|
+
txs[0] = txs[0].prepend(await getTipInstruction(client, 1000000));
|
163
|
+
const feeEstimates = await Promise.all(txs.map(getComputeUnitPriceEstimate));
|
164
|
+
|
165
|
+
let builtTxs = await umiToVersionedTransactions(
|
166
|
+
client.signer,
|
167
|
+
txs,
|
168
|
+
feeEstimates,
|
169
|
+
// Array(txs.length).fill(1_400_000)
|
170
|
+
);
|
171
|
+
// // TODO: Skip over this for now, and instead don't specify a compute unit limit in the final bundle transactions
|
172
|
+
// const simulationResults = await simulateJitoBundle(builtTxs);
|
173
|
+
|
174
|
+
if (!simulateOnly) {
|
175
|
+
// let builtTxs = await umiToVersionedTransactions(
|
176
|
+
// client.signer,
|
177
|
+
// txs,
|
178
|
+
// feeEstimates,
|
179
|
+
// simulationResults.map((x) => x.unitsConsumed! * 1.15)
|
180
|
+
// );
|
181
|
+
|
182
|
+
const bundleResult = await sendJitoBundle(
|
183
|
+
new Bundle(builtTxs, 100)
|
184
|
+
);
|
185
|
+
return {
|
186
|
+
bundleResult,
|
187
|
+
txSigs: builtTxs.map((x) => x.signatures).flat(),
|
188
|
+
};
|
189
|
+
}
|
190
|
+
|
191
|
+
return undefined;
|
192
|
+
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import {
|
2
|
+
Signer,
|
3
|
+
TransactionBuilder,
|
4
|
+
transactionBuilder,
|
5
|
+
} from "@metaplex-foundation/umi";
|
6
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
7
|
+
import { getWrappedInstruction } from "./solanaUtils";
|
8
|
+
import { toBps } from "./numberUtils";
|
9
|
+
import { assert } from "console";
|
10
|
+
import {
|
11
|
+
createJupiterApiClient,
|
12
|
+
Instruction,
|
13
|
+
QuoteResponse,
|
14
|
+
} from "@jup-ag/api";
|
15
|
+
import { getTokenAccount } from "./accountUtils";
|
16
|
+
|
17
|
+
const jupApi = createJupiterApiClient();
|
18
|
+
|
19
|
+
export interface JupSwapDetails {
|
20
|
+
inputMint: PublicKey;
|
21
|
+
outputMint: PublicKey;
|
22
|
+
destinationWallet: PublicKey;
|
23
|
+
amount: bigint;
|
24
|
+
slippageBpsIncFactor?: number;
|
25
|
+
exactOut?: boolean;
|
26
|
+
exactIn?: boolean;
|
27
|
+
}
|
28
|
+
|
29
|
+
function createTransactionInstruction(
|
30
|
+
instruction: Instruction
|
31
|
+
): TransactionInstruction {
|
32
|
+
return new TransactionInstruction({
|
33
|
+
programId: new PublicKey(instruction.programId),
|
34
|
+
keys: instruction.accounts.map((key) => ({
|
35
|
+
pubkey: new PublicKey(key.pubkey),
|
36
|
+
isSigner: key.isSigner,
|
37
|
+
isWritable: key.isWritable,
|
38
|
+
})),
|
39
|
+
data: Buffer.from(instruction.data, "base64"),
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
export interface JupSwapTransaction {
|
44
|
+
jupQuote: QuoteResponse;
|
45
|
+
lookupTableAddresses: string[];
|
46
|
+
setupInstructions: TransactionBuilder;
|
47
|
+
tokenLedgerIx: TransactionBuilder;
|
48
|
+
swapIx: TransactionBuilder;
|
49
|
+
}
|
50
|
+
|
51
|
+
export async function getJupSwapTransaction(
|
52
|
+
signer: Signer,
|
53
|
+
swapDetails: JupSwapDetails
|
54
|
+
): Promise<JupSwapTransaction> {
|
55
|
+
console.log("Getting jup quote...");
|
56
|
+
|
57
|
+
const quoteResponse = await jupApi.quoteGet({
|
58
|
+
amount: Number(swapDetails.amount),
|
59
|
+
inputMint: swapDetails.inputMint.toString(),
|
60
|
+
outputMint: swapDetails.outputMint.toString(),
|
61
|
+
swapMode: swapDetails.exactOut
|
62
|
+
? "ExactOut"
|
63
|
+
: swapDetails.exactIn
|
64
|
+
? "ExactIn"
|
65
|
+
: undefined,
|
66
|
+
});
|
67
|
+
|
68
|
+
// Up price slippage bps by an extra swapDetails.slippageBpsIncFactor of the estimated price impact (minimum 0.1% price slippage no matter what)
|
69
|
+
const finalPriceSlippageBps = Math.max(
|
70
|
+
quoteResponse.slippageBps ?? 10,
|
71
|
+
Math.round(
|
72
|
+
toBps(parseFloat(quoteResponse.priceImpactPct)) *
|
73
|
+
(1 + (swapDetails.slippageBpsIncFactor ?? 0))
|
74
|
+
)
|
75
|
+
);
|
76
|
+
quoteResponse.slippageBps = finalPriceSlippageBps;
|
77
|
+
console.log(quoteResponse);
|
78
|
+
|
79
|
+
console.log("Getting jup instructions...");
|
80
|
+
const instructions = await jupApi.swapInstructionsPost({
|
81
|
+
swapRequest: {
|
82
|
+
userPublicKey: signer.publicKey.toString(),
|
83
|
+
quoteResponse,
|
84
|
+
wrapAndUnwrapSol: false,
|
85
|
+
useTokenLedger: !swapDetails.exactOut && !swapDetails.exactIn,
|
86
|
+
destinationTokenAccount: getTokenAccount(swapDetails.destinationWallet, swapDetails.outputMint).toString(),
|
87
|
+
},
|
88
|
+
});
|
89
|
+
|
90
|
+
assert(instructions.swapInstruction !== undefined);
|
91
|
+
return {
|
92
|
+
jupQuote: quoteResponse,
|
93
|
+
lookupTableAddresses: instructions.addressLookupTableAddresses,
|
94
|
+
setupInstructions: transactionBuilder().add(
|
95
|
+
instructions.setupInstructions.map((ix) =>
|
96
|
+
getWrappedInstruction(signer, createTransactionInstruction(ix))
|
97
|
+
)
|
98
|
+
),
|
99
|
+
tokenLedgerIx: transactionBuilder().add(
|
100
|
+
instructions.tokenLedgerInstruction !== undefined
|
101
|
+
? getWrappedInstruction(
|
102
|
+
signer,
|
103
|
+
createTransactionInstruction(instructions.tokenLedgerInstruction)
|
104
|
+
)
|
105
|
+
: transactionBuilder()
|
106
|
+
),
|
107
|
+
swapIx: transactionBuilder().add(
|
108
|
+
getWrappedInstruction(
|
109
|
+
signer,
|
110
|
+
createTransactionInstruction(instructions.swapInstruction)
|
111
|
+
)
|
112
|
+
),
|
113
|
+
};
|
114
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import {
|
2
|
+
Keypair,
|
3
|
+
AddressLookupTableProgram,
|
4
|
+
TransactionInstruction,
|
5
|
+
TransactionMessage,
|
6
|
+
VersionedTransaction,
|
7
|
+
PublicKey,
|
8
|
+
} from "@solana/web3.js";
|
9
|
+
import { getSecretKey } from "../solanaUtils";
|
10
|
+
import { CONNECTION } from "../../constants/solautoConstants";
|
11
|
+
|
12
|
+
const keypair = Keypair.fromSecretKey(getSecretKey());
|
13
|
+
|
14
|
+
async function createAndSendV0Tx(txInstructions: TransactionInstruction[]) {
|
15
|
+
let latestBlockhash = await CONNECTION.getLatestBlockhash("finalized");
|
16
|
+
|
17
|
+
const messageV0 = new TransactionMessage({
|
18
|
+
payerKey: keypair.publicKey,
|
19
|
+
recentBlockhash: latestBlockhash.blockhash,
|
20
|
+
instructions: txInstructions,
|
21
|
+
}).compileToV0Message();
|
22
|
+
const transaction = new VersionedTransaction(messageV0);
|
23
|
+
|
24
|
+
transaction.sign([keypair]);
|
25
|
+
|
26
|
+
const txid = await CONNECTION.sendTransaction(transaction, {
|
27
|
+
maxRetries: 5,
|
28
|
+
});
|
29
|
+
|
30
|
+
const confirmation = await CONNECTION.confirmTransaction({
|
31
|
+
signature: txid,
|
32
|
+
blockhash: latestBlockhash.blockhash,
|
33
|
+
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
34
|
+
});
|
35
|
+
if (confirmation.value.err) {
|
36
|
+
throw new Error(confirmation.value.err.toString());
|
37
|
+
}
|
38
|
+
console.log(txid);
|
39
|
+
}
|
40
|
+
|
41
|
+
async function addAddressesIfNeeded(
|
42
|
+
lookupTableAddress: PublicKey,
|
43
|
+
existingAddresses: string[],
|
44
|
+
addressesToAdd: string[]
|
45
|
+
) {
|
46
|
+
const addresses = addressesToAdd
|
47
|
+
.filter((x) => !existingAddresses.includes(x))
|
48
|
+
.map((x) => new PublicKey(x));
|
49
|
+
|
50
|
+
if (addresses.length > 0) {
|
51
|
+
await createAndSendV0Tx([
|
52
|
+
AddressLookupTableProgram.extendLookupTable({
|
53
|
+
payer: keypair.publicKey,
|
54
|
+
authority: keypair.publicKey,
|
55
|
+
lookupTable: lookupTableAddress,
|
56
|
+
addresses,
|
57
|
+
}),
|
58
|
+
]);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
export async function updateLookupTable(
|
63
|
+
accounts: string[],
|
64
|
+
lookupTableAddress?: PublicKey
|
65
|
+
) {
|
66
|
+
let lookupTable = lookupTableAddress
|
67
|
+
? await CONNECTION.getAddressLookupTable(lookupTableAddress)
|
68
|
+
: null;
|
69
|
+
if (lookupTable === null) {
|
70
|
+
const [createLutIx, addr] = AddressLookupTableProgram.createLookupTable({
|
71
|
+
authority: keypair.publicKey,
|
72
|
+
payer: keypair.publicKey,
|
73
|
+
recentSlot: await CONNECTION.getSlot({ commitment: "finalized" }),
|
74
|
+
});
|
75
|
+
lookupTableAddress = addr;
|
76
|
+
console.log("Lookup Table Address:", lookupTableAddress.toString());
|
77
|
+
createAndSendV0Tx([createLutIx]);
|
78
|
+
}
|
79
|
+
|
80
|
+
const existingAccounts =
|
81
|
+
lookupTable?.value?.state.addresses.map((x) => x.toString()) ?? [];
|
82
|
+
console.log("Existing accounts: ", existingAccounts.length);
|
83
|
+
|
84
|
+
await addAddressesIfNeeded(lookupTableAddress!, existingAccounts, accounts);
|
85
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
2
|
+
import { MARGINFI_ACCOUNTS_LOOKUP_TABLE } from "../../constants/marginfiAccounts";
|
3
|
+
import {
|
4
|
+
MARGINFI_ACCOUNTS,
|
5
|
+
DEFAULT_MARGINFI_GROUP,
|
6
|
+
} from "../../constants/marginfiAccounts";
|
7
|
+
import { MARGINFI_PROGRAM_ID } from "../../marginfi-sdk";
|
8
|
+
import { updateLookupTable } from "./shared";
|
9
|
+
|
10
|
+
const LOOKUP_TABLE_ADDRESS = new PublicKey(MARGINFI_ACCOUNTS_LOOKUP_TABLE);
|
11
|
+
|
12
|
+
async function addBanks() {
|
13
|
+
for (const key in MARGINFI_ACCOUNTS) {
|
14
|
+
const accounts = MARGINFI_ACCOUNTS[key];
|
15
|
+
await updateLookupTable(
|
16
|
+
[
|
17
|
+
accounts.mint,
|
18
|
+
accounts.bank,
|
19
|
+
accounts.liquidityVault,
|
20
|
+
accounts.vaultAuthority,
|
21
|
+
accounts.priceOracle,
|
22
|
+
],
|
23
|
+
LOOKUP_TABLE_ADDRESS
|
24
|
+
);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
updateLookupTable(
|
29
|
+
[DEFAULT_MARGINFI_GROUP, MARGINFI_PROGRAM_ID],
|
30
|
+
LOOKUP_TABLE_ADDRESS
|
31
|
+
);
|
32
|
+
|
33
|
+
addBanks();
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
2
|
+
import { getTokenAccounts } from "../accountUtils";
|
3
|
+
import { SOLAUTO_MANAGER } from "../../constants/generalAccounts";
|
4
|
+
import { ALL_SUPPORTED_TOKENS } from "../../constants/tokenConstants";
|
5
|
+
import { updateLookupTable } from "./shared";
|
6
|
+
import { STANDARD_LUT_ACCOUNTS } from "../../constants/solautoConstants";
|
7
|
+
|
8
|
+
const solautoManagerTokenAccounts = getTokenAccounts(SOLAUTO_MANAGER, ALL_SUPPORTED_TOKENS.map((x) => new PublicKey(x)));
|
9
|
+
|
10
|
+
updateLookupTable(
|
11
|
+
[
|
12
|
+
...STANDARD_LUT_ACCOUNTS,
|
13
|
+
...solautoManagerTokenAccounts.map((x) => x.toString())
|
14
|
+
]
|
15
|
+
);
|