From 540306fea4ad291d19ded7ba822fcc97946ba71a Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 25 Sep 2024 16:12:28 +0100 Subject: [PATCH 1/3] chore: correct invalid AC --- protocol/0097-PAPU-protocol_automated_purchases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/0097-PAPU-protocol_automated_purchases.md b/protocol/0097-PAPU-protocol_automated_purchases.md index 81dae3fb2..2e297113a 100644 --- a/protocol/0097-PAPU-protocol_automated_purchases.md +++ b/protocol/0097-PAPU-protocol_automated_purchases.md @@ -175,7 +175,7 @@ To ensure a market can only ever support one **active** PAP program: ### Protocol Automated Orders - Given the program specifies a source asset matching the base asset of the market, it will place a sell order at the start of the auction. (0097-PAPU-038). -- Given the program specifies a source asset matching the quote asset of the market, it will place a sell order at the start of the auction. (0097-PAPU-039). +- Given the program specifies a source asset matching the quote asset of the market, it will place a buy order at the start of the auction. (0097-PAPU-039). - The price of the order will equal the product of the oracle price and the programs oracle offset factor. (0097-PAPU-040). From 90ad9df5b6eb2b16e102f3bcaafed370bc647ca9 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 26 Sep 2024 13:51:56 +0100 Subject: [PATCH 2/3] feat: change uncrossed end of auction behaviour --- protocol/0097-PAPU-protocol_automated_purchases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/0097-PAPU-protocol_automated_purchases.md b/protocol/0097-PAPU-protocol_automated_purchases.md index 2e297113a..a1cb7c8f3 100644 --- a/protocol/0097-PAPU-protocol_automated_purchases.md +++ b/protocol/0097-PAPU-protocol_automated_purchases.md @@ -168,7 +168,7 @@ To ensure a market can only ever support one **active** PAP program: - Given an auction trigger occurs, if the price oracle has not yet reported a valid price, then the auction is skipped. (0097-PAPU-033). - Given an auction trigger occurs, if the price oracle has reported a valid price but the value is stale, then the auction is skipped. (0097-PAPU-034). -- Given the end of an auction is reached and the book is not crossed, the market will remain in auction un till an uncrossing price can be determined. (0097-PAPU-035). +- Given the end of an auction is reached and the book is not crossed, the auction will end, the automated purchase order removed from the book, and the funds earmarked for the auction released. (0097-PAPU-035). - Given the end of an auction is reached and the book is crossed, if the uncrossing price would break an active price monitoring trigger, the auction is extended by the relevant length. (0097-PAPU-036). - Given the end of an auction is reached and the book is crossed, if the uncrossing price would not break an active price monitoring trigger, the auction is ended. (0097-PAPU-037). From 16b8dc5975f38a120c2d7937967646f4b6d752cb Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 26 Sep 2024 16:23:08 +0100 Subject: [PATCH 3/3] feat: add ACs for decimal configurations --- .../0097-PAPU-protocol_automated_purchases.md | 145 ++++++++++++++++++ protocol/features.json | 16 +- 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/protocol/0097-PAPU-protocol_automated_purchases.md b/protocol/0097-PAPU-protocol_automated_purchases.md index a1cb7c8f3..bdf84d16c 100644 --- a/protocol/0097-PAPU-protocol_automated_purchases.md +++ b/protocol/0097-PAPU-protocol_automated_purchases.md @@ -186,3 +186,148 @@ To ensure a market can only ever support one **active** PAP program: - If an automated purchase order is not filled on auction uncrossing, the order is removed from the book automatically (as it is a GFA order) and all earmarked funds returned to the relevant source account. (0097-PAPU-044). - If an automated purchase order is only partially filled on auction uncrossing, the order is removed from the book automatically (as it is a GFA order), any swapped tokens transferred to the correct to account, and the remaining earmarked funds returned to the relevant source account. (0097-PAPU-045). - If an automated purchase order is fully filled on auction uncrossing, all swapped tokens are transferred to the correct to account. (0097-PAPU-046). + +- The following set of ACs assumes a program where the source token matches the base asset of the relevant market. Prices, sizes, and balances are expressed in there scaled integer form: + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-047). + + Given the decimals: + + - `oracleDecimals=3` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the base asset and the latest oracle price was `100000`. The program will submit a sell order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-048). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=3` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1000` at `100000`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-049). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=3` + + If the latest snapshot earmarked `1000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1000000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-050). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=-3` + + If the latest snapshot earmarked `1000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-051). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=3` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the from account holds `1000000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the quote asset. (0097-PAPU-052). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=3` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the from account holds `1000` of the base asset and the latest oracle price was `100`. The program will submit a sell order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000000` of the quote asset. (0097-PAPU-053). + + +- The following set of ACs assumes a program where the source token matches the base asset of the relevant market. Prices, sizes, and balances are expressed in there scaled integer form: + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-054). + + Given the decimals: + + - `oracleDecimals=3` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the quote asset and the latest oracle price was `100000`. The program will submit a buy order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-055). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=3` + - `marketPositionDecimals=0` + + If the latest snapshot earmarked `1000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1000` at `100000`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-056). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=3` + + If the latest snapshot earmarked `1000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1000000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-057). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=-3` + + If the latest snapshot earmarked `1000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-058). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=3` + - `quoteAssetDecimals=0` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the from account holds `1000000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000` of the base asset. (0097-PAPU-059). + + Given the decimals: + + - `oracleDecimals=0` + - `baseAssetDecimals=0` + - `quoteAssetDecimals=3` + - `marketPriceDecimals=0` + - `marketPositionDecimals=0` + + If the from account holds `1000` of the quote asset and the latest oracle price was `100`. The program will submit a buy order of size `1000` at `100`. When the auction uncrosses at that price, the to account will be credited with `100000000` of the base asset. (0097-PAPU-060). diff --git a/protocol/features.json b/protocol/features.json index 0b7099adc..6ad345b7c 100644 --- a/protocol/features.json +++ b/protocol/features.json @@ -832,7 +832,21 @@ "0097-PAPU-043", "0097-PAPU-044", "0097-PAPU-045", - "0097-PAPU-046" + "0097-PAPU-046", + "0097-PAPU-047", + "0097-PAPU-048", + "0097-PAPU-049", + "0097-PAPU-050", + "0097-PAPU-051", + "0097-PAPU-052", + "0097-PAPU-053", + "0097-PAPU-054", + "0097-PAPU-055", + "0097-PAPU-056", + "0097-PAPU-057", + "0097-PAPU-058", + "0097-PAPU-059", + "0097-PAPU-060" ] }, "Cancelling Proposals": {