Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: terra classic burn fees #373

Merged
merged 2 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions components/Navbar/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import React from 'react'

import { HStack, Image, Text } from '@chakra-ui/react'
import { useRouter } from 'next/router'
import { useRecoilState } from 'recoil'
import { walletState } from 'state/atoms/walletAtoms'
import { useRouter } from 'next/router'

const Logo = () => {
const [currentWalletState, setCurrentWalletState] =
useRecoilState(walletState)
const router = useRouter()
return (
<HStack alignItems="center">
<a
onClick={async() => {
setCurrentWalletState({
...currentWalletState,
chainId: 'migaloo-1'
})
await router.push('/migaloo/swap')
}
}
>
<Image src="/img/logo.svg" alt="WhiteWhale Logo" boxSize={[8, 12]} />
</a>
<a
onClick={async () => {
setCurrentWalletState({
...currentWalletState,
chainId: 'migaloo-1',
})
await router.push('/migaloo/swap')
}
}
>
<Image src="/img/logo.svg" alt="WhiteWhale Logo" boxSize={[8, 12]} />
</a>
<HStack display={['none', 'flex']}>
<Text pl={2} fontSize="26" fontWeight="400">
White
Expand Down
5 changes: 2 additions & 3 deletions components/Pages/Dashboard/BondingActions/Bond.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import React, { useEffect, useMemo, useState } from 'react'
import { Controller, useForm } from 'react-hook-form'

import { VStack } from '@chakra-ui/react'
import AssetInput from 'components/AssetInput/index'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'
import { useConfig } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { useRecoilState, useRecoilValue } from 'recoil'
import { WalletStatusType, walletState } from 'state/atoms/walletAtoms'

import AssetInput from 'components/AssetInput/index'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'

export interface BondingTokenState {
tokenSymbol: string
amount: number
Expand Down
26 changes: 13 additions & 13 deletions components/Pages/Dashboard/BondingActions/BondingActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import {
VStack,
useDisclosure,
} from '@chakra-ui/react'
import Loader from 'components/Loader'
import { Bond, BondingTokenState } from 'components/Pages/Dashboard/BondingActions/Bond'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'
import { BondingActionTooltip } from 'components/Pages/Dashboard/BondingActions/BondingAcionTooltip'
import useTransaction, { TxStep } from 'components/Pages/Dashboard/BondingActions/hooks/useTransaction'
import Unbond from 'components/Pages/Dashboard/BondingActions/Unbond'
import Withdraw from 'components/Pages/Dashboard/BondingActions/Withdraw'
import { ActionType } from 'components/Pages/Dashboard/BondingOverview'
import { WithdrawableInfo } from 'components/Pages/Dashboard/hooks/getWithdrawable'
import {
Config,
useConfig,
useDashboardData,
} from 'components/Pages/Dashboard/hooks/useDashboardData'
import WalletModal from 'components/Wallet/Modal/Modal'
import { useChains } from 'hooks/useChainInfo'
import { useMultipleTokenBalance } from 'hooks/useTokenBalance'
import { useRouter } from 'next/router'
import { useRecoilState } from 'recoil'
import { WalletStatusType, walletState } from 'state/atoms/walletAtoms'

import Loader from 'components/Loader'
import WalletModal from 'components/Wallet/Modal/Modal'
import { ActionType } from 'components/Pages/Dashboard/BondingOverview'
import {
Config,
useConfig,
useDashboardData,
} from 'components/Pages/Dashboard/hooks/useDashboardData'
import { Bond, BondingTokenState } from 'components/Pages/Dashboard/BondingActions/Bond'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'
import useTransaction, { TxStep } from 'components/Pages/Dashboard/BondingActions/hooks/useTransaction'
import Unbond from 'components/Pages/Dashboard/BondingActions/Unbond'
import Withdraw from 'components/Pages/Dashboard/BondingActions/Withdraw'

const BondingActions = ({ globalAction }) => {
const [{ chainId, client, address, status, network }, _] =
Expand Down
7 changes: 3 additions & 4 deletions components/Pages/Dashboard/BondingActions/Unbond.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { Controller, useForm } from 'react-hook-form'

import { VStack } from '@chakra-ui/react'
import AssetInput from 'components/AssetInput/index'
import { BondingTokenState, TokenBalance } from 'components/Pages/Dashboard/BondingActions/Bond'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'
import { BondedData } from 'components/Pages/Dashboard/hooks/getBonded'
import { useConfig } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { useRecoilState, useRecoilValue } from 'recoil'
import { WalletStatusType, walletState } from 'state/atoms/walletAtoms'

import AssetInput from 'components/AssetInput/index'
import { BondingTokenState, TokenBalance } from 'components/Pages/Dashboard/BondingActions/Bond'
import { bondingAtom } from 'components/Pages/Dashboard/BondingActions/bondAtoms'

const Unbond = ({ bondedAssets }: { bondedAssets: BondedData[] }) => {
const { status, chainId, network } = useRecoilValue(walletState)
const [currentBondState, setCurrentBondState] =
Expand Down
3 changes: 1 addition & 2 deletions components/Pages/Dashboard/BondingActions/Withdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react'
import { Box, HStack, Text, VStack } from '@chakra-ui/react'
import { UnbondingData } from 'components/Pages/Dashboard/hooks/getUnbonding'
import { WithdrawableInfo } from 'components/Pages/Dashboard/hooks/getWithdrawable'
import { WhaleTooltip } from 'components/Pages/Dashboard/WhaleTooltip'
import usePrices from 'hooks/usePrices'
import { useTokenList } from 'hooks/useTokenList'
import { useRecoilValue } from 'recoil'
Expand All @@ -13,8 +14,6 @@ import {
nanoToMilli,
} from 'util/conversion/index'

import { WhaleTooltip } from 'components/Pages/Dashboard/WhaleTooltip'

type Props = {
unbondingRequests: UnbondingData[]
withdrawableInfos: WithdrawableInfo[]
Expand Down
3 changes: 1 addition & 2 deletions components/Pages/Dashboard/BondingActions/bondAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { atom } from 'recoil'

import { BondingTokenState } from 'components/Pages/Dashboard/BondingActions/Bond'
import { atom } from 'recoil'

export const bondingAtom = atom<BondingTokenState>({
key: 'bondingToken',
Expand Down
19 changes: 14 additions & 5 deletions components/Pages/Dashboard/BondingActions/hooks/bondTokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { coin } from '@cosmjs/stargate'
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { TerraTreasuryService } from 'services/treasuryService'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'
import { Wallet } from 'util/wallet-adapters/index'

export const bondTokens = async (
Expand All @@ -23,13 +24,21 @@ export const bondTokens = async (
},
},
}
const execMsg = createExecuteMessage({ senderAddress: address,
contractAddress: config.whale_lair,
message: handleMsg,
funds: [coin(amount, denom)] })
let fee = null
if (chainId === 'columbus-5') {
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(amount, denom)
const gas = Math.ceil(await client.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(
amount, denom, gas,
)
}
return client.execute(
address, config.whale_lair, handleMsg, [
coin(amount, denom),
], fee,
return await client.post(
address, [execMsg], '', fee,
)
}

23 changes: 20 additions & 3 deletions components/Pages/Dashboard/BondingActions/hooks/claimRewards.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'
import { Wallet } from 'util/wallet-adapters/index'

export const claimRewards = (
import { TerraTreasuryService } from '../../../../../services/treasuryService'

export const claimRewards = async (
client: Wallet,
address: string,
config: Config,
) => {
const handleMsg = {
claim: {},
}
return client.execute(
address, config.fee_distributor, handleMsg,

const execMsg = createExecuteMessage({ senderAddress: address,
contractAddress: config.fee_distributor,
message: handleMsg,
funds: [] })
let fee = null
if (await client.getChainId() === 'columbus-5') {
const gas = Math.ceil(await client.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(
0, '', gas,
)
}
return await client.post(
address, [execMsg], '', fee,
)
}
21 changes: 19 additions & 2 deletions components/Pages/Dashboard/BondingActions/hooks/createNewEpoch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'
import { Wallet } from 'util/wallet-adapters/index'

import { TerraTreasuryService } from '../../../../../services/treasuryService'

export const createNewEpoch = async (
client: Wallet,
config: Config,
Expand All @@ -9,7 +12,21 @@ export const createNewEpoch = async (
const handleMsg = {
new_epoch: {},
}
return client.execute(
address, config.fee_distributor, handleMsg,

const execMsg = createExecuteMessage({ senderAddress: address,
contractAddress: config.fee_distributor,
message: handleMsg,
funds: [] })
let fee = null
if (await client.getChainId() === 'columbus-5') {
const gas = Math.ceil(await client.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(
0, '', gas,
)
}
return await client.post(
address, [execMsg], '', fee,
)
}
21 changes: 18 additions & 3 deletions components/Pages/Dashboard/BondingActions/hooks/unbondTokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'
import { Wallet } from 'util/wallet-adapters/index'

export const unbondTokens = (
import { TerraTreasuryService } from '../../../../../services/treasuryService'

export const unbondTokens = async (
client: Wallet,
address: string,
amount: number,
Expand All @@ -20,7 +23,19 @@ export const unbondTokens = (
},
},
}
return client.execute(
address, config.whale_lair, handleMsg,

const execMsg = createExecuteMessage({ senderAddress: address,
contractAddress: config.whale_lair,
message: handleMsg,
funds: [] })
let fee = null
if (chainId === 'columbus-5') {
const gas = Math.ceil(await client.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(amount, denom)
}
return await client.post(
address, [execMsg], '', fee,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { useMutation, useQuery } from 'react-query'

import { useToast } from '@chakra-ui/react'
import Finder from 'components/Finder'
import { bondTokens } from 'components/Pages/Dashboard/BondingActions/hooks/bondTokens'
import { claimRewards } from 'components/Pages/Dashboard/BondingActions/hooks/claimRewards'
import { createNewEpoch } from 'components/Pages/Dashboard/BondingActions/hooks/createNewEpoch'
import { unbondTokens } from 'components/Pages/Dashboard/BondingActions/hooks/unbondTokens'
import { withdrawTokens } from 'components/Pages/Dashboard/BondingActions/hooks/withdrawTokens'
import { ActionType } from 'components/Pages/Dashboard/BondingOverview'
import {
Config,
useConfig,
Expand All @@ -13,11 +17,6 @@ import { useRecoilValue } from 'recoil'
import { walletState } from 'state/atoms/walletAtoms'
import { convertDenomToMicroDenom } from 'util/conversion/index'

import { ActionType } from 'components/Pages/Dashboard/BondingOverview'
import { bondTokens } from 'components/Pages/Dashboard/BondingActions/hooks/bondTokens'
import { unbondTokens } from 'components/Pages/Dashboard/BondingActions/hooks/unbondTokens'
import { withdrawTokens } from 'components/Pages/Dashboard/BondingActions/hooks/withdrawTokens'

export enum TxStep {
/**
* Idle
Expand Down
23 changes: 20 additions & 3 deletions components/Pages/Dashboard/BondingActions/hooks/withdrawTokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Config } from 'components/Pages/Dashboard/hooks/useDashboardData'
import { createExecuteMessage } from 'util/messages/createExecuteMessage'
import { Wallet } from 'util/wallet-adapters/index'

export const withdrawTokens = (
import { TerraTreasuryService } from '../../../../../services/treasuryService'

export const withdrawTokens = async (
client: Wallet,
address: string,
denom: string,
Expand All @@ -12,7 +15,21 @@ export const withdrawTokens = (
denom,
},
}
return client.execute(
address, config.whale_lair, handleMsg,

const execMsg = createExecuteMessage({ senderAddress: address,
contractAddress: config.whale_lair,
message: handleMsg,
funds: [] })
let fee = null
if (chainId === 'columbus-5') {
const gas = Math.ceil(await client.simulate(
address, [execMsg], '',
) * 1.3)
fee = await TerraTreasuryService.getInstance().getTerraClassicFee(
0, '', gas,
)
}
return await client.post(
address, [execMsg], '', fee,
)
}
2 changes: 1 addition & 1 deletion components/Pages/Dashboard/RewardsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
useDisclosure,
} from '@chakra-ui/react'
import { BondingActionTooltip } from 'components/Pages/Dashboard/BondingActions/BondingAcionTooltip'
import useTransaction, { TxStep } from 'components/Pages/Dashboard/BondingActions/hooks/useTransaction'
import {
Config,
useConfig,
Expand All @@ -24,7 +25,6 @@ import { calculateRewardDurationString, nanoToMilli } from 'util/conversion'

import Loader from '../../Loader'
import WalletModal from '../../Wallet/Modal/Modal'
import useTransaction, { TxStep } from 'components/Pages/Dashboard/BondingActions/hooks/useTransaction'
import { ActionType } from './BondingOverview'

const pulseAnimation = keyframes`
Expand Down
1 change: 0 additions & 1 deletion components/Pages/Flashloan/Vaults/AllVaultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
useReactTable,
} from '@tanstack/react-table'
import Loader from 'components/Loader'

import VaultName from 'components/Pages/Flashloan/Vaults/VaultName'

export type Vault = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import { Button, VStack, useToast } from '@chakra-ui/react'
import AssetInput from 'components/AssetInput/index'
import Finder from 'components/Finder'
import { useRecoilValue } from 'recoil'
import { WalletStatusType, walletState } from 'state/atoms/walletAtoms'

import useDepost from 'components/Pages/Flashloan/Vaults/hooks/useDeposit'
import { TxStep } from 'components/Pages/Flashloan/Vaults/hooks/useTransaction'
import { useRecoilValue } from 'recoil'
import { WalletStatusType, walletState } from 'state/atoms/walletAtoms'

type Props = {
connected: WalletStatusType
Expand Down
Loading