Client/program interface changes
- rearrange structs to have gPA data in front and add comments about the offsets being relevant - add insuranceMint to group creation in client - drop quoteTokenIndex storage on PerpMarket - fixes to editAccount in example1-user and client
This commit is contained in:
parent
f2d8aceebe
commit
de86b69e1a
|
@ -78,12 +78,12 @@ impl MangoClient {
|
|||
// Mango Account
|
||||
let mut mango_account_tuples = program.accounts::<MangoAccount>(vec![
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 40,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(group.to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 72,
|
||||
offset: 40,
|
||||
bytes: MemcmpEncodedBytes::Base58(payer.pubkey().to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
|
@ -135,12 +135,12 @@ impl MangoClient {
|
|||
}
|
||||
let mango_account_tuples = program.accounts::<MangoAccount>(vec![
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 40,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(group.to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 72,
|
||||
offset: 40,
|
||||
bytes: MemcmpEncodedBytes::Base58(payer.pubkey().to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
|
@ -155,7 +155,7 @@ impl MangoClient {
|
|||
let mut banks_cache = HashMap::new();
|
||||
let mut banks_cache_by_token_index = HashMap::new();
|
||||
let bank_tuples = program.accounts::<Bank>(vec![RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(group.to_string()),
|
||||
encoding: None,
|
||||
})])?;
|
||||
|
@ -197,7 +197,7 @@ impl MangoClient {
|
|||
let mut serum3_external_markets_cache = HashMap::new();
|
||||
let serum3_market_tuples =
|
||||
program.accounts::<Serum3Market>(vec![RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(group.to_string()),
|
||||
encoding: None,
|
||||
})])?;
|
||||
|
@ -221,7 +221,7 @@ impl MangoClient {
|
|||
let mut perp_markets_cache_by_perp_market_index = HashMap::new();
|
||||
let perp_market_tuples =
|
||||
program.accounts::<PerpMarket>(vec![RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(group.to_string()),
|
||||
encoding: None,
|
||||
})])?;
|
||||
|
@ -279,12 +279,12 @@ impl MangoClient {
|
|||
pub fn get_account(&self) -> Result<(Pubkey, MangoAccount), anchor_client::ClientError> {
|
||||
let mango_accounts = self.program().accounts::<MangoAccount>(vec![
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 40,
|
||||
offset: 8,
|
||||
bytes: MemcmpEncodedBytes::Base58(self.group().to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
RpcFilterType::Memcmp(Memcmp {
|
||||
offset: 72,
|
||||
offset: 40,
|
||||
bytes: MemcmpEncodedBytes::Base58(self.payer().to_string()),
|
||||
encoding: None,
|
||||
}),
|
||||
|
|
|
@ -50,7 +50,6 @@ pub fn perp_create_market(
|
|||
oracle_config: OracleConfig,
|
||||
base_token_index_opt: Option<TokenIndex>,
|
||||
base_token_decimals: u8,
|
||||
quote_token_index: TokenIndex,
|
||||
quote_lot_size: i64,
|
||||
base_lot_size: i64,
|
||||
maint_asset_weight: f32,
|
||||
|
@ -96,7 +95,8 @@ pub fn perp_create_market(
|
|||
base_token_decimals,
|
||||
perp_market_index,
|
||||
base_token_index: base_token_index_opt.ok_or(TokenIndex::MAX).unwrap(),
|
||||
quote_token_index,
|
||||
padding: Default::default(),
|
||||
reserved: Default::default(),
|
||||
};
|
||||
|
||||
let mut bids = ctx.accounts.bids.load_init()?;
|
||||
|
|
|
@ -74,6 +74,7 @@ pub fn serum3_register_market(
|
|||
base_token_index: base_bank.token_index,
|
||||
quote_token_index: quote_bank.token_index,
|
||||
bump: *ctx.bumps.get("serum_market").ok_or(MangoError::SomeError)?,
|
||||
padding: Default::default(),
|
||||
reserved: Default::default(),
|
||||
};
|
||||
|
||||
|
|
|
@ -170,6 +170,7 @@ pub fn token_register(
|
|||
token_index,
|
||||
address_lookup_table_bank_index: alt_previous_size as u8,
|
||||
address_lookup_table_oracle_index: alt_previous_size as u8 + 1,
|
||||
padding: Default::default(),
|
||||
reserved: Default::default(),
|
||||
};
|
||||
|
||||
|
|
|
@ -322,7 +322,6 @@ pub mod mango_v4 {
|
|||
oracle_config: OracleConfig,
|
||||
base_token_index_opt: Option<TokenIndex>,
|
||||
base_token_decimals: u8,
|
||||
quote_token_index: TokenIndex,
|
||||
quote_lot_size: i64,
|
||||
base_lot_size: i64,
|
||||
maint_asset_weight: f32,
|
||||
|
@ -343,7 +342,6 @@ pub mod mango_v4 {
|
|||
oracle_config,
|
||||
base_token_index_opt,
|
||||
base_token_decimals,
|
||||
quote_token_index,
|
||||
quote_lot_size,
|
||||
base_lot_size,
|
||||
maint_asset_weight,
|
||||
|
|
|
@ -13,9 +13,11 @@ pub const YEAR: I80F48 = I80F48!(31536000);
|
|||
|
||||
#[account(zero_copy)]
|
||||
pub struct Bank {
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
|
||||
pub name: [u8; 16],
|
||||
|
||||
pub group: Pubkey,
|
||||
pub mint: Pubkey,
|
||||
pub vault: Pubkey,
|
||||
pub oracle: Pubkey,
|
||||
|
|
|
@ -9,22 +9,25 @@ pub const QUOTE_TOKEN_INDEX: TokenIndex = 0;
|
|||
#[account(zero_copy)]
|
||||
#[derive(Debug)]
|
||||
pub struct Group {
|
||||
// Relying on Anchor's discriminator be sufficient for our versioning needs?
|
||||
// pub meta_data: MetaData,
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub admin: Pubkey,
|
||||
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub group_num: u32,
|
||||
|
||||
pub padding: [u8; 4],
|
||||
|
||||
pub insurance_vault: Pubkey,
|
||||
pub insurance_mint: Pubkey,
|
||||
|
||||
pub group_num: u32,
|
||||
pub bump: u8,
|
||||
// Only support closing/deregistering groups, stub oracles, tokens, and markets
|
||||
// if testing == 1
|
||||
pub testing: u8,
|
||||
pub padding2: [u8; 2],
|
||||
pub padding2: [u8; 6],
|
||||
pub reserved: [u8; 8],
|
||||
}
|
||||
const_assert_eq!(size_of::<Group>(), 32 * 3 + 4 + 1 * 2 + 10);
|
||||
const_assert_eq!(size_of::<Group>(), 32 * 3 + 4 + 4 + 1 * 2 + 6 + 8);
|
||||
const_assert_eq!(size_of::<Group>() % 8, 0);
|
||||
|
||||
#[macro_export]
|
||||
|
|
|
@ -869,7 +869,6 @@ mod tests {
|
|||
perp1.data().group = group;
|
||||
perp1.data().perp_market_index = 9;
|
||||
perp1.data().base_token_index = 4;
|
||||
perp1.data().quote_token_index = 1;
|
||||
perp1.data().init_asset_weight = I80F48::from_num(1.0 - 0.2f64);
|
||||
perp1.data().init_liab_weight = I80F48::from_num(1.0 + 0.2f64);
|
||||
perp1.data().maint_asset_weight = I80F48::from_num(1.0 - 0.1f64);
|
||||
|
@ -1044,7 +1043,6 @@ mod tests {
|
|||
perp1.data().group = group;
|
||||
perp1.data().perp_market_index = 9;
|
||||
perp1.data().base_token_index = 4;
|
||||
perp1.data().quote_token_index = 1;
|
||||
perp1.data().init_asset_weight = I80F48::from_num(1.0 - 0.2f64);
|
||||
perp1.data().init_liab_weight = I80F48::from_num(1.0 + 0.2f64);
|
||||
perp1.data().maint_asset_weight = I80F48::from_num(1.0 - 0.1f64);
|
||||
|
|
|
@ -704,11 +704,14 @@ impl Default for MangoAccountPerpPositions {
|
|||
|
||||
#[account(zero_copy)]
|
||||
pub struct MangoAccount {
|
||||
pub name: [u8; 32],
|
||||
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub owner: Pubkey,
|
||||
|
||||
pub name: [u8; 32],
|
||||
|
||||
// Alternative authority/signer of transactions for a mango account
|
||||
pub delegate: Pubkey,
|
||||
|
||||
|
|
|
@ -15,25 +15,28 @@ pub const MAX_BANKS: usize = 6;
|
|||
#[account(zero_copy)]
|
||||
#[derive(Debug)]
|
||||
pub struct MintInfo {
|
||||
// TODO: none of these pubkeys are needed, remove?
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub token_index: TokenIndex,
|
||||
|
||||
pub padding: [u8; 6],
|
||||
pub mint: Pubkey,
|
||||
pub banks: [Pubkey; MAX_BANKS],
|
||||
pub vaults: [Pubkey; MAX_BANKS],
|
||||
pub oracle: Pubkey,
|
||||
pub address_lookup_table: Pubkey,
|
||||
|
||||
pub token_index: TokenIndex,
|
||||
|
||||
// describe what address map relevant accounts are found on
|
||||
pub address_lookup_table_bank_index: u8,
|
||||
pub address_lookup_table_oracle_index: u8,
|
||||
|
||||
pub reserved: [u8; 4],
|
||||
pub reserved: [u8; 6],
|
||||
}
|
||||
const_assert_eq!(
|
||||
size_of::<MintInfo>(),
|
||||
MAX_BANKS * 2 * 32 + 4 * 32 + 2 + 2 + 4
|
||||
MAX_BANKS * 2 * 32 + 4 * 32 + 2 + 6 + 2 + 6
|
||||
);
|
||||
const_assert_eq!(size_of::<MintInfo>() % 8, 0);
|
||||
|
||||
|
|
|
@ -71,7 +71,9 @@ pub enum OracleType {
|
|||
|
||||
#[account(zero_copy)]
|
||||
pub struct StubOracle {
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub mint: Pubkey,
|
||||
pub price: I80F48,
|
||||
pub last_updated: i64,
|
||||
|
|
|
@ -16,10 +16,20 @@ pub type PerpMarketIndex = u16;
|
|||
#[account(zero_copy)]
|
||||
#[derive(Debug)]
|
||||
pub struct PerpMarket {
|
||||
pub name: [u8; 16],
|
||||
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
|
||||
// TODO: Remove!
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub base_token_index: TokenIndex,
|
||||
|
||||
/// Lookup indices
|
||||
pub perp_market_index: PerpMarketIndex,
|
||||
|
||||
pub padding: [u8; 4],
|
||||
|
||||
pub name: [u8; 16],
|
||||
|
||||
pub oracle: Pubkey,
|
||||
|
||||
pub oracle_config: OracleConfig,
|
||||
|
@ -76,18 +86,12 @@ pub struct PerpMarket {
|
|||
|
||||
pub base_token_decimals: u8,
|
||||
|
||||
/// Lookup indices
|
||||
pub perp_market_index: PerpMarketIndex,
|
||||
|
||||
pub base_token_index: TokenIndex,
|
||||
|
||||
/// Cannot be chosen freely, must be the health-reference token, same for all PerpMarkets
|
||||
pub quote_token_index: TokenIndex,
|
||||
pub reserved: [u8; 6],
|
||||
}
|
||||
|
||||
const_assert_eq!(
|
||||
size_of::<PerpMarket>(),
|
||||
16 + 32 * 2 + 16 + 32 * 3 + 8 * 2 + 16 * 11 + 8 * 2 + 8 * 2 + 16 + 8
|
||||
32 + 2 + 2 + 4 + 16 + 32 + 16 + 32 * 3 + 8 * 2 + 16 * 11 + 8 * 2 + 8 * 2 + 16 + 2 + 6
|
||||
);
|
||||
const_assert_eq!(size_of::<PerpMarket>() % 8, 0);
|
||||
|
||||
|
|
|
@ -9,19 +9,26 @@ pub type Serum3MarketIndex = u16;
|
|||
#[account(zero_copy)]
|
||||
#[derive(Debug)]
|
||||
pub struct Serum3Market {
|
||||
pub name: [u8; 16],
|
||||
// ABI: Clients rely on this being at offset 8
|
||||
pub group: Pubkey,
|
||||
// ABI: Clients rely on this being at offset 40
|
||||
pub base_token_index: TokenIndex,
|
||||
// ABI: Clients rely on this being at offset 42
|
||||
pub quote_token_index: TokenIndex,
|
||||
pub padding: [u8; 4],
|
||||
pub name: [u8; 16],
|
||||
pub serum_program: Pubkey,
|
||||
pub serum_market_external: Pubkey,
|
||||
|
||||
pub market_index: Serum3MarketIndex,
|
||||
pub base_token_index: TokenIndex,
|
||||
pub quote_token_index: TokenIndex,
|
||||
|
||||
pub bump: u8,
|
||||
pub reserved: [u8; 1],
|
||||
pub reserved: [u8; 5],
|
||||
}
|
||||
const_assert_eq!(size_of::<Serum3Market>(), 16 + 32 * 3 + 3 * 2 + 1 + 1);
|
||||
const_assert_eq!(
|
||||
size_of::<Serum3Market>(),
|
||||
32 + 2 + 2 + 4 + 16 + 2 * 32 + 2 + 1 + 5
|
||||
);
|
||||
const_assert_eq!(size_of::<Serum3Market>() % 8, 0);
|
||||
|
||||
impl Serum3Market {
|
||||
|
|
|
@ -2160,7 +2160,6 @@ pub struct PerpCreateMarketInstruction<'keypair> {
|
|||
pub perp_market_index: PerpMarketIndex,
|
||||
pub base_token_index: TokenIndex,
|
||||
pub base_token_decimals: u8,
|
||||
pub quote_token_index: TokenIndex,
|
||||
pub quote_lot_size: i64,
|
||||
pub base_lot_size: i64,
|
||||
pub maint_asset_weight: f32,
|
||||
|
@ -2187,7 +2186,6 @@ impl<'keypair> ClientInstruction for PerpCreateMarketInstruction<'keypair> {
|
|||
},
|
||||
perp_market_index: self.perp_market_index,
|
||||
base_token_index_opt: Option::from(self.base_token_index),
|
||||
quote_token_index: self.quote_token_index,
|
||||
quote_lot_size: self.quote_lot_size,
|
||||
base_lot_size: self.base_lot_size,
|
||||
maint_asset_weight: self.maint_asset_weight,
|
||||
|
|
|
@ -271,7 +271,6 @@ async fn test_health_compute_perp() -> Result<(), TransportError> {
|
|||
perp_market_index: perp_market_index as PerpMarketIndex,
|
||||
base_token_index: quote_token.index,
|
||||
base_token_decimals: quote_token.mint.decimals,
|
||||
quote_token_index: token.index,
|
||||
quote_lot_size: 10,
|
||||
base_lot_size: 100,
|
||||
maint_asset_weight: 0.975,
|
||||
|
|
|
@ -154,7 +154,6 @@ async fn test_perp() -> Result<(), TransportError> {
|
|||
perp_market_index: 0,
|
||||
base_token_index: tokens[0].index,
|
||||
base_token_decimals: tokens[0].mint.decimals,
|
||||
quote_token_index: tokens[1].index,
|
||||
quote_lot_size: 10,
|
||||
base_lot_size: 100,
|
||||
maint_asset_weight: 0.975,
|
||||
|
|
|
@ -15,7 +15,7 @@ anchor build --skip-lint
|
|||
# update types in ts client package
|
||||
cp -v ./target/types/mango_v4.ts ./ts/client/src/mango_v4.ts
|
||||
|
||||
(cd ./ts/client && tsc)
|
||||
(cd ./ts/client && yarn tsc)
|
||||
|
||||
if [[ -z "${NO_DEPLOY}" ]]; then
|
||||
# publish program
|
||||
|
|
|
@ -15,7 +15,7 @@ anchor build --skip-lint
|
|||
# update types in ts client package
|
||||
cp -v ./target/types/mango_v4.ts ./ts/client/src/mango_v4.ts
|
||||
|
||||
(cd ./ts/client && tsc)
|
||||
(cd ./ts/client && yarn tsc)
|
||||
|
||||
if [[ -z "${NO_DEPLOY}" ]]; then
|
||||
# publish program
|
||||
|
@ -31,4 +31,4 @@ fi
|
|||
|
||||
|
||||
# build npm package
|
||||
(cd ./ts/client && tsc)
|
||||
(cd ./ts/client && yarn tsc)
|
||||
|
|
|
@ -67,6 +67,7 @@ export class MangoClient {
|
|||
public async createGroup(
|
||||
groupNum: number,
|
||||
testing: boolean,
|
||||
insuranceMintPk: PublicKey,
|
||||
): Promise<TransactionSignature> {
|
||||
const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey;
|
||||
return await this.program.methods
|
||||
|
@ -74,6 +75,7 @@ export class MangoClient {
|
|||
.accounts({
|
||||
admin: adminPk,
|
||||
payer: adminPk,
|
||||
insuranceMint: insuranceMintPk,
|
||||
})
|
||||
.rpc();
|
||||
}
|
||||
|
@ -117,7 +119,7 @@ export class MangoClient {
|
|||
filters.push({
|
||||
memcmp: {
|
||||
bytes: bs58.encode(bbuf),
|
||||
offset: 44,
|
||||
offset: 40,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -286,7 +288,7 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: group.publicKey.toBase58(),
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
@ -325,7 +327,7 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: bs58.encode(tokenIndexBuf),
|
||||
offset: 200,
|
||||
offset: 40,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
@ -443,6 +445,7 @@ export class MangoClient {
|
|||
|
||||
public async editMangoAccount(
|
||||
group: Group,
|
||||
mangoAccount: MangoAccount,
|
||||
name?: string,
|
||||
delegate?: PublicKey,
|
||||
): Promise<TransactionSignature> {
|
||||
|
@ -450,6 +453,7 @@ export class MangoClient {
|
|||
.editAccount(name, delegate)
|
||||
.accounts({
|
||||
group: group.publicKey,
|
||||
account: mangoAccount.publicKey,
|
||||
owner: (this.program.provider as AnchorProvider).wallet.publicKey,
|
||||
})
|
||||
.rpc();
|
||||
|
@ -471,13 +475,13 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: group.publicKey.toBase58(),
|
||||
offset: 40,
|
||||
offset: 8,
|
||||
},
|
||||
},
|
||||
{
|
||||
memcmp: {
|
||||
bytes: ownerPk.toBase58(),
|
||||
offset: 72,
|
||||
offset: 40,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
@ -724,7 +728,7 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: group.publicKey.toBase58(),
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -735,7 +739,7 @@ export class MangoClient {
|
|||
filters.push({
|
||||
memcmp: {
|
||||
bytes: bs58.encode(bbuf),
|
||||
offset: 122,
|
||||
offset: 40,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -746,7 +750,7 @@ export class MangoClient {
|
|||
filters.push({
|
||||
memcmp: {
|
||||
bytes: bs58.encode(qbuf),
|
||||
offset: 124,
|
||||
offset: 42,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -1052,7 +1056,6 @@ export class MangoClient {
|
|||
} as any, // future: nested custom types dont typecheck, fix if possible?
|
||||
baseTokenIndex,
|
||||
baseTokenDecimals,
|
||||
quoteTokenIndex,
|
||||
new BN(quoteLotSize),
|
||||
new BN(baseLotSize),
|
||||
maintAssetWeight,
|
||||
|
@ -1188,7 +1191,6 @@ export class MangoClient {
|
|||
public async perpGetMarkets(
|
||||
group: Group,
|
||||
baseTokenIndex?: number,
|
||||
quoteTokenIndex?: number,
|
||||
): Promise<PerpMarket[]> {
|
||||
const bumpfbuf = Buffer.alloc(1);
|
||||
bumpfbuf.writeUInt8(255);
|
||||
|
@ -1197,7 +1199,7 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: group.publicKey.toBase58(),
|
||||
offset: 24,
|
||||
offset: 8,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -1208,18 +1210,7 @@ export class MangoClient {
|
|||
filters.push({
|
||||
memcmp: {
|
||||
bytes: bs58.encode(bbuf),
|
||||
offset: 444,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (quoteTokenIndex) {
|
||||
const qbuf = Buffer.alloc(2);
|
||||
qbuf.writeUInt16LE(quoteTokenIndex);
|
||||
filters.push({
|
||||
memcmp: {
|
||||
bytes: bs58.encode(qbuf),
|
||||
offset: 446,
|
||||
offset: 40,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1953,10 +1953,6 @@ export type MangoV4 = {
|
|||
"name": "baseTokenDecimals",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteLotSize",
|
||||
"type": "i64"
|
||||
|
@ -2496,6 +2492,10 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -2505,10 +2505,6 @@ export type MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"type": "publicKey"
|
||||
|
@ -2696,6 +2692,19 @@ export type MangoV4 = {
|
|||
"name": "admin",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "groupNum",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "insuranceVault",
|
||||
"type": "publicKey"
|
||||
|
@ -2704,10 +2713,6 @@ export type MangoV4 = {
|
|||
"name": "insuranceMint",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "groupNum",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "bump",
|
||||
"type": "u8"
|
||||
|
@ -2721,7 +2726,7 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
2
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -2742,6 +2747,14 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -2751,14 +2764,6 @@ export type MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "delegate",
|
||||
"type": "publicKey"
|
||||
|
@ -2818,6 +2823,19 @@ export type MangoV4 = {
|
|||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "tokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"type": "publicKey"
|
||||
|
@ -2848,10 +2866,6 @@ export type MangoV4 = {
|
|||
"name": "addressLookupTable",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "tokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "addressLookupTableBankIndex",
|
||||
"type": "u8"
|
||||
|
@ -2865,7 +2879,7 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
6
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -2991,6 +3005,27 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "perpMarketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -3000,10 +3035,6 @@ export type MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "oracle",
|
||||
"type": "publicKey"
|
||||
|
@ -3131,16 +3162,13 @@ export type MangoV4 = {
|
|||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"name": "perpMarketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
"name": "reserved",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
6
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -3150,6 +3178,27 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -3159,10 +3208,6 @@ export type MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "serumProgram",
|
||||
"type": "publicKey"
|
||||
|
@ -3175,14 +3220,6 @@ export type MangoV4 = {
|
|||
"name": "marketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "bump",
|
||||
"type": "u8"
|
||||
|
@ -3192,7 +3229,7 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
1
|
||||
5
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -6444,10 +6481,6 @@ export const IDL: MangoV4 = {
|
|||
"name": "baseTokenDecimals",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteLotSize",
|
||||
"type": "i64"
|
||||
|
@ -6987,6 +7020,10 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -6996,10 +7033,6 @@ export const IDL: MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"type": "publicKey"
|
||||
|
@ -7187,6 +7220,19 @@ export const IDL: MangoV4 = {
|
|||
"name": "admin",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "groupNum",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "insuranceVault",
|
||||
"type": "publicKey"
|
||||
|
@ -7195,10 +7241,6 @@ export const IDL: MangoV4 = {
|
|||
"name": "insuranceMint",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "groupNum",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"name": "bump",
|
||||
"type": "u8"
|
||||
|
@ -7212,7 +7254,7 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
2
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -7233,6 +7275,14 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -7242,14 +7292,6 @@ export const IDL: MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "delegate",
|
||||
"type": "publicKey"
|
||||
|
@ -7309,6 +7351,19 @@ export const IDL: MangoV4 = {
|
|||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "tokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
6
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "mint",
|
||||
"type": "publicKey"
|
||||
|
@ -7339,10 +7394,6 @@ export const IDL: MangoV4 = {
|
|||
"name": "addressLookupTable",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "tokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "addressLookupTableBankIndex",
|
||||
"type": "u8"
|
||||
|
@ -7356,7 +7407,7 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
6
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -7482,6 +7533,27 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "perpMarketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -7491,10 +7563,6 @@ export const IDL: MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "oracle",
|
||||
"type": "publicKey"
|
||||
|
@ -7622,16 +7690,13 @@ export const IDL: MangoV4 = {
|
|||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"name": "perpMarketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
"name": "reserved",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
6
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -7641,6 +7706,27 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"kind": "struct",
|
||||
"fields": [
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "padding",
|
||||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
4
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": {
|
||||
|
@ -7650,10 +7736,6 @@ export const IDL: MangoV4 = {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "publicKey"
|
||||
},
|
||||
{
|
||||
"name": "serumProgram",
|
||||
"type": "publicKey"
|
||||
|
@ -7666,14 +7748,6 @@ export const IDL: MangoV4 = {
|
|||
"name": "marketIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "baseTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "quoteTokenIndex",
|
||||
"type": "u16"
|
||||
},
|
||||
{
|
||||
"name": "bump",
|
||||
"type": "u8"
|
||||
|
@ -7683,7 +7757,7 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
1
|
||||
5
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,15 +53,16 @@ async function main() {
|
|||
|
||||
// group
|
||||
console.log(`Creating Group...`);
|
||||
const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
|
||||
try {
|
||||
await client.createGroup(0, true);
|
||||
await client.createGroup(0, true, insuranceMint);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
const group = await client.getGroupForAdmin(admin.publicKey);
|
||||
console.log(`...registered group ${group.publicKey}`);
|
||||
|
||||
// register token 0
|
||||
// register token 1
|
||||
console.log(`Registering BTC...`);
|
||||
const btcDevnetMint = new PublicKey(DEVNET_MINTS.get('BTC')!);
|
||||
const btcDevnetOracle = new PublicKey(DEVNET_ORACLES.get('BTC')!);
|
||||
|
@ -71,7 +72,7 @@ async function main() {
|
|||
btcDevnetMint,
|
||||
btcDevnetOracle,
|
||||
0.1,
|
||||
0,
|
||||
1, // tokenIndex
|
||||
'BTC',
|
||||
0.4,
|
||||
0.07,
|
||||
|
@ -91,7 +92,7 @@ async function main() {
|
|||
console.log(error);
|
||||
}
|
||||
|
||||
// stub oracle + register token 1
|
||||
// stub oracle + register token 0
|
||||
console.log(`Registering USDC...`);
|
||||
const usdcDevnetMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
|
||||
try {
|
||||
|
@ -109,7 +110,7 @@ async function main() {
|
|||
usdcDevnetMint,
|
||||
usdcDevnetOracle.publicKey,
|
||||
0.1,
|
||||
1,
|
||||
0, // tokenIndex
|
||||
'USDC',
|
||||
0.4,
|
||||
0.07,
|
||||
|
@ -228,7 +229,7 @@ async function main() {
|
|||
0,
|
||||
'BTC-PERP',
|
||||
0.1,
|
||||
0,
|
||||
1,
|
||||
6,
|
||||
1,
|
||||
10,
|
||||
|
@ -251,7 +252,6 @@ async function main() {
|
|||
const perpMarkets = await client.perpGetMarkets(
|
||||
group,
|
||||
group.banksMap.get('BTC')?.tokenIndex,
|
||||
group.banksMap.get('USDC')?.tokenIndex,
|
||||
);
|
||||
console.log(`...created perp market ${perpMarkets[0].publicKey}`);
|
||||
|
||||
|
@ -319,7 +319,7 @@ async function main() {
|
|||
'BTC-PERP',
|
||||
btcDevnetOracle,
|
||||
0.2,
|
||||
1,
|
||||
0,
|
||||
6,
|
||||
0.9,
|
||||
0.9,
|
||||
|
@ -345,7 +345,7 @@ async function main() {
|
|||
'BTC-PERP',
|
||||
btcDevnetOracle,
|
||||
0.1,
|
||||
0,
|
||||
1,
|
||||
6,
|
||||
1,
|
||||
0.95,
|
||||
|
|
|
@ -67,12 +67,12 @@ async function main() {
|
|||
const randomKey = new PublicKey(
|
||||
'4ZkS7ZZkxfsC3GtvvsHP3DFcUeByU9zzZELS4r8HCELo',
|
||||
);
|
||||
await client.editMangoAccount(group, 'my_changed_name', randomKey);
|
||||
await client.editMangoAccount(group, mangoAccount, 'my_changed_name', randomKey);
|
||||
await mangoAccount.reload(client, group);
|
||||
console.log(mangoAccount.toString());
|
||||
|
||||
console.log(`...resetting mango account name, and re-setting a delegate`);
|
||||
await client.editMangoAccount(group, 'my_mango_account', PublicKey.default);
|
||||
await client.editMangoAccount(group, mangoAccount, 'my_mango_account', PublicKey.default);
|
||||
await mangoAccount.reload(client, group);
|
||||
console.log(mangoAccount.toString());
|
||||
}
|
||||
|
|
|
@ -12,4 +12,4 @@ anchor build --skip-lint
|
|||
# update types in ts client package
|
||||
cp -v ./target/types/mango_v4.ts ./ts/client/src/mango_v4.ts
|
||||
|
||||
(cd ./ts/client && tsc)
|
||||
(cd ./ts/client && yarn tsc)
|
||||
|
|
Loading…
Reference in New Issue