diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d079a9d..8a0789219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,35 @@ Update this for each program release and mainnet deployment. ## not on mainnet -### v0.16.0, 2023-5- +### v0.17.0, 2023-6- + +- Configurable perp market settle token (#550) + + This changes perp market margining to no longer assume all pnl is in USD + while settlement is in USDC. Instead, a configurable settle token is used for + pnl and settlement, defaulting to USDC. + + There is no difference while the USDC price is forced to $1 and its init and liab + weights are 1. But with this patch, it becomes possible to change that. + + For now it is not recommended to use a token other than USDC or USDT (or + another USD targeting stable token) for perp settlement. + + The patch also updates all instructions dealing with the insurance vault + to be aware that the insurance fund is not in USD but in USDC and apply the + USDC price before payouts. To do this, the previous + PerpLiqNegativePnlOrBankruptcy was replaced by a new + PerpLiqNegativePnlOrBankruptcyV2 instruction. + +- Whitelist PerpPlaceOrderV2 and PerpPlaceOrderPeggedV2 for HealthRegions (#597) +- Improve docs (#590, #594) +- Use workspace dependencies (#588) + +## mainnet + +### v0.16.0, 2023-5-19 + +Deployment: May 19, 2023 at 15:35:12 Central European Summer Time, https://explorer.solana.com/tx/22fEcghPGgAnYCZkfjTxTeKQwX5rzWSx3c5CV9TikJmaAKWCpubCZYBx5ZJJPeNG1xWUPWMw3ooDhFBRYCR3tKYU - New event: PerpTakerTradeLog immediately logs your trade execution (#579, #584) @@ -26,8 +54,6 @@ Update this for each program release and mainnet deployment. Mango used to depend on a fork of anchor. Now all patches are upstreamed and we have upgraded to the unmodified upstream version of v0.27.0. -## mainnet - ### v0.15.0, 2023-5-11 Deployment: May 11, 2023 at 09:29:12 Central European Summer Time, https://explorer.solana.com/tx/3h6KFxLEAvifNGDBNcQrWdc6cRkpHTzFzL8VradfAXBYNfScrLJzDxm52N4RNmS9dmE84zDuwbErQ75RcxDcihY3 diff --git a/Cargo.lock b/Cargo.lock index bf55098cd..53565103d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,7 +2928,7 @@ dependencies = [ [[package]] name = "mango-v4" -version = "0.16.0" +version = "0.17.0" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/mango_v4.json b/mango_v4.json index 2a70d762f..fdbd80dd0 100644 --- a/mango_v4.json +++ b/mango_v4.json @@ -1,5 +1,5 @@ { - "version": "0.16.0", + "version": "0.17.0", "name": "mango_v4", "instructions": [ { @@ -4556,12 +4556,18 @@ { "name": "group", "isMut": false, - "isSigner": false + "isSigner": false, + "relations": [ + "insurance_vault" + ] }, { "name": "liqor", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "liqorOwner", @@ -4571,12 +4577,19 @@ { "name": "liqee", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "perpMarket", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group", + "oracle" + ] }, { "name": "oracle", @@ -4586,7 +4599,10 @@ { "name": "settleBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "settleVault", @@ -4606,7 +4622,10 @@ { "name": "insuranceBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "insuranceBankVault", @@ -6202,6 +6221,14 @@ }, { "name": "Serum3Info", + "docs": [ + "Information about reserved funds on Serum3 open orders accounts.", + "", + "Note that all \"free\" funds on open orders accounts are added directly", + "to the token info. This is only about dealing with the reserved funds", + "that might end up as base OR quote tokens, depending on whether the", + "open orders execute on not." + ], "type": { "kind": "struct", "fields": [ @@ -6218,11 +6245,11 @@ } }, { - "name": "baseIndex", + "name": "baseInfoIndex", "type": "u64" }, { - "name": "quoteIndex", + "name": "quoteInfoIndex", "type": "u64" }, { @@ -6241,6 +6268,12 @@ }, { "name": "PerpInfo", + "docs": [ + "Stores information about perp market positions and their open orders.", + "", + "Perp markets affect account health indirectly, though the token balance in the", + "perp market's settle token. See `effective_token_balances()`." + ], "type": { "kind": "struct", "fields": [ @@ -6329,6 +6362,21 @@ }, { "name": "HealthCache", + "docs": [ + "Store information needed to compute account health", + "", + "This is called a cache, because it extracts information from a MangoAccount and", + "the Bank, Perp, oracle accounts once and then allows computing different types", + "of health.", + "", + "For compute-saving reasons, it also allows applying adjustments to the extracted", + "positions. That's often helpful for instructions that want to re-compute health", + "after having made small, well-known changes to an account. Recomputing the", + "HealthCache from scratch would be significantly more expensive.", + "", + "However, there's a real risk of getting the adjustments wrong and computing an", + "inconsistent result, so particular care needs to be taken when this is done." + ], "type": { "kind": "struct", "fields": [ diff --git a/programs/mango-v4/Cargo.toml b/programs/mango-v4/Cargo.toml index e26787c74..f6440faf4 100644 --- a/programs/mango-v4/Cargo.toml +++ b/programs/mango-v4/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = ["workspace-inheritance"] [package] name = "mango-v4" -version = "0.16.0" +version = "0.17.0" description = "Created with Anchor" edition = "2021" diff --git a/ts/client/src/mango_v4.ts b/ts/client/src/mango_v4.ts index fa71e175b..0902fc018 100644 --- a/ts/client/src/mango_v4.ts +++ b/ts/client/src/mango_v4.ts @@ -1,5 +1,5 @@ export type MangoV4 = { - "version": "0.16.0", + "version": "0.17.0", "name": "mango_v4", "instructions": [ { @@ -4556,12 +4556,18 @@ export type MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false + "isSigner": false, + "relations": [ + "insurance_vault" + ] }, { "name": "liqor", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "liqorOwner", @@ -4571,12 +4577,19 @@ export type MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "perpMarket", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group", + "oracle" + ] }, { "name": "oracle", @@ -4586,7 +4599,10 @@ export type MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "settleVault", @@ -4606,7 +4622,10 @@ export type MangoV4 = { { "name": "insuranceBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "insuranceBankVault", @@ -6202,6 +6221,14 @@ export type MangoV4 = { }, { "name": "Serum3Info", + "docs": [ + "Information about reserved funds on Serum3 open orders accounts.", + "", + "Note that all \"free\" funds on open orders accounts are added directly", + "to the token info. This is only about dealing with the reserved funds", + "that might end up as base OR quote tokens, depending on whether the", + "open orders execute on not." + ], "type": { "kind": "struct", "fields": [ @@ -6218,11 +6245,11 @@ export type MangoV4 = { } }, { - "name": "baseIndex", + "name": "baseInfoIndex", "type": "u64" }, { - "name": "quoteIndex", + "name": "quoteInfoIndex", "type": "u64" }, { @@ -6241,6 +6268,12 @@ export type MangoV4 = { }, { "name": "PerpInfo", + "docs": [ + "Stores information about perp market positions and their open orders.", + "", + "Perp markets affect account health indirectly, though the token balance in the", + "perp market's settle token. See `effective_token_balances()`." + ], "type": { "kind": "struct", "fields": [ @@ -6329,6 +6362,21 @@ export type MangoV4 = { }, { "name": "HealthCache", + "docs": [ + "Store information needed to compute account health", + "", + "This is called a cache, because it extracts information from a MangoAccount and", + "the Bank, Perp, oracle accounts once and then allows computing different types", + "of health.", + "", + "For compute-saving reasons, it also allows applying adjustments to the extracted", + "positions. That's often helpful for instructions that want to re-compute health", + "after having made small, well-known changes to an account. Recomputing the", + "HealthCache from scratch would be significantly more expensive.", + "", + "However, there's a real risk of getting the adjustments wrong and computing an", + "inconsistent result, so particular care needs to be taken when this is done." + ], "type": { "kind": "struct", "fields": [ @@ -9912,7 +9960,7 @@ export type MangoV4 = { }; export const IDL: MangoV4 = { - "version": "0.16.0", + "version": "0.17.0", "name": "mango_v4", "instructions": [ { @@ -14469,12 +14517,18 @@ export const IDL: MangoV4 = { { "name": "group", "isMut": false, - "isSigner": false + "isSigner": false, + "relations": [ + "insurance_vault" + ] }, { "name": "liqor", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "liqorOwner", @@ -14484,12 +14538,19 @@ export const IDL: MangoV4 = { { "name": "liqee", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "perpMarket", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group", + "oracle" + ] }, { "name": "oracle", @@ -14499,7 +14560,10 @@ export const IDL: MangoV4 = { { "name": "settleBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "settleVault", @@ -14519,7 +14583,10 @@ export const IDL: MangoV4 = { { "name": "insuranceBank", "isMut": true, - "isSigner": false + "isSigner": false, + "relations": [ + "group" + ] }, { "name": "insuranceBankVault", @@ -16115,6 +16182,14 @@ export const IDL: MangoV4 = { }, { "name": "Serum3Info", + "docs": [ + "Information about reserved funds on Serum3 open orders accounts.", + "", + "Note that all \"free\" funds on open orders accounts are added directly", + "to the token info. This is only about dealing with the reserved funds", + "that might end up as base OR quote tokens, depending on whether the", + "open orders execute on not." + ], "type": { "kind": "struct", "fields": [ @@ -16131,11 +16206,11 @@ export const IDL: MangoV4 = { } }, { - "name": "baseIndex", + "name": "baseInfoIndex", "type": "u64" }, { - "name": "quoteIndex", + "name": "quoteInfoIndex", "type": "u64" }, { @@ -16154,6 +16229,12 @@ export const IDL: MangoV4 = { }, { "name": "PerpInfo", + "docs": [ + "Stores information about perp market positions and their open orders.", + "", + "Perp markets affect account health indirectly, though the token balance in the", + "perp market's settle token. See `effective_token_balances()`." + ], "type": { "kind": "struct", "fields": [ @@ -16242,6 +16323,21 @@ export const IDL: MangoV4 = { }, { "name": "HealthCache", + "docs": [ + "Store information needed to compute account health", + "", + "This is called a cache, because it extracts information from a MangoAccount and", + "the Bank, Perp, oracle accounts once and then allows computing different types", + "of health.", + "", + "For compute-saving reasons, it also allows applying adjustments to the extracted", + "positions. That's often helpful for instructions that want to re-compute health", + "after having made small, well-known changes to an account. Recomputing the", + "HealthCache from scratch would be significantly more expensive.", + "", + "However, there's a real risk of getting the adjustments wrong and computing an", + "inconsistent result, so particular care needs to be taken when this is done." + ], "type": { "kind": "struct", "fields": [