Skip to content

Commit 3dbaaf6

Browse files
committed
Sync with mythic-project Sept 25
1 parent 868fb21 commit 3dbaaf6

29 files changed

Lines changed: 298 additions & 269 deletions

File tree

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--add.exact true
22
ignore-scripts true
3+
--frozen-lockfile true

Strategies/protocols/solend/index.ts

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { SolendStrategy } from 'Strategies/types/types'
3232
import { VotingClient } from '@utils/uiTypes/VotePlugin'
3333
import { AssetAccount } from '@utils/uiTypes/assets'
3434
import { ConnectionContext } from '@utils/connection'
35-
import { MAIN_POOL_CONFIGS, RESERVE_CONFIG } from '@hub/providers/Defi/plans/save'
35+
import { Config, ReserveConfig } from '@hub/providers/Defi/plans/save'
3636

3737
const MAINNET_PROGRAM = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
3838
const DEVNET_PROGRAM = 'ALend7Ketfx5bxh6ghsCDXAoDrhvEmsXT3cynB6aPLgx'
@@ -65,38 +65,6 @@ export type CreateSolendStrategyParams = (
6565
client?: VotingClient,
6666
) => Promise<PublicKey>
6767

68-
type Config = Array<MarketConfig>
69-
70-
type MarketConfig = {
71-
name: string
72-
isPrimary: boolean
73-
description: string
74-
creator: string
75-
address: string
76-
authorityAddress: string
77-
reserves: Array<ReserveConfig>
78-
}
79-
80-
type ReserveConfig = {
81-
liquidityToken: {
82-
coingeckoID: string
83-
decimals: number
84-
logo: string
85-
mint: string
86-
name: string
87-
symbol: string
88-
volume24h: number
89-
}
90-
pythOracle: string
91-
switchboardOracle: string
92-
address: string
93-
collateralMintAddress: string
94-
collateralSupplyAddress: string
95-
liquidityAddress: string
96-
liquidityFeeReceiverAddress: string
97-
userSupplyCap: number
98-
}
99-
10068
type ReserveStat = {
10169
reserve: {
10270
lendingMarket: string
@@ -173,13 +141,13 @@ export function cTokenExchangeRate(reserve: ReserveStat) {
173141
.toNumber()
174142
}
175143

176-
export async function getReserve(): Promise<Config> {
144+
export async function getReserve(): Promise<Config[]> {
177145
return await (
178146
await axios.get(`${SOLEND_ENDPOINT}/v1/markets/configs?scope=all`)
179147
).data
180148
}
181149

182-
export async function getReserves(): Promise<Config[0]['reserves']> {
150+
export async function getReserves(): Promise<ReserveConfig[]> {
183151
const config = await getReserve()
184152
const reserves = config.flatMap((market) =>
185153
market.reserves.map((reserve) => ({
@@ -526,37 +494,57 @@ export async function handleSolendActionV2(
526494
proposalIndex: number,
527495
isDraft: boolean,
528496
connection: ConnectionContext,
529-
client?: VotingClient
497+
config: Config,
498+
reserveConfig: ReserveConfig,
499+
client?: VotingClient,
530500
) {
531501
const isSol = matchedTreasury.isSol
532502
const owner = isSol
533503
? matchedTreasury!.pubkey
534504
: matchedTreasury!.extensions!.token!.account.owner
535505

536506
const solendAction = form.action === 'Deposit' ? await SolendActionCore.buildDepositReserveLiquidityTxns(
537-
MAIN_POOL_CONFIGS,
538-
RESERVE_CONFIG[form.reserveAddress],
507+
config,
508+
{
509+
address: reserveConfig.address,
510+
liquidityAddress: reserveConfig.liquidityAddress,
511+
cTokenMint: reserveConfig.collateralMintAddress,
512+
cTokenLiquidityAddress: reserveConfig.liquidityAddress,
513+
pythOracle: reserveConfig.pythOracle,
514+
switchboardOracle: reserveConfig.switchboardOracle,
515+
mintAddress: reserveConfig.liquidityToken.mint,
516+
liquidityFeeReceiverAddress: reserveConfig.liquidityFeeReceiverAddress,
517+
},
539518
connection.current,
540519
form.bnAmount.toString(),
541520
{
542521
publicKey: owner,
543522
},
544523
{
545-
lookupTableAddress: MAIN_POOL_CONFIGS.lookupTableAddress
546-
? new PublicKey(MAIN_POOL_CONFIGS.lookupTableAddress)
524+
lookupTableAddress: config?.lookupTableAddress
525+
? new PublicKey(config.lookupTableAddress)
547526
: undefined,
548527
},
549528
) : await SolendActionCore.buildRedeemReserveCollateralTxns(
550-
MAIN_POOL_CONFIGS,
551-
RESERVE_CONFIG[form.reserveAddress],
529+
config,
530+
{
531+
address: reserveConfig.address,
532+
liquidityAddress: reserveConfig.liquidityAddress,
533+
cTokenMint: reserveConfig.collateralMintAddress,
534+
cTokenLiquidityAddress: reserveConfig.liquidityAddress,
535+
pythOracle: reserveConfig.pythOracle,
536+
switchboardOracle: reserveConfig.switchboardOracle,
537+
mintAddress: reserveConfig.liquidityToken.mint,
538+
liquidityFeeReceiverAddress: reserveConfig.liquidityFeeReceiverAddress,
539+
},
552540
connection.current,
553541
form.bnAmount.toString(),
554542
{
555543
publicKey: owner,
556544
},
557545
{
558-
lookupTableAddress: MAIN_POOL_CONFIGS.lookupTableAddress
559-
? new PublicKey(MAIN_POOL_CONFIGS.lookupTableAddress)
546+
lookupTableAddress: config.lookupTableAddress
547+
? new PublicKey(config.lookupTableAddress)
560548
: undefined,
561549
},
562550
);
@@ -586,7 +574,7 @@ export async function handleSolendActionV2(
586574
form.title ||
587575
`${form.action} ${form.amountFmt} ${
588576
tokenPriceService.getTokenInfo(
589-
RESERVE_CONFIG[form.reserveAddress].mintAddress
577+
reserveConfig.liquidityToken.mint
590578
)?.symbol || 'tokens'
591579
} ${form.action === 'Deposit' ? 'into' : 'from'} Save`,
592580
form.description,

VoteStakeRegistry/sdk/withCreateNewDeposit.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ export const withCreateNewDeposit = async ({
6767
clientProgramId,
6868
)
6969
const existingVoter = await tryGetVoter(voter, client)
70-
const mintInfo = await client.program.provider.connection.getAccountInfo(mintPk)
71-
const tokenProgram = mintInfo?.owner.equals(TOKEN_2022_PROGRAM_ID) ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID
70+
const mintInfo =
71+
await client.program.provider.connection.getAccountInfo(mintPk)
72+
const tokenProgram = mintInfo?.owner.equals(TOKEN_2022_PROGRAM_ID)
73+
? TOKEN_2022_PROGRAM_ID
74+
: TOKEN_PROGRAM_ID
7275

7376
const voterATAPk = await Token.getAssociatedTokenAddress(
7477
ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -159,6 +162,6 @@ export const withCreateNewDeposit = async ({
159162
voter,
160163
tokenOwnerRecordPubKey,
161164
voterWeightPk,
162-
tokenProgram
165+
tokenProgram,
163166
}
164167
}

actions/castVote.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Connection,
33
Keypair,
44
PublicKey,
5+
SystemProgram,
56
TransactionInstruction,
67
} from '@solana/web3.js'
78
import {
@@ -46,6 +47,8 @@ import { postComment } from './chat/postMessage'
4647
import { withPostChatMessageEphSigner } from '@utils/ephemeral-signers/postMessageWithEphSigner'
4748
import { getEphemeralSigners } from '@utils/ephemeral-signers'
4849
import { Wallet } from '@solana/wallet-adapter-react'
50+
import { FEE_WALLET } from '@utils/orders'
51+
import { VOTER_ACCOUNT_FEE } from '@tools/constants'
4952

5053
const getVetoTokenMint = (
5154
proposal: ProgramAccount<Proposal>,
@@ -156,6 +159,13 @@ const createTokenOwnerRecordIfNeeded = async ({
156159
governingTokenMint,
157160
payer,
158161
)
162+
ixs.push(
163+
SystemProgram.transfer({
164+
fromPubkey: payer!,
165+
toPubkey: FEE_WALLET,
166+
lamports: VOTER_ACCOUNT_FEE,
167+
}),
168+
)
159169
return ixs
160170
}
161171

@@ -239,7 +249,14 @@ export async function castVote(
239249
const castVoteIxs: TransactionInstruction[] = []
240250
const pluginCastVoteIxs: TransactionInstruction[] = []
241251

242-
if (calculatedVoterWeight !== null && calculatedVoterWeight.gtn(0)) {
252+
const isPyth = realm.owner.equals(
253+
new PublicKey('pytGY6tWRgGinSCvRLnSv4fHfBTMoiDGiCsesmHWM6U'),
254+
)
255+
256+
if (
257+
isPyth ||
258+
(calculatedVoterWeight !== null && calculatedVoterWeight.gtn(0))
259+
) {
243260
//will run only if any plugin is connected with realm
244261
const plugin = await votingPlugin?.withCastPluginVote(
245262
pluginCastVoteIxs,

actions/createMultisigWallet.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ export default async function createMultisigWallet({
4040
...params,
4141
})
4242
const solBalance = await connection.getBalance(wallet.publicKey!)
43-
if (lamportsToSol(new BN(solBalance)) < 0.25) {
44-
throw new Error('You need to have at least 0.25 SOL to create a realm')
43+
if (lamportsToSol(new BN(solBalance)) < 1.05) {
44+
throw new Error('You need to have at least 1.05 SOL to create a realm')
4545
}
4646

4747
try {
4848
const councilMembersChunks = chunks(councilMembersInstructions, 8)
4949

5050
const allSigners = [...mintsSetupSigners, ...realmSigners]
5151

52-
const cuLimtIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000})
52+
const cuLimtIx = ComputeBudgetProgram.setComputeUnitLimit({
53+
units: 800_000,
54+
})
5355
realmInstructions.unshift(cuLimtIx)
5456

5557
const txes = [
@@ -60,7 +62,7 @@ export default async function createMultisigWallet({
6062
SystemProgram.transfer({
6163
fromPubkey: wallet.publicKey!,
6264
toPubkey: FEE_WALLET,
63-
lamports: solToLamports(0.2).toNumber(),
65+
lamports: solToLamports(2).toNumber(),
6466
}),
6567
],
6668
].map((txBatch) => {

actions/createNFTRealm.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ export default async function createNFTRealm({
7676
wallet,
7777
})
7878
const solBalance = await connection.getBalance(wallet.publicKey!)
79-
if (lamportsToSol(new BN(solBalance)) < 0.25) {
80-
throw new Error('You need to have at least 0.25 SOL to create a realm')
79+
if (lamportsToSol(new BN(solBalance)) < 1.05) {
80+
throw new Error('You need to have at least 1.05 SOL to create a realm')
8181
}
8282

8383
console.log('NFT REALM realm public-key', realmPk.toBase58())
@@ -214,7 +214,9 @@ export default async function createNFTRealm({
214214
nftSigners,
215215
]
216216

217-
const cuLimtIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 800_000})
217+
const cuLimtIx = ComputeBudgetProgram.setComputeUnitLimit({
218+
units: 800_000,
219+
})
218220
realmInstructions.unshift(cuLimtIx)
219221

220222
const txes = [
@@ -226,7 +228,7 @@ export default async function createNFTRealm({
226228
SystemProgram.transfer({
227229
fromPubkey: wallet.publicKey!,
228230
toPubkey: FEE_WALLET,
229-
lamports: solToLamports(0.2).toNumber(),
231+
lamports: solToLamports(2).toNumber(),
230232
}),
231233
],
232234
].map((txBatch, batchIdx) => {

actions/createTokenizedRealm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export default async function createTokenizedRealm({
9292
})
9393

9494
const solBalance = await connection.getBalance(wallet.publicKey!)
95-
if (lamportsToSol(new BN(solBalance)) < 0.25) {
96-
throw new Error('You need to have at least 0.25 SOL to create a realm')
95+
if (lamportsToSol(new BN(solBalance)) < 1.05) {
96+
throw new Error('You need to have at least 1.05 SOL to create a realm')
9797
}
9898

9999
try {
@@ -195,7 +195,7 @@ export default async function createTokenizedRealm({
195195
SystemProgram.transfer({
196196
fromPubkey: walletPk,
197197
toPubkey: FEE_WALLET,
198-
lamports: solToLamports(0.2).toNumber(),
198+
lamports: solToLamports(2).toNumber(),
199199
}),
200200
],
201201
].map((ixBatch, batchIdx) => ({

components/App.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,17 @@ export function AppContents(props: Props) {
326326
<ErrorBoundary>
327327
<ThemeProvider defaultTheme="Dark">
328328
<GatewayProvider>
329+
<div className="relative color-white z-10 text-center w-full py-2">
330+
Faster. Sharper. More. Yours.{' '}
331+
<a
332+
href="https://v2.realms.today"
333+
rel="noreferrer"
334+
target="_blank"
335+
className="underline"
336+
>
337+
Try Realms v2
338+
</a>
339+
</div>
329340
<Telemetry></Telemetry>
330341
<NavBar />
331342
<Notifications />

components/GovernancePower/Power/Vanilla/useDepositCallback.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import { useCallback } from 'react'
22
import useWalletOnePointOh from '@hooks/useWalletOnePointOh'
33
import { fetchRealmByPubkey } from '@hooks/queries/realm'
44
import { useConnection } from '@solana/wallet-adapter-react'
5-
import { Keypair, TransactionInstruction } from '@solana/web3.js'
5+
import { Keypair, SystemProgram, TransactionInstruction } from '@solana/web3.js'
66
import { approveTokenTransfer } from '@utils/tokens'
77
import useSelectedRealmPubkey from '@hooks/selectedRealm/useSelectedRealmPubkey'
8-
import { withDepositGoverningTokens } from '@solana/spl-governance'
8+
import {
9+
getTokenOwnerRecordAddress,
10+
withDepositGoverningTokens,
11+
} from '@solana/spl-governance'
912
import {
1013
ASSOCIATED_TOKEN_PROGRAM_ID,
1114
Token,
@@ -16,6 +19,8 @@ import { fetchProgramVersion } from '@hooks/queries/useProgramVersionQuery'
1619
import queryClient from '@hooks/queries/queryClient'
1720
import { useJoinRealm } from '@hooks/useJoinRealm'
1821
import { SequenceType, sendTransactionsV3 } from '@utils/sendTransactions'
22+
import { FEE_WALLET } from '@utils/orders'
23+
import { VOTER_ACCOUNT_FEE } from '@tools/constants'
1924

2025
export const useDepositCallback = (
2126
role: 'community' | 'council' | 'undefined',

components/Members/AddMemberForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ const AddMemberForm: FC<{ close: () => void; mintAccount: AssetAccount }> = ({
280280
})
281281

282282
const url = fmtUrlWithCluster(
283-
`/dao/${symbol}/proposal/${proposalAddress}`,
283+
`https://v2.realms.today/dao/${symbol}/proposal/${proposalAddress}?share=true`,
284284
)
285285

286286
router.push(url)

0 commit comments

Comments
 (0)