@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,432 @@
|
|
1
|
+
import { describe, it, before } from 'mocha';
|
2
|
+
import { PublicKey } from "@solana/web3.js";
|
3
|
+
import { NATIVE_MINT } from "@solana/spl-token";
|
4
|
+
import {
|
5
|
+
SolautoMarginfiClient,
|
6
|
+
newMarginfiSolautoManagedPositionArgs,
|
7
|
+
} from "../../src/clients/solautoMarginfiClient";
|
8
|
+
import { setupTest } from "../shared";
|
9
|
+
import { MARGINFI_ACCOUNTS } from "../../src/constants/marginfiAccounts";
|
10
|
+
import { getRebalanceValues } from "../../src/utils/solauto/rebalanceUtils";
|
11
|
+
import { publicKey } from "@metaplex-foundation/umi";
|
12
|
+
import { SolautoClient } from "../../src/clients/solautoClient";
|
13
|
+
import {
|
14
|
+
DCASettings,
|
15
|
+
FeeType,
|
16
|
+
LendingPlatform,
|
17
|
+
SolautoRebalanceType,
|
18
|
+
SolautoSettingsParameters,
|
19
|
+
} from "../../src/generated";
|
20
|
+
import {
|
21
|
+
fromBaseUnit,
|
22
|
+
fromBps,
|
23
|
+
getLiqUtilzationRateBps,
|
24
|
+
toBaseUnit,
|
25
|
+
} from "../../src/utils/numberUtils";
|
26
|
+
import { USD_DECIMALS } from "../../src/constants/generalAccounts";
|
27
|
+
import { assert } from "chai";
|
28
|
+
import {
|
29
|
+
eligibleForNextAutomationPeriod,
|
30
|
+
getAdjustedSettingsFromAutomation,
|
31
|
+
getSolautoFeesBps,
|
32
|
+
getUpdatedValueFromAutomation,
|
33
|
+
} from "../../src/utils/solauto/generalUtils";
|
34
|
+
import {
|
35
|
+
currentUnixSeconds,
|
36
|
+
getTokenPrices,
|
37
|
+
} from "../../src/utils/generalUtils";
|
38
|
+
import { USDC_MINT } from "../../src/constants/tokenConstants";
|
39
|
+
|
40
|
+
const signer = setupTest();
|
41
|
+
|
42
|
+
function assertAccurateRebalance(
|
43
|
+
client: SolautoClient,
|
44
|
+
expectedLiqUtilizationRateBps: number,
|
45
|
+
targetLiqUtilizationRateBps?: number,
|
46
|
+
expectedUsdToDcaIn?: number
|
47
|
+
) {
|
48
|
+
const { increasingLeverage, debtAdjustmentUsd, amountUsdToDcaIn } =
|
49
|
+
getRebalanceValues(client, targetLiqUtilizationRateBps);
|
50
|
+
|
51
|
+
let adjustmentFeeBps = 0;
|
52
|
+
if (increasingLeverage) {
|
53
|
+
adjustmentFeeBps = getSolautoFeesBps(
|
54
|
+
client.referredByState !== undefined,
|
55
|
+
client.solautoPositionData!.feeType
|
56
|
+
).total;
|
57
|
+
}
|
58
|
+
|
59
|
+
assert(
|
60
|
+
Math.round(amountUsdToDcaIn) === Math.round(expectedUsdToDcaIn ?? 0),
|
61
|
+
`Expected DCA-in amount does not match ${Math.round(amountUsdToDcaIn)}, ${Math.round(expectedUsdToDcaIn ?? 0)}`
|
62
|
+
);
|
63
|
+
|
64
|
+
const newSupply =
|
65
|
+
fromBaseUnit(
|
66
|
+
client.solautoPositionState!.supply.amountUsed.baseAmountUsdValue,
|
67
|
+
USD_DECIMALS
|
68
|
+
) +
|
69
|
+
(debtAdjustmentUsd - debtAdjustmentUsd * fromBps(adjustmentFeeBps)) +
|
70
|
+
amountUsdToDcaIn;
|
71
|
+
const newDebt =
|
72
|
+
fromBaseUnit(
|
73
|
+
client.solautoPositionState!.debt.amountUsed.baseAmountUsdValue,
|
74
|
+
USD_DECIMALS
|
75
|
+
) + debtAdjustmentUsd;
|
76
|
+
|
77
|
+
const newLiqUtilizationRateBps = getLiqUtilzationRateBps(
|
78
|
+
newSupply,
|
79
|
+
newDebt,
|
80
|
+
client.solautoPositionState!.liqThresholdBps
|
81
|
+
);
|
82
|
+
assert(
|
83
|
+
Math.round(newLiqUtilizationRateBps) === expectedLiqUtilizationRateBps,
|
84
|
+
`Expected liq utilization rate does not match ${Math.round(newLiqUtilizationRateBps)}, ${expectedLiqUtilizationRateBps}`
|
85
|
+
);
|
86
|
+
}
|
87
|
+
|
88
|
+
async function getFakePosition(
|
89
|
+
supplyPrice: number,
|
90
|
+
debtPrice: number,
|
91
|
+
fakeLiqUtilizationRateBps: number,
|
92
|
+
settings: SolautoSettingsParameters,
|
93
|
+
dca?: DCASettings
|
94
|
+
): Promise<SolautoClient> {
|
95
|
+
const client = new SolautoMarginfiClient(true);
|
96
|
+
await client.initialize(
|
97
|
+
newMarginfiSolautoManagedPositionArgs(
|
98
|
+
1,
|
99
|
+
signer,
|
100
|
+
new PublicKey(NATIVE_MINT),
|
101
|
+
new PublicKey(MARGINFI_ACCOUNTS.USDC.mint)
|
102
|
+
)
|
103
|
+
);
|
104
|
+
|
105
|
+
const state = await client.getFreshPositionState();
|
106
|
+
client.solautoPositionData = {
|
107
|
+
positionId: [1],
|
108
|
+
bump: [0],
|
109
|
+
selfManaged: {
|
110
|
+
val: false,
|
111
|
+
},
|
112
|
+
authority: client.signer.publicKey,
|
113
|
+
position: {
|
114
|
+
dca: dca ?? {
|
115
|
+
automation: {
|
116
|
+
targetPeriods: 0,
|
117
|
+
periodsPassed: 0,
|
118
|
+
unixStartDate: BigInt(0),
|
119
|
+
intervalSeconds: BigInt(0),
|
120
|
+
padding1: [],
|
121
|
+
padding: new Uint8Array([]),
|
122
|
+
},
|
123
|
+
debtToAddBaseUnit: BigInt(0),
|
124
|
+
padding: new Uint8Array([]),
|
125
|
+
},
|
126
|
+
lendingPlatform: LendingPlatform.Marginfi,
|
127
|
+
supplyMint: publicKey(client.supplyLiquidityMint),
|
128
|
+
debtMint: publicKey(client.debtLiquidityMint),
|
129
|
+
protocolAccount: publicKey(PublicKey.default),
|
130
|
+
settingParams: settings,
|
131
|
+
padding1: [],
|
132
|
+
padding: [],
|
133
|
+
},
|
134
|
+
state: state!,
|
135
|
+
rebalance: {
|
136
|
+
rebalanceType: SolautoRebalanceType.Regular,
|
137
|
+
targetLiqUtilizationRateBps: 0,
|
138
|
+
flashLoanAmount: BigInt(0),
|
139
|
+
priceSlippageBps: 0,
|
140
|
+
padding1: [],
|
141
|
+
padding2: [],
|
142
|
+
padding: new Uint8Array([]),
|
143
|
+
},
|
144
|
+
feeType: FeeType.Small,
|
145
|
+
padding1: [],
|
146
|
+
padding2: [],
|
147
|
+
padding: [],
|
148
|
+
publicKey: publicKey(PublicKey.default),
|
149
|
+
header: {
|
150
|
+
executable: false,
|
151
|
+
lamports: {
|
152
|
+
basisPoints: BigInt(0),
|
153
|
+
decimals: 9,
|
154
|
+
identifier: "SOL",
|
155
|
+
},
|
156
|
+
owner: publicKey(PublicKey.default),
|
157
|
+
},
|
158
|
+
};
|
159
|
+
|
160
|
+
const supplyUsd = 1000;
|
161
|
+
client.livePositionUpdates.new({
|
162
|
+
type: "supply",
|
163
|
+
value: toBaseUnit(supplyUsd / supplyPrice, state!.supply.decimals),
|
164
|
+
});
|
165
|
+
client.livePositionUpdates.new({
|
166
|
+
type: "debt",
|
167
|
+
value: toBaseUnit(
|
168
|
+
(supplyUsd *
|
169
|
+
fromBps(state!.liqThresholdBps) *
|
170
|
+
fromBps(fakeLiqUtilizationRateBps)) /
|
171
|
+
debtPrice,
|
172
|
+
state!.debt.decimals
|
173
|
+
),
|
174
|
+
});
|
175
|
+
|
176
|
+
client.solautoPositionState = await client.getFreshPositionState();
|
177
|
+
client.solautoPositionState!.lastUpdated = BigInt(currentUnixSeconds());
|
178
|
+
|
179
|
+
return client;
|
180
|
+
}
|
181
|
+
|
182
|
+
async function rebalanceFromFakePosition(
|
183
|
+
supplyPrice: number,
|
184
|
+
debtPrice: number,
|
185
|
+
fakeLiqUtilizationRateBps: number,
|
186
|
+
settings: SolautoSettingsParameters
|
187
|
+
) {
|
188
|
+
const client = await getFakePosition(
|
189
|
+
supplyPrice,
|
190
|
+
debtPrice,
|
191
|
+
fakeLiqUtilizationRateBps,
|
192
|
+
settings
|
193
|
+
);
|
194
|
+
|
195
|
+
const adjustedSettings = getAdjustedSettingsFromAutomation(
|
196
|
+
settings,
|
197
|
+
currentUnixSeconds()
|
198
|
+
);
|
199
|
+
const expectedLiqUtilizationRateBps =
|
200
|
+
fakeLiqUtilizationRateBps <
|
201
|
+
adjustedSettings.boostToBps - adjustedSettings.boostGap
|
202
|
+
? adjustedSettings.boostToBps
|
203
|
+
: adjustedSettings.repayToBps;
|
204
|
+
assertAccurateRebalance(client, expectedLiqUtilizationRateBps);
|
205
|
+
}
|
206
|
+
|
207
|
+
async function dcaRebalanceFromFakePosition(
|
208
|
+
supplyPrice: number,
|
209
|
+
debtPrice: number,
|
210
|
+
fakeLiqUtilizationRateBps: number,
|
211
|
+
settings: SolautoSettingsParameters,
|
212
|
+
dca: DCASettings
|
213
|
+
) {
|
214
|
+
const client = await getFakePosition(
|
215
|
+
supplyPrice,
|
216
|
+
debtPrice,
|
217
|
+
fakeLiqUtilizationRateBps,
|
218
|
+
settings,
|
219
|
+
dca
|
220
|
+
);
|
221
|
+
|
222
|
+
const adjustedSettings = getAdjustedSettingsFromAutomation(
|
223
|
+
settings,
|
224
|
+
currentUnixSeconds()
|
225
|
+
);
|
226
|
+
const expectedLiqUtilizationRateBps =
|
227
|
+
dca.debtToAddBaseUnit > BigInt(0)
|
228
|
+
? Math.max(fakeLiqUtilizationRateBps, adjustedSettings.boostToBps)
|
229
|
+
: adjustedSettings.boostToBps;
|
230
|
+
|
231
|
+
const expectedDcaInAmount =
|
232
|
+
dca.debtToAddBaseUnit > 0 && eligibleForNextAutomationPeriod(dca.automation)
|
233
|
+
? dca.debtToAddBaseUnit -
|
234
|
+
BigInt(
|
235
|
+
Math.round(
|
236
|
+
getUpdatedValueFromAutomation(
|
237
|
+
Number(dca.debtToAddBaseUnit),
|
238
|
+
0,
|
239
|
+
dca.automation,
|
240
|
+
currentUnixSeconds()
|
241
|
+
)
|
242
|
+
)
|
243
|
+
)
|
244
|
+
: BigInt(0);
|
245
|
+
const expectedUsdToDcaIn =
|
246
|
+
fromBaseUnit(
|
247
|
+
BigInt(Math.round(Number(expectedDcaInAmount))),
|
248
|
+
client.solautoPositionState!.debt.decimals
|
249
|
+
) * debtPrice;
|
250
|
+
|
251
|
+
assertAccurateRebalance(
|
252
|
+
client,
|
253
|
+
expectedLiqUtilizationRateBps,
|
254
|
+
undefined,
|
255
|
+
expectedUsdToDcaIn
|
256
|
+
);
|
257
|
+
}
|
258
|
+
|
259
|
+
describe("Rebalance tests", async () => {
|
260
|
+
let supplyPrice: number, debtPrice: number;
|
261
|
+
|
262
|
+
before(async () => {
|
263
|
+
[supplyPrice, debtPrice] = await getTokenPrices([
|
264
|
+
NATIVE_MINT,
|
265
|
+
new PublicKey(USDC_MINT),
|
266
|
+
]);
|
267
|
+
});
|
268
|
+
|
269
|
+
it("Standard rebalance with target rate", async () => {
|
270
|
+
const client = new SolautoMarginfiClient(true);
|
271
|
+
await client.initialize(
|
272
|
+
newMarginfiSolautoManagedPositionArgs(
|
273
|
+
1,
|
274
|
+
signer,
|
275
|
+
new PublicKey(NATIVE_MINT),
|
276
|
+
new PublicKey(MARGINFI_ACCOUNTS.USDC.mint)
|
277
|
+
)
|
278
|
+
);
|
279
|
+
|
280
|
+
client.livePositionUpdates.new({
|
281
|
+
type: "supply",
|
282
|
+
value: BigInt(10000000000),
|
283
|
+
});
|
284
|
+
client.solautoPositionState = await client.getFreshPositionState();
|
285
|
+
client.solautoPositionState!.lastUpdated = BigInt(currentUnixSeconds());
|
286
|
+
|
287
|
+
assertAccurateRebalance(client, 5000, 5000);
|
288
|
+
assertAccurateRebalance(client, 1000, 1000);
|
289
|
+
});
|
290
|
+
|
291
|
+
it("Standard boost or repay", async () => {
|
292
|
+
const settings: SolautoSettingsParameters = {
|
293
|
+
automation: {
|
294
|
+
targetPeriods: 0,
|
295
|
+
periodsPassed: 0,
|
296
|
+
unixStartDate: BigInt(0),
|
297
|
+
intervalSeconds: BigInt(0),
|
298
|
+
padding1: [],
|
299
|
+
padding: new Uint8Array([]),
|
300
|
+
},
|
301
|
+
targetBoostToBps: 0,
|
302
|
+
boostGap: 1000,
|
303
|
+
boostToBps: 4000,
|
304
|
+
repayGap: 1000,
|
305
|
+
repayToBps: 7500,
|
306
|
+
padding1: [],
|
307
|
+
padding: new Uint8Array([]),
|
308
|
+
};
|
309
|
+
|
310
|
+
await rebalanceFromFakePosition(supplyPrice, debtPrice, 1000, settings);
|
311
|
+
await rebalanceFromFakePosition(supplyPrice, debtPrice, 9000, settings);
|
312
|
+
});
|
313
|
+
|
314
|
+
it("Rebalance with settings automation", async () => {
|
315
|
+
const settings: SolautoSettingsParameters = {
|
316
|
+
automation: {
|
317
|
+
targetPeriods: 2,
|
318
|
+
periodsPassed: 1,
|
319
|
+
intervalSeconds: BigInt(5),
|
320
|
+
unixStartDate: BigInt(currentUnixSeconds() - 5),
|
321
|
+
padding1: [],
|
322
|
+
padding: new Uint8Array([]),
|
323
|
+
},
|
324
|
+
targetBoostToBps: 5000,
|
325
|
+
boostGap: 1000,
|
326
|
+
boostToBps: 4000,
|
327
|
+
repayGap: 1000,
|
328
|
+
repayToBps: 7500,
|
329
|
+
padding1: [],
|
330
|
+
padding: new Uint8Array([]),
|
331
|
+
};
|
332
|
+
await rebalanceFromFakePosition(supplyPrice, debtPrice, 3500, settings);
|
333
|
+
|
334
|
+
settings.automation.targetPeriods = 5;
|
335
|
+
await rebalanceFromFakePosition(supplyPrice, debtPrice, 3100, settings);
|
336
|
+
|
337
|
+
settings.automation.periodsPassed = 0;
|
338
|
+
settings.automation.unixStartDate = BigInt(currentUnixSeconds());
|
339
|
+
await rebalanceFromFakePosition(supplyPrice, debtPrice, 3100, settings);
|
340
|
+
});
|
341
|
+
|
342
|
+
it("Rebalance DCA out", async () => {
|
343
|
+
const settings: SolautoSettingsParameters = {
|
344
|
+
automation: {
|
345
|
+
targetPeriods: 4,
|
346
|
+
periodsPassed: 0,
|
347
|
+
intervalSeconds: BigInt(5),
|
348
|
+
unixStartDate: BigInt(currentUnixSeconds()),
|
349
|
+
padding1: [],
|
350
|
+
padding: new Uint8Array([]),
|
351
|
+
},
|
352
|
+
targetBoostToBps: 0,
|
353
|
+
boostGap: 1000,
|
354
|
+
boostToBps: 4000,
|
355
|
+
repayGap: 1000,
|
356
|
+
repayToBps: 7500,
|
357
|
+
padding1: [],
|
358
|
+
padding: new Uint8Array([]),
|
359
|
+
};
|
360
|
+
const dca: DCASettings = {
|
361
|
+
automation: {
|
362
|
+
targetPeriods: 4,
|
363
|
+
periodsPassed: 0,
|
364
|
+
intervalSeconds: BigInt(5),
|
365
|
+
unixStartDate: BigInt(currentUnixSeconds()),
|
366
|
+
padding1: [],
|
367
|
+
padding: new Uint8Array([]),
|
368
|
+
},
|
369
|
+
debtToAddBaseUnit: BigInt(0),
|
370
|
+
padding: new Uint8Array([]),
|
371
|
+
};
|
372
|
+
await dcaRebalanceFromFakePosition(
|
373
|
+
supplyPrice,
|
374
|
+
debtPrice,
|
375
|
+
3500,
|
376
|
+
settings,
|
377
|
+
dca
|
378
|
+
);
|
379
|
+
|
380
|
+
settings.boostToBps = 1500;
|
381
|
+
settings.automation.periodsPassed = 3;
|
382
|
+
settings.automation.unixStartDate = BigInt(currentUnixSeconds() - 3 * 5);
|
383
|
+
dca.automation.periodsPassed = 3;
|
384
|
+
dca.automation.unixStartDate = BigInt(currentUnixSeconds() - 3 * 5);
|
385
|
+
await dcaRebalanceFromFakePosition(
|
386
|
+
supplyPrice,
|
387
|
+
debtPrice,
|
388
|
+
3500,
|
389
|
+
settings,
|
390
|
+
dca
|
391
|
+
);
|
392
|
+
});
|
393
|
+
|
394
|
+
it("Rebalance DCA in", async () => {
|
395
|
+
const settings: SolautoSettingsParameters = {
|
396
|
+
automation: {
|
397
|
+
targetPeriods: 4,
|
398
|
+
periodsPassed: 0,
|
399
|
+
intervalSeconds: BigInt(5),
|
400
|
+
unixStartDate: BigInt(currentUnixSeconds()),
|
401
|
+
padding1: [],
|
402
|
+
padding: new Uint8Array([]),
|
403
|
+
},
|
404
|
+
targetBoostToBps: 0,
|
405
|
+
boostGap: 1000,
|
406
|
+
boostToBps: 4000,
|
407
|
+
repayGap: 1000,
|
408
|
+
repayToBps: 7500,
|
409
|
+
padding1: [],
|
410
|
+
padding: new Uint8Array([]),
|
411
|
+
};
|
412
|
+
const dca: DCASettings = {
|
413
|
+
automation: {
|
414
|
+
targetPeriods: 4,
|
415
|
+
periodsPassed: 0,
|
416
|
+
intervalSeconds: BigInt(5),
|
417
|
+
unixStartDate: BigInt(currentUnixSeconds()),
|
418
|
+
padding1: [],
|
419
|
+
padding: new Uint8Array([]),
|
420
|
+
},
|
421
|
+
debtToAddBaseUnit: toBaseUnit(debtPrice * 300, 6),
|
422
|
+
padding: new Uint8Array([]),
|
423
|
+
};
|
424
|
+
await dcaRebalanceFromFakePosition(
|
425
|
+
supplyPrice,
|
426
|
+
debtPrice,
|
427
|
+
3500,
|
428
|
+
settings,
|
429
|
+
dca
|
430
|
+
);
|
431
|
+
});
|
432
|
+
});
|
package/tsconfig.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"types": ["mocha", "chai"],
|
4
|
+
"typeRoots": ["./node_modules/@types"],
|
5
|
+
"lib": ["es2020", "dom"],
|
6
|
+
"module": "commonjs",
|
7
|
+
"target": "ES2020",
|
8
|
+
"moduleResolution": "node",
|
9
|
+
"resolveJsonModule": true,
|
10
|
+
"esModuleInterop": true,
|
11
|
+
"strictNullChecks": true,
|
12
|
+
"declaration": true,
|
13
|
+
"declarationMap": true,
|
14
|
+
"emitDeclarationOnly": false,
|
15
|
+
"strict": true,
|
16
|
+
"skipLibCheck": true,
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
18
|
+
"outDir": "./dist"
|
19
|
+
},
|
20
|
+
"include": ["src/**/*"],
|
21
|
+
"exclude": ["tests/**/*"],
|
22
|
+
}
|