Skip to content

Order book refactor (FungiblePayment) + big num proportion methods#2276

Merged
andrei-marinica merged 19 commits intomasterfrom
order-book-fungible
Feb 4, 2026
Merged

Order book refactor (FungiblePayment) + big num proportion methods#2276
andrei-marinica merged 19 commits intomasterfrom
order-book-fungible

Conversation

@andrei-marinica
Copy link
Contributor

@andrei-marinica andrei-marinica commented Jan 31, 2026

Pull request overview

Refactors the order-book example contract to use the framework’s FungiblePayment / NonZeroBigUint types and introduces proportion/into_proportion helpers for big number types, with added scenario tests for these new helpers.

Changes:

  • Added proportion / into_proportion APIs on BigInt, BigUint.
  • Attempted adding it to NonZeroBigUint as well, but it is not helpful, since there are no clean mathematical mechanisms of preserving the non-zero invariant. Ultimately dropped.
  • Refactored the order-book example to use FungiblePayment and NonZeroBigUint amounts.
  • Added/expanded scenario tests for proportion behavior (including NonZeroBigUint panic behavior).

@github-actions
Copy link

github-actions bot commented Jan 31, 2026

Contract comparison - from dcf00bb to ebb1f7c

Path                                                                                             size                  has-allocator                     has-format
fractional-nfts.wasm 8302 false without message
multisig-view.wasm 5590 false None
multisig-full.wasm 15111 false without message
multisig.wasm 13606 false without message
nft-minter.wasm 9726 false without message
ping-pong-egld.wasm 6397 false None
factorial.wasm 579 false None
nft-subscription.wasm 8725 false without message
kitty-auction.wasm 9394 false without message
kitty-genetic-alg.wasm 3494 false without message
kitty-ownership.wasm 12953 false without message
nft-storage-prepay.wasm 2609 false None
crypto-bubbles.wasm 2561 false None
esdt-transfer-with-fee.wasm 7505 false without message
seed-nft-minter.wasm 14189 false without message
adder.wasm 699 false None
bonding-curve-contract.wasm 14011 false None
proxy-pause.wasm 4165 false None
empty.wasm 244 false None
crowdfunding.wasm 3574 false None
digital-cash.wasm 9730 false None
token-release.wasm 6948 false without message
lottery-esdt.wasm 10580 false without message
rewards-distribution.wasm 9449 false without message
check-pause.wasm 1240 false None
order-book-factory.wasm 3401 false None
order-book-pair.wasm 13848 ➡️ 14098 🔴 (+250) false without message ➡️ None
crypto-zombies.wasm 9276 false without message
set-repeat.wasm 6511 false None
single-value-repeat.wasm 4253 false None
map-repeat.wasm 7363 false without message
queue-repeat.wasm 5536 false None
linked-list-repeat.wasm 6838 false without message
vec-repeat.wasm 4872 false None
str-repeat-mb-builder-cached.wasm 1109 false without message
str-repeat-mb-builder-basic.wasm 757 false None
str-repeat.wasm 2733 false without message
large-storage.wasm 1656 false None
send-tx-repeat.wasm 1292 false None
abi-tester.wasm 8607 true without message
abi-tester-ev.wasm 760 false None
exchange-features.wasm 1514 false None
use-module.wasm 32360 false without message
use-module-view.wasm 736 false None
panic-message-features.wasm 12838 false with message
panic-message-std.wasm 15886 false with message
big-float-features.wasm 6373 false without message
scenario-tester.wasm 1374 false None
forbidden-opcodes.wasm 842 false None
basic-features.wasm 85420 false without message
basic-features-storage-bytes.wasm 541 false None
payable-features.wasm 6046 false None
std-contract.wasm 3469 true without message
forwarder-queue.wasm 12712 false without message
forwarder-queue-promises.wasm 13336 false without message
forwarder-raw.wasm 13081 false None
forwarder-raw-init-sync-call.wasm 2958 false None
forwarder-raw-init-async-call.wasm 2374 false None
forwarder-legacy.wasm 33262 false without message
recursive-caller.wasm 5163 false without message
second-contract.wasm 1158 false None
first-contract.wasm 3450 false None
proxy-test-first.wasm 5711 false without message
transfer-role-features.wasm 8605 false without message
vault.wasm 8857 false None
vault-upgrade.wasm 708 false None
forwarder.wasm 48793 false without message
proxy-test-second.wasm 2327 false without message
local-esdt-and-nft.wasm 12254 false without message
parent.wasm 1999 false None
child.wasm 3982 false without message
builtin-func-features.wasm 3828 false None
rust-snippets-generator-test.wasm 4708 false None
rust-testing-framework-tester.wasm 8584 false None
multi-contract-features-view.wasm 1113 false None
multi-contract-features.wasm 681 false None
multi-contract-alt-impl.wasm 353 false None
multi-contract-example-feature.wasm 680 false None
alloc-mem-leaking.wasm 23325 false without message
alloc-features.wasm 23168 false without message
alloc-mem-fail.wasm 17720 true without message
erc1155-user-mock.wasm 1229 false None
erc721.wasm 2232 false None
crowdfunding-erc20.wasm 4909 false without message
lottery-erc20.wasm 12886 false without message
erc1155.wasm 11969 false without message
erc1155-marketplace.wasm 10603 false without message
erc20.wasm 1887 false None
esdt-system-sc-mock.wasm 4199 false None
formatted-message-features.wasm 3613 false without message
multiversx-price-aggregator-sc.wasm 17896 false without message
multiversx-wegld-swap-sc.wasm 4304 false None

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the order-book example contract to use the framework’s FungiblePayment / NonZeroBigUint types and introduces proportion/into_proportion helpers for big number types, with added scenario tests for these new helpers.

