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

retering multi #447

Closed
wants to merge 1 commit into from
Closed
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
167 changes: 167 additions & 0 deletions components/modals/DashboardSuggestedValuesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,172 @@ const DashboardSuggestedValues = ({
setForcePythOracle(bank?.oracleProvider === OracleProvider.Pyth)
}, [bank.oracleProvider])

const proposeChanges = async () => {
const toRetier = [
{ name: 'RLB', tier: 'D' },
{ name: 'stSOL', tier: 'D' },
{ name: 'LDO', tier: 'D' },
{ name: 'EURC', tier: 'D' },
{ name: 'NEON', tier: 'D' },
{ name: 'RAY', tier: 'AA' },
{ name: 'W', tier: 'AA' },
{ name: 'PYTH', tier: 'AA' },
{ name: 'MEW', tier: 'AA' },
{ name: 'BONK', tier: 'AAA' },
{ name: 'ETH (Portal)', tier: 'AAA' },
{ name: 'WIF', tier: 'AAA' },
{ name: 'wBTC (Portal)', tier: 'AAA' },
{ name: 'TBTC', tier: 'AAA' },
{ name: 'BLZE', tier: 'C' },
{ name: 'GOFX', tier: 'C' },
{ name: 'SOL', tier: 'S' },
{ name: 'JitoSOL', tier: 'S' },
{ name: 'USDT', tier: 'S' },
{ name: 'MSOL', tier: 'S' },
{ name: 'USDC', tier: 'S' },
{ name: 'JLP', tier: 'S' },
{ name: 'bSOL', tier: 'S' },
{ name: 'INF', tier: 'S' },
{ name: 'ZEUS', tier: 'A' },
{ name: 'JSOL', tier: 'A' },
{ name: 'POPCAT', tier: 'A' },
{ name: 'DAI', tier: 'A' },
{ name: 'DRIFT', tier: 'AA' },
{ name: 'MOTHER', tier: 'AA' },
{ name: 'USDY', tier: 'AA' },
{ name: 'hubSOL', tier: 'AAA' },
{ name: 'dualSOL', tier: 'AAA' },
{ name: 'digitSOL', tier: 'AAA' },
{ name: 'mangoSOL', tier: 'AAA' },
{ name: 'compassSOL', tier: 'AAA' },
{ name: 'stepSOL', tier: 'AAA' },
{ name: 'Moutai', tier: 'C' },
{ name: 'DUAL', tier: 'C' },
{ name: 'META', tier: 'C' },
{ name: 'GUAC', tier: 'C' },
{ name: 'CORN', tier: 'C' },
{ name: 'USDH', tier: 'C' },
{ name: 'SLCL', tier: 'C' },
{ name: 'MNGO', tier: 'C' },
{ name: 'GECKO', tier: 'C' },
{ name: 'ELON', tier: 'C' },
{ name: 'GME', tier: 'C' },
{ name: 'BILLY', tier: 'C' },
{ name: 'DEAN', tier: 'C' },
{ name: 'LNGCAT', tier: 'C' },
{ name: 'OPOS', tier: 'D' },
{ name: 'CROWN', tier: 'D' },
{ name: 'ALL-OLD', tier: 'D' },
{ name: 'KIN', tier: 'D' },
{ name: 'CHAI', tier: 'S' },
]
console.log(toRetier.length)
const proposalTx = []
for (const token of toRetier) {
const bank = group!.banksMapByName.get(token.name)
if (!bank) {
console.log('no token')
throw 'noo token'
}
const mintInfo = group!.mintInfosMapByMint.get(bank[0].mint.toBase58())!
if (!mintInfo) {
console.log('no mint info')
throw 'no mintinfo'
}

const ix = await client!.program.methods
.tokenEdit(
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
false,
false,
null,
null,
null,
null,
null,
null,
//do not edit of interest curve scaling
null,
null,
null,
null,
null,
null,
false,
false,
null,
null,
null,
null,
null,
null,
token.tier,
)
.accounts({
group: group!.publicKey,
fallbackOracle: PublicKey.default,
oracle: bank[0]!.oracle!,
admin: MANGO_DAO_WALLET,
mintInfo: mintInfo.publicKey,
})
.remainingAccounts([
{
pubkey: bank[0].publicKey!,
isWritable: true,
isSigner: false,
} as AccountMeta,
])
.instruction()
proposalTx.push(ix)
}
try {
const walletSigner = wallet as never

const index = proposals ? Object.values(proposals).length : 0
const proposalAddress = await createProposal(
connection,
client,
walletSigner,
MANGO_DAO_WALLET_GOVERNANCE,
voter.tokenOwnerRecord!,
`Edit tokens tier params`,
'',
index,
proposalTx,
vsrClient!,
fee,
)
window.open(
`https://dao.mango.markets/dao/MNGO/proposal/${proposalAddress.toBase58()}`,
'_blank',
)
} catch (e) {
notify({
title: 'Error during proposal creation',
description: `${e}`,
type: 'error',
})
}
}

