Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/move_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
test:
runs-on: ubuntu-latest
env:
SUI_VERSION: "1.80.1" # Parameterized Sui version
SUI_VERSION: "1.83.1" # Parameterized Sui version

steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -67,8 +67,10 @@ jobs:
TOML=packages/deeptrade-core/Move.toml
# Comment production pins, then uncomment the test-fork lines (no duplicate keys).
perl -i -pe 's/^(deepbook = \{ git = "https:\/\/github.com\/MystenLabs\/deepbookv3.git".*\})/# $1/' "$TOML"
perl -i -pe 's/^(token = \{ git = "https:\/\/github.com\/MystenLabs\/deepbookv3.git".*\})/# $1/' "$TOML"
perl -i -pe 's/^(pyth = \{ git = "https:\/\/github.com\/pyth-network\/pyth-crosschain.git".*\})/# $1/' "$TOML"
perl -i -pe 's/^#\s*(deepbook = \{ git = "https:\/\/github.com\/DeeptradeProtocol\/deepbookv3.git".*\})/$1/' "$TOML"
perl -i -pe 's/^#\s*(token = \{ git = "https:\/\/github.com\/DeeptradeProtocol\/deepbookv3.git".*\})/$1/' "$TOML"
perl -i -pe 's/^#\s*(pyth = \{ git = "https:\/\/github.com\/DeeptradeProtocol\/pyth-crosschain.git".*\})/$1/' "$TOML"
echo "Move.toml after changes:"
cat "$TOML"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
env:
# Keep in sync with .github/workflows/move_test.yml (SUI_VERSION).
SUI_VERSION: "1.80.1"
SUI_VERSION: "1.83.1"
PACKAGE_PATH: "packages/deeptrade-core"
# Gas budget for the unsigned upgrade PTB (MIST). CLI auto-selects coins from sender.
GAS_BUDGET: "1000000000"
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrade-provenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This rebuilds with `toolchain-version` from `Published.toml` and compares root p
If metadata is incomplete, override explicitly:

```bash
sui client verify-source --toolchain-version 1.80.1
sui client verify-source --toolchain-version 1.83.1
```

## What each check proves
Expand Down
40 changes: 14 additions & 26 deletions packages/deeptrade-core/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
version = 4

[pinned.mainnet.MoveStdlib]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "ae59d7718668b468ce65702ecb0440aa2330f389" }
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "b0535f1f3a3310e71790e90d8ae4e8ca840c897e" }
use_environment = "mainnet"
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
deps = {}

[pinned.mainnet.MoveStdlib_1]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "62b9f371e37e618b7048417e2d232d6cd678c967" }
use_environment = "mainnet"
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
deps = {}

[pinned.mainnet.MoveStdlib_2]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "041c5f2bae2fe52079e44b70514333532d69f4e6" }
use_environment = "mainnet"
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
Expand All @@ -26,54 +20,48 @@ deps = {}
source = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "3bd1262dcba9518a6901aa6a15f04072799bfb37" }
use_environment = "mainnet"
manifest_digest = "F2C5AF85C4B72C8F6A8132D05DE4F787F4EB80DBFF812331ED65AE599E7DF92A"
deps = { Sui = "Sui_2", Wormhole = "Wormhole" }
deps = { Sui = "Sui_1", Wormhole = "Wormhole" }

[pinned.mainnet.PythProCompatible]
source = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "aa291266173173480efef77b9454f2dbc2b4fd62" }
use_environment = "mainnet"
manifest_digest = "3D2B5BBF2058F3C9DCA3527CC2486C518124687B60479CA9875E5475652B7BBC"
deps = { Sui = "Sui_2", WormholeSimpleMajority = "WormholeSimpleMajority" }
deps = { Sui = "Sui_1", WormholeSimpleMajority = "WormholeSimpleMajority" }

[pinned.mainnet.Sui]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "ae59d7718668b468ce65702ecb0440aa2330f389" }
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "b0535f1f3a3310e71790e90d8ae4e8ca840c897e" }
use_environment = "mainnet"
manifest_digest = "CD547CB1ACCE0880C835DAED2D8FFCB91D56C833AE5240D3AA5B918398263195"
deps = { MoveStdlib = "MoveStdlib" }

