Skip to content

Commit

Permalink
Merge pull request #66 from HaloDAO/feature/hdev-187-swap-ui-integration
Browse files Browse the repository at this point in the history
Swap UI integration
  • Loading branch information
0xAplki authored Sep 15, 2021
2 parents 7c411ac + ff9793f commit ed4df58
Show file tree
Hide file tree
Showing 23 changed files with 1,543 additions and 59 deletions.
3 changes: 3 additions & 0 deletions src/assets/svg/arrow-down-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svg/cog-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/svg/switch-swap-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svg/warning-icon-purple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions src/components/Tailwind/InputFields/CurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MaxButton from '../Buttons/MaxButton'
import SelectButton from '../Buttons/SelectButton'
import NumericalInput from 'components/NumericalInput'
import TokenSelectModal from 'components/Tailwind/Modals/TokenSelectModal'
import { formatNumber, NumberFormat } from 'utils/formatNumber'
import { useCurrencyBalance } from 'state/wallet/hooks'
import { useActiveWeb3React } from 'hooks'

Expand All @@ -17,6 +18,7 @@ interface TokenInputProps {
showMax: boolean
onSelectToken?: (token: Token) => void
tokenList?: Token[]
balance?: string
}

const TokenInput = ({
Expand All @@ -27,15 +29,16 @@ const TokenInput = ({
showBalance,
showMax,
onSelectToken,
tokenList
tokenList,
balance
}: TokenInputProps) => {
const { account } = useActiveWeb3React()
const balance = useCurrencyBalance(account ?? undefined, currency)
const [showModal, setShowModal] = useState(false)
const { account } = useActiveWeb3React()
const currencyBalance = useCurrencyBalance(account ?? undefined, currency)

const onMax = () => {
if (balance) {
didChangeValue(balance.toExact())
didChangeValue(balance)
}
}

Expand Down Expand Up @@ -66,7 +69,10 @@ const TokenInput = ({
<div className="flex-auto">
{showBalance && (
<div className="text-xs text-secondary-alternate uppercase font-semibold tracking-widest">
Balance: {balance ? balance.toSignificant(6) : '-'}
Balance:{' '}
{balance
? formatNumber(Number(balance), NumberFormat.long) || '-'
: currencyBalance?.toSignificant(6) || '-'}
</div>
)}
<NumericalInput
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tailwind/InputFields/SlippageTolerance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const SlippageTolerance = ({ value, didChangeValue }: SlippageToleranceProps) =>
return (
<div>
<div className="flex items-center space-x-2 mb-2">
<span>Slippage tollerance:</span>
<span>Slippage tolerance:</span>
<QuestionIcon size={16} />
</div>
<div className="flex space-x-4 mb-2">
Expand Down
34 changes: 34 additions & 0 deletions src/constants/buttonStates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export enum ModalState {
NotConfirmed,
InProgress,
Successful
}

export enum ButtonState {
Default,
EnterAmount,
Approving,
Approved,
Next,
Confirming,
InsufficientBalance,
Retry,
MaxCap,
Swap,
InsufficientLiquidity,
NotMinimum
}

export enum SwapButtonState {
Default,
EnterAmount,
Approving,
Approved,
Next,
Confirming,
Retry,
MaxCap,
Swap,
InsufficientLiquidity,
InsufficientBalance
}
175 changes: 175 additions & 0 deletions src/constants/haloAbis/CurveFactory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
[
{
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "caller",
"type": "address"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "id",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "curve",
"type": "address"
}
],
"name": "NewCurve",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "curves",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_baseCurrency",
"type": "address"
},
{
"internalType": "address",
"name": "_quoteCurrency",
"type": "address"
}
],
"name": "getCurve",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
},
{
"internalType": "string",
"name": "_symbol",
"type": "string"
},
{
"internalType": "address",
"name": "_baseCurrency",
"type": "address"
},
{
"internalType": "address",
"name": "_quoteCurrency",
"type": "address"
},
{
"internalType": "uint256",
"name": "_baseWeight",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_quoteWeight",
"type": "uint256"
},
{
"internalType": "address",
"name": "_baseAssimilator",
"type": "address"
},
{
"internalType": "address",
"name": "_quoteAssimilator",
"type": "address"
}
],
"name": "newCurve",
"outputs": [
{
"internalType": "contract Curve",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit ed4df58

Please sign in to comment.