Skip to content

Commit

Permalink
Merge pull request #483 from comdex-official/pool-integration
Browse files Browse the repository at this point in the history
Pool integration
  • Loading branch information
dheerajkd30 authored Jan 4, 2023
2 parents 17e4adb + 6fa47aa commit 3d35062
Show file tree
Hide file tree
Showing 8 changed files with 996 additions and 136 deletions.
32 changes: 20 additions & 12 deletions src/assets/scss/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ body {
}
}

h1, h2, h3, h4, h5, h6 {
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
}

p{
p {
margin: 0;
}

Expand Down Expand Up @@ -420,11 +425,10 @@ button {
}
}


.comdex-tabs {
.ant-tabs-nav {
margin-bottom: 10px;
padding: 0 15px ;
padding: 0 15px;
&:before {
display: none;
}
Expand Down Expand Up @@ -567,6 +571,10 @@ button {
color: $text-color-white;
}
}
td {
background: transparent;
border: none;
}
th:nth-child(1) {
text-align: left !important;
}
Expand Down Expand Up @@ -1245,9 +1253,9 @@ button {
color: red;
}
}
.ant-picker-disabled{
background: transparent !important;
}
.ant-picker-disabled {
background: transparent !important;
}
}

.buysell-arrow {
Expand Down Expand Up @@ -1716,7 +1724,7 @@ button {
a {
color: $secondary-color;
.dark-mode & {
color: $white;
color: $black;
}
}
}
Expand Down Expand Up @@ -1777,16 +1785,16 @@ button {
background: rgba(#665aa6, 0.8);
}

.dropconnect-overlay{
.dropconnect-overlay {
padding: 0;
background: none !important;
.ant-dropdown-menu{
.ant-dropdown-menu {
padding: 0;
background: none !important;
.ant-dropdown-menu-item{
.ant-dropdown-menu-item {
padding: 0;
cursor: default;
background: none !important;
}
}
}
}
4 changes: 4 additions & 0 deletions src/containers/Assets/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
th {
font-size: 12px;
}
td {
background: transparent;
border: none;
}
}
}
.ant-table-tbody {
Expand Down
202 changes: 181 additions & 21 deletions src/containers/More/Vote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as PropTypes from "prop-types";
import { Col, Row, SvgIcon } from "../../../components/common";
import './index.scss';
import { connect } from "react-redux";
import { Button, message, Table } from "antd";
import { Button, message, Table, Tabs } from "antd";
import { denomToSymbol, iconNameFromDenom, symbolToDenom } from "../../../utils/string";
import { amountConversion, amountConversionWithComma } from '../../../utils/coin';
import { DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE, DOLLAR_DECIMALS, PRODUCT_ID } from '../../../constants/common';
import { totalVTokens, userProposalAllUpData, votingCurrentProposal, votingCurrentProposalId, votingTotalBribs, votingTotalVotes, votingUserVote } from '../../../services/voteContractsRead';
import { totalVTokens, userProposalAllUpData, userProposalAllUpPoolData, votingCurrentProposal, votingCurrentProposalId, votingTotalBribs, votingTotalVotes, votingUserVote } from '../../../services/voteContractsRead';
import { queryAssets, queryPair, queryPairVault } from '../../../services/asset/query';
import { queryMintedTokenSpecificVaultType, queryOwnerVaults, queryOwnerVaultsInfo, queryUserVaults } from '../../../services/vault/query';
import { transactionForVotePairProposal } from '../../../services/voteContractsWrites';
Expand All @@ -20,6 +20,8 @@ import variables from '../../../utils/variables';
import { comdex } from '../../../config/network';
import NoDataIcon from '../../../components/common/NoDataIcon';
import CustomSkelton from '../../../components/CustomSkelton';
import Pool from './pool';
import { queryPoolsList } from '../../../services/pools/query';

const Vote = ({
lang,
Expand All @@ -34,6 +36,7 @@ const Vote = ({
const [currentProposalAllData, setCurrentProposalAllData] = useState();
const [disableVoteBtn, setVoteDisableBtn] = useState(true)
const [allProposalData, setAllProposalData] = useState();
const [allProposalPoolData, setAllProposalPoolData] = useState();
const [btnLoading, setBtnLoading] = useState(0);
const [pairVaultData, setPairValutData] = useState({})
const [assetList, setAssetList] = useState();
Expand Down Expand Up @@ -139,6 +142,7 @@ const Vote = ({
}))
})
}

const getOwnerVaultId = (productId, address, extentedPairId) => {
queryOwnerVaults(productId, address, extentedPairId, (error, data) => {
if (error) {
Expand Down Expand Up @@ -186,10 +190,8 @@ const Vote = ({
const calculateTotalVotes = (value) => {
let userTotalVotes = 0;
let calculatePercentage = 0;
allProposalData && allProposalData.map((item) => {
userTotalVotes = userTotalVotes + Number(amountConversion(item?.total_vote || 0))
})
calculatePercentage = (Number(value) / userTotalVotes) * 100;

calculatePercentage = (Number(value) / amountConversion(currentProposalAllData?.total_voted_weight || 0, DOLLAR_DECIMALS)) * 100;
calculatePercentage = Number(calculatePercentage || 0).toFixed(DOLLAR_DECIMALS)
return calculatePercentage;
}
Expand Down Expand Up @@ -383,6 +385,143 @@ const Vote = ({

const tableData =
allProposalData && allProposalData.map((item, index) => {
return {
key: index,
asset: (
<>
<div className="assets-withicon">
<div className="assets-icon">
<SvgIcon
name={iconNameFromDenom(
symbolToDenom(getIconFromPairName(pairVaultData[item?.extended_pair_id]))
)}
/>
</div>
{pairVaultData[item?.extended_pair_id]}
</div>
</>
),
my_borrowed: (
<>
<div className="assets-withicon display-center">
{myBorrowed[item?.extended_pair_id] ? amountConversionWithComma(myBorrowed[item?.extended_pair_id], DOLLAR_DECIMALS) : Number(0).toFixed(2)}
{" "}{denomToSymbol("ucmst")}
</div>
</>
),
total_borrowed:
<div>
{totalBorrowed[item?.extended_pair_id] ? amountConversionWithComma(
totalBorrowed[item?.extended_pair_id], DOLLAR_DECIMALS
) : Number(0).toFixed(2)} {denomToSymbol("ucmst")}
</div>,
total_votes: <div >{item?.total_vote ? amountConversionWithComma(item?.total_vote, DOLLAR_DECIMALS) : Number(0).toFixed(DOLLAR_DECIMALS)} veHARBOR <div style={{ fontSize: "12px" }}>{item?.total_vote ? calculateTotalVotes(amountConversion(item?.total_vote || 0, 6) || 0) : Number(0).toFixed(DOLLAR_DECIMALS)}%</div></div>,
bribe: item?.bribe,
my_vote: <div>{item?.my_vote ? amountConversion(item?.my_vote, DOLLAR_DECIMALS) : Number(0).toFixed(DOLLAR_DECIMALS)} veHARBOR</div>,
action: <>
<Button
type="primary"
className="btn-filled"
size="sm"
loading={index === btnLoading ? inProcess : false}
onClick={() => handleVote(item?.extended_pair_id, index)}
disabled={disableVoteBtn}
>
Vote
</Button>
</>,
}
})
const poolColumns = [
{
title: (
<>
Vault Pair
</>
),
dataIndex: "asset",
key: "asset",
width: 150,
},
{
title: (
<>
My Borrowed{" "}
</>
),
dataIndex: "my_borrowed",
key: "my_borrowed",
width: 150,
},
{
title: (
<>
Total Borrowed
</>
),
dataIndex: "total_borrowed",
key: "total_borrowed",
width: 200,
},
{
title: (
<>
Total Votes
</>
),
dataIndex: "total_votes",
key: "total_votes",
width: 200,
},

{
title: (
<>
External Incentives
</>
),
dataIndex: "bribe",
key: "bribe",
width: 200,
render: (item) => (
<>
{item?.length > 0 ?
item && item?.map((singleBribe, index) => {
return <div className="endtime-badge mt-1" key={index}>{amountConversionWithComma(singleBribe?.amount, DOLLAR_DECIMALS)} {denomToSymbol(singleBribe?.denom)}</div>
})
: <div className="endtime-badge mt-1" >{" "}</div>

}

</>
),
},
{
title: (
<>
My Vote
</>
),
dataIndex: "my_vote",
key: "my_vote",
align: "center",
width: 100,
},
{
title: (
<>
Action
</>
),
dataIndex: "action",
key: "action",
align: "centre",
width: 130,
},
];

const poolTableData =
allProposalPoolData && allProposalPoolData.map((item, index) => {
return {
key: index,
asset: (
Expand Down Expand Up @@ -431,6 +570,34 @@ const Vote = ({
}
})

const tabsItem = [
{
label: "Vaults", key: "1", children: (
<Row>
<Col>
<div className="composite-card ">
<div className="card-content">
<Table
className="custom-table liquidation-table"
dataSource={tableData}
columns={columns}
loading={loading}
pagination={false}
scroll={{ x: "100%" }}
locale={{ emptyText: <NoDataIcon /> }}
/>
</div>
</div>

</Col>
</Row>
)
},
{
label: "Pools", key: "2", children: <Pool />
},
]

return (
<>
<div className="app-content-wrapper">
Expand All @@ -455,27 +622,20 @@ const Vote = ({
<Col>
<div className="vote-text-main-container mt-3">
<div className="vote-text-container">
{currentProposalAllData ? "Votes are due by" + calculteVotingTime() : "Voting for epoch proposal not active "}, when the next epoch begins. Your vote will allocate 100% of the veHARBOR voting power. Voters will earn External Incentives no matter when in the epoch they are added.
{currentProposalAllData ? "Votes are due by " + calculteVotingTime() : "Voting for epoch proposal not active "}, when the next epoch begins. Your vote will allocate 100% of the veHARBOR voting power. Voters will earn External Incentives no matter when in the epoch they are added.
</div>
</div>
</Col>
</Row>


<Row>
<Col>
<div className="composite-card ">
<div className="card-content">
<Table
className="custom-table liquidation-table"
dataSource={tableData}
columns={columns}
loading={loading}
pagination={false}
scroll={{ x: "100%" }}
locale={{ emptyText: <NoDataIcon /> }}
/>
</div>
</div>

<Tabs
className="comdex-tabs mt-2"
defaultActiveKey="1"
items={tabsItem}
/>
</Col>
</Row>
</div>
Expand Down
Loading

0 comments on commit 3d35062

Please sign in to comment.