[pinned.mainnet.Sui_1]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "62b9f371e37e618b7048417e2d232d6cd678c967" }
use_environment = "mainnet"
manifest_digest = "CD547CB1ACCE0880C835DAED2D8FFCB91D56C833AE5240D3AA5B918398263195"
deps = { MoveStdlib = "MoveStdlib_1" }

[pinned.mainnet.Sui_2]
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "041c5f2bae2fe52079e44b70514333532d69f4e6" }
use_environment = "mainnet"
manifest_digest = "CD547CB1ACCE0880C835DAED2D8FFCB91D56C833AE5240D3AA5B918398263195"
deps = { MoveStdlib = "MoveStdlib_2" }
deps = { MoveStdlib = "MoveStdlib_1" }

[pinned.mainnet.Wormhole]
source = { git = "https://github.com/wormhole-foundation/wormhole.git", subdir = "sui/wormhole", rev = "b71be5cbb9537c4aac8e23e74371affa3825efcd" }
use_environment = "mainnet"
manifest_digest = "0D766A0380B75080707CFA6099AF469A2E502B0D9DC334A9E9983B391C5555D9"
deps = { Sui = "Sui_2" }
deps = { Sui = "Sui_1" }

[pinned.mainnet.WormholeSimpleMajority]
source = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/vendor/wormhole_simple_majority/wormhole", rev = "aa291266173173480efef77b9454f2dbc2b4fd62" }
use_environment = "mainnet"
manifest_digest = "0D766A0380B75080707CFA6099AF469A2E502B0D9DC334A9E9983B391C5555D9"
deps = { Sui = "Sui_2" }
deps = { Sui = "Sui_1" }

[pinned.mainnet.deepbook]
source = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/deepbook", rev = "bf14d55d8aeabcd06f30713a2c105532c01d3d9a" }
source = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/deepbook", rev = "8a46552dfac02f2225965dda243bdea1ddcbec89" }
use_environment = "mainnet"
manifest_digest = "FCFED6D27C18F9FA855BD4A8D57673B0DBC5654AC7B60BCC86ACB4BBAC23EEDF"
deps = { Sui = "Sui_1", token = "token" }
manifest_digest = "BBE7F8BFEF088532C5358623C6F5B3153EE14B3265ABA833B0F3CF9D313264A7"
deps = { std = "MoveStdlib", sui = "Sui", token = "token" }

[pinned.mainnet.deeptrade_core]
source = { root = true }
use_environment = "mainnet"
manifest_digest = "146698FE91735D6E150640D3554540F22780B51F153C7DFABB7BFF8DFBC757C4"
manifest_digest = "349A4DE56587A83933E2890B98CC6978620033B8002BE40ABC22DBFE28820C32"
deps = { deepbook = "deepbook", multisig = "multisig", pyth = "Pyth", pyth_upgraded = "PythProCompatible", std = "MoveStdlib", sui = "Sui", token = "token" }

[pinned.mainnet.multisig]
Expand All @@ -83,7 +71,7 @@ manifest_digest = "E41BBD67BE8940D26C79D78B028477EF5B33BA217A1282C78ACB344CF8A5E
deps = { std = "MoveStdlib", sui = "Sui" }

[pinned.mainnet.token]
source = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/token", rev = "bf14d55d8aeabcd06f30713a2c105532c01d3d9a" }
source = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/token", rev = "8a46552dfac02f2225965dda243bdea1ddcbec89" }
use_environment = "mainnet"
manifest_digest = "CF8E7F9892A27676E1B4120F63AB9B10842B35CF5D395B321061CDFBCFE084B3"
deps = { Sui = "Sui_1" }
manifest_digest = "E41BBD67BE8940D26C79D78B028477EF5B33BA217A1282C78ACB344CF8A5ECF6"
deps = { std = "MoveStdlib", sui = "Sui" }
7 changes: 4 additions & 3 deletions packages/deeptrade-core/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "2.0.0"
edition = "2024.alpha"

[dependencies]
deepbook = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/deepbook", rev = "v4.0.0" }
token = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/token", rev = "main" }
deepbook = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/deepbook", rev = "v9.0.0" }
token = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/token", rev = "v9.0.0" }
multisig = { git = "https://github.com/DeeptradeProtocol/multisig-move.git", subdir = "move", rev = "v1.0.1" }