Changes:

  • Added proportion / into_proportion APIs on BigInt, BigUint, and NonZeroBigUint.
  • Refactored the order-book example to use FungiblePayment and NonZeroBigUint amounts.
  • Added/expanded scenario tests for proportion behavior (including NonZeroBigUint panic behavior).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
framework/scenario/tests/non_zero_big_uint_test.rs Adds tests for NonZeroBigUint proportion behavior and panic on zero result.
framework/scenario/tests/big_uint_test.rs Adds BigUint proportion tests alongside existing ln tests.
framework/scenario/tests/big_int_test.rs Adds BigInt proportion tests.
framework/base/src/types/managed/wrapped/num/non_zero_big_uint_operators.rs Exposes an internal helper (wrap_big_int_assert_gt_zero) for use by new APIs.
framework/base/src/types/managed/wrapped/num/non_zero_big_uint.rs Adds NonZeroBigUint::{proportion, into_proportion} with rustdoc.
framework/base/src/types/managed/wrapped/num/big_uint.rs Adds BigUint::{proportion, into_proportion} and new_unchecked, with rustdoc.
framework/base/src/types/managed/basic/big_int.rs Makes overwrite_i64 mutable and adds BigInt::{proportion, into_proportion}.
contracts/feature-tests/basic-features/src/big_num_methods.rs Updates endpoint to pass BigInt as mutable due to signature change.
contracts/examples/order-book/pair/src/validation.rs Switches to FungiblePayment/NonZeroBigUint and updates fee/payment validation logic.
contracts/examples/order-book/pair/src/orders.rs Refactors order processing to use new payment/amount types and new proportion helpers.
contracts/examples/order-book/pair/src/common.rs Replaces custom payment struct with FungiblePayment and makes order amounts non-zero.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@andrei-marinica andrei-marinica marked this pull request as ready for review February 2, 2026 13:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@andrei-marinica andrei-marinica merged commit d8f980b into master Feb 4, 2026
23 checks passed
@andrei-marinica andrei-marinica deleted the order-book-fungible branch February 4, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants