Skip to content
Open
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
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"programs/integration_tests",
"tools/idl-gen",
"tools/risc0-packager",
"tools/wallet-idl-decoder",
]
exclude = [
"programs/token/methods/guest",
Expand Down
58 changes: 57 additions & 1 deletion apps/amm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21)
project(AmmUiPlugin LANGUAGES CXX)

find_package(Qt6 6.8 REQUIRED COMPONENTS Core Gui Network Qml Quick QuickControls2)
find_package(Qt6 6.8 REQUIRED COMPONENTS Core Gui Qml Quick QuickControls2)
qt_standard_project_setup(REQUIRES 6.8)

find_package(PkgConfig REQUIRED)
Expand All @@ -23,6 +23,30 @@ set(LOGOS_WALLET_GENERATED_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/generated_code"
CACHE PATH "Path to generated Logos SDK sources"
)
# LogosModule.cmake discovers external libraries only while it creates the AMM
# plugin, after this shared static target has already been configured. When the
# builder has staged the decoder locally, expose it to direct shared-wallet
# consumers too; the plugin's EXTERNAL_LIBS entry below remains the canonical
# packaging/runtime dependency.
if(NOT LOGOS_WALLET_IDL_DECODER_LIBRARY)
set(amm_wallet_decoder_search_path "${CMAKE_CURRENT_SOURCE_DIR}/lib")
if(DEFINED ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER})
set(amm_wallet_decoder_search_path
"$ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER}/lib")
endif()
find_library(AMM_WALLET_IDL_DECODER_LIBRARY
NAMES wallet_idl_decoder
PATHS "${amm_wallet_decoder_search_path}"
NO_DEFAULT_PATH
)
if(AMM_WALLET_IDL_DECODER_LIBRARY)
set(LOGOS_WALLET_IDL_DECODER_LIBRARY
"${AMM_WALLET_IDL_DECODER_LIBRARY}"
CACHE FILEPATH
"wallet_idl_decoder library required by logos_wallet_access"
)
endif()
endif()
add_subdirectory("${LOGOS_WALLET_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/shared-wallet")

# ui_qml module with a hand-written C++ backend (QtRO .rep view contract +
Expand Down Expand Up @@ -52,9 +76,40 @@ logos_module(
logos_wallet_access
EXTERNAL_LIBS
amm_client
wallet_idl_decoder
)

set(LEZ_IDL_ARTIFACTS_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../../artifacts"
CACHE PATH "Path to committed LEZ program IDL artifacts"
)
set(AMM_TOKEN_IDL "${LEZ_IDL_ARTIFACTS_DIR}/token-idl.json")
set(AMM_IDL "${LEZ_IDL_ARTIFACTS_DIR}/amm-idl.json")

foreach(idl_file IN ITEMS "${AMM_TOKEN_IDL}" "${AMM_IDL}")
if(NOT EXISTS "${idl_file}")
message(FATAL_ERROR "Committed IDL artifact not found: ${idl_file}")
endif()
endforeach()

set_source_files_properties(
"${AMM_TOKEN_IDL}"
PROPERTIES QT_RESOURCE_ALIAS "idl/token-idl.json"
)
set_source_files_properties(
"${AMM_IDL}"
PROPERTIES QT_RESOURCE_ALIAS "idl/amm-idl.json"
)
qt_add_resources(amm_ui_module_plugin amm_ui_wallet_data
PREFIX "/amm"
FILES
"${AMM_TOKEN_IDL}"
"${AMM_IDL}"
)

if(BUILD_TESTING)
find_package(Qt6 6.8 REQUIRED COMPONENTS Test)

add_executable(amm_new_position_runtime_test
tests/cpp/NewPositionRuntimeTest.cpp
src/NewPositionRuntime.cpp
Expand All @@ -66,4 +121,5 @@ if(BUILD_TESTING)
logos_wallet_access
)
add_test(NAME amm_new_position_runtime COMMAND amm_new_position_runtime_test)

endif()
17 changes: 17 additions & 0 deletions apps/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ nix run .#amm-ui
Without `AMM_PROGRAM_BIN` the Swap and Liquidity views stay disabled; without
`TOKENS_CONFIG` the token picker is empty. Each is detailed below.

### Network identity

The shared wallet verifies the sequencer before it enables network-dependent
portfolio data or AMM quotes. Testnet uses the bundled checkpoint identity. For
devnet, provide the channel identity emitted by the local sequencer:

```bash
LOGOS_WALLET_NETWORK=devnet \
LOGOS_WALLET_DEVNET_FILE=/abs/path/to/devnet.json \
nix run .#amm-ui
```

`devnet.json` must contain a 64-character lowercase-hex `channelId`. The
legacy `AMM_UI_NETWORK` and `AMM_UI_DEVNET_FILE` names remain accepted. AMM
deployment and token selection stay app-specific through `AMM_PROGRAM_BIN` and
`TOKENS_CONFIG`.

### AMM program binary (required for swaps and liquidity)

To execute a swap, the app must submit a transaction against the **exact AMM
Expand Down
6 changes: 6 additions & 0 deletions apps/amm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

inputs = {
logos-module-builder.url = "github:logos-co/logos-module-builder";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11-small";
crane.url = "github:ipetkov/crane/v0.23.4";

# Shared C++ wallet access and Logos.Wallet QML sources.
shared_wallet = {
Expand Down Expand Up @@ -54,6 +56,10 @@
input = inputs.amm_client;
packages.default = "amm_client";
};
wallet_idl_decoder = {
input = inputs.amm_client;
packages.default = "wallet_idl_decoder";
};
};
postInstall = ''
# The builder installs the view under lib/qml after this hook. Its
Expand Down
3 changes: 2 additions & 1 deletion apps/amm/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"runtime": ["qt6.qtdeclarative", "zstd", "krb5", "abseil-cpp", "libbase58"]
},
"external_libraries": [
{ "name": "amm_client" }
{ "name": "amm_client" },
{ "name": "wallet_idl_decoder" }
],
"cmake": {
"find_packages": [],
Expand Down
8 changes: 3 additions & 5 deletions apps/amm/src/ActiveNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
#include <QString>
#include <QStringList>

// Network context handed to the new-position flow. The AMM deployment identity
// (ammProgramId, from $AMM_PROGRAM_BIN) and the configured token set (tokenIds,
// from $TOKENS_CONFIG) are the same sources the Swap view uses; there is no
// separate network config file or channel-identity probe. `fingerprint` binds a
// quote to the deployment so a quote can't be replayed against a different one.
// AMM-specific deployment context handed to the new-position flow. Shared
// wallet code verifies the sequencer identity; this type adds the AMM program
// and configured token definitions required only by the AMM runtime.
struct ActiveNetworkSnapshot {
QString id;
QString status;
Expand Down
Loading
Loading