diff --git a/src/components/Borrow/BorrowActionButtons.tsx b/src/components/Borrow/BorrowActionButtons.tsx
index 22fd6e5d..ab902d15 100644
--- a/src/components/Borrow/BorrowActionButtons.tsx
+++ b/src/components/Borrow/BorrowActionButtons.tsx
@@ -1,7 +1,7 @@
import { useCallback } from 'react'
import Button from 'components/Button'
-import { Plus } from 'components/Icons'
+import { Plus, ReceiptCheck } from 'components/Icons'
import useStore from 'store'
import { getEnabledMarketAssets } from 'utils/assets'
@@ -29,13 +29,15 @@ export default function BorrowActionButtons(props: Props) {
return (
+
{details.map((detail, index) => (
()
- const [selectedAccount, setSelectedAccount] = useState(currentAccount)
const [isConfirming, setIsConfirming] = useToggle()
+ const [borrowToWallet, setBorrowToWallet] = useToggle()
const modal = useStore((s) => s.borrowModal)
const borrow = useStore((s) => s.borrow)
const repay = useStore((s) => s.repay)
const asset = modal?.asset ?? ASSETS[0]
- const accounts = useStore((s) => s.accounts)
- const accountOptions = accounts?.map((account) => {
- return { value: account.id, label: `Account ${account.id}` }
- })
const isRepay = modal?.isRepay ?? false
function resetState() {
@@ -53,21 +49,22 @@ export default function BorrowModal() {
}
async function onConfirmClick() {
- if (!modal?.asset) return
+ if (!modal?.asset || !currentAccount) return
setIsConfirming(true)
let result
if (isRepay) {
result = await repay({
fee: hardcodedFee,
- accountId: selectedAccount?.id ?? '0',
+ accountId: currentAccount.id,
coin: BNCoin.fromDenomAndBigNumber(modal.asset.denom, amount),
accountBalance: percentage === 100,
})
} else {
result = await borrow({
fee: hardcodedFee,
- accountId: selectedAccount?.id ?? '0',
+ accountId: currentAccount.id,
coin: { denom: modal.asset.denom, amount: amount.toString() },
+ borrowToWallet,
})
}
@@ -95,10 +92,6 @@ export default function BorrowModal() {
const max = BN(isRepay ? getDebtAmount(modal) : modal?.marketData?.liquidity?.amount ?? '0')
- useEffect(() => {
- if (!selectedAccount) setSelectedAccount(currentAccount)
- }, [selectedAccount, currentAccount])
-
useEffect(() => {
if (!modal?.asset) return
@@ -167,19 +160,17 @@ export default function BorrowModal() {
maxText='Max'
/>
-
- {isRepay ? 'Repay for' : 'Borrow to'}
-
-
-
@@ -192,7 +183,7 @@ export default function BorrowModal() {
rightIcon={}
/>
-
+
)
diff --git a/src/store/slices/broadcast.ts b/src/store/slices/broadcast.ts
index 77e418e5..0452f167 100644
--- a/src/store/slices/broadcast.ts
+++ b/src/store/slices/broadcast.ts
@@ -42,11 +42,20 @@ export default function createBroadcastSlice(
return {
toast: null,
- borrow: async (options: { fee: StdFee; accountId: string; coin: Coin }) => {
+ borrow: async (options: {
+ fee: StdFee
+ accountId: string
+ coin: Coin
+ borrowToWallet: boolean
+ }) => {
+ const borrowAction: Action = { borrow: options.coin }
+ const withdrawAction: Action = { withdraw: options.coin }
+ const actions = options.borrowToWallet ? [borrowAction, withdrawAction] : [borrowAction]
+
const msg: CreditManagerExecuteMsg = {
update_credit_account: {
account_id: options.accountId,
- actions: [{ borrow: options.coin }],
+ actions,
},
}
@@ -54,7 +63,9 @@ export default function createBroadcastSlice(
handleResponseMessages(
response,
- `Borrowed ${formatAmountWithSymbol(options.coin)} to Account ${options.accountId}`,
+ `Borrowed ${formatAmountWithSymbol(options.coin)} to ${
+ options.borrowToWallet ? 'Wallet' : `Account ${options.accountId}`
+ }`,
)
return !!response.result
},
diff --git a/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client.ts b/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client.ts
index 6f775dea..9df5e5b0 100644
--- a/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client.ts
+++ b/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.client.ts
@@ -5,25 +5,26 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
-import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate'
+import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import { Coin, StdFee } from '@cosmjs/amino'
+
import {
- InstantiateMsg,
- ExecuteMsg,
- OsmosisPriceSourceForString,
+ ArrayOfPriceResponse,
+ ArrayOfPriceSourceResponseForString,
+ ConfigResponse,
Decimal,
Downtime,
- Identifier,
- OwnerUpdate,
DowntimeDetector,
+ ExecuteMsg,
GeometricTwap,
- RedemptionRateForString,
- QueryMsg,
- ConfigResponse,
+ Identifier,
+ InstantiateMsg,
+ OsmosisPriceSourceForString,
+ OwnerUpdate,
PriceResponse,
PriceSourceResponseForString,
- ArrayOfPriceSourceResponseForString,
- ArrayOfPriceResponse,
+ QueryMsg,
+ RedemptionRateForString,
} from './MarsOracleOsmosis.types'
export interface MarsOracleOsmosisReadOnlyInterface {
contractAddress: string
diff --git a/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.react-query.ts b/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.react-query.ts
index 9af54f39..fcab034d 100644
--- a/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.react-query.ts
+++ b/src/types/generated/mars-oracle-osmosis/MarsOracleOsmosis.react-query.ts
@@ -5,28 +5,29 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/
-import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query'
+import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query'
import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
-import { StdFee, Coin } from '@cosmjs/amino'
+import { Coin, StdFee } from '@cosmjs/amino'
+
import {
- InstantiateMsg,
- ExecuteMsg,
- OsmosisPriceSourceForString,
+ ArrayOfPriceResponse,
+ ArrayOfPriceSourceResponseForString,
+ ConfigResponse,
Decimal,
Downtime,
- Identifier,
- OwnerUpdate,
DowntimeDetector,
+ ExecuteMsg,
GeometricTwap,
- RedemptionRateForString,
- QueryMsg,
- ConfigResponse,
+ Identifier,
+ InstantiateMsg,
+ OsmosisPriceSourceForString,
+ OwnerUpdate,
PriceResponse,
PriceSourceResponseForString,
- ArrayOfPriceSourceResponseForString,
- ArrayOfPriceResponse,
+ QueryMsg,
+ RedemptionRateForString,
} from './MarsOracleOsmosis.types'
-import { MarsOracleOsmosisQueryClient, MarsOracleOsmosisClient } from './MarsOracleOsmosis.client'
+import { MarsOracleOsmosisClient, MarsOracleOsmosisQueryClient } from './MarsOracleOsmosis.client'
export const marsOracleOsmosisQueryKeys = {
contract: [
{
diff --git a/src/types/interfaces/store/broadcast.d.ts b/src/types/interfaces/store/broadcast.d.ts
index 1be32a63..534694ac 100644
--- a/src/types/interfaces/store/broadcast.d.ts
+++ b/src/types/interfaces/store/broadcast.d.ts
@@ -12,7 +12,12 @@ interface BroadcastSlice {
fee: StdFee
funds?: Coin[]
}) => Promise
- borrow: (options: { fee: StdFee; accountId: string; coin: Coin }) => Promise
+ borrow: (options: {
+ fee: StdFee
+ accountId: string
+ coin: Coin
+ borrowToWallet: boolean
+ }) => Promise
createAccount: (options: { fee: StdFee }) => Promise
deleteAccount: (options: { fee: StdFee; accountId: string }) => Promise
deposit: (options: { fee: StdFee; accountId: string; coin: Coin }) => Promise