Skip to content

Commit 113fbc8

Browse files
committed
2 parents 83d18ed + b4e8926 commit 113fbc8

22 files changed

Lines changed: 1845 additions & 143 deletions
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
3+
name: Multi-Platform Build
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
17+
fail-fast: false
18+
19+
# Set up a matrix to run the following 3 configurations:
20+
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
21+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
22+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
23+
#
24+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
25+
matrix:
26+
os: [ubuntu-latest, windows-latest]
27+
build_type: [Release]
28+
cpp_compiler: [g++, clang++, cl]
29+
include:
30+
- os: windows-latest
31+
cpp_compiler: cl
32+
- os: ubuntu-latest
33+
cpp_compiler: g++
34+
- os: ubuntu-latest
35+
cpp_compiler: clang++
36+
exclude:
37+
- os: windows-latest
38+
cpp_compiler: g++
39+
- os: windows-latest
40+
cpp_compiler: clang++
41+
- os: ubuntu-latest
42+
cpp_compiler: cl
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set reusable strings
48+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
49+
id: strings
50+
shell: bash
51+
run: |
52+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
53+
54+
- name: Configure CMake
55+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
56+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
57+
run: >
58+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
59+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
60+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
61+
-S ${{ github.workspace }}
62+
63+
- name: Build
64+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
65+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
66+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
build/
33
# geany editor
44
*geany
5+
tmp/
56

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ SET(FILES ${CMAKE_SOURCE_DIR}/connection.cpp
1515
${CMAKE_SOURCE_DIR}/proposal.cpp
1616
${CMAKE_SOURCE_DIR}/qearn.cpp
1717
${CMAKE_SOURCE_DIR}/qvault.cpp
18-
${CMAKE_SOURCE_DIR}/msvault.cpp
19-
${CMAKE_SOURCE_DIR}/nostromo.cpp
18+
${CMAKE_SOURCE_DIR}/msvault.cpp
19+
${CMAKE_SOURCE_DIR}/qswap.cpp
20+
${CMAKE_SOURCE_DIR}/nostromo.cpp
2021
)
2122
SET(HEADER_FILES
2223
K12AndKeyUtil.h
@@ -43,7 +44,9 @@ SET(HEADER_FILES
4344
qearn.h
4445
qvault.h
4546
msvault.h
46-
nostromo.h
47+
qswap.h
48+
qswap_struct.h
49+
nostromo.h
4750
)
4851
if(MSVC)
4952
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Qubic Core client
44

55
An intermediate tool to communicate to qubic core node.
6+
7+
> [![MultiPlatformBuild](https://github.com/qubic/qubic-cli/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/qubic/qubic-cli/actions/workflows/cmake-multi-platform.yml)
8+
69
```
710
./qubic-cli [basic config] [command] [command extra parameters]
811
-help print this message
@@ -250,8 +253,36 @@ Command:
250253
-msvaultgetvaultowners <VAULT_ID>
251254
Get MsVault owners given vault ID.
252255
253-
[NOSTROMO COMMANDS]
256+
[QSWAP COMMANDS]
257+
-qswapgetfee
258+
Show current Qswap fees.
259+
-qswapissueasset <ASSET_NAME> <NUMBER_OF_UNIT> <UNIT_OF_MEASUREMENT> <NUM_DECIMAL>
260+
Create an asset via Qswap contract.
261+
-qswaptransferasset <ASSET_NAME> <ISSUER_IN_HEX> <NEW_OWNER_IDENTITY> <AMOUNT_OF_SHARE>
262+
Transfer an asset via Qswap contract.
263+
-qswapcreatepool <ASSET_NAME> <ISSUER_IN_HEX>
264+
Create an AMM pool via Qswap contract.
265+
-qswapgetpoolbasicstate <ASSET_NAME> <ISSUER_IN_HEX>
266+
Get the basic info of a pool, totol liquidity, qu reserved, asset reserved.
267+
268+
-qswapaddliquidity <ASSET_NAME> <ISSUER_IN_HEX> <QU_AMOUNT_IN> <ASSET_AMOUNT_DESIRED> <QU_AMOUNT_MIN> <ASSET_AMOUNT_MIN>
269+
Add liquidity with restriction to an AMM pool via Qswap contract.
270+
-qswapremoveliquidity <ASSET_NAME> <ISSUER_IN_HEX> <BURN_LIQUIDITY> <QU_AMOUNT_MIN> <ASSET_AMOUNT_MIN>
271+
Remove liquidity with restriction from an AMM pool via Qswap contract.
272+
-qswapswapexactquforasset <ASSET_NAME> <ISSUER_IN_HEX> <QU_AMOUNT_IN> <ASSET_AMOUNT_OUT_MIN>
273+
Swap qu for asset via Qswap contract, only execute if asset_amount_out >= ASSET_AMOUNT_OUT_MIN.
274+
-qswapswapquforexactasset <ASSET_NAME> <ISSUER_IN_HEX> <ASSET_AMOUNT_OUT> <QU_AMOUNT_IN_MAX>
275+
Swap qu for asset via Qswap contract, only execute if qu_amount_in <= QU_AMOUNT_IN_MAX.
276+
-qswapswapexactassetforqu <ASSET_NAME> <ISSUER_IN_HEX> <ASSET_AMOUNT_IN> <QU_AMOUNT_OUT_MIN>
277+
Swap asset for qu via Qswap contract, only execute if qu_amount_out >= QU_AMOUNT_OUT_MIN.
278+
-qswapswapassetforexactqu <ASSET_NAME> <ISSUER_IN_HEX> <QU_AMOUNT_OUT> <ASSET_AMOUNT_IN_MAX>
279+
Swap asset for qu via Qswap contract, only execute if asset_amount_in <= ASSET_AMOUNT_IN_MAX.
280+
-qswapgetliquidityof <ASSET_NAME> <ISSUER_IN_HEX> [LIQUIDITY_STAKER(in qublic format)]
281+
Get the staker's liquidity in a pool.
282+
-qswapquote exact_qu_input/exact_qu_output/exact_asset_input/exact_asset_output <ASSET_NAME> <ISSUER_IN_HEX> <AMOUNT>
283+
Quote amount_out/amount_in with given amount_in/amount_out.
254284
285+
[NOSTROMO COMMANDS]
255286
-nostromoregisterintier <TIER_LEVEL>
256287
Register in tier.
257288
-nostromologoutfromtier

SCUtils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ void dumpQxContractToCSV(const char* input, const char* output)
3737
std::shared_ptr<QX> qxState = std::make_shared<QX>();
3838

3939
f = fopen(input, "rb");
40-
fread(qxState.get(), 1, sizeof(QX), f);
40+
if (fread(qxState.get(), 1, sizeof(QX), f) != sizeof(QX))
41+
{
42+
LOG("Failed to read QX state\n");
43+
fclose(f);
44+
return;
45+
}
4146
fclose(f);
4247

4348
f = fopen(output, "w");

0 commit comments

Comments
 (0)