Skip to content

Commit

Permalink
Add instructions for raising proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
metaproph3t committed Dec 28, 2023
1 parent 96fdcb6 commit 5c759a0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 56 deletions.
1 change: 1 addition & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ autocrat_v0 = "yarn run ts-node scripts/autocratV0.ts"
clob = "yarn run tsc scripts/clob.ts --esModuleInterop --resolveJsonModule && node scripts/clob.js && rm scripts/clob.js"
crank = "yarn run ts-node scripts/crank.ts"
main = "yarn run ts-node scripts/main.ts"
propose = "yarn run ts-node scripts/initializeProposal.ts"
initialize_vault = "yarn run tsc scripts/initializeVault.ts --esModuleInterop --resolveJsonModule && node scripts/initializeVault.js"
place_order = "yarn run ts-node scripts/placeOrder.ts"
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/*.ts"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
Monorepo that houses the Meta-DAO's programs. A description of these programs
and what they do can be found at [themetadao.org](https://themetadao.org).

## Scripts

The scripts folder contains a few scripts that you can use to interact with the Meta-DAO.
Today, the only way to create proposals is via script. You can do this by modifying the
`initializeProposal.ts` script and replacing its `pubkey`, `accounts`, and `data` with the
SVM instruction that you want to use in your proposal.

Then, run `anchor run propose --provider.cluster CLUSTER`, where `CLUSTER` is replaced with
either devnet, mainnet, or (recommended) an RPC URL.

## Deployments

| program | tag | program ID |
Expand Down
35 changes: 35 additions & 0 deletions scripts/initializeProposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { initializeProposal } from "./main";
import * as anchor from "@coral-xyz/anchor";
import { MEMO_PROGRAM_ID } from "@solana/spl-memo";

const { PublicKey, Keypair, SystemProgram } = anchor.web3;
const { BN, Program } = anchor;

async function main() {
const memoText =
"I, glorious autocrat of the divine Meta-DAO, " +
"sanction the creation of this Saber vote market platform.\n\n" +
"That I shall bestow lavish rewards upon those who contribute to its creation is guaranteed. " +
"Remember that my word is not the word of a man but the word of a market.\n\n" +
"Godspeed, futards!";

const memoInstruction = {
programId: new PublicKey(MEMO_PROGRAM_ID),
data: Buffer.from(memoText),
accounts: [],
};

// accounts should be an array of objects that look like
// {
// pubkey: new PublicKey(MEMO_PROGRAM_ID),
// isWritable: false,
// isSigner: false,
// }

await initializeProposal(
memoInstruction,
"https://hackmd.io/@jlPYU3_dTOuQkU5duRNUlg/rkhWWXjLp"
);
}

main();
63 changes: 7 additions & 56 deletions scripts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const AutocratMigratorIDL: AutocratMigrator = require("../target/idl/autocrat_mi
const AUTOCRAT_PROGRAM_ID = new PublicKey(
"metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq"
);
// const AUTOCRAT_PROGRAM_ID = new PublicKey(
// "meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi"
// );
const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey(
"vaU1tVLj8RFk7mNj1BxqgAsMKKaL8UvEUHvU3tdbZPe"
);
Expand Down Expand Up @@ -88,12 +85,12 @@ export const migrator = new anchor.Program<AutocratMigrator>(
provider
);

const [dao] = PublicKey.findProgramAddressSync(
export const [dao] = PublicKey.findProgramAddressSync(
[anchor.utils.bytes.utf8.encode("WWCACOTMICMIBMHAFTTWYGHMB")],
autocratProgram.programId
);

const [daoTreasury] = PublicKey.findProgramAddressSync(
export const [daoTreasury] = PublicKey.findProgramAddressSync(
[dao.toBuffer()],
autocratProgram.programId
);
Expand Down Expand Up @@ -262,7 +259,10 @@ async function initializeDAO(META: any, USDC: any) {
// console.log("Proposal finalized", tx);
// }

async function initializeProposal(instruction: any, proposalURL: string) {
export async function initializeProposal(
instruction: any,
proposalURL: string
) {
const proposalKeypair = Keypair.generate();

const storedDAO = await autocratProgram.account.dao.fetch(dao);
Expand All @@ -277,7 +277,7 @@ async function initializeProposal(instruction: any, proposalURL: string) {

const quoteVault = await initializeVault(
daoTreasury,
USDC,
DEVNET_USDC,
baseNonce.or(new BN(1).shln(63))
);

Expand All @@ -296,7 +296,6 @@ async function initializeProposal(instruction: any, proposalURL: string) {
).conditionalOnRevertTokenMint;

let openbookPassMarketKP = Keypair.generate();
console.log(openbookPassMarketKP);

let [openbookTwapPassMarket] = PublicKey.findProgramAddressSync(
[
Expand Down Expand Up @@ -335,7 +334,6 @@ async function initializeProposal(instruction: any, proposalURL: string) {
.rpc();

let openbookFailMarketKP = Keypair.generate();
console.log(openbookFailMarketKP);

let [openbookTwapFailMarket] = PublicKey.findProgramAddressSync(
[
Expand Down Expand Up @@ -624,50 +622,3 @@ async function getOrCreateAccount(mint: anchor.web3.PublicKey) {
)
).address;
}

async function main() {
// await initializeProposal();
// let proposal = (await autocratProgram.account.proposal.all())[0];

// console.log(proposal.publicKey)
// console.log(newDaoTreasury)
// console.log(await newAutocratProgram.account.dao.fetch(newDao));

const memoText =
"I, glorious autocrat of the divine Meta-DAO, " +
"sanction the creation of this Saber vote market platform.\n\n" +
"That I shall bestow lavish rewards upon those who contribute to its creation is guaranteed. " +
"Remember that my word is not the word of a man but the word of a market.\n\n" +
"Godspeed, futards!";

const memoInstruction = {
programId: new PublicKey(MEMO_PROGRAM_ID),
data: Buffer.from(memoText),
accounts: [],
};

await initializeProposal(
memoInstruction,
"https://hackmd.io/@jlPYU3_dTOuQkU5duRNUlg/rkhWWXjLp"
);

// Create a transaction and add the memo instruction
// const transaction = new anchor.web3.Transaction();
// transaction.add(memoInstruction);

// Send the transaction
// const signature = await anchor.web3.sendAndConfirmTransaction(
// provider.connection,
// transaction,
// [payer] // The account that will sign the transaction
// );

// console.log(`Transaction sent with signature: ${signature}`);

// await finalizeProposal(proposal.publicKey)

// console.log(await openbookTwap.account.twapMarket.fetch(proposal.openbookTwapPassMarket));
// console.log(await openbookTwap.account.twapMarket.fetch(proposal.openbookTwapPassMarket));
}

main();

0 comments on commit 5c759a0

Please sign in to comment.