const proposeNewSuggestedValues = useCallback(
async (
bank: Bank,
Expand Down Expand Up @@ -679,6 +845,7 @@ const DashboardSuggestedValues = ({
>
{proposing ? <Loading></Loading> : 'Propose new suggested values'}
</Button>
<Button onClick={proposeChanges}>proposeChanges</Button>
</div>
)}
</div>
Expand Down
45 changes: 34 additions & 11 deletions utils/governance/instructions/createProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import {
MangoClient,
} from '@blockworks-foundation/mango-v4'
import { sendTxAndConfirm } from '../tools'
import {
SequenceType,
TransactionInstructionWithSigners,
} from '@blockworks-foundation/mangolana/lib/globalTypes'
import {
sendSignAndConfirmTransactions,
TransactionInstructionWithType,
} from '@blockworks-foundation/mangolana/lib/transactions'

export const createProposal = async (
connection: Connection,
Expand Down Expand Up @@ -139,20 +147,35 @@ export const createProposal = async (
undefined,
)

const txChunks = chunk([...instructions, ...insertInstructions], 2)

const transactions: Transaction[] = []
const latestBlockhash = await connection.getLatestBlockhash('processed')

for (const chunk of txChunks) {
const tx = new Transaction()
tx.add(createComputeBudgetIx(fee))
tx.add(...chunk)
tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight
tx.recentBlockhash = latestBlockhash.blockhash
tx.feePayer = payer
transactions.push(tx)
}
const transactionInstructions: TransactionInstructionWithType[] = []
chunk([...instructions, ...insertInstructions], 2).map((chunkInstructions) =>
transactionInstructions.push({
instructionsSet: [
new TransactionInstructionWithSigners(createComputeBudgetIx(80000)),
...chunkInstructions.map(
(inst) => new TransactionInstructionWithSigners(inst),
),
],
sequenceType: SequenceType.Sequential,
}),
)

await sendSignAndConfirmTransactions({
connection,
wallet: wallet,
backupConnections: [],
transactionInstructions: transactionInstructions,
config: {
maxTxesInBatch: 10,
maxRetries: 3,
autoRetry: true,
logFlowInfo: true,
useVersionedTransactions: true,
},
})
const signedTransactions = await wallet.signAllTransactions(transactions)
for (const tx of signedTransactions) {
await sendTxAndConfirm(
Expand Down
7 changes: 5 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10826,14 +10826,14 @@ node-addon-api@^7.0.0:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-7.1.0.tgz#71f609369379c08e251c558527a107107b5e0fdb"
integrity sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==

node-fetch@3.3.2, "node-fetch@npm:@blockworks-foundation/node-fetch@2.6.11":
node-fetch@3.3.2, node-fetch@^2.6.12, node-fetch@^2.7.0, "node-fetch@npm:@blockworks-foundation/node-fetch@2.6.11":
version "2.6.11"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/node-fetch/-/node-fetch-2.6.11.tgz#fb536ef0e6a960e7b7993f3c1d3b3bba9bdfbc56"
integrity sha512-HeDTxpIypSR4qCoqgUXGr8YL4OG1z7BbV4VhQ9iQs+pt2wV3MtqO+sQk2vXK3WDKu5C6BsbGmWE22BmIrcuOOw==
dependencies:
whatwg-url "^5.0.0"

node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7, node-fetch@^2.7.0:
node-fetch@^2.6.1, node-fetch@^2.6.7:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
Expand Down Expand Up @@ -12764,6 +12764,7 @@ string-length@^4.0.1:
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
name string-width-cjs
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -12884,6 +12885,7 @@ stringify-entities@^4.0.0:
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -14340,6 +14342,7 @@ word-wrap@^1.2.5:
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down
Loading