# Pyth dependency
Expand All @@ -16,5 +16,6 @@ pyth_upgraded = { git = "https://github.com/pyth-network/pyth-crosschain.git", s

# For `sui move test`, comment the production pins above and uncomment these.
# Never leave both copies uncommented.
# deepbook = { git = "https://github.com/DeeptradeProtocol/deepbookv3.git", subdir = "packages/deepbook", rev = "v4-tag-fork-test-methods" }
# deepbook = { git = "https://github.com/DeeptradeProtocol/deepbookv3.git", subdir = "packages/deepbook", rev = "v9-tag-fork-test-methods" }
# token = { git = "https://github.com/DeeptradeProtocol/deepbookv3.git", subdir = "packages/token", rev = "v9-tag-fork-test-methods" }
# pyth = { git = "https://github.com/DeeptradeProtocol/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "sui-contract-mainnet" }
2 changes: 1 addition & 1 deletion packages/deeptrade-core/Published.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ published-at = "0xda5b27f23ac02c1f9acec07a32baf6523a381d7df9b00d99c99e3f9b41b128
original-id = "0xc10d536b6580d809711b9bb8eee3945d5e96f92a346c84d74ff7a0697e664695"
version = 2
upgrade-capability = "0x331c41b3587619223c8ccf44b2aa9ad683fae7b536d6b5ed96fc94fe9a8d4278"
toolchain-version = "1.80.1"
toolchain-version = "1.83.1"
build-config = { flavor = "sui", edition = "2024.alpha" }
32 changes: 30 additions & 2 deletions packages/deeptrade-core/sources/helper.move
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,42 @@ public(package) fun calculate_market_order_params<BaseToken, QuoteToken>(
// Since `get_quantity_out` goes through order book same way as actual order placement,
// we can use its `deep_req` value
// - For asks: Use order_amount directly as base quantity. Since `get_quantity_out` goes through
// order book same way as actual order placement, we can use its `deep_req` value
// order book same way as actual order placement, we can use its `deep_req` value.
// Exception is the dust-bid case handled below.
if (is_bid) {
let (base_out, _, deep_req) = pool.get_quantity_out(0, order_amount, clock);
let (_, lot_size, _) = pool.pool_book_params();
let floored_base_out = base_out - base_out % lot_size;
(floored_base_out, deep_req)
} else {
let (_, _, deep_req) = pool.get_quantity_out(order_amount, 0, clock);
let (base_left, _, mut deep_req) = pool.get_quantity_out(order_amount, 0, clock);
let (_, _, min_size) = pool.pool_book_params();

// DeepBook v9 `get_quantity_out` can return 0 DEEP required for ask that will require
// DEEP on execution. Example: min_size is 1 SUI, the sell is 10 SUI, and the only
// bid is 0.2 SUI. `get_quantity_out` will say nothing is filled, so no DEEP required,
// but the real order will fill that 0.2 SUI and take DEEP fee for that. If the balance
// manager has no DEEP, transaction aborts.
// How do we handle this?
// First, we check that `get_quantity_out` says nothing is filled (`base_left == order_amount`).
// This can be in 3 cases: empty bids, dust bids (< min_size), or order is too small (< min_size).
// So, at second, we check that the order is at least `min_size` (order_amount >= min_size).
// If both are true, we know that either bids are empty or dust.
// Third, we check that the best bid is live (best_bid.is_some()).
// If all three are true, we know that this is the dust-bid case and the order will require
// DEEP on execution. Since we know that sum of dust bids sizes is less than `min_size`
// (otherwise, `get_quantity_out` returns base_left < order_amount), we can estimate the maximum
// DEEP that can be required to fill these dust bids: `min_size * best_bid_price`.
if (base_left == order_amount && order_amount >= min_size) {
let best_bid = pool.best_bid_price(clock);
if (best_bid.is_some()) {
let (taker_deep, _) = pool.get_order_deep_required(
min_size,
best_bid.destroy_some(),
);
deep_req = taker_deep;
}
};
(order_amount, deep_req)
}
}
Expand Down
Loading
Loading