@layerzerolabs/protocol-starknet-v2 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +186 -0
- package/.turbo/turbo-lint.log +71 -0
- package/.turbo/turbo-test.log +937 -0
- package/README.md +41 -0
- package/Scarb.lock +211 -0
- package/Scarb.toml +2 -0
- package/dist/4XD3ZRZ4.cjs +301 -0
- package/dist/4XD3ZRZ4.cjs.map +1 -0
- package/dist/4Z5IPBC3.js +299 -0
- package/dist/4Z5IPBC3.js.map +1 -0
- package/dist/5NEZDLVQ.cjs +474 -0
- package/dist/5NEZDLVQ.cjs.map +1 -0
- package/dist/6JYCOKDE.js +472 -0
- package/dist/6JYCOKDE.js.map +1 -0
- package/dist/7C4PFMIZ.cjs +1288 -0
- package/dist/7C4PFMIZ.cjs.map +1 -0
- package/dist/7ZSGGZUE.js +1229 -0
- package/dist/7ZSGGZUE.js.map +1 -0
- package/dist/ARHOGUYH.cjs +2136 -0
- package/dist/ARHOGUYH.cjs.map +1 -0
- package/dist/CRCRIUFX.js +1264 -0
- package/dist/CRCRIUFX.js.map +1 -0
- package/dist/DB7CQSED.cjs +430 -0
- package/dist/DB7CQSED.cjs.map +1 -0
- package/dist/DFXLWHYP.cjs +1266 -0
- package/dist/DFXLWHYP.cjs.map +1 -0
- package/dist/EOLZCMCK.js +988 -0
- package/dist/EOLZCMCK.js.map +1 -0
- package/dist/FFDPTOWG.cjs +331 -0
- package/dist/FFDPTOWG.cjs.map +1 -0
- package/dist/FOJGEAIO.js +2134 -0
- package/dist/FOJGEAIO.js.map +1 -0
- package/dist/IWIUMVGB.js +629 -0
- package/dist/IWIUMVGB.js.map +1 -0
- package/dist/MUEN6AWV.cjs +697 -0
- package/dist/MUEN6AWV.cjs.map +1 -0
- package/dist/ORE6VBZ4.cjs +990 -0
- package/dist/ORE6VBZ4.cjs.map +1 -0
- package/dist/OUFKWPZ7.js +732 -0
- package/dist/OUFKWPZ7.js.map +1 -0
- package/dist/T2QTYQXJ.js +1229 -0
- package/dist/T2QTYQXJ.js.map +1 -0
- package/dist/UPJTM7BR.cjs +631 -0
- package/dist/UPJTM7BR.cjs.map +1 -0
- package/dist/VNVNX2P3.cjs +1231 -0
- package/dist/VNVNX2P3.cjs.map +1 -0
- package/dist/VUOMXK5T.js +6 -0
- package/dist/VUOMXK5T.js.map +1 -0
- package/dist/WISWRTDG.js +1286 -0
- package/dist/WISWRTDG.js.map +1 -0
- package/dist/WU5L7YIQ.cjs +1231 -0
- package/dist/WU5L7YIQ.cjs.map +1 -0
- package/dist/X3B5JDMZ.js +695 -0
- package/dist/X3B5JDMZ.js.map +1 -0
- package/dist/XYNBDBBV.cjs +297 -0
- package/dist/XYNBDBBV.cjs.map +1 -0
- package/dist/Y5JFPCYJ.cjs +734 -0
- package/dist/Y5JFPCYJ.cjs.map +1 -0
- package/dist/YEHL7IYO.js +295 -0
- package/dist/YEHL7IYO.js.map +1 -0
- package/dist/YJF4D23A.cjs +8 -0
- package/dist/YJF4D23A.cjs.map +1 -0
- package/dist/YTS44OEA.js +428 -0
- package/dist/YTS44OEA.js.map +1 -0
- package/dist/Z2NIUZMW.js +329 -0
- package/dist/Z2NIUZMW.js.map +1 -0
- package/dist/abis/blocked-message-lib.cjs +13 -0
- package/dist/abis/blocked-message-lib.cjs.map +1 -0
- package/dist/abis/blocked-message-lib.d.ts +338 -0
- package/dist/abis/blocked-message-lib.d.ts.map +1 -0
- package/dist/abis/blocked-message-lib.js +4 -0
- package/dist/abis/blocked-message-lib.js.map +1 -0
- package/dist/abis/dvn-fee-lib.cjs +13 -0
- package/dist/abis/dvn-fee-lib.cjs.map +1 -0
- package/dist/abis/dvn-fee-lib.d.ts +214 -0
- package/dist/abis/dvn-fee-lib.d.ts.map +1 -0
- package/dist/abis/dvn-fee-lib.js +4 -0
- package/dist/abis/dvn-fee-lib.js.map +1 -0
- package/dist/abis/dvn.cjs +13 -0
- package/dist/abis/dvn.cjs.map +1 -0
- package/dist/abis/dvn.d.ts +952 -0
- package/dist/abis/dvn.d.ts.map +1 -0
- package/dist/abis/dvn.js +4 -0
- package/dist/abis/dvn.js.map +1 -0
- package/dist/abis/endpoint-v2.cjs +13 -0
- package/dist/abis/endpoint-v2.cjs.map +1 -0
- package/dist/abis/endpoint-v2.d.ts +1580 -0
- package/dist/abis/endpoint-v2.d.ts.map +1 -0
- package/dist/abis/endpoint-v2.js +4 -0
- package/dist/abis/endpoint-v2.js.map +1 -0
- package/dist/abis/executor-fee-lib.cjs +13 -0
- package/dist/abis/executor-fee-lib.cjs.map +1 -0
- package/dist/abis/executor-fee-lib.d.ts +217 -0
- package/dist/abis/executor-fee-lib.d.ts.map +1 -0
- package/dist/abis/executor-fee-lib.js +4 -0
- package/dist/abis/executor-fee-lib.js.map +1 -0
- package/dist/abis/executor.cjs +13 -0
- package/dist/abis/executor.cjs.map +1 -0
- package/dist/abis/executor.d.ts +914 -0
- package/dist/abis/executor.d.ts.map +1 -0
- package/dist/abis/executor.js +4 -0
- package/dist/abis/executor.js.map +1 -0
- package/dist/abis/o-app.cjs +13 -0
- package/dist/abis/o-app.cjs.map +1 -0
- package/dist/abis/o-app.d.ts +311 -0
- package/dist/abis/o-app.d.ts.map +1 -0
- package/dist/abis/o-app.js +4 -0
- package/dist/abis/o-app.js.map +1 -0
- package/dist/abis/oft-adapter.cjs +13 -0
- package/dist/abis/oft-adapter.cjs.map +1 -0
- package/dist/abis/oft-adapter.d.ts +722 -0
- package/dist/abis/oft-adapter.d.ts.map +1 -0
- package/dist/abis/oft-adapter.js +4 -0
- package/dist/abis/oft-adapter.js.map +1 -0
- package/dist/abis/oft.cjs +13 -0
- package/dist/abis/oft.cjs.map +1 -0
- package/dist/abis/oft.d.ts +922 -0
- package/dist/abis/oft.d.ts.map +1 -0
- package/dist/abis/oft.js +4 -0
- package/dist/abis/oft.js.map +1 -0
- package/dist/abis/omni-counter.cjs +13 -0
- package/dist/abis/omni-counter.cjs.map +1 -0
- package/dist/abis/omni-counter.d.ts +459 -0
- package/dist/abis/omni-counter.d.ts.map +1 -0
- package/dist/abis/omni-counter.js +4 -0
- package/dist/abis/omni-counter.js.map +1 -0
- package/dist/abis/price-feed.cjs +13 -0
- package/dist/abis/price-feed.cjs.map +1 -0
- package/dist/abis/price-feed.d.ts +505 -0
- package/dist/abis/price-feed.d.ts.map +1 -0
- package/dist/abis/price-feed.js +4 -0
- package/dist/abis/price-feed.js.map +1 -0
- package/dist/abis/simple-message-lib.cjs +13 -0
- package/dist/abis/simple-message-lib.cjs.map +1 -0
- package/dist/abis/simple-message-lib.d.ts +535 -0
- package/dist/abis/simple-message-lib.d.ts.map +1 -0
- package/dist/abis/simple-message-lib.js +4 -0
- package/dist/abis/simple-message-lib.js.map +1 -0
- package/dist/abis/treasury.cjs +13 -0
- package/dist/abis/treasury.cjs.map +1 -0
- package/dist/abis/treasury.d.ts +240 -0
- package/dist/abis/treasury.d.ts.map +1 -0
- package/dist/abis/treasury.js +4 -0
- package/dist/abis/treasury.js.map +1 -0
- package/dist/abis/ultra-light-node.cjs +13 -0
- package/dist/abis/ultra-light-node.cjs.map +1 -0
- package/dist/abis/ultra-light-node.d.ts +900 -0
- package/dist/abis/ultra-light-node.d.ts.map +1 -0
- package/dist/abis/ultra-light-node.js +4 -0
- package/dist/abis/ultra-light-node.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/build-abi.cjs +28 -0
- package/dist/scripts/build-abi.cjs.map +1 -0
- package/dist/scripts/build-abi.d.ts +2 -0
- package/dist/scripts/build-abi.d.ts.map +1 -0
- package/dist/scripts/build-abi.js +26 -0
- package/dist/scripts/build-abi.js.map +1 -0
- package/layerzero/README.md +244 -0
- package/layerzero/Scarb.lock +203 -0
- package/layerzero/Scarb.toml +30 -0
- package/layerzero/snfoundry.toml +11 -0
- package/layerzero/src/common/constants.cairo +26 -0
- package/layerzero/src/common/conversions.cairo +16 -0
- package/layerzero/src/common/guid.cairo +20 -0
- package/layerzero/src/common/packet_v1_codec.cairo +307 -0
- package/layerzero/src/common/structs/messaging.cairo +40 -0
- package/layerzero/src/common/structs/packet.cairo +31 -0
- package/layerzero/src/endpoint/constants.cairo +14 -0
- package/layerzero/src/endpoint/endpoint.cairo +688 -0
- package/layerzero/src/endpoint/errors.cairo +108 -0
- package/layerzero/src/endpoint/events.cairo +124 -0
- package/layerzero/src/endpoint/interfaces/endpoint.cairo +286 -0
- package/layerzero/src/endpoint/interfaces/layerzero_composer.cairo +62 -0
- package/layerzero/src/endpoint/interfaces/layerzero_receiver.cairo +63 -0
- package/layerzero/src/endpoint/message_lib_manager/errors.cairo +95 -0
- package/layerzero/src/endpoint/message_lib_manager/events.cairo +90 -0
- package/layerzero/src/endpoint/message_lib_manager/interface.cairo +449 -0
- package/layerzero/src/endpoint/message_lib_manager/message_lib_manager.cairo +720 -0
- package/layerzero/src/endpoint/message_lib_manager/structs.cairo +33 -0
- package/layerzero/src/endpoint/messaging_channel/errors.cairo +37 -0
- package/layerzero/src/endpoint/messaging_channel/events.cairo +58 -0
- package/layerzero/src/endpoint/messaging_channel/interface.cairo +171 -0
- package/layerzero/src/endpoint/messaging_channel/messaging_channel.cairo +453 -0
- package/layerzero/src/endpoint/messaging_composer/errors.cairo +46 -0
- package/layerzero/src/endpoint/messaging_composer/events.cairo +67 -0
- package/layerzero/src/endpoint/messaging_composer/interface.cairo +132 -0
- package/layerzero/src/endpoint/messaging_composer/messaging_composer.cairo +223 -0
- package/layerzero/src/lib.cairo +189 -0
- package/layerzero/src/message_lib/blocked_message_lib.cairo +114 -0
- package/layerzero/src/message_lib/interface.cairo +63 -0
- package/layerzero/src/message_lib/sml/errors.cairo +23 -0
- package/layerzero/src/message_lib/sml/events.cairo +32 -0
- package/layerzero/src/message_lib/sml/simple_message_lib.cairo +312 -0
- package/layerzero/src/message_lib/structs.cairo +22 -0
- package/layerzero/src/message_lib/uln/errors.cairo +128 -0
- package/layerzero/src/message_lib/uln/events.cairo +97 -0
- package/layerzero/src/message_lib/uln/interface.cairo +83 -0
- package/layerzero/src/message_lib/uln/options.cairo +64 -0
- package/layerzero/src/message_lib/uln/structs/executor_config.cairo +35 -0
- package/layerzero/src/message_lib/uln/structs/payment_info.cairo +7 -0
- package/layerzero/src/message_lib/uln/structs/uln_config.cairo +155 -0
- package/layerzero/src/message_lib/uln/structs/uln_config_storage_node.cairo +91 -0
- package/layerzero/src/message_lib/uln/structs/verification.cairo +7 -0
- package/layerzero/src/message_lib/uln/ultra_light_node.cairo +965 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/errors.cairo +22 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/events.cairo +6 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/interface.cairo +34 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/oapp_options_type_3.cairo +120 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/structs.cairo +6 -0
- package/layerzero/src/oapps/counter/constants.cairo +3 -0
- package/layerzero/src/oapps/counter/counter.cairo +170 -0
- package/layerzero/src/oapps/counter/interface.cairo +27 -0
- package/layerzero/src/oapps/counter/structs.cairo +20 -0
- package/layerzero/src/oapps/message_inspector/interface.cairo +21 -0
- package/layerzero/src/oapps/oapp/errors.cairo +72 -0
- package/layerzero/src/oapps/oapp/events.cairo +9 -0
- package/layerzero/src/oapps/oapp/interface.cairo +67 -0
- package/layerzero/src/oapps/oapp/oapp.cairo +70 -0
- package/layerzero/src/oapps/oapp/oapp_core.cairo +448 -0
- package/layerzero/src/oapps/oft/errors.cairo +42 -0
- package/layerzero/src/oapps/oft/events.cairo +33 -0
- package/layerzero/src/oapps/oft/interface.cairo +87 -0
- package/layerzero/src/oapps/oft/oft.cairo +188 -0
- package/layerzero/src/oapps/oft/oft_adapter.cairo +175 -0
- package/layerzero/src/oapps/oft/oft_compose_msg_codec.cairo +128 -0
- package/layerzero/src/oapps/oft/oft_core.cairo +542 -0
- package/layerzero/src/oapps/oft/oft_msg_codec.cairo +131 -0
- package/layerzero/src/oapps/oft/structs.cairo +72 -0
- package/layerzero/src/treasury/errors.cairo +22 -0
- package/layerzero/src/treasury/events.cairo +5 -0
- package/layerzero/src/treasury/interfaces/layerzero_treasury.cairo +54 -0
- package/layerzero/src/treasury/interfaces/lz_token_fee_lib.cairo +45 -0
- package/layerzero/src/treasury/interfaces/treasury_admin.cairo +39 -0
- package/layerzero/src/treasury/treasury.cairo +140 -0
- package/layerzero/src/workers/access_control.cairo +11 -0
- package/layerzero/src/workers/base/base.cairo +238 -0
- package/layerzero/src/workers/base/errors.cairo +24 -0
- package/layerzero/src/workers/base/events.cairo +43 -0
- package/layerzero/src/workers/base/interface.cairo +93 -0
- package/layerzero/src/workers/base/structs.cairo +10 -0
- package/layerzero/src/workers/common.cairo +59 -0
- package/layerzero/src/workers/dvn/constants.cairo +11 -0
- package/layerzero/src/workers/dvn/dvn.cairo +338 -0
- package/layerzero/src/workers/dvn/errors.cairo +80 -0
- package/layerzero/src/workers/dvn/events.cairo +30 -0
- package/layerzero/src/workers/dvn/fee_lib/dvn_fee_lib.cairo +152 -0
- package/layerzero/src/workers/dvn/fee_lib/interface.cairo +45 -0
- package/layerzero/src/workers/dvn/interface.cairo +131 -0
- package/layerzero/src/workers/dvn/options.cairo +125 -0
- package/layerzero/src/workers/dvn/structs.cairo +51 -0
- package/layerzero/src/workers/executor/errors.cairo +159 -0
- package/layerzero/src/workers/executor/events.cairo +32 -0
- package/layerzero/src/workers/executor/executor.cairo +392 -0
- package/layerzero/src/workers/executor/fee_lib/executor_fee_lib.cairo +160 -0
- package/layerzero/src/workers/executor/fee_lib/interface.cairo +87 -0
- package/layerzero/src/workers/executor/interface.cairo +131 -0
- package/layerzero/src/workers/executor/options.cairo +244 -0
- package/layerzero/src/workers/executor/structs.cairo +119 -0
- package/layerzero/src/workers/interface.cairo +32 -0
- package/layerzero/src/workers/price_feed/constants.cairo +7 -0
- package/layerzero/src/workers/price_feed/errors.cairo +28 -0
- package/layerzero/src/workers/price_feed/events.cairo +13 -0
- package/layerzero/src/workers/price_feed/interface.cairo +264 -0
- package/layerzero/src/workers/price_feed/price_feed.cairo +392 -0
- package/layerzero/src/workers/price_feed/structs.cairo +74 -0
- package/layerzero/tests/common/test_constants.cairo +21 -0
- package/layerzero/tests/common/test_guid.cairo +232 -0
- package/layerzero/tests/common/test_packet_v1_codec.cairo +372 -0
- package/layerzero/tests/common/utils.cairo +23 -0
- package/layerzero/tests/e2e/oft_utils.cairo +121 -0
- package/layerzero/tests/e2e/test_counter_with_sml.cairo +194 -0
- package/layerzero/tests/e2e/test_counter_with_uln.cairo +352 -0
- package/layerzero/tests/e2e/test_dvn.cairo +406 -0
- package/layerzero/tests/e2e/test_lz_token.cairo +354 -0
- package/layerzero/tests/e2e/test_oft_compose_with_uln.cairo +364 -0
- package/layerzero/tests/e2e/test_oft_with_sml.cairo +240 -0
- package/layerzero/tests/e2e/test_oft_with_uln.cairo +299 -0
- package/layerzero/tests/e2e/utils.cairo +490 -0
- package/layerzero/tests/endpoint/message_lib_manager/test_message_lib_manager.cairo +2051 -0
- package/layerzero/tests/endpoint/message_lib_manager/utils.cairo +45 -0
- package/layerzero/tests/endpoint/messaging_channel/test_messaging_channel.cairo +621 -0
- package/layerzero/tests/endpoint/messaging_channel/utils.cairo +96 -0
- package/layerzero/tests/endpoint/messaging_composer/test_messaging_composer.cairo +456 -0
- package/layerzero/tests/endpoint/messaging_composer/utils.cairo +75 -0
- package/layerzero/tests/endpoint/test_endpoint_commit.cairo +763 -0
- package/layerzero/tests/endpoint/test_endpoint_lzreceive.cairo +1253 -0
- package/layerzero/tests/endpoint/test_endpoint_quote.cairo +71 -0
- package/layerzero/tests/endpoint/test_endpoint_send.cairo +1327 -0
- package/layerzero/tests/endpoint/utils.cairo +129 -0
- package/layerzero/tests/fuzzable/blockchain_config.cairo +89 -0
- package/layerzero/tests/fuzzable/bytes32.cairo +16 -0
- package/layerzero/tests/fuzzable/contract_address.cairo +67 -0
- package/layerzero/tests/fuzzable/dst_config.cairo +37 -0
- package/layerzero/tests/fuzzable/eid.cairo +23 -0
- package/layerzero/tests/fuzzable/eth_address.cairo +17 -0
- package/layerzero/tests/fuzzable/expiry.cairo +27 -0
- package/layerzero/tests/fuzzable/felt_array.cairo +38 -0
- package/layerzero/tests/fuzzable/inbound_params.cairo +21 -0
- package/layerzero/tests/fuzzable/keys.cairo +16 -0
- package/layerzero/tests/fuzzable/model_type.cairo +27 -0
- package/layerzero/tests/fuzzable/origin.cairo +21 -0
- package/layerzero/tests/fuzzable/price.cairo +32 -0
- package/layerzero/tests/fuzzable/role_admin.cairo +29 -0
- package/layerzero/tests/fuzzable/small_byte_array.cairo +61 -0
- package/layerzero/tests/lib.cairo +177 -0
- package/layerzero/tests/message_lib/sml/test_simple_message_lib.cairo +224 -0
- package/layerzero/tests/message_lib/uln/test_uln_admin.cairo +2150 -0
- package/layerzero/tests/message_lib/uln/test_uln_config.cairo +527 -0
- package/layerzero/tests/message_lib/uln/test_uln_config_storage_node.cairo +69 -0
- package/layerzero/tests/message_lib/uln/test_uln_executor_config.cairo +173 -0
- package/layerzero/tests/message_lib/uln/test_uln_options.cairo +329 -0
- package/layerzero/tests/message_lib/uln/test_uln_quote.cairo +1038 -0
- package/layerzero/tests/message_lib/uln/test_uln_receive.cairo +715 -0
- package/layerzero/tests/message_lib/uln/test_uln_send.cairo +1155 -0
- package/layerzero/tests/message_lib/uln/utils.cairo +59 -0
- package/layerzero/tests/mocks/composer_target.cairo +76 -0
- package/layerzero/tests/mocks/endpoint.cairo +199 -0
- package/layerzero/tests/mocks/erc20/erc20.cairo +50 -0
- package/layerzero/tests/mocks/erc20/interface.cairo +8 -0
- package/layerzero/tests/mocks/message_inspector/message_inspector.cairo +17 -0
- package/layerzero/tests/mocks/message_lib_manager.cairo +98 -0
- package/layerzero/tests/mocks/messaging_channel/interface.cairo +23 -0
- package/layerzero/tests/mocks/messaging_channel/messaging_channel.cairo +138 -0
- package/layerzero/tests/mocks/messaging_composer.cairo +171 -0
- package/layerzero/tests/mocks/oapp_core/interface.cairo +53 -0
- package/layerzero/tests/mocks/oapp_core/oapp_core.cairo +142 -0
- package/layerzero/tests/mocks/oapp_options_type3.cairo +42 -0
- package/layerzero/tests/mocks/oft_core/interface.cairo +28 -0
- package/layerzero/tests/mocks/oft_core/oft_core.cairo +242 -0
- package/layerzero/tests/mocks/receiver.cairo +54 -0
- package/layerzero/tests/mocks/treasury/lz_token_fee_lib.cairo +57 -0
- package/layerzero/tests/mocks/treasury/treasury.cairo +74 -0
- package/layerzero/tests/mocks/uln_config/interface.cairo +12 -0
- package/layerzero/tests/mocks/uln_config/uln_config.cairo +35 -0
- package/layerzero/tests/mocks/workers/base.cairo +80 -0
- package/layerzero/tests/mocks/workers/dvn.cairo +115 -0
- package/layerzero/tests/mocks/workers/executor/decode/decode.cairo +97 -0
- package/layerzero/tests/mocks/workers/executor/decode/interface.cairo +59 -0
- package/layerzero/tests/mocks/workers/executor/executor.cairo +176 -0
- package/layerzero/tests/oapps/common/test_oapp_options_type_3.cairo +279 -0
- package/layerzero/tests/oapps/oft/test_oft_adapter.cairo +441 -0
- package/layerzero/tests/oapps/oft/test_oft_compose_msg_codec.cairo +139 -0
- package/layerzero/tests/oapps/oft/test_oft_core.cairo +751 -0
- package/layerzero/tests/oapps/oft/test_oft_msg_codec.cairo +268 -0
- package/layerzero/tests/oapps/test_counter.cairo +470 -0
- package/layerzero/tests/oapps/test_oapp_core.cairo +750 -0
- package/layerzero/tests/treasury/test_lz_token_fee_lib.cairo +63 -0
- package/layerzero/tests/treasury/test_treasury.cairo +458 -0
- package/layerzero/tests/treasury/utils.cairo +8 -0
- package/layerzero/tests/utils.cairo +48 -0
- package/layerzero/tests/workers/base/test_worker_base.cairo +1097 -0
- package/layerzero/tests/workers/base/utils.cairo +76 -0
- package/layerzero/tests/workers/dvn/fee_lib/test_dvn_fee_lib.cairo +361 -0
- package/layerzero/tests/workers/dvn/test_dvn.cairo +1101 -0
- package/layerzero/tests/workers/dvn/test_dvn_options.cairo +312 -0
- package/layerzero/tests/workers/dvn/utils.cairo +236 -0
- package/layerzero/tests/workers/executor/fee_lib/test_executor_fee_lib.cairo +223 -0
- package/layerzero/tests/workers/executor/test_decode.cairo +612 -0
- package/layerzero/tests/workers/executor/test_executor.cairo +1472 -0
- package/layerzero/tests/workers/executor/utils.cairo +296 -0
- package/layerzero/tests/workers/price_feed/test_price_feed.cairo +879 -0
- package/layerzero/tests/workers/price_feed/utils.cairo +37 -0
- package/libs/enumerable_set/Scarb.lock +24 -0
- package/libs/enumerable_set/Scarb.toml +17 -0
- package/libs/enumerable_set/src/enumerable_set.cairo +118 -0
- package/libs/enumerable_set/src/lib.cairo +4 -0
- package/libs/enumerable_set/tests/lib.cairo +5 -0
- package/libs/enumerable_set/tests/mocks/mock_enumerable_set.cairo +61 -0
- package/libs/enumerable_set/tests/test_enumerable_set.cairo +379 -0
- package/libs/lz_utils/Scarb.lock +24 -0
- package/libs/lz_utils/Scarb.toml +17 -0
- package/libs/lz_utils/src/bytes.cairo +33 -0
- package/libs/lz_utils/src/error.cairo +12 -0
- package/libs/lz_utils/src/keccak.cairo +28 -0
- package/libs/lz_utils/src/lib.cairo +3 -0
- package/libs/multisig/Scarb.lock +172 -0
- package/libs/multisig/Scarb.toml +23 -0
- package/libs/multisig/src/errors.cairo +84 -0
- package/libs/multisig/src/events.cairo +13 -0
- package/libs/multisig/src/interface.cairo +73 -0
- package/libs/multisig/src/lib.cairo +7 -0
- package/libs/multisig/src/multisig.cairo +241 -0
- package/libs/multisig/tests/lib.cairo +4 -0
- package/libs/multisig/tests/mocks/mock_multisig.cairo +57 -0
- package/libs/multisig/tests/test_multisig.cairo +452 -0
- package/package.json +41 -0
- package/src/scripts/build-abi.ts +51 -0
- package/target/CACHEDIR.TAG +3 -0
- package/target/dev/.fingerprint/alexandria_bytes-5ea6u5t70d7qi/alexandria_bytes +1 -0
- package/target/dev/.fingerprint/alexandria_data_structures-0aue3g6q80gs0/alexandria_data_structures +1 -0
- package/target/dev/.fingerprint/alexandria_math-h2fi7jdq4isuu/alexandria_math +1 -0
- package/target/dev/.fingerprint/core-lq3u730l5p1ag/core +1 -0
- package/target/dev/.fingerprint/core-vf7fc6rvic5vi/core +1 -0
- package/target/dev/.fingerprint/enumerable_set-eaerkg8njl85o/enumerable_set +1 -0
- package/target/dev/.fingerprint/enumerable_set-r54oje7t06ku8/enumerable_set +1 -0
- package/target/dev/.fingerprint/layerzero-oqgdqsaddpi2k/layerzero +1 -0
- package/target/dev/.fingerprint/lz_utils-kfkkeueiqg0pa/lz_utils +1 -0
- package/target/dev/.fingerprint/lz_utils-u4v1os6e7gkng/lz_utils +1 -0
- package/target/dev/.fingerprint/multisig-0fjetugejecge/multisig +1 -0
- package/target/dev/.fingerprint/multisig-6j5kqs436hm54/multisig +1 -0
- package/target/dev/.fingerprint/openzeppelin-ei1id1hu088lo/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin-j9d5nd1qhfnu6/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-3oa41aikpaek0/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-p5h849v8so76q/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-4qhv5fks84g9u/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-hgbm8ln9ah7rm/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-n70q9al0cps8i/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-nnd4f8703t3ak/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-3gnk21ubp5lis/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-rj1bfont4fij4/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-3fja9hd1gvbcq/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-jc3nf5525eet6/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4en77ogr2r2l2/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4t190frqs4db8/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-aqb0f6p9c0bp6/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-nseg8korhin8e/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-g7p73ji1ih1qg/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-qp5328v80452u/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-jjf7tl9rphc6k/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-r6s43vlpj6rqk/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-0dpbnre7engca/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-2sqgvbuv9s800/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-mj395ivff1ffo/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-oh1hse8sjumgm/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-1qnnjnq0pf9u0/starkware_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-mh8e3te65lju4/starkware_utils +1 -0
- package/target/dev/enumerable_set.sierra.json +1 -0
- package/target/dev/incremental/alexandria_bytes-5ea6u5t70d7qi.bin +0 -0
- package/target/dev/incremental/alexandria_data_structures-0aue3g6q80gs0.bin +0 -0
- package/target/dev/incremental/alexandria_math-h2fi7jdq4isuu.bin +0 -0
- package/target/dev/incremental/core-lq3u730l5p1ag.bin +0 -0
- package/target/dev/incremental/core-vf7fc6rvic5vi.bin +0 -0
- package/target/dev/incremental/enumerable_set-eaerkg8njl85o.bin +0 -0
- package/target/dev/incremental/enumerable_set-r54oje7t06ku8.bin +0 -0
- package/target/dev/incremental/layerzero-oqgdqsaddpi2k.bin +0 -0
- package/target/dev/incremental/lz_utils-kfkkeueiqg0pa.bin +0 -0
- package/target/dev/incremental/lz_utils-u4v1os6e7gkng.bin +0 -0
- package/target/dev/incremental/multisig-0fjetugejecge.bin +0 -0
- package/target/dev/incremental/multisig-6j5kqs436hm54.bin +0 -0
- package/target/dev/incremental/openzeppelin-ei1id1hu088lo.bin +0 -0
- package/target/dev/incremental/openzeppelin-j9d5nd1qhfnu6.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-3oa41aikpaek0.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-p5h849v8so76q.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-4qhv5fks84g9u.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-hgbm8ln9ah7rm.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-n70q9al0cps8i.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-nnd4f8703t3ak.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-3gnk21ubp5lis.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-rj1bfont4fij4.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-3fja9hd1gvbcq.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-jc3nf5525eet6.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4en77ogr2r2l2.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4t190frqs4db8.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-aqb0f6p9c0bp6.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-nseg8korhin8e.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-g7p73ji1ih1qg.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-qp5328v80452u.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-jjf7tl9rphc6k.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-r6s43vlpj6rqk.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-0dpbnre7engca.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-2sqgvbuv9s800.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-mj395ivff1ffo.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-oh1hse8sjumgm.bin +0 -0
- package/target/dev/incremental/starkware_utils-1qnnjnq0pf9u0.bin +0 -0
- package/target/dev/incremental/starkware_utils-mh8e3te65lju4.bin +0 -0
- package/target/dev/layerzero.starknet_artifacts.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.contract_class.json +1 -0
- package/target/dev/layerzero_Executor.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Executor.contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_OApp.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OApp.contract_class.json +1 -0
- package/target/dev/layerzero_OFT.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFT.contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.contract_class.json +1 -0
- package/target/dev/lz_utils.sierra.json +1 -0
- package/target/dev/multisig.sierra.json +1 -0
- package/tools/update_contracts.sh +19 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +7 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//! LayerZero token fee library tests
|
|
2
|
+
|
|
3
|
+
use layerzero::treasury::interfaces::lz_token_fee_lib::{
|
|
4
|
+
ILzTokenFeeLibDispatcher, ILzTokenFeeLibDispatcherTrait,
|
|
5
|
+
};
|
|
6
|
+
use starknet::ContractAddress;
|
|
7
|
+
use crate::fuzzable::contract_address::{FuzzableContractAddress, FuzzableContractAddresses};
|
|
8
|
+
use crate::fuzzable::eid::{Eid, FuzzableEid};
|
|
9
|
+
use crate::mocks::treasury::lz_token_fee_lib::{
|
|
10
|
+
IMockLzTokenFeeLibAssertionDispatcher, IMockLzTokenFeeLibAssertionDispatcherTrait,
|
|
11
|
+
};
|
|
12
|
+
use crate::treasury::utils::deploy_mock_lz_token_fee_lib;
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
#[fuzzer(runs: 10)]
|
|
16
|
+
fn test_mock_constructor(fee: u256) {
|
|
17
|
+
deploy_mock_lz_token_fee_lib(fee);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#[test]
|
|
21
|
+
#[fuzzer(runs: 10)]
|
|
22
|
+
fn test_mock_get_fee(
|
|
23
|
+
owner: ContractAddress,
|
|
24
|
+
configured_fee: u256,
|
|
25
|
+
sender: ContractAddress,
|
|
26
|
+
dst_eid: Eid,
|
|
27
|
+
worker_fee: u256,
|
|
28
|
+
native_treasury_fee: u256,
|
|
29
|
+
) {
|
|
30
|
+
let library = deploy_mock_lz_token_fee_lib(configured_fee);
|
|
31
|
+
let dispatcher = ILzTokenFeeLibDispatcher { contract_address: library };
|
|
32
|
+
|
|
33
|
+
let fee = dispatcher.get_fee(sender, dst_eid.eid, worker_fee, native_treasury_fee);
|
|
34
|
+
|
|
35
|
+
assert(fee == configured_fee, 'Unexpected fee');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[test]
|
|
39
|
+
#[fuzzer(runs: 10)]
|
|
40
|
+
fn test_mock_pay_fee(
|
|
41
|
+
owner: ContractAddress,
|
|
42
|
+
configured_fee: u256,
|
|
43
|
+
sender: ContractAddress,
|
|
44
|
+
dst_eid: Eid,
|
|
45
|
+
worker_fee: u256,
|
|
46
|
+
native_treasury_fee: u256,
|
|
47
|
+
) {
|
|
48
|
+
let library = deploy_mock_lz_token_fee_lib(configured_fee);
|
|
49
|
+
let dispatcher = ILzTokenFeeLibDispatcher { contract_address: library };
|
|
50
|
+
let assertion = IMockLzTokenFeeLibAssertionDispatcher { contract_address: library };
|
|
51
|
+
|
|
52
|
+
assertion.assert_payment_count(0);
|
|
53
|
+
|
|
54
|
+
let fee = dispatcher.pay_fee(sender, dst_eid.eid, worker_fee, native_treasury_fee);
|
|
55
|
+
|
|
56
|
+
assert(fee == configured_fee, 'Unexpected fee');
|
|
57
|
+
assertion.assert_payment_count(1);
|
|
58
|
+
|
|
59
|
+
let fee = dispatcher.pay_fee(sender, dst_eid.eid, worker_fee, native_treasury_fee);
|
|
60
|
+
|
|
61
|
+
assert(fee == configured_fee, 'Unexpected fee');
|
|
62
|
+
assertion.assert_payment_count(2);
|
|
63
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
//! Treasury tests
|
|
2
|
+
|
|
3
|
+
use layerzero::common::constants::DEFAULT_BPS;
|
|
4
|
+
use layerzero::treasury::errors::err_lz_token_not_enabled;
|
|
5
|
+
use layerzero::treasury::events::BasisPointsUpdated;
|
|
6
|
+
use layerzero::treasury::interfaces::layerzero_treasury::{
|
|
7
|
+
ILayerZeroTreasurySafeDispatcher, ILayerZeroTreasurySafeDispatcherTrait,
|
|
8
|
+
};
|
|
9
|
+
use layerzero::treasury::interfaces::treasury_admin::{
|
|
10
|
+
ITreasuryAdminSafeDispatcher, ITreasuryAdminSafeDispatcherTrait,
|
|
11
|
+
};
|
|
12
|
+
use layerzero::treasury::treasury::Treasury;
|
|
13
|
+
use openzeppelin::access::ownable::interface::{IOwnableSafeDispatcher, IOwnableSafeDispatcherTrait};
|
|
14
|
+
use openzeppelin::token::erc20::ERC20Component::{Event as ERC20Event, Transfer};
|
|
15
|
+
use openzeppelin::token::erc20::interface::{IERC20SafeDispatcher, IERC20SafeDispatcherTrait};
|
|
16
|
+
use snforge_std::{
|
|
17
|
+
ContractClassTrait, DeclareResultTrait, EventSpyAssertionsTrait, declare, spy_events,
|
|
18
|
+
start_cheat_caller_address, stop_cheat_caller_address,
|
|
19
|
+
};
|
|
20
|
+
use starknet::ContractAddress;
|
|
21
|
+
use starkware_utils_testing::test_utils::{
|
|
22
|
+
assert_panic_with_error, assert_panic_with_felt_error, cheat_caller_address_once,
|
|
23
|
+
};
|
|
24
|
+
use crate::fuzzable::contract_address::{FuzzableContractAddress, FuzzableContractAddresses};
|
|
25
|
+
use crate::mocks::treasury::lz_token_fee_lib::{
|
|
26
|
+
IMockLzTokenFeeLibAssertionDispatcher, IMockLzTokenFeeLibAssertionDispatcherTrait,
|
|
27
|
+
};
|
|
28
|
+
use crate::treasury::utils::deploy_mock_lz_token_fee_lib;
|
|
29
|
+
|
|
30
|
+
// Test constants
|
|
31
|
+
const OWNER: ContractAddress = 'owner'.try_into().unwrap();
|
|
32
|
+
const USER: ContractAddress = 'user'.try_into().unwrap();
|
|
33
|
+
const RECIPIENT: ContractAddress = 'recipient'.try_into().unwrap();
|
|
34
|
+
const ZERO_ADDRESS: ContractAddress = 0.try_into().unwrap();
|
|
35
|
+
|
|
36
|
+
// Test values
|
|
37
|
+
const INITIAL_TOKEN_SUPPLY: u256 = 1000000_u256; // 1M tokens
|
|
38
|
+
const TEST_BASIS_POINTS: u256 = 500_u256; // 5%
|
|
39
|
+
const TEST_WORKER_FEE: u256 = 10000_u256;
|
|
40
|
+
const TEST_DST_EID: u32 = 102;
|
|
41
|
+
const TEST_EXPECTED_FEE: u32 = 500;
|
|
42
|
+
|
|
43
|
+
fn deploy_mock_erc20(initial_supply: u256, recipient: ContractAddress) -> ContractAddress {
|
|
44
|
+
let contract = declare("MockERC20").unwrap().contract_class();
|
|
45
|
+
// this sis done because u256 does not fit into felt252
|
|
46
|
+
let (address, _) = contract
|
|
47
|
+
.deploy(@array![initial_supply.low.into(), initial_supply.high.into(), recipient.into()])
|
|
48
|
+
.unwrap();
|
|
49
|
+
address
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fn deploy_treasury(owner: ContractAddress) -> ContractAddress {
|
|
53
|
+
let contract = declare("Treasury").unwrap().contract_class();
|
|
54
|
+
let (address, _) = contract.deploy(@array![owner.into()]).unwrap();
|
|
55
|
+
address
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fn setup() -> (
|
|
59
|
+
ContractAddress,
|
|
60
|
+
ContractAddress,
|
|
61
|
+
ILayerZeroTreasurySafeDispatcher,
|
|
62
|
+
ITreasuryAdminSafeDispatcher,
|
|
63
|
+
IOwnableSafeDispatcher,
|
|
64
|
+
IERC20SafeDispatcher,
|
|
65
|
+
) {
|
|
66
|
+
let token_address = deploy_mock_erc20(INITIAL_TOKEN_SUPPLY, USER);
|
|
67
|
+
let treasury_address = deploy_treasury(OWNER);
|
|
68
|
+
|
|
69
|
+
(
|
|
70
|
+
treasury_address,
|
|
71
|
+
token_address,
|
|
72
|
+
ILayerZeroTreasurySafeDispatcher { contract_address: treasury_address },
|
|
73
|
+
ITreasuryAdminSafeDispatcher { contract_address: treasury_address },
|
|
74
|
+
IOwnableSafeDispatcher { contract_address: treasury_address },
|
|
75
|
+
IERC20SafeDispatcher { contract_address: token_address },
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn setup_with_basis_points(
|
|
80
|
+
basis_points: u256,
|
|
81
|
+
) -> (
|
|
82
|
+
ContractAddress,
|
|
83
|
+
ContractAddress,
|
|
84
|
+
ILayerZeroTreasurySafeDispatcher,
|
|
85
|
+
ITreasuryAdminSafeDispatcher,
|
|
86
|
+
IOwnableSafeDispatcher,
|
|
87
|
+
IERC20SafeDispatcher,
|
|
88
|
+
) {
|
|
89
|
+
let (
|
|
90
|
+
treasury_address,
|
|
91
|
+
token_address,
|
|
92
|
+
treasury_dispatcher,
|
|
93
|
+
admin_dispatcher,
|
|
94
|
+
ownable_dispatcher,
|
|
95
|
+
token_dispatcher,
|
|
96
|
+
) =
|
|
97
|
+
setup();
|
|
98
|
+
|
|
99
|
+
// Set basis points
|
|
100
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
101
|
+
admin_dispatcher.set_fee_bp(basis_points).unwrap();
|
|
102
|
+
stop_cheat_caller_address(treasury_address);
|
|
103
|
+
|
|
104
|
+
(
|
|
105
|
+
treasury_address,
|
|
106
|
+
token_address,
|
|
107
|
+
treasury_dispatcher,
|
|
108
|
+
admin_dispatcher,
|
|
109
|
+
ownable_dispatcher,
|
|
110
|
+
token_dispatcher,
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#[test]
|
|
115
|
+
fn test_constructor() {
|
|
116
|
+
let (treasury_address, _, _, _, ownable_dispatcher, _) = setup();
|
|
117
|
+
|
|
118
|
+
// Test that owner is set correctly
|
|
119
|
+
assert(ownable_dispatcher.owner().unwrap() == OWNER, 'Owner should be set correctly');
|
|
120
|
+
|
|
121
|
+
// Test that basis points start at 0
|
|
122
|
+
let admin_dispatcher = ITreasuryAdminSafeDispatcher { contract_address: treasury_address };
|
|
123
|
+
assert(admin_dispatcher.get_fee_bp().unwrap() == 0, 'Basis points should be 0');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#[test]
|
|
127
|
+
fn test_withdraw_tokens_as_owner() {
|
|
128
|
+
let CUSTOM_BASIS_POINTS = 200;
|
|
129
|
+
|
|
130
|
+
let (treasury_address, _, _, admin_dispatcher, _, token_dispatcher) = setup_with_basis_points(
|
|
131
|
+
CUSTOM_BASIS_POINTS,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// First, get some tokens into the treasury by paying a fee
|
|
135
|
+
// 1999.62 rounded down
|
|
136
|
+
let expected_treasury_fee = 1_999;
|
|
137
|
+
|
|
138
|
+
start_cheat_caller_address(token_dispatcher.contract_address, USER);
|
|
139
|
+
token_dispatcher.transfer(treasury_address, expected_treasury_fee).unwrap();
|
|
140
|
+
stop_cheat_caller_address(token_dispatcher.contract_address);
|
|
141
|
+
|
|
142
|
+
let mut spy = spy_events();
|
|
143
|
+
// should be 999.5 => 999
|
|
144
|
+
let withdraw_amount = expected_treasury_fee / 2;
|
|
145
|
+
|
|
146
|
+
// Withdraw tokens as owner
|
|
147
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
148
|
+
admin_dispatcher
|
|
149
|
+
.withdraw_tokens(token_dispatcher.contract_address, RECIPIENT, withdraw_amount)
|
|
150
|
+
.unwrap();
|
|
151
|
+
stop_cheat_caller_address(treasury_address);
|
|
152
|
+
|
|
153
|
+
// Verify balances
|
|
154
|
+
let final_recipient_balance = token_dispatcher.balance_of(RECIPIENT).unwrap();
|
|
155
|
+
let final_treasury_balance = token_dispatcher.balance_of(treasury_address).unwrap();
|
|
156
|
+
|
|
157
|
+
assert(final_recipient_balance == 999, 'Recipient balance incorrect');
|
|
158
|
+
assert(final_treasury_balance == 1000, 'Treasury balance incorrect');
|
|
159
|
+
|
|
160
|
+
let expected_event = ERC20Event::Transfer(
|
|
161
|
+
Transfer { from: treasury_address, to: RECIPIENT, value: withdraw_amount },
|
|
162
|
+
);
|
|
163
|
+
spy.assert_emitted(@array![(token_dispatcher.contract_address, expected_event)]);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#[test]
|
|
167
|
+
#[fuzzer(runs: 10)]
|
|
168
|
+
fn test_withdraw_tokens_fails_as_non_owner(amount: u256) {
|
|
169
|
+
let (treasury_address, _, _, admin_dispatcher, _, token_dispatcher) = setup();
|
|
170
|
+
|
|
171
|
+
start_cheat_caller_address(treasury_address, USER);
|
|
172
|
+
let result = admin_dispatcher
|
|
173
|
+
.withdraw_tokens(token_dispatcher.contract_address, RECIPIENT, amount);
|
|
174
|
+
stop_cheat_caller_address(treasury_address);
|
|
175
|
+
|
|
176
|
+
assert_panic_with_felt_error(result, 'Caller is not the owner');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
#[test]
|
|
181
|
+
#[fuzzer(runs: 10)]
|
|
182
|
+
fn test_withdraw_tokens_fails_with_insufficient_balance(amount: u256) {
|
|
183
|
+
let (treasury_address, _, _, admin_dispatcher, _, token_dispatcher) = setup();
|
|
184
|
+
|
|
185
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
186
|
+
let result = admin_dispatcher
|
|
187
|
+
.withdraw_tokens(
|
|
188
|
+
token_dispatcher.contract_address, RECIPIENT, amount + 1,
|
|
189
|
+
); // More than treasury has
|
|
190
|
+
stop_cheat_caller_address(treasury_address);
|
|
191
|
+
|
|
192
|
+
assert_panic_with_felt_error(result, 'ERC20: insufficient balance');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// =============================== Native token =================================
|
|
196
|
+
|
|
197
|
+
#[test]
|
|
198
|
+
#[fuzzer(runs: 10)]
|
|
199
|
+
fn test_get_native_fee_with_zero_basis_points(dst_eid: u32, worker_fee: u256) {
|
|
200
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup();
|
|
201
|
+
|
|
202
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, worker_fee, false).unwrap();
|
|
203
|
+
assert(fee == 0, 'Fee should be 0 with 0 bp');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#[test]
|
|
207
|
+
#[fuzzer(runs: 10)]
|
|
208
|
+
fn test_get_native_fee_with_basis_points(dst_eid: u32, basis_points: u128) {
|
|
209
|
+
const CUSTOM_WORKER_FEE: u256 = 1000_000_000;
|
|
210
|
+
let basis_points = basis_points.into();
|
|
211
|
+
|
|
212
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup_with_basis_points(basis_points);
|
|
213
|
+
|
|
214
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, CUSTOM_WORKER_FEE, false).unwrap();
|
|
215
|
+
assert(fee == 100_000 * basis_points, 'Fee calculation incorrect');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
#[test]
|
|
219
|
+
#[fuzzer(runs: 10)]
|
|
220
|
+
fn test_get_native_fee_edge_cases(dst_eid: u32, worker_fee: u128) {
|
|
221
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup_with_basis_points(10000); // 100%
|
|
222
|
+
let worker_fee = worker_fee.into();
|
|
223
|
+
|
|
224
|
+
// Test with 100% basis points
|
|
225
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, worker_fee, false).unwrap();
|
|
226
|
+
assert(fee == worker_fee, '100% fee should equal total');
|
|
227
|
+
|
|
228
|
+
// Test with zero total fee
|
|
229
|
+
let fee_zero = treasury_dispatcher.get_fee(USER, dst_eid, 0, false).unwrap();
|
|
230
|
+
assert(fee_zero == 0, 'Zero total should give zero fee');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#[test]
|
|
234
|
+
#[fuzzer(runs: 10)]
|
|
235
|
+
fn test_simple_pay_native_fee(dst_eid: u32, worker_fee: u128) {
|
|
236
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup_with_basis_points(10000);
|
|
237
|
+
let worker_fee = worker_fee.into();
|
|
238
|
+
|
|
239
|
+
let fee = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, false).unwrap();
|
|
240
|
+
assert(fee == worker_fee, '100% fee should equal total');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
#[test]
|
|
244
|
+
#[fuzzer(runs: 10)]
|
|
245
|
+
fn test_set_native_fee_bp_as_owner(basis_points: u256) {
|
|
246
|
+
let (treasury_address, _, _, admin_dispatcher, _, _) = setup();
|
|
247
|
+
|
|
248
|
+
let mut spy = spy_events();
|
|
249
|
+
|
|
250
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
251
|
+
admin_dispatcher.set_fee_bp(basis_points).unwrap();
|
|
252
|
+
stop_cheat_caller_address(treasury_address);
|
|
253
|
+
|
|
254
|
+
assert(admin_dispatcher.get_fee_bp().unwrap() == basis_points, 'Basis points not updated');
|
|
255
|
+
|
|
256
|
+
// Verify event was emitted
|
|
257
|
+
let expected_event = Treasury::Event::BasisPointsUpdated(
|
|
258
|
+
BasisPointsUpdated { old_bp: 0, new_bp: basis_points },
|
|
259
|
+
);
|
|
260
|
+
spy.assert_emitted(@array![(treasury_address, expected_event)]);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
#[test]
|
|
264
|
+
#[fuzzer(runs: 10)]
|
|
265
|
+
fn test_set_native_fee_bp_fails_as_non_owner(basis_points: u256) {
|
|
266
|
+
let (treasury_address, _, _, admin_dispatcher, _, _) = setup();
|
|
267
|
+
|
|
268
|
+
start_cheat_caller_address(treasury_address, USER);
|
|
269
|
+
let result = admin_dispatcher.set_fee_bp(basis_points);
|
|
270
|
+
stop_cheat_caller_address(treasury_address);
|
|
271
|
+
|
|
272
|
+
assert_panic_with_felt_error(result, 'Caller is not the owner');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#[test]
|
|
276
|
+
fn test_basis_points_update_affects_fee_calculation() {
|
|
277
|
+
let (treasury_address, _, treasury_dispatcher, admin_dispatcher, _, _) = setup();
|
|
278
|
+
|
|
279
|
+
// Initially 0 basis points
|
|
280
|
+
let initial_fee = treasury_dispatcher
|
|
281
|
+
.get_fee(USER, TEST_DST_EID, TEST_WORKER_FEE, false)
|
|
282
|
+
.unwrap();
|
|
283
|
+
assert(initial_fee == 0, 'Initial fee should be 0');
|
|
284
|
+
|
|
285
|
+
const CUSTOM_WORKER_FEE: u256 = 8736482;
|
|
286
|
+
const CUSTOM_BASIS_POINTS: u256 = 721;
|
|
287
|
+
|
|
288
|
+
// Update basis points
|
|
289
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
290
|
+
admin_dispatcher.set_fee_bp(CUSTOM_BASIS_POINTS).unwrap();
|
|
291
|
+
stop_cheat_caller_address(treasury_address);
|
|
292
|
+
|
|
293
|
+
// Fee should now be calculated with new basis points
|
|
294
|
+
// should be 629,900.3522 ~= 629,900
|
|
295
|
+
let updated_fee = treasury_dispatcher
|
|
296
|
+
.get_fee(USER, TEST_DST_EID, CUSTOM_WORKER_FEE, false)
|
|
297
|
+
.unwrap();
|
|
298
|
+
assert(updated_fee == 629_900, 'Updated fee incorrect');
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#[test]
|
|
302
|
+
#[fuzzer(runs: 10)]
|
|
303
|
+
fn test_keep_integer_part_of_native_fee(dst_eid: u32, amount: u128) {
|
|
304
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup_with_basis_points(1);
|
|
305
|
+
let amount = amount.into();
|
|
306
|
+
|
|
307
|
+
// The integer part should be kept.
|
|
308
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, amount * DEFAULT_BPS, false).unwrap();
|
|
309
|
+
assert(fee == amount, 'Invalid fee amount');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
#[test]
|
|
313
|
+
#[fuzzer(runs: 10)]
|
|
314
|
+
fn test_drop_fractional_part_of_native_fee(dst_eid: u32, amount: u256) {
|
|
315
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup_with_basis_points(1);
|
|
316
|
+
|
|
317
|
+
// The fractional part should be truncated.
|
|
318
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, amount % DEFAULT_BPS, false).unwrap();
|
|
319
|
+
assert(fee == 0, 'Small fee should truncate to 0');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// =============================== LayerZero token =================================
|
|
323
|
+
|
|
324
|
+
#[test]
|
|
325
|
+
#[fuzzer(runs: 10)]
|
|
326
|
+
fn test_get_enabled_lz_token_fee(dst_eid: u32, worker_fee: u256, expected_fee: u256) {
|
|
327
|
+
let (treasury_address, _, treasury_dispatcher, admin_dispatcher, _, _) = setup();
|
|
328
|
+
|
|
329
|
+
let library = deploy_mock_lz_token_fee_lib(0);
|
|
330
|
+
let library_assertion = IMockLzTokenFeeLibAssertionDispatcher { contract_address: library };
|
|
331
|
+
cheat_caller_address_once(treasury_address, OWNER);
|
|
332
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(library)).unwrap();
|
|
333
|
+
|
|
334
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
335
|
+
assert(fee == 0, 'Fee should be 0');
|
|
336
|
+
|
|
337
|
+
let library = deploy_mock_lz_token_fee_lib(expected_fee);
|
|
338
|
+
cheat_caller_address_once(treasury_address, OWNER);
|
|
339
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(library)).unwrap();
|
|
340
|
+
|
|
341
|
+
library_assertion.assert_payment_count(0);
|
|
342
|
+
|
|
343
|
+
let fee = treasury_dispatcher.get_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
344
|
+
assert(fee == expected_fee, 'Invalid fee amount');
|
|
345
|
+
library_assertion.assert_payment_count(0);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#[test]
|
|
349
|
+
#[fuzzer(runs: 10)]
|
|
350
|
+
fn test_get_disabled_lz_token_fee(dst_eid: u32, worker_fee: u256) {
|
|
351
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup();
|
|
352
|
+
|
|
353
|
+
let result = treasury_dispatcher.get_fee(USER, dst_eid, worker_fee, true);
|
|
354
|
+
|
|
355
|
+
assert_panic_with_error(result, err_lz_token_not_enabled());
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
#[test]
|
|
359
|
+
#[fuzzer(runs: 10)]
|
|
360
|
+
fn test_pay_enabled_lz_token_fee(dst_eid: u32, worker_fee: u256, expected_fee: u256) {
|
|
361
|
+
let (treasury_address, _, treasury_dispatcher, admin_dispatcher, _, _) = setup();
|
|
362
|
+
|
|
363
|
+
let library = deploy_mock_lz_token_fee_lib(0);
|
|
364
|
+
cheat_caller_address_once(treasury_address, OWNER);
|
|
365
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(library)).unwrap();
|
|
366
|
+
|
|
367
|
+
let fee = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
368
|
+
assert(fee == 0, 'Fee should be 0');
|
|
369
|
+
|
|
370
|
+
let library = deploy_mock_lz_token_fee_lib(expected_fee);
|
|
371
|
+
cheat_caller_address_once(treasury_address, OWNER);
|
|
372
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(library)).unwrap();
|
|
373
|
+
|
|
374
|
+
let fee = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
375
|
+
assert(fee == expected_fee, 'Invalid fee amount');
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
#[test]
|
|
379
|
+
#[fuzzer(runs: 10)]
|
|
380
|
+
fn test_pay_enabled_lz_token_fee_multiple_times(
|
|
381
|
+
dst_eid: u32, worker_fee: u256, expected_fee: u256,
|
|
382
|
+
) {
|
|
383
|
+
let (treasury_address, _, treasury_dispatcher, admin_dispatcher, _, _) = setup();
|
|
384
|
+
|
|
385
|
+
let library = deploy_mock_lz_token_fee_lib(expected_fee);
|
|
386
|
+
let library_assertion = IMockLzTokenFeeLibAssertionDispatcher { contract_address: library };
|
|
387
|
+
cheat_caller_address_once(treasury_address, OWNER);
|
|
388
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(library)).unwrap();
|
|
389
|
+
|
|
390
|
+
library_assertion.assert_payment_count(0);
|
|
391
|
+
|
|
392
|
+
let fee = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
393
|
+
assert(fee == expected_fee, 'Invalid fee amount');
|
|
394
|
+
library_assertion.assert_payment_count(1);
|
|
395
|
+
|
|
396
|
+
let fee = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, true).unwrap();
|
|
397
|
+
assert(fee == expected_fee, 'Invalid fee amount');
|
|
398
|
+
library_assertion.assert_payment_count(2);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
#[test]
|
|
402
|
+
#[fuzzer(runs: 10)]
|
|
403
|
+
fn test_pay_disabled_lz_token_fee(dst_eid: u32, worker_fee: u256) {
|
|
404
|
+
let (_, _, treasury_dispatcher, _, _, _) = setup();
|
|
405
|
+
|
|
406
|
+
let result = treasury_dispatcher.pay_fee(USER, dst_eid, worker_fee, true);
|
|
407
|
+
|
|
408
|
+
assert_panic_with_error(result, err_lz_token_not_enabled());
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
#[test]
|
|
412
|
+
#[fuzzer(runs: 10)]
|
|
413
|
+
fn test_set_lz_token_fee_as_owner(
|
|
414
|
+
dst_eid: u32,
|
|
415
|
+
worker_fee: u256,
|
|
416
|
+
first_lz_token_fee_lib: ContractAddress,
|
|
417
|
+
second_lz_token_fee_lib: ContractAddress,
|
|
418
|
+
) {
|
|
419
|
+
let (treasury_address, _, _, admin_dispatcher, _, _) = setup();
|
|
420
|
+
|
|
421
|
+
assert(admin_dispatcher.get_lz_token_fee_lib().unwrap() == None, 'LZ token fee library set');
|
|
422
|
+
|
|
423
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
424
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(first_lz_token_fee_lib)).unwrap();
|
|
425
|
+
stop_cheat_caller_address(treasury_address);
|
|
426
|
+
|
|
427
|
+
assert(
|
|
428
|
+
admin_dispatcher.get_lz_token_fee_lib().unwrap() == Some(first_lz_token_fee_lib),
|
|
429
|
+
'Invalid LZ token fee library',
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
start_cheat_caller_address(treasury_address, OWNER);
|
|
433
|
+
admin_dispatcher.set_lz_token_fee_lib(Some(second_lz_token_fee_lib)).unwrap();
|
|
434
|
+
stop_cheat_caller_address(treasury_address);
|
|
435
|
+
|
|
436
|
+
assert(
|
|
437
|
+
admin_dispatcher.get_lz_token_fee_lib().unwrap() == Some(second_lz_token_fee_lib),
|
|
438
|
+
'Invalid LZ token fee library',
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
#[test]
|
|
443
|
+
#[fuzzer(runs: 10)]
|
|
444
|
+
fn test_set_lz_token_fee_lib_as_non_owner(
|
|
445
|
+
user: ContractAddress, lz_token_fee_lib: ContractAddress,
|
|
446
|
+
) {
|
|
447
|
+
let (treasury_address, _, _, admin_dispatcher, _, _) = setup();
|
|
448
|
+
|
|
449
|
+
cheat_caller_address_once(treasury_address, user);
|
|
450
|
+
let result = admin_dispatcher.set_lz_token_fee_lib(None);
|
|
451
|
+
|
|
452
|
+
assert_panic_with_felt_error(result, 'Caller is not the owner');
|
|
453
|
+
|
|
454
|
+
cheat_caller_address_once(treasury_address, user);
|
|
455
|
+
let result = admin_dispatcher.set_lz_token_fee_lib(Some(lz_token_fee_lib));
|
|
456
|
+
|
|
457
|
+
assert_panic_with_felt_error(result, 'Caller is not the owner');
|
|
458
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
use snforge_std::{ContractClassTrait, DeclareResultTrait, declare};
|
|
2
|
+
use starknet::ContractAddress;
|
|
3
|
+
|
|
4
|
+
pub fn deploy_mock_lz_token_fee_lib(fee: u256) -> ContractAddress {
|
|
5
|
+
let contract = declare("MockLzTokenFeeLib").unwrap().contract_class();
|
|
6
|
+
let (address, _) = contract.deploy(@array![fee.low.into(), fee.high.into()]).unwrap();
|
|
7
|
+
address
|
|
8
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use core::num::traits::SaturatingSub;
|
|
2
|
+
use starknet::ContractAddress;
|
|
3
|
+
use crate::fuzzable::felt_array::{Felt252ArrayList, FuzzableFelt252Array};
|
|
4
|
+
|
|
5
|
+
pub fn sort_contract_addresses(xs: Array<ContractAddress>) -> Array<ContractAddress> {
|
|
6
|
+
if xs.len() < 2 {
|
|
7
|
+
return xs;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let pivot = *xs[0];
|
|
11
|
+
let mut left = array![];
|
|
12
|
+
let mut right = array![];
|
|
13
|
+
let mut xs = xs.into_iter();
|
|
14
|
+
xs.advance_by(1).unwrap();
|
|
15
|
+
|
|
16
|
+
for x in xs {
|
|
17
|
+
if x < pivot {
|
|
18
|
+
left.append(x);
|
|
19
|
+
} else {
|
|
20
|
+
right.append(x);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
sort_contract_addresses(left)
|
|
25
|
+
.into_iter()
|
|
26
|
+
.chain(Some(pivot))
|
|
27
|
+
.chain(sort_contract_addresses(right))
|
|
28
|
+
.collect()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#[test]
|
|
32
|
+
#[fuzzer(runs: 10)]
|
|
33
|
+
fn test_sort(list: Felt252ArrayList) {
|
|
34
|
+
let xs = list.arr.into_iter().map(|x| x.try_into().unwrap()).collect();
|
|
35
|
+
let ys = sort_contract_addresses(xs.clone());
|
|
36
|
+
|
|
37
|
+
assert_eq!(ys.len(), xs.len());
|
|
38
|
+
|
|
39
|
+
for x in xs {
|
|
40
|
+
let mut iterator = ys.span().into_iter();
|
|
41
|
+
|
|
42
|
+
assert!(iterator.any(|y| *y == x));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for index in 0..ys.len().saturating_sub(1) {
|
|
46
|
+
assert_le!(ys[index], ys[index + 1]);
|
|
47
|
+
}
|
|
48
|
+
}
|