From 266c55a459f0c7151f48202b4a3f7d3717975f85 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 21 Jul 2023 08:45:47 +0200 Subject: [PATCH 01/46] Extend changelog Signed-off-by: microwavedcola1 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2045cd6..6e0b892d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Update this for each program release and mainnet deployment. ## not on mainnet -### v0.18.0, 2023-7- +### v0.18.0, 2023-7-21 - Introduce limit and stop loss orders for arbitrary spot pairs (#604, #634) @@ -23,6 +23,7 @@ Update this for each program release and mainnet deployment. - Perp FillEventLog: Include amount of closed pnl (#624) - Pyth: Fix reading most recent valid price (#631) +- Introduce mechanism for moving collected fees to DAO (#644) ## mainnet @@ -390,25 +391,30 @@ Deployment: Jan 13, 2023 at 11:31:05 Central European Standard Time, https://exp ### Dec 16, 2022 at 16:40 Central European Standard Time ### Oct 8, 2022 at 14:38:31 Central European Summer Time + https://explorer.solana.com/tx/3m8EDohkgwJZyiwpGXztBWARWQVxyhnSNDVuH467D7FPS2wxJerr79HhdhDEed5hpConHgGsKHvxtW1HJP6GixX9 ### Oct 8, 2022 at 14:38:31 Central European Summer Time + https://explorer.solana.com/tx/3m8EDohkgwJZyiwpGXztBWARWQVxyhnSNDVuH467D7FPS2wxJerr79HhdhDEed5hpConHgGsKHvxtW1HJP6GixX9 - New ix `TokenDepositIntoExisting` ### Sep 1, 2022 at 10:24:35 Central European Summer Time + https://explorer.solana.com/tx/3NnX13A3QwsREKKKo3iYR4jqgoongpCjdhhXuJ3y5iP6FwfPcNieVop623tpgPbyreC7m7KtphwdWdoHYE5YC394 - Add HealthRegionBegin, -End instructions - Add explicit "oracle" account argument for TokenDeposit and TokenWithdraw instructions ### Aug 20, 2022 at 19:58:29 Central European Summer Time + https://explorer.solana.com/tx/3R4frko1AekQKJmmQ5T6k3mdXF9uZVHTR7oocdspTPsc82xX7qrbgnG61r28UdhCxsjMxtQHgBqMc37FSvoHQfCN - loan fee logging for off-chain services ### Aug 18, 2022 at 17:17:40 Central European Summer Time + https://explorer.solana.com/tx/4Xnyswcwx98y6khw8ptNVmdhQZwJjuNy2BvmQg2pJayoThFiw8kmS2ecRAg5cg2DncvW3NQgn2vtP8mCUtv6Q1yB - liq_token_bankruptcy: removed liab_token_index argument @@ -455,6 +461,7 @@ https://explorer.solana.com/tx/4Xnyswcwx98y6khw8ptNVmdhQZwJjuNy2BvmQg2pJayoThFiw marginTrade takes flashLoanType as an argument ### Aug 8, 2022 at 18:56:04 Central European Summer Time + https://explorer.solana.com/tx/yjZggRTrcDNquMkftNvBKLv77Dk4xp5yQPYXgN3qvBHTBWWJVhLPGHxqpGwosmEq3j8byHZMa13oxLLerBWUdgW - improved logging for off chain services @@ -487,6 +494,7 @@ New features - Enforced a minimum maximum rate of 50% so that rates don't fall so low that they cannot recover. ### Jul 14, 2022 at 09:33:52 Central European Summer Time + https://explorer.solana.com/tx/vZ5hP1vGp37fgzBfG9nb4nfA5ZdmYgk8meq53YPR4ReFxrcTwBUxTYBQUgnfAnq9u5fH36S3QTfb9mVkBXt5A6C - Account data was rearranged to put fields that are often used with gPA first From d98bf2357bc9d31ba98e4b9256aec34c39324a9c Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 21 Jul 2023 08:46:24 +0200 Subject: [PATCH 02/46] update idl Signed-off-by: microwavedcola1 --- mango_v4.json | 790 ++++--------------- ts/client/src/mango_v4.ts | 1580 +++++++------------------------------ 2 files changed, 426 insertions(+), 1944 deletions(-) diff --git a/mango_v4.json b/mango_v4.json index 80fb3e2f5..719ac923f 100644 --- a/mango_v4.json +++ b/mango_v4.json @@ -8,19 +8,12 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -51,27 +44,17 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -194,10 +177,7 @@ { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -292,11 +272,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault", - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -353,11 +329,7 @@ { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin", - "insurance_vault" - ] + "isSigner": false }, { "name": "admin", @@ -388,10 +360,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -729,10 +698,7 @@ { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -897,10 +863,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -915,11 +878,7 @@ { "name": "existingBank", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "bank", @@ -982,11 +941,7 @@ { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "payer", @@ -1026,10 +981,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1039,10 +991,7 @@ { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "dustVault", @@ -1073,11 +1022,7 @@ { "name": "mintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "oracle", - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -1183,11 +1128,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1235,11 +1176,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1291,11 +1228,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1329,10 +1262,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "admin", @@ -1358,11 +1288,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1398,10 +1324,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -1411,18 +1334,12 @@ { "name": "daoAccount", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoOracle", @@ -1432,10 +1349,7 @@ { "name": "feesBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "feesOracle", @@ -1456,10 +1370,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "oracle", @@ -1522,10 +1433,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1535,10 +1443,7 @@ { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -1559,10 +1464,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1572,10 +1474,7 @@ { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -1598,11 +1497,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1612,12 +1507,7 @@ { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1667,20 +1557,12 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1730,11 +1612,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1744,12 +1622,7 @@ { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1898,10 +1771,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -1928,10 +1798,7 @@ { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1999,18 +1866,12 @@ { "name": "quoteBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "payer", @@ -2050,10 +1911,7 @@ { "name": "market", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -2083,10 +1941,7 @@ { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -2096,18 +1951,12 @@ { "name": "serumMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "indexReservation", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -2133,10 +1982,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2146,12 +1992,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2216,10 +2057,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2229,12 +2067,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2270,10 +2103,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2288,12 +2118,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2349,9 +2174,6 @@ "isSigner": false, "docs": [ "The bank that pays for the order, if necessary" - ], - "relations": [ - "group" ] }, { @@ -2425,10 +2247,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2443,12 +2262,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2500,10 +2314,7 @@ { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2518,12 +2329,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2575,10 +2381,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2593,12 +2396,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2631,10 +2429,7 @@ { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2644,10 +2439,7 @@ { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2680,10 +2472,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2698,12 +2487,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2736,10 +2520,7 @@ { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2749,10 +2530,7 @@ { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2800,10 +2578,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "openOrders", @@ -2813,12 +2588,7 @@ { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2863,10 +2633,7 @@ { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2876,10 +2643,7 @@ { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2910,10 +2674,7 @@ { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -2923,10 +2684,7 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -2952,18 +2710,12 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -2973,18 +2725,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -3022,10 +2768,7 @@ { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3035,10 +2778,7 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -3069,10 +2809,7 @@ { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3082,10 +2819,7 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -3109,18 +2843,12 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3130,18 +2858,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -3179,10 +2901,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -3377,10 +3096,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -3581,10 +3297,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -3594,13 +3307,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue" - ] + "isSigner": false }, { "name": "bids", @@ -3641,10 +3348,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3654,10 +3358,7 @@ { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -3673,10 +3374,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3686,14 +3384,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3773,10 +3464,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3786,14 +3474,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3879,10 +3560,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3892,14 +3570,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3987,10 +3658,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4000,14 +3668,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -4101,10 +3762,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4114,12 +3772,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4150,10 +3803,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4163,12 +3813,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4199,10 +3844,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4212,12 +3854,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4248,10 +3885,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4261,12 +3895,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4305,11 +3934,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "event_queue" - ] + "isSigner": false }, { "name": "eventQueue", @@ -4335,13 +3960,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -4372,10 +3991,7 @@ { "name": "settler", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settlerOwner", @@ -4385,27 +4001,17 @@ { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4415,10 +4021,7 @@ { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -4439,27 +4042,17 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4480,19 +4073,12 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4502,10 +4088,7 @@ { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -4531,11 +4114,7 @@ { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4545,10 +4124,7 @@ { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4558,18 +4134,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4604,20 +4174,12 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4643,18 +4205,12 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4664,19 +4220,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4686,10 +4235,7 @@ { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4725,18 +4271,12 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4746,19 +4286,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4768,10 +4301,7 @@ { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4791,10 +4321,7 @@ { "name": "insuranceBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "insuranceBankVault", @@ -4830,10 +4357,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -4843,18 +4367,12 @@ { "name": "buyBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "sellBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -4903,10 +4421,7 @@ { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -4919,18 +4434,12 @@ "isSigner": false, "docs": [ "The bank's token_index is checked at #1" - ], - "relations": [ - "group" ] }, { "name": "sellBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -4955,18 +4464,12 @@ { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorAuthority", @@ -4999,10 +4502,7 @@ { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -5028,10 +4528,7 @@ { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -5073,10 +4570,7 @@ { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index 2b3bcce74..6961da112 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -8,19 +8,12 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -51,27 +44,17 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -194,10 +177,7 @@ export type MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -292,11 +272,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault", - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -353,11 +329,7 @@ export type MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin", - "insurance_vault" - ] + "isSigner": false }, { "name": "admin", @@ -388,10 +360,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -729,10 +698,7 @@ export type MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -897,10 +863,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -915,11 +878,7 @@ export type MangoV4 = { { "name": "existingBank", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "bank", @@ -982,11 +941,7 @@ export type MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "payer", @@ -1026,10 +981,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1039,10 +991,7 @@ export type MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "dustVault", @@ -1073,11 +1022,7 @@ export type MangoV4 = { { "name": "mintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "oracle", - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -1183,11 +1128,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1235,11 +1176,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1291,11 +1228,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1329,10 +1262,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "admin", @@ -1358,11 +1288,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1398,10 +1324,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -1411,18 +1334,12 @@ export type MangoV4 = { { "name": "daoAccount", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoOracle", @@ -1432,10 +1349,7 @@ export type MangoV4 = { { "name": "feesBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "feesOracle", @@ -1456,10 +1370,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "oracle", @@ -1522,10 +1433,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1535,10 +1443,7 @@ export type MangoV4 = { { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -1559,10 +1464,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1572,10 +1474,7 @@ export type MangoV4 = { { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -1598,11 +1497,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1612,12 +1507,7 @@ export type MangoV4 = { { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1667,20 +1557,12 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1730,11 +1612,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -1744,12 +1622,7 @@ export type MangoV4 = { { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -1898,10 +1771,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -1928,10 +1798,7 @@ export type MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -1999,18 +1866,12 @@ export type MangoV4 = { { "name": "quoteBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "payer", @@ -2050,10 +1911,7 @@ export type MangoV4 = { { "name": "market", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -2083,10 +1941,7 @@ export type MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -2096,18 +1951,12 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "indexReservation", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -2133,10 +1982,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2146,12 +1992,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2216,10 +2057,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2229,12 +2067,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2270,10 +2103,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2288,12 +2118,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2349,9 +2174,6 @@ export type MangoV4 = { "isSigner": false, "docs": [ "The bank that pays for the order, if necessary" - ], - "relations": [ - "group" ] }, { @@ -2425,10 +2247,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2443,12 +2262,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2500,10 +2314,7 @@ export type MangoV4 = { { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2518,12 +2329,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2575,10 +2381,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2593,12 +2396,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2631,10 +2429,7 @@ export type MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2644,10 +2439,7 @@ export type MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2680,10 +2472,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -2698,12 +2487,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2736,10 +2520,7 @@ export type MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2749,10 +2530,7 @@ export type MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2800,10 +2578,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "openOrders", @@ -2813,12 +2588,7 @@ export type MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -2863,10 +2633,7 @@ export type MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -2876,10 +2643,7 @@ export type MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -2910,10 +2674,7 @@ export type MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -2923,10 +2684,7 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -2952,18 +2710,12 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -2973,18 +2725,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -3022,10 +2768,7 @@ export type MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3035,10 +2778,7 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -3069,10 +2809,7 @@ export type MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3082,10 +2819,7 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -3109,18 +2843,12 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -3130,18 +2858,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -3179,10 +2901,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -3377,10 +3096,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -3581,10 +3297,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -3594,13 +3307,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue" - ] + "isSigner": false }, { "name": "bids", @@ -3641,10 +3348,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3654,10 +3358,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -3673,10 +3374,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3686,14 +3384,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3773,10 +3464,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3786,14 +3474,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3879,10 +3560,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -3892,14 +3570,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -3987,10 +3658,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4000,14 +3668,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -4101,10 +3762,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4114,12 +3772,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4150,10 +3803,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4163,12 +3813,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4199,10 +3844,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4212,12 +3854,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4248,10 +3885,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -4261,12 +3895,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4305,11 +3934,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "event_queue" - ] + "isSigner": false }, { "name": "eventQueue", @@ -4335,13 +3960,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -4372,10 +3991,7 @@ export type MangoV4 = { { "name": "settler", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settlerOwner", @@ -4385,27 +4001,17 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4415,10 +4021,7 @@ export type MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -4439,27 +4042,17 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4480,19 +4073,12 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -4502,10 +4088,7 @@ export type MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -4531,11 +4114,7 @@ export type MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4545,10 +4124,7 @@ export type MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4558,18 +4134,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4604,20 +4174,12 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -4643,18 +4205,12 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4664,19 +4220,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4686,10 +4235,7 @@ export type MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4725,18 +4271,12 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -4746,19 +4286,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -4768,10 +4301,7 @@ export type MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -4791,10 +4321,7 @@ export type MangoV4 = { { "name": "insuranceBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "insuranceBankVault", @@ -4830,10 +4357,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -4843,18 +4367,12 @@ export type MangoV4 = { { "name": "buyBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "sellBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -4903,10 +4421,7 @@ export type MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -4919,18 +4434,12 @@ export type MangoV4 = { "isSigner": false, "docs": [ "The bank's token_index is checked at #1" - ], - "relations": [ - "group" ] }, { "name": "sellBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -4955,18 +4464,12 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorAuthority", @@ -4999,10 +4502,7 @@ export type MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -5028,10 +4528,7 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -5073,10 +4570,7 @@ export type MangoV4 = { { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -10853,19 +10347,12 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -10896,27 +10383,17 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault" - ] + "isSigner": false }, { "name": "vault", @@ -11039,10 +10516,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -11137,11 +10611,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault", - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -11198,11 +10668,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin", - "insurance_vault" - ] + "isSigner": false }, { "name": "admin", @@ -11233,10 +10699,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -11574,10 +11037,7 @@ export const IDL: MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -11742,10 +11202,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -11760,11 +11217,7 @@ export const IDL: MangoV4 = { { "name": "existingBank", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "bank", @@ -11827,11 +11280,7 @@ export const IDL: MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "mint" - ] + "isSigner": false }, { "name": "payer", @@ -11871,10 +11320,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -11884,10 +11330,7 @@ export const IDL: MangoV4 = { { "name": "mintInfo", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "dustVault", @@ -11918,11 +11361,7 @@ export const IDL: MangoV4 = { { "name": "mintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "oracle", - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -12028,11 +11467,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12080,11 +11515,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12136,11 +11567,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12174,10 +11601,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "admin", @@ -12203,11 +11627,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12243,10 +11663,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -12256,18 +11673,12 @@ export const IDL: MangoV4 = { { "name": "daoAccount", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "mngoOracle", @@ -12277,10 +11688,7 @@ export const IDL: MangoV4 = { { "name": "feesBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "feesOracle", @@ -12301,10 +11709,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "oracle", @@ -12367,10 +11772,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -12380,10 +11782,7 @@ export const IDL: MangoV4 = { { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -12404,10 +11803,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -12417,10 +11813,7 @@ export const IDL: MangoV4 = { { "name": "oracle", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -12443,11 +11836,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12457,12 +11846,7 @@ export const IDL: MangoV4 = { { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -12512,20 +11896,12 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -12575,11 +11951,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "owner" - ] + "isSigner": false }, { "name": "owner", @@ -12589,12 +11961,7 @@ export const IDL: MangoV4 = { { "name": "bank", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "vault", - "oracle" - ] + "isSigner": false }, { "name": "vault", @@ -12743,10 +12110,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -12773,10 +12137,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -12844,18 +12205,12 @@ export const IDL: MangoV4 = { { "name": "quoteBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "payer", @@ -12895,10 +12250,7 @@ export const IDL: MangoV4 = { { "name": "market", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -12928,10 +12280,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -12941,18 +12290,12 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "indexReservation", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "solDestination", @@ -12978,10 +12321,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -12991,12 +12331,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13061,10 +12396,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13074,12 +12406,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13115,10 +12442,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13133,12 +12457,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13194,9 +12513,6 @@ export const IDL: MangoV4 = { "isSigner": false, "docs": [ "The bank that pays for the order, if necessary" - ], - "relations": [ - "group" ] }, { @@ -13270,10 +12586,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13288,12 +12601,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13345,10 +12653,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13363,12 +12668,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13420,10 +12720,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13438,12 +12735,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13476,10 +12768,7 @@ export const IDL: MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -13489,10 +12778,7 @@ export const IDL: MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -13525,10 +12811,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -13543,12 +12826,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13581,10 +12859,7 @@ export const IDL: MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -13594,10 +12869,7 @@ export const IDL: MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -13645,10 +12917,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "openOrders", @@ -13658,12 +12927,7 @@ export const IDL: MangoV4 = { { "name": "serumMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "serum_program", - "serum_market_external" - ] + "isSigner": false }, { "name": "serumProgram", @@ -13708,10 +12972,7 @@ export const IDL: MangoV4 = { { "name": "quoteBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -13721,10 +12982,7 @@ export const IDL: MangoV4 = { { "name": "baseBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "baseVault", @@ -13755,10 +13013,7 @@ export const IDL: MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -13768,10 +13023,7 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -13797,18 +13049,12 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -13818,18 +13064,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -13867,10 +13107,7 @@ export const IDL: MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -13880,10 +13117,7 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -13914,10 +13148,7 @@ export const IDL: MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -13927,10 +13158,7 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -13954,18 +13182,12 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -13975,18 +13197,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liabMintInfo", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "quoteVault", @@ -14024,10 +13240,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -14222,10 +13435,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -14426,10 +13636,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -14439,13 +13646,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue" - ] + "isSigner": false }, { "name": "bids", @@ -14486,10 +13687,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14499,10 +13697,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] @@ -14518,10 +13713,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14531,14 +13723,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -14618,10 +13803,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14631,14 +13813,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -14724,10 +13899,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14737,14 +13909,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -14832,10 +13997,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14845,14 +14007,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "event_queue", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -14946,10 +14101,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -14959,12 +14111,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -14995,10 +14142,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -15008,12 +14152,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -15044,10 +14183,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -15057,12 +14193,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -15093,10 +14224,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "owner", @@ -15106,12 +14234,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -15150,11 +14273,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "event_queue" - ] + "isSigner": false }, { "name": "eventQueue", @@ -15180,13 +14299,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks", - "oracle" - ] + "isSigner": false }, { "name": "bids", @@ -15217,10 +14330,7 @@ export const IDL: MangoV4 = { { "name": "settler", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settlerOwner", @@ -15230,27 +14340,17 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": false, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -15260,10 +14360,7 @@ export const IDL: MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -15284,27 +14381,17 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "accountA", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "accountB", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -15325,19 +14412,12 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "oracle", @@ -15347,10 +14427,7 @@ export const IDL: MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleOracle", @@ -15376,11 +14453,7 @@ export const IDL: MangoV4 = { { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -15390,10 +14463,7 @@ export const IDL: MangoV4 = { { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -15403,18 +14473,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -15449,20 +14513,12 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "bids", - "asks" - ] + "isSigner": false }, { "name": "bids", @@ -15488,18 +14544,12 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -15509,19 +14559,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -15531,10 +14574,7 @@ export const IDL: MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -15570,18 +14610,12 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "insurance_vault" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorOwner", @@ -15591,19 +14625,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "perpMarket", "isMut": true, - "isSigner": false, - "relations": [ - "group", - "oracle" - ] + "isSigner": false }, { "name": "oracle", @@ -15613,10 +14640,7 @@ export const IDL: MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "settleVault", @@ -15636,10 +14660,7 @@ export const IDL: MangoV4 = { { "name": "insuranceBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "insuranceBankVault", @@ -15675,10 +14696,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -15688,18 +14706,12 @@ export const IDL: MangoV4 = { { "name": "buyBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "sellBank", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -15748,10 +14760,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "authority", @@ -15764,18 +14773,12 @@ export const IDL: MangoV4 = { "isSigner": false, "docs": [ "The bank's token_index is checked at #1" - ], - "relations": [ - "group" ] }, { "name": "sellBank", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [ @@ -15800,18 +14803,12 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqor", "isMut": true, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false }, { "name": "liqorAuthority", @@ -15844,10 +14841,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": true, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -15873,10 +14867,7 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false, - "relations": [ - "admin" - ] + "isSigner": false }, { "name": "admin", @@ -15918,10 +14909,7 @@ export const IDL: MangoV4 = { { "name": "account", "isMut": false, - "isSigner": false, - "relations": [ - "group" - ] + "isSigner": false } ], "args": [] From c7cc7c248cd195dc31d7a3bc5168e666368e38ec Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Thu, 10 Aug 2023 16:16:05 +0200 Subject: [PATCH 03/46] ts: fix threshold price computation in token conditional swaps Signed-off-by: microwavedcola1 --- ts/client/src/accounts/mangoAccount.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index 4b6c8bbd3..da028f50a 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -1875,15 +1875,16 @@ export class TokenConditionalSwap { } getThresholdPriceUi(group: Group): number { - const a = I80F48.fromNumber(this.priceLowerLimit); - const b = I80F48.fromNumber(this.priceUpperLimit); - const buyBank = this.getBuyToken(group); const sellBank = this.getSellToken(group); - const o = buyBank.price.div(sellBank.price); + + const a = toUiSellPerBuyTokenPrice(this.priceLowerLimit, sellBank, buyBank); + const b = toUiSellPerBuyTokenPrice(this.priceUpperLimit, sellBank, buyBank); + + const o = buyBank.uiPrice / sellBank.uiPrice; // Choose the price closest to oracle - if (o.sub(a).abs().lt(o.sub(b).abs())) { + if (Math.abs(o - a) < Math.abs(o - b)) { return this.getPriceLowerLimitUi(group); } return this.getPriceUpperLimitUi(group); From 10d26f0b07dd2be5575842196155493fd74d0d39 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Thu, 10 Aug 2023 16:16:52 +0200 Subject: [PATCH 04/46] v0.18.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2e0736f1..765f365a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.18.14", + "version": "0.18.15", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 707de12bb727d11b8afda10367aa96cc144fc7cd Mon Sep 17 00:00:00 2001 From: Vladimir Guguiev Date: Fri, 11 Aug 2023 10:35:57 +0300 Subject: [PATCH 05/46] Client: wrap SOL using createWithSeed (#671) --- ts/client/src/client.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index f2fa15887..5ad239033 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -1306,39 +1306,46 @@ export class MangoClient { const tokenAccountPk = await getAssociatedTokenAddress( mintPk, mangoAccount.owner, - true, ); - let wrappedSolAccount: Keypair | undefined; + let wrappedSolAccount: PublicKey | undefined; let preInstructions: TransactionInstruction[] = []; let postInstructions: TransactionInstruction[] = []; - const additionalSigners: Signer[] = []; if (mintPk.equals(NATIVE_MINT)) { - wrappedSolAccount = new Keypair(); + // Generate a random seed for wrappedSolAccount. + const seed = Keypair.generate().publicKey.toBase58().slice(0, 32); + // Calculate a publicKey that will be controlled by the `mangoAccount.owner`. + wrappedSolAccount = await PublicKey.createWithSeed( + mangoAccount.owner, + seed, + TOKEN_PROGRAM_ID, + ); + const lamports = nativeAmount.add(new BN(1e7)); preInstructions = [ - SystemProgram.createAccount({ + SystemProgram.createAccountWithSeed({ fromPubkey: mangoAccount.owner, - newAccountPubkey: wrappedSolAccount.publicKey, + basePubkey: mangoAccount.owner, + seed, + newAccountPubkey: wrappedSolAccount, lamports: lamports.toNumber(), space: 165, programId: TOKEN_PROGRAM_ID, }), createInitializeAccount3Instruction( - wrappedSolAccount.publicKey, + wrappedSolAccount, NATIVE_MINT, mangoAccount.owner, ), ]; postInstructions = [ createCloseAccountInstruction( - wrappedSolAccount.publicKey, + wrappedSolAccount, mangoAccount.owner, mangoAccount.owner, ), ]; - additionalSigners.push(wrappedSolAccount); } const healthRemainingAccounts: PublicKey[] = @@ -1353,7 +1360,7 @@ export class MangoClient { bank: bank.publicKey, vault: bank.vault, oracle: bank.oracle, - tokenAccount: wrappedSolAccount?.publicKey ?? tokenAccountPk, + tokenAccount: wrappedSolAccount ?? tokenAccountPk, tokenAuthority: mangoAccount.owner, }) .remainingAccounts( @@ -1364,11 +1371,11 @@ export class MangoClient { ) .instruction(); - return await this.sendAndConfirmTransactionForGroup( - group, - [...preInstructions, ix, ...postInstructions], - { additionalSigners }, - ); + return await this.sendAndConfirmTransactionForGroup(group, [ + ...preInstructions, + ix, + ...postInstructions, + ]); } public async tokenWithdraw( From b684c32e1ea6b2a1b574a7018810b83d9582fe2e Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 11 Aug 2023 09:42:10 +0200 Subject: [PATCH 06/46] v0.18.16 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 765f365a7..0f08dd806 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.18.15", + "version": "0.18.16", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 72cb639ec9cfacc61f535ea50dde9f15c103ca13 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 11 Aug 2023 12:48:50 +0200 Subject: [PATCH 07/46] liquidator: increase tx budget for tcs trigger instructions (#674) (cherry picked from commit 8746060be0ff138f227ef0ebe67ab765a84e55c4) --- bin/liquidator/README.md | 1 + bin/liquidator/src/main.rs | 5 +++++ bin/liquidator/src/trigger_tcs.rs | 16 ++++++++++++---- lib/client/src/client.rs | 6 +++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/liquidator/README.md b/bin/liquidator/README.md index 9882b5964..9463c6877 100644 --- a/bin/liquidator/README.md +++ b/bin/liquidator/README.md @@ -46,6 +46,7 @@ more advanced parameters - `MIN_HEALTH_RATIO` - minimum health ratio the liquidator should retain (default 50%) - `REBALANCE_SLIPPAGE_BPS` - slippage liquidator should tolerate when offloading tokens (default 100) +- `COMPUTE_LIMIT_FOR_TCS` - compute to request for token conditional swap trigger instructions (default 300k) ```shell cargo run --bin liquidator diff --git a/bin/liquidator/src/main.rs b/bin/liquidator/src/main.rs index 064e49674..9eb467488 100644 --- a/bin/liquidator/src/main.rs +++ b/bin/liquidator/src/main.rs @@ -90,6 +90,10 @@ struct Cli { #[clap(long, env, default_value = "0")] prioritization_micro_lamports: u64, + /// compute limit requested for tcs trigger instructions + #[clap(long, env, default_value = "300000")] + compute_limit_for_tcs: u32, + /// use a jupiter mock instead of actual queries /// /// This is required for devnet testing. @@ -250,6 +254,7 @@ async fn main() -> anyhow::Result<()> { min_health_ratio: cli.min_health_ratio, max_trigger_quote_amount: 1_000_000_000, // TODO: config, $1000 mock_jupiter: cli.mock_jupiter == BoolArg::True, + compute_limit_for_trigger: cli.compute_limit_for_tcs, // TODO: config refresh_timeout: Duration::from_secs(30), }; diff --git a/bin/liquidator/src/trigger_tcs.rs b/bin/liquidator/src/trigger_tcs.rs index b017bb72a..6aa7e1a5a 100644 --- a/bin/liquidator/src/trigger_tcs.rs +++ b/bin/liquidator/src/trigger_tcs.rs @@ -14,6 +14,7 @@ pub struct Config { pub max_trigger_quote_amount: u64, pub refresh_timeout: Duration, pub mock_jupiter: bool, + pub compute_limit_for_trigger: u32, } async fn tcs_is_in_price_range( @@ -212,14 +213,20 @@ async fn execute_token_conditional_swap( "executing token conditional swap", ); - let txsig = mango_client - .token_conditional_swap_trigger( + let compute_ix = solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_limit( + config.compute_limit_for_trigger, + ); + let trigger_ix = mango_client + .token_conditional_swap_trigger_instruction( (pubkey, &liqee), tcs.id, max_buy_token_to_liqee, max_sell_token_to_liqor, ) .await?; + let txsig = mango_client + .send_and_confirm_owner_tx(vec![compute_ix, trigger_ix]) + .await?; info!( %txsig, "Executed token conditional swap", @@ -248,9 +255,10 @@ pub async fn remove_expired_token_conditional_swap( liqee: &MangoAccountValue, tcs_id: u64, ) -> anyhow::Result { - let txsig = mango_client - .token_conditional_swap_trigger((pubkey, &liqee), tcs_id, 0, 0) + let ix = mango_client + .token_conditional_swap_trigger_instruction((pubkey, &liqee), tcs_id, 0, 0) .await?; + let txsig = mango_client.send_and_confirm_owner_tx(vec![ix]).await?; info!( %txsig, "Removed expired token conditional swap", diff --git a/lib/client/src/client.rs b/lib/client/src/client.rs index bf00463bc..872a5ee87 100644 --- a/lib/client/src/client.rs +++ b/lib/client/src/client.rs @@ -1258,13 +1258,13 @@ impl MangoClient { self.send_and_confirm_owner_tx(vec![ix]).await } - pub async fn token_conditional_swap_trigger( + pub async fn token_conditional_swap_trigger_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), token_conditional_swap_id: u64, max_buy_token_to_liqee: u64, max_sell_token_to_liqor: u64, - ) -> anyhow::Result { + ) -> anyhow::Result { let (tcs_index, tcs) = liqee .1 .token_conditional_swap_by_id(token_conditional_swap_id)?; @@ -1302,7 +1302,7 @@ impl MangoClient { }, ), }; - self.send_and_confirm_owner_tx(vec![ix]).await + Ok(ix) } // health region From c37e535273d159c89f16ee3bc259a84d61811b4f Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 11 Aug 2023 16:46:19 +0200 Subject: [PATCH 08/46] Fix price limit calculation in tcs Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 91 ++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 5ad239033..46e3f266b 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -23,7 +23,6 @@ import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, - Signer, SystemProgram, TransactionInstruction, TransactionSignature, @@ -3398,13 +3397,24 @@ export class MangoClient { ); } + if (!thresholdPriceInSellPerBuyToken) { + thresholdPriceUi = 1 / thresholdPriceUi; + } + const thresholdPrice = toNativeSellPerBuyTokenPrice( + thresholdPriceUi, + sellBank, + buyBank, + ); + const lowerLimit = 0; + const upperLimit = thresholdPrice; + return await this.tokenConditionalSwapCreate( group, account, sellBank, buyBank, - thresholdPriceUi, - thresholdPriceInSellPerBuyToken, + lowerLimit, + upperLimit, Number.MAX_SAFE_INTEGER, maxSellUi ?? account.getTokenBalanceUi(sellBank), 'TakeProfitOnDeposit', @@ -3434,13 +3444,24 @@ export class MangoClient { ); } + if (!thresholdPriceInSellPerBuyToken) { + thresholdPriceUi = 1 / thresholdPriceUi; + } + const thresholdPrice = toNativeSellPerBuyTokenPrice( + thresholdPriceUi, + sellBank, + buyBank, + ); + const lowerLimit = thresholdPrice; + const upperLimit = Number.MAX_SAFE_INTEGER; + return await this.tokenConditionalSwapCreate( group, account, sellBank, buyBank, - thresholdPriceUi, - thresholdPriceInSellPerBuyToken, + lowerLimit, + upperLimit, Number.MAX_SAFE_INTEGER, maxSellUi ?? account.getTokenBalanceUi(sellBank), 'StopLossOnDeposit', @@ -3471,13 +3492,24 @@ export class MangoClient { ); } + if (!thresholdPriceInSellPerBuyToken) { + thresholdPriceUi = 1 / thresholdPriceUi; + } + const thresholdPrice = toNativeSellPerBuyTokenPrice( + thresholdPriceUi, + sellBank, + buyBank, + ); + const lowerLimit = thresholdPrice; + const upperLimit = Number.MAX_SAFE_INTEGER; + return await this.tokenConditionalSwapCreate( group, account, sellBank, buyBank, - thresholdPriceUi, - thresholdPriceInSellPerBuyToken, + lowerLimit, + upperLimit, maxBuyUi ?? -account.getTokenBalanceUi(buyBank), Number.MAX_SAFE_INTEGER, 'TakeProfitOnBorrow', @@ -3508,13 +3540,24 @@ export class MangoClient { ); } + if (!thresholdPriceInSellPerBuyToken) { + thresholdPriceUi = 1 / thresholdPriceUi; + } + const thresholdPrice = toNativeSellPerBuyTokenPrice( + thresholdPriceUi, + sellBank, + buyBank, + ); + const lowerLimit = 0; + const upperLimit = thresholdPrice; + return await this.tokenConditionalSwapCreate( group, account, sellBank, buyBank, - thresholdPriceUi, - thresholdPriceInSellPerBuyToken, + lowerLimit, + upperLimit, maxBuyUi ?? -account.getTokenBalanceUi(buyBank), Number.MAX_SAFE_INTEGER, 'StopLossOnBorrow', @@ -3530,8 +3573,8 @@ export class MangoClient { account: MangoAccount, sellBank: Bank, buyBank: Bank, - thresholdPriceUi: number, - thresholdPriceInSellPerBuyToken: boolean, + lowerLimit: number, + upperLimit: number, maxBuyUi: number, maxSellUi: number, tcsIntention: @@ -3554,32 +3597,6 @@ export class MangoClient { ? U64_MAX_BN : toNative(maxSellUi, sellBank.mintDecimals); - if (!thresholdPriceInSellPerBuyToken) { - thresholdPriceUi = 1 / thresholdPriceUi; - } - - let lowerLimit, upperLimit; - const thresholdPrice = toNativeSellPerBuyTokenPrice( - thresholdPriceUi, - sellBank, - buyBank, - ); - const sellTokenPerBuyTokenPrice = buyBank.price - .div(sellBank.price) - .toNumber(); - - if ( - tcsIntention == 'TakeProfitOnDeposit' || - tcsIntention == 'StopLossOnBorrow' || - (tcsIntention == null && thresholdPrice > sellTokenPerBuyTokenPrice) - ) { - lowerLimit = thresholdPrice; - upperLimit = Number.MAX_SAFE_INTEGER; - } else { - lowerLimit = 0; - upperLimit = thresholdPrice; - } - const expiryTimestampBn = expiryTimestamp !== null ? new BN(expiryTimestamp) : U64_MAX_BN; From c1be446aab155d14f00262378269922320004b78 Mon Sep 17 00:00:00 2001 From: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com> Date: Fri, 11 Aug 2023 19:12:13 +0200 Subject: [PATCH 09/46] Mc/slot to tx (#676) * v0.18.17 * ts: return confirmed slot when executing a tx Signed-off-by: microwavedcola1 * Fixes from review Signed-off-by: microwavedcola1 --------- Signed-off-by: microwavedcola1 --- package.json | 2 +- ts/client/scripts/archive/mb-admin.ts | 2 +- ts/client/src/accounts/mangoAccount.ts | 7 +- ts/client/src/client.ts | 143 ++++++++++++------------- ts/client/src/index.ts | 1 + ts/client/src/utils/rpc.ts | 15 ++- 6 files changed, 91 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index 0f08dd806..584100226 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.18.16", + "version": "0.18.17", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { diff --git a/ts/client/scripts/archive/mb-admin.ts b/ts/client/scripts/archive/mb-admin.ts index ae9b831c9..c38b47ee2 100644 --- a/ts/client/scripts/archive/mb-admin.ts +++ b/ts/client/scripts/archive/mb-admin.ts @@ -679,7 +679,7 @@ async function createAndPopulateAlt() { ); console.log(`ALT: set at index 0 for group...`); - sig = await client.altSet(group, createIx[1], 0); + sig = (await client.altSet(group, createIx[1], 0)).signature; console.log(`...https://explorer.solana.com/tx/${sig}`); } catch (error) { console.log(error); diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index da028f50a..4ba6197d8 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -1,7 +1,7 @@ import { AnchorProvider, BN } from '@coral-xyz/anchor'; import { utf8 } from '@coral-xyz/anchor/dist/cjs/utils/bytes'; import { OpenOrders, Order, Orderbook } from '@project-serum/serum/lib/market'; -import { AccountInfo, PublicKey, TransactionSignature } from '@solana/web3.js'; +import { AccountInfo, PublicKey } from '@solana/web3.js'; import { MangoClient } from '../client'; import { OPENBOOK_PROGRAM_ID, RUST_I64_MAX, RUST_I64_MIN } from '../constants'; import { I80F48, I80F48Dto, ONE_I80F48, ZERO_I80F48 } from '../numbers/I80F48'; @@ -13,6 +13,7 @@ import { toUiDecimalsForQuote, toUiSellPerBuyTokenPrice, } from '../utils'; +import { MangoSignatureStatus } from '../utils/rpc'; import { Bank, TokenIndex } from './bank'; import { Group } from './group'; import { HealthCache } from './healthCache'; @@ -888,7 +889,7 @@ export class MangoAccount { public async serum3SettleFundsForAllMarkets( client: MangoClient, group: Group, - ): Promise { + ): Promise { // Future: collect ixs, batch them, and send them in fewer txs return await Promise.all( this.serum3Active().map((s) => { @@ -906,7 +907,7 @@ export class MangoAccount { public async serum3CancelAllOrdersForAllMarkets( client: MangoClient, group: Group, - ): Promise { + ): Promise { // Future: collect ixs, batch them, and send them in in fewer txs return await Promise.all( this.serum3Active().map((s) => { diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 46e3f266b..6c93aa961 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -25,7 +25,6 @@ import { SYSVAR_RENT_PUBKEY, SystemProgram, TransactionInstruction, - TransactionSignature, } from '@solana/web3.js'; import bs58 from 'bs58'; import chunk from 'lodash/chunk'; @@ -78,7 +77,7 @@ import { toNative, toNativeSellPerBuyTokenPrice, } from './utils'; -import { sendTransaction } from './utils/rpc'; +import { MangoSignatureStatus, sendTransaction } from './utils/rpc'; import { NATIVE_MINT, TOKEN_PROGRAM_ID } from './utils/spl'; export const DEFAULT_TOKEN_CONDITIONAL_SWAP_COUNT = 8; @@ -136,7 +135,7 @@ export class MangoClient { public async sendAndConfirmTransaction( ixs: TransactionInstruction[], opts: any = {}, - ): Promise { + ): Promise { return await sendTransaction( this.program.provider as AnchorProvider, ixs, @@ -154,7 +153,7 @@ export class MangoClient { group: Group, ixs: TransactionInstruction[], opts: any = {}, - ): Promise { + ): Promise { return await this.sendAndConfirmTransaction(ixs, { alts: group.addressLookupTablesList, ...opts, @@ -165,7 +164,7 @@ export class MangoClient { group: Group, bank: Bank, tokenAccountPk: PublicKey, - ): Promise { + ): Promise { const admin = (this.program.provider as AnchorProvider).wallet.publicKey; const ix = await this.program.methods .admingTokenWithdrawFees() @@ -184,7 +183,7 @@ export class MangoClient { group: Group, perpMarket: PerpMarket, tokenAccountPk: PublicKey, - ): Promise { + ): Promise { const bank = group.getFirstBankByTokenIndex(perpMarket.settleTokenIndex); const admin = (this.program.provider as AnchorProvider).wallet.publicKey; const ix = await this.program.methods @@ -207,7 +206,7 @@ export class MangoClient { testing: boolean, version: number, insuranceMintPk: PublicKey, - ): Promise { + ): Promise { const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; const ix = await this.program.methods .groupCreate(groupNum, testing ? 1 : 0, version) @@ -235,7 +234,7 @@ export class MangoClient { feesExpiryInterval?: BN, tokenConditionalSwapTakerFeeFraction?: number, tokenConditionalSwapMakerFeeFraction?: number, - ): Promise { + ): Promise { const ix = await this.program.methods .groupEdit( admin ?? null, @@ -263,7 +262,7 @@ export class MangoClient { public async ixGateSet( group: Group, ixGateParams: IxGateParams, - ): Promise { + ): Promise { const ix = await this.program.methods .ixGateSet(buildIxGate(ixGateParams)) .accounts({ @@ -274,7 +273,7 @@ export class MangoClient { return await this.sendAndConfirmTransactionForGroup(group, [ix]); } - public async groupClose(group: Group): Promise { + public async groupClose(group: Group): Promise { const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; const ix = await this.program.methods .groupClose() @@ -371,7 +370,7 @@ export class MangoClient { minVaultToDepositsRatio: number, netBorrowLimitWindowSizeTs: number, netBorrowLimitPerWindowQuote: number, - ): Promise { + ): Promise { const ix = await this.program.methods .tokenRegister( tokenIndex, @@ -407,7 +406,7 @@ export class MangoClient { oraclePk: PublicKey, tokenIndex: number, name: string, - ): Promise { + ): Promise { const ix = await this.program.methods .tokenRegisterTrustless(tokenIndex, name) .accounts({ @@ -426,7 +425,7 @@ export class MangoClient { group: Group, mintPk: PublicKey, params: TokenEditParams, - ): Promise { + ): Promise { const bank = group.getFirstBankByMint(mintPk); const mintInfo = group.mintInfosMapByTokenIndex.get(bank.tokenIndex)!; @@ -485,7 +484,7 @@ export class MangoClient { assetTokenIndex: TokenIndex, liabTokenIndex: TokenIndex, maxLiabTransfer?: number, - ): Promise { + ): Promise { const assetBank = group.getFirstBankByTokenIndex(assetTokenIndex); const liabBank = group.getFirstBankByTokenIndex(liabTokenIndex); const healthRemainingAccounts: PublicKey[] = @@ -528,7 +527,7 @@ export class MangoClient { public async tokenDeregister( group: Group, mintPk: PublicKey, - ): Promise { + ): Promise { const bank = group.getFirstBankByMint(mintPk); const adminPk = (this.program.provider as AnchorProvider).wallet.publicKey; @@ -632,7 +631,7 @@ export class MangoClient { group: Group, mintPk: PublicKey, price: number, - ): Promise { + ): Promise { const ix = await this.program.methods .stubOracleCreate({ val: I80F48.fromNumber(price).getData() }) .accounts({ @@ -648,7 +647,7 @@ export class MangoClient { public async stubOracleClose( group: Group, oracle: PublicKey, - ): Promise { + ): Promise { const ix = await this.program.methods .stubOracleClose() .accounts({ @@ -665,7 +664,7 @@ export class MangoClient { group: Group, oraclePk: PublicKey, price: number, - ): Promise { + ): Promise { const ix = await this.program.methods .stubOracleSet({ val: I80F48.fromNumber(price).getData() }) .accounts({ @@ -714,7 +713,7 @@ export class MangoClient { serum3Count?: number, perpCount?: number, perpOoCount?: number, - ): Promise { + ): Promise { const ix = await this.program.methods .accountCreate( accountNumber ?? 0, @@ -741,7 +740,7 @@ export class MangoClient { serum3Count: number, perpCount: number, perpOoCount: number, - ): Promise { + ): Promise { const ix = await this.program.methods .accountExpand(tokenCount, serum3Count, perpCount, perpOoCount) .accounts({ @@ -762,7 +761,7 @@ export class MangoClient { perpCount: number, perpOoCount: number, tokenConditionalSwapCount: number, - ): Promise { + ): Promise { const ix = await this.accountExpandV2Ix( group, account, @@ -806,7 +805,7 @@ export class MangoClient { mangoAccount: MangoAccount, name?: string, delegate?: PublicKey, - ): Promise { + ): Promise { const ix = await this.program.methods .accountEdit(name ?? null, delegate ?? null) .accounts({ @@ -822,7 +821,7 @@ export class MangoClient { public async computeAccountData( group: Group, mangoAccount: MangoAccount, - ): Promise { + ): Promise { const healthRemainingAccounts: PublicKey[] = this.buildHealthRemainingAccounts(group, [mangoAccount], [], []); @@ -847,7 +846,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, freeze: boolean, - ): Promise { + ): Promise { const ix = await this.program.methods .accountToggleFreeze(freeze) .accounts({ @@ -1164,7 +1163,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, forceClose = false, - ): Promise { + ): Promise { const ix = await this.program.methods .accountClose(forceClose) .accounts({ @@ -1181,7 +1180,7 @@ export class MangoClient { public async emptyAndCloseMangoAccount( group: Group, mangoAccount: MangoAccount, - ): Promise { + ): Promise { // Work on a deep cloned mango account, since we would deactivating positions // before deactivation reaches on-chain state in order to simplify building a fresh list // of healthRemainingAccounts to each subsequent ix @@ -1266,7 +1265,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, maxBuyback?: number, - ): Promise { + ): Promise { const ix = await this.accountBuybackFeesWithMngoIx( group, mangoAccount, @@ -1281,7 +1280,7 @@ export class MangoClient { mintPk: PublicKey, amount: number, reduceOnly = false, - ): Promise { + ): Promise { const decimals = group.getMintDecimals(mintPk); const nativeAmount = toNative(amount, decimals); return await this.tokenDepositNative( @@ -1299,7 +1298,7 @@ export class MangoClient { mintPk: PublicKey, nativeAmount: BN, reduceOnly = false, - ): Promise { + ): Promise { const bank = group.getFirstBankByMint(mintPk); const tokenAccountPk = await getAssociatedTokenAddress( @@ -1383,7 +1382,7 @@ export class MangoClient { mintPk: PublicKey, amount: number, allowBorrow: boolean, - ): Promise { + ): Promise { const nativeAmount = toNative(amount, group.getMintDecimals(mintPk)); const ixes = await this.tokenWithdrawNativeIx( group, @@ -1466,7 +1465,7 @@ export class MangoClient { mintPk: PublicKey, nativeAmount: BN, allowBorrow: boolean, - ): Promise { + ): Promise { const ixs = await this.tokenWithdrawNativeIx( group, mangoAccount, @@ -1486,7 +1485,7 @@ export class MangoClient { quoteBank: Bank, marketIndex: number, name: string, - ): Promise { + ): Promise { const ix = await this.program.methods .serum3RegisterMarket(marketIndex, name) .accounts({ @@ -1508,7 +1507,7 @@ export class MangoClient { reduceOnly: boolean | null, forceClose: boolean | null, name: string | null, - ): Promise { + ): Promise { const serum3Market = group.serum3MarketsMapByMarketIndex.get(serum3MarketIndex); const ix = await this.program.methods @@ -1525,7 +1524,7 @@ export class MangoClient { public async serum3deregisterMarket( group: Group, externalMarketPk: PublicKey, - ): Promise { + ): Promise { const serum3Market = group.serum3MarketsMapByExternal.get( externalMarketPk.toBase58(), )!; @@ -1598,7 +1597,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, externalMarketPk: PublicKey, - ): Promise { + ): Promise { const serum3Market: Serum3Market = group.serum3MarketsMapByExternal.get( externalMarketPk.toBase58(), )!; @@ -1674,7 +1673,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, externalMarketPk: PublicKey, - ): Promise { + ): Promise { const ix = await this.serum3CloseOpenOrdersIx( group, mangoAccount, @@ -1696,7 +1695,7 @@ export class MangoClient { mangoAccount: MangoAccount, externalMarketPk: PublicKey, limit?: number, - ): Promise { + ): Promise { const serum3Market = group.serum3MarketsMapByExternal.get( externalMarketPk.toBase58(), )!; @@ -1891,7 +1890,7 @@ export class MangoClient { orderType: Serum3OrderType, clientOrderId: number, limit: number, - ): Promise { + ): Promise { const placeOrderIxes = await this.serum3PlaceOrderIx( group, mangoAccount, @@ -1955,7 +1954,7 @@ export class MangoClient { mangoAccount: MangoAccount, externalMarketPk: PublicKey, limit?: number, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.serum3CancelAllOrdersIx( group, @@ -2049,7 +2048,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, externalMarketPk: PublicKey, - ): Promise { + ): Promise { const ix = await this.serum3SettleFundsV2Ix( group, mangoAccount, @@ -2099,7 +2098,7 @@ export class MangoClient { externalMarketPk: PublicKey, side: Serum3Side, orderId: BN, - ): Promise { + ): Promise { const ixes = await Promise.all([ this.serum3CancelOrderIx( group, @@ -2146,7 +2145,7 @@ export class MangoClient { settlePnlLimitFactor: number, settlePnlLimitWindowSize: number, positivePnlLiquidationFee: number, - ): Promise { + ): Promise { const bids = new Keypair(); const asks = new Keypair(); const eventQueue = new Keypair(); @@ -2245,7 +2244,7 @@ export class MangoClient { group: Group, perpMarketIndex: PerpMarketIndex, params: PerpEditParams, - ): Promise { + ): Promise { const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex); const ix = await this.program.methods @@ -2298,7 +2297,7 @@ export class MangoClient { perpMarketIndex: PerpMarketIndex, accountA: MangoAccount, accountB: MangoAccount, - ): Promise { + ): Promise { const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex); const ix = await this.program.methods @@ -2317,7 +2316,7 @@ export class MangoClient { public async perpCloseMarket( group: Group, perpMarketIndex: PerpMarketIndex, - ): Promise { + ): Promise { const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex); const ix = await this.program.methods @@ -2383,7 +2382,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, perpMarketIndex: PerpMarketIndex, - ): Promise { + ): Promise { const ix = await this.perpDeactivatePositionIx( group, mangoAccount, @@ -2396,7 +2395,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, slippage = 0.01, // 1%, 100bps - ): Promise { + ): Promise { if (mangoAccount.perpActive().length == 0) { throw new Error(`No perp positions found.`); } @@ -2458,7 +2457,7 @@ export class MangoClient { reduceOnly?: boolean, expiryTimestamp?: number, limit?: number, - ): Promise { + ): Promise { const ix = await this.perpPlaceOrderV2Ix( group, mangoAccount, @@ -2606,7 +2605,7 @@ export class MangoClient { reduceOnly?: boolean, expiryTimestamp?: number, limit?: number, - ): Promise { + ): Promise { const ix = await this.perpPlaceOrderPeggedV2Ix( group, mangoAccount, @@ -2772,7 +2771,7 @@ export class MangoClient { mangoAccount: MangoAccount, perpMarketIndex: PerpMarketIndex, orderId: BN, - ): Promise { + ): Promise { const ix = await this.perpCancelOrderIx( group, mangoAccount, @@ -2788,7 +2787,7 @@ export class MangoClient { mangoAccount: MangoAccount, perpMarketIndex: PerpMarketIndex, limit: number, - ): Promise { + ): Promise { const ix = await this.perpCancelAllOrdersIx( group, mangoAccount, @@ -2824,7 +2823,7 @@ export class MangoClient { group: Group, mangoAccount: MangoAccount, allMangoAccounts?: MangoAccount[], - ): Promise { + ): Promise { if (!allMangoAccounts) { allMangoAccounts = await client.getAllMangoAccounts(group, true); } @@ -2905,7 +2904,7 @@ export class MangoClient { settler: MangoAccount, perpMarketIndex: PerpMarketIndex, maxSettleAmount?: number, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.perpSettlePnlIx( group, @@ -2929,7 +2928,7 @@ export class MangoClient { unprofitableAccount: MangoAccount, settler: MangoAccount, perpMarketIndex: PerpMarketIndex, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.perpSettlePnlIx( group, @@ -2985,7 +2984,7 @@ export class MangoClient { account: MangoAccount, perpMarketIndex: PerpMarketIndex, maxSettleAmount?: number, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.perpSettleFeesIx( group, @@ -3037,7 +3036,7 @@ export class MangoClient { perpMarketIndex: PerpMarketIndex, accounts: PublicKey[], limit: number, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.perpConsumeEventsIx(group, perpMarketIndex, accounts, limit), ]); @@ -3135,7 +3134,7 @@ export class MangoClient { userDefinedInstructions: TransactionInstruction[]; userDefinedAlts: AddressLookupTableAccount[]; flashLoanType: FlashLoanType; - }): Promise { + }): Promise { const isDelegate = ( this.program.provider as AnchorProvider ).wallet.publicKey.equals(mangoAccount.delegate); @@ -3298,7 +3297,7 @@ export class MangoClient { public async tokenUpdateIndexAndRate( group: Group, mintPk: PublicKey, - ): Promise { + ): Promise { return await this.sendAndConfirmTransactionForGroup(group, [ await this.tokenUpdateIndexAndRateIx(group, mintPk), ]); @@ -3338,7 +3337,7 @@ export class MangoClient { assetMintPk: PublicKey, liabMintPk: PublicKey, maxLiabTransfer: number, - ): Promise { + ): Promise { const assetBank: Bank = group.getFirstBankByMint(assetMintPk); const liabBank: Bank = group.getFirstBankByMint(liabMintPk); @@ -3388,7 +3387,7 @@ export class MangoClient { maxSellUi: number | null, pricePremium: number | null, expiryTimestamp: number | null, - ): Promise { + ): Promise { if (account.getTokenBalanceUi(sellBank) < 0) { throw new Error( `Only allowed to take profits on deposits! Current balance ${account.getTokenBalanceUi( @@ -3435,7 +3434,7 @@ export class MangoClient { maxSellUi: number | null, pricePremium: number | null, expiryTimestamp: number | null, - ): Promise { + ): Promise { if (account.getTokenBalanceUi(sellBank) < 0) { throw new Error( `Only allowed to set a stop loss on deposits! Current balance ${account.getTokenBalanceUi( @@ -3483,7 +3482,7 @@ export class MangoClient { pricePremium: number | null, allowMargin: boolean | null, expiryTimestamp: number | null, - ): Promise { + ): Promise { if (account.getTokenBalanceUi(buyBank) > 0) { throw new Error( `Only allowed to take profits on borrows! Current balance ${account.getTokenBalanceUi( @@ -3531,7 +3530,7 @@ export class MangoClient { pricePremium: number | null, allowMargin: boolean | null, expiryTimestamp: number | null, - ): Promise { + ): Promise { if (account.getTokenBalanceUi(buyBank) > 0) { throw new Error( `Only allowed to set stop loss on borrows! Current balance ${account.getTokenBalanceUi( @@ -3587,7 +3586,7 @@ export class MangoClient { allowCreatingDeposits: boolean, allowCreatingBorrows: boolean, expiryTimestamp: number | null, - ): Promise { + ): Promise { const maxBuy = maxBuyUi == Number.MAX_SAFE_INTEGER ? U64_MAX_BN @@ -3668,7 +3667,7 @@ export class MangoClient { pricePremiumFraction: number, allowCreatingDeposits: boolean, allowCreatingBorrows: boolean, - ): Promise { + ): Promise { const buyBank: Bank = group.getFirstBankByMint(buyMintPk); const sellBank: Bank = group.getFirstBankByMint(sellMintPk); const ix = await this.program.methods @@ -3713,7 +3712,7 @@ export class MangoClient { group: Group, account: MangoAccount, tokenConditionalSwapId: BN, - ): Promise { + ): Promise { const tokenConditionalSwapIndex = account.tokenConditionalSwaps.findIndex( (tcs) => tcs.id.eq(tokenConditionalSwapId), ); @@ -3745,7 +3744,7 @@ export class MangoClient { public async tokenConditionalSwapCancelAll( group: Group, account: MangoAccount, - ): Promise { + ): Promise { const ixs = await Promise.all( account.tokenConditionalSwaps .filter((tcs) => tcs.hasData) @@ -3778,7 +3777,7 @@ export class MangoClient { tokenConditionalSwapId: BN, maxBuyTokenToLiqee: number, maxSellTokenToLiqor: number, - ): Promise { + ): Promise { const tokenConditionalSwapIndex = liqee.tokenConditionalSwaps.findIndex( (tcs) => tcs.id.eq(tokenConditionalSwapId), ); @@ -3834,7 +3833,7 @@ export class MangoClient { group: Group, addressLookupTable: PublicKey, index: number, - ): Promise { + ): Promise { const ix = await this.program.methods .altSet(index) .accounts({ @@ -3852,7 +3851,7 @@ export class MangoClient { addressLookupTable: PublicKey, index: number, pks: PublicKey[], - ): Promise { + ): Promise { const ix = await this.program.methods .altExtend(index, pks) .accounts({ @@ -4136,7 +4135,7 @@ export class MangoClient { reduceOnly?: boolean, expiryTimestamp?: number, limit?: number, - ): Promise { + ): Promise { const transactionInstructions: TransactionInstruction[] = []; const [cancelOrderIx, placeOrderIx] = await Promise.all([ this.perpCancelOrderIx(group, mangoAccount, perpMarketIndex, orderId), @@ -4174,7 +4173,7 @@ export class MangoClient { orderType: Serum3OrderType, clientOrderId: number, limit: number, - ): Promise { + ): Promise { const transactionInstructions: TransactionInstruction[] = []; const [cancelOrderIx, settleIx, placeOrderIx] = await Promise.all([ this.serum3CancelOrderIx( diff --git a/ts/client/src/index.ts b/ts/client/src/index.ts index a70a20bec..68ddb931f 100644 --- a/ts/client/src/index.ts +++ b/ts/client/src/index.ts @@ -26,4 +26,5 @@ export * from './router'; export * from './stats'; export * from './types'; export * from './utils'; +export * from './utils/rpc'; export { Group, MANGO_V4_ID, MangoClient, OracleProvider, StubOracle }; diff --git a/ts/client/src/utils/rpc.ts b/ts/client/src/utils/rpc.ts index f42013897..c200f5c26 100644 --- a/ts/client/src/utils/rpc.ts +++ b/ts/client/src/utils/rpc.ts @@ -5,16 +5,27 @@ import { ComputeBudgetProgram, MessageV0, Signer, + TransactionConfirmationStatus, + TransactionError, TransactionInstruction, + TransactionSignature, VersionedTransaction, } from '@solana/web3.js'; +export interface MangoSignatureStatus { + slot: number; + confirmations: number | null; + err: TransactionError | null; + confirmationStatus?: TransactionConfirmationStatus; + signature: TransactionSignature; +} + export async function sendTransaction( provider: AnchorProvider, ixs: TransactionInstruction[], alts: AddressLookupTableAccount[], opts: any = {}, -): Promise { +): Promise { const connection = provider.connection; const latestBlockhash = opts.latestBlockhash ?? @@ -102,7 +113,7 @@ export async function sendTransaction( }); } - return signature; + return { signature, ...status }; } export const createComputeBudgetIx = ( From 916ed29498acf171fc6cd359869cc6d71b4e4bcf Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 11 Aug 2023 19:13:27 +0200 Subject: [PATCH 10/46] v0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 584100226..325bdb183 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.18.17", + "version": "0.19.0", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 765f82c5be143e0056f0b97dff22115cd5668ad7 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 11 Aug 2023 22:06:21 +0200 Subject: [PATCH 11/46] make helper function public Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 6c93aa961..a76efc19b 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -149,7 +149,7 @@ export class MangoClient { ); } - private async sendAndConfirmTransactionForGroup( + public async sendAndConfirmTransactionForGroup( group: Group, ixs: TransactionInstruction[], opts: any = {}, From 4fbedf97d1a2c7914db516b626bab299f54e0d66 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 11 Aug 2023 22:07:06 +0200 Subject: [PATCH 12/46] v0.19.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 325bdb183..cfad4f8ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.0", + "version": "0.19.1", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From f2d8e72057ea3353a611becc4b07c4a35e70a4ae Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sat, 12 Aug 2023 19:37:29 +0200 Subject: [PATCH 13/46] doesnt need to be async Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index a76efc19b..8a3b02b6f 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -872,7 +872,7 @@ export class MangoClient { private async getMangoAccountFromPk( mangoAccountPk: PublicKey, ): Promise { - return await this.getMangoAccountFromAi( + return this.getMangoAccountFromAi( mangoAccountPk, (await this.program.provider.connection.getAccountInfo( mangoAccountPk, @@ -880,10 +880,10 @@ export class MangoClient { ); } - public async getMangoAccountFromAi( + public getMangoAccountFromAi( mangoAccountPk: PublicKey, ai: AccountInfo, - ): Promise { + ): MangoAccount { const decodedMangoAccount = this.program.coder.accounts.decode( 'mangoAccount', ai.data, From 4f0f162b842c8a4e2002ced6db18d16be59f894d Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sat, 12 Aug 2023 19:38:11 +0200 Subject: [PATCH 14/46] v0.19.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfad4f8ce..e5871c901 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.1", + "version": "0.19.2", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From aa1a9f36e92d4f1514bb503babc46b155d36cdaf Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sun, 13 Aug 2023 12:01:20 +0200 Subject: [PATCH 15/46] ts: add tcs helper for current pair price Signed-off-by: microwavedcola1 --- ts/client/src/accounts/mangoAccount.ts | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index 4ba6197d8..e7b4321bc 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -1841,6 +1841,14 @@ export class TokenConditionalSwap { return this.expiryTimestamp.toNumber(); } + // TODO: will be replaced by onchain enum in next release + private getTokenConditionalSwapDisplayPriceStyle(): boolean { + if (this.maxSell.eq(U64_MAX_BN)) { + true; + } + return false; + } + private priceLimitToUi( group: Group, sellTokenPerBuyTokenNative: number, @@ -1858,7 +1866,7 @@ export class TokenConditionalSwap { // buytoken/selltoken or selltoken/buytoken // Buy limit / close short - if (this.maxSell.eq(U64_MAX_BN)) { + if (this.getTokenConditionalSwapDisplayPriceStyle()) { return roundTo5(sellTokenPerBuyTokenUi); } @@ -1891,6 +1899,29 @@ export class TokenConditionalSwap { return this.getPriceUpperLimitUi(group); } + getCurrentPairPriceUi(group: Group): number { + const buyBank = this.getBuyToken(group); + const sellBank = this.getSellToken(group); + const sellTokenPerBuyTokenUi = toUiSellPerBuyTokenPrice( + buyBank.price.div(sellBank.price).toNumber(), + sellBank, + buyBank, + ); + + // Below are workarounds to know when to show an inverted price in ui + // We want to identify if the pair user is wanting to trade is + // buytoken/selltoken or selltoken/buytoken + + // Buy limit / close short + if (this.getTokenConditionalSwapDisplayPriceStyle()) { + return roundTo5(sellTokenPerBuyTokenUi); + } + + // Stop loss / take profit + const buyTokenPerSellTokenUi = 1 / sellTokenPerBuyTokenUi; + return roundTo5(buyTokenPerSellTokenUi); + } + getPricePremium(): number { return this.pricePremiumFraction * 100; } From 40fb973731918c0680fb134d59438479d0d341ed Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sun, 13 Aug 2023 12:02:08 +0200 Subject: [PATCH 16/46] v0.19.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e5871c901..00dd8ee6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.2", + "version": "0.19.3", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From cc72f63d06d8b2f2de22e52baf24294b7a221d65 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sun, 20 Aug 2023 21:25:42 +0200 Subject: [PATCH 17/46] bump Signed-off-by: microwavedcola1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00dd8ee6c..aec3bbdd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.3", + "version": "0.19.4", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 447e7cb151ca9c9516867ea17290681ee5654fb8 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sun, 20 Aug 2023 21:30:12 +0200 Subject: [PATCH 18/46] ts: update tcs helpers Signed-off-by: microwavedcola1 --- ts/client/src/accounts/mangoAccount.ts | 36 +++++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ts/client/src/accounts/mangoAccount.ts b/ts/client/src/accounts/mangoAccount.ts index e7b4321bc..742063bc8 100644 --- a/ts/client/src/accounts/mangoAccount.ts +++ b/ts/client/src/accounts/mangoAccount.ts @@ -1842,11 +1842,23 @@ export class TokenConditionalSwap { } // TODO: will be replaced by onchain enum in next release - private getTokenConditionalSwapDisplayPriceStyle(): boolean { - if (this.maxSell.eq(U64_MAX_BN)) { - true; + private getTokenConditionalSwapDisplayPriceStyle(group: Group): boolean { + const buyBank = this.getBuyToken(group); + const sellBank = this.getSellToken(group); + + // If we are tp/sl'ing SOL borrow, then price is stored in sol/usdc + // then don't flip + if (sellBank.tokenIndex == 0) { + return true; } - return false; + + // E.g. + // If we are tp/sl'ing SOL deposit, then price is stored in usdc/sol + if (this.maxSell.eq(U64_MAX_BN)) { + true; // dont flip, i.e. continue using sellTokenPerBuyTokenUi price + } + // Flip the price if we know we are selling an exact amount of SOL + return false; // flip, i.e. use buyTokenPerSellTokenUi price } private priceLimitToUi( @@ -1866,7 +1878,7 @@ export class TokenConditionalSwap { // buytoken/selltoken or selltoken/buytoken // Buy limit / close short - if (this.getTokenConditionalSwapDisplayPriceStyle()) { + if (this.getTokenConditionalSwapDisplayPriceStyle(group)) { return roundTo5(sellTokenPerBuyTokenUi); } @@ -1913,7 +1925,7 @@ export class TokenConditionalSwap { // buytoken/selltoken or selltoken/buytoken // Buy limit / close short - if (this.getTokenConditionalSwapDisplayPriceStyle()) { + if (this.getTokenConditionalSwapDisplayPriceStyle(group)) { return roundTo5(sellTokenPerBuyTokenUi); } @@ -1943,16 +1955,20 @@ export class TokenConditionalSwap { } toString(group: Group): string { - return `getMaxBuy ${this.getMaxBuyUi( + return `${ + group.getFirstBankByTokenIndex(this.buyTokenIndex).name + + '/' + + group.getFirstBankByTokenIndex(this.sellTokenIndex).name + } , getMaxBuy ${this.getMaxBuyUi(group)}, getMaxSell ${this.getMaxSellUi( group, - )}, getMaxSell ${this.getMaxSellUi(group)}, bought ${this.getBoughtUi( - group, - )}, sold ${this.getSoldUi( + )}, bought ${this.getBoughtUi(group)}, sold ${this.getSoldUi( group, )}, getPriceLowerLimitUi ${this.getPriceLowerLimitUi( group, )}, getPriceUpperLimitUi ${this.getPriceUpperLimitUi( group, + )}, getCurrentPairPriceUi ${this.getCurrentPairPriceUi( + group, )}, getThresholdPriceUi ${this.getThresholdPriceUi( group, )}, getPricePremium ${this.getPricePremium()}, expiry ${this.expiryTimestamp.toString()}`; From 9e6ad1853ce13559921dad2cddd28b45ac64bfd6 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Sun, 20 Aug 2023 21:30:53 +0200 Subject: [PATCH 19/46] v0.19.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aec3bbdd1..c44be066d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.4", + "version": "0.19.5", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 5fd31270f639462e76da89615fbadfc0556cf05c Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 21 Aug 2023 07:38:35 +0200 Subject: [PATCH 20/46] v0.19.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c44be066d..63b609b25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.5", + "version": "0.19.6", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From ea0267000345d11eb8038942965a397f70e14f76 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 25 Aug 2023 15:20:00 +0200 Subject: [PATCH 21/46] ts: drop the premium calculators chunk size for tcs swap, we were overestimating slippage before Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 8a3b02b6f..bc833284a 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -3587,26 +3587,44 @@ export class MangoClient { allowCreatingBorrows: boolean, expiryTimestamp: number | null, ): Promise { - const maxBuy = - maxBuyUi == Number.MAX_SAFE_INTEGER - ? U64_MAX_BN - : toNative(maxBuyUi, buyBank.mintDecimals); - const maxSell = - maxSellUi == Number.MAX_SAFE_INTEGER - ? U64_MAX_BN - : toNative(maxSellUi, sellBank.mintDecimals); + let maxBuy, maxSell, buyAmountInUsd, sellAmountInUsd; + if (maxBuyUi == Number.MAX_SAFE_INTEGER) { + maxBuy = U64_MAX_BN; + } else { + buyAmountInUsd = maxBuyUi * buyBank.uiPrice; + maxBuy = toNative(maxBuyUi, buyBank.mintDecimals); + } + if (maxSellUi == Number.MAX_SAFE_INTEGER) { + maxSell = U64_MAX_BN; + } else { + sellAmountInUsd = maxSellUi * sellBank.uiPrice; + maxSell = toNative(maxSellUi, sellBank.mintDecimals); + } + + // Used for computing optimal premium + let liqorTcsChunkSizeInUsd = Math.min(buyAmountInUsd, sellAmountInUsd); + if (liqorTcsChunkSizeInUsd > 5000) { + liqorTcsChunkSizeInUsd = 5000; + } + // For small TCS swaps, reduce chunk size to 1000 USD + else { + liqorTcsChunkSizeInUsd = 1000; + } const expiryTimestampBn = expiryTimestamp !== null ? new BN(expiryTimestamp) : U64_MAX_BN; if (!pricePremium) { + if (maxBuy.eq(U64_MAX_BN)) { + maxSell.toNumber() * sellBank.uiPrice; + } const buyTokenPriceImpact = group.getPriceImpactByTokenIndex( buyBank.tokenIndex, - 5000, + liqorTcsChunkSizeInUsd, ); const sellTokenPriceImpact = group.getPriceImpactByTokenIndex( sellBank.tokenIndex, - 5000, + liqorTcsChunkSizeInUsd, ); pricePremium = ((1 + buyTokenPriceImpact / 100) * (1 + sellTokenPriceImpact / 100) - From a855d5467a96661fc0bc83ff9660bb9cc32745a8 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 25 Aug 2023 15:30:16 +0200 Subject: [PATCH 22/46] v0.19.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63b609b25..46e92eaf5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.6", + "version": "0.19.7", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From e767990c64fbbfdf74e52e3ce9094e70142ef75a Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 28 Aug 2023 08:44:13 +0200 Subject: [PATCH 23/46] ts: fix bug in perp close all lot computation Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index bc833284a..55bcda8fe 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -2419,7 +2419,7 @@ export class MangoClient { pa.marketIndex, isLong ? PerpOrderSide.ask : PerpOrderSide.bid, pm.uiPrice * (isLong ? 1 - slippage : 1 + slippage), // Try to cross the spread to guarantee matching - pa.getBasePositionUi(pm) * 1.01, // Send a larger size to ensure full order is closed + Math.abs(pa.getBasePositionUi(pm) * 1.01), // Send a larger size to ensure full order is closed undefined, Date.now(), PerpOrderType.immediateOrCancel, From da8a5909f9013d60326f1ba32246bcdb674dff84 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 28 Aug 2023 08:45:02 +0200 Subject: [PATCH 24/46] v0.19.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46e92eaf5..5a07e1ddc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.7", + "version": "0.19.8", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 6871ca2ad4c941d49ddc416bfbe18e1fc8533fb1 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 28 Aug 2023 17:33:34 +0200 Subject: [PATCH 25/46] ts: use average slippage for computing tcs premium Signed-off-by: microwavedcola1 --- ts/client/src/risk.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/client/src/risk.ts b/ts/client/src/risk.ts index c11de3791..653929285 100644 --- a/ts/client/src/risk.ts +++ b/ts/client/src/risk.ts @@ -73,7 +73,7 @@ export function computePriceImpactOnJup( (pi) => pi.symbol == tokenName && pi.target_amount == closestTo, ); if (filteredPis.length > 0) { - return (filteredPis[0].max_price_impact_percent * 10000) / 100; + return (filteredPis[0].avg_price_impact_percent * 10000) / 100; } else { return -1; } From 92be5b7de6f77ed5d84724fae59221c3becb680b Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 28 Aug 2023 17:34:52 +0200 Subject: [PATCH 26/46] v0.19.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a07e1ddc..b67685295 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.8", + "version": "0.19.9", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 0ee9af749f58b662c6b36da1ff9188edc8fb5515 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Mon, 28 Aug 2023 17:56:14 +0200 Subject: [PATCH 27/46] ts: getInstantaneousFundingRatePerSecond Signed-off-by: microwavedcola1 --- ts/client/src/accounts/perp.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ts/client/src/accounts/perp.ts b/ts/client/src/accounts/perp.ts index 99a274d2e..04e844e7e 100644 --- a/ts/client/src/accounts/perp.ts +++ b/ts/client/src/accounts/perp.ts @@ -408,6 +408,13 @@ export class PerpMarket { return funding; } + public getInstantaneousFundingRatePerSecond( + bids: BookSide, + asks: BookSide, + ): number { + return this.getInstantaneousFundingRate(bids, asks) / (24 * 60 * 60); + } + /** * * Returns instantaneous funding rate for the day. How is it actually applied - funding is From 2d392c8fff4742678121caf56b7b3e74e0539621 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 29 Aug 2023 10:03:07 +0200 Subject: [PATCH 28/46] FlashLoan: fee fixes (#693) - Rename the new "swap fee" to "deposit fee" and let it apply to all deposits, not just for Swap-type flash loans. - But don't apply it to withdrawals (effectively giving rebates!) Result of audit feedback (cherry picked from commit 1d6ce550f33e6ce60b161be646b0b302fcfd022c) --- CHANGELOG.md | 9 ++++-- mango_v4.json | 8 +++--- .../mango-v4/src/instructions/flash_loan.rs | 16 +++++------ .../mango-v4/src/instructions/token_edit.rs | 28 +++++++++---------- .../src/instructions/token_register.rs | 4 +-- .../instructions/token_register_trustless.rs | 2 +- programs/mango-v4/src/lib.rs | 8 +++--- programs/mango-v4/src/logs.rs | 2 +- programs/mango-v4/src/state/bank.rs | 6 ++-- .../mango-v4/tests/cases/test_margin_trade.rs | 14 +++++++--- .../tests/program_test/mango_client.rs | 4 +-- ts/client/scripts/create-gov-ix.ts | 2 +- ts/client/src/accounts/bank.ts | 6 ++-- ts/client/src/client.ts | 4 +-- ts/client/src/clientIxParamBuilder.ts | 8 +++--- ts/client/src/mango_v4.ts | 16 +++++------ 16 files changed, 73 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d989b16d..32da0140e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,10 +35,13 @@ Update this for each program release and mainnet deployment. Liquidators may be interested in performing actions in the same transaction as a flash loan swap. -- Flash loan swaps: The DAO can now charge a fee (#660) +- Flash loan: The DAO can now charge a deposit fee (#660, #693) - The DAO can now configure a fee on flash loan based swaps. Previously flash - loans that did not use more than the user's deposits were free. + The DAO can now configure a fee on deposits that happen in flash loans. This + could be used to apply a fee to flash loan swaps. + + Previously flash loans that did not increase the user's token balance and did + not borrow tokens were free. - Stop loss: Respect net borrow limits and change low-health completion (#677) - Stop loss: Store helpful UI fields (#654, #667) diff --git a/mango_v4.json b/mango_v4.json index 50b059e8d..1172e177d 100644 --- a/mango_v4.json +++ b/mango_v4.json @@ -594,7 +594,7 @@ "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" } ] @@ -926,7 +926,7 @@ } }, { - "name": "flashLoanSwapFeeRateOpt", + "name": "flashLoanDepositFeeRateOpt", "type": { "option": "f32" } @@ -6670,7 +6670,7 @@ "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" }, { @@ -8256,7 +8256,7 @@ "type": "i128" }, { - "name": "swapFee", + "name": "depositFee", "type": "i128" } ] diff --git a/programs/mango-v4/src/instructions/flash_loan.rs b/programs/mango-v4/src/instructions/flash_loan.rs index b77f22e8b..5b342bf28 100644 --- a/programs/mango-v4/src/instructions/flash_loan.rs +++ b/programs/mango-v4/src/instructions/flash_loan.rs @@ -235,8 +235,8 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( // Verify that each mentioned vault has a bank in the health accounts let mut vaults_with_banks = vec![false; vaults.len()]; - // Biggest flash_loan_swap_fee_rate over all involved banks - let mut max_swap_fee_rate = 0.0f32; + // Biggest flash_loan_deposit_fee_rate over all involved banks + let mut max_deposit_fee_rate = 0.0f32; // Loop over the banks, finding matching vaults // TODO: must be moved into health.rs, because it assumes something about the health accounts structure @@ -295,7 +295,7 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( change += repay; } - max_swap_fee_rate = max_swap_fee_rate.max(bank.flash_loan_swap_fee_rate); + max_deposit_fee_rate = max_deposit_fee_rate.max(bank.flash_loan_deposit_fee_rate); changes.push(TokenVaultChange { token_index: bank.token_index, @@ -364,14 +364,14 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( let loan_origination_fee = loan * bank.loan_origination_fee_rate; bank.collected_fees_native += loan_origination_fee; - let swap_fee = if flash_loan_type == FlashLoanType::Swap { - change.amount * I80F48::from_num(max_swap_fee_rate) + let deposit_fee = if change.amount > 0 { + change.amount * I80F48::from_num(max_deposit_fee_rate) } else { I80F48::ZERO }; - bank.collected_fees_native += swap_fee; + bank.collected_fees_native += deposit_fee; - let change_amount = change.amount - loan_origination_fee - swap_fee; + let change_amount = change.amount - loan_origination_fee - deposit_fee; let native_after_change = native + change_amount; if bank.are_deposits_reduce_only() { require!( @@ -415,7 +415,7 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( deposit_index: bank.deposit_index.to_bits(), borrow_index: bank.borrow_index.to_bits(), price: oracle_price.to_bits(), - swap_fee: swap_fee.to_bits(), + deposit_fee: deposit_fee.to_bits(), }); emit!(TokenBalanceLog { diff --git a/programs/mango-v4/src/instructions/token_edit.rs b/programs/mango-v4/src/instructions/token_edit.rs index beee307d8..9b7c90efe 100644 --- a/programs/mango-v4/src/instructions/token_edit.rs +++ b/programs/mango-v4/src/instructions/token_edit.rs @@ -41,7 +41,7 @@ pub fn token_edit( force_close_opt: Option, token_conditional_swap_taker_fee_rate_opt: Option, token_conditional_swap_maker_fee_rate_opt: Option, - flash_loan_swap_fee_rate_opt: Option, + flash_loan_deposit_fee_rate_opt: Option, ) -> Result<()> { let group = ctx.accounts.group.load()?; @@ -308,35 +308,35 @@ pub fn token_edit( require_group_admin = true; }; - if let Some(fee_fraction) = token_conditional_swap_taker_fee_rate_opt { + if let Some(fee_rate) = token_conditional_swap_taker_fee_rate_opt { msg!( "Token conditional swap taker fee fraction old {:?}, new {:?}", bank.token_conditional_swap_taker_fee_rate, - fee_fraction + fee_rate ); - require_gte!(fee_fraction, 0.0); // values <0 are not currently supported - bank.token_conditional_swap_taker_fee_rate = fee_fraction; + require_gte!(fee_rate, 0.0); // values <0 are not currently supported + bank.token_conditional_swap_taker_fee_rate = fee_rate; require_group_admin = true; } - if let Some(fees_fraction) = token_conditional_swap_maker_fee_rate_opt { + if let Some(fee_rate) = token_conditional_swap_maker_fee_rate_opt { msg!( "Token conditional swap maker fee fraction old {:?}, new {:?}", bank.token_conditional_swap_maker_fee_rate, - fees_fraction + fee_rate ); - require_gte!(fees_fraction, 0.0); // values <0 are not currently supported - bank.token_conditional_swap_maker_fee_rate = fees_fraction; + require_gte!(fee_rate, 0.0); // values <0 are not currently supported + bank.token_conditional_swap_maker_fee_rate = fee_rate; require_group_admin = true; } - if let Some(fees_fraction) = flash_loan_swap_fee_rate_opt { + if let Some(fee_rate) = flash_loan_deposit_fee_rate_opt { msg!( "Flash loan swap fee fraction old {:?}, new {:?}", - bank.flash_loan_swap_fee_rate, - fees_fraction + bank.flash_loan_deposit_fee_rate, + fee_rate ); - require_gte!(fees_fraction, 0.0); // values <0 are not currently supported - bank.flash_loan_swap_fee_rate = fees_fraction; + require_gte!(fee_rate, 0.0); // values <0 are not currently supported + bank.flash_loan_deposit_fee_rate = fee_rate; require_group_admin = true; } } diff --git a/programs/mango-v4/src/instructions/token_register.rs b/programs/mango-v4/src/instructions/token_register.rs index ef65e5621..07c52cdf1 100644 --- a/programs/mango-v4/src/instructions/token_register.rs +++ b/programs/mango-v4/src/instructions/token_register.rs @@ -37,7 +37,7 @@ pub fn token_register( reduce_only: u8, token_conditional_swap_taker_fee_rate: f32, token_conditional_swap_maker_fee_rate: f32, - flash_loan_swap_fee_rate: f32, + flash_loan_deposit_fee_rate: f32, ) -> Result<()> { // Require token 0 to be in the insurance token if token_index == INSURANCE_TOKEN_INDEX { @@ -107,7 +107,7 @@ pub fn token_register( fees_withdrawn: 0, token_conditional_swap_taker_fee_rate, token_conditional_swap_maker_fee_rate, - flash_loan_swap_fee_rate, + flash_loan_deposit_fee_rate, reserved: [0; 2092], }; diff --git a/programs/mango-v4/src/instructions/token_register_trustless.rs b/programs/mango-v4/src/instructions/token_register_trustless.rs index 706fe2ba6..339741c23 100644 --- a/programs/mango-v4/src/instructions/token_register_trustless.rs +++ b/programs/mango-v4/src/instructions/token_register_trustless.rs @@ -79,7 +79,7 @@ pub fn token_register_trustless( fees_withdrawn: 0, token_conditional_swap_taker_fee_rate: 0.0005, token_conditional_swap_maker_fee_rate: 0.0005, - flash_loan_swap_fee_rate: 0.0005, + flash_loan_deposit_fee_rate: 0.0005, reserved: [0; 2092], }; require_gt!(bank.max_rate, MINIMUM_MAX_RATE); diff --git a/programs/mango-v4/src/lib.rs b/programs/mango-v4/src/lib.rs index a85b51f1b..d7ab907c3 100644 --- a/programs/mango-v4/src/lib.rs +++ b/programs/mango-v4/src/lib.rs @@ -145,7 +145,7 @@ pub mod mango_v4 { reduce_only: u8, token_conditional_swap_taker_fee_rate: f32, token_conditional_swap_maker_fee_rate: f32, - flash_loan_swap_fee_rate: f32, + flash_loan_deposit_fee_rate: f32, ) -> Result<()> { #[cfg(feature = "enable-gpl")] instructions::token_register( @@ -172,7 +172,7 @@ pub mod mango_v4 { reduce_only, token_conditional_swap_taker_fee_rate, token_conditional_swap_maker_fee_rate, - flash_loan_swap_fee_rate, + flash_loan_deposit_fee_rate, )?; Ok(()) } @@ -216,7 +216,7 @@ pub mod mango_v4 { force_close_opt: Option, token_conditional_swap_taker_fee_rate_opt: Option, token_conditional_swap_maker_fee_rate_opt: Option, - flash_loan_swap_fee_rate_opt: Option, + flash_loan_deposit_fee_rate_opt: Option, ) -> Result<()> { #[cfg(feature = "enable-gpl")] instructions::token_edit( @@ -247,7 +247,7 @@ pub mod mango_v4 { force_close_opt, token_conditional_swap_taker_fee_rate_opt, token_conditional_swap_maker_fee_rate_opt, - flash_loan_swap_fee_rate_opt, + flash_loan_deposit_fee_rate_opt, )?; Ok(()) } diff --git a/programs/mango-v4/src/logs.rs b/programs/mango-v4/src/logs.rs index c669fc807..35ded564d 100644 --- a/programs/mango-v4/src/logs.rs +++ b/programs/mango-v4/src/logs.rs @@ -67,7 +67,7 @@ pub struct FlashLoanTokenDetailV2 { pub deposit_index: i128, pub borrow_index: i128, pub price: i128, - pub swap_fee: i128, + pub deposit_fee: i128, } #[event] diff --git a/programs/mango-v4/src/state/bank.rs b/programs/mango-v4/src/state/bank.rs index 33cc75491..df0a52610 100644 --- a/programs/mango-v4/src/state/bank.rs +++ b/programs/mango-v4/src/state/bank.rs @@ -146,7 +146,7 @@ pub struct Bank { pub token_conditional_swap_taker_fee_rate: f32, pub token_conditional_swap_maker_fee_rate: f32, - pub flash_loan_swap_fee_rate: f32, + pub flash_loan_deposit_fee_rate: f32, #[derivative(Debug = "ignore")] pub reserved: [u8; 2092], @@ -259,7 +259,7 @@ impl Bank { fees_withdrawn: 0, token_conditional_swap_taker_fee_rate: 0.0, token_conditional_swap_maker_fee_rate: 0.0, - flash_loan_swap_fee_rate: 0.0, + flash_loan_deposit_fee_rate: 0.0, reserved: [0; 2092], } } @@ -285,7 +285,7 @@ impl Bank { require_gte!(2, self.reduce_only); require_gte!(self.token_conditional_swap_taker_fee_rate, 0.0); require_gte!(self.token_conditional_swap_maker_fee_rate, 0.0); - require_gte!(self.flash_loan_swap_fee_rate, 0.0); + require_gte!(self.flash_loan_deposit_fee_rate, 0.0); Ok(()) } diff --git a/programs/mango-v4/tests/cases/test_margin_trade.rs b/programs/mango-v4/tests/cases/test_margin_trade.rs index ae14710bf..003585b5c 100644 --- a/programs/mango-v4/tests/cases/test_margin_trade.rs +++ b/programs/mango-v4/tests/cases/test_margin_trade.rs @@ -242,7 +242,7 @@ async fn test_margin_trade() -> Result<(), BanksClientError> { } #[tokio::test] -async fn test_flash_loan_swap_fee() -> Result<(), BanksClientError> { +async fn test_flash_loan_deposit_fee() -> Result<(), BanksClientError> { let mut test_builder = TestContextBuilder::new(); test_builder.test().set_compute_max_units(100_000); let context = test_builder.start_default().await; @@ -271,7 +271,7 @@ async fn test_flash_loan_swap_fee() -> Result<(), BanksClientError> { .create(solana) .await; - let swap_fee_fraction = 0.042f64; + let deposit_fee_rate = 0.042f64; send_tx( solana, TokenEdit { @@ -279,7 +279,7 @@ async fn test_flash_loan_swap_fee() -> Result<(), BanksClientError> { admin, mint: tokens[1].mint.pubkey, options: mango_v4::instruction::TokenEdit { - flash_loan_swap_fee_rate_opt: Some(swap_fee_fraction as f32), + flash_loan_deposit_fee_rate_opt: Some(deposit_fee_rate as f32), ..token_edit_instruction_default() }, }, @@ -412,10 +412,16 @@ async fn test_flash_loan_swap_fee() -> Result<(), BanksClientError> { provided_amount + deposit_amount ); + let mango_withdraw_amount = account_position_f64(solana, account, tokens[0].bank).await; + assert!(balance_f64eq( + mango_withdraw_amount, + (initial_deposit - withdraw_amount) as f64 + )); + let mango_deposit_amount = account_position_f64(solana, account, tokens[1].bank).await; assert!(balance_f64eq( mango_deposit_amount, - deposit_amount as f64 * (1.0 - swap_fee_fraction) + deposit_amount as f64 * (1.0 - deposit_fee_rate) )); Ok(()) diff --git a/programs/mango-v4/tests/program_test/mango_client.rs b/programs/mango-v4/tests/program_test/mango_client.rs index 24aebcad9..dd5e0b06f 100644 --- a/programs/mango-v4/tests/program_test/mango_client.rs +++ b/programs/mango-v4/tests/program_test/mango_client.rs @@ -875,7 +875,7 @@ impl ClientInstruction for TokenRegisterInstruction { reduce_only: 0, token_conditional_swap_taker_fee_rate: 0.0, token_conditional_swap_maker_fee_rate: 0.0, - flash_loan_swap_fee_rate: 0.0, + flash_loan_deposit_fee_rate: 0.0, }; let bank = Pubkey::find_program_address( @@ -1119,7 +1119,7 @@ pub fn token_edit_instruction_default() -> mango_v4::instruction::TokenEdit { force_close_opt: None, token_conditional_swap_taker_fee_rate_opt: None, token_conditional_swap_maker_fee_rate_opt: None, - flash_loan_swap_fee_rate_opt: None, + flash_loan_deposit_fee_rate_opt: None, } } diff --git a/ts/client/scripts/create-gov-ix.ts b/ts/client/scripts/create-gov-ix.ts index e3f26fa18..639fa6b6a 100644 --- a/ts/client/scripts/create-gov-ix.ts +++ b/ts/client/scripts/create-gov-ix.ts @@ -151,7 +151,7 @@ async function tokenEdit(): Promise { params.forceClose, params.tokenConditionalSwapTakerFeeRate, params.tokenConditionalSwapMakerFeeRate, - params.flashLoanSwapFeeRate, + params.flashLoanDepositFeeRate, ) .accounts({ group: group.publicKey, diff --git a/ts/client/src/accounts/bank.ts b/ts/client/src/accounts/bank.ts index 46d92b222..1d36304b5 100644 --- a/ts/client/src/accounts/bank.ts +++ b/ts/client/src/accounts/bank.ts @@ -124,7 +124,7 @@ export class Bank implements BankForHealth { feesWithdrawn: BN; tokenConditionalSwapTakerFeeRate: number; tokenConditionalSwapMakerFeeRate: number; - flashLoanSwapFeeRate: number; + flashLoanDepositFeeRate: number; }, ): Bank { return new Bank( @@ -175,7 +175,7 @@ export class Bank implements BankForHealth { obj.feesWithdrawn, obj.tokenConditionalSwapTakerFeeRate, obj.tokenConditionalSwapMakerFeeRate, - obj.flashLoanSwapFeeRate, + obj.flashLoanDepositFeeRate, ); } @@ -227,7 +227,7 @@ export class Bank implements BankForHealth { public feesWithdrawn: BN, public tokenConditionalSwapTakerFeeRate: number, public tokenConditionalSwapMakerFeeRate: number, - public flashLoanSwapFeeRate: number, + public flashLoanDepositFeeRate: number, ) { this.name = utf8.decode(new Uint8Array(name)).split('\x00')[0]; this.oracleConfig = { diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 58288a7e5..5a92aebf4 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -404,7 +404,7 @@ export class MangoClient { params.reduceOnly, params.tokenConditionalSwapTakerFeeRate, params.tokenConditionalSwapMakerFeeRate, - params.flashLoanSwapFeeRate, + params.flashLoanDepositFeeRate, ) .accounts({ group: group.publicKey, @@ -479,7 +479,7 @@ export class MangoClient { params.forceClose, params.tokenConditionalSwapTakerFeeRate, params.tokenConditionalSwapMakerFeeRate, - params.flashLoanSwapFeeRate, + params.flashLoanDepositFeeRate, ) .accounts({ group: group.publicKey, diff --git a/ts/client/src/clientIxParamBuilder.ts b/ts/client/src/clientIxParamBuilder.ts index 3eefcfc37..39de1d534 100644 --- a/ts/client/src/clientIxParamBuilder.ts +++ b/ts/client/src/clientIxParamBuilder.ts @@ -24,7 +24,7 @@ export interface TokenRegisterParams { reduceOnly: number; tokenConditionalSwapTakerFeeRate: number; tokenConditionalSwapMakerFeeRate: number; - flashLoanSwapFeeRate: number; + flashLoanDepositFeeRate: number; } export const DefaultTokenRegisterParams: TokenRegisterParams = { @@ -59,7 +59,7 @@ export const DefaultTokenRegisterParams: TokenRegisterParams = { reduceOnly: 0, tokenConditionalSwapTakerFeeRate: 0.0005, tokenConditionalSwapMakerFeeRate: 0.0005, - flashLoanSwapFeeRate: 0.0005, + flashLoanDepositFeeRate: 0.0005, }; export interface TokenEditParams { @@ -89,7 +89,7 @@ export interface TokenEditParams { forceClose: boolean | null; tokenConditionalSwapTakerFeeRate: number | null; tokenConditionalSwapMakerFeeRate: number | null; - flashLoanSwapFeeRate: number | null; + flashLoanDepositFeeRate: number | null; } export const NullTokenEditParams: TokenEditParams = { @@ -119,7 +119,7 @@ export const NullTokenEditParams: TokenEditParams = { forceClose: null, tokenConditionalSwapTakerFeeRate: null, tokenConditionalSwapMakerFeeRate: null, - flashLoanSwapFeeRate: null, + flashLoanDepositFeeRate: null, }; export interface PerpEditParams { diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index dadffb457..7b1c9df22 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -594,7 +594,7 @@ export type MangoV4 = { "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" } ] @@ -926,7 +926,7 @@ export type MangoV4 = { } }, { - "name": "flashLoanSwapFeeRateOpt", + "name": "flashLoanDepositFeeRateOpt", "type": { "option": "f32" } @@ -6670,7 +6670,7 @@ export type MangoV4 = { "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" }, { @@ -8256,7 +8256,7 @@ export type MangoV4 = { "type": "i128" }, { - "name": "swapFee", + "name": "depositFee", "type": "i128" } ] @@ -13131,7 +13131,7 @@ export const IDL: MangoV4 = { "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" } ] @@ -13463,7 +13463,7 @@ export const IDL: MangoV4 = { } }, { - "name": "flashLoanSwapFeeRateOpt", + "name": "flashLoanDepositFeeRateOpt", "type": { "option": "f32" } @@ -19207,7 +19207,7 @@ export const IDL: MangoV4 = { "type": "f32" }, { - "name": "flashLoanSwapFeeRate", + "name": "flashLoanDepositFeeRate", "type": "f32" }, { @@ -20793,7 +20793,7 @@ export const IDL: MangoV4 = { "type": "i128" }, { - "name": "swapFee", + "name": "depositFee", "type": "i128" } ] From 7125058ce5915d76d126c5bda968a681769c2d11 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 29 Aug 2023 10:03:24 +0200 Subject: [PATCH 29/46] Account expansion: Transfer more lamports only if needed (#694) Result of audit feedback (cherry picked from commit 020a978270a688a1a2b96e8e7fe7a034bf5352de) --- CHANGELOG.md | 1 + .../src/instructions/account_expand.rs | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32da0140e..ea830bde3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Update this for each program release and mainnet deployment. - Stop loss: Avoid expensive health cache for expired orders (#682) - Account creation: Add account_create_v2 instruction (#680, #685) - Account resizing: Lower maximums due to tx account limit (#686, #688, #689) +- Account resizing: Fix denial of service if account has too many lamports (#694) - Token register: Revamp API for simpler use from governance (#665) - Token register untrusted: Adjust default oracle staleness (#678) - Fix typo in name of admin_token_withdraw_fees instruction (#655) diff --git a/programs/mango-v4/src/instructions/account_expand.rs b/programs/mango-v4/src/instructions/account_expand.rs index 7ccfcf32d..56e06ddde 100644 --- a/programs/mango-v4/src/instructions/account_expand.rs +++ b/programs/mango-v4/src/instructions/account_expand.rs @@ -26,17 +26,19 @@ pub fn account_expand( require_gt!(new_space, old_space); - // transfer required additional rent - anchor_lang::system_program::transfer( - anchor_lang::context::CpiContext::new( - ctx.accounts.system_program.to_account_info(), - anchor_lang::system_program::Transfer { - from: ctx.accounts.payer.to_account_info(), - to: realloc_account.clone(), - }, - ), - new_rent_minimum - old_lamports, - )?; + if old_lamports < new_rent_minimum { + // transfer required additional rent + anchor_lang::system_program::transfer( + anchor_lang::context::CpiContext::new( + ctx.accounts.system_program.to_account_info(), + anchor_lang::system_program::Transfer { + from: ctx.accounts.payer.to_account_info(), + to: realloc_account.clone(), + }, + ), + new_rent_minimum - old_lamports, + )?; + } // realloc: it's safe to not re-zero-init since we never shrink accounts realloc_account.realloc(new_space, false)?; From e730bcd14631ae914faa24660ae6d6432b8ff38e Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 30 Aug 2023 07:21:03 +0200 Subject: [PATCH 30/46] ts: perpCancelOrderByClientOrderIdIx Signed-off-by: microwavedcola1 --- ts/client/src/client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 55bcda8fe..b4c106973 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -2746,6 +2746,26 @@ export class MangoClient { .instruction(); } + public async perpCancelOrderByClientOrderIdIx( + group: Group, + mangoAccount: MangoAccount, + perpMarketIndex: PerpMarketIndex, + clientOrderId: BN, + ): Promise { + const perpMarket = group.getPerpMarketByMarketIndex(perpMarketIndex); + return await this.program.methods + .perpCancelOrderByClientOrderId(new BN(clientOrderId)) + .accounts({ + group: group.publicKey, + account: mangoAccount.publicKey, + owner: (this.program.provider as AnchorProvider).wallet.publicKey, + perpMarket: perpMarket.publicKey, + bids: perpMarket.bids, + asks: perpMarket.asks, + }) + .instruction(); + } + public async perpCancelOrderIx( group: Group, mangoAccount: MangoAccount, From e0de779d96eb68f0174bafbae4090a4ce5cc21ee Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 30 Aug 2023 07:21:53 +0200 Subject: [PATCH 31/46] v0.19.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b67685295..358d3ae53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.9", + "version": "0.19.10", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 289c3ff8285a26da94fbbafbc13ecf7bcbc15db9 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 30 Aug 2023 10:57:41 +0200 Subject: [PATCH 32/46] FlashLoan: Log the approved amount (#696) Previously only the part of the approved amount that was a loan got logged, missing some interesting information. (cherry picked from commit 03378bb80811e763cf567f3437f8db7b573135a9) --- .../mango-v4/src/instructions/flash_loan.rs | 4 +++- programs/mango-v4/src/logs.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/programs/mango-v4/src/instructions/flash_loan.rs b/programs/mango-v4/src/instructions/flash_loan.rs index 5b342bf28..c97a17ccb 100644 --- a/programs/mango-v4/src/instructions/flash_loan.rs +++ b/programs/mango-v4/src/instructions/flash_loan.rs @@ -353,7 +353,8 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( let position = account.token_position_mut_by_raw_index(change.raw_token_index); let native = position.native(&bank); - let approved_amount = I80F48::from(bank.flash_loan_approved_amount); + let approved_amount_u64 = bank.flash_loan_approved_amount; + let approved_amount = I80F48::from(approved_amount_u64); let loan = if native.is_positive() { (approved_amount - native).max(I80F48::ZERO) @@ -416,6 +417,7 @@ pub fn flash_loan_end<'key, 'accounts, 'remaining, 'info>( borrow_index: bank.borrow_index.to_bits(), price: oracle_price.to_bits(), deposit_fee: deposit_fee.to_bits(), + approved_amount: approved_amount_u64, }); emit!(TokenBalanceLog { diff --git a/programs/mango-v4/src/logs.rs b/programs/mango-v4/src/logs.rs index 35ded564d..e12f01b0c 100644 --- a/programs/mango-v4/src/logs.rs +++ b/programs/mango-v4/src/logs.rs @@ -61,13 +61,32 @@ pub struct FlashLoanTokenDetail { #[derive(AnchorSerialize, AnchorDeserialize)] pub struct FlashLoanTokenDetailV2 { pub token_index: u16, + + /// The amount by which the user's token position changed at the end + /// + /// So if the user repaid the approved_amount in full, it'd be 0. + /// + /// Does NOT include the loan_origination_fee or deposit_fee, so the true + /// change is `change_amount - loan_origination_fee - deposit_fee`. pub change_amount: i128, + + /// The amount that was a loan (<= approved_amount, depends on user's deposits) pub loan: i128, + + /// The fee paid on the loan, not included in `loan` or `change_amount` pub loan_origination_fee: i128, + pub deposit_index: i128, pub borrow_index: i128, pub price: i128, + + /// Deposit fee paid for positive change_amount. + /// + /// Not factored into change_amount. pub deposit_fee: i128, + + /// The amount that was transfered out to the user + pub approved_amount: u64, } #[event] From e37f1ed99656923f6e29e46e0925b5bdac3ed1b1 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 30 Aug 2023 10:59:14 +0200 Subject: [PATCH 33/46] update idl --- mango_v4.json | 26 ++++++++++++++++++++ ts/client/src/mango_v4.ts | 52 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/mango_v4.json b/mango_v4.json index 1172e177d..8abfc7723 100644 --- a/mango_v4.json +++ b/mango_v4.json @@ -8233,14 +8233,28 @@ }, { "name": "changeAmount", + "docs": [ + "The amount by which the user's token position changed at the end", + "", + "So if the user repaid the approved_amount in full, it'd be 0.", + "", + "Does NOT include the loan_origination_fee or deposit_fee, so the true", + "change is `change_amount - loan_origination_fee - deposit_fee`." + ], "type": "i128" }, { "name": "loan", + "docs": [ + "The amount that was a loan (<= approved_amount, depends on user's deposits)" + ], "type": "i128" }, { "name": "loanOriginationFee", + "docs": [ + "The fee paid on the loan, not included in `loan` or `change_amount`" + ], "type": "i128" }, { @@ -8257,7 +8271,19 @@ }, { "name": "depositFee", + "docs": [ + "Deposit fee paid for positive change_amount.", + "", + "Not factored into change_amount." + ], "type": "i128" + }, + { + "name": "approvedAmount", + "docs": [ + "The amount that was transfered out to the user" + ], + "type": "u64" } ] } diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index 7b1c9df22..6d88385e5 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -8233,14 +8233,28 @@ export type MangoV4 = { }, { "name": "changeAmount", + "docs": [ + "The amount by which the user's token position changed at the end", + "", + "So if the user repaid the approved_amount in full, it'd be 0.", + "", + "Does NOT include the loan_origination_fee or deposit_fee, so the true", + "change is `change_amount - loan_origination_fee - deposit_fee`." + ], "type": "i128" }, { "name": "loan", + "docs": [ + "The amount that was a loan (<= approved_amount, depends on user's deposits)" + ], "type": "i128" }, { "name": "loanOriginationFee", + "docs": [ + "The fee paid on the loan, not included in `loan` or `change_amount`" + ], "type": "i128" }, { @@ -8257,7 +8271,19 @@ export type MangoV4 = { }, { "name": "depositFee", + "docs": [ + "Deposit fee paid for positive change_amount.", + "", + "Not factored into change_amount." + ], "type": "i128" + }, + { + "name": "approvedAmount", + "docs": [ + "The amount that was transfered out to the user" + ], + "type": "u64" } ] } @@ -20770,14 +20796,28 @@ export const IDL: MangoV4 = { }, { "name": "changeAmount", + "docs": [ + "The amount by which the user's token position changed at the end", + "", + "So if the user repaid the approved_amount in full, it'd be 0.", + "", + "Does NOT include the loan_origination_fee or deposit_fee, so the true", + "change is `change_amount - loan_origination_fee - deposit_fee`." + ], "type": "i128" }, { "name": "loan", + "docs": [ + "The amount that was a loan (<= approved_amount, depends on user's deposits)" + ], "type": "i128" }, { "name": "loanOriginationFee", + "docs": [ + "The fee paid on the loan, not included in `loan` or `change_amount`" + ], "type": "i128" }, { @@ -20794,7 +20834,19 @@ export const IDL: MangoV4 = { }, { "name": "depositFee", + "docs": [ + "Deposit fee paid for positive change_amount.", + "", + "Not factored into change_amount." + ], "type": "i128" + }, + { + "name": "approvedAmount", + "docs": [ + "The amount that was transfered out to the user" + ], + "type": "u64" } ] } From d9f756b346465650e2882c57794d329d6909f6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezi=C5=84ski?= Date: Thu, 31 Aug 2023 14:36:04 +0200 Subject: [PATCH 34/46] additional functions mechanizm (#700) --- ts/client/src/client.ts | 54 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index b4c106973..f90c59894 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -103,6 +103,16 @@ export class MangoClient { private prioritizationFee: number; private txConfirmationCommitment: Commitment; private openbookFeesToDao: boolean; + /** + * @param tempAdditionalInstructions - Instructions to be appended ixes of to the next sendAndConfirmTransaction call. + * Cleared automatically after the sendAndConfirmTransaction call is executed. + */ + private tempAdditionalInstructions: TransactionInstruction[] = []; + /** + * @param prependedGlobalAdditionalInstructions - Instructions to be prepended (unshift) to ixes inside any sendAndConfirmTransaction call. + * They remain effective until cleared with clearPrependedGlobalAdditionalInstructions. + */ + private prependedGlobalAdditionalInstructions: TransactionInstruction[] = []; constructor( public program: Program, @@ -131,14 +141,52 @@ export class MangoClient { return (this.program.provider as AnchorProvider).wallet.publicKey; } + public clearTempAdditionalInstructions(): void { + this.tempAdditionalInstructions = []; + } + + public addTempAdditionalInstructions(ixs: TransactionInstruction[]): void { + this.tempAdditionalInstructions = [ + ...this.tempAdditionalInstructions, + ...ixs, + ]; + } + + public clearPrependedGlobalAdditionalInstructions(): void { + this.prependedGlobalAdditionalInstructions = []; + } + + public addPrependedGlobalAdditionalInstructions( + ixs: TransactionInstruction[], + ): void { + this.prependedGlobalAdditionalInstructions = [ + ...this.prependedGlobalAdditionalInstructions, + ...ixs, + ]; + } + /// Transactions public async sendAndConfirmTransaction( ixs: TransactionInstruction[], opts: any = {}, ): Promise { - return await sendTransaction( - this.program.provider as AnchorProvider, + return await this.sendTransactionWithClearTempAdditionalInstructions( ixs, + opts, + ); + } + + public async sendTransactionWithClearTempAdditionalInstructions( + ixs: TransactionInstruction[], + opts: any = {}, + ): Promise { + const status = await sendTransaction( + this.program.provider as AnchorProvider, + [ + ...this.prependedGlobalAdditionalInstructions, + ...ixs, + ...this.tempAdditionalInstructions, + ], opts.alts ?? [], { postSendTxCallback: this.postSendTxCallback, @@ -147,6 +195,8 @@ export class MangoClient { ...opts, }, ); + this.clearTempAdditionalInstructions(); + return status; } public async sendAndConfirmTransactionForGroup( From bb478b9631e29c6875c2aeec0b4ba63b987f2e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Thu, 31 Aug 2023 14:37:29 +0200 Subject: [PATCH 35/46] v0.19.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 358d3ae53..86955ce9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.10", + "version": "0.19.11", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 0a2bf3abd5df7c3d5dbaef1adff96862b39def03 Mon Sep 17 00:00:00 2001 From: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:11:04 +0200 Subject: [PATCH 36/46] ts: example script no margin group (#697) Signed-off-by: microwavedcola1 --- ts/client/scripts/mainnet-no-margin-group.ts | 255 +++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 ts/client/scripts/mainnet-no-margin-group.ts diff --git a/ts/client/scripts/mainnet-no-margin-group.ts b/ts/client/scripts/mainnet-no-margin-group.ts new file mode 100644 index 000000000..8446966e4 --- /dev/null +++ b/ts/client/scripts/mainnet-no-margin-group.ts @@ -0,0 +1,255 @@ +import { AnchorProvider, Wallet } from '@coral-xyz/anchor'; +import { Connection, Keypair, PublicKey } from '@solana/web3.js'; +import fs from 'fs'; +import { TokenIndex } from '../src/accounts/bank'; +import { Group } from '../src/accounts/group'; +import { MangoClient } from '../src/client'; +import { MANGO_V4_ID } from '../src/constants'; +import { toNative } from '../src/utils'; + +const MAINNET_MINTS = new Map([ + ['USDC', 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'], // 0 + ['SOL', 'So11111111111111111111111111111111111111112'], // 1 +]); +const MAINNET_ORACLES = new Map([ + ['USDC', 'Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD'], + ['SOL', 'H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG'], +]); +const MAINNET_SERUM3_MARKETS = new Map([ + ['SOL/USDC', '8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'], +]); +const { + MB_CLUSTER_URL, + MB_PAYER_KEYPAIR, + GROUP_NUM, +}: { + MB_CLUSTER_URL: string; + MB_PAYER_KEYPAIR: string; + GROUP_NUM: number; +} = process.env as any; + +const MIN_VAULT_TO_DEPOSITS_RATIO = 1; +const NET_BORROWS_WINDOW_SIZE_TS = 24 * 60 * 60; +const NET_BORROW_LIMIT_PER_WINDOW_QUOTE = toNative(0, 6).toNumber(); + +const defaultOracleConfig = { + confFilter: 0.1, + maxStalenessSlots: null, +}; + +const defaultInterestRate = { + adjustmentFactor: 0.0, + util0: 0.0, + rate0: 0.0, + util1: 0.0, + rate1: 0.0, + maxRate: 0.51, +}; + +async function buildAdminClient(): Promise<[MangoClient, Keypair]> { + const admin = Keypair.fromSecretKey( + Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))), + ); + const options = AnchorProvider.defaultOptions(); + const connection = new Connection(MB_CLUSTER_URL!, options); + const adminWallet = new Wallet(admin); + const adminProvider = new AnchorProvider(connection, adminWallet, options); + const client = await MangoClient.connect( + adminProvider, + 'mainnet-beta', + MANGO_V4_ID['mainnet-beta'], + { + idsSource: 'get-program-accounts', + }, + ); + return [client, admin]; +} + +async function buildUserClient(): Promise<[MangoClient, Group, Keypair]> { + const options = AnchorProvider.defaultOptions(); + const connection = new Connection(MB_CLUSTER_URL!, options); + + const user = Keypair.fromSecretKey( + Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR, 'utf-8'))), + ); + const userWallet = new Wallet(user); + const userProvider = new AnchorProvider(connection, userWallet, options); + + const client = await MangoClient.connect( + userProvider, + 'mainnet-beta', + MANGO_V4_ID['mainnet-beta'], + ); + const group = await client.getGroupForCreator(user.publicKey, GROUP_NUM); + return [client, group, user]; +} + +async function createGroup(): Promise { + const result = await buildAdminClient(); + const client = result[0]; + const admin = result[1]; + + const insuranceMint = new PublicKey(MAINNET_MINTS.get('USDC')!); + await client.groupCreate(GROUP_NUM, false, 2, insuranceMint); + const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM); + console.log(`...registered group ${group.publicKey}`); +} + +async function registerTokens(): Promise { + const result = await buildAdminClient(); + const client = result[0]; + const admin = result[1]; + + const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM); + + const usdcMainnetMint = new PublicKey(MAINNET_MINTS.get('USDC')!); + const usdcMainnetOracle = new PublicKey(MAINNET_ORACLES.get('USDC')!); + let sig = await client.tokenRegister( + group, + usdcMainnetMint, + usdcMainnetOracle, + defaultOracleConfig, + 0, + 'USDC', + defaultInterestRate, + 0.0, + 0.0, + 0, + 0, + 0, + 0, + 0, + MIN_VAULT_TO_DEPOSITS_RATIO, + NET_BORROWS_WINDOW_SIZE_TS, + NET_BORROW_LIMIT_PER_WINDOW_QUOTE, + ); + console.log(`registered usdc ${sig}`); + + const solMainnetMint = new PublicKey(MAINNET_MINTS.get('SOL')!); + const solMainnetOracle = new PublicKey(MAINNET_ORACLES.get('SOL')!); + sig = await client.tokenRegister( + group, + solMainnetMint, + solMainnetOracle, + defaultOracleConfig, + 1, + 'SOL', + defaultInterestRate, + 0.0, + 0.0, + 0, + 0, + 0, + 0, + 0, + MIN_VAULT_TO_DEPOSITS_RATIO, + NET_BORROWS_WINDOW_SIZE_TS, + NET_BORROW_LIMIT_PER_WINDOW_QUOTE, + ); + console.log(`registered sol ${sig}`); +} + +async function registerSerum3Market(): Promise { + const result = await buildAdminClient(); + const client = result[0]; + const admin = result[1]; + + const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM); + await client.serum3RegisterMarket( + group, + new PublicKey(MAINNET_SERUM3_MARKETS.get('SOL/USDC')!), + group.getFirstBankByTokenIndex(1 as TokenIndex), + group.getFirstBankByTokenIndex(0 as TokenIndex), + 0, + 'SOL/USDC', + ); +} + +async function doUserAction(): Promise { + const result = await buildUserClient(); + const client = result[0]; + const group = result[1]; + const user = result[2]; + + let mangoAccount = await client.getMangoAccountForOwner( + group, + user.publicKey, + 0, + ); + + if (!mangoAccount) { + await client.createMangoAccount(group, 0); + mangoAccount = await client.getMangoAccountForOwner( + group, + user.publicKey, + 0, + ); + } + + // await client.tokenDeposit( + // group, + // mangoAccount!, + // new PublicKey(MAINNET_MINTS.get('SOL')!), + // 0.01, + // ); + + // await client.tcsStopLossOnDeposit( + // group, + // mangoAccount!, + // group.getFirstBankByTokenIndex(1 as TokenIndex), + // group.getFirstBankByTokenIndex(0 as TokenIndex), + // group.getFirstBankByTokenIndex(1 as TokenIndex).uiPrice * 1.1, + // false, + // null, + // null, + // null, + // ); + + await mangoAccount?.reload(client); + mangoAccount + ?.tokenConditionalSwapsActive() + .map((tcs) => console.log(tcs.toString(group))); +} + +async function doUserAction2(): Promise { + const result = await buildUserClient(); + const client = result[0]; + const group = result[1]; + const user = result[2]; + + let mangoAccount = await client.getMangoAccountForOwner( + group, + user.publicKey, + 1, + ); + + if (!mangoAccount) { + await client.createMangoAccount(group, 1); + mangoAccount = await client.getMangoAccountForOwner( + group, + user.publicKey, + 1, + ); + } + + await client.tokenDeposit( + group, + mangoAccount!, + new PublicKey(MAINNET_MINTS.get('USDC')!), + 5, + ); +} + +async function main(): Promise { + try { + // await createGroup(); + // await registerTokens(); + // await registerSerum3Market(); + await doUserAction(); + // await doUserAction2(); + } catch (error) { + console.log(error); + } +} + +main(); From 79ea2bc7dfdd8284aec1eac49ef8860203e9afe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezi=C5=84ski?= Date: Mon, 4 Sep 2023 18:06:37 +0200 Subject: [PATCH 37/46] preprended instruction change (#703) * fix * fix --- ts/client/src/client.ts | 53 ++++------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index f90c59894..b431686ac 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -95,6 +95,7 @@ export type MangoClientOptions = { prioritizationFee?: number; txConfirmationCommitment?: Commitment; openbookFeesToDao?: boolean; + prependedGlobalAdditionalInstructions?: TransactionInstruction[]; }; export class MangoClient { @@ -103,15 +104,6 @@ export class MangoClient { private prioritizationFee: number; private txConfirmationCommitment: Commitment; private openbookFeesToDao: boolean; - /** - * @param tempAdditionalInstructions - Instructions to be appended ixes of to the next sendAndConfirmTransaction call. - * Cleared automatically after the sendAndConfirmTransaction call is executed. - */ - private tempAdditionalInstructions: TransactionInstruction[] = []; - /** - * @param prependedGlobalAdditionalInstructions - Instructions to be prepended (unshift) to ixes inside any sendAndConfirmTransaction call. - * They remain effective until cleared with clearPrependedGlobalAdditionalInstructions. - */ private prependedGlobalAdditionalInstructions: TransactionInstruction[] = []; constructor( @@ -124,6 +116,8 @@ export class MangoClient { this.prioritizationFee = opts?.prioritizationFee || 0; this.postSendTxCallback = opts?.postSendTxCallback; this.openbookFeesToDao = opts?.openbookFeesToDao ?? true; + this.prependedGlobalAdditionalInstructions = + opts.prependedGlobalAdditionalInstructions ?? []; this.txConfirmationCommitment = opts?.txConfirmationCommitment ?? (program.provider as AnchorProvider).opts.commitment ?? @@ -141,52 +135,14 @@ export class MangoClient { return (this.program.provider as AnchorProvider).wallet.publicKey; } - public clearTempAdditionalInstructions(): void { - this.tempAdditionalInstructions = []; - } - - public addTempAdditionalInstructions(ixs: TransactionInstruction[]): void { - this.tempAdditionalInstructions = [ - ...this.tempAdditionalInstructions, - ...ixs, - ]; - } - - public clearPrependedGlobalAdditionalInstructions(): void { - this.prependedGlobalAdditionalInstructions = []; - } - - public addPrependedGlobalAdditionalInstructions( - ixs: TransactionInstruction[], - ): void { - this.prependedGlobalAdditionalInstructions = [ - ...this.prependedGlobalAdditionalInstructions, - ...ixs, - ]; - } - /// Transactions public async sendAndConfirmTransaction( ixs: TransactionInstruction[], opts: any = {}, - ): Promise { - return await this.sendTransactionWithClearTempAdditionalInstructions( - ixs, - opts, - ); - } - - public async sendTransactionWithClearTempAdditionalInstructions( - ixs: TransactionInstruction[], - opts: any = {}, ): Promise { const status = await sendTransaction( this.program.provider as AnchorProvider, - [ - ...this.prependedGlobalAdditionalInstructions, - ...ixs, - ...this.tempAdditionalInstructions, - ], + [...this.prependedGlobalAdditionalInstructions, ...ixs], opts.alts ?? [], { postSendTxCallback: this.postSendTxCallback, @@ -195,7 +151,6 @@ export class MangoClient { ...opts, }, ); - this.clearTempAdditionalInstructions(); return status; } From 2110cf7f55fa18f8843d6b643814d1f086374392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Mon, 4 Sep 2023 18:20:02 +0200 Subject: [PATCH 38/46] v0.19.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 86955ce9c..67db01caf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.11", + "version": "0.19.12", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 3715a9a7f2de87db31a993123dd52029252c93bb Mon Sep 17 00:00:00 2001 From: tjs Date: Mon, 4 Sep 2023 21:04:42 -0400 Subject: [PATCH 39/46] Update Ids class so the array filters in the getters work Also add placeholder values in ids.json so types work; Deprecate ids.json --- ts/client/ids.json | 21 ++++++++++++++------- ts/client/src/ids.ts | 30 ++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ts/client/ids.json b/ts/client/ids.json index 9cf163f8e..7f3abe94e 100644 --- a/ts/client/ids.json +++ b/ts/client/ids.json @@ -13,7 +13,8 @@ "mint": "So11111111111111111111111111111111111111112", "tokenIndex": 5, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "USDT", @@ -21,7 +22,8 @@ "mint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "tokenIndex": 1, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "USDC", @@ -29,7 +31,8 @@ "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "tokenIndex": 0, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "BTC", @@ -37,7 +40,8 @@ "mint": "9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E", "tokenIndex": 2, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "soETH", @@ -45,7 +49,8 @@ "mint": "2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk", "tokenIndex": 4, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "ETH", @@ -53,7 +58,8 @@ "mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "tokenIndex": 3, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 }, { "name": "MSOL", @@ -61,7 +67,8 @@ "mint": "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So", "tokenIndex": 6, "bankNum": 0, - "active": true + "active": true, + "decimals": 99999 } ], "stubOracles": [ diff --git a/ts/client/src/ids.ts b/ts/client/src/ids.ts index 186afb296..ef39ff71b 100644 --- a/ts/client/src/ids.ts +++ b/ts/client/src/ids.ts @@ -8,7 +8,14 @@ export class Id { public publicKey: string, public serum3ProgramId: string, public mangoProgramId: string, - public banks: { name: string; publicKey: string; active: boolean }[], + public banks: { + name: string; + mint: string; + tokenIndex: number; + publicKey: string; + active: boolean; + decimals: number; + }[], public stubOracles: { name: string; publicKey: string }[], public mintInfos: { name: string; publicKey: string }[], public serum3Markets: { @@ -23,7 +30,7 @@ export class Id { public getBanks(): PublicKey[] { return Array.from( this.banks - .filter((perpMarket) => perpMarket.active) + .filter((bank) => bank.active) .map((bank) => new PublicKey(bank.publicKey)), ); } @@ -43,11 +50,19 @@ export class Id { public getSerum3Markets(): PublicKey[] { return Array.from( this.serum3Markets - .filter((perpMarket) => perpMarket.active) + .filter((serum3Market) => serum3Market.active) .map((serum3Market) => new PublicKey(serum3Market.publicKey)), ); } + public getSerum3ExternalMarkets(): PublicKey[] { + return Array.from( + this.serum3Markets + .filter((serum3Market) => serum3Market.active) + .map((serum3Market) => new PublicKey(serum3Market.marketExternal)), + ); + } + public getPerpMarkets(): PublicKey[] { return Array.from( this.perpMarkets @@ -56,6 +71,7 @@ export class Id { ); } + // DEPRECATED static fromIdsByName(name: string): Id { const groupConfig = ids.groups.find((id) => id['name'] === name); if (!groupConfig) throw new Error(`No group config ${name} found in Ids!`); @@ -73,6 +89,7 @@ export class Id { ); } + // DEPRECATED static fromIdsByPk(groupPk: PublicKey): Id { const groupConfig = ids.groups.find( (id) => id['publicKey'] === groupPk.toString(), @@ -115,6 +132,8 @@ export class Id { tokenIndex: t.tokenIndex, bankNum: b.bankNum, publicKey: b.publicKey, + active: t.active, + decimals: t.decimals, })), ), groupConfig.stubOracles.map((s) => ({ @@ -126,15 +145,18 @@ export class Id { mint: t.mint, tokenIndex: t.tokenIndex, publicKey: t.mintInfo, + active: t.active, })), groupConfig.serum3Markets.map((s) => ({ name: s.name, publicKey: s.publicKey, - marketExternal: s.marketExternal, + marketExternal: s.serumMarketExternal, + active: s.active, })), groupConfig.perpMarkets.map((p) => ({ name: p.name, publicKey: p.publicKey, + active: p.active, })), ); } From c7c362292c91ebfee95360f85d083be413cba8d0 Mon Sep 17 00:00:00 2001 From: tjs Date: Tue, 5 Sep 2023 09:34:15 -0400 Subject: [PATCH 40/46] Support reloading reloadSerum3ExternalMarkets from Ids class remove console logs --- ts/client/src/accounts/group.ts | 65 ++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/ts/client/src/accounts/group.ts b/ts/client/src/accounts/group.ts index 1bb672bab..36d035e98 100644 --- a/ts/client/src/accounts/group.ts +++ b/ts/client/src/accounts/group.ts @@ -144,7 +144,7 @@ export class Group { ), this.reloadMintInfos(client, ids), this.reloadSerum3Markets(client, ids).then(() => - this.reloadSerum3ExternalMarkets(client), + this.reloadSerum3ExternalMarkets(client, ids), ), ]); // console.timeEnd('group.reload'); @@ -280,23 +280,63 @@ export class Group { ); } - public async reloadSerum3ExternalMarkets(client: MangoClient): Promise { - const externalMarkets = await Promise.all( - Array.from(this.serum3MarketsMapByExternal.values()).map((serum3Market) => - Market.load( - client.program.provider.connection, - serum3Market.serumMarketExternal, - { commitment: client.program.provider.connection.commitment }, - OPENBOOK_PROGRAM_ID[client.cluster], + public async reloadSerum3ExternalMarkets( + client: MangoClient, + ids?: Id, + ): Promise { + let markets: Market[] = []; + const externalMarketIds = ids?.getSerum3ExternalMarkets(); + + if (ids && externalMarketIds && externalMarketIds.length) { + markets = await Promise.all( + ( + await client.program.provider.connection.getMultipleAccountsInfo( + externalMarketIds, + ) + ).map( + (account, index) => + new Market( + Market.getLayout(OPENBOOK_PROGRAM_ID[client.cluster]).decode( + account?.data, + ), + ids.banks.find( + (b) => + b.tokenIndex === + this.serum3MarketsMapByExternal.get( + externalMarketIds[index].toString(), + )?.baseTokenIndex, + )?.decimals || 6, + ids.banks.find( + (b) => + b.tokenIndex === + this.serum3MarketsMapByExternal.get( + externalMarketIds[index].toString(), + )?.quoteTokenIndex, + )?.decimals || 6, + { commitment: client.program.provider.connection.commitment }, + OPENBOOK_PROGRAM_ID[client.cluster], + ), ), - ), - ); + ); + } else { + markets = await Promise.all( + Array.from(this.serum3MarketsMapByExternal.values()).map( + (serum3Market) => + Market.load( + client.program.provider.connection, + serum3Market.serumMarketExternal, + { commitment: client.program.provider.connection.commitment }, + OPENBOOK_PROGRAM_ID[client.cluster], + ), + ), + ); + } this.serum3ExternalMarketsMap = new Map( Array.from(this.serum3MarketsMapByExternal.values()).map( (serum3Market, index) => [ serum3Market.serumMarketExternal.toBase58(), - externalMarkets[index], + markets[index], ], ), ); @@ -469,7 +509,6 @@ export class Group { await client.program.provider.connection.getMultipleAccountsInfo( vaultPks, ); - const coder = new BorshAccountsCoder(client.program.idl); this.vaultAmountsMap = new Map( vaultAccounts.map((vaultAi, i) => { if (!vaultAi) { From b42a35cdb99be460d1b6a15363e80c445407d34c Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Tue, 5 Sep 2023 15:56:04 +0200 Subject: [PATCH 41/46] sb logs Signed-off-by: microwavedcola1 --- ts/client/scripts/switchboard-logs.ts | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 ts/client/scripts/switchboard-logs.ts diff --git a/ts/client/scripts/switchboard-logs.ts b/ts/client/scripts/switchboard-logs.ts new file mode 100644 index 000000000..8d23aacc1 --- /dev/null +++ b/ts/client/scripts/switchboard-logs.ts @@ -0,0 +1,72 @@ +import { PublicKey } from '@solana/web3.js'; +import { Group } from '../src/accounts/group'; +import { isSwitchboardOracle } from '../src/accounts/oracle'; +import { MangoClient } from '../src/client'; +import { buildFetch } from '../src/utils'; + +function getNameForBank(group: Group, oracle: PublicKey): string { + let match: any[] = Array.from(group.banksMapByName.values()) + .flat() + .filter((b) => b.oracle.equals(oracle)); + if (match.length > 0) { + return match[0].name; + } + + match = Array.from(group.perpMarketsMapByName.values()).filter((p) => + p.oracle.equals(oracle), + ); + if (match.length > 0) { + return match[0].name; + } + + throw new Error(`No token or perp market found for ${oracle}`); +} + +async function main(): Promise { + const client = await MangoClient.connectDefault(process.env.MB_CLUSTER_URL!); + const group = await client.getGroup( + new PublicKey('78b8f4cGCwmZ9ysPFMWLaLTkkaYnUjwMJYStWe5RTSSX'), + ); + + const oracles1 = Array.from(group.banksMapByName.values()).map( + (b) => b[0].oracle, + ); + const oracles2 = Array.from(group.perpMarketsMapByName.values()).map( + (p) => p.oracle, + ); + const oracles = oracles1.concat(oracles2); + + const ais = await client.program.provider.connection.getMultipleAccountsInfo( + oracles, + ); + + const switcboardOracles: PublicKey[] = ais + .map((ai, i) => [isSwitchboardOracle(ai!), oracles[i]]) + .filter((r) => r[0]) + .map((r) => r[1]) as PublicKey[]; + + for (const o of switcboardOracles) { + const r = await ( + await buildFetch() + )('https://stats.switchboard.xyz/logs', { + headers: { + accept: '*/*', + 'content-type': 'application/json', + }, + body: `{"cluster":"solana-mainnet","query":"${o.toString()}","number":100,"severity":"INFO"}`, + method: 'POST', + }); + + console.log(`${getNameForBank(group, o)} ${o}`); + + (await r.json()).forEach((e: { message: string; timestamp: string }) => { + if (e.message.toLowerCase().includes('error')) { + console.log(`${e.timestamp}: ${e.message}`); + } + }); + + console.log(``); + } +} + +main(); From 7b4d46e135c46760db360634b80a6b3a01a7ed38 Mon Sep 17 00:00:00 2001 From: tjs Date: Tue, 5 Sep 2023 10:59:55 -0400 Subject: [PATCH 42/46] v0.19.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 67db01caf..f507a7538 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.12", + "version": "0.19.13", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From f2eb37b5987d3c5559033a0470d8fba85200c2c0 Mon Sep 17 00:00:00 2001 From: tjs Date: Wed, 6 Sep 2023 13:51:40 -0400 Subject: [PATCH 43/46] ids should return all subitems for a group regardless of active state --- ts/client/src/ids.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ts/client/src/ids.ts b/ts/client/src/ids.ts index ef39ff71b..8eed9e072 100644 --- a/ts/client/src/ids.ts +++ b/ts/client/src/ids.ts @@ -28,11 +28,7 @@ export class Id { ) {} public getBanks(): PublicKey[] { - return Array.from( - this.banks - .filter((bank) => bank.active) - .map((bank) => new PublicKey(bank.publicKey)), - ); + return Array.from(this.banks.map((bank) => new PublicKey(bank.publicKey))); } public getStubOracles(): PublicKey[] { @@ -49,25 +45,23 @@ export class Id { public getSerum3Markets(): PublicKey[] { return Array.from( - this.serum3Markets - .filter((serum3Market) => serum3Market.active) - .map((serum3Market) => new PublicKey(serum3Market.publicKey)), + this.serum3Markets.map( + (serum3Market) => new PublicKey(serum3Market.publicKey), + ), ); } public getSerum3ExternalMarkets(): PublicKey[] { return Array.from( - this.serum3Markets - .filter((serum3Market) => serum3Market.active) - .map((serum3Market) => new PublicKey(serum3Market.marketExternal)), + this.serum3Markets.map( + (serum3Market) => new PublicKey(serum3Market.marketExternal), + ), ); } public getPerpMarkets(): PublicKey[] { return Array.from( - this.perpMarkets - .filter((perpMarket) => perpMarket.active) - .map((perpMarket) => new PublicKey(perpMarket.publicKey)), + this.perpMarkets.map((perpMarket) => new PublicKey(perpMarket.publicKey)), ); } From 335c98a09aa46ff413f5221778410494fc5476af Mon Sep 17 00:00:00 2001 From: tjs Date: Wed, 6 Sep 2023 13:53:07 -0400 Subject: [PATCH 44/46] v0.19.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f507a7538..469f12b45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockworks-foundation/mango-v4", - "version": "0.19.13", + "version": "0.19.14", "description": "Typescript Client for mango-v4 program.", "repository": "https://github.com/blockworks-foundation/mango-v4", "author": { From 1861d127bc91974f2c2359887680eca127e99954 Mon Sep 17 00:00:00 2001 From: tjs Date: Wed, 6 Sep 2023 14:11:25 -0400 Subject: [PATCH 45/46] only remove active filter from Ids on perp markets --- ts/client/src/ids.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ts/client/src/ids.ts b/ts/client/src/ids.ts index 8eed9e072..e39d2dc75 100644 --- a/ts/client/src/ids.ts +++ b/ts/client/src/ids.ts @@ -28,7 +28,11 @@ export class Id { ) {} public getBanks(): PublicKey[] { - return Array.from(this.banks.map((bank) => new PublicKey(bank.publicKey))); + return Array.from( + this.banks + .filter((bank) => bank.active) + .map((bank) => new PublicKey(bank.publicKey)), + ); } public getStubOracles(): PublicKey[] { @@ -45,17 +49,17 @@ export class Id { public getSerum3Markets(): PublicKey[] { return Array.from( - this.serum3Markets.map( - (serum3Market) => new PublicKey(serum3Market.publicKey), - ), + this.serum3Markets + .filter((serum3Market) => serum3Market.active) + .map((serum3Market) => new PublicKey(serum3Market.publicKey)), ); } public getSerum3ExternalMarkets(): PublicKey[] { return Array.from( - this.serum3Markets.map( - (serum3Market) => new PublicKey(serum3Market.marketExternal), - ), + this.serum3Markets + .filter((serum3Market) => serum3Market.active) + .map((serum3Market) => new PublicKey(serum3Market.marketExternal)), ); } From 97d3ec01c1bacb2ecd6fbb32029ccca3f4228bea Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 7 Sep 2023 13:07:55 +0200 Subject: [PATCH 46/46] scripts: fix mainnet-no-margin-group post-merge --- ts/client/scripts/mainnet-no-margin-group.ts | 46 ++++++++------------ 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/ts/client/scripts/mainnet-no-margin-group.ts b/ts/client/scripts/mainnet-no-margin-group.ts index 8446966e4..bd5634e10 100644 --- a/ts/client/scripts/mainnet-no-margin-group.ts +++ b/ts/client/scripts/mainnet-no-margin-group.ts @@ -4,6 +4,7 @@ import fs from 'fs'; import { TokenIndex } from '../src/accounts/bank'; import { Group } from '../src/accounts/group'; import { MangoClient } from '../src/client'; +import { DefaultTokenRegisterParams } from '../src/clientIxParamBuilder'; import { MANGO_V4_ID } from '../src/constants'; import { toNative } from '../src/utils'; @@ -28,10 +29,6 @@ const { GROUP_NUM: number; } = process.env as any; -const MIN_VAULT_TO_DEPOSITS_RATIO = 1; -const NET_BORROWS_WINDOW_SIZE_TS = 24 * 60 * 60; -const NET_BORROW_LIMIT_PER_WINDOW_QUOTE = toNative(0, 6).toNumber(); - const defaultOracleConfig = { confFilter: 0.1, maxStalenessSlots: null, @@ -46,6 +43,21 @@ const defaultInterestRate = { maxRate: 0.51, }; +const defaultTokenParams = { + ...DefaultTokenRegisterParams, + oracleConfig: defaultOracleConfig, + interestRateParams: defaultInterestRate, + loanOriginationFeeRate: 0.0, + loanFeeRate: 0.0, + initAssetWeight: 0, + maintAssetWeight: 0, + initLiabWeight: 1, + maintLiabWeight: 1, + liquidationFee: 0, + minVaultToDepositsRatio: 1, + netBorrowLimitPerWindowQuote: 0, +}; + async function buildAdminClient(): Promise<[MangoClient, Keypair]> { const admin = Keypair.fromSecretKey( Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))), @@ -108,20 +120,9 @@ async function registerTokens(): Promise { group, usdcMainnetMint, usdcMainnetOracle, - defaultOracleConfig, 0, 'USDC', - defaultInterestRate, - 0.0, - 0.0, - 0, - 0, - 0, - 0, - 0, - MIN_VAULT_TO_DEPOSITS_RATIO, - NET_BORROWS_WINDOW_SIZE_TS, - NET_BORROW_LIMIT_PER_WINDOW_QUOTE, + defaultTokenParams, ); console.log(`registered usdc ${sig}`); @@ -131,20 +132,9 @@ async function registerTokens(): Promise { group, solMainnetMint, solMainnetOracle, - defaultOracleConfig, 1, 'SOL', - defaultInterestRate, - 0.0, - 0.0, - 0, - 0, - 0, - 0, - 0, - MIN_VAULT_TO_DEPOSITS_RATIO, - NET_BORROWS_WINDOW_SIZE_TS, - NET_BORROW_LIMIT_PER_WINDOW_QUOTE, + defaultTokenParams, ); console.log(`registered sol ${sig}`); }