Skip to content

Commit

Permalink
starknet defi spring (#275)
Browse files Browse the repository at this point in the history
* strk rewards new design implemented

* hardcode bug resolved

* button state handling and some iterations

* added allocation dependencies to numbers

* apr updated

* reward pair name fixes

* api url update for rewards

* added loader

* double currency logo handled
  • Loading branch information
vnaysngh-mudrex authored Mar 8, 2024
1 parent 0b92a7d commit b2b6ddb
Show file tree
Hide file tree
Showing 21 changed files with 1,518 additions and 174 deletions.
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
"prettier": "^1.17.0",
"pretty-quick": "^3.1.3",
"qs": "^6.9.4",
"react": "^16.13.1",
"react": "^18.2.0",
"react-confetti": "^6.0.0",
"react-device-detect": "^1.6.2",
"react-dom": "^16.13.1",
"react-dom": "^18.2.0",
"react-error-overlay": "6.0.9",
"react-feather": "^2.0.10",
"react-ga4": "^1.4.1",
Expand All @@ -89,7 +89,7 @@
"rebass": "^4.0.7",
"redux-localstorage-simple": "^2.3.1",
"serve": "13.0.2",
"starknet": "^5.19.5",
"starknet": "^5.24.3",
"start-server-and-test": "^1.11.0",
"styled-components": "^4.2.0",
"tiny-invariant": "^1.2.0",
Expand Down Expand Up @@ -137,12 +137,18 @@
"dependencies": {
"@argent/starknet-react-webwallet-connector": "^6.4.2",
"@sentry/react": "^7.53.1",
"@starknet-react/chains": "^0.1.0-next.1",
"@starknet-react/core": "2.0.0-next.6",
"@starknet-react/chains": "^0.1.7",
"@starknet-react/core": "^2.3.0",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"events": "^3.3.0",
"get-starknet-core": "^3.2.0",
"graphql": "^14.5.6",
"graphql-tag": "^2.10.1",
"react-apollo": "^3.1.5",
"starknetkit": "^1.1.3",
"vite-plugin-svgr": "^2.2.0",
"wido-widget": "1.5.3"
Expand Down
35 changes: 35 additions & 0 deletions src/apollo/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
import { getApiUrl } from '../constants'

export const jediSwapClient = new ApolloClient({
link: new HttpLink({
uri: getApiUrl(),
headers: {
// 'm-color': 'blue',
}
}),
cache: new InMemoryCache({
dataIdFromObject: object => {
switch (object.__typename) {
case 'TokenDayData': {
return `${object.tokenAddress}${object.datetime}`
}
case 'FactoryDayData': {
return `${object.id}${object.dayId}`
}
case 'Token': {
return `${object.tokenAddress}${object.name}`
}
case 'Pool': {
return `${object.poolAddress}${object.datetime}`
}
default: {
return object.id || object._id
}
}
}
}),
shouldBatch: true
})
23 changes: 23 additions & 0 deletions src/apollo/queries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import gql from 'graphql-tag'

export const PAIRS_DATA_FOR_REWARDS = ({ pairIds = [] }) => {
const poolsString = `[${pairIds.map(pool => `"${pool}"`).join(',')}]`
let queryString = `
query pairDayDatas {
pairDayDatas(
where: {
pairIn: ${poolsString},
}
orderBy: "date"
orderByDirection: "desc"
first: ${10 * pairIds.length}
) {
pairId
date
dailyVolumeUSD
reserveUSD
}
}
`
return gql(queryString)
}
9 changes: 9 additions & 0 deletions src/assets/jedi/stark-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/CurrencyLogo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function CurrencyLogo({
return []
}, [currency, uriLocations])

if (currency === ETHER) {
if (currency === ETHER || currency?.symbol === 'ETH') {
return <StyledEthereumLogo src={EthereumLogo} size={size} style={style} />
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ function Header({ history }: { history: any }) {
V2
</StyledExternalLink>

<StyledExternalLink id={`rewards-link`} href={'https://rewards.jediswap.xyz/'}>
<StyledNavLink id={`rewards-link`} to={'/rewards'}>
Rewards
</StyledExternalLink>
</StyledNavLink>

{/* <StyledNavLink id={`stake-nav-link`} to={'/uni'} isActive={() => history.location.pathname.includes('/uni')}>
UNI
Expand Down
22 changes: 11 additions & 11 deletions src/components/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'
import styled from 'styled-components'
import { ReactComponent as Close } from '../../assets/images/x.svg'
import { isProductionChainId, isProductionEnvironment, isTestnetChainId, isTestnetEnvironment } from '../../connectors'
import {NetworkContextName, SUPPORTED_WALLETS} from '../../constants'
import { NetworkContextName, SUPPORTED_WALLETS } from '../../constants'
import usePrevious from '../../hooks/usePrevious'
import { ApplicationModal } from '../../state/application/actions'
import { useModalOpen, useWalletModalToggle } from '../../state/application/hooks'
Expand Down Expand Up @@ -150,15 +150,15 @@ export default function WalletModal({
const previousAccount = usePrevious(account)

useEffect(() => {
if (status === 'connected' && chainId) {
if (
(isProductionEnvironment() && !isProductionChainId(chainId)) ||
(isTestnetEnvironment() && !isTestnetChainId(chainId)) ||
!Object.values(ChainId).includes(chainId)
) {
setChainError(true)
}
}
// if (status === 'connected' && chainId) {
// if (
// (isProductionEnvironment() && !isProductionChainId(chainId)) ||
// (isTestnetEnvironment() && !isTestnetChainId(chainId)) ||
// !Object.values(ChainId).includes(chainId)
// ) {
// setChainError(true)
// }
// }
}, [status])

useEffect(() => {
Expand Down Expand Up @@ -238,7 +238,7 @@ export default function WalletModal({
// get wallets user can switch too, depending on device/browser
function getOptions() {
return connectors.map((option: Connector) => {
const wallet = SUPPORTED_WALLETS[option.id] ?? option;
const wallet = SUPPORTED_WALLETS[option.id] ?? option
return (
<Option
id={`connect-${wallet.id}`}
Expand Down
28 changes: 15 additions & 13 deletions src/components/Web3Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,21 @@ export default function Web3Status() {

const [domain, setDomain] = useState<string>('')

useEffect(() => {
const url = domainURL(chainId as ChainId)
if (!address) { return };
setDomain('');
fetch(url + num.hexToDecimalString(address ?? ''))
.then(response => response.json())
.then((data: DomainToAddrData) => {
setDomain(data.domain)
})
.catch(error => {
console.error(error)
})
}, [address, chainId])
// useEffect(() => {
// const url = domainURL(chainId as ChainId)
// if (!address) {
// return
// }
// setDomain('')
// fetch(url + num.hexToDecimalString(address ?? ''))
// .then(response => response.json())
// .then((data: DomainToAddrData) => {
// setDomain(data.domain)
// })
// .catch(error => {
// console.error(error)
// })
// }, [address, chainId])

const allTransactions = useAllTransactions()

Expand Down
197 changes: 197 additions & 0 deletions src/constants/abis/strk-rewards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
[
{
"name": "Distributor",
"type": "impl",
"interface_name": "distributor::contract::IDistributor"
},
{
"name": "core::array::Span::<core::felt252>",
"type": "struct",
"members": [
{
"name": "snapshot",
"type": "@core::array::Array::<core::felt252>"
}
]
},
{
"name": "distributor::contract::IDistributor",
"type": "interface",
"items": [
{
"name": "claim",
"type": "function",
"inputs": [
{
"name": "amount",
"type": "core::integer::u128"
},
{
"name": "proof",
"type": "core::array::Span::<core::felt252>"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"name": "add_root",
"type": "function",
"inputs": [
{
"name": "new_root",
"type": "core::felt252"
}
],
"outputs": [],
"state_mutability": "external"
},
{
"name": "get_root_for",
"type": "function",
"inputs": [
{
"name": "claimee",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"name": "amount",
"type": "core::integer::u128"
},
{
"name": "proof",
"type": "core::array::Span::<core::felt252>"
}
],
"outputs": [
{
"type": "core::felt252"
}
],
"state_mutability": "view"
},
{
"name": "amount_already_claimed",
"type": "function",
"inputs": [
{
"name": "claimee",
"type": "core::starknet::contract_address::ContractAddress"
}
],
"outputs": [
{
"type": "core::integer::u128"
}
],
"state_mutability": "view"
},
{
"name": "roots",
"type": "function",
"inputs": [],
"outputs": [
{
"type": "core::array::Span::<core::felt252>"
}
],
"state_mutability": "view"
}
]
},
{
"name": "constructor",
"type": "constructor",
"inputs": [
{
"name": "owner",
"type": "core::starknet::contract_address::ContractAddress"
}
]
},
{
"kind": "struct",
"name": "distributor::contract::Distributor::Claimed",
"type": "event",
"members": [
{
"kind": "data",
"name": "claimee",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"kind": "data",
"name": "amount",
"type": "core::integer::u128"
}
]
},
{
"kind": "struct",
"name": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred",
"type": "event",
"members": [
{
"kind": "key",
"name": "previous_owner",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"kind": "key",
"name": "new_owner",
"type": "core::starknet::contract_address::ContractAddress"
}
]
},
{
"kind": "struct",
"name": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
"type": "event",
"members": [
{
"kind": "key",
"name": "previous_owner",
"type": "core::starknet::contract_address::ContractAddress"
},
{
"kind": "key",
"name": "new_owner",
"type": "core::starknet::contract_address::ContractAddress"
}
]
},
{
"kind": "enum",
"name": "openzeppelin::access::ownable::ownable::OwnableComponent::Event",
"type": "event",
"variants": [
{
"kind": "nested",
"name": "OwnershipTransferred",
"type": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred"
},
{
"kind": "nested",
"name": "OwnershipTransferStarted",
"type": "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted"
}
]
},
{
"kind": "enum",
"name": "distributor::contract::Distributor::Event",
"type": "event",
"variants": [
{
"kind": "nested",
"name": "Claimed",
"type": "distributor::contract::Distributor::Claimed"
},
{
"kind": "nested",
"name": "OwnableEvent",
"type": "openzeppelin::access::ownable::ownable::OwnableComponent::Event"
}
]
}
]
Loading

0 comments on commit b2b6ddb

Please sign in to comment.