From b74a57e313431728a84e47c02286579d1d36ed36 Mon Sep 17 00:00:00 2001 From: raghav-rama Date: Sun, 15 Dec 2024 18:35:09 +0530 Subject: [PATCH] fix: cycle numbers --- .../controllers/initializePools.controller.js | 86 ++++++--------- .../initializePools.controller.js.map | 2 +- .../src/controllers/mintOptions.controller.js | 103 +++++++++--------- .../controllers/mintOptions.controller.js.map | 2 +- dist/src/routes/mintOptions.route.js | 2 - dist/src/routes/mintOptions.route.js.map | 2 +- dist/src/types/euro_primitive.js.map | 2 +- dist/src/types/option_auction.js.map | 2 +- dist/src/types/vaults.js.map | 2 +- dist/src/utils/index.js | 13 +++ dist/src/utils/index.js.map | 2 +- dist/src/utils/pdas.js | 11 +- dist/src/utils/pdas.js.map | 2 +- dist/src/utils/programUtils.js | 6 + dist/src/utils/programUtils.js.map | 2 +- src/controllers/mintOptions.controller.ts | 8 +- 16 files changed, 127 insertions(+), 120 deletions(-) diff --git a/dist/src/controllers/initializePools.controller.js b/dist/src/controllers/initializePools.controller.js index 42298dd..a3b9e1a 100644 --- a/dist/src/controllers/initializePools.controller.js +++ b/dist/src/controllers/initializePools.controller.js @@ -1,65 +1,47 @@ import { getProgram } from '../utils/programUtils'; import Config from '../config'; import * as anchor from '@coral-xyz/anchor'; -import { - getUnderlyingPoolPda, - getQuotePoolPda, - getPoolAuthorityPda, -} from '../utils/pdas'; +import { getUnderlyingPoolPda, getQuotePoolPda, getPoolAuthorityPda } from '../utils/pdas'; import { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token'; export async function getInitializePools(_req, res) { - const provider = anchor.AnchorProvider.env(); - anchor.setProvider(provider); - const program = await getProgram(provider); - await initializePools( - Config.TESTNET_SOL_MINT, - Config.TESTNET_QUOTE_MINT, - provider, - program, - ); - res.status(200).json({ - message: 'Initialize pools', - }); + const provider = anchor.AnchorProvider.env(); + anchor.setProvider(provider); + const program = await getProgram(provider); + await initializePools(Config.TESTNET_WETH_MINT, Config.TESTNET_QUOTE_MINT, provider, program); + res.status(200).json({ + message: 'Initialize pools' + }); } -export async function initializePools( - underlyingMint, - quoteMint, - provider, - program, -) { - const [underlyingPool] = getUnderlyingPoolPda(underlyingMint); - const [quotePool] = getQuotePoolPda(quoteMint); - const [poolAuthority] = getPoolAuthorityPda(); - { - const txHash = await program.methods - .initializeStablePool() - .accounts({ +export async function initializePools(underlyingMint, quoteMint, provider, program) { + const [underlyingPool] = getUnderlyingPoolPda(underlyingMint); + const [quotePool] = getQuotePoolPda(quoteMint); + const [poolAuthority] = getPoolAuthorityPda(); + { + const txHash = await program.methods.initializeStablePool().accounts({ + payer: provider.publicKey, + stableMint: quoteMint, + stablePool: quotePool, + poolAuthority, + tokenProgram: TOKEN_PROGRAM_ID, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + systemProgram: anchor.web3.SystemProgram.programId + }).signers([ + Config.ADMIN_KEYPAIR + ]).rpc(); + console.log(`Transaction completed successfully: ${txHash}`); + } + const txHash = await program.methods.initializeUnderlyingPool().accounts({ payer: provider.publicKey, - stableMint: quoteMint, - stablePool: quotePool, + underlyingMint, + underlyingPool, poolAuthority, tokenProgram: TOKEN_PROGRAM_ID, rent: anchor.web3.SYSVAR_RENT_PUBKEY, - systemProgram: anchor.web3.SystemProgram.programId, - }) - .signers([Config.ADMIN_KEYPAIR]) - .rpc(); + systemProgram: anchor.web3.SystemProgram.programId + }).signers([ + Config.ADMIN_KEYPAIR + ]).rpc(); console.log(`Transaction completed successfully: ${txHash}`); - } - const txHash = await program.methods - .initializeUnderlyingPool() - .accounts({ - payer: provider.publicKey, - underlyingMint, - underlyingPool, - poolAuthority, - tokenProgram: TOKEN_PROGRAM_ID, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, - systemProgram: anchor.web3.SystemProgram.programId, - }) - .signers([Config.ADMIN_KEYPAIR]) - .rpc(); - console.log(`Transaction completed successfully: ${txHash}`); } -//# sourceMappingURL=initializePools.controller.js.map +//# sourceMappingURL=initializePools.controller.js.map \ No newline at end of file diff --git a/dist/src/controllers/initializePools.controller.js.map b/dist/src/controllers/initializePools.controller.js.map index ebc3b1a..2431117 100644 --- a/dist/src/controllers/initializePools.controller.js.map +++ b/dist/src/controllers/initializePools.controller.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/controllers/initializePools.controller.ts"],"sourcesContent":["import { getProgram } from '@/utils/programUtils';\nimport Config from '@/config';\nimport * as anchor from '@coral-xyz/anchor';\nimport { PublicKey } from '@solana/web3.js';\nimport { Request, Response } from 'express';\nimport { EuroPrimitive } from '@/types/euro_primitive';\nimport {\n getUnderlyingPoolPda,\n getQuotePoolPda,\n getPoolAuthorityPda,\n} from '@/utils/pdas';\nimport { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token';\n\nexport async function getInitializePools(_req: Request, res: Response) {\n const provider = anchor.AnchorProvider.env();\n anchor.setProvider(provider);\n const program = await getProgram(provider);\n await initializePools(\n Config.TESTNET_SOL_MINT,\n Config.TESTNET_QUOTE_MINT,\n provider,\n program,\n );\n res.status(200).json({\n message: 'Initialize pools',\n });\n}\n\nexport async function initializePools(\n underlyingMint: PublicKey,\n quoteMint: PublicKey,\n provider: anchor.AnchorProvider,\n program: anchor.Program,\n) {\n const [underlyingPool] = getUnderlyingPoolPda(underlyingMint);\n const [quotePool] = getQuotePoolPda(quoteMint);\n const [poolAuthority] = getPoolAuthorityPda();\n {\n const txHash = await program.methods\n .initializeStablePool()\n .accounts({\n payer: provider.publicKey,\n stableMint: quoteMint,\n stablePool: quotePool,\n poolAuthority,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .rpc();\n console.log(`Transaction completed successfully: ${txHash}`);\n }\n const txHash = await program.methods\n .initializeUnderlyingPool()\n .accounts({\n payer: provider.publicKey,\n underlyingMint,\n underlyingPool,\n poolAuthority,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .rpc();\n console.log(`Transaction completed successfully: ${txHash}`);\n}\n"],"names":["getProgram","Config","anchor","getUnderlyingPoolPda","getQuotePoolPda","getPoolAuthorityPda","TOKEN_PROGRAM_ID","getInitializePools","_req","res","provider","AnchorProvider","env","setProvider","program","initializePools","TESTNET_SOL_MINT","TESTNET_QUOTE_MINT","status","json","message","underlyingMint","quoteMint","underlyingPool","quotePool","poolAuthority","txHash","methods","initializeStablePool","accounts","payer","publicKey","stableMint","stablePool","tokenProgram","rent","web3","SYSVAR_RENT_PUBKEY","systemProgram","SystemProgram","programId","signers","ADMIN_KEYPAIR","rpc","console","log","initializeUnderlyingPool"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,OAAOC,YAAY,WAAW;AAC9B,YAAYC,YAAY,oBAAoB;AAI5C,SACEC,oBAAoB,EACpBC,eAAe,EACfC,mBAAmB,QACd,eAAe;AACtB,SAASC,gBAAgB,QAAQ,yCAAyC;AAE1E,OAAO,eAAeC,mBAAmBC,IAAa,EAAEC,GAAa;IACnE,MAAMC,WAAWR,OAAOS,cAAc,CAACC,GAAG;IAC1CV,OAAOW,WAAW,CAACH;IACnB,MAAMI,UAAU,MAAMd,WAAWU;IACjC,MAAMK,gBACJd,OAAOe,gBAAgB,EACvBf,OAAOgB,kBAAkB,EACzBP,UACAI;IAEFL,IAAIS,MAAM,CAAC,KAAKC,IAAI,CAAC;QACnBC,SAAS;IACX;AACF;AAEA,OAAO,eAAeL,gBACpBM,cAAyB,EACzBC,SAAoB,EACpBZ,QAA+B,EAC/BI,OAAsC;IAEtC,MAAM,CAACS,eAAe,GAAGpB,qBAAqBkB;IAC9C,MAAM,CAACG,UAAU,GAAGpB,gBAAgBkB;IACpC,MAAM,CAACG,cAAc,GAAGpB;IACxB;QACE,MAAMqB,SAAS,MAAMZ,QAAQa,OAAO,CACjCC,oBAAoB,GACpBC,QAAQ,CAAC;YACRC,OAAOpB,SAASqB,SAAS;YACzBC,YAAYV;YACZW,YAAYT;YACZC;YACAS,cAAc5B;YACd6B,MAAMjC,OAAOkC,IAAI,CAACC,kBAAkB;YACpCC,eAAepC,OAAOkC,IAAI,CAACG,aAAa,CAACC,SAAS;QACpD,GACCC,OAAO,CAAC;YAACxC,OAAOyC,aAAa;SAAC,EAC9BC,GAAG;QACNC,QAAQC,GAAG,CAAC,CAAC,oCAAoC,EAAEnB,OAAO,CAAC;IAC7D;IACA,MAAMA,SAAS,MAAMZ,QAAQa,OAAO,CACjCmB,wBAAwB,GACxBjB,QAAQ,CAAC;QACRC,OAAOpB,SAASqB,SAAS;QACzBV;QACAE;QACAE;QACAS,cAAc5B;QACd6B,MAAMjC,OAAOkC,IAAI,CAACC,kBAAkB;QACpCC,eAAepC,OAAOkC,IAAI,CAACG,aAAa,CAACC,SAAS;IACpD,GACCC,OAAO,CAAC;QAACxC,OAAOyC,aAAa;KAAC,EAC9BC,GAAG;IACNC,QAAQC,GAAG,CAAC,CAAC,oCAAoC,EAAEnB,OAAO,CAAC;AAC7D"} \ No newline at end of file +{"version":3,"sources":["../../../src/controllers/initializePools.controller.ts"],"sourcesContent":["import { getProgram } from '../utils/programUtils';\nimport Config from '../config';\nimport * as anchor from '@coral-xyz/anchor';\nimport { PublicKey } from '@solana/web3.js';\nimport { Request, Response } from 'express';\nimport { EuroPrimitive } from '../types/euro_primitive';\nimport {\n getUnderlyingPoolPda,\n getQuotePoolPda,\n getPoolAuthorityPda,\n} from '../utils/pdas';\nimport { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token';\n\nexport async function getInitializePools(_req: Request, res: Response) {\n const provider = anchor.AnchorProvider.env();\n anchor.setProvider(provider);\n const program = await getProgram(provider);\n await initializePools(\n Config.TESTNET_WETH_MINT,\n Config.TESTNET_QUOTE_MINT,\n provider,\n program,\n );\n res.status(200).json({\n message: 'Initialize pools',\n });\n}\n\nexport async function initializePools(\n underlyingMint: PublicKey,\n quoteMint: PublicKey,\n provider: anchor.AnchorProvider,\n program: anchor.Program,\n) {\n const [underlyingPool] = getUnderlyingPoolPda(underlyingMint);\n const [quotePool] = getQuotePoolPda(quoteMint);\n const [poolAuthority] = getPoolAuthorityPda();\n {\n const txHash = await program.methods\n .initializeStablePool()\n .accounts({\n payer: provider.publicKey,\n stableMint: quoteMint,\n stablePool: quotePool,\n poolAuthority,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .rpc();\n console.log(`Transaction completed successfully: ${txHash}`);\n }\n const txHash = await program.methods\n .initializeUnderlyingPool()\n .accounts({\n payer: provider.publicKey,\n underlyingMint,\n underlyingPool,\n poolAuthority,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .rpc();\n console.log(`Transaction completed successfully: ${txHash}`);\n}\n"],"names":["getProgram","Config","anchor","getUnderlyingPoolPda","getQuotePoolPda","getPoolAuthorityPda","TOKEN_PROGRAM_ID","getInitializePools","_req","res","provider","AnchorProvider","env","setProvider","program","initializePools","TESTNET_WETH_MINT","TESTNET_QUOTE_MINT","status","json","message","underlyingMint","quoteMint","underlyingPool","quotePool","poolAuthority","txHash","methods","initializeStablePool","accounts","payer","publicKey","stableMint","stablePool","tokenProgram","rent","web3","SYSVAR_RENT_PUBKEY","systemProgram","SystemProgram","programId","signers","ADMIN_KEYPAIR","rpc","console","log","initializeUnderlyingPool"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,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C,IAAI,CAACC,kBAAkB;QACpCC,eAAepC,OAAOkC,IAAI,CAACG,aAAa,CAACC,SAAS;IACpD,GACCC,OAAO,CAAC;QAACxC,OAAOyC,aAAa;KAAC,EAC9BC,GAAG;IACNC,QAAQC,GAAG,CAAC,CAAC,oCAAoC,EAAEnB,OAAO,CAAC;AAC7D"} \ No newline at end of file diff --git a/dist/src/controllers/mintOptions.controller.js b/dist/src/controllers/mintOptions.controller.js index 49dd44a..e4bcd85 100644 --- a/dist/src/controllers/mintOptions.controller.js +++ b/dist/src/controllers/mintOptions.controller.js @@ -1,21 +1,22 @@ import Config from '../config.js'; -import { getEuroMetaPda, getExpirationDataPda, getOptionMintPda, getWriterMintPda, getUnderlyingPoolPda, getOptionCyclePda, getAuctionProgramVaultPda, getAuctionStatePda } from '../utils/pdas.js'; -import { sleep, OptionTypeV2, // postTelegramMessage, -getAtaForUser } from '../utils/index.js'; +import { getEuroMetaPda, getExpirationDataPda, getOptionMintPda, getWriterMintPda, getUnderlyingPoolPda, getOptionCyclePda, getAuctionProgramVaultPda, getAuctionStatePda, getPoolAuthorityVaultsPda } from '../utils/pdas.js'; +import { sleep, OptionTypeV2, postTelegramMessage, getAtaForUser } from '../utils/index.js'; import * as anchor from '@coral-xyz/anchor'; import BN from 'bn.js'; -import { getProgram, getVaultsProgram } from '../utils/programUtils.js'; +import { getProgram, getVaultsProgram, getAuctionProgram } from '../utils/programUtils.js'; import { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token.js'; import { Transaction } from '@solana/web3.js'; -// import cron from 'node-cron'; -async function processMintingTransaction(provider, expiration) { +import { getAssociatedTokenAddressSync } from '@solana/spl-token'; +import cron from 'node-cron'; +async function processMintingTransaction(provider, expiration, cycleNumber) { const program = await getProgram(provider); const vaultsProgram = await getVaultsProgram(provider); + const auctionProgram = await getAuctionProgram(provider); const priceDecimals = 2; - const [expirationData, expirationDataBump] = getExpirationDataPda(Config.TESTNET_SOL_MINT, expiration, Config.TESTNET_ORACLE_PUBLIC_KEY); + const [expirationData, expirationDataBump] = getExpirationDataPda(Config.TESTNET_WETH_MINT, expiration, Config.TESTNET_ORACLE_PUBLIC_KEY); const initExpirationDataInstruction = await program.methods.initExpirationData(expiration, priceDecimals, 1).accounts({ payer: provider.publicKey, - underlyingMint: Config.TESTNET_SOL_MINT, + underlyingMint: Config.TESTNET_WETH_MINT, expirationData: expirationData, oracle: Config.TESTNET_ORACLE_PUBLIC_KEY, tokenProgram: TOKEN_PROGRAM_ID, @@ -28,13 +29,13 @@ async function processMintingTransaction(provider, expiration) { const strikePrices = [ new BN(Math.pow(10, priceDecimals) * (underlyingPrice + 1)) ]; - const [underlyingPool] = getUnderlyingPoolPda(Config.TESTNET_SOL_MINT); - const [euroMetaKey, euroMetaBump] = getEuroMetaPda(Config.TESTNET_SOL_MINT, Config.TESTNET_QUOTE_MINT, expiration, OptionTypeV2.CALL, underlyingPool, strikePrices); + const [underlyingPool] = getUnderlyingPoolPda(Config.TESTNET_WETH_MINT); + const [euroMetaKey, euroMetaBump] = getEuroMetaPda(Config.TESTNET_WETH_MINT, Config.TESTNET_QUOTE_MINT, expiration, OptionTypeV2.CALL, underlyingPool, strikePrices); const underlyingAmountPerContract = new BN(1_000_000); const [optionMint] = getOptionMintPda(euroMetaKey); const [writerMint] = getWriterMintPda(euroMetaKey); const euroMeta = { - underlyingMint: Config.TESTNET_SOL_MINT, + underlyingMint: Config.TESTNET_WETH_MINT, collateralPool: underlyingPool, stableMint: Config.TESTNET_QUOTE_MINT, stableDecimals: 6, @@ -80,75 +81,75 @@ async function processMintingTransaction(provider, expiration) { if (!atas) { throw new Error('Failed to get ATAs'); } - // const mintOptionInstruction = await program.methods - // .mintOptionsV2(size, OptionTypeV2.CALL) - // .accounts({ - // payer: provider.publicKey, - // euroMeta: euroMetaKey, - // collateralPool: underlyingPool, - // optionMint: euroMeta.optionMint, - // writerMint: euroMeta.writerMint, - // minterCollateral: atas.underlyingMintAta, - // optionDestination: atas.optionMintAta, - // writerDestination: atas.writerMintAta, - // tokenProgram: TOKEN_PROGRAM_ID, - // }) - // .signers([Config.ADMIN_KEYPAIR]) - // .instruction(); - const cycleNumber = new BN(1); const strikePrice = new BN(269); const optionType = OptionTypeV2.CALL; const auctionType = 0; const startingBid = new BN(1_000_000); const duration = new BN(604_800); const [optionCycle] = getOptionCyclePda(provider.publicKey, cycleNumber); - const [auctionProgramVault] = getAuctionProgramVaultPda(optionCycle); - const [auctionState] = getAuctionStatePda(provider.publicKey); + const [auctionState] = getAuctionStatePda(provider.publicKey, cycleNumber); + const [auctionProgramVault] = getAuctionProgramVaultPda(auctionState); + console.log('Getting auction program ATAs'); const auctionProgramAtas = await getAtaForUser(euroMeta.optionMint, euroMeta.writerMint, euroMeta.underlyingMint, auctionProgramVault, true); if (!auctionProgramAtas) { throw new Error('Failed to get auction program ATAs'); } + const [poolAuthorityVaults] = getPoolAuthorityVaultsPda(); + const vaultUnderlyingAta = getAssociatedTokenAddressSync(euroMeta.underlyingMint, poolAuthorityVaults, true); + // const vaultStableAta = getAssociatedTokenAddressSync( + // euroMeta.stableMint, + // poolAuthorityVaults, + // true, + // ); const mintOptionInstruction = await vaultsProgram.methods.startCycle(cycleNumber, strikePrice, underlyingAmountPerContract, size, priceDecimals, optionType, auctionType, startingBid, duration).accounts({ vaultAuthority: provider.publicKey, optionCycle, vaultOptionTokenAccount: auctionProgramAtas.optionMintAta, vaultWriterTokenAccount: auctionProgramAtas.writerMintAta, - auctionVault: auctionProgramVault, - creatorTokenAccount: atas.optionMintAta, - underlyingMint: euroMeta.underlyingMint, - stableMint: euroMeta.stableMint, - underlyingPool: euroMeta.collateralPool, - stablePool: euroMeta.collateralPool, + collateralPool: euroMeta.collateralPool, + underlyingPool: atas.underlyingMintAta, + vaultCollateral: vaultUnderlyingAta, + vaultPoolAuthority: poolAuthorityVaults, euroMeta: euroMetaKey, optionMint: euroMeta.optionMint, writerMint: euroMeta.writerMint, - expirationData: euroMeta.expirationData, - oracle: euroMeta.oracle, auctionState, euroPrimitiveProgram: Config.LEVERAGE_FUN_PROGRAM_ID, - optionAuctionProgram: Config.AUCTION_PROGRAM_ID, tokenProgram: TOKEN_PROGRAM_ID, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, systemProgram: anchor.web3.SystemProgram.programId }).instruction(); + const initAuctionIx = await auctionProgram.methods.initializeAuction(cycleNumber, auctionType, startingBid, duration).accounts({ + auction: auctionState, + creator: provider.publicKey, + tokenMint: euroMeta.optionMint, + assetHolder: auctionProgramAtas.optionMintAta, + vault: auctionProgramVault, + creatorTokenAccount: atas.optionMintAta, + systemProgram: anchor.web3.SystemProgram.programId, + tokenProgram: TOKEN_PROGRAM_ID, + rent: anchor.web3.SYSVAR_RENT_PUBKEY + }).instruction(); { - const tx = new Transaction().add(mintOptionInstruction); + const tx = new Transaction().add(initAuctionIx).add(mintOptionInstruction); return await provider.sendAndConfirm(tx); } } export async function scheduleMintingProcess(provider) { - // cron.schedule('30 * * * *', async () => { - try { - const expiration = new BN(new Date().getTime() / 1000 + 3600); - const txHash = await processMintingTransaction(provider, expiration); - if (txHash) { - // await postTelegramMessage(txHash); - console.log(`Transaction completed successfully: ${txHash}`); + let cycleNumber = new BN(6); + cron.schedule('0 0 * * 5', async ()=>{ + console.log('Current cycle number, ', cycleNumber.toString()); + try { + const expiration = new BN(new Date().getTime() / 1000 + 3600); + const txHash = await processMintingTransaction(provider, expiration, cycleNumber); + if (txHash) { + await postTelegramMessage(txHash); + console.log(`Transaction completed successfully: ${txHash}`); + cycleNumber = cycleNumber.add(new BN(1)); + } + } catch (error) { + console.error('Scheduled transaction failed:', error); } - } catch (error) { - console.error('Scheduled transaction failed:', error); - } -// }); + }); } export async function startMintingOptions(_req, res) { const provider = anchor.AnchorProvider.env(); diff --git a/dist/src/controllers/mintOptions.controller.js.map b/dist/src/controllers/mintOptions.controller.js.map index 535b735..72e0204 100644 --- a/dist/src/controllers/mintOptions.controller.js.map +++ b/dist/src/controllers/mintOptions.controller.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/controllers/mintOptions.controller.ts"],"sourcesContent":["import { Request, Response } from 'express';\nimport Config from '../config.js';\nimport {\n getEuroMetaPda,\n getExpirationDataPda,\n getOptionMintPda,\n getWriterMintPda,\n getUnderlyingPoolPda,\n getOptionCyclePda,\n getAuctionProgramVaultPda,\n getAuctionStatePda,\n} from '../utils/pdas.js';\nimport {\n sleep,\n OptionTypeV2,\n // postTelegramMessage,\n getAtaForUser,\n} from '../utils/index.js';\nimport * as anchor from '@coral-xyz/anchor';\nimport BN from 'bn.js';\nimport { getProgram, getVaultsProgram } from '../utils/programUtils.js';\nimport { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token.js';\nimport { Transaction } from '@solana/web3.js';\n// import cron from 'node-cron';\n\nasync function processMintingTransaction(\n provider: anchor.AnchorProvider,\n expiration: BN,\n): Promise {\n const program = await getProgram(provider);\n const vaultsProgram = await getVaultsProgram(provider);\n const priceDecimals = 2;\n const [expirationData, expirationDataBump] = getExpirationDataPda(\n Config.TESTNET_SOL_MINT,\n expiration,\n Config.SOLANA_DEVNET_ORACLE,\n );\n\n const initExpirationDataInstruction = await program.methods\n .initExpirationData(expiration, priceDecimals, 1)\n .accounts({\n payer: provider.publicKey,\n underlyingMint: Config.TESTNET_SOL_MINT,\n expirationData: expirationData,\n oracle: Config.SOLANA_DEVNET_ORACLE,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .instruction();\n const underlyingPrice = 25_000;\n const strikePrices = [\n new BN(Math.pow(10, priceDecimals) * (underlyingPrice + 1)),\n ];\n const [underlyingPool] = getUnderlyingPoolPda(Config.TESTNET_SOL_MINT);\n const [euroMetaKey, euroMetaBump] = getEuroMetaPda(\n Config.TESTNET_SOL_MINT,\n Config.TESTNET_QUOTE_MINT,\n expiration,\n OptionTypeV2.CALL,\n underlyingPool,\n strikePrices,\n );\n const underlyingAmountPerContract = new BN(1_000_000);\n const [optionMint] = getOptionMintPda(euroMetaKey);\n const [writerMint] = getWriterMintPda(euroMetaKey);\n const euroMeta = {\n underlyingMint: Config.TESTNET_SOL_MINT,\n collateralPool: underlyingPool,\n stableMint: Config.TESTNET_QUOTE_MINT,\n stableDecimals: 6,\n underlyingDecimals: 6,\n underlyingAmountPerContract,\n oracle: Config.SOLANA_DEVNET_ORACLE,\n strikePrices,\n priceDecimals,\n optionMint,\n writerMint,\n expiration,\n expirationData,\n bumpSeed: euroMetaBump,\n oracleProviderId: 1,\n optionType: OptionTypeV2.CALL,\n };\n const createEuroMetaV2Instruction = await program.methods\n .createEuroMetaV2(\n euroMeta.expiration,\n euroMeta.strikePrices,\n euroMeta.oracleProviderId,\n euroMeta.optionType,\n expirationDataBump,\n euroMeta.underlyingAmountPerContract,\n euroMeta.priceDecimals,\n )\n .accounts({\n payer: provider.publicKey,\n underlyingMint: euroMeta.underlyingMint,\n collateralPool: euroMeta.collateralPool,\n stableMint: euroMeta.stableMint,\n euroMeta: euroMetaKey,\n expirationData: euroMeta.expirationData,\n optionMint: euroMeta.optionMint,\n writerMint: euroMeta.writerMint,\n oracle: euroMeta.oracle,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .instruction();\n {\n const tx = new Transaction().add(initExpirationDataInstruction);\n tx.add(createEuroMetaV2Instruction);\n const sig = await provider.sendAndConfirm(tx);\n console.log(`Euro meta created: ${sig}`);\n sleep(5000);\n }\n const wholeContracts = 2.5;\n const size = new BN(Math.pow(10, 4)).muln(wholeContracts);\n const atas = await getAtaForUser(\n euroMeta.optionMint,\n euroMeta.writerMint,\n euroMeta.underlyingMint,\n provider.publicKey,\n );\n if (!atas) {\n throw new Error('Failed to get ATAs');\n }\n // const mintOptionInstruction = await program.methods\n // .mintOptionsV2(size, OptionTypeV2.CALL)\n // .accounts({\n // payer: provider.publicKey,\n // euroMeta: euroMetaKey,\n // collateralPool: underlyingPool,\n // optionMint: euroMeta.optionMint,\n // writerMint: euroMeta.writerMint,\n // minterCollateral: atas.underlyingMintAta,\n // optionDestination: atas.optionMintAta,\n // writerDestination: atas.writerMintAta,\n // tokenProgram: TOKEN_PROGRAM_ID,\n // })\n // .signers([Config.ADMIN_KEYPAIR])\n // .instruction();\n const cycleNumber = new BN(1);\n const strikePrice = new BN(269);\n const optionType = OptionTypeV2.CALL;\n const auctionType = 0;\n const startingBid = new BN(1_000_000);\n const duration = new BN(604_800);\n\n const [optionCycle] = getOptionCyclePda(provider.publicKey, cycleNumber);\n const [auctionProgramVault] = getAuctionProgramVaultPda(optionCycle);\n const [auctionState] = getAuctionStatePda(provider.publicKey);\n const auctionProgramAtas = await getAtaForUser(\n euroMeta.optionMint,\n euroMeta.writerMint,\n euroMeta.underlyingMint,\n auctionProgramVault,\n true,\n );\n if (!auctionProgramAtas) {\n throw new Error('Failed to get auction program ATAs');\n }\n const mintOptionInstruction = await vaultsProgram.methods\n .startCycle(\n cycleNumber,\n strikePrice,\n underlyingAmountPerContract,\n size,\n priceDecimals,\n optionType,\n auctionType,\n startingBid,\n duration,\n )\n .accounts({\n vaultAuthority: provider.publicKey,\n optionCycle,\n vaultOptionTokenAccount: auctionProgramAtas.optionMintAta,\n vaultWriterTokenAccount: auctionProgramAtas.writerMintAta,\n auctionVault: auctionProgramVault,\n creatorTokenAccount: atas.optionMintAta,\n underlyingMint: euroMeta.underlyingMint,\n stableMint: euroMeta.stableMint,\n underlyingPool: euroMeta.collateralPool,\n stablePool: euroMeta.collateralPool,\n euroMeta: euroMetaKey,\n optionMint: euroMeta.optionMint,\n writerMint: euroMeta.writerMint,\n expirationData: euroMeta.expirationData,\n oracle: euroMeta.oracle,\n auctionState,\n euroPrimitiveProgram: Config.LEVERAGE_FUN_PROGRAM_ID,\n optionAuctionProgram: Config.AUCTION_PROGRAM_ID,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .instruction();\n {\n const tx = new Transaction().add(mintOptionInstruction);\n return await provider.sendAndConfirm(tx);\n }\n}\n\nexport async function scheduleMintingProcess(provider: anchor.AnchorProvider) {\n // cron.schedule('30 * * * *', async () => {\n try {\n const expiration = new BN(new Date().getTime() / 1000 + 3600);\n const txHash = await processMintingTransaction(provider, expiration);\n if (txHash) {\n // await postTelegramMessage(txHash);\n console.log(`Transaction completed successfully: ${txHash}`);\n }\n } catch (error) {\n console.error('Scheduled transaction failed:', error);\n }\n // });\n}\n\nexport async function startMintingOptions(_req: Request, res: Response) {\n const provider = anchor.AnchorProvider.env();\n anchor.setProvider(provider);\n\n scheduleMintingProcess(provider).catch(error => {\n console.error('Failed to start cron job:', error);\n });\n\n res.status(202).json({\n message: 'Minting options cron job started',\n status: 'pending',\n });\n}\n"],"names":["Config","getEuroMetaPda","getExpirationDataPda","getOptionMintPda","getWriterMintPda","getUnderlyingPoolPda","getOptionCyclePda","getAuctionProgramVaultPda","getAuctionStatePda","sleep","OptionTypeV2","getAtaForUser","anchor","BN","getProgram","getVaultsProgram","TOKEN_PROGRAM_ID","Transaction","processMintingTransaction","provider","expiration","program","vaultsProgram","priceDecimals","expirationData","expirationDataBump","TESTNET_SOL_MINT","SOLANA_DEVNET_ORACLE","initExpirationDataInstruction","methods","initExpirationData","accounts","payer","publicKey","underlyingMint","oracle","tokenProgram","rent","web3","SYSVAR_RENT_PUBKEY","systemProgram","SystemProgram","programId","signers","ADMIN_KEYPAIR","instruction","underlyingPrice","strikePrices","Math","pow","underlyingPool","euroMetaKey","euroMetaBump","TESTNET_QUOTE_MINT","CALL","underlyingAmountPerContract","optionMint","writerMint","euroMeta","collateralPool","stableMint","stableDecimals","underlyingDecimals","bumpSeed","oracleProviderId","optionType","createEuroMetaV2Instruction","createEuroMetaV2","tx","add","sig","sendAndConfirm","console","log","wholeContracts","size","muln","atas","Error","cycleNumber","strikePrice","auctionType","startingBid","duration","optionCycle","auctionProgramVault","auctionState","auctionProgramAtas","mintOptionInstruction","startCycle","vaultAuthority","vaultOptionTokenAccount","optionMintAta","vaultWriterTokenAccount","writerMintAta","auctionVault","creatorTokenAccount","stablePool","euroPrimitiveProgram","LEVERAGE_FUN_PROGRAM_ID","optionAuctionProgram","AUCTION_PROGRAM_ID","scheduleMintingProcess","Date","getTime","txHash","error","startMintingOptions","_req","res","AnchorProvider","env","setProvider","catch","status","json","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,OAAOA,YAAY,eAAe;AAClC,SACEC,cAAc,EACdC,oBAAoB,EACpBC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,iBAAiB,EACjBC,yBAAyB,EACzBC,kBAAkB,QACb,mBAAmB;AAC1B,SACEC,KAAK,EACLC,YAAY,EAEZC,AADA,uBAAuB;AACvBA,aAAa,QACR,oBAAoB;AAC3B,YAAYC,YAAY,oBAAoB;AAC5C,OAAOC,QAAQ,QAAQ;AACvB,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,2BAA2B;AACxE,SAASC,gBAAgB,QAAQ,4CAA4C;AAC7E,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,gCAAgC;AAEhC,eAAeC,0BACbC,QAA+B,EAC/BC,UAAc;IAEd,MAAMC,UAAU,MAAMP,WAAWK;IACjC,MAAMG,gBAAgB,MAAMP,iBAAiBI;IAC7C,MAAMI,gBAAgB;IACtB,MAAM,CAACC,gBAAgBC,mBAAmB,GAAGvB,qBAC3CF,OAAO0B,gBAAgB,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pCC,eAAe5B,OAAO0B,IAAI,CAACG,aAAa,CAACC,SAAS;IACpD,GACCG,WAAW;IACd;QACE,MAAMuB,KAAK,IAAInD,cAAcoD,GAAG,CAACmB;QACjC,OAAO,MAAMrE,SAASoD,cAAc,CAACH;IACvC;AACF;AAEA,OAAO,eAAekC,uBAAuBnF,QAA+B;IAC1E,4CAA4C;IAC5C,IAAI;QACF,MAAMC,aAAa,IAAIP,GAAG,IAAI0F,OAAOC,OAAO,KAAK,OAAO;QACxD,MAAMC,SAAS,MAAMvF,0BAA0BC,UAAUC;QACzD,IAAIqF,QAAQ;YACV,qCAAqC;YACrCjC,QAAQC,GAAG,CAAC,CAAC,oCAAoC,EAAEgC,OAAO,CAAC;QAC7D;IACF,EAAE,OAAOC,OAAO;QACdlC,QAAQkC,KAAK,CAAC,iCAAiCA;IACjD;AACA,MAAM;AACR;AAEA,OAAO,eAAeC,oBAAoBC,IAAa,EAAEC,GAAa;IACpE,MAAM1F,WAAWP,OAAOkG,cAAc,CAACC,GAAG;IAC1CnG,OAAOoG,WAAW,CAAC7F;IAEnBmF,uBAAuBnF,UAAU8F,KAAK,CAACP,CAAAA;QACrClC,QAAQkC,KAAK,CAAC,6BAA6BA;IAC7C;IAEAG,IAAIK,MAAM,CAAC,KAAKC,IAAI,CAAC;QACnBC,SAAS;QACTF,QAAQ;IACV;AACF"} \ No newline at end of file +{"version":3,"sources":["../../../src/controllers/mintOptions.controller.ts"],"sourcesContent":["import { Request, Response } from 'express';\nimport Config from '../config.js';\nimport {\n getEuroMetaPda,\n getExpirationDataPda,\n getOptionMintPda,\n getWriterMintPda,\n getUnderlyingPoolPda,\n getOptionCyclePda,\n getAuctionProgramVaultPda,\n getAuctionStatePda,\n getPoolAuthorityVaultsPda,\n} from '../utils/pdas.js';\nimport {\n sleep,\n OptionTypeV2,\n postTelegramMessage,\n getAtaForUser,\n} from '../utils/index.js';\nimport * as anchor from '@coral-xyz/anchor';\nimport BN from 'bn.js';\nimport {\n getProgram,\n getVaultsProgram,\n getAuctionProgram,\n} from '../utils/programUtils.js';\nimport { TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/cjs/utils/token.js';\nimport { Transaction } from '@solana/web3.js';\nimport { getAssociatedTokenAddressSync } from '@solana/spl-token';\nimport cron from 'node-cron';\n\nasync function processMintingTransaction(\n provider: anchor.AnchorProvider,\n expiration: BN,\n cycleNumber: BN,\n): Promise {\n const program = await getProgram(provider);\n const vaultsProgram = await getVaultsProgram(provider);\n const auctionProgram = await getAuctionProgram(provider);\n const priceDecimals = 2;\n const [expirationData, expirationDataBump] = getExpirationDataPda(\n Config.TESTNET_WETH_MINT,\n expiration,\n Config.TESTNET_ORACLE_PUBLIC_KEY,\n );\n\n const initExpirationDataInstruction = await program.methods\n .initExpirationData(expiration, priceDecimals, 1)\n .accounts({\n payer: provider.publicKey,\n underlyingMint: Config.TESTNET_WETH_MINT,\n expirationData: expirationData,\n oracle: Config.TESTNET_ORACLE_PUBLIC_KEY,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .instruction();\n const underlyingPrice = 25_000;\n const strikePrices = [\n new BN(Math.pow(10, priceDecimals) * (underlyingPrice + 1)),\n ];\n const [underlyingPool] = getUnderlyingPoolPda(Config.TESTNET_WETH_MINT);\n const [euroMetaKey, euroMetaBump] = getEuroMetaPda(\n Config.TESTNET_WETH_MINT,\n Config.TESTNET_QUOTE_MINT,\n expiration,\n OptionTypeV2.CALL,\n underlyingPool,\n strikePrices,\n );\n const underlyingAmountPerContract = new BN(1_000_000);\n const [optionMint] = getOptionMintPda(euroMetaKey);\n const [writerMint] = getWriterMintPda(euroMetaKey);\n const euroMeta = {\n underlyingMint: Config.TESTNET_WETH_MINT,\n collateralPool: underlyingPool,\n stableMint: Config.TESTNET_QUOTE_MINT,\n stableDecimals: 6,\n underlyingDecimals: 6,\n underlyingAmountPerContract,\n oracle: Config.TESTNET_ORACLE_PUBLIC_KEY,\n strikePrices,\n priceDecimals,\n optionMint,\n writerMint,\n expiration,\n expirationData,\n bumpSeed: euroMetaBump,\n oracleProviderId: 1,\n optionType: OptionTypeV2.CALL,\n };\n const createEuroMetaV2Instruction = await program.methods\n .createEuroMetaV2(\n euroMeta.expiration,\n euroMeta.strikePrices,\n euroMeta.oracleProviderId,\n euroMeta.optionType,\n expirationDataBump,\n euroMeta.underlyingAmountPerContract,\n euroMeta.priceDecimals,\n )\n .accounts({\n payer: provider.publicKey,\n underlyingMint: euroMeta.underlyingMint,\n collateralPool: euroMeta.collateralPool,\n stableMint: euroMeta.stableMint,\n euroMeta: euroMetaKey,\n expirationData: euroMeta.expirationData,\n optionMint: euroMeta.optionMint,\n writerMint: euroMeta.writerMint,\n oracle: euroMeta.oracle,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .signers([Config.ADMIN_KEYPAIR])\n .instruction();\n {\n const tx = new Transaction().add(initExpirationDataInstruction);\n tx.add(createEuroMetaV2Instruction);\n const sig = await provider.sendAndConfirm(tx);\n console.log(`Euro meta created: ${sig}`);\n sleep(5000);\n }\n const wholeContracts = 2.5;\n const size = new BN(Math.pow(10, 4)).muln(wholeContracts);\n const atas = await getAtaForUser(\n euroMeta.optionMint,\n euroMeta.writerMint,\n euroMeta.underlyingMint,\n provider.publicKey,\n );\n if (!atas) {\n throw new Error('Failed to get ATAs');\n }\n const strikePrice = new BN(269);\n const optionType = OptionTypeV2.CALL;\n const auctionType = 0;\n const startingBid = new BN(1_000_000);\n const duration = new BN(604_800);\n\n const [optionCycle] = getOptionCyclePda(provider.publicKey, cycleNumber);\n const [auctionState] = getAuctionStatePda(provider.publicKey, cycleNumber);\n const [auctionProgramVault] = getAuctionProgramVaultPda(auctionState);\n console.log('Getting auction program ATAs');\n const auctionProgramAtas = await getAtaForUser(\n euroMeta.optionMint,\n euroMeta.writerMint,\n euroMeta.underlyingMint,\n auctionProgramVault,\n true,\n );\n if (!auctionProgramAtas) {\n throw new Error('Failed to get auction program ATAs');\n }\n const [poolAuthorityVaults] = getPoolAuthorityVaultsPda();\n const vaultUnderlyingAta = getAssociatedTokenAddressSync(\n euroMeta.underlyingMint,\n poolAuthorityVaults,\n true,\n );\n // const vaultStableAta = getAssociatedTokenAddressSync(\n // euroMeta.stableMint,\n // poolAuthorityVaults,\n // true,\n // );\n const mintOptionInstruction = await vaultsProgram.methods\n .startCycle(\n cycleNumber,\n strikePrice,\n underlyingAmountPerContract,\n size,\n priceDecimals,\n optionType,\n auctionType,\n startingBid,\n duration,\n )\n .accounts({\n vaultAuthority: provider.publicKey,\n optionCycle,\n vaultOptionTokenAccount: auctionProgramAtas.optionMintAta,\n vaultWriterTokenAccount: auctionProgramAtas.writerMintAta,\n collateralPool: euroMeta.collateralPool,\n underlyingPool: atas.underlyingMintAta,\n vaultCollateral: vaultUnderlyingAta,\n vaultPoolAuthority: poolAuthorityVaults,\n euroMeta: euroMetaKey,\n optionMint: euroMeta.optionMint,\n writerMint: euroMeta.writerMint,\n auctionState,\n euroPrimitiveProgram: Config.LEVERAGE_FUN_PROGRAM_ID,\n tokenProgram: TOKEN_PROGRAM_ID,\n systemProgram: anchor.web3.SystemProgram.programId,\n })\n .instruction();\n\n const initAuctionIx = await auctionProgram.methods\n .initializeAuction(cycleNumber, auctionType, startingBid, duration)\n .accounts({\n auction: auctionState,\n creator: provider.publicKey,\n tokenMint: euroMeta.optionMint,\n assetHolder: auctionProgramAtas.optionMintAta,\n vault: auctionProgramVault,\n creatorTokenAccount: atas.optionMintAta,\n systemProgram: anchor.web3.SystemProgram.programId,\n tokenProgram: TOKEN_PROGRAM_ID,\n rent: anchor.web3.SYSVAR_RENT_PUBKEY,\n })\n .instruction();\n {\n const tx = new Transaction().add(initAuctionIx).add(mintOptionInstruction);\n return await provider.sendAndConfirm(tx);\n }\n}\n\nexport async function scheduleMintingProcess(provider: anchor.AnchorProvider) {\n let cycleNumber = new BN(6);\n cron.schedule('0 0 * * 5', async () => {\n console.log('Current cycle number, ', cycleNumber.toString());\n try {\n const expiration = new BN(new Date().getTime() / 1000 + 3600);\n const txHash = await processMintingTransaction(\n provider,\n expiration,\n cycleNumber,\n );\n if (txHash) {\n await postTelegramMessage(txHash);\n console.log(`Transaction completed successfully: ${txHash}`);\n cycleNumber = cycleNumber.add(new BN(1));\n }\n } catch (error) {\n console.error('Scheduled transaction failed:', error);\n }\n });\n}\n\nexport async function startMintingOptions(_req: Request, res: Response) {\n const provider = anchor.AnchorProvider.env();\n anchor.setProvider(provider);\n\n scheduleMintingProcess(provider).catch(error => {\n console.error('Failed to start cron job:', error);\n });\n\n res.status(202).json({\n message: 'Minting options cron job started',\n status: 'pending',\n });\n}\n"],"names":["Config","getEuroMetaPda","getExpirationDataPda","getOptionMintPda","getWriterMintPda","getUnderlyingPoolPda","getOptionCyclePda","getAuctionProgramVaultPda","getAuctionStatePda","getPoolAuthorityVaultsPda","sleep","OptionTypeV2","postTelegramMessage","getAtaForUser","anchor","BN","getProgram","getVaultsProgram","getAuctionProgram","TOKEN_PROGRAM_ID","Transaction","getAssociatedTokenAddressSync","cron","processMintingTransaction","provider","expiration","cycleNumber","program","vaultsProgram","auctionProgram","priceDecimals","expirationData","expirationDataBump","TESTNET_WETH_MINT","TESTNET_ORACLE_PUBLIC_KEY","initExpirationDataInstruction","methods","initExpirationData","accounts","payer","publicKey","underlyingMint","oracle","tokenProgram","rent","web3","SYSVAR_RENT_PUBKEY","systemProgram","SystemProgram","programId","signers","ADMIN_KEYPAIR","instruction","underlyingPrice","strikePrices","Math","pow","underlyingPool","euroMetaKey","euroMetaBump","TESTNET_QUOTE_MINT","CALL","underlyingAmountPerContract","optionMint","writerMint","euroMeta","collateralPool","stableMint","stableDecimals","underlyingDecimals","bumpSeed","oracleProviderId","optionType","createEuroMetaV2Instruction","createEuroMetaV2","tx","add","sig","sendAndConfirm","console","log","wholeContracts","size","muln","atas","Error","strikePrice","auctionType","startingBid","duration","optionCycle","auctionState","auctionProgramVault","auctionProgramAtas","poolAuthorityVaults","vaultUnderlyingAta","mintOptionInstruction","startCycle","vaultAuthority","vaultOptionTokenAccount","optionMintAta","vaultWriterTokenAccount","writerMintAta","underlyingMintAta","vaultCollateral","vaultPoolAuthority","euroPrimitiveProgram","LEVERAGE_FUN_PROGRAM_ID","initAuctionIx","initializeAuction","auction","creator","tokenMint","assetHolder","vault","creatorTokenAccount","scheduleMintingProcess","schedule","toString","Date","getTime","txHash","error","startMintingOptions","_req","res","AnchorProvider","env","setProvider","catch","status","json","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,OAAOA,YAAY,eAAe;AAClC,SACEC,cAAc,EACdC,oBAAoB,EACpBC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,iBAAiB,EACjBC,yBAAyB,EACzBC,kBAAkB,EAClBC,yBAAyB,QACpB,mBAAmB;AAC1B,SACEC,KAAK,EACLC,YAAY,EACZC,mBAAmB,EACnBC,aAAa,QACR,oBAAoB;AAC3B,YAAYC,YAAY,oBAAoB;AAC5C,OAAOC,QAAQ,QAAQ;AACvB,SACEC,UAAU,EACVC,gBAAgB,EAChBC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,gBAAgB,QAAQ,4CAA4C;AAC7E,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,6BAA6B,QAAQ,oBAAoB;AAClE,OAAOC,UAAU,YAAY;AAE7B,eAAeC,0BACbC,QAA+B,EAC/BC,UAAc,EACdC,WAAe;IAEf,MAAMC,UAAU,MAAMX,WAAWQ;IACjC,MAA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2C,KAAK,CAAC,6BAA6BA;IAC7C;IAEAG,IAAIK,MAAM,CAAC,KAAKC,IAAI,CAAC;QACnBC,SAAS;QACTF,QAAQ;IACV;AACF"} \ No newline at end of file diff --git a/dist/src/routes/mintOptions.route.js b/dist/src/routes/mintOptions.route.js index ae760b0..a10ebb3 100644 --- a/dist/src/routes/mintOptions.route.js +++ b/dist/src/routes/mintOptions.route.js @@ -1,9 +1,7 @@ import { startMintingOptions } from '../controllers/mintOptions.controller.js'; -import { getInitializePools } from '../controllers/initializePools.controller.js'; import { Router } from 'express'; const router = Router(); router.get('/', startMintingOptions); -router.get('/initialize', getInitializePools); export default router; //# sourceMappingURL=mintOptions.route.js.map \ No newline at end of file diff --git a/dist/src/routes/mintOptions.route.js.map b/dist/src/routes/mintOptions.route.js.map index 9579d2b..c4660c7 100644 --- a/dist/src/routes/mintOptions.route.js.map +++ b/dist/src/routes/mintOptions.route.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/routes/mintOptions.route.ts"],"sourcesContent":["import { startMintingOptions } from '../controllers/mintOptions.controller.js';\nimport { getInitializePools } from '../controllers/initializePools.controller.js';\nimport { Router } from 'express';\n\nconst router = Router();\n\nrouter.get('/', startMintingOptions);\nrouter.get('/initialize', getInitializePools);\nexport default router;\n"],"names":["startMintingOptions","getInitializePools","Router","router","get"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,2CAA2C;AAC/E,SAASC,kBAAkB,QAAQ,+CAA+C;AAClF,SAASC,MAAM,QAAQ,UAAU;AAEjC,MAAMC,SAASD;AAEfC,OAAOC,GAAG,CAAC,KAAKJ;AAChBG,OAAOC,GAAG,CAAC,eAAeH;AAC1B,eAAeE,OAAO"} \ No newline at end of file +{"version":3,"sources":["../../../src/routes/mintOptions.route.ts"],"sourcesContent":["import { startMintingOptions } from '../controllers/mintOptions.controller.js';\nimport { Router } from 'express';\n\nconst router = Router();\n\nrouter.get('/', startMintingOptions);\nexport default router;\n"],"names":["startMintingOptions","Router","router","get"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,mBAAmB,QAAQ,2CAA2C;AAC/E,SAASC,MAAM,QAAQ,UAAU;AAEjC,MAAMC,SAASD;AAEfC,OAAOC,GAAG,CAAC,KAAKH;AAChB,eAAeE,OAAO"} \ No newline at end of file diff --git a/dist/src/types/euro_primitive.js.map b/dist/src/types/euro_primitive.js.map index be62418..d95df8c 100644 --- a/dist/src/types/euro_primitive.js.map +++ b/dist/src/types/euro_primitive.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/types/euro_primitive.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/euro_primitive.json`.\n */\nexport type EuroPrimitive = {\n \"address\": \"\",\n \"metadata\": {\n \"name\": \"euroPrimitive\",\n \"version\": \"1.1.1\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"closeOptions\",\n \"discriminator\": [\n 164,\n 233,\n 228,\n 52,\n 10,\n 204,\n 181,\n 163\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"closeOptionsV2\",\n \"discriminator\": [\n 171,\n 116,\n 142,\n 55,\n 21,\n 58,\n 56,\n 164\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"createEuroMeta\",\n \"discriminator\": [\n 3,\n 89,\n 97,\n 204,\n 36,\n 53,\n 59,\n 224\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset. Calls will be settled in this asset.\"\n ]\n },\n {\n \"name\": \"underlyingPool\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset. Puts will be settled in this asset.\",\n \"NOTE: This should match the oracle\"\n ]\n },\n {\n \"name\": \"stablePool\"\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"callOptionMint\"\n },\n {\n \"name\": \"callWriterMint\"\n },\n {\n \"name\": \"putOptionMint\",\n \"writable\": true\n },\n {\n \"name\": \"putWriterMint\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"the oracle account is a seed for the ExpirationData PDA, you know this is the same oracle\",\n \"account on that strutcture that was previously checked. Thus all known appropriate checks for\",\n \"the oracle, given the derived ExpirationData, have been met.\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"createEuroMetaV2\",\n \"discriminator\": [\n 100,\n 255,\n 189,\n 150,\n 136,\n 21,\n 243,\n 41\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ]\n },\n {\n \"name\": \"collateralPool\",\n \"docs\": [\n \"The token held in the pool depends on the collateral type in use: PUTs and PUT spreads\",\n \"use the stable asset, CALLs and CALL spreads use underlying. Some CALL Spreads can also\",\n \"use stable. For example, a SOL call spread market may trade in SOL, or USDC.\",\n \"\",\n \"The seeds are checked in access_control\"\n ]\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset.\",\n \"NOTE: This should match the oracle\"\n ]\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"the oracle account is a seed for the ExpirationData PDA, you know this is the same oracle\",\n \"account on that structure that was previously checked. Thus all known appropriate checks for\",\n \"the oracle, given the derived ExpirationData, have been met.\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrices\",\n \"type\": {\n \"vec\": \"u64\"\n }\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"initExpirationData\",\n \"discriminator\": [\n 62,\n 16,\n 215,\n 70,\n 29,\n 99,\n 13,\n 240\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ]\n },\n {\n \"name\": \"expirationData\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"initSerumMarket\",\n \"discriminator\": [\n 55,\n 157,\n 44,\n 90,\n 69,\n 81,\n 148,\n 175\n ],\n \"accounts\": [\n {\n \"name\": \"userAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"serumMarket\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"dexProgram\",\n \"docs\": [\n \"from https://github.com/mithraiclabs/openbook-psy\"\n ]\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"pcMint\"\n },\n {\n \"name\": \"optionMint\"\n },\n {\n \"name\": \"requestQueue\",\n \"writable\": true\n },\n {\n \"name\": \"eventQueue\",\n \"writable\": true\n },\n {\n \"name\": \"bids\",\n \"writable\": true\n },\n {\n \"name\": \"asks\",\n \"writable\": true\n },\n {\n \"name\": \"coinVault\"\n },\n {\n \"name\": \"pcVault\"\n },\n {\n \"name\": \"vaultSigner\"\n },\n {\n \"name\": \"marketAuthority\"\n }\n ],\n \"args\": [\n {\n \"name\": \"marketSpace\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"vaultSignerNonce\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"coinLotSize\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"pcLotSize\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"pcDustThreshold\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"initializeStablePool\",\n \"discriminator\": [\n 144,\n 90,\n 99,\n 33,\n 247,\n 50,\n 214,\n 249\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset\"\n ]\n },\n {\n \"name\": \"stablePool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"initializeUnderlyingPool\",\n \"discriminator\": [\n 14,\n 86,\n 241,\n 157,\n 12,\n 229,\n 171,\n 163\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset. Calls will be settled in this asset.\"\n ]\n },\n {\n \"name\": \"underlyingPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"mintOptions\",\n \"discriminator\": [\n 48,\n 123,\n 197,\n 59,\n 160,\n 199,\n 75,\n 150\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"minterCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"optionDestination\",\n \"writable\": true\n },\n {\n \"name\": \"writerDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"mintOptionsV2\",\n \"discriminator\": [\n 249,\n 84,\n 107,\n 193,\n 157,\n 119,\n 210,\n 190\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"minterCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"optionDestination\",\n \"writable\": true\n },\n {\n \"name\": \"writerDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"preCreateEuroMeta\",\n \"discriminator\": [\n 144,\n 161,\n 76,\n 176,\n 227,\n 97,\n 81,\n 174\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"stableMint\"\n },\n {\n \"name\": \"underlyingMint\"\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"callOptionMint\",\n \"writable\": true\n },\n {\n \"name\": \"callWriterMint\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"preInitSerumMarket\",\n \"discriminator\": [\n 76,\n 6,\n 159,\n 50,\n 147,\n 186,\n 193,\n 223\n ],\n \"accounts\": [\n {\n \"name\": \"userAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"pcMint\"\n },\n {\n \"name\": \"optionMint\"\n },\n {\n \"name\": \"vaultSigner\"\n },\n {\n \"name\": \"coinVault\",\n \"writable\": true\n },\n {\n \"name\": \"pcVault\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"setExpirationPrice\",\n \"discriminator\": [\n 83,\n 210,\n 157,\n 170,\n 44,\n 1,\n 80,\n 109\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"expirationData\",\n \"writable\": true\n },\n {\n \"name\": \"priceOracle\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"settleExpiredOptionV2\",\n \"discriminator\": [\n 93,\n 152,\n 134,\n 107,\n 97,\n 15,\n 215,\n 218\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredOptions\",\n \"discriminator\": [\n 68,\n 203,\n 65,\n 23,\n 67,\n 152,\n 142,\n 56\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"collateralMint\"\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredWriters\",\n \"discriminator\": [\n 193,\n 172,\n 151,\n 210,\n 87,\n 237,\n 226,\n 29\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"collateralMint\"\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredWritersV2\",\n \"discriminator\": [\n 231,\n 50,\n 25,\n 221,\n 92,\n 88,\n 78,\n 252\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"euroMeta\",\n \"discriminator\": [\n 143,\n 142,\n 75,\n 68,\n 96,\n 251,\n 84,\n 36\n ]\n },\n {\n \"name\": \"euroMetaV2\",\n \"discriminator\": [\n 235,\n 100,\n 34,\n 74,\n 90,\n 205,\n 244,\n 43\n ]\n },\n {\n \"name\": \"expirationData\",\n \"discriminator\": [\n 138,\n 118,\n 169,\n 12,\n 44,\n 29,\n 42,\n 126\n ]\n }\n ],\n \"types\": [\n {\n \"name\": \"euroMeta\",\n \"serialization\": \"bytemuckunsafe\",\n \"repr\": {\n \"kind\": \"rust\",\n \"packed\": true\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stablePool\",\n \"docs\": [\n \"The stable pool's address\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"The TokenAccount that holds underlying asset deposits\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"The key for the oracle mapping\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint key for some stable coin that is pegged to the oracle\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"callOptionMint\",\n \"docs\": [\n \"The mint for the CALL option tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"callWriterMint\",\n \"docs\": [\n \"The mint for the CALL writer tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"putOptionMint\",\n \"docs\": [\n \"The mint for the PUT option tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"putWriterMint\",\n \"docs\": [\n \"The mint for the PUT writer tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"expirationData\",\n \"docs\": [\n \"The address for the associated ExpirationData. Stored to make validations computationally\",\n \"efficient.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"strikePrice\",\n \"docs\": [\n \"The strike price with decimals price_decimals\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The Unix Timestamp for the expiration\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"docs\": [\n \"The amount of underlying assets per 1 OptionToken,\",\n \"denoted in the underlying assets decimals.\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingDecimals\",\n \"docs\": [\n \"The number of decimals on the underlying, read from the Mint on creation\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"stableDecimals\",\n \"docs\": [\n \"The decimals of the stable mint\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_price & price_at_expiration. This is\",\n \"required to normalize the strike price with the oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the EuroMeta\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier\"\n ],\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"euroMetaCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"euroMeta\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"euroMetaV2\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint key for some stable coin. Oracle should use this token for pricing. Use of a\",\n \"different token is not recommended (e.g. USDT when Oracle uses USDT), as prices may deviate\",\n \"slightly even for stablecoins.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"collateralPool\",\n \"docs\": [\n \"The collateral pool's address.\",\n \"\",\n \"The token held in the pool depends on the collateral type in use: PUTs and PUT spreads\",\n \"use the stable asset, CALLs and CALL spreads use underlying. Some CALL Spreads can also\",\n \"use stable. For example, a SOL call spread market may trade in SOL, or USDC.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"Oracle's address. Chainlink and Pyth oracles are supported at this time. Matches\",\n \"ExpirationData's oracle\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"writerMint\",\n \"docs\": [\n \"The mint for the writer tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionMint\",\n \"docs\": [\n \"The mint for the option tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"expirationData\",\n \"docs\": [\n \"The address for the associated ExpirationData. Stored to make validations computationally\",\n \"efficient.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"strikePrices\",\n \"docs\": [\n \"Strike price(s). For Calls/Puts, a single value. For vertical spreads, two values. The\",\n \"lower strike price is first, followed by the higher price. Uses price_decimals\"\n ],\n \"type\": {\n \"vec\": \"u64\"\n }\n },\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The Unix Timestamp for the expiration, in seconds. Must match ExpirationData's\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"docs\": [\n \"The amount of underlying assets per 1 OptionToken,\",\n \"denoted in the underlying assets decimals.\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingDecimals\",\n \"docs\": [\n \"The number of decimals on the underlying, read from the mint on creation\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"stableDecimals\",\n \"docs\": [\n \"The decimals of the stable mint, read from the mint on creation.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_prices & price_at_expiration. This is\",\n \"required to normalize the strike price with oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the EuroMeta\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier. Pyth = 0, Switchboard = 1\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"docs\": [\n \"Option type of the euro meta: CALL, PUT, LongCallSpread, LongPutSpread\"\n ],\n \"type\": {\n \"defined\": {\n \"name\": \"optionTypeV2\"\n }\n }\n }\n ]\n }\n },\n {\n \"name\": \"expirationData\",\n \"serialization\": \"bytemuckunsafe\",\n \"repr\": {\n \"kind\": \"rust\",\n \"packed\": true\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The expiration time\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"The aggregate price oracle for pyth or switchboard\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"priceAtExpiration\",\n \"docs\": [\n \"The price, in price_decimals, at the time of expiration\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceSetAtTime\",\n \"docs\": [\n \"The time at which the price_at_expiration was set.\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_price & price_at_expiration. This is\",\n \"required to normalize the strike price with the oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceSet\",\n \"docs\": [\n \"Flag for easy memcmp filtering\"\n ],\n \"type\": \"bool\"\n },\n {\n \"name\": \"bump\",\n \"docs\": [\n \"bump seed\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier\"\n ],\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"expirationDataCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"expirationData\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"optionTypeV2\",\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"call\"\n },\n {\n \"name\": \"put\"\n },\n {\n \"name\": \"longCallSpread\"\n },\n {\n \"name\": \"longPutSpread\"\n }\n ]\n }\n },\n {\n \"name\": \"stablePoolCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"stablePool\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"underlyingPoolCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingPool\",\n \"type\": \"pubkey\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WAsiDE"} \ No newline at end of file +{"version":3,"sources":["../../../src/types/euro_primitive.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/euro_primitive.json`.\n */\nexport type EuroPrimitive = {\n \"address\": \"\",\n \"metadata\": {\n \"name\": \"euroPrimitive\",\n \"version\": \"1.1.1\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"closeOptions\",\n \"discriminator\": [\n 164,\n 233,\n 228,\n 52,\n 10,\n 204,\n 181,\n 163\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"closeOptionsV2\",\n \"discriminator\": [\n 171,\n 116,\n 142,\n 55,\n 21,\n 58,\n 56,\n 164\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"createEuroMeta\",\n \"discriminator\": [\n 3,\n 89,\n 97,\n 204,\n 36,\n 53,\n 59,\n 224\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset. Calls will be settled in this asset.\"\n ]\n },\n {\n \"name\": \"underlyingPool\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset. Puts will be settled in this asset.\",\n \"NOTE: This should match the oracle\"\n ]\n },\n {\n \"name\": \"stablePool\"\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"callOptionMint\"\n },\n {\n \"name\": \"callWriterMint\"\n },\n {\n \"name\": \"putOptionMint\",\n \"writable\": true\n },\n {\n \"name\": \"putWriterMint\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"the oracle account is a seed for the ExpirationData PDA, you know this is the same oracle\",\n \"account on that strutcture that was previously checked. Thus all known appropriate checks for\",\n \"the oracle, given the derived ExpirationData, have been met.\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"createEuroMetaV2\",\n \"discriminator\": [\n 100,\n 255,\n 189,\n 150,\n 136,\n 21,\n 243,\n 41\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ]\n },\n {\n \"name\": \"collateralPool\",\n \"docs\": [\n \"The token held in the pool depends on the collateral type in use: PUTs and PUT spreads\",\n \"use the stable asset, CALLs and CALL spreads use underlying. Some CALL Spreads can also\",\n \"use stable. For example, a SOL call spread market may trade in SOL, or USDC.\",\n \"\",\n \"The seeds are checked in access_control\"\n ]\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset.\",\n \"NOTE: This should match the oracle\"\n ]\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"the oracle account is a seed for the ExpirationData PDA, you know this is the same oracle\",\n \"account on that structure that was previously checked. Thus all known appropriate checks for\",\n \"the oracle, given the derived ExpirationData, have been met.\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrices\",\n \"type\": {\n \"vec\": \"u64\"\n }\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"initExpirationData\",\n \"discriminator\": [\n 62,\n 16,\n 215,\n 70,\n 29,\n 99,\n 13,\n 240\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ]\n },\n {\n \"name\": \"expirationData\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"initSerumMarket\",\n \"discriminator\": [\n 55,\n 157,\n 44,\n 90,\n 69,\n 81,\n 148,\n 175\n ],\n \"accounts\": [\n {\n \"name\": \"userAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"serumMarket\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"dexProgram\",\n \"docs\": [\n \"from https://github.com/mithraiclabs/openbook-psy\"\n ]\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"pcMint\"\n },\n {\n \"name\": \"optionMint\"\n },\n {\n \"name\": \"requestQueue\",\n \"writable\": true\n },\n {\n \"name\": \"eventQueue\",\n \"writable\": true\n },\n {\n \"name\": \"bids\",\n \"writable\": true\n },\n {\n \"name\": \"asks\",\n \"writable\": true\n },\n {\n \"name\": \"coinVault\"\n },\n {\n \"name\": \"pcVault\"\n },\n {\n \"name\": \"vaultSigner\"\n },\n {\n \"name\": \"marketAuthority\"\n }\n ],\n \"args\": [\n {\n \"name\": \"marketSpace\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"vaultSignerNonce\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"coinLotSize\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"pcLotSize\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"pcDustThreshold\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"initializeStablePool\",\n \"discriminator\": [\n 144,\n 90,\n 99,\n 33,\n 247,\n 50,\n 214,\n 249\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint of the stable asset\"\n ]\n },\n {\n \"name\": \"stablePool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"initializeUnderlyingPool\",\n \"discriminator\": [\n 14,\n 86,\n 241,\n 157,\n 12,\n 229,\n 171,\n 163\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"docs\": [\n \"The wallet address signing the transaction\"\n ],\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset. Calls will be settled in this asset.\"\n ]\n },\n {\n \"name\": \"underlyingPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"mintOptions\",\n \"discriminator\": [\n 48,\n 123,\n 197,\n 59,\n 160,\n 199,\n 75,\n 150\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"minterCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"optionDestination\",\n \"writable\": true\n },\n {\n \"name\": \"writerDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"mintOptionsV2\",\n \"discriminator\": [\n 249,\n 84,\n 107,\n 193,\n 157,\n 119,\n 210,\n 190\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"minterCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"vaultCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"vaultAuthority\",\n \"writable\": true\n },\n {\n \"name\": \"optionDestination\",\n \"writable\": true\n },\n {\n \"name\": \"writerDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"preCreateEuroMeta\",\n \"discriminator\": [\n 144,\n 161,\n 76,\n 176,\n 227,\n 97,\n 81,\n 174\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"stableMint\"\n },\n {\n \"name\": \"underlyingMint\"\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"callOptionMint\",\n \"writable\": true\n },\n {\n \"name\": \"callWriterMint\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"expirationDataBump\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"preInitSerumMarket\",\n \"discriminator\": [\n 76,\n 6,\n 159,\n 50,\n 147,\n 186,\n 193,\n 223\n ],\n \"accounts\": [\n {\n \"name\": \"userAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"pcMint\"\n },\n {\n \"name\": \"optionMint\"\n },\n {\n \"name\": \"vaultSigner\"\n },\n {\n \"name\": \"coinVault\",\n \"writable\": true\n },\n {\n \"name\": \"pcVault\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"setExpirationPrice\",\n \"discriminator\": [\n 83,\n 210,\n 157,\n 170,\n 44,\n 1,\n 80,\n 109\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"expirationData\",\n \"writable\": true\n },\n {\n \"name\": \"priceOracle\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"settleExpiredOptionV2\",\n \"discriminator\": [\n 93,\n 152,\n 134,\n 107,\n 97,\n 15,\n 215,\n 218\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredOptions\",\n \"discriminator\": [\n 68,\n 203,\n 65,\n 23,\n 67,\n 152,\n 142,\n 56\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"collateralMint\"\n },\n {\n \"name\": \"optionSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredWriters\",\n \"discriminator\": [\n 193,\n 172,\n 151,\n 210,\n 87,\n 237,\n 226,\n 29\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"collateralMint\"\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n },\n {\n \"name\": \"settleExpiredWritersV2\",\n \"discriminator\": [\n 231,\n 50,\n 25,\n 221,\n 92,\n 88,\n 78,\n 252\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"signer\": true\n },\n {\n \"name\": \"euroMeta\"\n },\n {\n \"name\": \"expirationData\"\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerSource\",\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"collateralDestination\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"euroMeta\",\n \"discriminator\": [\n 143,\n 142,\n 75,\n 68,\n 96,\n 251,\n 84,\n 36\n ]\n },\n {\n \"name\": \"euroMetaV2\",\n \"discriminator\": [\n 235,\n 100,\n 34,\n 74,\n 90,\n 205,\n 244,\n 43\n ]\n },\n {\n \"name\": \"expirationData\",\n \"discriminator\": [\n 138,\n 118,\n 169,\n 12,\n 44,\n 29,\n 42,\n 126\n ]\n }\n ],\n \"types\": [\n {\n \"name\": \"euroMeta\",\n \"serialization\": \"bytemuckunsafe\",\n \"repr\": {\n \"kind\": \"rust\",\n \"packed\": true\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stablePool\",\n \"docs\": [\n \"The stable pool's address\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"The TokenAccount that holds underlying asset deposits\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"The key for the oracle mapping\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint key for some stable coin that is pegged to the oracle\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"callOptionMint\",\n \"docs\": [\n \"The mint for the CALL option tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"callWriterMint\",\n \"docs\": [\n \"The mint for the CALL writer tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"putOptionMint\",\n \"docs\": [\n \"The mint for the PUT option tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"putWriterMint\",\n \"docs\": [\n \"The mint for the PUT writer tokens\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"expirationData\",\n \"docs\": [\n \"The address for the associated ExpirationData. Stored to make validations computationally\",\n \"efficient.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"strikePrice\",\n \"docs\": [\n \"The strike price with decimals price_decimals\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The Unix Timestamp for the expiration\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"docs\": [\n \"The amount of underlying assets per 1 OptionToken,\",\n \"denoted in the underlying assets decimals.\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingDecimals\",\n \"docs\": [\n \"The number of decimals on the underlying, read from the Mint on creation\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"stableDecimals\",\n \"docs\": [\n \"The decimals of the stable mint\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_price & price_at_expiration. This is\",\n \"required to normalize the strike price with the oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the EuroMeta\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier\"\n ],\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"euroMetaCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"euroMeta\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"euroMetaV2\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint key for some stable coin. Oracle should use this token for pricing. Use of a\",\n \"different token is not recommended (e.g. USDT when Oracle uses USDT), as prices may deviate\",\n \"slightly even for stablecoins.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"collateralPool\",\n \"docs\": [\n \"The collateral pool's address.\",\n \"\",\n \"The token held in the pool depends on the collateral type in use: PUTs and PUT spreads\",\n \"use the stable asset, CALLs and CALL spreads use underlying. Some CALL Spreads can also\",\n \"use stable. For example, a SOL call spread market may trade in SOL, or USDC.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"Oracle's address. Chainlink and Pyth oracles are supported at this time. Matches\",\n \"ExpirationData's oracle\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"writerMint\",\n \"docs\": [\n \"The mint for the writer tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionMint\",\n \"docs\": [\n \"The mint for the option tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"expirationData\",\n \"docs\": [\n \"The address for the associated ExpirationData. Stored to make validations computationally\",\n \"efficient.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"strikePrices\",\n \"docs\": [\n \"Strike price(s). For Calls/Puts, a single value. For vertical spreads, two values. The\",\n \"lower strike price is first, followed by the higher price. Uses price_decimals\"\n ],\n \"type\": {\n \"vec\": \"u64\"\n }\n },\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The Unix Timestamp for the expiration, in seconds. Must match ExpirationData's\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"docs\": [\n \"The amount of underlying assets per 1 OptionToken,\",\n \"denoted in the underlying assets decimals.\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingDecimals\",\n \"docs\": [\n \"The number of decimals on the underlying, read from the mint on creation\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"stableDecimals\",\n \"docs\": [\n \"The decimals of the stable mint, read from the mint on creation.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_prices & price_at_expiration. This is\",\n \"required to normalize the strike price with oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the EuroMeta\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier. Pyth = 0, Switchboard = 1\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"docs\": [\n \"Option type of the euro meta: CALL, PUT, LongCallSpread, LongPutSpread\"\n ],\n \"type\": {\n \"defined\": {\n \"name\": \"optionTypeV2\"\n }\n }\n }\n ]\n }\n },\n {\n \"name\": \"expirationData\",\n \"serialization\": \"bytemuckunsafe\",\n \"repr\": {\n \"kind\": \"rust\",\n \"packed\": true\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The expiration time\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"The aggregate price oracle for pyth or switchboard\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"priceAtExpiration\",\n \"docs\": [\n \"The price, in price_decimals, at the time of expiration\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceSetAtTime\",\n \"docs\": [\n \"The time at which the price_at_expiration was set.\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_price & price_at_expiration. This is\",\n \"required to normalize the strike price with the oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceSet\",\n \"docs\": [\n \"Flag for easy memcmp filtering\"\n ],\n \"type\": \"bool\"\n },\n {\n \"name\": \"bump\",\n \"docs\": [\n \"bump seed\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier\"\n ],\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"expirationDataCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"expirationData\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"optionTypeV2\",\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"call\"\n },\n {\n \"name\": \"put\"\n },\n {\n \"name\": \"longCallSpread\"\n },\n {\n \"name\": \"longPutSpread\"\n }\n ]\n }\n },\n {\n \"name\": \"stablePoolCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"stablePool\",\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"underlyingPoolCreated\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingPool\",\n \"type\": \"pubkey\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WA8iDE"} \ No newline at end of file diff --git a/dist/src/types/option_auction.js.map b/dist/src/types/option_auction.js.map index 6cc41c7..d498827 100644 --- a/dist/src/types/option_auction.js.map +++ b/dist/src/types/option_auction.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/types/option_auction.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/option_auction.json`.\n */\nexport type OptionAuction = {\n \"address\": \"BTxfkFZ7bGfse162Tz3hHpd9NxJJxYrFMj63iFmVDs7i\",\n \"metadata\": {\n \"name\": \"optionAuction\",\n \"version\": \"0.1.0\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"cancelAuction\",\n \"discriminator\": [\n 156,\n 43,\n 197,\n 110,\n 218,\n 105,\n 143,\n 182\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"creatorAssetAccount\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"closeAuction\",\n \"discriminator\": [\n 225,\n 129,\n 91,\n 48,\n 215,\n 73,\n 203,\n 172\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"creatorTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"creatorAssetAccount\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"winnerAssetAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"initializeAuction\",\n \"discriminator\": [\n 37,\n 10,\n 117,\n 197,\n 208,\n 88,\n 117,\n 62\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"tokenMint\"\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"creatorTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n }\n ],\n \"args\": [\n {\n \"name\": \"auctionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n }\n ]\n },\n {\n \"name\": \"placeBid\",\n \"discriminator\": [\n 238,\n 77,\n 148,\n 91,\n 200,\n 151,\n 92,\n 146\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"bidder\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"bidderTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"bidAmount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"discriminator\": [\n 218,\n 94,\n 247,\n 242,\n 126,\n 233,\n 131,\n 81\n ]\n }\n ],\n \"errors\": [\n {\n \"code\": 6000,\n \"name\": \"auctionNotActive\",\n \"msg\": \"Auction is not active.\"\n },\n {\n \"code\": 6001,\n \"name\": \"auctionEnded\",\n \"msg\": \"Auction has already ended.\"\n },\n {\n \"code\": 6002,\n \"name\": \"bidTooLow\",\n \"msg\": \"Your bid is too low.\"\n },\n {\n \"code\": 6003,\n \"name\": \"auctionStillActive\",\n \"msg\": \"Auction is still active.\"\n },\n {\n \"code\": 6004,\n \"name\": \"unauthorized\",\n \"msg\": \"Unauthorized action.\"\n }\n ],\n \"types\": [\n {\n \"name\": \"auction\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"creator\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": {\n \"defined\": {\n \"name\": \"auctionType\"\n }\n }\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"startTime\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"highestBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"highestBidder\",\n \"type\": {\n \"option\": \"pubkey\"\n }\n },\n {\n \"name\": \"isActive\",\n \"type\": \"bool\"\n },\n {\n \"name\": \"tokenMint\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"assetHolder\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"auctionBump\",\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"auctionType\",\n \"repr\": {\n \"kind\": \"rust\"\n },\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"english\"\n },\n {\n \"name\": \"dutch\"\n },\n {\n \"name\": \"sealedBid\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WAuVE"} \ No newline at end of file +{"version":3,"sources":["../../../src/types/option_auction.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/option_auction.json`.\n */\nexport type OptionAuction = {\n \"address\": \"BTxfkFZ7bGfse162Tz3hHpd9NxJJxYrFMj63iFmVDs7i\",\n \"metadata\": {\n \"name\": \"optionAuction\",\n \"version\": \"0.1.0\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"cancelAuction\",\n \"discriminator\": [\n 156,\n 43,\n 197,\n 110,\n 218,\n 105,\n 143,\n 182\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"creatorAssetAccount\",\n \"writable\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"closeAuction\",\n \"discriminator\": [\n 225,\n 129,\n 91,\n 48,\n 215,\n 73,\n 203,\n 172\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"creatorTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"creatorAssetAccount\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"winnerAssetAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"initializeAuction\",\n \"discriminator\": [\n 37,\n 10,\n 117,\n 197,\n 208,\n 88,\n 117,\n 62\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"creator\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"tokenMint\"\n },\n {\n \"name\": \"assetHolder\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"creatorTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n }\n ],\n \"args\": [\n {\n \"name\": \"auctionNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n }\n ]\n },\n {\n \"name\": \"placeBid\",\n \"discriminator\": [\n 238,\n 77,\n 148,\n 91,\n 200,\n 151,\n 92,\n 146\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"writable\": true\n },\n {\n \"name\": \"bidder\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"bidderTokenAccount\",\n \"writable\": true\n },\n {\n \"name\": \"vault\",\n \"writable\": true\n },\n {\n \"name\": \"highestBidderTokenAccount\",\n \"writable\": true,\n \"optional\": true\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"bidAmount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"discriminator\": [\n 218,\n 94,\n 247,\n 242,\n 126,\n 233,\n 131,\n 81\n ]\n }\n ],\n \"errors\": [\n {\n \"code\": 6000,\n \"name\": \"auctionNotActive\",\n \"msg\": \"Auction is not active.\"\n },\n {\n \"code\": 6001,\n \"name\": \"auctionEnded\",\n \"msg\": \"Auction has already ended.\"\n },\n {\n \"code\": 6002,\n \"name\": \"bidTooLow\",\n \"msg\": \"Your bid is too low.\"\n },\n {\n \"code\": 6003,\n \"name\": \"auctionStillActive\",\n \"msg\": \"Auction is still active.\"\n },\n {\n \"code\": 6004,\n \"name\": \"unauthorized\",\n \"msg\": \"Unauthorized action.\"\n }\n ],\n \"types\": [\n {\n \"name\": \"auction\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"creator\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": {\n \"defined\": {\n \"name\": \"auctionType\"\n }\n }\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"startTime\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"highestBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"auctionNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"highestBidder\",\n \"type\": {\n \"option\": \"pubkey\"\n }\n },\n {\n \"name\": \"isActive\",\n \"type\": \"bool\"\n },\n {\n \"name\": \"tokenMint\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"assetHolder\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"auctionBump\",\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"auctionType\",\n \"repr\": {\n \"kind\": \"rust\"\n },\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"english\"\n },\n {\n \"name\": \"dutch\"\n },\n {\n \"name\": \"sealedBid\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WA+VE"} \ No newline at end of file diff --git a/dist/src/types/vaults.js.map b/dist/src/types/vaults.js.map index 70e68eb..99d67b4 100644 --- a/dist/src/types/vaults.js.map +++ b/dist/src/types/vaults.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/types/vaults.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/vaults.json`.\n */\nexport type Vaults = {\n \"address\": \"doVLtcguouVHW5c6odaNrbcHAUEd2fkMGxq28efDptj\",\n \"metadata\": {\n \"name\": \"vaults\",\n \"version\": \"0.1.0\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"deposit\",\n \"discriminator\": [\n 242,\n 35,\n 198,\n 137,\n 82,\n 225,\n 242,\n 182\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"payerVaultLpMintAta\",\n \"writable\": true\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"Deposit pool for the underlying asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"payerUnderlyingAta\",\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"Deposit pool for the quote asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"payerQuoteAta\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"depositAmount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"initialize\",\n \"discriminator\": [\n 175,\n 175,\n 109,\n 31,\n 13,\n 152,\n 155,\n 237\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"Deposit pool for the underlying asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"Deposit pool for the quote asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"startCycle\",\n \"discriminator\": [\n 203,\n 152,\n 115,\n 167,\n 17,\n 252,\n 73,\n 86\n ],\n \"accounts\": [\n {\n \"name\": \"vaultAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"optionCycle\",\n \"writable\": true\n },\n {\n \"name\": \"vaultOptionTokenAccount\",\n \"docs\": [\n \"The vault's token account that will receive the minted options\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"vaultWriterTokenAccount\",\n \"docs\": [\n \"The vault's token account that will receive the writer tokens\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"auctionVault\",\n \"docs\": [\n \"The vault account\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"creatorTokenAccount\",\n \"docs\": [\n \"The creator token account\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\"\n },\n {\n \"name\": \"stableMint\"\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"this underlying pool is of the defi option vaults program, not leverage.fun engine\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"stablePool\",\n \"docs\": [\n \"this stable pool is of the defi option vaults program, not leverage.fun engine\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"expirationData\",\n \"writable\": true\n },\n {\n \"name\": \"oracle\"\n },\n {\n \"name\": \"auctionState\",\n \"writable\": true\n },\n {\n \"name\": \"euroPrimitiveProgram\",\n \"docs\": [\n \"Euro primitive program for minting options\"\n ]\n },\n {\n \"name\": \"optionAuctionProgram\",\n \"docs\": [\n \"Option auction program for starting the auction\"\n ]\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"rent\"\n }\n ],\n \"args\": [\n {\n \"name\": \"cycleNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionAmount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n }\n ]\n },\n {\n \"name\": \"withdraw\",\n \"discriminator\": [\n 183,\n 18,\n 70,\n 156,\n 148,\n 109,\n 161,\n 34\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"payerVaultLpMintAta\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"writable\": true\n },\n {\n \"name\": \"payerUnderlyingAta\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"coveredCallBaseVault\",\n \"discriminator\": [\n 138,\n 80,\n 190,\n 45,\n 22,\n 116,\n 53,\n 30\n ]\n },\n {\n \"name\": \"optionCycle\",\n \"discriminator\": [\n 57,\n 38,\n 196,\n 146,\n 11,\n 164,\n 132,\n 183\n ]\n }\n ],\n \"errors\": [\n {\n \"code\": 6000,\n \"name\": \"vaultNotInitialized\",\n \"msg\": \"The expiration is in the past\"\n },\n {\n \"code\": 6001,\n \"name\": \"depositAmountZero\",\n \"msg\": \"The deposit amount is zero\"\n },\n {\n \"code\": 6002,\n \"name\": \"premiumZero\",\n \"msg\": \"The premium amount is zero\"\n },\n {\n \"code\": 6003,\n \"name\": \"insufficientVaultLp\",\n \"msg\": \"Insufficient vault lp\"\n },\n {\n \"code\": 6004,\n \"name\": \"withdrawAmountZero\",\n \"msg\": \"The withdraw amount is zero\"\n },\n {\n \"code\": 6005,\n \"name\": \"mathOverflow\",\n \"msg\": \"Math overflow\"\n },\n {\n \"code\": 6006,\n \"name\": \"someError\",\n \"msg\": \"\"\n }\n ],\n \"types\": [\n {\n \"name\": \"coveredCallBaseVault\",\n \"serialization\": \"bytemuck\",\n \"repr\": {\n \"kind\": \"c\"\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"totalDepositedAssets\",\n \"docs\": [\n \"Total amount of underlying assets deposited in the vault\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"totalIssuedShares\",\n \"docs\": [\n \"Total shares issued to depositors\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"currentOptionStrikePrice\",\n \"docs\": [\n \"Current strike price of the options being sold (in smallest units, e.g., lamports)\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"currentOptionExpiry\",\n \"docs\": [\n \"Expiration timestamp of the current options (Unix timestamp)\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"totalPremiumCollected\",\n \"docs\": [\n \"Total option premiums collected (in smallest units)\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"transferWindow\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"startTransferTime\",\n \"docs\": [\n \"time at which withdrawals began\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"endTransferTime\",\n \"docs\": [\n \"minimum time at which withdrawals end\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"isInitialized\",\n \"docs\": [\n \"Indicates if the vault has been initialized, 0 - no, 1 - yes\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the vault\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"vaultLpMintBump\",\n \"docs\": [\n \"The bump for vault lp mint\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"poolAuthorityBump\",\n \"docs\": [\n \"The bump for pool authority\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"vaultMintAuthorityBump\",\n \"docs\": [\n \"The bump for vault mint authority\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"padding\",\n \"type\": {\n \"array\": [\n \"u8\",\n 3\n ]\n }\n },\n {\n \"name\": \"manager\",\n \"docs\": [\n \"The authority or manager of the vault\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultLpMint\",\n \"docs\": [\n \"The vault's LP token mint\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The SPL token mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"quoteMint\",\n \"docs\": [\n \"The SPL token mint for the vault shares issued to depositors\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"The SPL token account holding the underlying assets\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionMint\",\n \"docs\": [\n \"The SPL token mint of the option token\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"The SPL token account holding premiums collected from selling options\"\n ],\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"optionCycle\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"startTimestamp\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"endTimestamp\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"isActive\",\n \"type\": \"bool\"\n },\n {\n \"name\": \"optionMint\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"auctionState\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultAuthority\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"cycleNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"euroMeta\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WA2qBE"} \ No newline at end of file +{"version":3,"sources":["../../../src/types/vaults.ts"],"sourcesContent":["/**\n * Program IDL in camelCase format in order to be used in JS/TS.\n *\n * Note that this is only a type helper and is not the actual IDL. The original\n * IDL can be found at `target/idl/vaults.json`.\n */\nexport type Vaults = {\n \"address\": \"doVLtcguouVHW5c6odaNrbcHAUEd2fkMGxq28efDptj\",\n \"metadata\": {\n \"name\": \"vaults\",\n \"version\": \"0.1.0\",\n \"spec\": \"0.1.0\",\n \"description\": \"Created with Anchor\"\n },\n \"instructions\": [\n {\n \"name\": \"deposit\",\n \"discriminator\": [\n 242,\n 35,\n 198,\n 137,\n 82,\n 225,\n 242,\n 182\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"payerVaultLpMintAta\",\n \"writable\": true\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"Deposit pool for the underlying asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"payerUnderlyingAta\",\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"Deposit pool for the quote asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"payerQuoteAta\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"depositAmount\",\n \"type\": \"u64\"\n }\n ]\n },\n {\n \"name\": \"initialize\",\n \"discriminator\": [\n 175,\n 175,\n 109,\n 31,\n 13,\n 152,\n 155,\n 237\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"Deposit pool for the underlying asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"Deposit pool for the quote asset\",\n \"Should be initialized before calling this instruction\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": []\n },\n {\n \"name\": \"startCycle\",\n \"discriminator\": [\n 203,\n 152,\n 115,\n 167,\n 17,\n 252,\n 73,\n 86\n ],\n \"accounts\": [\n {\n \"name\": \"vaultAuthority\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"optionCycle\",\n \"writable\": true\n },\n {\n \"name\": \"vaultOptionTokenAccount\",\n \"docs\": [\n \"The vault's token account that will receive the minted options\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"vaultWriterTokenAccount\",\n \"docs\": [\n \"The vault's token account that will receive the writer tokens\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"collateralPool\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"this underlying pool is of the defi option vaults program, not leverage.fun engine\"\n ],\n \"writable\": true\n },\n {\n \"name\": \"vaultCollateral\",\n \"writable\": true\n },\n {\n \"name\": \"vaultPoolAuthority\",\n \"writable\": true\n },\n {\n \"name\": \"euroMeta\",\n \"writable\": true\n },\n {\n \"name\": \"optionMint\",\n \"writable\": true\n },\n {\n \"name\": \"writerMint\",\n \"writable\": true\n },\n {\n \"name\": \"auctionState\",\n \"writable\": true\n },\n {\n \"name\": \"euroPrimitiveProgram\",\n \"docs\": [\n \"Euro primitive program for minting options\"\n ]\n },\n {\n \"name\": \"systemProgram\"\n },\n {\n \"name\": \"tokenProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"cycleNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"optionAmount\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n }\n ]\n },\n {\n \"name\": \"withdraw\",\n \"discriminator\": [\n 183,\n 18,\n 70,\n 156,\n 148,\n 109,\n 161,\n 34\n ],\n \"accounts\": [\n {\n \"name\": \"payer\",\n \"writable\": true,\n \"signer\": true\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"writable\": true\n },\n {\n \"name\": \"vaultLpMint\",\n \"writable\": true\n },\n {\n \"name\": \"payerVaultLpMintAta\",\n \"writable\": true\n },\n {\n \"name\": \"vaultMintAuthority\"\n },\n {\n \"name\": \"authority\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingMint\",\n \"writable\": true\n },\n {\n \"name\": \"quoteMint\",\n \"writable\": true\n },\n {\n \"name\": \"underlyingPool\",\n \"writable\": true\n },\n {\n \"name\": \"payerUnderlyingAta\",\n \"writable\": true\n },\n {\n \"name\": \"poolAuthority\",\n \"docs\": [\n \"The general pool authority for the protocol\"\n ]\n },\n {\n \"name\": \"tokenProgram\"\n },\n {\n \"name\": \"systemProgram\"\n }\n ],\n \"args\": [\n {\n \"name\": \"amount\",\n \"type\": \"u64\"\n }\n ]\n }\n ],\n \"accounts\": [\n {\n \"name\": \"auction\",\n \"discriminator\": [\n 218,\n 94,\n 247,\n 242,\n 126,\n 233,\n 131,\n 81\n ]\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"discriminator\": [\n 138,\n 80,\n 190,\n 45,\n 22,\n 116,\n 53,\n 30\n ]\n },\n {\n \"name\": \"euroMetaV2\",\n \"discriminator\": [\n 235,\n 100,\n 34,\n 74,\n 90,\n 205,\n 244,\n 43\n ]\n },\n {\n \"name\": \"optionCycle\",\n \"discriminator\": [\n 57,\n 38,\n 196,\n 146,\n 11,\n 164,\n 132,\n 183\n ]\n }\n ],\n \"errors\": [\n {\n \"code\": 6000,\n \"name\": \"vaultNotInitialized\",\n \"msg\": \"The expiration is in the past\"\n },\n {\n \"code\": 6001,\n \"name\": \"depositAmountZero\",\n \"msg\": \"The deposit amount is zero\"\n },\n {\n \"code\": 6002,\n \"name\": \"premiumZero\",\n \"msg\": \"The premium amount is zero\"\n },\n {\n \"code\": 6003,\n \"name\": \"insufficientVaultLp\",\n \"msg\": \"Insufficient vault lp\"\n },\n {\n \"code\": 6004,\n \"name\": \"withdrawAmountZero\",\n \"msg\": \"The withdraw amount is zero\"\n },\n {\n \"code\": 6005,\n \"name\": \"mathOverflow\",\n \"msg\": \"Math overflow\"\n },\n {\n \"code\": 6006,\n \"name\": \"someError\",\n \"msg\": \"\"\n }\n ],\n \"types\": [\n {\n \"name\": \"auction\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"creator\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"auctionType\",\n \"type\": {\n \"defined\": {\n \"name\": \"auctionType\"\n }\n }\n },\n {\n \"name\": \"startingBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"duration\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"startTime\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"highestBid\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"highestBidder\",\n \"type\": {\n \"option\": \"pubkey\"\n }\n },\n {\n \"name\": \"isActive\",\n \"type\": \"bool\"\n },\n {\n \"name\": \"tokenMint\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"assetHolder\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultBump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"auctionBump\",\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"auctionType\",\n \"repr\": {\n \"kind\": \"rust\"\n },\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"english\"\n },\n {\n \"name\": \"dutch\"\n },\n {\n \"name\": \"sealedBid\"\n }\n ]\n }\n },\n {\n \"name\": \"coveredCallBaseVault\",\n \"serialization\": \"bytemuck\",\n \"repr\": {\n \"kind\": \"c\"\n },\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"totalDepositedAssets\",\n \"docs\": [\n \"Total amount of underlying assets deposited in the vault\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"totalIssuedShares\",\n \"docs\": [\n \"Total shares issued to depositors\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"currentOptionStrikePrice\",\n \"docs\": [\n \"Current strike price of the options being sold (in smallest units, e.g., lamports)\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"currentOptionExpiry\",\n \"docs\": [\n \"Expiration timestamp of the current options (Unix timestamp)\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"totalPremiumCollected\",\n \"docs\": [\n \"Total option premiums collected (in smallest units)\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"transferWindow\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"startTransferTime\",\n \"docs\": [\n \"time at which withdrawals began\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"endTransferTime\",\n \"docs\": [\n \"minimum time at which withdrawals end\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"isInitialized\",\n \"docs\": [\n \"Indicates if the vault has been initialized, 0 - no, 1 - yes\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the vault\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"vaultLpMintBump\",\n \"docs\": [\n \"The bump for vault lp mint\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"poolAuthorityBump\",\n \"docs\": [\n \"The bump for pool authority\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"vaultMintAuthorityBump\",\n \"docs\": [\n \"The bump for vault mint authority\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"padding\",\n \"type\": {\n \"array\": [\n \"u8\",\n 3\n ]\n }\n },\n {\n \"name\": \"manager\",\n \"docs\": [\n \"The authority or manager of the vault\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultLpMint\",\n \"docs\": [\n \"The vault's LP token mint\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The SPL token mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"quoteMint\",\n \"docs\": [\n \"The SPL token mint for the vault shares issued to depositors\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"underlyingPool\",\n \"docs\": [\n \"The SPL token account holding the underlying assets\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionMint\",\n \"docs\": [\n \"The SPL token mint of the option token\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"premiumPool\",\n \"docs\": [\n \"The SPL token account holding premiums collected from selling options\"\n ],\n \"type\": \"pubkey\"\n }\n ]\n }\n },\n {\n \"name\": \"euroMetaV2\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"underlyingMint\",\n \"docs\": [\n \"The mint of the underlying asset\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"stableMint\",\n \"docs\": [\n \"The mint key for some stable coin. Oracle should use this token for pricing. Use of a\",\n \"different token is not recommended (e.g. USDT when Oracle uses USDT), as prices may deviate\",\n \"slightly even for stablecoins.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"collateralPool\",\n \"docs\": [\n \"The collateral pool's address.\",\n \"\",\n \"The token held in the pool depends on the collateral type in use: PUTs and PUT spreads\",\n \"use the stable asset, CALLs and CALL spreads use underlying. Some CALL Spreads can also\",\n \"use stable. For example, a SOL call spread market may trade in SOL, or USDC.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"oracle\",\n \"docs\": [\n \"Oracle's address. Chainlink and Pyth oracles are supported at this time. Matches\",\n \"ExpirationData's oracle\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"writerMint\",\n \"docs\": [\n \"The mint for the writer tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionMint\",\n \"docs\": [\n \"The mint for the option tokens, initialized on creation\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"expirationData\",\n \"docs\": [\n \"The address for the associated ExpirationData. Stored to make validations computationally\",\n \"efficient.\"\n ],\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"strikePrices\",\n \"docs\": [\n \"Strike price(s). For Calls/Puts, a single value. For vertical spreads, two values. The\",\n \"lower strike price is first, followed by the higher price. Uses price_decimals\"\n ],\n \"type\": {\n \"vec\": \"u64\"\n }\n },\n {\n \"name\": \"expiration\",\n \"docs\": [\n \"The Unix Timestamp for the expiration, in seconds. Must match ExpirationData's\"\n ],\n \"type\": \"i64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"docs\": [\n \"The amount of underlying assets per 1 OptionToken,\",\n \"denoted in the underlying assets decimals.\"\n ],\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingDecimals\",\n \"docs\": [\n \"The number of decimals on the underlying, read from the mint on creation\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"stableDecimals\",\n \"docs\": [\n \"The decimals of the stable mint, read from the mint on creation.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"priceDecimals\",\n \"docs\": [\n \"The number of decimals in the strike_prices & price_at_expiration. This is\",\n \"required to normalize the strike price with oracles.\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"bumpSeed\",\n \"docs\": [\n \"The bump seed for the EuroMeta\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"oracleProviderId\",\n \"docs\": [\n \"An oracle provider identifier. Pyth = 0, Switchboard = 1\"\n ],\n \"type\": \"u8\"\n },\n {\n \"name\": \"optionType\",\n \"docs\": [\n \"Option type of the euro meta: CALL, PUT, LongCallSpread, LongPutSpread\"\n ],\n \"type\": {\n \"defined\": {\n \"name\": \"optionTypeV2\"\n }\n }\n }\n ]\n }\n },\n {\n \"name\": \"optionCycle\",\n \"type\": {\n \"kind\": \"struct\",\n \"fields\": [\n {\n \"name\": \"startTimestamp\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"endTimestamp\",\n \"type\": \"i64\"\n },\n {\n \"name\": \"isActive\",\n \"type\": \"bool\"\n },\n {\n \"name\": \"optionMint\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"auctionState\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"vaultAuthority\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"cycleNumber\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"bump\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"strikePrice\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"underlyingAmountPerContract\",\n \"type\": \"u64\"\n },\n {\n \"name\": \"priceDecimals\",\n \"type\": \"u8\"\n },\n {\n \"name\": \"euroMeta\",\n \"type\": \"pubkey\"\n },\n {\n \"name\": \"optionType\",\n \"type\": \"u8\"\n }\n ]\n }\n },\n {\n \"name\": \"optionTypeV2\",\n \"type\": {\n \"kind\": \"enum\",\n \"variants\": [\n {\n \"name\": \"call\"\n },\n {\n \"name\": \"put\"\n },\n {\n \"name\": \"longCallSpread\"\n },\n {\n \"name\": \"longPutSpread\"\n }\n ]\n }\n }\n ]\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":"AAAA;;;;;CAKC,GACD,WAq5BE"} \ No newline at end of file diff --git a/dist/src/utils/index.js b/dist/src/utils/index.js index a3d7a7c..3782411 100644 --- a/dist/src/utils/index.js +++ b/dist/src/utils/index.js @@ -43,6 +43,19 @@ export async function getAtaForUser(optionMint, writerMint, underlyingMint, acco const optionMintAta = getAssociatedTokenAddressSync(optionMint, accountOwner, allowOwnerOffCurve); const writerMintAta = getAssociatedTokenAddressSync(writerMint, accountOwner, allowOwnerOffCurve); const underlyingMintAta = getAssociatedTokenAddressSync(underlyingMint, accountOwner, allowOwnerOffCurve); + console.log('optionMint:', optionMint.toBase58()); + console.log('writerMint:', writerMint.toBase58()); + console.log('underlyingMint:', underlyingMint.toBase58()); + // Validate that the provided addresses are actually token mints + const mintInfos = await connection.getMultipleAccountsInfo([ + optionMint, + writerMint, + underlyingMint + ]); + if (mintInfos.some((info)=>!info)) { + console.error('One or more mint addresses are invalid, trying again...'); + await sleep(1000); + } console.log('optionMintAta:', optionMintAta.toBase58()); console.log('writerMintAta:', writerMintAta.toBase58()); console.log('underlyingMintAta:', underlyingMintAta.toBase58()); diff --git a/dist/src/utils/index.js.map b/dist/src/utils/index.js.map index 0691c3d..1b2659a 100644 --- a/dist/src/utils/index.js.map +++ b/dist/src/utils/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import * as pdas from './pdas.js';\nimport * as programUtils from './programUtils.js';\n// import * as anchor from '@coral-xyz/anchor';\nimport axios from 'axios';\nimport Config from '../config.js';\nimport BN from 'bn.js';\nimport {\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddressSync,\n} from '@solana/spl-token';\nimport {\n Connection,\n PublicKey,\n Transaction,\n sendAndConfirmTransaction,\n} from '@solana/web3.js';\n\nexport { pdas, programUtils };\n\nconst connection = new Connection(Config.TESTNET_RPC_URL, 'confirmed');\n\nexport enum OptionTypeV2 {\n CALL = 0,\n PUT = 1,\n LONG_CALL_SPREAD = 2,\n LONG_PUT_SPREAD = 3,\n}\n\nexport const sleep = (ms: number) =>\n new Promise(resolve => setTimeout(resolve, ms));\n\nexport async function postTelegramMessage(txHash: string) {\n const url = `https://api.telegram.org/bot${Config.TELEGRAM_BOT_TOKEN}/sendMessage`;\n const message = `Minted call option via Leverage.fun expiring in 1 hour. Explorer: [tx link](https://eclipsescan.xyz/tx/${txHash}?cluster=testnet)`;\n\n const payload = {\n chat_id: Config.TELEGRAM_CHANNEL_ID,\n text: message,\n parse_mode: 'Markdown',\n };\n\n await axios.post(url, payload);\n}\nexport const serializeStrikePrices = (strikePrices: BN[]) => {\n let buffer = Buffer.from([]);\n strikePrices.forEach(async value => {\n const newBuffer = value.toArrayLike(Buffer, 'le', 8);\n // @ts-expect-error idk why this shows an error\n buffer = Buffer.concat([buffer, newBuffer]);\n });\n return buffer;\n};\n\nexport async function getAtaForUser(\n optionMint: PublicKey,\n writerMint: PublicKey,\n underlyingMint: PublicKey,\n accountOwner: PublicKey,\n allowOwnerOffCurve: boolean = false,\n) {\n try {\n console.log('Getting ATAs');\n\n const optionMintAta = getAssociatedTokenAddressSync(\n optionMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n const writerMintAta = getAssociatedTokenAddressSync(\n writerMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n const underlyingMintAta = getAssociatedTokenAddressSync(\n underlyingMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n\n console.log('optionMintAta:', optionMintAta.toBase58());\n console.log('writerMintAta:', writerMintAta.toBase58());\n console.log('underlyingMintAta:', underlyingMintAta.toBase58());\n\n // Check if accounts exist first\n const accounts = await connection.getMultipleAccountsInfo([\n optionMintAta,\n writerMintAta,\n underlyingMintAta,\n ]);\n\n const tx = new Transaction();\n\n // Only create ATAs that don't exist\n if (!accounts[0]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n optionMintAta,\n accountOwner,\n optionMint,\n ),\n );\n }\n\n if (!accounts[1]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n writerMintAta,\n accountOwner,\n writerMint,\n ),\n );\n }\n\n if (!accounts[2]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n underlyingMintAta,\n accountOwner,\n underlyingMint,\n ),\n );\n }\n\n // Only send transaction if there are instructions to execute\n if (tx.instructions.length > 0) {\n const sig = await sendAndConfirmTransaction(connection, tx, [\n Config.ADMIN_KEYPAIR,\n ]);\n console.log('ATAs created:', sig);\n } else {\n console.log('All ATAs already exist');\n }\n\n return { optionMintAta, writerMintAta, underlyingMintAta };\n } catch (e) {\n console.error('Error in getAtaForUser:', e);\n return null;\n }\n}\n"],"names":["pdas","programUtils","axios","Config","createAssociatedTokenAccountInstruction","getAssociatedTokenAddressSync","Connection","Transaction","sendAndConfirmTransaction","connection","TESTNET_RPC_URL","OptionTypeV2","sleep","ms","Promise","resolve","setTimeout","postTelegramMessage","txHash","url","TELEGRAM_BOT_TOKEN","message","payload","chat_id","TELEGRAM_CHANNEL_ID","text","parse_mode","post","serializeStrikePrices","strikePrices","buffer","Buffer","from","forEach","value","newBuffer","toArrayLike","concat","getAtaForUser","optionMint","writerMint","underlyingMint","accountOwner","allowOwnerOffCurve","console","log","optionMintAta","writerMintAta","underlyingMintAta","toBase58","accounts","getMultipleAccountsInfo","tx","add","ADMIN_KEYPAIR","publicKey","instructions","length","sig","e","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,UAAU,YAAY;AAClC,YAAYC,kBAAkB,oBAAoB;AAClD,+CAA+C;AAC/C,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,YAAY,eAAe;AAElC,SACEC,uCAAuC,EACvCC,6BAA6B,QACxB,oBAAoB;AAC3B,SACEC,UAAU,EAEVC,WAAW,EACXC,yBAAyB,QACpB,kBAAkB;AAEzB,SAASR,IAAI,EAAEC,YAAY,GAAG;AAE9B,MAAMQ,aAAa,IAAIH,WAAWH,OAAOO,eAAe,EAAE;;UAE9CC;;;;;GAAAA,iBAAAA;AAOZ,OAAO,MAAMC,QAAQ,CAACC,KACpB,IAAIC,QAAQC,CAAAA,UAAWC,WAAWD,SAASF,KAAK;AAElD,OAAO,eAAeI,oBAAoBC,MAAc;IACtD,MAAMC,MAAM,CAAC,4BAA4B,EAAEhB,OAAOiB,kBAAkB,CAAC,YAAY,CAAC;IAClF,MAAMC,UAAU,CAAC,uGAAuG,EAAEH,OAAO,iBAAiB,CAAC;IAEnJ,MAAMI,UAAU;QACdC,SAASpB,OAAOqB,mBAAmB;QACnCC,MAAMJ;QACNK,YAAY;IACd;IAEA,MAAMxB,MAAMyB,IAAI,CAACR,KAAKG;AACxB;AACA,OAAO,MAA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,GAAGI,YAAY,CAACC,MAAM,GAAG,GAAG;YAC9B,MAAMC,MAAM,MAAMlD,0BAA0BC,YAAY2C,IAAI;gBAC1DjD,OAAOmD,aAAa;aACrB;YACDV,QAAQC,GAAG,CAAC,iBAAiBa;QAC/B,OAAO;YACLd,QAAQC,GAAG,CAAC;QACd;QAEA,OAAO;YAAEC;YAAeC;YAAeC;QAAkB;IAC3D,EAAE,OAAOW,GAAG;QACVf,QAAQgB,KAAK,CAAC,2BAA2BD;QACzC,OAAO;IACT;AACF"} \ No newline at end of file +{"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["import * as pdas from './pdas.js';\nimport * as programUtils from './programUtils.js';\n// import * as anchor from '@coral-xyz/anchor';\nimport axios from 'axios';\nimport Config from '../config.js';\nimport BN from 'bn.js';\nimport {\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddressSync,\n} from '@solana/spl-token';\nimport {\n Connection,\n PublicKey,\n Transaction,\n sendAndConfirmTransaction,\n} from '@solana/web3.js';\n\nexport { pdas, programUtils };\n\nconst connection = new Connection(Config.TESTNET_RPC_URL, 'confirmed');\n\nexport enum OptionTypeV2 {\n CALL = 0,\n PUT = 1,\n LONG_CALL_SPREAD = 2,\n LONG_PUT_SPREAD = 3,\n}\n\nexport const sleep = (ms: number) =>\n new Promise(resolve => setTimeout(resolve, ms));\n\nexport async function postTelegramMessage(txHash: string) {\n const url = `https://api.telegram.org/bot${Config.TELEGRAM_BOT_TOKEN}/sendMessage`;\n const message = `Minted call option via Leverage.fun expiring in 1 hour. Explorer: [tx link](https://eclipsescan.xyz/tx/${txHash}?cluster=testnet)`;\n\n const payload = {\n chat_id: Config.TELEGRAM_CHANNEL_ID,\n text: message,\n parse_mode: 'Markdown',\n };\n\n await axios.post(url, payload);\n}\nexport const serializeStrikePrices = (strikePrices: BN[]) => {\n let buffer = Buffer.from([]);\n strikePrices.forEach(async value => {\n const newBuffer = value.toArrayLike(Buffer, 'le', 8);\n // @ts-expect-error idk why this shows an error\n buffer = Buffer.concat([buffer, newBuffer]);\n });\n return buffer;\n};\n\nexport async function getAtaForUser(\n optionMint: PublicKey,\n writerMint: PublicKey,\n underlyingMint: PublicKey,\n accountOwner: PublicKey,\n allowOwnerOffCurve: boolean = false,\n) {\n try {\n console.log('Getting ATAs');\n\n const optionMintAta = getAssociatedTokenAddressSync(\n optionMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n const writerMintAta = getAssociatedTokenAddressSync(\n writerMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n const underlyingMintAta = getAssociatedTokenAddressSync(\n underlyingMint,\n accountOwner,\n allowOwnerOffCurve,\n );\n\n console.log('optionMint:', optionMint.toBase58());\n console.log('writerMint:', writerMint.toBase58());\n console.log('underlyingMint:', underlyingMint.toBase58());\n\n // Validate that the provided addresses are actually token mints\n const mintInfos = await connection.getMultipleAccountsInfo([\n optionMint,\n writerMint,\n underlyingMint,\n ]);\n\n if (mintInfos.some(info => !info)) {\n console.error('One or more mint addresses are invalid, trying again...');\n await sleep(1000);\n }\n console.log('optionMintAta:', optionMintAta.toBase58());\n console.log('writerMintAta:', writerMintAta.toBase58());\n console.log('underlyingMintAta:', underlyingMintAta.toBase58());\n\n // Check if accounts exist first\n const accounts = await connection.getMultipleAccountsInfo([\n optionMintAta,\n writerMintAta,\n underlyingMintAta,\n ]);\n\n const tx = new Transaction();\n\n // Only create ATAs that don't exist\n if (!accounts[0]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n optionMintAta,\n accountOwner,\n optionMint,\n ),\n );\n }\n\n if (!accounts[1]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n writerMintAta,\n accountOwner,\n writerMint,\n ),\n );\n }\n\n if (!accounts[2]) {\n tx.add(\n createAssociatedTokenAccountInstruction(\n Config.ADMIN_KEYPAIR.publicKey,\n underlyingMintAta,\n accountOwner,\n underlyingMint,\n ),\n );\n }\n\n // Only send transaction if there are instructions to execute\n if (tx.instructions.length > 0) {\n const sig = await sendAndConfirmTransaction(connection, tx, [\n Config.ADMIN_KEYPAIR,\n ]);\n console.log('ATAs created:', sig);\n } else {\n console.log('All ATAs already exist');\n }\n\n return { optionMintAta, writerMintAta, underlyingMintAta };\n } catch (e) {\n console.error('Error in getAtaForUser:', e);\n return null;\n }\n}\n"],"names":["pdas","programUtils","axios","Config","createAssociatedTokenAccountInstruction","getAssociatedTokenAddressSync","Connection","Transaction","sendAndConfirmTransaction","connection","TESTNET_RPC_URL","OptionTypeV2","sleep","ms","Promise","resolve","setTimeout","postTelegramMessage","txHash","url","TELEGRAM_BOT_TOKEN","message","payload","chat_id","TELEGRAM_CHANNEL_ID","text","parse_mode","post","serializeStrikePrices","strikePrices","buffer","Buffer","from","forEach","value","newBuffer","toArrayLike","concat","getAtaForUser","optionMint","writerMint","underlyingMint","accountOwner","allowOwnerOffCurve","console","log","optionMintAta","writerMintAta","underlyingMintAta","toBase58","mintInfos","getMultipleAccountsInfo","some","info","error","accounts","tx","add","ADMIN_KEYPAIR","publicKey","instructions","length","sig","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,UAAU,YAAY;AAClC,YAAYC,kBAAkB,oBAAoB;AAClD,+CAA+C;AAC/C,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,YAAY,eAAe;AAElC,SACEC,uCAAuC,EACvCC,6BAA6B,QACxB,oBAAoB;AAC3B,SACEC,UAAU,EAEVC,WAAW,EACXC,yBAAyB,QACpB,kBAAkB;AAEzB,SAASR,IAAI,EAAEC,YAAY,GAAG;AAE9B,MAAMQ,aAAa,IAAIH,WAAWH,OAAOO,eAAe,EAAE;;UAE9CC;;;;;GAAAA,iBAAAA;AAOZ,OAAO,MAAMC,QAAQ,CAACC,KACpB,IAAIC,QA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d;QACAgC,QAAQC,GAAG,CAAC,kBAAkBC,cAAcG,QAAQ;QACpDL,QAAQC,GAAG,CAAC,kBAAkBE,cAAcE,QAAQ;QACpDL,QAAQC,GAAG,CAAC,sBAAsBG,kBAAkBC,QAAQ;QAE5D,gCAAgC;QAChC,MAAMM,WAAW,MAAM9C,WAAW0C,uBAAuB,CAAC;YACxDL;YACAC;YACAC;SACD;QAED,MAAMQ,KAAK,IAAIjD;QAEf,oCAAoC;QACpC,IAAI,CAACgD,QAAQ,CAAC,EAAE,EAAE;YAChBC,GAAGC,GAAG,CACJrD,wCACED,OAAOuD,aAAa,CAACC,SAAS,EAC9Bb,eACAJ,cACAH;QAGN;QAEA,IAAI,CAACgB,QAAQ,CAAC,EAAE,EAAE;YAChBC,GAAGC,GAAG,CACJrD,wCACED,OAAOuD,aAAa,CAACC,SAAS,EAC9BZ,eACAL,cACAF;QAGN;QAEA,IAAI,CAACe,QAAQ,CAAC,EAAE,EAAE;YAChBC,GAAGC,GAAG,CACJrD,wCACED,OAAOuD,aAAa,CAACC,SAAS,EAC9BX,mBACAN,cACAD;QAGN;QAEA,6DAA6D;QAC7D,IAAIe,GAAGI,YAAY,CAACC,MAAM,GAAG,GAAG;YAC9B,MAAMC,MAAM,MAAMtD,0BAA0BC,YAAY+C,IAAI;gBAC1DrD,OAAOuD,aAAa;aACrB;YACDd,QAAQC,GAAG,CAAC,iBAAiBiB;QAC/B,OAAO;YACLlB,QAAQC,GAAG,CAAC;QACd;QAEA,OAAO;YAAEC;YAAeC;YAAeC;QAAkB;IAC3D,EAAE,OAAOe,GAAG;QACVnB,QAAQU,KAAK,CAAC,2BAA2BS;QACzC,OAAO;IACT;AACF"} \ No newline at end of file diff --git a/dist/src/utils/pdas.js b/dist/src/utils/pdas.js index ad8c60c..90cdfc0 100644 --- a/dist/src/utils/pdas.js +++ b/dist/src/utils/pdas.js @@ -68,12 +68,19 @@ export function getAuctionProgramVaultPda(auction) { auction.toBuffer() ], Config.AUCTION_PROGRAM_ID); } -export function getAuctionStatePda(creator) { +export function getAuctionStatePda(creator, cycleNumber) { const textEncoder = new TextEncoder(); return PublicKey.findProgramAddressSync([ textEncoder.encode('auction'), - creator.toBuffer() + creator.toBuffer(), + cycleNumber.toArrayLike(Buffer, 'le', 8) ], Config.AUCTION_PROGRAM_ID); } +export function getPoolAuthorityVaultsPda() { + const textEncoder = new TextEncoder(); + return PublicKey.findProgramAddressSync([ + textEncoder.encode('pool_authority') + ], Config.VAULTS_PROGRAM_ID); +} //# sourceMappingURL=pdas.js.map \ No newline at end of file diff --git a/dist/src/utils/pdas.js.map b/dist/src/utils/pdas.js.map index 4482dcc..e66eee2 100644 --- a/dist/src/utils/pdas.js.map +++ b/dist/src/utils/pdas.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/utils/pdas.ts"],"sourcesContent":["import { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\nimport Config from '../config.js';\nimport { OptionTypeV2, serializeStrikePrices } from './index.js';\n\nexport function getExpirationDataPda(\n underlyingMint: PublicKey,\n expiration: BN,\n oracle: PublicKey,\n) {\n return PublicKey.findProgramAddressSync(\n [\n underlyingMint.toBuffer(),\n expiration.toArrayLike(Buffer, 'le', 8),\n oracle.toBuffer(),\n ],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getEuroMetaPda(\n underlyingMint: PublicKey,\n quoteMint: PublicKey,\n expiration: BN,\n optionType: OptionTypeV2,\n underlyingPool: PublicKey,\n strikePrices: BN[],\n) {\n return PublicKey.findProgramAddressSync(\n [\n underlyingMint.toBuffer(),\n quoteMint.toBuffer(),\n expiration.toArrayLike(Buffer, 'le', 8),\n new BN(optionType as number).toArrayLike(Buffer, 'le', 1),\n underlyingPool.toBuffer(),\n serializeStrikePrices(strikePrices),\n ],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getOptionMintPda(euroMeta: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [euroMeta.toBuffer(), textEncoder.encode('optionMint')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getWriterMintPda(euroMeta: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [euroMeta.toBuffer(), textEncoder.encode('writerMint')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getUnderlyingPoolPda(underlyingMint: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [underlyingMint.toBuffer(), textEncoder.encode('underlyingPool')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getQuotePoolPda(quoteMint: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [quoteMint.toBuffer(), textEncoder.encode('stablePool')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getPoolAuthorityPda() {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('poolAuthority')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getOptionCyclePda(vaultAuthority: PublicKey, cycleNumber: BN) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [\n textEncoder.encode('option_cycle'),\n vaultAuthority.toBuffer(),\n cycleNumber.toArrayLike(Buffer, 'le', 8),\n ],\n Config.VAULTS_PROGRAM_ID,\n );\n}\n\nexport function getAuctionProgramVaultPda(auction: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('vault'), auction.toBuffer()],\n Config.AUCTION_PROGRAM_ID,\n );\n}\n\nexport function getAuctionStatePda(creator: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('auction'), creator.toBuffer()],\n Config.AUCTION_PROGRAM_ID,\n );\n}\n"],"names":["PublicKey","BN","Config","serializeStrikePrices","getExpirationDataPda","underlyingMint","expiration","oracle","findProgramAddressSync","toBuffer","toArrayLike","Buffer","LEVERAGE_FUN_PROGRAM_ID","getEuroMetaPda","quoteMint","optionType","underlyingPool","strikePrices","getOptionMintPda","euroMeta","textEncoder","TextEncoder","encode","getWriterMintPda","getUnderlyingPoolPda","getQuotePoolPda","getPoolAuthorityPda","getOptionCyclePda","vaultAuthority","cycleNumber","VAULTS_PROGRAM_ID","getAuctionProgramVaultPda","auction","AUCTION_PROGRAM_ID","getAuctionStatePda","creator"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,QAAQ;AACvB,OAAOC,YAAY,eAAe;AAClC,SAAuBC,qBAAqB,QAAQ,aAAa;AAEjE,OAAO,SAASC,qBACdC,cAAyB,EACzBC,UAAc,EACdC,MAAiB;IAEjB,OAAOP,UAAUQ,sBAAsB,CACrC;QACEH,eAAeI,QAAQ;QACvBH,WAAWI,WAAW,CAACC,QAAQ,MAAM;QACrCJ,OAAOE,QAAQ;KAChB,EACDP,OAAOU,uBAAuB;AAElC;AAEA,OAAO,SAASC,eACdR,cAAyB,EACzBS,SAAoB,EACpBR,UAAc,EACdS,UAAwB,EACxBC,cAAyB,EACzBC,YAAkB;IAElB,OAAOjB,UAAUQ,sBAAsB,CACrC;QACEH,eAAeI,QAAQ;QACvBK,UAAUL,QAAQ;QAClBH,WAAWI,WAAW,CAACC,QAAQ,MAAM;QACrC,IAAIV,GAAGc,YAAsBL,WAAW,CAACC,QAAQ,MAAM;QACvDK,eAAeP,QAAQ;QACvBN,sBAAsBc;KACvB,EACDf,OAAOU,uBAAuB;AAElC;AAEA,OAAO,SAASM,iBAAiBC,QAAmB;IAClD,MAAMC,cAAc,IAAIC;IACxB,OAAOrB,UAAUQ,sBAAsB,CACrC;QAACW,SAASV,QAAQ;QAAIW,YAAYE,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OAAOrB,UAAUQ,sBAAsB,CACrC;QAACY,YAAYE,MAAM,CAAC;QAAYa,QAAQ1B,QAAQ;KAAG,EACnDP,OAAO+B,kBAAkB;AAE7B"} \ No newline at end of file +{"version":3,"sources":["../../../src/utils/pdas.ts"],"sourcesContent":["import { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\nimport Config from '../config.js';\nimport { OptionTypeV2, serializeStrikePrices } from './index.js';\n\nexport function getExpirationDataPda(\n underlyingMint: PublicKey,\n expiration: BN,\n oracle: PublicKey,\n) {\n return PublicKey.findProgramAddressSync(\n [\n underlyingMint.toBuffer(),\n expiration.toArrayLike(Buffer, 'le', 8),\n oracle.toBuffer(),\n ],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getEuroMetaPda(\n underlyingMint: PublicKey,\n quoteMint: PublicKey,\n expiration: BN,\n optionType: OptionTypeV2,\n underlyingPool: PublicKey,\n strikePrices: BN[],\n) {\n return PublicKey.findProgramAddressSync(\n [\n underlyingMint.toBuffer(),\n quoteMint.toBuffer(),\n expiration.toArrayLike(Buffer, 'le', 8),\n new BN(optionType as number).toArrayLike(Buffer, 'le', 1),\n underlyingPool.toBuffer(),\n serializeStrikePrices(strikePrices),\n ],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getOptionMintPda(euroMeta: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [euroMeta.toBuffer(), textEncoder.encode('optionMint')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getWriterMintPda(euroMeta: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [euroMeta.toBuffer(), textEncoder.encode('writerMint')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getUnderlyingPoolPda(underlyingMint: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [underlyingMint.toBuffer(), textEncoder.encode('underlyingPool')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getQuotePoolPda(quoteMint: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [quoteMint.toBuffer(), textEncoder.encode('stablePool')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getPoolAuthorityPda() {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('poolAuthority')],\n Config.LEVERAGE_FUN_PROGRAM_ID,\n );\n}\n\nexport function getOptionCyclePda(vaultAuthority: PublicKey, cycleNumber: BN) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [\n textEncoder.encode('option_cycle'),\n vaultAuthority.toBuffer(),\n cycleNumber.toArrayLike(Buffer, 'le', 8),\n ],\n Config.VAULTS_PROGRAM_ID,\n );\n}\n\nexport function getAuctionProgramVaultPda(auction: PublicKey) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('vault'), auction.toBuffer()],\n Config.AUCTION_PROGRAM_ID,\n );\n}\n\nexport function getAuctionStatePda(creator: PublicKey, cycleNumber: BN) {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [\n textEncoder.encode('auction'),\n creator.toBuffer(),\n cycleNumber.toArrayLike(Buffer, 'le', 8),\n ],\n Config.AUCTION_PROGRAM_ID,\n );\n}\n\nexport function getPoolAuthorityVaultsPda() {\n const textEncoder = new TextEncoder();\n return PublicKey.findProgramAddressSync(\n [textEncoder.encode('pool_authority')],\n Config.VAULTS_PROGRAM_ID,\n );\n}\n"],"names":["PublicKey","BN","Config","serializeStrikePrices","getExpirationDataPda","underlyingMint","expiration","oracle","findProgramAddressSync","toBuffer","toArrayLike","Buffer","LEVERAGE_FUN_PROGRAM_ID","getEuroMetaPda","quoteMint","optionType","underlyingPool","strikePrices","getOptionMintPda","euroMeta","textEncoder","TextEncoder","encode","getWriterMintPda","getUnderlyingPoolPda","getQuotePoolPda","getPoolAuthorityPda","getOptionCyclePda","vaultAuthority","cycleNumber","VAULTS_PROGRAM_ID","getAuctionProgramVaultPda","auction","AUCTION_PROGRAM_ID","getAuctionStatePda","creator","getPoolAuthorityVaultsPda"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,QAAQ,QAAQ;AACvB,OAAOC,YAAY,eAAe;AAClC,SAAuBC,qBAAqB,QAAQ,aAAa;AAEjE,OAAO,SAASC,qBACdC,cAAyB,EACzBC,UAAc,EACdC,MAAiB;IAEjB,OAAOP,UAAUQ,sBAAsB,CACrC;QACEH,eAAeI,QAAQ;QACvBH,WAAWI,WAAW,CAACC,QAAQ,MAAM;QACrCJ,OAAOE,QAAQ;KAChB,EACDP,OAAOU,uBAAuB;AAElC;AAEA,OAAO,SAASC,eACdR,cAAyB,EACzBS,SAAoB,EACpBR,UAAc,EACdS,UAAwB,EACxBC,cAAyB,EACzBC,YAAkB;IAElB,OAAOjB,UAAUQ,sBAAsB,CACrC;QACEH,eAAeI,QAAQ;QACvBK,UAAUL,QAAQ;QAClBH,WAAWI,WAAW,CAACC,QAAQ,MAAM;QACrC,IAAIV,GAAGc,YAAsBL,WAAW,CAACC,QAAQ,MAAM;QACvDK,eAAeP,QAAQ;QACvBN,sBAAsBc;KACvB,EACDf,OAAOU,uBAAuB;AAElC;AAEA,OAAO,SAASM,iBAAiBC,QAAmB;IAClD,MAAMC,cAAc,IAAIC;IACxB,OAAOrB,UAAUQ,sBAAsB,CACrC;QAACW,SAASV,QAAQ;QAAIW,YAAYE,MAAM,CAAC;KAAc,EACvDpB,OAAOU,uBAAuB;AAElC;AAEA,OAAO,SAASW,iBAAiBJ,QAAmB;IAClD,MAAMC,cAAc,IAAIC;IACxB,OAAOrB,UAAUQ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AM;KACvC,EACDT,OAAO+B,kBAAkB;AAE7B;AAEA,OAAO,SAASG;IACd,MAAMhB,cAAc,IAAIC;IACxB,OAAOrB,UAAUQ,sBAAsB,CACrC;QAACY,YAAYE,MAAM,CAAC;KAAkB,EACtCpB,OAAO4B,iBAAiB;AAE5B"} \ No newline at end of file diff --git a/dist/src/utils/programUtils.js b/dist/src/utils/programUtils.js index 7ce9eba..081fd7f 100644 --- a/dist/src/utils/programUtils.js +++ b/dist/src/utils/programUtils.js @@ -22,5 +22,11 @@ export async function getVaultsProgram(provider) { throw error; } } +export async function getAuctionProgram(provider) { + const pid = Config.AUCTION_PROGRAM_ID; + const idl = await anchor.Program.fetchIdl(pid, provider); + const program = new anchor.Program(idl, provider); + return program; +} //# sourceMappingURL=programUtils.js.map \ No newline at end of file diff --git a/dist/src/utils/programUtils.js.map b/dist/src/utils/programUtils.js.map index 598685c..3534b70 100644 --- a/dist/src/utils/programUtils.js.map +++ b/dist/src/utils/programUtils.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/utils/programUtils.ts"],"sourcesContent":["import * as anchor from '@coral-xyz/anchor';\nimport { EuroPrimitive } from '../types/euro_primitive.js';\nimport { Vaults } from '../types/vaults.js';\nimport Config from '../config.js';\n\nexport async function getProgram(\n provider: anchor.Provider,\n): Promise> {\n try {\n const pid = Config.LEVERAGE_FUN_PROGRAM_ID;\n const idl = await anchor.Program.fetchIdl(pid, provider);\n const program = new anchor.Program(idl!, provider);\n return program;\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n\nexport async function getVaultsProgram(\n provider: anchor.Provider,\n): Promise> {\n try {\n const pid = Config.VAULTS_PROGRAM_ID;\n const idl = await anchor.Program.fetchIdl(pid, provider);\n const program = new anchor.Program(idl!, provider);\n return program;\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n"],"names":["anchor","Config","getProgram","provider","pid","LEVERAGE_FUN_PROGRAM_ID","idl","Program","fetchIdl","program","error","console","getVaultsProgram","VAULTS_PROGRAM_ID"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,YAAY,oBAAoB;AAG5C,OAAOC,YAAY,eAAe;AAElC,OAAO,eAAeC,WACpBC,QAAyB;IAEzB,IAAI;QACF,MAAMC,MAAMH,OAAOI,uBAAuB;QAC1C,MAAMC,MAAM,MAAMN,OAAOO,OAAO,CAACC,QAAQ,CAAgBJ,KAAKD;QAC9D,MAAMM,UAAU,IAAIT,OAAOO,OAAO,CAAgBD,KAAMH;QACxD,OAAOM;IACT,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAACA;QACd,MAAMA;IACR;AACF;AAEA,OAAO,eAAeE,iBACpBT,QAAyB;IAEzB,IAAI;QACF,MAAMC,MAAMH,OAAOY,iBAAiB;QACpC,MAAMP,MAAM,MAAMN,OAAOO,OAAO,CAACC,QAAQ,CAASJ,KAAKD;QACvD,MAAMM,UAAU,IAAIT,OAAOO,OAAO,CAASD,KAAMH;QACjD,OAAOM;IACT,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAACA;QACd,MAAMA;IACR;AACF"} \ No newline at end of file +{"version":3,"sources":["../../../src/utils/programUtils.ts"],"sourcesContent":["import * as anchor from '@coral-xyz/anchor';\nimport { EuroPrimitive } from '../types/euro_primitive.js';\nimport { Vaults } from '../types/vaults.js';\nimport { OptionAuction } from '../types/option_auction.js';\nimport Config from '../config.js';\n\nexport async function getProgram(\n provider: anchor.Provider,\n): Promise> {\n try {\n const pid = Config.LEVERAGE_FUN_PROGRAM_ID;\n const idl = await anchor.Program.fetchIdl(pid, provider);\n const program = new anchor.Program(idl!, provider);\n return program;\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n\nexport async function getVaultsProgram(\n provider: anchor.Provider,\n): Promise> {\n try {\n const pid = Config.VAULTS_PROGRAM_ID;\n const idl = await anchor.Program.fetchIdl(pid, provider);\n const program = new anchor.Program(idl!, provider);\n return program;\n } catch (error) {\n console.error(error);\n throw error;\n }\n}\n\nexport async function getAuctionProgram(\n provider: anchor.Provider,\n): Promise> {\n const pid = Config.AUCTION_PROGRAM_ID;\n const idl = await anchor.Program.fetchIdl(pid, provider);\n const program = new anchor.Program(idl!, provider);\n return program;\n}\n"],"names":["anchor","Config","getProgram","provider","pid","LEVERAGE_FUN_PROGRAM_ID","idl","Program","fetchIdl","program","error","console","getVaultsProgram","VAULTS_PROGRAM_ID","getAuctionProgram","AUCTION_PROGRAM_ID"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,YAAY,oBAAoB;AAI5C,OAAOC,YAAY,eAAe;AAElC,OAAO,eAAeC,WACpBC,QAAyB;IAEzB,IAAI;QACF,MAAMC,MAAMH,OAAOI,uBAAuB;QAC1C,MAAMC,MAAM,MAAMN,OAAOO,OAAO,CAACC,QAAQ,CAAgBJ,KAAKD;QAC9D,MAAMM,UAAU,IAAIT,OAAOO,OAAO,CAAgBD,KAAMH;QACxD,OAAOM;IACT,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAACA;QACd,MAAMA;IACR;AACF;AAEA,OAAO,eAAeE,iBACpBT,QAAyB;IAEzB,IAAI;QACF,MAAMC,MAAMH,OAAOY,iBAAiB;QACpC,MAAMP,MAAM,MAAMN,OAAOO,OAAO,CAACC,QAAQ,CAASJ,KAAKD;QACvD,MAAMM,UAAU,IAAIT,OAAOO,OAAO,CAASD,KAAMH;QACjD,OAAOM;IACT,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAACA;QACd,MAAMA;IACR;AACF;AAEA,OAAO,eAAeI,kBACpBX,QAAyB;IAEzB,MAAMC,MAAMH,OAAOc,kBAAkB;IACrC,MAAMT,MAAM,MAAMN,OAAOO,OAAO,CAACC,QAAQ,CAAgBJ,KAAKD;IAC9D,MAAMM,UAAU,IAAIT,OAAOO,OAAO,CAAgBD,KAAMH;IACxD,OAAOM;AACT"} \ No newline at end of file diff --git a/src/controllers/mintOptions.controller.ts b/src/controllers/mintOptions.controller.ts index 5d64fcc..3f337bc 100644 --- a/src/controllers/mintOptions.controller.ts +++ b/src/controllers/mintOptions.controller.ts @@ -14,7 +14,7 @@ import { import { sleep, OptionTypeV2, - // postTelegramMessage, + postTelegramMessage, getAtaForUser, } from '../utils/index.js'; import * as anchor from '@coral-xyz/anchor'; @@ -218,9 +218,9 @@ async function processMintingTransaction( } export async function scheduleMintingProcess(provider: anchor.AnchorProvider) { - let cycleNumber = new BN(4); - console.log('Current cycle number, ', cycleNumber.toString()); + let cycleNumber = new BN(6); cron.schedule('0 0 * * 5', async () => { + console.log('Current cycle number, ', cycleNumber.toString()); try { const expiration = new BN(new Date().getTime() / 1000 + 3600); const txHash = await processMintingTransaction( @@ -229,7 +229,7 @@ export async function scheduleMintingProcess(provider: anchor.AnchorProvider) { cycleNumber, ); if (txHash) { - // await postTelegramMessage(txHash); + await postTelegramMessage(txHash); console.log(`Transaction completed successfully: ${txHash}`); cycleNumber = cycleNumber.add(new BN(1)); }