diff --git a/client/idl/generateIdl.js b/client/idl/generateIdl.js index 019352e3f..f791b42ad 100644 --- a/client/idl/generateIdl.js +++ b/client/idl/generateIdl.js @@ -106,6 +106,29 @@ function modifyIdlCore(programName) { } } + for (const idlType of idl.types) { + if (idlType.type && idlType.type.fields) { + idlType.type.fields = idlType.type.fields.map((field) => { + if (field.type.defined == 'PodBool') { + field.type = 'bool'; + } + if (field.type.defined == 'BaseAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'GlobalAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtomsPerBaseAtom') { + field.type = 'u128'; + } + return field; + }); + } + } + for (const instruction of idl.instructions) { switch (instruction.name) { case 'CreateMarket': { @@ -243,12 +266,25 @@ function modifyIdlCore(programName) { }, }); + // TODO: Make a helper for this that is shared for (const idlType of idl.types) { if (idlType.type && idlType.type.fields) { idlType.type.fields = idlType.type.fields.map((field) => { if (field.type.defined == 'PodBool') { field.type = 'bool'; } + if (field.type.defined == 'BaseAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'GlobalAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtomsPerBaseAtom') { + field.type = 'u128'; + } return field; }); } @@ -352,6 +388,18 @@ function modifyIdlCore(programName) { if (field.type.defined == 'PodBool') { field.type = 'bool'; } + if (field.type.defined == 'BaseAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'GlobalAtoms') { + field.type = 'u64'; + } + if (field.type.defined == 'QuoteAtomsPerBaseAtom') { + field.type = 'u128'; + } return field; }); } diff --git a/client/idl/manifest.json b/client/idl/manifest.json index 0a2fa5fa0..688f6d58c 100644 --- a/client/idl/manifest.json +++ b/client/idl/manifest.json @@ -1472,6 +1472,293 @@ ] } }, + { + "name": "ClaimedSeat", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trader", + "type": "publicKey" + }, + { + "name": "baseWithdrawableBalance", + "type": "u64" + }, + { + "name": "quoteWithdrawableBalance", + "type": "u64" + }, + { + "name": "quoteVolume", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "GlobalFixed", + "type": { + "kind": "struct", + "fields": [ + { + "name": "discriminant", + "type": "u64" + }, + { + "name": "mint", + "type": "publicKey" + }, + { + "name": "vault", + "type": "publicKey" + }, + { + "name": "globalTradersRootIndex", + "type": "u32" + }, + { + "name": "globalDepositsRootIndex", + "type": "u32" + }, + { + "name": "globalDepositsMaxIndex", + "type": "u32" + }, + { + "name": "freeListHeadIndex", + "type": "u32" + }, + { + "name": "numBytesAllocated", + "type": "u32" + }, + { + "name": "vaultBump", + "type": "u8" + }, + { + "name": "globalBump", + "type": "u8" + }, + { + "name": "numSeatsClaimed", + "type": "u16" + } + ] + } + }, + { + "name": "GlobalTrader", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trader", + "type": "publicKey" + }, + { + "name": "unclaimedGasDeposits", + "type": "u32" + }, + { + "name": "depositIndex", + "type": "u32" + }, + { + "name": "padding", + "type": "u64" + } + ] + } + }, + { + "name": "GlobalDeposit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trader", + "type": "publicKey" + }, + { + "name": "balanceAtoms", + "type": "u64" + }, + { + "name": "padding", + "type": "u64" + } + ] + } + }, + { + "name": "MarketFixed", + "type": { + "kind": "struct", + "fields": [ + { + "name": "discriminant", + "type": "u64" + }, + { + "name": "version", + "type": "u8" + }, + { + "name": "baseMintDecimals", + "type": "u8" + }, + { + "name": "quoteMintDecimals", + "type": "u8" + }, + { + "name": "baseVaultBump", + "type": "u8" + }, + { + "name": "quoteVaultBump", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "baseMint", + "type": "publicKey" + }, + { + "name": "quoteMint", + "type": "publicKey" + }, + { + "name": "baseVault", + "type": "publicKey" + }, + { + "name": "quoteVault", + "type": "publicKey" + }, + { + "name": "orderSequenceNumber", + "type": "u64" + }, + { + "name": "numBytesAllocated", + "type": "u32" + }, + { + "name": "bidsRootIndex", + "type": "u32" + }, + { + "name": "bidsBestIndex", + "type": "u32" + }, + { + "name": "asksRootIndex", + "type": "u32" + }, + { + "name": "asksBestIndex", + "type": "u32" + }, + { + "name": "claimedSeatsRootIndex", + "type": "u32" + }, + { + "name": "freeListHeadIndex", + "type": "u32" + }, + { + "name": "padding2", + "type": { + "array": [ + "u32", + 1 + ] + } + }, + { + "name": "quoteVolume", + "type": "u64" + }, + { + "name": "padding3", + "type": { + "array": [ + "u64", + 8 + ] + } + } + ] + } + }, + { + "name": "RestingOrder", + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "u128" + }, + { + "name": "numBaseAtoms", + "type": "u64" + }, + { + "name": "sequenceNumber", + "type": "u64" + }, + { + "name": "traderIndex", + "type": "u32" + }, + { + "name": "lastValidSlot", + "type": "u32" + }, + { + "name": "isBid", + "type": "bool" + }, + { + "name": "orderType", + "type": { + "defined": "OrderType" + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 22 + ] + } + } + ] + } + }, { "name": "OrderType", "type": { diff --git a/client/idl/ui_wrapper.json b/client/idl/ui_wrapper.json index db90706f3..99cb0ed6d 100644 --- a/client/idl/ui_wrapper.json +++ b/client/idl/ui_wrapper.json @@ -558,6 +558,106 @@ } ], "types": [ + { + "name": "MarketInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "market", + "type": "publicKey" + }, + { + "name": "ordersRootIndex", + "type": "u32" + }, + { + "name": "traderIndex", + "type": "u32" + }, + { + "name": "baseBalance", + "type": "u64" + }, + { + "name": "quoteBalance", + "type": "u64" + }, + { + "name": "quoteVolume", + "type": "u64" + }, + { + "name": "quoteVolumeUnpaid", + "type": "u64" + }, + { + "name": "lastUpdatedSlot", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u32", + 1 + ] + } + } + ] + } + }, + { + "name": "WrapperOpenOrder", + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "u128" + }, + { + "name": "clientOrderId", + "type": "u64" + }, + { + "name": "orderSequenceNumber", + "type": "u64" + }, + { + "name": "numBaseAtoms", + "type": "u64" + }, + { + "name": "marketDataIndex", + "type": "u32" + }, + { + "name": "lastValidSlot", + "type": "u32" + }, + { + "name": "isBid", + "type": "bool" + }, + { + "name": "orderType", + "type": { + "defined": "OrderType" + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 30 + ] + } + } + ] + } + }, { "name": "WrapperCancelOrderParams", "type": { diff --git a/client/idl/wrapper.json b/client/idl/wrapper.json index 57b54e62e..3b039bbe9 100644 --- a/client/idl/wrapper.json +++ b/client/idl/wrapper.json @@ -307,6 +307,102 @@ } ], "types": [ + { + "name": "MarketInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "market", + "type": "publicKey" + }, + { + "name": "ordersRootIndex", + "type": "u32" + }, + { + "name": "traderIndex", + "type": "u32" + }, + { + "name": "baseBalance", + "type": "u64" + }, + { + "name": "quoteBalance", + "type": "u64" + }, + { + "name": "quoteVolume", + "type": "u64" + }, + { + "name": "lastUpdatedSlot", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u32", + 3 + ] + } + } + ] + } + }, + { + "name": "WrapperOpenOrder", + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "u128" + }, + { + "name": "clientOrderId", + "type": "u64" + }, + { + "name": "orderSequenceNumber", + "type": "u64" + }, + { + "name": "numBaseAtoms", + "type": "u64" + }, + { + "name": "marketDataIndex", + "type": "u32" + }, + { + "name": "lastValidSlot", + "type": "u32" + }, + { + "name": "isBid", + "type": "bool" + }, + { + "name": "orderType", + "type": { + "defined": "OrderType" + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 30 + ] + } + } + ] + } + }, { "name": "WrapperPlaceOrderParams", "type": { diff --git a/client/ts/src/manifest/types/ClaimedSeat.ts b/client/ts/src/manifest/types/ClaimedSeat.ts new file mode 100644 index 000000000..151f02dca --- /dev/null +++ b/client/ts/src/manifest/types/ClaimedSeat.ts @@ -0,0 +1,32 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js'; +import * as beet from '@metaplex-foundation/beet'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type ClaimedSeat = { + trader: web3.PublicKey; + baseWithdrawableBalance: beet.bignum; + quoteWithdrawableBalance: beet.bignum; + quoteVolume: beet.bignum; + padding: number[] /* size: 8 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const claimedSeatBeet = new beet.BeetArgsStruct( + [ + ['trader', beetSolana.publicKey], + ['baseWithdrawableBalance', beet.u64], + ['quoteWithdrawableBalance', beet.u64], + ['quoteVolume', beet.u64], + ['padding', beet.uniformFixedSizeArray(beet.u8, 8)], + ], + 'ClaimedSeat', +); diff --git a/client/ts/src/manifest/types/GlobalDeposit.ts b/client/ts/src/manifest/types/GlobalDeposit.ts new file mode 100644 index 000000000..d6e4a9ec5 --- /dev/null +++ b/client/ts/src/manifest/types/GlobalDeposit.ts @@ -0,0 +1,28 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js'; +import * as beet from '@metaplex-foundation/beet'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type GlobalDeposit = { + trader: web3.PublicKey; + balanceAtoms: beet.bignum; + padding: beet.bignum; +}; + +/** + * @category userTypes + * @category generated + */ +export const globalDepositBeet = new beet.BeetArgsStruct( + [ + ['trader', beetSolana.publicKey], + ['balanceAtoms', beet.u64], + ['padding', beet.u64], + ], + 'GlobalDeposit', +); diff --git a/client/ts/src/manifest/types/GlobalFixed.ts b/client/ts/src/manifest/types/GlobalFixed.ts new file mode 100644 index 000000000..dc4423d6e --- /dev/null +++ b/client/ts/src/manifest/types/GlobalFixed.ts @@ -0,0 +1,44 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet'; +import * as web3 from '@solana/web3.js'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type GlobalFixed = { + discriminant: beet.bignum; + mint: web3.PublicKey; + vault: web3.PublicKey; + globalTradersRootIndex: number; + globalDepositsRootIndex: number; + globalDepositsMaxIndex: number; + freeListHeadIndex: number; + numBytesAllocated: number; + vaultBump: number; + globalBump: number; + numSeatsClaimed: number; +}; + +/** + * @category userTypes + * @category generated + */ +export const globalFixedBeet = new beet.BeetArgsStruct( + [ + ['discriminant', beet.u64], + ['mint', beetSolana.publicKey], + ['vault', beetSolana.publicKey], + ['globalTradersRootIndex', beet.u32], + ['globalDepositsRootIndex', beet.u32], + ['globalDepositsMaxIndex', beet.u32], + ['freeListHeadIndex', beet.u32], + ['numBytesAllocated', beet.u32], + ['vaultBump', beet.u8], + ['globalBump', beet.u8], + ['numSeatsClaimed', beet.u16], + ], + 'GlobalFixed', +); diff --git a/client/ts/src/manifest/types/GlobalTrader.ts b/client/ts/src/manifest/types/GlobalTrader.ts new file mode 100644 index 000000000..c771b3446 --- /dev/null +++ b/client/ts/src/manifest/types/GlobalTrader.ts @@ -0,0 +1,30 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js'; +import * as beet from '@metaplex-foundation/beet'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type GlobalTrader = { + trader: web3.PublicKey; + unclaimedGasDeposits: number; + depositIndex: number; + padding: beet.bignum; +}; + +/** + * @category userTypes + * @category generated + */ +export const globalTraderBeet = new beet.BeetArgsStruct( + [ + ['trader', beetSolana.publicKey], + ['unclaimedGasDeposits', beet.u32], + ['depositIndex', beet.u32], + ['padding', beet.u64], + ], + 'GlobalTrader', +); diff --git a/client/ts/src/manifest/types/MarketFixed.ts b/client/ts/src/manifest/types/MarketFixed.ts new file mode 100644 index 000000000..70bcbfb50 --- /dev/null +++ b/client/ts/src/manifest/types/MarketFixed.ts @@ -0,0 +1,66 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet'; +import * as web3 from '@solana/web3.js'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type MarketFixed = { + discriminant: beet.bignum; + version: number; + baseMintDecimals: number; + quoteMintDecimals: number; + baseVaultBump: number; + quoteVaultBump: number; + padding1: number[] /* size: 3 */; + baseMint: web3.PublicKey; + quoteMint: web3.PublicKey; + baseVault: web3.PublicKey; + quoteVault: web3.PublicKey; + orderSequenceNumber: beet.bignum; + numBytesAllocated: number; + bidsRootIndex: number; + bidsBestIndex: number; + asksRootIndex: number; + asksBestIndex: number; + claimedSeatsRootIndex: number; + freeListHeadIndex: number; + padding2: number[] /* size: 1 */; + quoteVolume: beet.bignum; + padding3: beet.bignum[] /* size: 8 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const marketFixedBeet = new beet.BeetArgsStruct( + [ + ['discriminant', beet.u64], + ['version', beet.u8], + ['baseMintDecimals', beet.u8], + ['quoteMintDecimals', beet.u8], + ['baseVaultBump', beet.u8], + ['quoteVaultBump', beet.u8], + ['padding1', beet.uniformFixedSizeArray(beet.u8, 3)], + ['baseMint', beetSolana.publicKey], + ['quoteMint', beetSolana.publicKey], + ['baseVault', beetSolana.publicKey], + ['quoteVault', beetSolana.publicKey], + ['orderSequenceNumber', beet.u64], + ['numBytesAllocated', beet.u32], + ['bidsRootIndex', beet.u32], + ['bidsBestIndex', beet.u32], + ['asksRootIndex', beet.u32], + ['asksBestIndex', beet.u32], + ['claimedSeatsRootIndex', beet.u32], + ['freeListHeadIndex', beet.u32], + ['padding2', beet.uniformFixedSizeArray(beet.u32, 1)], + ['quoteVolume', beet.u64], + ['padding3', beet.uniformFixedSizeArray(beet.u64, 8)], + ], + 'MarketFixed', +); diff --git a/client/ts/src/manifest/types/RestingOrder.ts b/client/ts/src/manifest/types/RestingOrder.ts new file mode 100644 index 000000000..923b56d0e --- /dev/null +++ b/client/ts/src/manifest/types/RestingOrder.ts @@ -0,0 +1,37 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet'; +import { OrderType, orderTypeBeet } from './OrderType'; +export type RestingOrder = { + price: beet.bignum; + numBaseAtoms: beet.bignum; + sequenceNumber: beet.bignum; + traderIndex: number; + lastValidSlot: number; + isBid: boolean; + orderType: OrderType; + padding: number[] /* size: 22 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const restingOrderBeet = new beet.BeetArgsStruct( + [ + ['price', beet.u128], + ['numBaseAtoms', beet.u64], + ['sequenceNumber', beet.u64], + ['traderIndex', beet.u32], + ['lastValidSlot', beet.u32], + ['isBid', beet.bool], + ['orderType', orderTypeBeet], + ['padding', beet.uniformFixedSizeArray(beet.u8, 22)], + ], + 'RestingOrder', +); diff --git a/client/ts/src/manifest/types/index.ts b/client/ts/src/manifest/types/index.ts index 7ab220266..d3a85c1d1 100644 --- a/client/ts/src/manifest/types/index.ts +++ b/client/ts/src/manifest/types/index.ts @@ -1,11 +1,17 @@ export * from './BatchUpdateParams'; export * from './CancelOrderParams'; +export * from './ClaimedSeat'; export * from './DepositParams'; export * from './GlobalCleanParams'; +export * from './GlobalDeposit'; export * from './GlobalDepositParams'; export * from './GlobalEvictParams'; +export * from './GlobalFixed'; +export * from './GlobalTrader'; export * from './GlobalWithdrawParams'; +export * from './MarketFixed'; export * from './OrderType'; export * from './PlaceOrderParams'; +export * from './RestingOrder'; export * from './SwapParams'; export * from './WithdrawParams'; diff --git a/client/ts/src/ui_wrapper/types/MarketInfo.ts b/client/ts/src/ui_wrapper/types/MarketInfo.ts new file mode 100644 index 000000000..4415d781a --- /dev/null +++ b/client/ts/src/ui_wrapper/types/MarketInfo.ts @@ -0,0 +1,40 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js'; +import * as beet from '@metaplex-foundation/beet'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type MarketInfo = { + market: web3.PublicKey; + ordersRootIndex: number; + traderIndex: number; + baseBalance: beet.bignum; + quoteBalance: beet.bignum; + quoteVolume: beet.bignum; + quoteVolumeUnpaid: beet.bignum; + lastUpdatedSlot: number; + padding: number[] /* size: 1 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const marketInfoBeet = new beet.BeetArgsStruct( + [ + ['market', beetSolana.publicKey], + ['ordersRootIndex', beet.u32], + ['traderIndex', beet.u32], + ['baseBalance', beet.u64], + ['quoteBalance', beet.u64], + ['quoteVolume', beet.u64], + ['quoteVolumeUnpaid', beet.u64], + ['lastUpdatedSlot', beet.u32], + ['padding', beet.uniformFixedSizeArray(beet.u32, 1)], + ], + 'MarketInfo', +); diff --git a/client/ts/src/ui_wrapper/types/WrapperOpenOrder.ts b/client/ts/src/ui_wrapper/types/WrapperOpenOrder.ts new file mode 100644 index 000000000..292b5df2b --- /dev/null +++ b/client/ts/src/ui_wrapper/types/WrapperOpenOrder.ts @@ -0,0 +1,39 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet'; +import { OrderType, orderTypeBeet } from './OrderType'; +export type WrapperOpenOrder = { + price: beet.bignum; + clientOrderId: beet.bignum; + orderSequenceNumber: beet.bignum; + numBaseAtoms: beet.bignum; + marketDataIndex: number; + lastValidSlot: number; + isBid: boolean; + orderType: OrderType; + padding: number[] /* size: 30 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const wrapperOpenOrderBeet = new beet.BeetArgsStruct( + [ + ['price', beet.u128], + ['clientOrderId', beet.u64], + ['orderSequenceNumber', beet.u64], + ['numBaseAtoms', beet.u64], + ['marketDataIndex', beet.u32], + ['lastValidSlot', beet.u32], + ['isBid', beet.bool], + ['orderType', orderTypeBeet], + ['padding', beet.uniformFixedSizeArray(beet.u8, 30)], + ], + 'WrapperOpenOrder', +); diff --git a/client/ts/src/ui_wrapper/types/index.ts b/client/ts/src/ui_wrapper/types/index.ts index 92e8f4595..1f96b7294 100644 --- a/client/ts/src/ui_wrapper/types/index.ts +++ b/client/ts/src/ui_wrapper/types/index.ts @@ -1,4 +1,6 @@ +export * from './MarketInfo'; export * from './OrderType'; export * from './WrapperCancelOrderParams'; +export * from './WrapperOpenOrder'; export * from './WrapperPlaceOrderParams'; export * from './WrapperSettleFundsParams'; diff --git a/client/ts/src/utils/beet.ts b/client/ts/src/utils/beet.ts index c600f7d0d..abb9c124e 100644 --- a/client/ts/src/utils/beet.ts +++ b/client/ts/src/utils/beet.ts @@ -28,6 +28,7 @@ export const publicKeyBeet = new BeetArgsStruct( 'PubkeyWrapper', ); +// TODO: Use the shanked version of all these /** * RestingOrder deserializer. * diff --git a/client/ts/src/wrapper/types/MarketInfo.ts b/client/ts/src/wrapper/types/MarketInfo.ts new file mode 100644 index 000000000..34450eee9 --- /dev/null +++ b/client/ts/src/wrapper/types/MarketInfo.ts @@ -0,0 +1,38 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as web3 from '@solana/web3.js'; +import * as beet from '@metaplex-foundation/beet'; +import * as beetSolana from '@metaplex-foundation/beet-solana'; +export type MarketInfo = { + market: web3.PublicKey; + ordersRootIndex: number; + traderIndex: number; + baseBalance: beet.bignum; + quoteBalance: beet.bignum; + quoteVolume: beet.bignum; + lastUpdatedSlot: number; + padding: number[] /* size: 3 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const marketInfoBeet = new beet.BeetArgsStruct( + [ + ['market', beetSolana.publicKey], + ['ordersRootIndex', beet.u32], + ['traderIndex', beet.u32], + ['baseBalance', beet.u64], + ['quoteBalance', beet.u64], + ['quoteVolume', beet.u64], + ['lastUpdatedSlot', beet.u32], + ['padding', beet.uniformFixedSizeArray(beet.u32, 3)], + ], + 'MarketInfo', +); diff --git a/client/ts/src/wrapper/types/WrapperOpenOrder.ts b/client/ts/src/wrapper/types/WrapperOpenOrder.ts new file mode 100644 index 000000000..292b5df2b --- /dev/null +++ b/client/ts/src/wrapper/types/WrapperOpenOrder.ts @@ -0,0 +1,39 @@ +/** + * This code was GENERATED using the solita package. + * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. + * + * See: https://github.com/metaplex-foundation/solita + */ + +import * as beet from '@metaplex-foundation/beet'; +import { OrderType, orderTypeBeet } from './OrderType'; +export type WrapperOpenOrder = { + price: beet.bignum; + clientOrderId: beet.bignum; + orderSequenceNumber: beet.bignum; + numBaseAtoms: beet.bignum; + marketDataIndex: number; + lastValidSlot: number; + isBid: boolean; + orderType: OrderType; + padding: number[] /* size: 30 */; +}; + +/** + * @category userTypes + * @category generated + */ +export const wrapperOpenOrderBeet = new beet.BeetArgsStruct( + [ + ['price', beet.u128], + ['clientOrderId', beet.u64], + ['orderSequenceNumber', beet.u64], + ['numBaseAtoms', beet.u64], + ['marketDataIndex', beet.u32], + ['lastValidSlot', beet.u32], + ['isBid', beet.bool], + ['orderType', orderTypeBeet], + ['padding', beet.uniformFixedSizeArray(beet.u8, 30)], + ], + 'WrapperOpenOrder', +); diff --git a/client/ts/src/wrapper/types/index.ts b/client/ts/src/wrapper/types/index.ts index d4f731501..0ab7bc650 100644 --- a/client/ts/src/wrapper/types/index.ts +++ b/client/ts/src/wrapper/types/index.ts @@ -1,6 +1,8 @@ +export * from './MarketInfo'; export * from './OrderType'; export * from './WrapperBatchUpdateParams'; export * from './WrapperCancelOrderParams'; export * from './WrapperDepositParams'; +export * from './WrapperOpenOrder'; export * from './WrapperPlaceOrderParams'; export * from './WrapperWithdrawParams'; diff --git a/programs/manifest/src/state/claimed_seat.rs b/programs/manifest/src/state/claimed_seat.rs index 3ff340de3..12f16f15f 100644 --- a/programs/manifest/src/state/claimed_seat.rs +++ b/programs/manifest/src/state/claimed_seat.rs @@ -2,6 +2,7 @@ use std::mem::size_of; use crate::quantities::{BaseAtoms, QuoteAtoms}; use bytemuck::{Pod, Zeroable}; +use shank::ShankType; use solana_program::pubkey::Pubkey; use static_assertions::const_assert_eq; use std::cmp::Ordering; @@ -9,7 +10,7 @@ use std::cmp::Ordering; use super::constants::CLAIMED_SEAT_SIZE; #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct ClaimedSeat { pub trader: Pubkey, // Balances are withdrawable on the exchange. They do not include funds in diff --git a/programs/manifest/src/state/global.rs b/programs/manifest/src/state/global.rs index b9d745bb9..387092344 100644 --- a/programs/manifest/src/state/global.rs +++ b/programs/manifest/src/state/global.rs @@ -11,6 +11,7 @@ use hypertree::{ get_helper, get_mut_helper, DataIndex, FreeList, Get, HyperTreeReadOperations, HyperTreeWriteOperations, RBNode, RedBlackTree, RedBlackTreeReadOnly, NIL, }; +use shank::ShankType; use solana_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey}; use static_assertions::const_assert_eq; @@ -30,7 +31,7 @@ use super::{ }; #[repr(C)] -#[derive(Default, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Copy, Clone, Zeroable, Pod, ShankType)] pub struct GlobalFixed { /// Discriminant for identifying this type of account. pub discriminant: u64, @@ -93,7 +94,7 @@ const_assert_eq!( // Does not need to align to word boundaries because does not deserialize. #[repr(C)] -#[derive(Default, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Copy, Clone, Zeroable, Pod, ShankType)] pub struct GlobalTrader { /// Trader who controls this global trader. trader: Pubkey, @@ -132,7 +133,7 @@ impl std::fmt::Display for GlobalTrader { } #[repr(C)] -#[derive(Default, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Copy, Clone, Zeroable, Pod, ShankType)] pub struct GlobalDeposit { /// Trader who controls this global trader. trader: Pubkey, diff --git a/programs/manifest/src/state/market.rs b/programs/manifest/src/state/market.rs index a3a6789b7..c31a7cf59 100644 --- a/programs/manifest/src/state/market.rs +++ b/programs/manifest/src/state/market.rs @@ -4,6 +4,7 @@ use hypertree::{ HyperTreeReadOperations, HyperTreeValueIteratorTrait, HyperTreeWriteOperations, PodBool, RBNode, RedBlackTree, RedBlackTreeReadOnly, NIL, }; +use shank::ShankType; use solana_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey}; use static_assertions::const_assert_eq; use std::mem::size_of; @@ -67,7 +68,7 @@ const_assert_eq!( // Does not need to align to word boundaries because does not deserialize. #[repr(C)] -#[derive(Default, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Copy, Clone, Zeroable, Pod, ShankType)] pub struct MarketFixed { /// Discriminant for identifying this type of account. pub discriminant: u64, diff --git a/programs/manifest/src/state/resting_order.rs b/programs/manifest/src/state/resting_order.rs index 68ea678d6..7e06a0a6d 100644 --- a/programs/manifest/src/state/resting_order.rs +++ b/programs/manifest/src/state/resting_order.rs @@ -54,7 +54,7 @@ pub fn order_type_can_take(order_type: OrderType) -> bool { } #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct RestingOrder { price: QuoteAtomsPerBaseAtom, num_base_atoms: BaseAtoms, diff --git a/programs/ui-wrapper/src/market_info.rs b/programs/ui-wrapper/src/market_info.rs index 1a769ceda..c5c410a29 100644 --- a/programs/ui-wrapper/src/market_info.rs +++ b/programs/ui-wrapper/src/market_info.rs @@ -1,6 +1,7 @@ use bytemuck::{Pod, Zeroable}; use hypertree::{DataIndex, NIL}; use manifest::quantities::{BaseAtoms, QuoteAtoms}; +use shank::ShankType; use solana_program::pubkey::Pubkey; use static_assertions::const_assert_eq; use std::{cmp::Ordering, mem::size_of}; @@ -8,7 +9,7 @@ use std::{cmp::Ordering, mem::size_of}; use crate::processors::shared::WRAPPER_BLOCK_PAYLOAD_SIZE; #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct MarketInfo { /// Pubkey for the market pub market: Pubkey, diff --git a/programs/ui-wrapper/src/open_order.rs b/programs/ui-wrapper/src/open_order.rs index 61b452c91..9f3367f33 100644 --- a/programs/ui-wrapper/src/open_order.rs +++ b/programs/ui-wrapper/src/open_order.rs @@ -4,13 +4,14 @@ use manifest::{ quantities::{BaseAtoms, QuoteAtomsPerBaseAtom, WrapperU64}, state::OrderType, }; +use shank::ShankType; use static_assertions::const_assert_eq; use std::{cmp::Ordering, mem::size_of}; use crate::processors::shared::WRAPPER_BLOCK_PAYLOAD_SIZE; #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct WrapperOpenOrder { price: QuoteAtomsPerBaseAtom, client_order_id: u64, diff --git a/programs/wrapper/src/market_info.rs b/programs/wrapper/src/market_info.rs index b6a344b01..92cbd0be1 100644 --- a/programs/wrapper/src/market_info.rs +++ b/programs/wrapper/src/market_info.rs @@ -1,15 +1,15 @@ use bytemuck::{Pod, Zeroable}; use hypertree::{DataIndex, NIL}; use manifest::quantities::{BaseAtoms, QuoteAtoms}; +use shank::ShankType; use solana_program::pubkey::Pubkey; use static_assertions::const_assert_eq; use std::{cmp::Ordering, mem::size_of}; use crate::processors::shared::WRAPPER_BLOCK_PAYLOAD_SIZE; -// TODO: Use shank type https://docs.rs/shank/latest/shank/derive.ShankType.html #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct MarketInfo { /// Pubkey for the market pub market: Pubkey, diff --git a/programs/wrapper/src/open_order.rs b/programs/wrapper/src/open_order.rs index ab0835d64..fa1f01575 100644 --- a/programs/wrapper/src/open_order.rs +++ b/programs/wrapper/src/open_order.rs @@ -4,13 +4,14 @@ use manifest::{ quantities::{BaseAtoms, QuoteAtomsPerBaseAtom}, state::{OrderType, NO_EXPIRATION_LAST_VALID_SLOT}, }; +use shank::ShankType; use static_assertions::const_assert_eq; use std::{cmp::Ordering, mem::size_of}; use crate::processors::shared::WRAPPER_BLOCK_PAYLOAD_SIZE; #[repr(C)] -#[derive(Default, Debug, Copy, Clone, Zeroable, Pod)] +#[derive(Default, Debug, Copy, Clone, Zeroable, Pod, ShankType)] pub struct WrapperOpenOrder { price: QuoteAtomsPerBaseAtom, client_order_id: u64,