Skip to content

Commit

Permalink
Merge pull request #2294 from keep-network/tbtc_saddle_liquidity_rewards
Browse files Browse the repository at this point in the history
TBTC + Saddle pool

This PR Adds TBTC + Saddle pool to Liquidity Rewards page.
  • Loading branch information
r-czajkowski authored Jan 19, 2021
2 parents a6d64f5 + f39ca99 commit 5796392
Show file tree
Hide file tree
Showing 20 changed files with 422 additions and 152 deletions.
6 changes: 3 additions & 3 deletions solidity/dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion solidity/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"@0x/subproviders": "^6.0.8",
"@keep-network/keep-core": "1.4.1",
"@keep-network/keep-ecdsa": "1.5.0",
"@keep-network/keep-ecdsa": "1.6.0",
"@keep-network/tbtc": "1.1.0",
"@ledgerhq/hw-app-eth": "^5.13.0",
"@ledgerhq/hw-transport-u2f": "^5.13.0",
Expand Down
2 changes: 2 additions & 0 deletions solidity/dashboard/src/actions/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export const addMoreLpTokens = (
amount,
address,
liquidityPairContractName,
pool,
meta
) => {
return {
Expand All @@ -203,6 +204,7 @@ export const addMoreLpTokens = (
contractName: liquidityPairContractName,
amount,
address,
pool,
},
meta,
}
Expand Down
19 changes: 19 additions & 0 deletions solidity/dashboard/src/components/Icons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,24 @@ const Coinbase = () => (
</svg>
)

const Saddle = ({ className }) => {
return (
<img
style={{
width: "auto",
height: "1.8rem",
backgroundColor: "white",
borderRadius: "100%",
border: "2px solid #3800D6",
padding: ".1rem .35rem",
}}
className={className}
src={require("../static/svg/Saddle_logomark_blue.png")}
alt="Saddle Logo"
/>
)
}

export {
Badge,
Cross,
Expand Down Expand Up @@ -371,4 +389,5 @@ export {
Time,
KeepDashboardLogo,
NetworkStatusIndicator,
Saddle,
}
14 changes: 11 additions & 3 deletions solidity/dashboard/src/components/LiquidityRewardCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Banner from "./Banner"
import { toTokenUnit } from "../utils/token.utils"
import { gt } from "../utils/arithmetics.utils"
import { formatPercentage } from "../utils/general.utils"
import { LIQUIDITY_REWARD_PAIRS } from "../constants/constants"

const LiquidityRewardCard = ({
title,
Expand All @@ -32,6 +33,7 @@ const LiquidityRewardCard = ({
addLpTokens,
withdrawLiquidityRewards,
isAPYFetching,
pool,
}) => {
const formattedApy = useMemo(() => {
const bn = new BigNumber(apy).multipliedBy(100)
Expand Down Expand Up @@ -94,7 +96,9 @@ const LiquidityRewardCard = ({
href={viewPoolLink}
className="text-white text-link"
>
Uniswap pool
{title === LIQUIDITY_REWARD_PAIRS.TBTC_SADDLE.label
? "Saddle pool"
: "Uniswap pool"}
</a>
</Banner.Description>
</div>
Expand All @@ -114,7 +118,10 @@ const LiquidityRewardCard = ({
<h2 className={"h2--alt text-grey-70"}>{title}</h2>
</div>
<h4 className="liquidity__card-subtitle text-grey-40">
Uniswap Pool&nbsp;
{title === LIQUIDITY_REWARD_PAIRS.TBTC_SADDLE.label
? "Saddle Pool"
: "Uniswap Pool"}
&nbsp;
<a
target="_blank"
rel="noopener noreferrer"
Expand Down Expand Up @@ -156,7 +163,7 @@ const LiquidityRewardCard = ({
>
Uniswap subgraph API
</a>
&nbsp;to fetch the the total pool value and KEEP token in USD.
&nbsp;to fetch the total pool value and KEEP token in USD.
</Tooltip>
{isAPYFetching ? (
<Skeleton tag="h2" shining color="grey-10" />
Expand Down Expand Up @@ -228,6 +235,7 @@ const LiquidityRewardCard = ({
addLpTokens(
wrappedTokenBalance,
liquidityPairContractName,
pool,
awaitingPromise
)
}
Expand Down
10 changes: 10 additions & 0 deletions solidity/dashboard/src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const TBTC_SYSTEM_CONTRACT_NAME = "tbtcSystemContract"
export const TOKEN_STAKING_ESCROW_CONTRACT_NAME = "tokenStakingEscrow"
export const OLD_TOKEN_STAKING_CONTRACT_NAME = "oldTokenStakingContract"
export const STAKING_PORT_BACKER_CONTRACT_NAME = "stakingPortBackerContract"
export const LP_REWARDS_TBTC_SADDLE_CONTRACT_NAME = "LPRewardsTBTCSaddle"
export const LP_REWARDS_KEEP_ETH_CONTRACT_NAME = "LPRewardsKEEPETHContract"
export const LP_REWARDS_TBTC_ETH_CONTRACT_NAME = "LPRewardsTBTCETHContract"
export const LP_REWARDS_KEEP_TBTC_CONTRACT_NAME = "LPRewardsKEEPTBTCContract"
Expand Down Expand Up @@ -41,25 +42,34 @@ export const SIGNING_GROUP_STATUS = {
}

export const LIQUIDITY_REWARD_PAIRS = {
TBTC_SADDLE: {
contractName: LP_REWARDS_TBTC_SADDLE_CONTRACT_NAME,
label: "TBTC + SADDLE",
viewPoolLink: "https://saddle.exchange/#/deposit",
pool: "SADDLE",
},
KEEP_ETH: {
contractName: LP_REWARDS_KEEP_ETH_CONTRACT_NAME,
label: "KEEP + ETH",
viewPoolLink:
"https://info.uniswap.org/pair/0xe6f19dab7d43317344282f803f8e8d240708174a",
address: "0xe6f19dab7d43317344282f803f8e8d240708174a",
pool: "UNISWAP",
},
KEEP_TBTC: {
contractName: LP_REWARDS_KEEP_TBTC_CONTRACT_NAME,
label: "KEEP + TBTC",
viewPoolLink:
"https://info.uniswap.org/pair/0x38c8ffee49f286f25d25bad919ff7552e5daf081",
address: "0x38c8ffee49f286f25d25bad919ff7552e5daf081",
pool: "UNISWAP",
},
TBTC_ETH: {
contractName: LP_REWARDS_TBTC_ETH_CONTRACT_NAME,
label: "TBTC + ETH",
viewPoolLink:
"https://info.uniswap.org/pair/0x854056fd40c1b52037166285b2e54fee774d33f6",
address: "0x854056fd40c1b52037166285b2e54fee774d33f6",
pool: "UNISWAP",
},
}
2 changes: 2 additions & 0 deletions solidity/dashboard/src/contracts-artifacts/SaddleSwap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ "abi": [{"inputs":[{"internalType":"contract IERC20[]","name":"_pooledTokens","type":"address[]"},{"internalType":"uint8[]","name":"decimals","type":"uint8[]"},{"internalType":"string","name":"lpTokenName","type":"string"},{"internalType":"string","name":"lpTokenSymbol","type":"string"},{"internalType":"uint256","name":"_a","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"uint256","name":"_adminFee","type":"uint256"},{"internalType":"uint256","name":"_withdrawFee","type":"uint256"},{"internalType":"contract IAllowlist","name":"_allowlist","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"invariant","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokenSupply","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAdminFee","type":"uint256"}],"name":"NewAdminFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newSwapFee","type":"uint256"}],"name":"NewSwapFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newWithdrawFee","type":"uint256"}],"name":"NewWithdrawFee","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"initialTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"futureTime","type":"uint256"}],"name":"RampA","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"lpTokenSupply","type":"uint256"}],"name":"RemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"invariant","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokenSupply","type":"uint256"}],"name":"RemoveLiquidityImbalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"lpTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokenSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boughtId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensBought","type":"uint256"}],"name":"RemoveLiquidityOne","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"}],"name":"StopRampA","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokensSold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensBought","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"soldId","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"boughtId","type":"uint128"}],"name":"TokenSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"minToMint","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"calculateCurrentWithdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateRemoveLiquidity","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint8","name":"tokenIndex","type":"uint8"}],"name":"calculateRemoveLiquidityOneToken","outputs":[{"internalType":"uint256","name":"availableTokenAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"tokenIndexFrom","type":"uint8"},{"internalType":"uint8","name":"tokenIndexTo","type":"uint8"},{"internalType":"uint256","name":"dx","type":"uint256"}],"name":"calculateSwap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bool","name":"deposit","type":"bool"}],"name":"calculateTokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getA","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAPrecise","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getAdminBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllowlist","outputs":[{"internalType":"contract IAllowlist","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getDepositTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"getTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"getTokenIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVirtualPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isGuarded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"futureA","type":"uint256"},{"internalType":"uint256","name":"futureTime","type":"uint256"}],"name":"rampA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"maxBurnAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityImbalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint8","name":"tokenIndex","type":"uint8"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityOneToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAdminFee","type":"uint256"}],"name":"setAdminFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newWithdrawFee","type":"uint256"}],"name":"setDefaultWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newSwapFee","type":"uint256"}],"name":"setSwapFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopRampA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"tokenIndexFrom","type":"uint8"},{"internalType":"uint8","name":"tokenIndexTo","type":"uint8"},{"internalType":"uint256","name":"dx","type":"uint256"},{"internalType":"uint256","name":"minDy","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapStorage","outputs":[{"internalType":"uint256","name":"initialA","type":"uint256"},{"internalType":"uint256","name":"futureA","type":"uint256"},{"internalType":"uint256","name":"initialATime","type":"uint256"},{"internalType":"uint256","name":"futureATime","type":"uint256"},{"internalType":"uint256","name":"swapFee","type":"uint256"},{"internalType":"uint256","name":"adminFee","type":"uint256"},{"internalType":"uint256","name":"defaultWithdrawFee","type":"uint256"},{"internalType":"contract LPToken","name":"lpToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"transferAmount","type":"uint256"}],"name":"updateUserWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAdminFees","outputs":[],"stateMutability":"nonpayable","type":"function"}]
}
15 changes: 15 additions & 0 deletions solidity/dashboard/src/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import ECDSARewardsDistributor from "@keep-network/keep-ecdsa/artifacts/ECDSARew
import LPRewardsKEEPETH from "@keep-network/keep-ecdsa/artifacts/LPRewardsKEEPETH.json"
import LPRewardsTBTCETH from "@keep-network/keep-ecdsa/artifacts/LPRewardsTBTCETH.json"
import LPRewardsKEEPTBTC from "@keep-network/keep-ecdsa/artifacts/LPRewardsKEEPTBTC.json"
import LPRewardsTBTCSaddle from "@keep-network/keep-ecdsa/artifacts/LPRewardsTBTCSaddle.json"
import IERC20 from "@keep-network/keep-core/artifacts/IERC20.json"
import SaddleSwap from "./contracts-artifacts/SaddleSwap.json"
import Web3 from "web3"

import {
Expand All @@ -41,6 +43,7 @@ import {
LP_REWARDS_KEEP_ETH_CONTRACT_NAME,
LP_REWARDS_TBTC_ETH_CONTRACT_NAME,
LP_REWARDS_KEEP_TBTC_CONTRACT_NAME,
LP_REWARDS_TBTC_SADDLE_CONTRACT_NAME,
} from "./constants/constants"

export const CONTRACT_DEPLOY_BLOCK_NUMBER = {
Expand Down Expand Up @@ -118,6 +121,10 @@ const contracts = {
artifact: LPRewardsKEEPTBTC,
withDeployBlock: true,
},
[LP_REWARDS_TBTC_SADDLE_CONTRACT_NAME]: {
artifact: LPRewardsTBTCSaddle,
withDeployBlock: true,
},
}

export async function getKeepTokenContractDeployerAddress(web3) {
Expand Down Expand Up @@ -317,3 +324,11 @@ export const createLPRewardsContract = async (web3, contractName) => {
const { artifact } = contracts[contractName]
return await getContract(web3, artifact, {})
}

export const createSaddleSwapContract = (web3) => {
return createWeb3ContractInstance(
web3,
SaddleSwap.abi,
"0x4f6A43Ad7cba042606dECaCA730d4CE0A57ac62e"
)
}
6 changes: 6 additions & 0 deletions solidity/dashboard/src/css/card-container.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: 0 2.2rem;

@media screen and (min-width: 1600px) {
justify-content: start;
margin: 0 2.2rem;
}
}
2 changes: 1 addition & 1 deletion solidity/dashboard/src/css/liquidity-page.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.liquidity__double-icon-container {
margin-right: 0.5rem;

.tbtc-eth& {
.tbtc-eth&, .tbtc-saddle& {
.main-icon {
circle {
fill: @white;
Expand Down
Loading

0 comments on commit 5796392

Please sign in to comment.