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

Add testnet #7

Merged
merged 6 commits into from
Feb 5, 2024
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
8 changes: 4 additions & 4 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"@hookform/error-message": "^0.0.3",
"@hookform/resolvers": "^0.1.0",
"@invariant-labs/sdk-eclipse": "0.0.2",
"@invariant-labs/sdk-eclipse": "0.0.4",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
Expand Down
1 change: 1 addition & 0 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const Header: React.FC<IHeader> = ({
// rpcName:
// mainnetRPCs.find(data => data.rpc === defaultMainnetRPC)?.rpcName ?? 'Custom'
// },
{ networkType: NetworkType.TESTNET, rpc: EclipseNetworks.TEST },
{ networkType: NetworkType.DEVNET, rpc: EclipseNetworks.DEV }
]}
onSelect={onNetworkSelect}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/NewPositionWrapper/NewPositionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export const NewPositionWrapper: React.FC<IProps> = ({
const allPools = useSelector(poolsArraySortedByFees)
const poolsVolumeRanges = useSelector(volumeRanges)

const canUserCreateNewPool = useSelector(canCreateNewPool)
const canUserCreateNewPosition = useSelector(canCreateNewPosition)

const { success, inProgress } = useSelector(initPosition)
const { data: ticksData, loading: ticksLoading, hasError: hasTicksError } = useSelector(plotTicks)
const isFetchingNewPool = useSelector(isLoadingLatestPoolsForTransaction)
const currentNetwork = useSelector(network)

const canUserCreateNewPool = useSelector(canCreateNewPool(currentNetwork))
const canUserCreateNewPosition = useSelector(canCreateNewPosition(currentNetwork))

const [poolIndex, setPoolIndex] = useState<number | null>(null)

const [liquidity, setLiquidity] = useState<Decimal>({ v: new BN(0) })
Expand Down
8 changes: 6 additions & 2 deletions src/containers/WrappedStats/WrappedStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
useEffect
// useMemo
} from 'react'
import { Grid, Typography } from '@material-ui/core'

Check failure on line 5 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Import 'Typography' is declared but its value is never read. Allowed unused names must match /^_/.
import Liquidity from '@components/Stats/Liquidity/Liquidity'

Check failure on line 6 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import Volume from '@components/Stats/Volume/Volume'

Check failure on line 7 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import VolumeBar from '@components/Stats/volumeBar/volumeBar'

Check failure on line 8 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import TokensList from '@components/Stats/TokensList/TokensList'

Check failure on line 9 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import PoolList from '@components/Stats/PoolList/PoolList'

Check failure on line 10 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import { useDispatch, useSelector } from 'react-redux'
import {
fees24,
Expand All @@ -20,8 +20,9 @@
volumePlot
} from '@selectors/stats'
import { actions } from '@reducers/stats'
import loader from '@static/gif/loader.gif'

Check failure on line 23 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] All imports in import declaration are unused.
import useStyles from './styles'
import EmptyPlaceholder from '@components/EmptyPlaceholder/EmptyPlaceholder'
// import { farms } from '@selectors/farms'
// import { actions as farmsActions } from '@reducers/farms'

Expand All @@ -30,14 +31,14 @@

const dispatch = useDispatch()

const poolsList = useSelector(poolsStatsWithTokensDetails)

Check failure on line 34 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'poolsList' is declared but its value is never read. Allowed unused names must match /^_/.
const tokensList = useSelector(tokensStatsWithTokensDetails)

Check failure on line 35 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'tokensList' is declared but its value is never read. Allowed unused names must match /^_/.
const volume24h = useSelector(volume24)

Check failure on line 36 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'volume24h' is declared but its value is never read. Allowed unused names must match /^_/.
const tvl24h = useSelector(tvl24)

Check failure on line 37 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'tvl24h' is declared but its value is never read. Allowed unused names must match /^_/.
const fees24h = useSelector(fees24)

Check failure on line 38 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'fees24h' is declared but its value is never read. Allowed unused names must match /^_/.
const volumePlotData = useSelector(volumePlot)

Check failure on line 39 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'volumePlotData' is declared but its value is never read. Allowed unused names must match /^_/.
const liquidityPlotData = useSelector(liquidityPlot)

Check failure on line 40 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'liquidityPlotData' is declared but its value is never read. Allowed unused names must match /^_/.
const isLoadingStats = useSelector(isLoading)

Check failure on line 41 in src/containers/WrappedStats/WrappedStats.tsx

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-unused-vars-experimental)

[new] Variable 'isLoadingStats' is declared but its value is never read. Allowed unused names must match /^_/.
// const allFarms = useSelector(farms)

// useEffect(() => {
Expand Down Expand Up @@ -86,7 +87,10 @@

