Skip to content

Commit 868fb21

Browse files
authored
add jitosol minting, remove lido minting (#27)
1 parent d0e076e commit 868fb21

5 files changed

Lines changed: 137 additions & 155 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ yarn-error.log*
3131
.env.development.local
3232
.env.test.local
3333
.env.production.local
34+
.env.*
3435

3536
# vercel
3637
.vercel

components/TreasuryAccount/ConvertToStSol.tsx renamed to components/TreasuryAccount/ConvertToJitoSol.tsx

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,26 @@ import VoteBySwitch from 'pages/dao/[symbol]/proposal/components/VoteBySwitch'
1717
import Button from '@components/Button'
1818
import Tooltip from '@components/Tooltip'
1919
import { getStakeSchema } from '@utils/validations'
20-
import { getConvertToStSolInstruction } from '@utils/instructionTools'
20+
import { getConvertToJitoSolInstruction } from '@utils/instructionTools'
2121
import { getInstructionDataFromBase64 } from '@solana/spl-governance'
2222
import useQueryContext from '@hooks/useQueryContext'
2323
import { useRouter } from 'next/router'
2424
import { notify } from '@utils/notifications'
2525
import useCreateProposal from '@hooks/useCreateProposal'
2626
import { AssetAccount } from '@utils/uiTypes/assets'
27-
import { PublicKey } from '@solana/web3.js'
2827
import useWalletOnePointOh from '@hooks/useWalletOnePointOh'
2928
import { useRealmQuery } from '@hooks/queries/realm'
3029
import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext'
31-
import {
32-
LIDO_PROGRAM_ID,
33-
LIDO_PROGRAM_ID_DEVNET,
34-
} from '@constants/pubkeys/lido'
3530
import { useVoteByCouncilToggle } from '@hooks/useVoteByCouncilToggle'
31+
import { PublicKey } from '@solana/web3.js'
32+
33+
export const JITOSOL_MINT_ADDRESS = new PublicKey(
34+
'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn',
35+
)
36+
37+
export const JITO_STAKE_POOL_ACCOUNT = new PublicKey(
38+
'Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb',
39+
)
3640

3741
const defaultFormState = {
3842
destinationAccount: undefined,
@@ -44,39 +48,35 @@ const defaultFormState = {
4448

4549
const notConnectedMessage =
4650
'You need to be connected to your wallet to have the ability to create a staking proposal'
51+
4752
const getProposalText = (amount) => {
48-
return `Convert ${amount} SOL to stSOL`
53+
return `Convert ${amount} SOL to JitoSOL`
4954
}
5055

51-
const LIDO_ADDRESS = '49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn'
52-
const STSOL_MINT = '7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj'
53-
54-
const LIDO_ADDRESS_DEVNET = '8sqs4Jzs8uq7CEtimhXf32gioVUN3n5Qk65YMkNU5E4F'
55-
const STSOL_MINT_DEVNET = '5nnLCgZn1EQaLj1ub8vYbQgBhkWi97x4JC5ARVPhci4V'
56-
57-
const ConvertToStSol = () => {
56+
const ConvertToJitoSol = () => {
5857
const realm = useRealmQuery().data?.result
5958
const { symbol } = useRealm()
6059
const { canUseTransferInstruction } = useGovernanceAssets()
6160
const { governedTokenAccounts } = useGovernanceAssets()
6261
const { fmtUrlWithCluster } = useQueryContext()
6362
const router = useRouter()
6463
const { handleCreateProposal } = useCreateProposal()
65-
6664
const connection = useLegacyConnectionContext()
6765
const wallet = useWalletOnePointOh()
6866
const currentAccount = useTreasuryAccountStore((s) => s.currentAccount)
6967

7068
const [formErrors, setFormErrors] = useState({})
71-
const [stSolTokenAccounts, setStSolTokenAccounts] = useState<AssetAccount[]>(
72-
[],
73-
)
7469
const [form, setForm] = useState<StakingViewForm>(defaultFormState)
7570
const [showOptions, setShowOptions] = useState(false)
7671
const { voteByCouncil, shouldShowVoteByCouncilToggle, setVoteByCouncil } =
7772
useVoteByCouncilToggle()
7873
const [isLoading, setIsLoading] = useState(false)
7974

75+
const jitoSolTokenAccounts = governedTokenAccounts.filter(
76+
(acc) =>
77+
acc.extensions.mint?.publicKey.toString() ===
78+
JITOSOL_MINT_ADDRESS.toString(),
79+
)
8080
const mintMinAmount = form.governedTokenAccount?.extensions?.mint
8181
? getMintMinAmountAsDecimal(
8282
form.governedTokenAccount.extensions.mint.account,
@@ -90,27 +90,15 @@ const ConvertToStSol = () => {
9090
}
9191

9292
const handlePropose = async () => {
93-
setIsLoading(true)
93+
if (currentAccount?.governance === undefined) throw new Error()
9494

95-
let config = {
96-
lidoAddress: new PublicKey(LIDO_ADDRESS),
97-
stSolMint: new PublicKey(STSOL_MINT),
98-
programId: new PublicKey(LIDO_PROGRAM_ID),
99-
}
100-
if (connection.cluster === 'devnet') {
101-
config = {
102-
lidoAddress: new PublicKey(LIDO_ADDRESS_DEVNET),
103-
stSolMint: new PublicKey(STSOL_MINT_DEVNET),
104-
programId: new PublicKey(LIDO_PROGRAM_ID_DEVNET),
105-
}
106-
}
107-
const instruction: UiInstruction = await getConvertToStSolInstruction({
95+
setIsLoading(true)
96+
const instruction: UiInstruction = await getConvertToJitoSolInstruction({
10897
schema,
10998
form,
11099
connection,
111100
wallet,
112101
setFormErrors,
113-
config,
114102
})
115103

116104
if (instruction.isValid) {
@@ -134,7 +122,7 @@ const ConvertToStSol = () => {
134122
const proposalAddress = await handleCreateProposal({
135123
title: form.title ? form.title : getProposalText(form.amount),
136124
description: form.description ? form.description : '',
137-
governance: currentAccount!.governance!,
125+
governance: currentAccount?.governance,
138126
instructionsData: [instructionData],
139127
voteByCouncil,
140128
isDraft: false,
@@ -158,25 +146,15 @@ const ConvertToStSol = () => {
158146
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree
159147
}, [currentAccount, form.destinationAccount])
160148

161-
useEffect(() => {
162-
const stSolMint =
163-
connection.cluster === 'devnet' ? STSOL_MINT_DEVNET : STSOL_MINT
164-
const stSolAccounts = governedTokenAccounts.filter((acc) => {
165-
return acc.extensions.mint?.publicKey.toString() === stSolMint
166-
})
167-
setStSolTokenAccounts(stSolAccounts)
168-
// eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree
169-
}, [connection.cluster])
170-
171149
return (
172150
<>
173-
<h3 className="mb-4 flex items-center">Convert SOL to stSOL</h3>
174-
<AccountLabel />
151+
<h3 className="mb-4 flex items-center">Convert SOL to JitoSOL</h3>
152+
<AccountLabel></AccountLabel>
175153
<div className="space-y-4 w-full pb-4">
176-
{stSolTokenAccounts.length > 0 && (
154+
{jitoSolTokenAccounts.length > 0 && (
177155
<GovernedAccountSelect
178-
label="stSOL Treasury account"
179-
governedAccounts={stSolTokenAccounts as AssetAccount[]}
156+
label="JitoSOL Treasury account"
157+
governedAccounts={jitoSolTokenAccounts as AssetAccount[]}
180158
shouldBeGoverned={false}
181159
governance={currentAccount?.governance}
182160
value={form.destinationAccount}
@@ -261,7 +239,7 @@ const ConvertToStSol = () => {
261239
propertyName: 'description',
262240
})
263241
}
264-
/>
242+
></Textarea>
265243
{shouldShowVoteByCouncilToggle && (
266244
<VoteBySwitch
267245
checked={voteByCouncil}
@@ -289,4 +267,4 @@ const ConvertToStSol = () => {
289267
)
290268
}
291269

292-
export default ConvertToStSol
270+
export default ConvertToJitoSol

components/treasuryV2/Details/TokenDetails/Investments.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { StrategyCard } from '@components/TreasuryAccount/AccountOverview'
1212
import DepositModal from 'Strategies/components/DepositModal'
1313
import Modal from '@components/Modal'
1414
import ConvertToMsol from '@components/TreasuryAccount/ConvertToMsol'
15-
import ConvertToStSol from '@components/TreasuryAccount/ConvertToStSol'
1615
import Trade from '@components/TreasuryAccount/Trade'
1716
import useTreasuryAccountStore from 'stores/useTreasuryAccountStore'
1817
import MangoModal from '@components/TreasuryAccount/MangoModal'
1918
import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext'
19+
import ConvertToJitoSol from '../../../TreasuryAccount/ConvertToJitoSol'
2020

2121
interface Props {
2222
className?: string
@@ -35,7 +35,7 @@ export default function Investments(props: Props) {
3535
useState<ActiveInvestment | null>(null)
3636

3737
const [alternativeInvestment, setAlternativeInvestment] = useState<
38-
'Marinade' | 'Lido' | 'Poseidon' | 'Mango' | null
38+
'Marinade' | 'Jito' | 'Poseidon' | 'Mango' | null
3939
>(null)
4040

4141
const investments = useAccountInvestments({
@@ -138,7 +138,7 @@ export default function Investments(props: Props) {
138138
onClick={() => {
139139
switch (investment.protocolName) {
140140
case 'Marinade':
141-
case 'Lido':
141+
case 'Jito':
142142
case 'Mango':
143143
case 'Poseidon': {
144144
setAlternativeInvestment(investment.protocolName)
@@ -206,13 +206,13 @@ export default function Investments(props: Props) {
206206
<ConvertToMsol />
207207
</Modal>
208208
)}
209-
{alternativeInvestment === 'Lido' && (
209+
{alternativeInvestment === 'Jito' && (
210210
<Modal
211211
isOpen
212212
sizeClassName="sm:max-w-3xl"
213213
onClose={() => setAlternativeInvestment(null)}
214214
>
215-
<ConvertToStSol />
215+
<ConvertToJitoSol />
216216
</Modal>
217217
)}
218218
{alternativeInvestment === 'Poseidon' && (

hooks/useAccountInvestments/staticInvestments.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export const getSolInvestments = () => [
1818
liquidity: 0,
1919
protocolSymbol: '',
2020
apy: '',
21-
protocolName: 'Lido',
21+
protocolName: 'Jito',
2222
handledMint: '',
2323
handledTokenSymbol: '',
2424
handledTokenImgSrc:
2525
'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',
2626
protocolLogoSrc:
27-
'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj/logo.png',
27+
'https://storage.googleapis.com/token-metadata/JitoSOL-256.png',
2828
strategyName: 'Stake',
2929
strategyDescription: '',
3030
createProposalFcn: () => null,
@@ -46,17 +46,4 @@ export const getTokenInvestments = (tokenImg: string) => [
4646
createProposalFcn: () => null,
4747
noProtocol: true,
4848
},
49-
{
50-
liquidity: 0,
51-
protocolSymbol: '',
52-
apy: '',
53-
protocolName: 'Mango',
54-
handledMint: '',
55-
handledTokenSymbol: '',
56-
handledTokenImgSrc: tokenImg,
57-
protocolLogoSrc: 'https://mango.markets/logos/logo-mark.svg',
58-
strategyName: 'Trade',
59-
strategyDescription: '',
60-
createProposalFcn: () => null,
61-
},
6249
]

0 commit comments

Comments
 (0)