Short operational notes for developers: deployment, upgrade, and development tools for deeptrade-core package.
- Go to
packages/deeptrade-coredirectory (cd packages/deeptrade-core/) - Set
addressto0x0inMove.toml - Publish:
sui client publish --gas-budget 420000000
- Copy the new package
addressintopackages/deeptrade-core/Move.toml - Update
examples/constants.tswith new:DEEPTRADE_CORE_PACKAGE_IDADMIN_CAP_OBJECT_IDTREASURY_OBJECT_ID
- Add DEEP coins to reserves if needed:
ts-node examples/treasury/deposit-into-reserves.ts
- Go to
packages/deeptrade-coredirectory (cd packages/deeptrade-core/) - Set
addressto0x0inMove.toml - (optionally) In case it's update, that requires force update all clients and disable previous version, bump
CURRENT_VERSIONinpackages/deeptrade-core/helper.move. - Make sure that
envis set inMove.lock(or legacypublished_atpresent inMove.toml). - Verify compatibility:
sui client upgrade --dry-run --verify-compatibility --upgrade-capability <UPGRADE_CAP_ID> --gas-budget 1000000000
- Dry run upgrade (without
--verify-compatibility):sui client upgrade --dry-run --upgrade-capability <UPGRADE_CAP_ID> --gas-budget 1000000000
- Upgrade:
sui client upgrade --upgrade-capability <UPGRADE_CAP_ID> --gas-budget 1000000000
- Set
addressinMove.tomlto the new package address (from contract upgrade tx effects) - Build:
sui move build
- (Optional) Update
examples/constants.tsIDs if they changed
This section describes how to run the test suite for the deeptrade-core package. For information on generating coverage reports, see the "Test Coverage Reports" section below.
We prefer using remote dependencies in [dependencies] section of Move.toml, to ensure that we
maintain clarity for external observers and avoid potential integrity issues that could arise from
using modified local versions of dependencies in long-term.
The core issue affecting testing is a Sui compiler bug (Sui issue #23173) that prevents the project from building when development dependencies are active (uncommented).
Therefore, running tests always requires temporarily uncommenting these dependencies.
-
Uncomment Dependencies: In
packages/deeptrade-core/Move.toml, find the[dev-dependencies]section and uncomment the lines fordeepbookandPyth. -
Run Tests: From the root of the project, run the test command.
- To run all tests:
(cd packages/deeptrade-core && sui move test) - To run specific tests, you can add a filter string that matches the test function name:
(cd packages/deeptrade-core && sui move test <FILTER_STRING>)
- To run all tests:
-
Re-comment Dependencies: After testing is complete, remember to comment the
[dev-dependencies]inMove.tomlback out to avoid build issues.
There are three ways to generate and view test coverage reports. The automated scripts are recommended for convenience and reliability.
This script runs all tests, generates coverage data, and prints a summary directly in your terminal. It handles dependency management for you.
- Run the script:
sh scripts/run-coverage.sh
- Review the summary: The script will print a summary table of test coverage.
- (Optional) Explore manually: The script also generates the necessary coverage data. You can then manually inspect the coverage for any specific module. For example:
(cd packages/deeptrade-core && sui move coverage source --module pool)
This method is ideal for detailed reviews or for providing reports to auditors. It generates a full, browsable HTML coverage report.
- Prerequisite: Install
aha: This tool converts terminal output to HTML. You only need to do this once.- On macOS:
brew install aha - On Debian/Ubuntu:
sudo apt-get install aha
- On macOS:
- Run the script:
sh scripts/generate-coverage-report.sh
- View the Report: The script will generate a
coverage-reportsdirectory and provide a command to start a local web server to view the files. Open theindex.htmlfile in your browser to see the report.
If you prefer to run everything manually, follow these steps:
-
Uncomment Dependencies: In
packages/deeptrade-core/Move.toml, find the[dev-dependencies]section and uncomment the lines fordeepbookandPyth. -
Run Tests with Coverage: From the root of the project, run the test command with the
--coverageflag.(cd packages/deeptrade-core && sui move test --coverage)
-
Re-comment Dependencies: After testing is complete, remember to comment the
[dev-dependencies]inMove.tomlback out. -
View Coverage Results:
- For a summary:
(cd packages/deeptrade-core && sui move coverage summary) - For a specific module:
(cd packages/deeptrade-core && sui move coverage source --module pool)
- For a summary:
- Run
examples/treasury/get-charged-fee-info.tsto get the list of coins with charged fees (coverage fees and protocol fees). - Run
examples/ticket/admin-withdraw-all-coins-coverage-fee.tsto withdraw all coins coverage fees (coverage fees charged in output coin of each swap and for limit/market orders in SUI). - Run
examples/ticket/admin-withdraw-protocol-fee.tsto withdraw all protocol fees (protocol fees charged in SUI, pool creation fees charged in DEEP). - Run
examples/ticket/admin-withdraw-all-deep-reserves.tsto withdraw all DEEP coins from reserves.
For testing contract endpoints that require multisig authorization, use the multisig testing tool:
npm run test:multisig <transaction-bytes>This tool automates the multisig transaction flow by:
- Signing the transaction with all configured signers
- Combining the signatures
- Executing the final transaction
The tool uses the multisig configuration from examples/multisig/multisig.ts. Useful for rapid testing of multisig-protected endpoints during development.
Analyze and count lines of code across all Deeptrade Core package modules:
node scripts/count-loc.js [--help for options]The script provides a detailed breakdown by module and calculates effective lines of code. It analyzes both source files and test files separately.
Example: 🎯 Effective LoC (sources only): 1,234 lines
Use sui move build --lint for linting - enables additional linting checks beyond the default linters
The deeptrade_core address in packages/deeptrade-core/Move.toml is set to 0x1 as a workaround for a Sui compiler bug that creates namespace conflicts when a package and its dependencies share module names (Sui issue #22194). Our package and its deepbook dependency both contain math, pool, and order modules.
While developers typically set a package's address to 0x0 for local development, we use 0x1 to prevent build failures.
Important: This address must be changed to 0x0 before deploying or upgrading the package.