return (
<Grid container className={classes.wrapper} direction='column'>
{isLoadingStats ? (
<Grid container direction='column' alignItems='center'>
<EmptyPlaceholder desc={'We have not started collecting statistics yet'} />
</Grid>
{/* {isLoadingStats ? (
<img src={loader} className={classes.loading} />
) : (
<>
Expand Down Expand Up @@ -156,7 +160,7 @@
}))}
/>
</>
)}
)} */}
</Grid>
)
}
Expand Down
55 changes: 49 additions & 6 deletions src/store/consts/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,38 @@ export const WETH_DEV: Token = {
coingeckoId: 'ethereum'
}

export const USDC_TEST: Token = {
symbol: 'USDC',
address: new PublicKey('5yQMGqpB1Q1J3b8UNStkVks9nFKao1axKYsgZYeMv1ei'),
decimals: 9,
name: 'USD Coin',
logoURI:
'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',
coingeckoId: 'usd-coin'
}

export const BTC_TEST: Token = {
symbol: 'BTC',
address: new PublicKey('97hEP4PZ2P1pQ77yCvc9NxARHttVuTVhdKmvGG1aRNGG'),
decimals: 9,
name: 'Bitcoin',
logoURI:
'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',
coingeckoId: 'bitcoin'
}

export const WETH_TEST: Token = {
symbol: 'WETH',
address: new PublicKey('So11111111111111111111111111111111111111112'),
decimals: 9,
name: 'Wrapped Ethereum',
logoURI:
'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk/logo.png',
coingeckoId: 'ethereum'
}

enum EclipseNetworks {
TEST = 'https://staging-rpc.dev.eclipsenetwork.xyz', // TODO: TEST and MAIN temporarily set to the same endpoint as DEV; they are unvailable to change to on frontend anyways
TEST = 'https://testnet.dev2.eclipsenetwork.xyz', // TODO: TEST and MAIN temporarily set to the same endpoint as DEV; they are unvailable to change to on frontend anyways
MAIN = 'https://staging-rpc.dev.eclipsenetwork.xyz',
DEV = 'https://staging-rpc.dev.eclipsenetwork.xyz',
LOCAL = 'http://127.0.0.1:8899'
Expand All @@ -69,7 +99,7 @@ const MAX_U64 = new BN('18446744073709551615')
export const tokens: Record<NetworkType, Token[]> = {
Devnet: [USDC_DEV, BTC_DEV],
Mainnet: [],
Testnet: [],
Testnet: [USDC_TEST, BTC_TEST],
Localnet: []
}

Expand Down Expand Up @@ -151,29 +181,40 @@ export const bestTiers: Record<NetworkType, BestTier[]> = {
bestTierIndex: 2
}
],
Testnet: [],
Testnet: [
{
tokenX: USDC_TEST.address,
tokenY: WETH_TEST.address,
bestTierIndex: 2
},
{
tokenX: USDC_TEST.address,
tokenY: BTC_TEST.address,
bestTierIndex: 2
}
],
Mainnet: mainnetBestTiersCreator(),
Localnet: []
}

export const commonTokensForNetworks: Record<NetworkType, PublicKey[]> = {
Devnet: [USDC_DEV.address, BTC_DEV.address, WETH_DEV.address],
Mainnet: [],
Testnet: [],
Testnet: [USDC_TEST.address, BTC_TEST.address, WETH_TEST.address],
Localnet: []
}

export const airdropTokens: Record<NetworkType, PublicKey[]> = {
Devnet: [USDC_DEV.address, BTC_DEV.address],
Mainnet: [],
Testnet: [],
Testnet: [USDC_TEST.address, BTC_TEST.address],
Localnet: []
}

export const airdropQuantities: Record<NetworkType, number[]> = {
Devnet: [100 * 10 ** USDC_DEV.decimals, 0.0025 * 10 ** BTC_DEV.decimals],
Mainnet: [],
Testnet: [],
Testnet: [10 * 10 ** USDC_DEV.decimals, 0.00025 * 10 ** BTC_DEV.decimals],
Localnet: []
}

Expand All @@ -182,8 +223,10 @@ export const WRAPPED_ETH_ADDRESS = 'So11111111111111111111111111111111111111112'
export const WETH_MIN_DEPOSIT_SWAP_FROM_AMOUNT = new BN(9200961)

export const WETH_POSITION_INIT_LAMPORTS = new BN(6164600)
export const WETH_POSITION_INIT_LAMPORTS_TEST = new BN(61646)

export const WETH_POOL_INIT_LAMPORTS = new BN(106000961)
export const WETH_POOL_INIT_LAMPORTS_TEST = new BN(1060009)

