diff --git a/src/components/Routes.tsx b/src/components/Routes.tsx
index df26dd94..74b64b7c 100644
--- a/src/components/Routes.tsx
+++ b/src/components/Routes.tsx
@@ -3,7 +3,6 @@ import { Navigate, Outlet, Route, Routes as RoutesWrapper } from 'react-router-d
import Layout from 'pages/_layout'
import BorrowPage from 'pages/BorrowPage'
import FarmPage from 'pages/FarmPage'
-import HLSFarmPage from 'pages/HLSFarmPage'
import HLSStakingPage from 'pages/HLSStakingPage'
import LendPage from 'pages/LendPage'
import MobilePage from 'pages/MobilePage'
@@ -28,7 +27,7 @@ export default function Routes() {
} />
} />
} />
-
} />
+ {/*
} />*/}
} />
} />
@@ -36,11 +35,11 @@ export default function Routes() {
} />
} />
} />
+ } />
} />
- } />
- } />
+ {/*} />*/}
} />
} />
diff --git a/src/components/Slider.tsx b/src/components/Slider.tsx
deleted file mode 100644
index 8b2208d3..00000000
--- a/src/components/Slider.tsx
+++ /dev/null
@@ -1,205 +0,0 @@
-import classNames from 'classnames'
-import { ChangeEvent, useRef, useState } from 'react'
-import Draggable from 'react-draggable'
-
-import { OverlayMark } from 'components/Icons/index'
-import useToggle from 'hooks/useToggle'
-
-type Props = {
- value: number
- onChange: (value: number) => void
- className?: string
- disabled?: boolean
-}
-
-export default function Slider(props: Props) {
- const [showTooltip, setShowTooltip] = useToggle()
- const [sliderRect, setSliderRect] = useState({ width: 0, left: 0, right: 0 })
- const ref = useRef
(null)
- const nodeRef = useRef(null)
- const [isDragging, setIsDragging] = useToggle()
-
- function handleSliderRect() {
- const leftCap = ref.current?.getBoundingClientRect().left ?? 0
- const rightCap = ref.current?.getBoundingClientRect().right ?? 0
- const newSliderWidth = ref.current?.getBoundingClientRect().width ?? 0
-
- if (
- sliderRect.width !== newSliderWidth ||
- leftCap !== sliderRect.left ||
- rightCap !== sliderRect.right
- ) {
- setSliderRect({
- left: leftCap,
- right: rightCap,
- width: newSliderWidth,
- })
- }
- }
-
- function handleDrag(e: any) {
- if (!isDragging) {
- setIsDragging(true)
- }
-
- const current: number = e.clientX
-
- if (current < sliderRect.left) {
- props.onChange(0)
- return
- }
-
- if (current > sliderRect.right) {
- props.onChange(100)
- return
- }
-
- const value = Math.round(((current - sliderRect.left) / sliderRect.width) * 100)
-
- if (value !== props.value) {
- props.onChange(value)
- }
- }
-
- function handleSliderClick(e: ChangeEvent) {
- props.onChange(Number(e.target.value))
- }
-
- function handleShowTooltip() {
- setShowTooltip(true)
- }
-
- function handleHideTooltip() {
- setShowTooltip(false)
- }
-
- const DraggableElement: any = Draggable
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- {!props.disabled && (
-
-
setIsDragging(false)}
- position={{ x: (sliderRect.width / 100) * props.value, y: 0 }}
- >
-
-
- {(showTooltip || isDragging) && (
-
-
- {props.value.toFixed(0)}%
-
- )}
-
-
-
- )}
-
- )
-}
-
-interface MarkProps {
- value: number
- sliderValue: number
- onClick: (value: number) => void
- disabled?: boolean
-}
-
-function Mark(props: MarkProps) {
- return (
-
- )
-}
-
-interface TrackProps {
- maxValue: number
- sliderValue: number
-}
-
-function Track(props: TrackProps) {
- const minValue = props.maxValue - 21
- let percentage = 0
-
- if (props.sliderValue >= props.maxValue) percentage = 100
-
- if (props.sliderValue > minValue && props.sliderValue < props.maxValue) {
- percentage = ((props.sliderValue - minValue) / (props.maxValue - minValue)) * 100
- }
-
- return (
-
- )
-}
diff --git a/src/components/Slider/LeverageLabel.tsx b/src/components/Slider/LeverageLabel.tsx
new file mode 100644
index 00000000..3611429f
--- /dev/null
+++ b/src/components/Slider/LeverageLabel.tsx
@@ -0,0 +1,26 @@
+import classNames from 'classnames'
+
+import Text from 'components/Text'
+
+interface Props {
+ className?: string
+ decimals: number
+ leverage: number
+ style?: {}
+}
+
+export default function LeverageLabel(props: Props) {
+ return (
+
+
+
{props.leverage.toFixed(props.decimals)}x
+
+ )
+}
diff --git a/src/components/Slider/Mark.tsx b/src/components/Slider/Mark.tsx
new file mode 100644
index 00000000..28b10d00
--- /dev/null
+++ b/src/components/Slider/Mark.tsx
@@ -0,0 +1,23 @@
+import classNames from 'classnames'
+
+interface Props {
+ disabled?: boolean
+ onClick: (value: number) => void
+ sliderValue: number
+ style?: {}
+ value: number
+}
+
+export default function Mark(props: Props) {
+ return (
+
- Borrow rate
+ Borrow Rate APY
{formatPercent(borrowRate || 0)}
>
diff --git a/src/constants/assets.ts b/src/constants/assets.ts
index 1d6a344f..71e93ee0 100644
--- a/src/constants/assets.ts
+++ b/src/constants/assets.ts
@@ -1,16 +1,12 @@
import { ENV } from 'constants/env'
import { NETWORK } from 'types/enums/network'
-export const MARS_MAINNET_DENOM =
- 'ibc/573FCD90FACEE750F55A8864EF7D38265F07E5A9273FA0E8DAFD39951332B580'
-
export const ASSETS: Asset[] = [
{
symbol: 'OSMO',
name: 'Osmosis',
id: 'OSMO',
denom: 'uosmo',
- mainnetDenom: 'uosmo',
color: '#9f1ab9',
decimals: 6,
hasOraclePrice: true,
@@ -27,11 +23,7 @@ export const ASSETS: Asset[] = [
symbol: 'ATOM',
name: 'Atom',
id: 'ATOM',
- denom:
- ENV.NETWORK === NETWORK.TESTNET
- ? 'ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477'
- : 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
- mainnetDenom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
+ denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
color: '#6f7390',
logo: '/images/tokens/atom.svg',
decimals: 6,
@@ -50,31 +42,45 @@ export const ASSETS: Asset[] = [
name: 'Stride Atom',
id: 'stATOM',
denom: 'ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901',
- mainnetDenom: 'ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901',
color: '#e50571',
logo: '/images/tokens/statom.svg',
decimals: 6,
- hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
- isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
- isMarket: ENV.NETWORK !== NETWORK.TESTNET,
- isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
+ hasOraclePrice: true,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
isAutoLendEnabled: false,
poolId: 803,
isStaking: true,
},
+ {
+ symbol: 'stOSMO',
+ name: 'Stride Osmosis',
+ id: 'stOSMO',
+ denom: 'ibc/D176154B0C63D1F9C6DCFB4F70349EBF2E2B5A87A05902F57A6AE92B863E9AEC',
+ color: '#e50571',
+ logo: '/images/tokens/stosmo.svg',
+ decimals: 6,
+ hasOraclePrice: true,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
+ isAutoLendEnabled: false,
+ poolId: 833,
+ isStaking: true,
+ },
{
symbol: 'WBTC.axl',
id: 'axlWBTC',
name: 'Axelar Wrapped Bitcoin',
denom: 'ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F',
- mainnetDenom: 'ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F',
color: '#f09242',
logo: '/images/tokens/axlwbtc.svg',
decimals: 8,
hasOraclePrice: true,
- isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
- isMarket: ENV.NETWORK !== NETWORK.TESTNET,
- isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
isAutoLendEnabled: true,
isBorrowEnabled: true,
pythPriceFeedId: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
@@ -86,14 +92,13 @@ export const ASSETS: Asset[] = [
id: 'axlWETH',
name: 'Axelar Wrapped Ethereum',
denom: 'ibc/EA1D43981D5C9A1C4AAEA9C23BB1D4FA126BA9BC7020A25E0AE4AA841EA25DC5',
- mainnetDenom: 'ibc/EA1D43981D5C9A1C4AAEA9C23BB1D4FA126BA9BC7020A25E0AE4AA841EA25DC5',
color: '#343434',
logo: '/images/tokens/axlweth.svg',
decimals: 18,
hasOraclePrice: true,
- isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
- isMarket: ENV.NETWORK !== NETWORK.TESTNET,
- isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
isAutoLendEnabled: true,
isBorrowEnabled: true,
pythPriceFeedId: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
@@ -104,11 +109,7 @@ export const ASSETS: Asset[] = [
symbol: 'MARS',
name: 'Mars',
id: 'MARS',
- denom:
- ENV.NETWORK === NETWORK.TESTNET
- ? 'ibc/DB9D326CF53EA07610C394D714D78F8BB4DC7E312D4213193791A9046BF45E20'
- : MARS_MAINNET_DENOM,
- mainnetDenom: MARS_MAINNET_DENOM,
+ denom: 'ibc/573FCD90FACEE750F55A8864EF7D38265F07E5A9273FA0E8DAFD39951332B580',
color: '#a03b45',
logo: '/images/tokens/mars.svg',
decimals: 6,
@@ -122,11 +123,7 @@ export const ASSETS: Asset[] = [
symbol: 'USDC.axl',
name: 'Axelar USDC',
id: 'axlUSDC',
- denom:
- ENV.NETWORK === NETWORK.TESTNET
- ? 'ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE'
- : 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
- mainnetDenom: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
+ denom: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
color: '#478edc',
logo: '/images/tokens/axlusdc.svg',
decimals: 6,
@@ -145,11 +142,7 @@ export const ASSETS: Asset[] = [
symbol: 'USDC',
name: 'Noble',
id: 'USDC',
- denom:
- ENV.NETWORK === NETWORK.TESTNET
- ? 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4'
- : 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4',
- mainnetDenom: 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4',
+ denom: 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4',
color: '#478edc',
logo: '/images/tokens/usdc.svg',
decimals: 6,
@@ -169,25 +162,41 @@ export const ASSETS: Asset[] = [
name: 'Axelar',
id: 'AXL',
denom: 'ibc/903A61A498756EA560B85A85132D3AEE21B5DEDD41213725D22ABF276EA6945E',
- mainnetDenom: 'ibc/903A61A498756EA560B85A85132D3AEE21B5DEDD41213725D22ABF276EA6945E',
color: '#FFF',
logo: '/images/tokens/axl.svg',
decimals: 6,
hasOraclePrice: true,
- isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
- isMarket: ENV.NETWORK !== NETWORK.TESTNET,
- isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
isAutoLendEnabled: false,
pythPriceFeedId: '60144b1d5c9e9851732ad1d9760e3485ef80be39b984f6bf60f82b28a2b7f126',
pythHistoryFeedId: 'Crypto.AXL/USD',
poolId: 812,
},
+ {
+ symbol: 'TIA',
+ id: 'TIA',
+ name: 'Celestia',
+ denom: 'ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877',
+ color: '#8623ff',
+ logo: '/images/tokens/tia.svg',
+ decimals: 6,
+ hasOraclePrice: true,
+ isEnabled: true,
+ isMarket: true,
+ isDisplayCurrency: true,
+ isAutoLendEnabled: true,
+ isBorrowEnabled: true,
+ pythPriceFeedId: '09f7c1d7dfbb7df2b8fe3d3d87ee94a2259d212da4f30c1f0540d066dfa44723',
+ poolId: 1249,
+ pythHistoryFeedId: 'Crypto.TIA/USD',
+ },
{
symbol: '$',
name: 'US Dollar',
id: 'USD',
denom: 'usd',
- mainnetDenom: 'usd',
color: '',
logo: '',
decimals: 2,
@@ -201,9 +210,8 @@ export const ASSETS: Asset[] = [
{
symbol: 'OSMO-ATOM',
name: 'OSMO-ATOM LP',
- id: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
- denom: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
- mainnetDenom: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
+ id: 'gamm/pool/1',
+ denom: 'gamm/pool/1',
color: '',
logo: '',
decimals: 6,
@@ -217,55 +225,51 @@ export const ASSETS: Asset[] = [
name: 'OSMO-USDC.axl LP',
id: 'gamm/pool/678',
denom: 'gamm/pool/678',
- mainnetDenom: 'gamm/pool/678',
color: '',
logo: '',
decimals: 6,
isEnabled: false,
isMarket: false,
- hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
- forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
+ hasOraclePrice: true,
+ forceFetchPrice: true,
},
{
symbol: 'OSMO-WETH.axl',
name: 'OSMO-WETH.axl LP',
id: 'gamm/pool/704',
denom: 'gamm/pool/704',
- mainnetDenom: 'gamm/pool/704',
color: '',
logo: '',
decimals: 6,
isEnabled: false,
isMarket: false,
- hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
- forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
+ hasOraclePrice: true,
+ forceFetchPrice: true,
},
{
symbol: 'OSMO-WBTC.axl',
name: 'OSMO-WBTC.axl LP',
id: 'gamm/pool/712',
denom: 'gamm/pool/712',
- mainnetDenom: 'gamm/pool/712',
color: '',
logo: '',
decimals: 6,
isEnabled: false,
isMarket: false,
- hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
- forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
+ hasOraclePrice: true,
+ forceFetchPrice: true,
},
{
symbol: 'stATOM-ATOM',
name: 'stATOM-ATOM LP',
id: 'gamm/pool/803',
denom: 'gamm/pool/803',
- mainnetDenom: 'gamm/pool/803',
color: '',
logo: '',
decimals: 6,
isEnabled: false,
isMarket: false,
- hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
- forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
+ hasOraclePrice: true,
+ forceFetchPrice: true,
},
]
diff --git a/src/hooks/useUpdatedAccount/index.ts b/src/hooks/useUpdatedAccount/index.ts
index dcd5ebd4..1b6ae28a 100644
--- a/src/hooks/useUpdatedAccount/index.ts
+++ b/src/hooks/useUpdatedAccount/index.ts
@@ -14,7 +14,7 @@ import {
import useVaults from 'hooks/useVaults'
import useStore from 'store'
import { BNCoin } from 'types/classes/BNCoin'
-import { cloneAccount } from 'utils/accounts'
+import { calculateAccountLeverage, cloneAccount } from 'utils/accounts'
import { byDenom } from 'utils/array'
import { getCoinAmount, getCoinValue } from 'utils/formatters'
import { getValueFromBNCoins } from 'utils/helpers'
@@ -30,6 +30,7 @@ export function useUpdatedAccount(account?: Account) {
const [updatedAccount, setUpdatedAccount] = useState
(
account ? cloneAccount(account) : undefined,
)
+
const [slippage] = useLocalStorage(LocalStorageKeys.SLIPPAGE, DEFAULT_SETTINGS.slippage)
const [addedDeposits, addDeposits] = useState([])
const [removedDeposits, removeDeposits] = useState([])
@@ -39,6 +40,7 @@ export function useUpdatedAccount(account?: Account) {
const [addedLends, addLends] = useState([])
const [removedLends, removeLends] = useState([])
const [addedTrades, addTrades] = useState([])
+ const [leverage, setLeverage] = useState(0)
const removeDepositAndLendsByDenom = useCallback(
(denom: string) => {
@@ -165,6 +167,16 @@ export function useUpdatedAccount(account?: Account) {
[prices],
)
+ const simulateHlsStakingWithdraw = useCallback(
+ (collateralDenom: string, debtDenom: string, repayAmount: BigNumber) => {
+ const repayValue = getCoinValue(BNCoin.fromDenomAndBigNumber(debtDenom, repayAmount), prices)
+ const removeDepositAmount = getCoinAmount(collateralDenom, repayValue, prices)
+ removeDeposits([BNCoin.fromDenomAndBigNumber(collateralDenom, removeDepositAmount)])
+ removeDebts([BNCoin.fromDenomAndBigNumber(debtDenom, repayAmount)])
+ },
+ [prices],
+ )
+
const simulateVaultDeposit = useCallback(
(address: string, coins: BNCoin[], borrowCoins: BNCoin[]) => {
if (!account) return
@@ -205,6 +217,7 @@ export function useUpdatedAccount(account?: Account) {
accountCopy.lends = addCoins(addedLends, [...accountCopy.lends])
accountCopy.lends = removeCoins(removedLends, [...accountCopy.lends])
setUpdatedAccount(accountCopy)
+ setLeverage(calculateAccountLeverage(accountCopy, prices).toNumber())
useStore.setState({ updatedAccount: accountCopy })
return () => useStore.setState({ updatedAccount: undefined })
@@ -235,12 +248,14 @@ export function useUpdatedAccount(account?: Account) {
addedDeposits,
addedDebts,
addedLends,
+ leverage,
removedDeposits,
removedDebts,
removedLends,
simulateBorrow,
simulateDeposits,
simulateHlsStakingDeposit,
+ simulateHlsStakingWithdraw,
simulateLending,
simulateRepay,
simulateTrade,
diff --git a/src/pages/HLSStakingPage.tsx b/src/pages/HLSStakingPage.tsx
index 39777e2e..cce674e3 100644
--- a/src/pages/HLSStakingPage.tsx
+++ b/src/pages/HLSStakingPage.tsx
@@ -1,15 +1,13 @@
-import Tab from 'components/Earn/Tab'
import ActiveStakingAccounts from 'components/HLS/Staking/ActiveStakingAccounts'
import AvailableHlsStakingAssets from 'components/HLS/Staking/AvailableHLSStakingAssets'
import HLSStakingIntro from 'components/HLS/Staking/HLSStakingIntro'
import MigrationBanner from 'components/MigrationBanner'
-import { HLS_TABS } from 'constants/pages'
export default function HLSStakingPage() {
return (
-
+ {/*
*/}
diff --git a/src/store/slices/broadcast.ts b/src/store/slices/broadcast.ts
index 28ceb415..bd7f0fea 100644
--- a/src/store/slices/broadcast.ts
+++ b/src/store/slices/broadcast.ts
@@ -232,6 +232,28 @@ export default function createBroadcastSlice(
return response.then((response) => !!response.result)
},
+ changeHlsStakingLeverage: async (options: { accountId: string; actions: Action[] }) => {
+ const msg: CreditManagerExecuteMsg = {
+ update_credit_account: {
+ account_id: options.accountId,
+ actions: options.actions,
+ },
+ }
+
+ const response = get().executeMsg({
+ messages: [generateExecutionMessage(get().address, ENV.ADDRESS_CREDIT_MANAGER, msg, [])],
+ })
+
+ get().setToast({
+ response,
+ options: {
+ action: 'deposit',
+ message: `Changed Leverage`,
+ },
+ })
+
+ return response.then((response) => !!response.result)
+ },
closeHlsStakingPosition: async (options: { accountId: string; actions: Action[] }) => {
const msg: CreditManagerExecuteMsg = {
update_credit_account: {
@@ -252,10 +274,7 @@ export default function createBroadcastSlice(
},
})
- const response_1 = await response
- return response_1.result
- ? getSingleValueFromBroadcastResult(response_1.result, 'wasm', 'token_id')
- : null
+ return response.then((response) => !!response.result)
},
createAccount: async (accountKind: AccountKind) => {
diff --git a/src/types/interfaces/asset.d.ts b/src/types/interfaces/asset.d.ts
index d2426d5c..67afa00f 100644
--- a/src/types/interfaces/asset.d.ts
+++ b/src/types/interfaces/asset.d.ts
@@ -2,13 +2,14 @@ interface Asset {
color: string
name: string
denom: string
- mainnetDenom: string
symbol:
| 'OSMO'
| 'ATOM'
| 'MARS'
| 'stATOM'
+ | 'stOSMO'
| 'AXL'
+ | 'TIA'
| 'USDC.axl'
| 'USDC'
| 'WBTC.axl'
@@ -25,7 +26,9 @@ interface Asset {
| 'ATOM'
| 'MARS'
| 'stATOM'
+ | 'stOSMO'
| 'AXL'
+ | 'TIA'
| 'axlUSDC'
| 'axlWBTC'
| 'axlWETH'
diff --git a/src/types/interfaces/store/broadcast.d.ts b/src/types/interfaces/store/broadcast.d.ts
index fe8a29b8..e3ced21e 100644
--- a/src/types/interfaces/store/broadcast.d.ts
+++ b/src/types/interfaces/store/broadcast.d.ts
@@ -91,11 +91,9 @@ interface BroadcastSlice {
coin: BNCoin
borrowToWallet: boolean
}) => Promise
+ changeHlsStakingLeverage: (options: { accountId: string; actions: Action[] }) => Promise
claimRewards: (options: { accountId: string }) => ExecutableTx
- closeHlsStakingPosition: (options: {
- accountId: string
- actions: Action[]
- }) => Promise
+ closeHlsStakingPosition: (options: { accountId: string; actions: Action[] }) => Promise
createAccount: (
accountKind: import('types/generated/mars-rover-health-types/MarsRoverHealthTypes.types').AccountKind,
) => Promise
diff --git a/src/utils/actions.ts b/src/utils/actions.ts
new file mode 100644
index 00000000..f3f392ed
--- /dev/null
+++ b/src/utils/actions.ts
@@ -0,0 +1,68 @@
+import { BN_ZERO } from 'constants/math'
+import { BNCoin } from 'types/classes/BNCoin'
+import { Action } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
+import { getCoinAmount, getCoinValue } from 'utils/formatters'
+
+export function getHlsStakingChangeLevActions(
+ previousAmount: BigNumber,
+ currentAmount: BigNumber,
+ collateralDenom: string,
+ borrowDenom: string,
+ slippage: number,
+ prices: BNCoin[],
+): Action[] {
+ let actions: Action[] = []
+
+ if (currentAmount.isLessThan(previousAmount)) {
+ const debtValue = getCoinValue(
+ BNCoin.fromDenomAndBigNumber(borrowDenom, previousAmount.minus(currentAmount)),
+ prices,
+ )
+ const collateralAmount = getCoinAmount(collateralDenom, debtValue, prices)
+
+ actions = [
+ {
+ swap_exact_in: {
+ coin_in: BNCoin.fromDenomAndBigNumber(collateralDenom, collateralAmount).toActionCoin(),
+ denom_out: borrowDenom,
+ slippage: slippage.toString(),
+ },
+ },
+ {
+ repay: {
+ coin: BNCoin.fromDenomAndBigNumber(
+ borrowDenom,
+ previousAmount
+ .minus(currentAmount)
+ .times(1 - slippage)
+ .integerValue(),
+ ).toActionCoin(),
+ },
+ },
+ {
+ withdraw: BNCoin.fromDenomAndBigNumber(borrowDenom, BN_ZERO).toActionCoin(true),
+ },
+ ]
+ } else {
+ actions = [
+ {
+ borrow: BNCoin.fromDenomAndBigNumber(
+ borrowDenom,
+ currentAmount.minus(previousAmount),
+ ).toCoin(),
+ },
+ {
+ swap_exact_in: {
+ denom_out: collateralDenom,
+ coin_in: BNCoin.fromDenomAndBigNumber(
+ borrowDenom,
+ currentAmount.minus(previousAmount),
+ ).toActionCoin(true),
+ slippage: slippage.toString(),
+ },
+ },
+ ]
+ }
+
+ return actions
+}
diff --git a/src/utils/resolvers.ts b/src/utils/resolvers.ts
index c6618aa3..ac461986 100644
--- a/src/utils/resolvers.ts
+++ b/src/utils/resolvers.ts
@@ -5,6 +5,7 @@ import {
} from 'types/generated/mars-params/MarsParams.types'
import { Market as RedBankMarket } from 'types/generated/mars-red-bank/MarsRedBank.types'
import { BN, getLeverageFromLTV } from 'utils/helpers'
+import { convertAprToApy } from 'utils/parsers'
export function resolveMarketResponse(
marketResponse: RedBankMarket,
@@ -13,7 +14,7 @@ export function resolveMarketResponse(
): Market {
return {
denom: marketResponse.denom,
- borrowRate: Number(marketResponse.borrow_rate) * 100,
+ borrowRate: convertAprToApy(Number(marketResponse.borrow_rate), 365) * 100,
debtTotalScaled: marketResponse.debt_total_scaled,
collateralTotalScaled: marketResponse.collateral_total_scaled,
depositEnabled: assetParamsResponse.red_bank.deposit_enabled,
diff --git a/tailwind.config.js b/tailwind.config.js
index 533256ed..39a1a129 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -88,6 +88,7 @@ module.exports = {
chart: '#220e1d',
error: '#F04438',
'error-bg': '#FDA29B',
+ fuchsia: '#B7439F',
green: '#039855',
grey: '#908e91',
'grey-dark': '#1a1c25',
@@ -352,6 +353,18 @@ module.exports = {
'.gradient-secondary-to-primary': {
background: 'linear-gradient(180deg, #926AC8 100%, #7F78E8 0%)',
},
+ '.gradient-slider-1': {
+ background: 'linear-gradient(to right, #8D7F85, #B78796)',
+ },
+ '.gradient-slider-2': {
+ background: 'linear-gradient(to right, #C08899, #E08AA6)',
+ },
+ '.gradient-slider-3': {
+ background: 'linear-gradient(to right, #D97FA4, #B84A9C)',
+ },
+ '.gradient-slider-4': {
+ background: 'linear-gradient(to right, #961293, #B3419B)',
+ },
'.gradient-tooltip': {
background:
'linear-gradient(77.47deg, rgba(20, 24, 57, 0.9) 11.58%, rgba(34, 16, 57, 0.9) 93.89%)',
@@ -364,6 +377,9 @@ module.exports = {
whiteSpace: 'nowrap',
fontFeatureSettings: '"tnum" on',
},
+ '.slider-mask': {
+ mask: 'linear-gradient(#fff 0 0)',
+ },
'.text-3xs': { fontSize: '9px', lineHeight: '12px' },
'.text-3xs-caps': {
fontSize: '9px',
diff --git a/validate-env.js b/validate-env.js
index cefc2f02..646f28c6 100644
--- a/validate-env.js
+++ b/validate-env.js
@@ -36,8 +36,11 @@ if (!process.env.NEXT_PUBLIC_VAULT_APR) {
if (!process.env.NEXT_PUBLIC_PARAMS) {
throw 'NEXT_PUBLIC_PARAMS is not defined'
}
-if (!process.env.NEXT_PUBLIC_CANDLES_ENDPOINT) {
- throw 'NEXT_PUBLIC_CANDLES_ENDPOINT is not defined'
+if (!process.env.NEXT_PUBLIC_CANDLES_ENDPOINT_PYTH) {
+ throw 'NEXT_PUBLIC_CANDLES_ENDPOINT_PYTH is not defined'
+}
+if (!process.env.NEXT_PUBLIC_CANDLES_ENDPOINT_THE_GRAPH) {
+ throw 'NEXT_PUBLIC_CANDLES_ENDPOINT_THE_GRAPH is not defined'
}
if (!process.env.CHARTING_LIBRARY_USERNAME) {
throw 'CHARTING_LIBRARY_USERNAME is not defined'
diff --git a/yarn.lock b/yarn.lock
index 397526bf..e68ee0cc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2450,38 +2450,38 @@
"@jridgewell/resolve-uri" "3.1.0"
"@jridgewell/sourcemap-codec" "1.4.14"
-"@keplr-wallet/common@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/common/-/common-0.12.39.tgz#ba50c138e4d02d0a22f6083827a7fc7663ad35db"
- integrity sha512-7Xw7mYbi0+YjqS0ZERY7Ncxz0xhed6HEOlwZmrch0d81z0XPn+yBq06bWypf9nNuIl84D9uSgbys1pTuteXUYA==
+"@keplr-wallet/common@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/common/-/common-0.12.42.tgz#fa6a557a6bc04da8198dc5661a7d7a1a429223fc"
+ integrity sha512-xGADbV2Z7cTZqQVbbgSOudin3/7LY+FNseoc9yLTfIJuzoNcnHq3uBE8Sp+GCkax+tGc73LCtxmrB2NIqhmbkA==
dependencies:
- "@keplr-wallet/crypto" "0.12.39"
- "@keplr-wallet/types" "0.12.39"
+ "@keplr-wallet/crypto" "0.12.42"
+ "@keplr-wallet/types" "0.12.42"
buffer "^6.0.3"
delay "^4.4.0"
mobx "^6.1.7"
-"@keplr-wallet/cosmos@^0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/cosmos/-/cosmos-0.12.39.tgz#d4a633de619f8828eb3bfd4dc216b210c8f0ef69"
- integrity sha512-ag8IfaJQF84zDdqt2Ljvf/LGrlcKiG67aB8SKPERMT0daHRvobtII4dlofAp+UW34fgohmPbWi40mWveA+GNeQ==
+"@keplr-wallet/cosmos@^0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/cosmos/-/cosmos-0.12.42.tgz#788c28d9cb8c48e1e17d4d25ff6daafe50f47e7b"
+ integrity sha512-+HcldGPREaxI+FkIBNWlT9NDPktws+5YwMmLuwAwCD9baeEadCBI5NTbAbCuWoRSc6YSYZvxeKsjpSgPisysjw==
dependencies:
"@ethersproject/address" "^5.6.0"
- "@keplr-wallet/common" "0.12.39"
- "@keplr-wallet/crypto" "0.12.39"
- "@keplr-wallet/proto-types" "0.12.39"
- "@keplr-wallet/simple-fetch" "0.12.39"
- "@keplr-wallet/types" "0.12.39"
- "@keplr-wallet/unit" "0.12.39"
+ "@keplr-wallet/common" "0.12.42"
+ "@keplr-wallet/crypto" "0.12.42"
+ "@keplr-wallet/proto-types" "0.12.42"
+ "@keplr-wallet/simple-fetch" "0.12.42"
+ "@keplr-wallet/types" "0.12.42"
+ "@keplr-wallet/unit" "0.12.42"
bech32 "^1.1.4"
buffer "^6.0.3"
long "^4.0.0"
protobufjs "^6.11.2"
-"@keplr-wallet/crypto@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/crypto/-/crypto-0.12.39.tgz#30d065ccc7a1c15f48340932a64ccb33e65a1482"
- integrity sha512-7tkXiLAe04whpiMvVV0s3yDjv9to3nVFKR9rArfWTzs/x0VFEyIaVFL9+AmyjqSKQlnAKzPoK4ysmyGeBqEk6Q==
+"@keplr-wallet/crypto@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/crypto/-/crypto-0.12.42.tgz#2f43361651eec9fac38588b380a759b64b7629bb"
+ integrity sha512-fo+TlK5tDeS1drSP3uNHgTX3SYlERWeQUqtR1sTR2JyY5ShU56CwtNM+nwygl1ZQVtHxPZW5XBZiq9ZtjXddpw==
dependencies:
"@ethersproject/keccak256" "^5.5.0"
bip32 "^2.0.6"
@@ -2492,32 +2492,32 @@
elliptic "^6.5.3"
sha.js "^2.4.11"
-"@keplr-wallet/proto-types@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/proto-types/-/proto-types-0.12.39.tgz#6d65d1863c7d0db57729ee27539ad1492a18177d"
- integrity sha512-jY0Gbz/2orBi31buSx6V1EXC/Nfv98iN85wedovAtcbHn/lJa/b7KV1fuFMyXpANq9Bj/cYd5rw+NLi8IGyMWg==
+"@keplr-wallet/proto-types@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/proto-types/-/proto-types-0.12.42.tgz#320a067771154c977bb36d1baaf9077323ef6d09"
+ integrity sha512-iJsUpPmeKZOxKGv44nDhxrYbvbSBnLoEnatVfdPYngFHfSM7tYSHRliZ+riRCwliWLRGA9HhlGFD4/UyDpMyXg==
dependencies:
long "^4.0.0"
protobufjs "^6.11.2"
-"@keplr-wallet/simple-fetch@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/simple-fetch/-/simple-fetch-0.12.39.tgz#3dbba58ac1171f0ce62dea0da1f5f6bb71a91192"
- integrity sha512-QXS3iwggmUVEX1uHpiZK/JeT6EzsUr5g7b50hgziXl5pit002z0/L8s2Imh+2FtVmWROUHcAreS+n6Aptpbd6g==
+"@keplr-wallet/simple-fetch@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/simple-fetch/-/simple-fetch-0.12.42.tgz#75a31ef83bea86312c0e7fbd1f0aa8f237cded49"
+ integrity sha512-6xgIVhH473OX4raDI9X/KQLSZso2JhWqmnCZB/OQ+5m0fAsPGHTt6oYampYPQfnJdBGG95vGQ4//7QGEhmrrqg==
-"@keplr-wallet/types@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.12.39.tgz#31c86e994b1b223a13a877385f7c46760bb7c794"
- integrity sha512-eAgXrAl/56n2F27SV9WARpAdFGBZguSof0MX4yi5QtPlIQO8ksTA7E+raOZu1opD6/ZOiG+uYaKbrdYGMDL9Ng==
+"@keplr-wallet/types@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.12.42.tgz#f64e154580a93bcec918b3a30640b47d71428d25"
+ integrity sha512-o+BkY45xsONTzqTrmfL/ZU+I9dp6ACqB0dhmlRg4E03NRoj2olggWPgt7TPnoM3aB6rt+XK//kbrHvc9bRQrRA==
dependencies:
long "^4.0.0"
-"@keplr-wallet/unit@0.12.39":
- version "0.12.39"
- resolved "https://registry.yarnpkg.com/@keplr-wallet/unit/-/unit-0.12.39.tgz#58d8f75488bf721eda2eac830f60805a22c2f707"
- integrity sha512-O7ERBm9OhfZ7hh6qkq+wZ5K41RdGOjzHT5I3RYHcKm/2giArjnFQDyL4o59YcZd0Ku0u30UhjZ6keHpZqGo9UA==
+"@keplr-wallet/unit@0.12.42":
+ version "0.12.42"
+ resolved "https://registry.yarnpkg.com/@keplr-wallet/unit/-/unit-0.12.42.tgz#b78bb33d31851a8c2e41ee742d5722d9e3076cd0"
+ integrity sha512-FdPI12+jEn23sQ1CiTNtcP0N6QJOd0hcvmbFXb0RpJQ04Nh28cK0uxIXAqNzz0Y2WAaDBaS33grqdaaLkYkhbA==
dependencies:
- "@keplr-wallet/types" "0.12.39"
+ "@keplr-wallet/types" "0.12.42"
big-integer "^1.6.48"
utility-types "^3.10.0"