feat(vaults): implement auto-lend to withdrawals (#402)
This commit is contained in:
parent
69af852491
commit
44d5d5e42c
@ -11,7 +11,7 @@ import {
|
|||||||
Action as CreditManagerAction,
|
Action as CreditManagerAction,
|
||||||
ExecuteMsg as CreditManagerExecuteMsg,
|
ExecuteMsg as CreditManagerExecuteMsg,
|
||||||
} from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
} from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||||
import { getAssetByDenom } from 'utils/assets'
|
import { getAssetByDenom, getAssetBySymbol } from 'utils/assets'
|
||||||
import { getSingleValueFromBroadcastResult } from 'utils/broadcast'
|
import { getSingleValueFromBroadcastResult } from 'utils/broadcast'
|
||||||
import checkAutoLendEnabled from 'utils/checkAutoLendEnabled'
|
import checkAutoLendEnabled from 'utils/checkAutoLendEnabled'
|
||||||
import { defaultFee } from 'utils/constants'
|
import { defaultFee } from 'utils/constants'
|
||||||
@ -279,6 +279,19 @@ export default function createBroadcastSlice(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (checkAutoLendEnabled(options.accountId)) {
|
||||||
|
for (const vault of options.vaults) {
|
||||||
|
for (const symbol of Object.values(vault.symbols)) {
|
||||||
|
const asset = getAssetBySymbol(symbol)
|
||||||
|
if (asset?.isAutoLendEnabled) {
|
||||||
|
msg.update_credit_account.actions.push({
|
||||||
|
lend: { denom: asset.denom, amount: 'account_balance' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const response = await get().executeMsg({
|
const response = await get().executeMsg({
|
||||||
messages: [generateExecutionMessage(get().address, ENV.ADDRESS_CREDIT_MANAGER, msg, [])],
|
messages: [generateExecutionMessage(get().address, ENV.ADDRESS_CREDIT_MANAGER, msg, [])],
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user