export const ALL_FEE_TIERS_DATA = FEE_TIERS.map((tier, index) => ({
tier,
Expand Down
11 changes: 10 additions & 1 deletion src/store/consts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import { PlotTickData, PositionWithAddress } from '@reducers/positions'
import { Token as SPLToken, TOKEN_PROGRAM_ID } from '@solana/spl-token'
import {
BTC_DEV,
BTC_TEST,
MAX_U64,
NetworkType,
PRICE_DECIMAL,
Token,
USDC_DEV,
WETH_DEV
USDC_TEST,
WETH_DEV,
WETH_TEST
} from './static'
import mainnetList from './tokenLists/mainnet.json'
import { Connection, Keypair, PublicKey } from '@solana/web3.js'
Expand Down Expand Up @@ -392,6 +395,12 @@ export const getNetworkTokensList = (networkType: NetworkType): Record<string, T
[BTC_DEV.address.toString()]: BTC_DEV,
[WETH_DEV.address.toString()]: WETH_DEV
}
case NetworkType.TESTNET:
return {
[USDC_TEST.address.toString()]: USDC_TEST,
[BTC_TEST.address.toString()]: BTC_TEST,
[WETH_TEST.address.toString()]: WETH_TEST
}
default:
return {}
}
Expand Down
1 change: 1 addition & 0 deletions src/store/sagas/positions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export function* handleInitPosition(action: PayloadAction<InitPositionData>): Ge
if (poolSigners.length) {
signedTx.partialSign(...poolSigners)
}

const txid = yield* call(sendAndConfirmRawTransaction, connection, signedTx.serialize(), {
skipPreflight: false
})
Expand Down
90 changes: 79 additions & 11 deletions src/store/sagas/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

Check failure on line 1 in src/store/sagas/wallet.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
call,
takeLeading,
SagaGenerator,
Expand All @@ -15,6 +15,8 @@
import {
Account,
PublicKey,
sendAndConfirmRawTransaction,
Signer,
SystemProgram,
Transaction,
TransactionInstruction
Expand All @@ -26,7 +28,7 @@
import { WalletAdapter } from '@web3/adapters/types'
import { getTokenDetails } from './token'
import { accounts, status } from '@selectors/solanaWallet'
import { airdropQuantities, airdropTokens, Token as StoreToken } from '@consts/static'
import { airdropQuantities, airdropTokens, NetworkType, Token as StoreToken } from '@consts/static'
import airdropAdmin from '@consts/airdropAdmin'
import { network } from '@selectors/solanaConnection'
import { tokens } from '@selectors/pools'
Expand Down Expand Up @@ -113,16 +115,40 @@
const connection = yield* call(getConnection)
const networkType = yield* select(network)
const wallet = yield* call(getWallet)
yield* call([connection, connection.requestAirdrop], wallet.publicKey, 1 * 1e9)

yield* call(getCollateralTokenAirdrop, airdropTokens[networkType], airdropQuantities[networkType])
yield put(
snackbarsActions.add({
message: 'You will soon receive airdrop',
variant: 'success',
persist: false
})
)

if (networkType === NetworkType.TESTNET) {
// transfer sol
// yield* call([connection, connection.requestAirdrop], airdropAdmin.publicKey, 1 * 1e9)
yield* call(transferAirdropSOL)
yield* call(
getCollateralTokenAirdrop,
airdropTokens[networkType],
airdropQuantities[networkType]
)

Check failure on line 128 in src/store/sagas/wallet.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(no-trailing-spaces)

[new] Trailing spaces not allowed.
yield put(
snackbarsActions.add({
message: 'You will soon receive airdrop of tokens',
variant: 'success',
persist: false
})
)
} else {
yield* call([connection, connection.requestAirdrop], wallet.publicKey, 1 * 1e9)

yield* call(
getCollateralTokenAirdrop,
airdropTokens[networkType],
airdropQuantities[networkType]
)
yield put(
snackbarsActions.add({
message: 'You will soon receive airdrop',
variant: 'success',
persist: false
})
)
}
}

export function* setEmptyAccounts(collateralsAddresses: PublicKey[]): Generator {
Expand All @@ -142,6 +168,48 @@
}
}

export function* transferAirdropSOL(): Generator {
const wallet = yield* call(getWallet)

const tx = new Transaction().add(
SystemProgram.transfer({
fromPubkey: airdropAdmin.publicKey,
toPubkey: wallet.publicKey,
lamports: 3000000
})
)
const connection = yield* call(getConnection)
const blockhash = yield* call([connection, connection.getRecentBlockhash])
tx.feePayer = airdropAdmin.publicKey
tx.recentBlockhash = blockhash.blockhash
tx.setSigners(airdropAdmin.publicKey)
tx.partialSign(airdropAdmin as Signer)

const txid = yield* call(sendAndConfirmRawTransaction, connection, tx.serialize(), {
skipPreflight: false
})

if (!txid.length) {
yield put(
snackbarsActions.add({
message: 'Failed to airdrop testnet ETH. Please try again.',
variant: 'error',
persist: false,
txid
})
)
} else {
yield put(
snackbarsActions.add({
message: 'Testnet ETH airdrop successfully.',
variant: 'success',
persist: false,
txid
})
)
}
}

export function* getCollateralTokenAirdrop(
collateralsAddresses: PublicKey[],
collateralsQuantities: number[]
Expand Down
Loading
Loading