├── .cargo └── config.toml ├── .github ├── actions │ ├── free-disk-space │ │ └── action.yml │ ├── run-local-ic-example │ │ └── action.yml │ └── run-local-ic-test │ │ └── action.yml └── workflows │ ├── check-ci.yml │ └── docs.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── audits └── 2025_01_zellic.pdf ├── contracts ├── accounts │ ├── base_account │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-base-account.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── tests.rs │ ├── interchain_account │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-interchain-account.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ └── state.rs │ └── storage_account │ │ ├── .cargo │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ └── valence-storage-account.json │ │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ ├── state.rs │ │ └── tests.rs ├── authorization │ ├── .cargo │ │ └── config.toml │ ├── Cargo.toml │ ├── README.md │ ├── schema │ │ └── valence-authorization.json │ └── src │ │ ├── authorization.rs │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── domain.rs │ │ ├── error.rs │ │ ├── lib.rs │ │ ├── state.rs │ │ └── tests │ │ ├── builders.rs │ │ ├── helpers.rs │ │ ├── mod.rs │ │ ├── owner_actions.rs │ │ ├── processor.rs │ │ └── user_actions.rs ├── encoders │ ├── broker │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-encoder-broker.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ ├── state.rs │ │ │ └── tests.rs │ └── evm-encoder │ │ ├── .cargo │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ └── valence-evm-encoder-v1.json │ │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── hyperlane │ │ ├── callback.rs │ │ └── mod.rs │ │ ├── lib.rs │ │ ├── libraries │ │ ├── aave_position_manager.rs │ │ ├── balancer_v2_swap.rs │ │ ├── cctp_transfer.rs │ │ ├── forwarder.rs │ │ ├── ibc_eureka_transfer.rs │ │ ├── mod.rs │ │ ├── pancake_v3_position_manager.rs │ │ ├── standard_bridge_transfer.rs │ │ └── stargate_transfer.rs │ │ ├── processor │ │ ├── evict_msgs.rs │ │ ├── insert_msgs.rs │ │ ├── mod.rs │ │ ├── pause.rs │ │ ├── resume.rs │ │ └── send_msgs.rs │ │ └── tests.rs ├── libraries │ ├── astroport-lper │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-astroport-lper.json │ │ └── src │ │ │ ├── astroport_cw20.rs │ │ │ ├── astroport_native.rs │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── astroport-withdrawer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-astroport-withdrawer.json │ │ └── src │ │ │ ├── astroport_cw20.rs │ │ │ ├── astroport_native.rs │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── clearing-queue │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-clearing-queue.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ ├── state.rs │ │ │ └── testing │ │ │ ├── builder.rs │ │ │ ├── mod.rs │ │ │ ├── suite.rs │ │ │ └── tests.rs │ ├── drop-liquid-staker │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-drop-liquid-staker.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ ├── drop-liquid-unstaker │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-drop-liquid-unstaker.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ ├── forwarder │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-forwarder-library.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ ├── state.rs │ │ │ └── tests.rs │ ├── generic-ibc-transfer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-generic-ibc-transfer-library.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── ica-cctp-transfer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-ica-cctp-transfer.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── proto.rs │ ├── ica-ibc-transfer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-ica-ibc-transfer.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── mars-lending │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-mars-lending.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ ├── neutron-ibc-transfer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-neutron-ibc-transfer-library.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── tests.rs │ ├── neutron-ic-querier │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-neutron-ic-querier.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ ├── osmosis-cl-lper │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-osmosis-cl-lper.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ ├── test_suite.rs │ │ │ └── tests.rs │ ├── osmosis-cl-withdrawer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-osmosis-cl-withdrawer.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ ├── test_suite.rs │ │ │ └── tests.rs │ ├── osmosis-gamm-lper │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-osmosis-gamm-lper.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ ├── test_suite.rs │ │ │ └── tests.rs │ ├── osmosis-gamm-withdrawer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-osmosis-gamm-withdrawer.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ ├── test_suite.rs │ │ │ └── tests.rs │ ├── reverse-splitter │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-reverse-splitter-library.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── splitter │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-splitter-library.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── tests.rs │ ├── supervaults-lper │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-supervaults-lper.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ ├── supervaults-withdrawer │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-supervaults-withdrawer.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ └── msg.rs │ └── template │ │ ├── .cargo │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ └── valence-template-library.json │ │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ └── tests.rs ├── middleware │ ├── README.md │ ├── asserter │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-middleware-asserter.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ └── tests.rs │ ├── broker │ │ ├── .cargo │ │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ │ └── valence-middleware-broker.json │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ ├── state.rs │ │ │ └── testing │ │ │ ├── mod.rs │ │ │ └── tests.rs │ ├── type-registries │ │ ├── README.md │ │ └── osmosis │ │ │ └── osmo-26-0-0 │ │ │ ├── .cargo │ │ │ └── config.toml │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ ├── bin │ │ │ └── schema.rs │ │ │ ├── contract.rs │ │ │ ├── definitions │ │ │ ├── bank_balance │ │ │ │ ├── icq_adapter.rs │ │ │ │ ├── mod.rs │ │ │ │ └── valence_adapter.rs │ │ │ ├── gamm_pool │ │ │ │ ├── icq_adapter.rs │ │ │ │ ├── mod.rs │ │ │ │ └── valence_adapter.rs │ │ │ └── mod.rs │ │ │ └── lib.rs │ └── verification-gateway │ │ ├── .cargo │ │ └── config.toml │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── schema │ │ └── valence-verification-gateway.json │ │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── error.rs │ │ ├── lib.rs │ │ └── msg.rs ├── processor │ ├── .cargo │ │ └── config.toml │ ├── Cargo.toml │ ├── README.md │ ├── schema │ │ └── valence-processor.json │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── callback.rs │ │ ├── contract.rs │ │ ├── error.rs │ │ ├── lib.rs │ │ ├── queue.rs │ │ └── state.rs ├── program-registry │ ├── .cargo │ │ └── config.toml │ ├── Cargo.toml │ ├── README.md │ ├── schema │ │ └── valence-program-registry.json │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── error.rs │ │ ├── lib.rs │ │ └── state.rs └── testing │ ├── test-dynamic-ratio │ ├── Cargo.toml │ └── src │ │ ├── bin │ │ └── schema.rs │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ └── state.rs │ ├── test-icq-lib │ ├── Cargo.toml │ └── src │ │ ├── contract.rs │ │ ├── icq.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ └── state.rs │ └── test-library │ ├── .cargo │ └── config.toml │ ├── Cargo.toml │ ├── schema │ └── valence-test-library.json │ └── src │ ├── bin │ └── schema.rs │ ├── contract.rs │ ├── error.rs │ ├── lib.rs │ ├── msg.rs │ └── state.rs ├── deployment ├── README.md ├── configs │ └── mainnet │ │ ├── chains.toml │ │ ├── contracts.toml │ │ ├── general.toml │ │ └── neutron_bridges │ │ └── neutron_cosmos_hub.toml └── scripts │ ├── build_program │ ├── Cargo.toml │ └── src │ │ ├── main.rs │ │ └── my_program.rs │ ├── deploy_program │ ├── Cargo.toml │ └── src │ │ └── main.rs │ └── generate_local_ic_config │ ├── Cargo.toml │ └── src │ └── main.rs ├── devtools ├── optimize.sh ├── schema.sh └── toml_fmt.sh ├── docs ├── .gitignore ├── README.md ├── book.toml ├── mermaid-init.js ├── mermaid.min.js └── src │ ├── SUMMARY.md │ ├── accounts │ ├── _overview.md │ ├── base_accounts.md │ ├── interchain_accounts.md │ └── storage_accounts.md │ ├── authorizations_processors │ ├── _overview.md │ ├── assumptions.md │ ├── authorization_contract.md │ ├── authorization_instantiation.md │ ├── authorization_owner_actions.md │ ├── authorization_user_actions.md │ ├── callbacks.md │ ├── connectors.md │ ├── encoding.md │ ├── execution_environment_differences.md │ ├── lite_processor.md │ ├── processor.md │ └── processor_contract.md │ ├── components │ ├── _overview.md │ ├── domains.md │ ├── libraries_and_functions.md │ ├── middleware.md │ └── programs_and_authorizations.md │ ├── deployment │ ├── _overview.md │ └── local.md │ ├── examples │ ├── _overview.md │ ├── crosschain_vaults.md │ ├── token_swap.md │ └── vault_strategist.md │ ├── img │ ├── authorization_table.png │ └── user_flowchart.png │ ├── introduction.md │ ├── libraries │ ├── _overview.md │ ├── cosmwasm │ │ ├── _overview.md │ │ ├── astroport_lper.md │ │ ├── astroport_withdrawer.md │ │ ├── clearing_queue.md │ │ ├── drop_liquid_staker.md │ │ ├── drop_liquid_unstaker.md │ │ ├── forwarder.md │ │ ├── generic_ibc_transfer.md │ │ ├── ica_cctp_transfer.md │ │ ├── ica_ibc_transfer.md │ │ ├── mars_lending.md │ │ ├── neutron_ibc_transfer.md │ │ ├── neutron_ic_querier.md │ │ ├── osmosis_cl_lper.md │ │ ├── osmosis_cl_withdrawer.md │ │ ├── osmosis_gamm_lper.md │ │ ├── osmosis_gamm_withdrawer.md │ │ ├── reverse_splitter.md │ │ ├── splitter.md │ │ ├── supervaults_lper.md │ │ └── supervaults_withdrawer.md │ └── evm │ │ ├── _overview.md │ │ ├── aave_position_manager.md │ │ ├── balancer_v2_swap.md │ │ ├── cctp_transfer.md │ │ ├── forwarder.md │ │ ├── ibc_eureka_transfer.md │ │ ├── pancakeswap_v3_position_manager.md │ │ ├── splitter.md │ │ ├── standard_bridge_transfer.md │ │ └── stargate_transfer.md │ ├── middleware │ ├── _overview.md │ ├── broker.md │ ├── type_registry.md │ ├── valence_asserter.md │ └── valence_types.md │ ├── program_manager │ ├── _overview.md │ ├── build_program_config.md │ ├── how_to.md │ ├── library_account_type.md │ ├── manager_config.md │ └── program_configs │ │ ├── instantiate.md │ │ ├── migrate.md │ │ └── update.md │ ├── security.md │ ├── testing │ ├── _overview.md │ ├── setup.md │ ├── with_program_manager.md │ └── without_program_manager.md │ └── zk │ ├── 01_system_overview.md │ ├── 02_developing_coprocessor_apps.md │ ├── 03_onchain_integration.md │ ├── 04_coprocessor_internals.md │ ├── 05_sparse_merkle_trees.md │ ├── 06_guest_environment.md │ ├── 07_state_encoding_and_encoders.md │ └── _overview.md ├── e2e ├── Cargo.toml ├── README.md ├── chains │ ├── juno_osmosis.json │ ├── neutron.json │ ├── neutron_juno.json │ ├── neutron_noble.json │ ├── neutron_noble_osmosis.json │ ├── neutron_osmosis.json │ └── neutron_persistence.json ├── examples │ ├── conditional_lp.rs │ ├── eth_cctp_vault │ │ ├── evm.rs │ │ ├── neutron.rs │ │ ├── program.rs │ │ ├── strategist │ │ │ ├── astroport.rs │ │ │ ├── example_strategy.toml │ │ │ ├── mod.rs │ │ │ ├── routing.rs │ │ │ ├── strategy.rs │ │ │ └── strategy_config.rs │ │ └── vault.rs │ ├── eth_eureka_vault │ │ ├── evm.rs │ │ ├── program.rs │ │ ├── strategist │ │ │ ├── astroport.rs │ │ │ ├── example_strategy.toml │ │ │ ├── mod.rs │ │ │ ├── routing.rs │ │ │ ├── strategy.rs │ │ │ ├── strategy_config.rs │ │ │ └── vault.rs │ │ └── vault.rs │ ├── eth_to_base_vault_pancake │ │ ├── base.rs │ │ ├── ethereum.rs │ │ ├── strategist │ │ │ ├── aave_utils.rs │ │ │ ├── example_strategy.toml │ │ │ ├── mod.rs │ │ │ ├── pancake_v3_utils.rs │ │ │ ├── strategy.rs │ │ │ └── strategy_config.rs │ │ └── vault.rs │ ├── ethereum_integration_tests.rs │ ├── ibc_transfer_juno_ntrn.rs │ ├── ibc_transfer_ntrn_juno.rs │ ├── ibc_transfer_ntrn_juno_gaia_pfm.rs │ ├── ibc_transfer_osmo_juno_gaia_pfm.rs │ ├── ibc_transfer_osmo_ntrn.rs │ ├── ica_libraries.rs │ ├── icq_test.rs │ ├── manager_server_dev.rs │ ├── manager_test.rs │ ├── middleware_icq_test.rs │ ├── persistence_ls.rs │ ├── polytone.rs │ ├── splitter_program_setup.rs │ └── two_party_pol_astroport_neutron.rs ├── hyperlane │ ├── config │ │ └── config.json │ └── contracts │ │ ├── cosmwasm │ │ ├── hpl_hook_merkle.wasm │ │ ├── hpl_igp.wasm │ │ ├── hpl_ism_pausable.wasm │ │ ├── hpl_mailbox.wasm │ │ └── hpl_validator_announce.wasm │ │ └── solidity │ │ ├── InterchainGasPaymaster.json │ │ ├── Mailbox.json │ │ ├── MerkleTreeHook.json │ │ ├── PausableIsm.json │ │ ├── TestRecipient.json │ │ └── ValidatorAnnounce.json ├── polytone_contracts │ ├── polytone_note.wasm │ ├── polytone_proxy.wasm │ └── polytone_voice.wasm └── src │ ├── lib.rs │ └── utils │ ├── astroport.rs │ ├── authorization.rs │ ├── base_account.rs │ ├── ethereum.rs │ ├── hyperlane.rs │ ├── ibc.rs │ ├── icq.rs │ ├── manager.rs │ ├── mocks │ ├── cctp_relayer_evm_evm.rs │ ├── cctp_relayer_evm_noble.rs │ ├── eureka_rly_evm_gaia_neutron.rs │ ├── mod.rs │ └── standard_bridge_relayer.rs │ ├── mod.rs │ ├── osmosis.rs │ ├── parse.rs │ ├── persistence.rs │ ├── polytone.rs │ ├── processor.rs │ ├── relayer.rs │ ├── solidity_contracts.rs │ ├── vault.rs │ └── worker.rs ├── examples ├── README.md ├── osmo_cl │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── osmo_cl.rs │ │ └── osmo_cl_test.rs ├── osmo_gamm │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── osmo_gamm.rs │ │ └── osmo_gamm_test.rs └── token_swap │ ├── Cargo.toml │ └── src │ ├── lib.rs │ ├── token_swap.rs │ └── token_swap_test.rs ├── justfile ├── packages ├── account-utils │ ├── Cargo.toml │ └── src │ │ ├── error.rs │ │ ├── ica.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ └── testing.rs ├── astroport-utils │ ├── Cargo.toml │ ├── contracts │ │ ├── astroport_factory.wasm │ │ ├── astroport_factory_cw20.wasm │ │ ├── astroport_factory_native.wasm │ │ ├── astroport_native_coin_registry.wasm │ │ ├── astroport_pair_concentrated.wasm │ │ ├── astroport_pair_cw20.wasm │ │ ├── astroport_pair_native.wasm │ │ └── astroport_token.wasm │ └── src │ │ ├── astroport_cw20_lp_token.rs │ │ ├── astroport_native_lp_token.rs │ │ ├── lib.rs │ │ └── suite.rs ├── authorization-utils │ ├── Cargo.toml │ └── src │ │ ├── authorization.rs │ │ ├── authorization_message.rs │ │ ├── builders.rs │ │ ├── callback.rs │ │ ├── domain.rs │ │ ├── function.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ └── zk_authorization.rs ├── encoder-utils │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── libraries │ │ ├── aave_position_manager │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── balancer_v2_swap │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── cctp_transfer │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── forwarder │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── ibc_eureka_transfer │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── mod.rs │ │ ├── pancake_v3_position_manager │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── standard_bridge_transfer │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ └── stargate_transfer │ │ │ ├── mod.rs │ │ │ └── solidity_types.rs │ │ ├── msg.rs │ │ └── processor │ │ ├── mod.rs │ │ └── solidity_types.rs ├── gmp-utils │ ├── Cargo.toml │ └── src │ │ ├── hyperlane.rs │ │ ├── lib.rs │ │ └── polytone.rs ├── ibc-utils │ ├── Cargo.toml │ └── src │ │ ├── generic.rs │ │ ├── lib.rs │ │ ├── neutron.rs │ │ └── types.rs ├── lending-utils │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── mars.rs ├── library-base │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── helpers.rs │ │ ├── lib.rs │ │ └── state.rs ├── library-utils │ ├── Cargo.toml │ └── src │ │ ├── error.rs │ │ ├── ica.rs │ │ ├── lib.rs │ │ ├── library_account_type.rs │ │ ├── liquidity_utils.rs │ │ ├── msg.rs │ │ ├── raw_config.rs │ │ └── testing.rs ├── liquid-staking-utils │ ├── Cargo.toml │ └── src │ │ ├── drop.rs │ │ └── lib.rs ├── middleware-utils │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── canonical_types │ │ ├── bank │ │ │ ├── balance.rs │ │ │ └── mod.rs │ │ ├── mod.rs │ │ └── pools │ │ │ ├── mod.rs │ │ │ └── xyk.rs │ │ ├── lib.rs │ │ └── type_registry │ │ ├── macros.rs │ │ ├── mod.rs │ │ ├── queries.rs │ │ └── types.rs ├── osmosis-utils │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── suite.rs │ │ ├── testing │ │ ├── balancer.rs │ │ ├── concentrated_liquidity.rs │ │ └── mod.rs │ │ └── utils.rs ├── processor-utils │ ├── Cargo.toml │ └── src │ │ ├── callback.rs │ │ ├── lib.rs │ │ ├── msg.rs │ │ ├── processor.rs │ │ └── queue.rs ├── program-registry-utils │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── supervaults-utils │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── msg.rs │ │ ├── prec_dec_range.rs │ │ └── queries.rs └── valence-macros │ ├── Cargo.toml │ └── src │ ├── helpers.rs │ └── lib.rs ├── program-manager ├── .cargo │ └── config.toml ├── Cargo.toml ├── README.md ├── schema │ └── valence-program-manager.json └── src │ ├── account.rs │ ├── bin │ └── schema.rs │ ├── bridge.rs │ ├── config.rs │ ├── connectors.rs │ ├── domain │ ├── cosmos_cw.rs │ ├── cosmos_evm.rs │ └── mod.rs │ ├── error.rs │ ├── helpers.rs │ ├── lib.rs │ ├── library.rs │ ├── macros.rs │ ├── mock_api.rs │ ├── program_config.rs │ ├── program_config_builder.rs │ ├── program_migration.rs │ ├── program_update.rs │ └── tests.rs ├── scripts ├── init.sh ├── start-local-ic.sh └── upload.sh └── solidity ├── .gitignore ├── foundry.toml ├── remappings.txt ├── script ├── AavePositionManager.script.sol ├── BalancerV2Swap.script.sol ├── CCTPTransfer.script.sol ├── IBCEurekaTransfer.script.sol ├── L1StandardBridgeTransfer.script.sol ├── L2StandardBridgeTransfer.script.sol ├── PancakeSwapV3PositionManager.script.sol └── StargateTransfer.script.sol ├── soldeer.lock ├── src ├── accounts │ ├── Account.sol │ └── BaseAccount.sol ├── authorization │ └── Authorization.sol ├── libraries │ ├── AavePositionManager.sol │ ├── BalancerV2Swap.sol │ ├── CCTPTransfer.sol │ ├── Forwarder.sol │ ├── IBCEurekaTransfer.sol │ ├── Library.sol │ ├── PancakeSwapV3PositionManager.sol │ ├── Splitter.sol │ ├── StandardBridgeTransfer.sol │ ├── StargateTransfer.sol │ └── interfaces │ │ ├── balancerV2 │ │ └── IBalancerVault.sol │ │ ├── cctp │ │ └── ITokenMessenger.sol │ │ ├── eureka │ │ └── IEurekaHandler.sol │ │ ├── pancakeswap │ │ ├── IMasterChefV3.sol │ │ └── INonfungiblePositionManager.sol │ │ ├── splitter │ │ └── IDynamicRatioOracle.sol │ │ └── standard-bridge │ │ └── IStandardBridge.sol ├── processor │ ├── LiteProcessor.sol │ ├── Processor.sol │ ├── ProcessorBase.sol │ ├── interfaces │ │ ├── ICallback.sol │ │ ├── IProcessor.sol │ │ └── IProcessorMessageTypes.sol │ └── libs │ │ ├── ProcessorErrors.sol │ │ ├── ProcessorEvents.sol │ │ ├── ProcessorMessageDecoder.sol │ │ └── QueueMap.sol ├── vaults │ ├── OneWayVault.sol │ └── ValenceVault.sol └── verification │ ├── SP1VerificationGateway.sol │ └── VerificationGateway.sol └── test ├── accounts └── BaseAccount.t.sol ├── authorization ├── AuthorizationStandard.t.sol └── AuthorizationZK.t.sol ├── libraries ├── AavePositionManager.t.sol ├── BalancerV2Swap.t.sol ├── CCTPTransfer.t.sol ├── Forwarder.t.sol ├── IBCEurekaTransfer.t.sol ├── PancakeSwapV3PositionManager.sol ├── Splitter.t.sol ├── StandardBridgeTransfer.t.sol └── StargateTransfer.t.sol ├── mocks ├── MockAavePool.sol ├── MockBalancerVault.sol ├── MockDynamicRatioOracle.sol ├── MockERC20.sol ├── MockStargate.sol └── MockTokenMessenger.sol ├── processor ├── LiteProcessor.t.sol ├── Processor.t.sol ├── ProcessorMessageDecoder.t.sol └── QueueMap.t.sol └── vaults ├── OneWayVault.t.sol └── ValenceVault ├── VaultBasic.t.sol ├── VaultCompleteWithdraw.t.sol ├── VaultConfig.t.sol ├── VaultDeposit.t.sol ├── VaultFees.t.sol ├── VaultGasBenchmark.t.sol ├── VaultHelper.t.sol ├── VaultRedemptionRate.t.sol ├── VaultSimulationTest.t.sol ├── VaultUpdate.t.sol ├── VaultUpgrade.t.sol ├── VaultWithdraw.t.sol └── WithdrawDebugger.t.sol /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | wasm-debug = "build --lib --target wasm32-unknown-unknown" 4 | clippy-all = "clippy --all-targets -- -D warnings" 5 | core-test = "test --workspace --exclude valence-program-manager --exclude valence-e2e --verbose" 6 | -------------------------------------------------------------------------------- /.github/actions/free-disk-space/action.yml: -------------------------------------------------------------------------------- 1 | name: Free disk space 2 | description: We've run into out-of-disk error when compiling Rust projects, so we free up some space this way. 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Free Disk Space 8 | uses: jlumbroso/free-disk-space@v1.3.1 9 | with: 10 | large-packages: false 11 | tool-cache: false 12 | 13 | # all of these default to true, but feel free to set to 14 | # "false" if necessary for your workflow 15 | android: true 16 | dotnet: true 17 | haskell: true 18 | docker-images: true 19 | swap-storage: true 20 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | permissions: 12 | contents: write 13 | 14 | jobs: 15 | build-and-deploy: 16 | concurrency: 17 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 18 | cancel-in-progress: true 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v4 23 | 24 | - name: Install mdbook 25 | run: cargo install mdbook mdbook-mermaid mdbook-linkcheck 26 | 27 | - name: Build book 28 | run: mdbook build docs 29 | 30 | - name: Deploy 31 | if: github.event_name == 'push' 32 | uses: JamesIves/github-pages-deploy-action@v4 33 | with: 34 | folder: docs/book/html 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | .DS_Store 3 | 4 | # Build results 5 | /artifacts 6 | /target 7 | 8 | # Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) 9 | .cargo-ok 10 | 11 | # Text file backups 12 | **/*.rs.bk 13 | 14 | # IDEs 15 | .vscode/ 16 | .idea/ 17 | *.iml 18 | **/.editorconfig 19 | 20 | # schemas 21 | contracts/**/schema/raw 22 | program-manager/schema/raw 23 | 24 | # e2e 25 | e2e/configs 26 | e2e/code_id_cache* 27 | e2e/tmp 28 | e2e/hyperlane_db_relayer 29 | e2e/examples/**/*.wasm 30 | 31 | deployment/results 32 | deployment/configs/local 33 | deployment/output_program 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![valence_header](https://github.com/user-attachments/assets/d49566c4-337b-44b1-94ce-c57439e15616) 2 | 3 | # Valence Protocol 4 | 5 | Valence is a cross-chain execution environment for developing trust-minimized multi-party programs. 6 | Valence programs use a resource model to structure control flow, compiling to target domains as a collection of application-specific co-processors. 7 | 8 | ## Status 9 | 10 | This project is under heavy development, however portions of the toolchain have stabilized to build programs for cross-chain liquidity deployment and multi-party agreements. Programs may be written in a constrained configuration language or using rust, though developer documentation for the latter is currently quite sparse. 11 | 12 | Valence currently supports connections to Cosmos and EVM domains, with SVM coming soon. Programs currently compile to WASM, with planned support for RISC zk circuits. 13 | -------------------------------------------------------------------------------- /audits/2025_01_zellic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/audits/2025_01_zellic.pdf -------------------------------------------------------------------------------- /contracts/accounts/base_account/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | unit-test = "test --lib" 4 | schema = "run --bin schema" 5 | integration-test = "test --lib integration_tests" 6 | -------------------------------------------------------------------------------- /contracts/accounts/base_account/README.md: -------------------------------------------------------------------------------- 1 | # Valence Base Account 2 | 3 | The **Valence Base Account** is the main type of account used by Valence programs. It suports an **admin** and a set of **approved libraries** that can execute arbitrary messages on behalf of the account. 4 | A typical use case is for a library, configured as approved library on a given account, to transfer part (or the entirety) of the account's token balance (native or CW20) to a target recipient. 5 | -------------------------------------------------------------------------------- /contracts/accounts/base_account/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_account_utils::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/accounts/base_account/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod state; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /contracts/accounts/base_account/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Empty}; 2 | use cw_storage_plus::Map; 3 | 4 | // Approved libraries that can execute actions on behalf of the account 5 | pub const APPROVED_LIBRARIES: Map = Map::new("libraries"); 6 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-interchain-account" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw2 = { workspace = true } 22 | schemars = { workspace = true } 23 | serde = { workspace = true } 24 | thiserror = { workspace = true } 25 | neutron-sdk = { workspace = true } 26 | serde_json = { workspace = true } 27 | valence-account-utils = { workspace = true } 28 | valence-ibc-utils = { workspace = true, features = ["neutron"] } 29 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/README.md: -------------------------------------------------------------------------------- 1 | # Valence Interchain Account 2 | 3 | The **Valence Interchain Account** is an account that allows executing messages on other Cosmos domains over IBC by creating and controlling an ICS-27 Interchain Account on a remote domain. 4 | A typical use case for libraries configured to work together with a **Valence Interchain Account** is to execute messages on Cosmos domains that don't have CosmWasm or other smart contract capabilities. 5 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_account_utils::ica::{ExecuteMsg, InstantiateMsg, QueryMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_ownable::OwnershipError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | OwnershipError(#[from] OwnershipError), 12 | 13 | #[error("Unauthorized: {0}")] 14 | Unauthorized(#[from] UnauthorizedReason), 15 | 16 | #[error("Cannot register ICA in {} state", current_state)] 17 | InvalidIcaState { current_state: String }, 18 | 19 | #[error("Not enough balance to pay the ICA registration fee")] 20 | NotEnoughBalanceForIcaRegistration, 21 | 22 | #[error("Cannot cover IBC fee")] 23 | CannotCoverIbcFee, 24 | } 25 | 26 | #[derive(Error, Debug, PartialEq)] 27 | pub enum UnauthorizedReason { 28 | #[error("Unauthorized: Not the admin")] 29 | NotAdmin, 30 | 31 | #[error("Unauthorized: Not an approved library")] 32 | NotApprovedLibrary, 33 | 34 | #[error("Unauthorized: Not the admin or an approved library")] 35 | NotAdminOrApprovedLibrary, 36 | } 37 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod error; 3 | pub mod state; 4 | -------------------------------------------------------------------------------- /contracts/accounts/interchain_account/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Empty}; 2 | use cw_storage_plus::{Item, Map}; 3 | use valence_account_utils::ica::{IcaState, RemoteDomainInfo}; 4 | 5 | // Approved libraries that can execute actions on behalf of the account 6 | pub const APPROVED_LIBRARIES: Map = Map::new("libraries"); 7 | // Remote domain information 8 | pub const REMOTE_DOMAIN_INFO: Item = Item::new("remote_domain_info"); 9 | // State of the ICA 10 | pub const ICA_STATE: Item = Item::new("ica_state"); 11 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-storage-account" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true, features = ["stargate"] } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw2 = { workspace = true } 22 | schemars = { workspace = true } 23 | serde = { workspace = true } 24 | thiserror = { workspace = true } 25 | valence-account-utils = { workspace = true } 26 | valence-middleware-utils = { workspace = true } 27 | 28 | [dev-dependencies] 29 | cw-multi-test = { workspace = true } 30 | cw-denom = { workspace = true } 31 | cw-ownable = { workspace = true } 32 | cw20 = { workspace = true } 33 | cw20-base = { workspace = true } 34 | getset = { workspace = true } 35 | itertools = { workspace = true } 36 | sha2 = { workspace = true } 37 | valence-account-utils = { workspace = true, features = ["testing"] } 38 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/README.md: -------------------------------------------------------------------------------- 1 | # Valence Storage Account 2 | 3 | The **Valence Storage Account** is a type of Valence account that can store 4 | Valence Type variants. 5 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_account_utils::msg::InstantiateMsg; 4 | use valence_storage_account::msg::{ExecuteMsg, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod state; 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cw_ownable::{cw_ownable_execute, cw_ownable_query}; 3 | use valence_middleware_utils::type_registry::types::ValenceType; 4 | 5 | #[cw_ownable_execute] 6 | #[cw_serde] 7 | pub enum ExecuteMsg { 8 | // Add library to approved list (only admin) 9 | ApproveLibrary { library: String }, 10 | // Remove library from approved list (only admin) 11 | RemoveLibrary { library: String }, 12 | // stores the given `ValenceType` variant under storage key `key` 13 | StoreValenceType { key: String, variant: ValenceType }, 14 | } 15 | 16 | #[cw_ownable_query] 17 | #[cw_serde] 18 | #[derive(QueryResponses)] 19 | pub enum QueryMsg { 20 | // Get list of approved libraries 21 | #[returns(Vec)] 22 | ListApprovedLibraries {}, 23 | // Get Valence type variant from storage 24 | #[returns(ValenceType)] 25 | QueryValenceType { key: String }, 26 | } 27 | -------------------------------------------------------------------------------- /contracts/accounts/storage_account/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Empty}; 2 | use cw_storage_plus::Map; 3 | use valence_middleware_utils::type_registry::types::ValenceType; 4 | 5 | /// Approved libraries that can execute actions on behalf of the account 6 | pub const APPROVED_LIBRARIES: Map = Map::new("libraries"); 7 | 8 | pub const VALENCE_TYPE_STORE: Map = Map::new("valence_type_store"); 9 | -------------------------------------------------------------------------------- /contracts/authorization/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/authorization/README.md: -------------------------------------------------------------------------------- 1 | # Authorization Contract 2 | 3 | The Authorization contract will be a single contract deployed on the main domain and that will define the authorizations of the top-level application, which can include libraries in different domains (chains). For each domain there will be one Processor (with its corresponding execution queues). The Authorization contract will connect to all of the Processors using a connector (e.g. Polytone, Hyperlane…) and will route the functions to be executed to the right domain. At the same time, for each other domain, we will also have a proxy contract in the main domain which will be forwarding the callbacks received from the processor on the other domain. 4 | -------------------------------------------------------------------------------- /contracts/authorization/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_authorization_utils::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/authorization/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod authorization; 2 | pub mod contract; 3 | pub mod domain; 4 | pub mod error; 5 | pub mod state; 6 | #[cfg(test)] 7 | mod tests; 8 | -------------------------------------------------------------------------------- /contracts/authorization/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Empty}; 2 | use cw_storage_plus::{Item, Map}; 3 | use valence_authorization_utils::{ 4 | authorization::Authorization, callback::ProcessorCallbackInfo, domain::ExternalDomain, 5 | zk_authorization::ZkAuthorization, 6 | }; 7 | 8 | pub const FIRST_OWNERSHIP: Item = Item::new("first_ownership"); 9 | pub const SUB_OWNERS: Map = Map::new("sub_owners"); 10 | pub const AUTHORIZATIONS: Map = Map::new("authorizations"); 11 | pub const VERIFICATION_GATEWAY: Item = Item::new("verification_gateway"); 12 | pub const ZK_AUTHORIZATIONS: Map = Map::new("zk_authorizations"); 13 | pub const PROCESSOR_ON_MAIN_DOMAIN: Item = Item::new("processor_on_main_domain"); 14 | pub const EXTERNAL_DOMAINS: Map = Map::new("external_domains"); 15 | pub const EXECUTION_ID: Item = Item::new("execution_id"); 16 | // To track how many of each authorization are pending completion 17 | pub const CURRENT_EXECUTIONS: Map = Map::new("current_executions"); 18 | // To track the last block execution for a specific registry of a ZK program 19 | pub const REGISTRY_LAST_BLOCK_EXECUTION: Map = Map::new("registry_last_block_execution"); 20 | // Track all the callbacks for the processor, if they haven't been processed yet they will be in ExecutionResult::InProcess 21 | pub const PROCESSOR_CALLBACKS: Map = Map::new("processor_callbacks"); 22 | -------------------------------------------------------------------------------- /contracts/authorization/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod builders; 2 | pub mod helpers; 3 | pub mod owner_actions; 4 | pub mod processor; 5 | pub mod user_actions; 6 | -------------------------------------------------------------------------------- /contracts/encoders/broker/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/encoders/broker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-encoder-broker" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | [features] 11 | # use library feature to disable all instantiate/execute/query exports 12 | library = [] 13 | 14 | [dependencies] 15 | cosmwasm-schema = { workspace = true } 16 | cosmwasm-std = { workspace = true } 17 | cw-ownable = { workspace = true } 18 | cw-storage-plus = { workspace = true } 19 | cw2 = { workspace = true } 20 | thiserror = { workspace = true } 21 | valence-encoder-utils = { workspace = true } 22 | -------------------------------------------------------------------------------- /contracts/encoders/broker/README.md: -------------------------------------------------------------------------------- 1 | # Valence Encoder Broker 2 | 3 | The **Valence Encoder Broker** is a smart contract that manages and multiplexes message encoders across different versions. It implements an ownership model and maintains a registry of specialized encoders for a specific virtual machine (e.g. EVM, SVM ...) according to their version. 4 | The broker serves one primary functions: it directs encoding requests to the appropriate encoder based on the version of the encoder requested -------------------------------------------------------------------------------- /contracts/encoders/broker/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_encoder_broker::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | execute: ExecuteMsg, 8 | query: QueryMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/encoders/broker/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_ownable::OwnershipError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | Ownership(#[from] OwnershipError), 12 | } 13 | -------------------------------------------------------------------------------- /contracts/encoders/broker/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod error; 3 | pub mod msg; 4 | pub mod state; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | -------------------------------------------------------------------------------- /contracts/encoders/broker/src/msg.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use cosmwasm_schema::{cw_serde, QueryResponses}; 4 | use cosmwasm_std::{Addr, Binary}; 5 | use cw_ownable::{cw_ownable_execute, cw_ownable_query}; 6 | use valence_encoder_utils::msg::{ProcessorMessageToDecode, ProcessorMessageToEncode}; 7 | 8 | #[cw_serde] 9 | pub struct InstantiateMsg { 10 | // Version -> Address 11 | pub encoders: HashMap, 12 | pub owner: String, 13 | } 14 | 15 | #[cw_ownable_execute] 16 | #[cw_serde] 17 | pub enum ExecuteMsg { 18 | // Version -> Address 19 | RegisterEncoder { version: String, address: String }, 20 | // Version 21 | RemoveEncoder { version: String }, 22 | } 23 | 24 | #[cw_ownable_query] 25 | #[cw_serde] 26 | #[derive(QueryResponses)] 27 | pub enum QueryMsg { 28 | #[returns(Addr)] 29 | Encoder { version: String }, 30 | #[returns(Vec<(String, Addr)>)] 31 | ListEncoders {}, 32 | // Checks that the library that we want to encode into exists for a specific encoder version 33 | #[returns(bool)] 34 | IsValidLibrary { 35 | encoder_version: String, 36 | library: String, 37 | }, 38 | // Encodes the message 39 | #[returns(Binary)] 40 | Encode { 41 | encoder_version: String, 42 | message: ProcessorMessageToEncode, 43 | }, 44 | // Decodes the message 45 | #[returns(Binary)] 46 | Decode { 47 | encoder_version: String, 48 | message: ProcessorMessageToDecode, 49 | }, 50 | } 51 | -------------------------------------------------------------------------------- /contracts/encoders/broker/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Map; 3 | 4 | // Encoders that we can redirect the encoding petitions to, key is a version and value is the address of the encoder contract 5 | pub const ENCODERS: Map = Map::new("encoders"); 6 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-evm-encoder-v1" 3 | version = "1.0.0" 4 | authors = { workspace = true } 5 | edition = { workspace = true } 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | [features] 11 | # use library feature to disable all instantiate/execute/query exports 12 | library = [] 13 | 14 | [dependencies] 15 | cosmwasm-schema = { workspace = true } 16 | cosmwasm-std = { workspace = true } 17 | cw-storage-plus = { workspace = true } 18 | cw-ownable = { workspace = true } 19 | cw2 = { workspace = true } 20 | cw-utils = { workspace = true } 21 | thiserror = { workspace = true } 22 | valence-encoder-utils = { workspace = true } 23 | valence-authorization-utils = { workspace = true } 24 | valence-library-utils = { workspace = true } 25 | valence-forwarder-library = { workspace = true } 26 | serde_json = { workspace = true } 27 | alloy-sol-types = "0.7.7" 28 | alloy-primitives = "0.7.7" 29 | strum = { version = "0.26.3", features = ["derive"] } 30 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/README.md: -------------------------------------------------------------------------------- 1 | # Valence EVM Encoder V1 2 | 3 | The Valence EVM Encoder is a specialized smart contract responsible for encoding instructions that will be executed by **EVM Valence Processors**. It utilizes the Ethereum Application Binary Interface (ABI) encoding standard to perform two critical encoding functions: 4 | 5 | Processor Message Encoding: Transforms high-level instructions into a format that can be interpreted by the **Valence Processor**. 6 | Library Function Encoding: Prepares function calls that will be executed by various **Valence libraries** within the EVM environment. 7 | 8 | This encoder ensures that complex, multi-step operations can be properly serialized and executed within the Ethereum Virtual Machine, maintaining type safety and execution integrity throughout the process. By handling both processor-level messages and library function calls, it creates a complete encoded instruction set that defines the entire execution flow. 9 | 10 | To do this, it will receive the **Subroutine** information, and the messages that need to be encoded according to that subroutine. The subroutine information will contain the **Library** and **Function** that is being targeted for each message so that the encoder can properly encode the message. 11 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cosmwasm_std::Empty; 3 | use valence_encoder_utils::msg::QueryMsg; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: Empty, 8 | execute: Empty, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/hyperlane/callback.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::SolValue; 2 | use cosmwasm_std::{Binary, HexBinary, StdError, StdResult}; 3 | use valence_encoder_utils::processor::solidity_types::Callback; 4 | 5 | pub fn decode(msg: &HexBinary) -> StdResult { 6 | // Decode the callback message 7 | let callback = Callback::abi_decode(msg.as_slice(), true) 8 | .map_err(|e| StdError::generic_err(e.to_string()))?; 9 | 10 | // Create the expected callback message for the authorization contract 11 | let processor_callback: valence_authorization_utils::msg::InternalAuthorizationMsg = 12 | callback.into(); 13 | 14 | // Wrap it in a Binary 15 | let binary = Binary::new( 16 | serde_json::to_vec(&processor_callback) 17 | .map_err(|e| StdError::generic_err(format!("Failed to serialize callback: {}", e)))?, 18 | ); 19 | 20 | Ok(binary) 21 | } 22 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/hyperlane/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod callback; 2 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/evict_msgs.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::SolValue; 2 | use cosmwasm_std::{Binary, StdResult}; 3 | use valence_authorization_utils::authorization::Priority; 4 | 5 | use valence_encoder_utils::processor::solidity_types::{ 6 | EvictMsgs, ProcessorMessage, ProcessorMessageType, 7 | }; 8 | 9 | pub fn encode(queue_position: u64, priority: Priority) -> StdResult { 10 | let message = EvictMsgs { 11 | queuePosition: queue_position, 12 | priority: priority.into(), 13 | }; 14 | 15 | let processor_message = ProcessorMessage { 16 | messageType: ProcessorMessageType::EvictMsgs, 17 | message: message.abi_encode().into(), 18 | }; 19 | 20 | Ok(Binary::new(processor_message.abi_encode())) 21 | } 22 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/insert_msgs.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::SolValue; 2 | use cosmwasm_std::{Binary, StdError, StdResult}; 3 | use valence_authorization_utils::authorization::{Priority, Subroutine}; 4 | use valence_encoder_utils::{ 5 | msg::Message, 6 | processor::solidity_types::{InsertMsgs, ProcessorMessage, ProcessorMessageType}, 7 | }; 8 | 9 | use crate::{encode_subroutine, EVMLibrary}; 10 | 11 | pub fn encode( 12 | execution_id: u64, 13 | queue_position: u64, 14 | priority: Priority, 15 | subroutine: Subroutine, 16 | expiration_time: Option, 17 | messages: Vec, 18 | ) -> StdResult { 19 | let message = InsertMsgs { 20 | executionId: execution_id, 21 | queuePosition: queue_position, 22 | priority: priority.into(), 23 | subroutine: encode_subroutine(subroutine)?, 24 | expirationTime: expiration_time.unwrap_or(0), 25 | messages: messages 26 | .iter() 27 | .map(|m| { 28 | let encoded = EVMLibrary::encode_message(&m.library, &m.data)?; 29 | Ok(encoded.into()) 30 | }) 31 | .collect::, StdError>>()?, 32 | }; 33 | 34 | let processor_message = ProcessorMessage { 35 | messageType: ProcessorMessageType::InsertMsgs, 36 | message: message.abi_encode().into(), 37 | }; 38 | 39 | Ok(Binary::new(processor_message.abi_encode())) 40 | } 41 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod evict_msgs; 2 | pub mod insert_msgs; 3 | pub mod pause; 4 | pub mod resume; 5 | pub mod send_msgs; 6 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/pause.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::Bytes; 2 | use alloy_sol_types::SolValue; 3 | use cosmwasm_std::Binary; 4 | use valence_encoder_utils::processor::solidity_types::{ProcessorMessage, ProcessorMessageType}; 5 | 6 | pub fn encode() -> Binary { 7 | let processor_message = ProcessorMessage { 8 | messageType: ProcessorMessageType::Pause, 9 | // No data is required for the Pause message 10 | message: Bytes::new(), 11 | }; 12 | 13 | Binary::new(processor_message.abi_encode()) 14 | } 15 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/resume.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::Bytes; 2 | use alloy_sol_types::SolValue; 3 | use cosmwasm_std::Binary; 4 | use valence_encoder_utils::processor::solidity_types::{ProcessorMessage, ProcessorMessageType}; 5 | 6 | pub fn encode() -> Binary { 7 | let processor_message = ProcessorMessage { 8 | messageType: ProcessorMessageType::Resume, 9 | // No data is required for the Resume message 10 | message: Bytes::new(), 11 | }; 12 | 13 | Binary::new(processor_message.abi_encode()) 14 | } 15 | -------------------------------------------------------------------------------- /contracts/encoders/evm-encoder/src/processor/send_msgs.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::SolValue; 2 | use cosmwasm_std::{Binary, StdError, StdResult}; 3 | use valence_authorization_utils::authorization::{Priority, Subroutine}; 4 | use valence_encoder_utils::{ 5 | msg::Message, 6 | processor::solidity_types::{ProcessorMessage, ProcessorMessageType, SendMsgs}, 7 | }; 8 | 9 | use crate::{encode_subroutine, EVMLibrary}; 10 | 11 | pub fn encode( 12 | execution_id: u64, 13 | priority: Priority, 14 | subroutine: Subroutine, 15 | expiration_time: Option, 16 | messages: Vec, 17 | ) -> StdResult { 18 | let message = SendMsgs { 19 | executionId: execution_id, 20 | priority: priority.into(), 21 | subroutine: encode_subroutine(subroutine)?, 22 | expirationTime: expiration_time.unwrap_or(0), 23 | messages: messages 24 | .iter() 25 | .map(|m| { 26 | let encoded = EVMLibrary::encode_message(&m.library, &m.data)?; 27 | Ok(encoded.into()) 28 | }) 29 | .collect::, StdError>>()?, 30 | }; 31 | 32 | let processor_message = ProcessorMessage { 33 | messageType: ProcessorMessageType::SendMsgs, 34 | message: message.abi_encode().into(), 35 | }; 36 | 37 | Ok(Binary::new(processor_message.abi_encode())) 38 | } 39 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-lper/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-lper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-astroport-lper" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | valence-astroport-utils = { workspace = true } 24 | 25 | [dev-dependencies] 26 | valence-astroport-utils = { workspace = true, features = ["testing"] } 27 | cw20 = { workspace = true } 28 | valence-account-utils = { workspace = true } 29 | neutron-test-tube = { workspace = true } 30 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-lper/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_astroport_lper::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-lper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod astroport_cw20; 2 | pub mod astroport_native; 3 | pub mod contract; 4 | pub mod msg; 5 | #[cfg(test)] 6 | mod tests; 7 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-withdrawer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-withdrawer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-astroport-withdrawer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw20 = { workspace = true } 21 | valence-macros = { workspace = true } 22 | valence-library-utils = { workspace = true } 23 | valence-library-base = { workspace = true } 24 | valence-astroport-utils = { workspace = true } 25 | 26 | [dev-dependencies] 27 | valence-astroport-utils = { workspace = true, features = ["testing"] } 28 | cw20 = { workspace = true } 29 | valence-account-utils = { workspace = true } 30 | neutron-test-tube = { workspace = true } 31 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-withdrawer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_astroport_withdrawer::msg::{ 4 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 5 | }; 6 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/astroport-withdrawer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod astroport_cw20; 2 | pub mod astroport_native; 3 | pub mod contract; 4 | pub mod msg; 5 | #[cfg(test)] 6 | mod tests; 7 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-clearing-queue" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw-utils = { workspace = true } 22 | valence-macros = { workspace = true } 23 | valence-library-utils = { workspace = true } 24 | valence-library-base = { workspace = true } 25 | valence-processor-utils = { workspace = true } 26 | 27 | [dev-dependencies] 28 | cw-multi-test = { workspace = true } 29 | valence-account-utils = { workspace = true } 30 | valence-library-utils = { workspace = true, features = ["testing"] } 31 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_clearing_queue::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod state; 4 | 5 | #[cfg(test)] 6 | mod testing; 7 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, BlockInfo, Coin, Uint64}; 3 | use cw_storage_plus::Map; 4 | use valence_processor_utils::queue::QueueMap; 5 | 6 | /// map of registered obligation id -> settlement status. 7 | /// this map is also used for obligation registration checks to 8 | /// ensure that any given obligation can be registered at most once. 9 | pub const OBLIGATION_ID_TO_STATUS_MAP: Map = Map::new("reg_obl_id"); 10 | 11 | /// fifo queue storing the pending obligations 12 | pub const CLEARING_QUEUE: QueueMap = QueueMap::new( 13 | "clearing_queue", 14 | "clearing_queue_start_index", 15 | "clearing_queue_end_index", 16 | ); 17 | 18 | /// obligation status enum 19 | #[cw_serde] 20 | pub enum ObligationStatus { 21 | InQueue, 22 | Processed, 23 | Error(String), 24 | } 25 | 26 | /// unsettled liability sitting in the clearing queue 27 | #[cw_serde] 28 | pub struct WithdrawalObligation { 29 | /// where the payout is to be routed 30 | pub recipient: Addr, 31 | /// what is owed to the recipient 32 | pub payout_coin: Coin, 33 | /// some unique identifier for the request 34 | pub id: Uint64, 35 | /// block when registration was enqueued 36 | pub enqueue_block: BlockInfo, 37 | } 38 | -------------------------------------------------------------------------------- /contracts/libraries/clearing-queue/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod builder; 2 | pub mod suite; 3 | mod tests; 4 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-staker/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-staker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-drop-liquid-staker" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | valence-liquid-staking-utils = { workspace = true } 28 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-staker/README.md: -------------------------------------------------------------------------------- 1 | # Valence Drop Liquid Staker library 2 | 3 | The **Valence Drop Liquid Staker** library allows to **liquid stake** an asset from an **input account** in the [Drop protocol](https://docs.drop.money/) and deposit the liquid staking derivate into the **output account**. It is typically used as part of a **Valence Program**. In that context, a **Processor** contract will be the main contract interacting with the Forwarder library. 4 | 5 | ## High-level flow 6 | 7 | ```mermaid 8 | --- 9 | title: Drop Liquid Staker Library 10 | --- 11 | graph LR 12 | IA((Input 13 | Account)) 14 | CC((Drop Core 15 | Contract)) 16 | OA((Output 17 | Account)) 18 | P[Processor] 19 | S[Drop Liquid Staker 20 | Library] 21 | P -- 1/Liquid Stake --> S 22 | S -- 2/Query balance --> IA 23 | S -- 3/Do Liquid 24 | Stake funds --> IA 25 | IA -- 4/Liquid Stake 26 | funds --> CC 27 | CC -- 5/Send LS 28 | derivative --> OA 29 | ``` 30 | 31 | ## Configuration 32 | 33 | The library is configured on instantiation via the `LibraryConfig` type. 34 | 35 | ```rust 36 | pub struct LibraryConfig { 37 | pub input_addr: LibraryAccountType, 38 | pub output_addr: LibraryAccountType, 39 | // Address of the liquid staker contract (drop core contract) 40 | pub liquid_staker_addr: String, 41 | // Denom of the asset we are going to liquid stake 42 | pub denom: String, 43 | } 44 | ``` 45 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-staker/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_drop_liquid_staker::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-staker/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-unstaker/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-unstaker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-drop-liquid-unstaker" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | valence-liquid-staking-utils = { workspace = true } 28 | cw721 = { workspace = true } 29 | cw721-base = { workspace = true } 30 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-unstaker/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_drop_liquid_unstaker::msg::{ 4 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 5 | }; 6 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/drop-liquid-unstaker/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/forwarder/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/forwarder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-forwarder-library" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw-utils = { workspace = true } 22 | getset = { workspace = true } 23 | schemars = { workspace = true } 24 | serde = { workspace = true } 25 | thiserror = { workspace = true } 26 | valence-macros = { workspace = true } 27 | valence-library-utils = { workspace = true } 28 | valence-library-base = { workspace = true } 29 | 30 | [dev-dependencies] 31 | cw-multi-test = { workspace = true } 32 | cw-ownable = { workspace = true } 33 | cw20 = { workspace = true } 34 | cw20-base = { workspace = true } 35 | sha2 = { workspace = true } 36 | valence-account-utils = { workspace = true } 37 | valence-library-utils = { workspace = true, features = ["testing"] } 38 | -------------------------------------------------------------------------------- /contracts/libraries/forwarder/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_forwarder_library::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/forwarder/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod state; 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | -------------------------------------------------------------------------------- /contracts/libraries/forwarder/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::BlockInfo; 2 | use cw_storage_plus::Item; 3 | 4 | pub const LAST_SUCCESSFUL_FORWARD: Item = Item::new("last_successful_forward"); 5 | -------------------------------------------------------------------------------- /contracts/libraries/generic-ibc-transfer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/generic-ibc-transfer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-generic-ibc-transfer-library" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw-utils = { workspace = true } 22 | getset = { workspace = true } 23 | schemars = { workspace = true } 24 | serde = { workspace = true } 25 | thiserror = { workspace = true } 26 | valence-macros = { workspace = true } 27 | valence-ibc-utils = { workspace = true } 28 | valence-library-utils = { workspace = true } 29 | valence-library-base = { workspace = true } 30 | 31 | [dev-dependencies] 32 | cw-multi-test = { workspace = true } 33 | cw20 = { workspace = true } 34 | cw20-base = { workspace = true } 35 | sha2 = { workspace = true } 36 | valence-account-utils = { workspace = true } 37 | valence-library-utils = { workspace = true, features = ["testing"] } 38 | -------------------------------------------------------------------------------- /contracts/libraries/generic-ibc-transfer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_generic_ibc_transfer_library::msg::{ 4 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 5 | }; 6 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/generic-ibc-transfer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /contracts/libraries/ica-cctp-transfer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/ica-cctp-transfer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-ica-cctp-transfer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | valence-ibc-utils = { workspace = true } 28 | prost = { workspace = true, features = ["derive"] } 29 | -------------------------------------------------------------------------------- /contracts/libraries/ica-cctp-transfer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_ica_cctp_transfer::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/ica-cctp-transfer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod proto; 4 | -------------------------------------------------------------------------------- /contracts/libraries/ica-cctp-transfer/src/proto.rs: -------------------------------------------------------------------------------- 1 | // The proto message that is going to be executed on Noble 2 | #[allow(clippy::derive_partial_eq_without_eq)] 3 | #[derive(Clone, PartialEq, ::prost::Message)] 4 | pub struct MsgDepositForBurn { 5 | /// the signer address 6 | #[prost(string, tag = "1")] 7 | pub from: ::prost::alloc::string::String, 8 | /// the amount to bridge 9 | #[prost(string, tag = "2")] 10 | pub amount: ::prost::alloc::string::String, 11 | /// the destination domain 12 | #[prost(uint32, tag = "3")] 13 | pub destination_domain: u32, 14 | /// the mint recipient address 15 | #[prost(bytes, tag = "4")] 16 | pub mint_recipient: ::prost::alloc::vec::Vec, 17 | /// the token denom that is being bridged 18 | #[prost(string, tag = "5")] 19 | pub burn_token: ::prost::alloc::string::String, 20 | } 21 | 22 | impl ::prost::Name for MsgDepositForBurn { 23 | const NAME: &'static str = "MsgDepositForBurn"; 24 | const PACKAGE: &'static str = "circle.cctp.v1"; 25 | fn full_name() -> ::prost::alloc::string::String { 26 | "circle.cctp.v1.MsgDepositForBurn".into() 27 | } 28 | fn type_url() -> ::prost::alloc::string::String { 29 | "/circle.cctp.v1.MsgDepositForBurn".into() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/libraries/ica-ibc-transfer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/ica-ibc-transfer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-ica-ibc-transfer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | valence-ibc-utils = { workspace = true } 28 | cosmos-sdk-proto = { version = "0.26.1", default-features = false } 29 | ibc-proto = { version = "0.51.1", default-features = false } 30 | 31 | [dev-dependencies] 32 | cw-multi-test = { workspace = true } 33 | valence-account-utils = { workspace = true } 34 | valence-library-utils = { workspace = true, features = ["testing"] } 35 | -------------------------------------------------------------------------------- /contracts/libraries/ica-ibc-transfer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_ica_ibc_transfer::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 4 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/ica-ibc-transfer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /contracts/libraries/mars-lending/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/mars-lending/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-mars-lending" 3 | authors.workspace = true 4 | edition.workspace = true 5 | license.workspace = true 6 | version.workspace = true 7 | repository.workspace = true 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | valence-lending-utils = { workspace = true } 28 | valence-account-utils = { workspace = true } 29 | -------------------------------------------------------------------------------- /contracts/libraries/mars-lending/README.md: -------------------------------------------------------------------------------- 1 | # Mars Lending library 2 | 3 | The **Valence Mars Lending** library facilitates lending operations on Mars. It allows users to create and fund a Mars credit account from their input account. This credit account, which remains owned by the input account, then manages the **lending** of these assets. Additionally, the library supports the **withdrawal** of lent assets from the credit account, automatically depositing the retrieved tokens into the **output account** 4 | 5 | ## Configuration 6 | 7 | The library is configured on instantiation via the `LibraryConfig` type. 8 | 9 | ```rust 10 | pub struct LibraryConfig { 11 | // Address of the input account 12 | pub input_addr: LibraryAccountType, 13 | /// Address of the output account 14 | pub output_addr: LibraryAccountType, 15 | // Address of the credit manager contract 16 | pub credit_manager_addr: String, 17 | // Denom of the asset we are going to lend 18 | pub denom: String, 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /contracts/libraries/mars-lending/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_mars_lending::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/mars-lending/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ibc-transfer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ibc-transfer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_neutron_ibc_transfer_library::msg::{ 5 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | }; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ibc-transfer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | 3 | pub mod msg { 4 | pub use valence_generic_ibc_transfer_library::msg::{ 5 | Config, FunctionMsgs, IbcTransferAmount, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | RemoteChainInfo, 7 | }; 8 | } 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ic-querier/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ic-querier/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-neutron-ic-querier" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-storage-account = { workspace = true } 21 | valence-macros = { workspace = true } 22 | valence-library-utils = { workspace = true } 23 | valence-library-base = { workspace = true } 24 | neutron-sdk = { workspace = true } 25 | serde-json-wasm = { version = "1.0.0", default-features = false } 26 | cw-storage-plus = { workspace = true } 27 | valence-middleware-broker = { workspace = true } 28 | valence-middleware-utils = { workspace = true } 29 | cw-utils = { workspace = true } 30 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ic-querier/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_neutron_ic_querier::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/neutron-ic-querier/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-lper/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-lper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-osmosis-cl-lper" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | osmosis-std = { workspace = true } 24 | osmosis-std-derive = { workspace = true } 25 | valence-account-utils = { workspace = true } 26 | valence-osmosis-utils = { workspace = true } 27 | cw-storage-plus = { workspace = true } 28 | serde = { workspace = true } 29 | schemars = { workspace = true } 30 | cw-utils = { workspace = true } 31 | serde_json = { workspace = true } 32 | 33 | [dev-dependencies] 34 | cw20 = { workspace = true } 35 | osmosis-test-tube = { workspace = true } 36 | valence-osmosis-utils = { workspace = true, features = ["testing"] } 37 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-lper/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_osmosis_cl_lper::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-lper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | #[cfg(test)] 4 | mod testing; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-lper/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod test_suite; 3 | #[cfg(test)] 4 | mod tests; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-withdrawer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-withdrawer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-osmosis-cl-withdrawer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | osmosis-std = { workspace = true } 24 | osmosis-std-derive = { workspace = true } 25 | valence-account-utils = { workspace = true } 26 | valence-osmosis-utils = { workspace = true } 27 | cw-storage-plus = { workspace = true } 28 | serde = { workspace = true } 29 | schemars = { workspace = true } 30 | cw-utils = { workspace = true } 31 | serde_json = { workspace = true } 32 | 33 | [dev-dependencies] 34 | cw20 = { workspace = true } 35 | osmosis-test-tube = { workspace = true } 36 | valence-osmosis-utils = { workspace = true, features = ["testing"] } 37 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-withdrawer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_osmosis_cl_withdrawer::msg::{ 5 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | }; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-withdrawer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | #[cfg(test)] 4 | mod testing; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-cl-withdrawer/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | use osmosis_std::types::osmosis::concentratedliquidity::v1beta1::{ 2 | MsgTransferPositions, MsgTransferPositionsResponse, 3 | }; 4 | use osmosis_test_tube::{fn_execute, Module, Runner}; 5 | 6 | #[cfg(test)] 7 | mod test_suite; 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub struct ConcentratedLiquidityExts<'a, R: Runner<'a>> { 12 | runner: &'a R, 13 | } 14 | 15 | impl<'a, R: Runner<'a>> Module<'a, R> for ConcentratedLiquidityExts<'a, R> { 16 | fn new(runner: &'a R) -> Self { 17 | Self { runner } 18 | } 19 | } 20 | 21 | impl<'a, R> ConcentratedLiquidityExts<'a, R> 22 | where 23 | R: Runner<'a>, 24 | { 25 | // transfer CL position 26 | fn_execute! { pub transfer_positions: MsgTransferPositions => MsgTransferPositionsResponse } 27 | } 28 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-osmosis-gamm-lper" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | osmosis-std = { workspace = true } 24 | valence-account-utils = { workspace = true } 25 | valence-osmosis-utils = { workspace = true } 26 | 27 | [dev-dependencies] 28 | cw20 = { workspace = true } 29 | osmosis-test-tube = { workspace = true } 30 | valence-osmosis-utils = { workspace = true, features = ["testing"] } 31 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/README.md: -------------------------------------------------------------------------------- 1 | # Osmosis GAMM liquidity provider library 2 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_osmosis_gamm_lper::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | #[cfg(test)] 4 | mod testing; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-lper/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod test_suite; 3 | #[cfg(test)] 4 | mod tests; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-osmosis-gamm-withdrawer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | osmosis-std = { workspace = true } 24 | valence-account-utils = { workspace = true } 25 | valence-osmosis-utils = { workspace = true } 26 | 27 | [dev-dependencies] 28 | cw20 = { workspace = true } 29 | osmosis-test-tube = { workspace = true } 30 | valence-osmosis-utils = { workspace = true, features = ["testing"] } 31 | valence-osmosis-gamm-lper = { workspace = true } 32 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/README.md: -------------------------------------------------------------------------------- 1 | # Osmosis GAMM liquidity withdrawer library 2 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_osmosis_gamm_withdrawer::msg::{ 5 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | }; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | #[cfg(test)] 4 | mod testing; 5 | -------------------------------------------------------------------------------- /contracts/libraries/osmosis-gamm-withdrawer/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod test_suite; 3 | #[cfg(test)] 4 | mod tests; 5 | -------------------------------------------------------------------------------- /contracts/libraries/reverse-splitter/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/reverse-splitter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-reverse-splitter-library" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw-utils = { workspace = true } 22 | getset = { workspace = true } 23 | schemars = { workspace = true } 24 | serde = { workspace = true } 25 | thiserror = { workspace = true } 26 | valence-macros = { workspace = true } 27 | valence-library-utils = { workspace = true } 28 | valence-library-base = { workspace = true } 29 | 30 | [dev-dependencies] 31 | cw-multi-test = { workspace = true } 32 | cw-ownable = { workspace = true } 33 | cw20 = { workspace = true } 34 | cw20-base = { workspace = true } 35 | sha2 = { workspace = true } 36 | valence-library-utils = { workspace = true, features = ["testing"] } 37 | valence-test-dynamic-ratio = { workspace = true } 38 | -------------------------------------------------------------------------------- /contracts/libraries/reverse-splitter/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_reverse_splitter_library::msg::{ 5 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | }; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/reverse-splitter/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /contracts/libraries/splitter/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/splitter/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_splitter_library::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/splitter/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-lper/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-lper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-supervaults-lper" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | valence-account-utils = { workspace = true } 24 | valence-supervaults-utils = { workspace = true } 25 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-lper/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_supervaults_lper::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-lper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-withdrawer/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-withdrawer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-supervaults-withdrawer" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | valence-macros = { workspace = true } 21 | valence-library-utils = { workspace = true } 22 | valence-library-base = { workspace = true } 23 | valence-account-utils = { workspace = true } 24 | valence-supervaults-utils = { workspace = true } 25 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-withdrawer/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_supervaults_withdrawer::msg::{ 5 | FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg, 6 | }; 7 | 8 | fn main() { 9 | write_api! { 10 | instantiate: InstantiateMsg, 11 | execute: ExecuteMsg, 12 | query: QueryMsg, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/libraries/supervaults-withdrawer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | -------------------------------------------------------------------------------- /contracts/libraries/template/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/libraries/template/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-template-library" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | cw-utils = { workspace = true } 22 | getset = { workspace = true } 23 | schemars = { workspace = true } 24 | serde = { workspace = true } 25 | thiserror = { workspace = true } 26 | valence-macros = { workspace = true } 27 | valence-library-utils = { workspace = true } 28 | valence-library-base = { workspace = true } 29 | 30 | [dev-dependencies] 31 | cw-multi-test = { workspace = true } 32 | cw-ownable = { workspace = true } 33 | valence-library-utils = { workspace = true, features = ["testing"] } 34 | -------------------------------------------------------------------------------- /contracts/libraries/template/README.md: -------------------------------------------------------------------------------- 1 | # Template library 2 | 3 | The Template library is a template for creating new libraries (copy and rename the library name). 4 | -------------------------------------------------------------------------------- /contracts/libraries/template/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::{ExecuteMsg, InstantiateMsg}; 4 | use valence_template_library::msg::{FunctionMsgs, LibraryConfig, LibraryConfigUpdate, QueryMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: QueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/libraries/template/src/lib.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::Item; 2 | use msg::Config2; 3 | 4 | pub mod contract; 5 | pub mod msg; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | 10 | pub(crate) const CONFIG2: Item = Item::new("config2"); 11 | -------------------------------------------------------------------------------- /contracts/middleware/README.md: -------------------------------------------------------------------------------- 1 | # Valence Middleware 2 | 3 | The Valence Middleware is a set of components that provide 4 | a unified interface for the Valence Type system. 5 | 6 | There are two core elements to the middleware: 7 | 8 | - [brokers](./broker/README.md) 9 | - [type registries](./type-registries/README.md) 10 | -------------------------------------------------------------------------------- /contracts/middleware/asserter/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/middleware/asserter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-middleware-asserter" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | valence-middleware-utils = { workspace = true } 22 | cw2 = { workspace = true } 23 | valence-storage-account = { workspace = true } 24 | 25 | [dev-dependencies] 26 | cw-multi-test = { workspace = true } 27 | valence-account-utils = { workspace = true } 28 | -------------------------------------------------------------------------------- /contracts/middleware/asserter/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_middleware_asserter::msg::{ExecuteMsg, InstantiateMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | execute: ExecuteMsg, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /contracts/middleware/asserter/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | 4 | #[cfg(test)] 5 | mod testing; 6 | -------------------------------------------------------------------------------- /contracts/middleware/asserter/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::Binary; 3 | use valence_middleware_utils::type_registry::queries::ValencePrimitive; 4 | 5 | #[cw_serde] 6 | pub struct InstantiateMsg {} 7 | 8 | #[cw_serde] 9 | pub enum ExecuteMsg { 10 | Assert { 11 | a: AssertionValue, 12 | predicate: Predicate, 13 | b: AssertionValue, 14 | }, 15 | } 16 | 17 | #[cw_serde] 18 | pub enum Predicate { 19 | LT, 20 | LTE, 21 | EQ, 22 | GT, 23 | GTE, 24 | } 25 | 26 | impl Predicate { 27 | pub fn eval(&self, a: T, b: T) -> bool { 28 | match self { 29 | Predicate::LT => a < b, 30 | Predicate::LTE => a <= b, 31 | Predicate::EQ => a == b, 32 | Predicate::GT => a > b, 33 | Predicate::GTE => a >= b, 34 | } 35 | } 36 | } 37 | 38 | #[cw_serde] 39 | pub struct QueryInfo { 40 | // addr of the storage account 41 | pub storage_account: String, 42 | // key to access the value in the storage account 43 | pub storage_slot_key: String, 44 | // b64 encoded query 45 | pub query: Binary, 46 | } 47 | 48 | #[cw_serde] 49 | pub enum AssertionValue { 50 | // storage account slot query 51 | Variable(QueryInfo), 52 | // constant valence primitive value 53 | Constant(ValencePrimitive), 54 | } 55 | -------------------------------------------------------------------------------- /contracts/middleware/broker/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/middleware/broker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-middleware-broker" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | prost = { workspace = true, features = ["prost-derive"] } 21 | prost-types = { workspace = true } 22 | neutron-sdk = { workspace = true } 23 | serde-json-wasm = { version = "1.0.0" } 24 | thiserror = { workspace = true } 25 | serde_json = { workspace = true } 26 | cw-storage-plus = { workspace = true } 27 | valence-middleware-utils = { workspace = true } 28 | semver = { workspace = true } 29 | cw2 = { workspace = true } 30 | 31 | [dev-dependencies] 32 | cw-multi-test = { workspace = true } 33 | valence-middleware-osmosis = { workspace = true } 34 | osmosis-std = { workspace = true } 35 | osmosis-std-derive = { workspace = true } 36 | -------------------------------------------------------------------------------- /contracts/middleware/broker/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_middleware_broker::msg::{ExecuteMsg, InstantiateMsg}; 3 | use valence_middleware_utils::type_registry::types::RegistryQueryMsg; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: RegistryQueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/middleware/broker/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod state; 4 | 5 | #[cfg(test)] 6 | mod testing; 7 | -------------------------------------------------------------------------------- /contracts/middleware/broker/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::Addr; 3 | use valence_middleware_utils::type_registry::types::RegistryQueryMsg; 4 | 5 | #[cw_serde] 6 | pub struct InstantiateMsg {} 7 | 8 | #[cw_serde] 9 | pub enum ExecuteMsg { 10 | SetRegistry { version: String, address: String }, 11 | } 12 | 13 | #[cw_serde] 14 | pub struct QueryMsg { 15 | pub registry_version: Option, 16 | pub query: RegistryQueryMsg, 17 | } 18 | 19 | #[cw_serde] 20 | pub struct TypeRegistry { 21 | // address of the instantiated registry 22 | pub registry_address: Addr, 23 | // semver 24 | pub version: String, 25 | } 26 | -------------------------------------------------------------------------------- /contracts/middleware/broker/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::{Item, Map}; 2 | 3 | use crate::msg::TypeRegistry; 4 | 5 | // semver -> TypeRegistry 6 | pub const ACTIVE_REGISTRIES: Map = Map::new("active_registries"); 7 | pub const LATEST: Item = Item::new("latest"); 8 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-middleware-osmosis" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | cw-ownable = { workspace = true } 20 | osmosis-std = { workspace = true } 21 | osmosis-std-derive = { workspace = true } 22 | prost = { workspace = true, features = ["prost-derive"] } 23 | prost-types = { workspace = true } 24 | neutron-sdk = { workspace = true } 25 | serde-json-wasm = { version = "1.0.0" } 26 | thiserror = { workspace = true } 27 | serde_json = { workspace = true } 28 | cw-storage-plus = { workspace = true } 29 | valence-middleware-utils = { workspace = true } 30 | cw2 = { workspace = true } 31 | 32 | [dev-dependencies] 33 | osmosis-test-tube = { workspace = true } 34 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_middleware_utils::type_registry::types::{ 3 | RegistryExecuteMsg, RegistryInstantiateMsg, RegistryQueryMsg, 4 | }; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: RegistryInstantiateMsg, 9 | execute: RegistryExecuteMsg, 10 | query: RegistryQueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/contract.rs: -------------------------------------------------------------------------------- 1 | use crate::definitions::handle_query; 2 | #[cfg(not(feature = "library"))] 3 | use cosmwasm_std::entry_point; 4 | use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult}; 5 | use cw2::set_contract_version; 6 | use valence_middleware_utils::type_registry::types::{ 7 | RegistryExecuteMsg, RegistryInstantiateMsg, RegistryQueryMsg, 8 | }; 9 | 10 | // version info for migration info 11 | const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); 12 | const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); 13 | 14 | #[cfg_attr(not(feature = "library"), entry_point)] 15 | pub fn instantiate( 16 | deps: DepsMut, 17 | _env: Env, 18 | _info: MessageInfo, 19 | _msg: RegistryInstantiateMsg, 20 | ) -> Result { 21 | set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; 22 | Ok(Response::default()) 23 | } 24 | 25 | #[cfg_attr(not(feature = "library"), entry_point)] 26 | pub fn execute( 27 | _deps: DepsMut, 28 | _env: Env, 29 | _info: MessageInfo, 30 | _msg: RegistryExecuteMsg, 31 | ) -> Result { 32 | unimplemented!("execute is disabled") 33 | } 34 | 35 | #[cfg_attr(not(feature = "library"), entry_point)] 36 | pub fn query(_deps: Deps, _env: Env, msg: RegistryQueryMsg) -> StdResult { 37 | handle_query(msg) 38 | } 39 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/definitions/bank_balance/mod.rs: -------------------------------------------------------------------------------- 1 | use osmosis_std::types::cosmos::bank::v1beta1::QueryBalanceResponse; 2 | 3 | pub mod icq_adapter; 4 | pub mod valence_adapter; 5 | 6 | const ADDR_KEY: &str = "addr"; 7 | const DENOM_KEY: &str = "denom"; 8 | 9 | pub struct OsmosisBankBalance(pub QueryBalanceResponse); 10 | 11 | impl From for OsmosisBankBalance { 12 | fn from(balance: QueryBalanceResponse) -> Self { 13 | Self(balance) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/definitions/mod.rs: -------------------------------------------------------------------------------- 1 | use bank_balance::OsmosisBankBalance; 2 | use gamm_pool::OsmosisXykPool; 3 | use osmosis_std::types::{ 4 | cosmos::bank::v1beta1::QueryBalanceResponse, osmosis::gamm::v1beta1::Pool, 5 | }; 6 | use valence_middleware_utils::register_types; 7 | 8 | pub mod bank_balance; 9 | pub mod gamm_pool; 10 | 11 | register_types! { 12 | "/osmosis.gamm.v1beta1.Pool" => { 13 | // in the future, further plugins can be added here to handle type-specific 14 | // logic. e.g. a migration plugin that would handle the type conversion 15 | // from the type defined in the previous (semver) type registry: 16 | // migrate_from: osmo_25_0_0::Pool, 17 | // or maybe some kind of encoder/decoder plugin that could be defined along 18 | // the lines of: 19 | // evm_encoder: EvmTypeEncoder, 20 | native_type: Pool, 21 | adapter: OsmosisXykPool, 22 | to_valence: ValenceType::XykPool, 23 | }, 24 | "/cosmos.bank.v1beta1.QueryBalanceResponse" => { 25 | native_type: QueryBalanceResponse, 26 | adapter: OsmosisBankBalance, 27 | to_valence: ValenceType::BankBalance, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod definitions; 3 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-verification-gateway" 3 | version = { workspace = true } 4 | authors = { workspace = true } 5 | edition = { workspace = true } 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw2 = { workspace = true } 20 | thiserror = { workspace = true } 21 | sp1-verifier = "4.2.0" 22 | 23 | [dev-dependencies] 24 | bincode = "1.3.3" 25 | sp1-sdk = { version = "4.2.0", default-features = false } 26 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/README.md: -------------------------------------------------------------------------------- 1 | # Verification Gateway 2 | 3 | This contract is a simple contract that will perform the verification of ZK proofs. It's separated into a singleton contract to decouple the verification from the rest of the contracts and therefore can be extended with different verifying methods for different types of proofs. 4 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_verification_gateway::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | execute: ExecuteMsg, 8 | query: QueryMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | } 9 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod error; 3 | pub mod msg; 4 | -------------------------------------------------------------------------------- /contracts/middleware/verification-gateway/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::Binary; 3 | 4 | #[cw_serde] 5 | pub struct InstantiateMsg {} 6 | 7 | #[cw_serde] 8 | pub enum ExecuteMsg {} 9 | 10 | #[cw_serde] 11 | #[derive(QueryResponses)] 12 | pub enum QueryMsg { 13 | #[returns(bool)] 14 | VerifyProof { 15 | vk: Binary, 16 | proof: Binary, 17 | inputs: Binary, 18 | }, 19 | } 20 | -------------------------------------------------------------------------------- /contracts/processor/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/processor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-processor" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "CosmWasm Smart Contract that executes the messages on each library/account of the program by iterating over queues when ticked" 7 | 8 | [lib] 9 | crate-type = ["cdylib", "rlib"] 10 | 11 | [features] 12 | library = [] 13 | 14 | [dependencies] 15 | cosmwasm-std = { workspace = true } 16 | cw-storage-plus = { workspace = true } 17 | cosmwasm-schema = { workspace = true } 18 | thiserror = { workspace = true } 19 | cw2 = { workspace = true } 20 | valence-processor-utils = { workspace = true } 21 | valence-authorization-utils = { workspace = true } 22 | valence-gmp-utils = { workspace = true } 23 | cw-utils = { workspace = true } 24 | serde_json = { workspace = true } 25 | -------------------------------------------------------------------------------- /contracts/processor/README.md: -------------------------------------------------------------------------------- 1 | # Processor Contract 2 | 3 | The Processor will be a contract that will be sitting on each domain and, when ticked (entry point that will check the execution queues and see if there is any set of functions pending to be executed), will take the next list of functions in the queue and execute it for the program on that domain. It will also be in charge of dealing with the `Retry` logic for each message in the function list. If the list of functions executes successfully or we’ve gone through the entire `Retry` logic for any of the messages and they couldn’t be executed, they will be removed from the corresponding queue. 4 | 5 | The processors will be instantiated in advanced with the correct address that can send messages to it according to the flowchart defined in the previous section. 6 | 7 | The Authorization contract will be the only address allowed to add list of functions to the execution queues. It will also be allowed to Pause/Resume the Processor or to arbitrarily remove functions from the queues or add certain messages at a specific position. 8 | 9 | The contract ticking is permissionless and will just go over the execution queues in a round-robin fashion. 10 | 11 | There will be two execution queues: one `High` and one `Med`. This will allow to give priority to certain set of functions. 12 | -------------------------------------------------------------------------------- /contracts/processor/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_processor_utils::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/processor/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod callback; 2 | pub mod contract; 3 | pub mod error; 4 | pub mod queue; 5 | pub mod state; 6 | -------------------------------------------------------------------------------- /contracts/processor/src/queue.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{BlockInfo, Storage}; 2 | use valence_authorization_utils::{authorization::Priority, function::RetryLogic}; 3 | use valence_processor_utils::{ 4 | processor::{CurrentRetry, MessageBatch}, 5 | queue::QueueMap, 6 | }; 7 | 8 | use crate::{ 9 | error::ContractError, 10 | state::{EXECUTION_ID_TO_BATCH, HIGH_PRIORITY_QUEUE, MED_PRIORITY_QUEUE}, 11 | }; 12 | 13 | pub fn get_queue_map(priority: &Priority) -> QueueMap { 14 | match priority { 15 | Priority::High => HIGH_PRIORITY_QUEUE, 16 | Priority::Medium => MED_PRIORITY_QUEUE, 17 | } 18 | } 19 | 20 | pub fn put_back_into_queue( 21 | storage: &mut dyn Storage, 22 | batch: &mut MessageBatch, 23 | retry_amounts: u64, 24 | retry_logic: &RetryLogic, 25 | block: &BlockInfo, 26 | ) -> Result<(), ContractError> { 27 | // Increment the retry for the batch 28 | batch.retry = Some(CurrentRetry { 29 | retry_amounts: retry_amounts.checked_add(1).expect("Overflow"), 30 | retry_cooldown: retry_logic.interval.after(block), 31 | }); 32 | // Re-add to queue and save the batch with new retries 33 | let queue = get_queue_map(&batch.priority); 34 | queue.push_back(storage, batch)?; 35 | EXECUTION_ID_TO_BATCH.save(storage, batch.id, batch)?; 36 | 37 | Ok(()) 38 | } 39 | -------------------------------------------------------------------------------- /contracts/program-registry/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | unit-test = "test --lib" 4 | schema = "run --bin schema" 5 | integration-test = "test --lib integration_tests" 6 | -------------------------------------------------------------------------------- /contracts/program-registry/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-program-registry" 3 | version = { workspace = true } 4 | authors = { workspace = true } 5 | edition = { workspace = true } 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib", "rlib"] 11 | 12 | [features] 13 | # use library feature to disable all instantiate/execute/query exports 14 | library = [] 15 | 16 | [dependencies] 17 | cosmwasm-schema = { workspace = true } 18 | cosmwasm-std = { workspace = true } 19 | cw-storage-plus = { workspace = true } 20 | cw2 = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | cw-ownable = { workspace = true } 25 | valence-program-registry-utils = { workspace = true } 26 | 27 | [dev-dependencies] 28 | cw-multi-test = { workspace = true } 29 | -------------------------------------------------------------------------------- /contracts/program-registry/README.md: -------------------------------------------------------------------------------- 1 | # Program registry 2 | 3 | This contract is a registry of all the programs we instantiated. 4 | 5 | This should allow our manager to "lock" an id and store the program config in the registry. 6 | 7 | Library specific config are not stored in the registry, but can be queried from the specific library contract. 8 | -------------------------------------------------------------------------------- /contracts/program-registry/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_program_registry_utils::{ExecuteMsg, InstantiateMsg, QueryMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/program-registry/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_ownable::OwnershipError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | OwnershipError(#[from] OwnershipError), 12 | 13 | #[error("Program already exists with id {0}")] 14 | ProgramAlreadyExists(u64), 15 | #[error("Program doesn't exists with id {0}")] 16 | ProgramDoesntExists(u64), 17 | 18 | #[error("Unauthorized: This id is reserved to {0}")] 19 | UnauthorizedToSave(String), 20 | #[error("Unauthorized: This id can be only updated by {0}")] 21 | UnauthorizedToUpdate(String), 22 | } 23 | -------------------------------------------------------------------------------- /contracts/program-registry/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | mod error; 3 | pub mod state; 4 | 5 | pub use crate::error::ContractError; 6 | -------------------------------------------------------------------------------- /contracts/program-registry/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Binary}; 2 | use cw_storage_plus::{Item, Map}; 3 | 4 | pub const LAST_ID: Item = Item::new("id"); 5 | pub const PROGRAMS_OWNERS: Map = Map::new("programs_owners"); 6 | pub const PROGRAMS: Map = Map::new("programs"); 7 | pub const PROGRAMS_BACKUP: Map = Map::new("programs_backups"); 8 | -------------------------------------------------------------------------------- /contracts/testing/test-dynamic-ratio/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-test-dynamic-ratio" 3 | version = { workspace = true } 4 | authors = { workspace = true } 5 | edition = { workspace = true } 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | [features] 11 | # use library feature to disable all instantiate/execute/query exports 12 | library = [] 13 | 14 | [dependencies] 15 | cosmwasm-schema = { workspace = true } 16 | cosmwasm-std = { workspace = true } 17 | cw-ownable = { workspace = true } 18 | cw-storage-plus = { workspace = true } 19 | cw-utils = { workspace = true } 20 | getset = { workspace = true } 21 | schemars = { workspace = true } 22 | serde = { workspace = true } 23 | thiserror = { workspace = true } 24 | valence-macros = { workspace = true } 25 | valence-library-utils = { workspace = true } 26 | valence-library-base = { workspace = true } 27 | 28 | [dev-dependencies] 29 | cw-multi-test = { workspace = true } 30 | cw-ownable = { workspace = true } 31 | cw20 = { workspace = true } 32 | cw20-base = { workspace = true } 33 | sha2 = { workspace = true } 34 | valence-library-utils = { workspace = true, features = ["testing"] } 35 | -------------------------------------------------------------------------------- /contracts/testing/test-dynamic-ratio/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use valence_library_utils::msg::DynamicRatioQueryMsg; 4 | use valence_test_dynamic_ratio::msg::{ExecuteMsg, InstantiateMsg}; 5 | 6 | fn main() { 7 | write_api! { 8 | instantiate: InstantiateMsg, 9 | execute: ExecuteMsg, 10 | query: DynamicRatioQueryMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/testing/test-dynamic-ratio/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod msg; 3 | pub mod state; 4 | -------------------------------------------------------------------------------- /contracts/testing/test-dynamic-ratio/src/msg.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use cosmwasm_schema::cw_serde; 4 | use cosmwasm_std::Decimal; 5 | 6 | #[cw_serde] 7 | pub struct InstantiateMsg { 8 | pub denom_ratios: HashMap, 9 | } 10 | 11 | #[cw_serde] 12 | pub enum ExecuteMsg {} 13 | -------------------------------------------------------------------------------- /contracts/testing/test-dynamic-ratio/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Decimal; 2 | use cw_storage_plus::Item; 3 | use std::collections::HashMap; 4 | 5 | pub const DENOM_RATIOS: Item> = Item::new("denom_ratios"); 6 | -------------------------------------------------------------------------------- /contracts/testing/test-icq-lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-test-icq-lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | crate-type = ["cdylib", "rlib"] 10 | 11 | [features] 12 | # use library feature to disable all instantiate/execute/query exports 13 | library = [] 14 | 15 | [dependencies] 16 | cosmwasm-std = { workspace = true } 17 | cosmwasm-schema = { workspace = true } 18 | cw-storage-plus = { workspace = true } 19 | thiserror = { workspace = true } 20 | valence-processor-utils = { workspace = true } 21 | neutron-sdk = { workspace = true } 22 | serde-json-wasm = "1.0.0" 23 | cw2 = { workspace = true } 24 | cosmos-sdk-proto = { workspace = true } 25 | schemars = { workspace = true } 26 | serde_json = { workspace = true } 27 | serde = { workspace = true } 28 | osmosis-std = { workspace = true } 29 | prost = { workspace = true } 30 | prost-types = { workspace = true } 31 | valence-ibc-utils = { workspace = true, features = ["neutron"] } 32 | -------------------------------------------------------------------------------- /contracts/testing/test-icq-lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod icq; 3 | pub mod msg; 4 | pub mod state; 5 | -------------------------------------------------------------------------------- /contracts/testing/test-icq-lib/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use neutron_sdk::{ 3 | bindings::types::InterchainQueryResult, interchain_queries::v047::queries::BalanceResponse, 4 | }; 5 | 6 | #[cw_serde] 7 | pub struct InstantiateMsg {} 8 | 9 | #[cw_serde] 10 | pub enum ExecuteMsg { 11 | RegisterBalancesQuery { 12 | connection_id: String, 13 | update_period: u64, 14 | addr: String, 15 | denoms: Vec, 16 | }, 17 | RegisterKeyValueQuery { 18 | connection_id: String, 19 | update_period: u64, 20 | path: String, 21 | key: Vec, 22 | }, 23 | } 24 | 25 | #[cw_serde] 26 | #[derive(QueryResponses)] 27 | pub enum QueryMsg { 28 | #[returns(BalanceResponse)] 29 | Balance { query_id: u64 }, 30 | #[returns(Vec<(String, String)>)] 31 | Catchall {}, 32 | #[returns(InterchainQueryResult)] 33 | RawIcqResult { id: u64 }, 34 | } 35 | 36 | #[cw_serde] 37 | pub enum MigrateMsg {} 38 | -------------------------------------------------------------------------------- /contracts/testing/test-icq-lib/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::{Item, Map}; 2 | use valence_ibc_utils::neutron::Transfer; 3 | 4 | /// contains all transfers mapped by a recipient address observed by the contract. 5 | pub const RECIPIENT_TXS: Map> = Map::new("recipient_txs"); 6 | /// contains number of transfers to addresses observed by the contract. 7 | pub const TRANSFERS: Item = Item::new("transfers"); 8 | 9 | pub const CATCHALL: Map = Map::new("catchall"); 10 | -------------------------------------------------------------------------------- /contracts/testing/test-library/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /contracts/testing/test-library/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-test-library" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | crate-type = ["cdylib", "rlib"] 10 | 11 | [features] 12 | # use library feature to disable all instantiate/execute/query exports 13 | library = [] 14 | 15 | [dependencies] 16 | cosmwasm-std = { workspace = true } 17 | cosmwasm-schema = { workspace = true } 18 | cw-storage-plus = { workspace = true } 19 | thiserror = { workspace = true } 20 | valence-processor-utils = { workspace = true } 21 | -------------------------------------------------------------------------------- /contracts/testing/test-library/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use valence_test_library::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! {instantiate: InstantiateMsg, execute: ExecuteMsg, query: QueryMsg, migrate: MigrateMsg } 6 | } 7 | -------------------------------------------------------------------------------- /contracts/testing/test-library/src/error.rs: -------------------------------------------------------------------------------- 1 | use thiserror::Error; 2 | 3 | use cosmwasm_std::StdError; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | } 10 | -------------------------------------------------------------------------------- /contracts/testing/test-library/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | pub mod error; 3 | pub mod msg; 4 | pub mod state; 5 | -------------------------------------------------------------------------------- /contracts/testing/test-library/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::Binary; 3 | 4 | #[cw_serde] 5 | pub struct InstantiateMsg {} 6 | 7 | #[cw_serde] 8 | pub enum ExecuteMsg { 9 | WillError { error: String }, 10 | WillSucceed { execution_id: Option }, 11 | WillSucceedIfTrue {}, 12 | SetCondition { condition: bool }, 13 | SendCallback { to: String, callback: Binary }, 14 | } 15 | 16 | #[cw_serde] 17 | #[derive(QueryResponses)] 18 | pub enum QueryMsg { 19 | #[returns(bool)] 20 | Condition {}, 21 | } 22 | 23 | #[cw_serde] 24 | pub enum MigrateMsg { 25 | Migrate { new_condition: bool }, 26 | } 27 | -------------------------------------------------------------------------------- /contracts/testing/test-library/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::Item; 2 | 3 | pub const CONDITION: Item = Item::new("condition"); 4 | pub const EXECUTION_ID: Item = Item::new("execution_id"); 5 | -------------------------------------------------------------------------------- /deployment/README.md: -------------------------------------------------------------------------------- 1 | # Scripts for easy deployment of programs 2 | 3 | This directory contains scripts for easy deployment of programs. 4 | 5 | ## Generate local interchain config 6 | 7 | This script is used to generate a manager config from local interchain chains. 8 | 9 | In order to build the manager config we need 3 things: 10 | 11 | - The chains information like RPC, coin type, etc. to enable the manager to interact with the chains. 12 | - The contract information to be able to instantiate the contracts on the chains. (for example code ids for cosmos chains) 13 | - General information like registry contract address. 14 | 15 | The script will generate a config file that can be used by the manager to work with local interchain chains. 16 | 17 | ## Build program 18 | 19 | This script is used to build the program config using the program builder. 20 | 21 | In order to use it, you need to modify `my_program.rs` to include your custom program logic, and run the script. 22 | 23 | The script will output the program config in a JSON format in `output_program/program.json`. 24 | 25 | ## Deploy program 26 | 27 | To deploy a program we need `manager_config` and `program_config`. 28 | 29 | - `manager_config` is generated by the `generate_local_ic_config` script 30 | - `program_config` is generated by the `build_program` script. 31 | 32 | The script will use the program manager to deploy the program on your locally running interchain chains. -------------------------------------------------------------------------------- /deployment/configs/mainnet/chains.toml: -------------------------------------------------------------------------------- 1 | [chains] 2 | 3 | # [chains.cosmos-hub] 4 | # name = "cosmos-hub" 5 | # rpc = "https://rpc.cosmos.network:443" 6 | # grpc = "https://cosmos-testnet-grpc.polkachu.com:14990" 7 | # prefix = "cosmos" 8 | # gas_price = "0.025" 9 | # gas_denom = "uatom" 10 | # coin_type = "118" 11 | 12 | [chains.juno] 13 | name = "juno" 14 | rpc = "http://0.0.0.0:34125" 15 | grpc = "http://0.0.0.0:46547" 16 | prefix = "juno" 17 | gas_price = "0.1" 18 | gas_denom = "ujuno" 19 | coin_type = "118" 20 | 21 | [chains.neutron] 22 | name = "neutron" 23 | rpc = "https://neutron-testnet-rpc.polkachu.com:443" 24 | grpc = "https://grpc-falcron.pion-1.ntrn.tech:80" 25 | # grpc = "https://neutron-testnet-rpc.polkachu.com:19190" 26 | prefix = "neutron" 27 | gas_price = "0.055" 28 | gas_denom = "untrn" 29 | coin_type = "118" 30 | -------------------------------------------------------------------------------- /deployment/configs/mainnet/contracts.toml: -------------------------------------------------------------------------------- 1 | [contracts] 2 | 3 | [contracts.code_ids.neutron] 4 | valence_authorization = 7217 5 | valence_processor = 7218 6 | valence_base_account = 7219 7 | valence_forwarder = 7222 8 | valence_splitter = 6049 9 | valence_reverse_splitter = 3 10 | 11 | [contracts.code_ids.cosmos-hub] 12 | valence_authorization = 7217 13 | valence_processor = 7218 14 | valence_base_account = 7219 15 | valence_forwarder = 7222 16 | valence_splitter = 6049 17 | valence_reverse_splitter = 3 18 | -------------------------------------------------------------------------------- /deployment/configs/mainnet/general.toml: -------------------------------------------------------------------------------- 1 | [general] 2 | registry_addr = "neutron1gnnphq9vkcd8t4vend2f88qrcxeu3ncz3vmj6zzfm5n0psn97drs2ygf4f" 3 | -------------------------------------------------------------------------------- /deployment/configs/mainnet/neutron_bridges/neutron_cosmos_hub.toml: -------------------------------------------------------------------------------- 1 | [bridges.neutron.cosmos_hub.polytone] 2 | voice_addr = "neutron1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 3 | note_addr = "neutron1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 4 | other_note_port = "wasm.cosmos1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 5 | connection_id = "connection-0" 6 | channel_id = "channel-0" 7 | [bridges.cosmos_hub.neutron.polytone] 8 | voice_addr = "cosmos1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 9 | note_addr = "cosmos1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 10 | other_note_port = "wasm.neutron1vq2z7zgj7v4yj7z2zgj7v4yj7z2zgj7z2zgj7v" 11 | connection_id = "connection-0" 12 | channel_id = "channel-0" 13 | -------------------------------------------------------------------------------- /deployment/scripts/build_program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "build_program" 3 | edition = { workspace = true } 4 | license = { workspace = true } 5 | version = { workspace = true } 6 | repository = { workspace = true } 7 | 8 | [dependencies] 9 | localic-std = { git = "https://github.com/strangelove-ventures/interchaintest", branch = "main" } 10 | localic-utils = { git = "https://github.com/timewave-computer/localic-utils", branch = "main" } 11 | serde_json = { workspace = true } 12 | valence-program-manager = { workspace = true } 13 | valence-splitter-library = { workspace = true } 14 | valence-authorization-utils = { workspace = true } 15 | valence-library-utils = { workspace = true } 16 | clap = { workspace = true } 17 | -------------------------------------------------------------------------------- /deployment/scripts/build_program/src/main.rs: -------------------------------------------------------------------------------- 1 | mod my_program; 2 | 3 | use crate::my_program::my_program; 4 | use std::error::Error; 5 | use std::fs; 6 | use std::io::{BufWriter, Write}; 7 | use std::path::Path; 8 | 9 | use valence_program_manager::program_config::ProgramConfig; 10 | 11 | fn main() -> Result<(), Box> { 12 | let program = my_program(); 13 | 14 | // Print instantiated program to file 15 | save_config_to_json_file(program)?; 16 | 17 | Ok(()) 18 | } 19 | 20 | fn save_config_to_json_file(program_config: ProgramConfig) -> Result<(), Box> { 21 | let path_name = "deployment/output_program"; 22 | let path = Path::new(path_name); 23 | 24 | if !path.exists() { 25 | fs::create_dir_all(path_name)?; 26 | } 27 | 28 | // Construct the full file path 29 | let file_path = path.join("program.json"); 30 | 31 | // Create and write to the file 32 | let file = fs::File::create(file_path.clone())?; 33 | let mut writer = BufWriter::new(file); 34 | 35 | // Serialize the data to a string 36 | serde_json::to_writer(&mut writer, &program_config)?; 37 | writer.flush()?; 38 | 39 | println!("Program config was built successfully."); 40 | 41 | Ok(()) 42 | } 43 | -------------------------------------------------------------------------------- /deployment/scripts/deploy_program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deploy_program" 3 | edition = { workspace = true } 4 | license = { workspace = true } 5 | version = { workspace = true } 6 | repository = { workspace = true } 7 | 8 | [dependencies] 9 | localic-std = { git = "https://github.com/strangelove-ventures/interchaintest", branch = "main" } 10 | localic-utils = { git = "https://github.com/timewave-computer/localic-utils", branch = "main" } 11 | serde_json = { workspace = true } 12 | valence-program-manager = { workspace = true } 13 | valence-splitter-library = { workspace = true } 14 | valence-authorization-utils = { workspace = true } 15 | valence-library-utils = { workspace = true } 16 | tokio = { workspace = true } 17 | toml = "0.8.19" 18 | clap = { workspace = true } 19 | glob = { workspace = true } 20 | config = { workspace = true } 21 | -------------------------------------------------------------------------------- /deployment/scripts/generate_local_ic_config/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "generate_local_ic_config" 3 | edition = { workspace = true } 4 | license = { workspace = true } 5 | version = { workspace = true } 6 | repository = { workspace = true } 7 | 8 | [dependencies] 9 | localic-std = { git = "https://github.com/strangelove-ventures/interchaintest", branch = "main" } 10 | localic-utils = { git = "https://github.com/timewave-computer/localic-utils", branch = "main" } 11 | polytone-note = { git = "https://github.com/DA0-DA0/polytone", rev = "f70440a" } 12 | polytone-voice = { git = "https://github.com/DA0-DA0/polytone", rev = "f70440a" } 13 | sha2 = { workspace = true } 14 | hex = { workspace = true } 15 | serde_json = { workspace = true } 16 | env_logger = { workspace = true } 17 | log = { workspace = true } 18 | rand = "0.8.5" 19 | cosmos-grpc-client = "3.0.1" 20 | valence-program-manager = { workspace = true } 21 | tokio = { workspace = true } 22 | toml = "0.8.19" 23 | valence-e2e = { workspace = true } 24 | clap = { workspace = true } 25 | -------------------------------------------------------------------------------- /devtools/optimize.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $(uname -m) =~ "arm64" ]]; then 4 | docker run --rm -v "$(pwd)":/code \ 5 | --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ 6 | --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ 7 | cosmwasm/optimizer-arm64:0.16.1 8 | 9 | else 10 | docker run --rm -v "$(pwd)":/code \ 11 | --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ 12 | --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ 13 | cosmwasm/optimizer:0.16.1 14 | fi 15 | 16 | docker run --rm -it \ 17 | -v "$(pwd)/solidity":/solidity \ 18 | -w /solidity \ 19 | --entrypoint sh \ 20 | ghcr.io/foundry-rs/foundry:stable -c "forge soldeer install && forge build" 21 | -------------------------------------------------------------------------------- /devtools/schema.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Function to process a directory 4 | process_directory() { 5 | if [ -d "$1" ] && [ -f "$1/Cargo.toml" ]; then 6 | echo "Processing: $1" 7 | cd "$1" 8 | # Delete old one if it exists 9 | rm -rf schema 10 | cargo schema 11 | rm -rf schema/raw 12 | cd - >/dev/null 13 | fi 14 | } 15 | 16 | # Process contracts in contracts/*/* 17 | for d in contracts/*/*; do 18 | process_directory "$d" 19 | done 20 | 21 | # Process contracts in contracts/* 22 | for d in contracts/*; do 23 | if [ -d "$d" ]; then 24 | process_directory "$d" 25 | fi 26 | done 27 | 28 | # Process schema for program-manager 29 | process_directory "program-manager" -------------------------------------------------------------------------------- /devtools/toml_fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | toml_fmt() { 4 | # if no flags are provided we default to empty 5 | local flag="${1:-}" 6 | 7 | # create a temp toml config 8 | cat > /tmp/taplo.toml << 'EOF' 9 | [formatting] 10 | align_entries = true 11 | align_comments = true 12 | array_auto_expand = true 13 | array_auto_collapse = true 14 | compact_arrays = true 15 | compact_inline_tables = false 16 | column_width = 120 17 | indent_string = " " 18 | reorder_keys = false 19 | EOF 20 | 21 | # run the formatter with provided flag (if provided) 22 | taplo fmt $flag --config /tmp/taplo.toml 23 | 24 | # remove the temp config 25 | rm /tmp/taplo.toml 26 | } 27 | 28 | toml_fmt "$@" 29 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Valence Programs Documentation 2 | 3 | This folder contains the source code for the Valence Programs documentation. 4 | 5 | ## Building 6 | 7 | 1. Install mdbook, mdbook-mermaid and mdbook-linkcheck: 8 | 9 | ```bash 10 | cargo install mdbook mdbook-mermaid mdbook-linkcheck 11 | ``` 12 | 13 | 2. Build: 14 | 15 | From `/docs` directory, run: 16 | 17 | ```bash 18 | mdbook build 19 | ``` 20 | 21 | 3. The output will be in the book subdirectory. Open it in your web browser. Examples: 22 | 23 | - Firefox: 24 | 25 | ```bash 26 | firefox book/html/index.html # Linux 27 | open -a "Firefox" book/html/index.html # OS X 28 | Start-Process "firefox.exe" .\book\html\index.html # Windows (PowerShell) 29 | start firefox.exe .\book\html\index.html # Windows (Cmd) 30 | ``` 31 | 32 | - Chrome: 33 | 34 | ```bash 35 | google-chrome book/html/index.html # Linux 36 | open -a "Google Chrome" book/index.html # OS X 37 | Start-Process "chrome.exe" .\book\html\index.html # Windows (PowerShell) 38 | start chrome.exe .\book\html\index.html # Windows (Cmd) 39 | ``` 40 | 41 | 4. To apply docs changes automatically without rebuilding manually, run: 42 | 43 | ```bash 44 | mdbook serve 45 | ``` 46 | -------------------------------------------------------------------------------- /docs/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["Timewave Labs"] 3 | language = "en" 4 | multilingual = false 5 | src = "src" 6 | title = "Valence Protocol Documentation" 7 | 8 | [output.html] 9 | git-repository-url = "https://github.com/timewave-computer/valence-protocol" 10 | default-theme = "light" 11 | preferred-light-theme = "light" 12 | preferred-dark-theme = "ayu" 13 | additional-js = ["mermaid.min.js", "mermaid-init.js"] 14 | mathjax-support = true 15 | 16 | [output.linkcheck] 17 | 18 | [preprocessor.mermaid] 19 | command = "mdbook-mermaid" 20 | -------------------------------------------------------------------------------- /docs/mermaid-init.js: -------------------------------------------------------------------------------- 1 | (() => { 2 | const darkThemes = ['ayu', 'navy', 'coal']; 3 | const lightThemes = ['light', 'rust']; 4 | 5 | const classList = document.getElementsByTagName('html')[0].classList; 6 | 7 | let lastThemeWasLight = true; 8 | for (const cssClass of classList) { 9 | if (darkThemes.includes(cssClass)) { 10 | lastThemeWasLight = false; 11 | break; 12 | } 13 | } 14 | 15 | const theme = lastThemeWasLight ? 'default' : 'dark'; 16 | mermaid.initialize({ startOnLoad: true, theme }); 17 | 18 | // Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page 19 | 20 | for (const darkTheme of darkThemes) { 21 | document.getElementById(darkTheme).addEventListener('click', () => { 22 | if (lastThemeWasLight) { 23 | window.location.reload(); 24 | } 25 | }); 26 | } 27 | 28 | for (const lightTheme of lightThemes) { 29 | document.getElementById(lightTheme).addEventListener('click', () => { 30 | if (!lastThemeWasLight) { 31 | window.location.reload(); 32 | } 33 | }); 34 | } 35 | })(); 36 | -------------------------------------------------------------------------------- /docs/src/accounts/_overview.md: -------------------------------------------------------------------------------- 1 | # Valence Accounts 2 | 3 | Valence Programs usually perform operations on tokens accross multiple domains. To ensure that the funds remain safe throughout a program's execution, Valence Programs rely on a primitive called Valence Accounts. Additionally, Valence Accounts can also be used to store data that is not directly related to tokens. 4 | 5 | In this section we will introduce all the different types of Valence Accounts and explain their purpose. 6 | -------------------------------------------------------------------------------- /docs/src/authorizations_processors/_overview.md: -------------------------------------------------------------------------------- 1 | # Authorization & Processors 2 | 3 | The **Authorization** and **Processor** contracts are foundational pieces of the **Valence Protocol**, as they enable on-chain (and cross-chain) execution of **Valence Programs** and enforce access control to the program's **Subroutines** via **Authorizations**. 4 | 5 | This section explains the rationale for these contracts and shares insights into their technical implementation, as well as how end-users can interact with **Valence Programs** via **Authorizations**. 6 | 7 | ## Rationale 8 | 9 | - To have a general purpose set of smart contracts that provide users with a single point of entry to interact with the Valence Program, which can have libraries and accounts deployed on multiple chains. 10 | - To have all the user authorizations for multiple domains in a single place, making it very easy to control the application. 11 | - To have a single address (Processor) that will execute the messages for all the contracts in a domain using execution queues. 12 | - To only tick a single contract (Processor) that will go through the queues to route and execute the messages. 13 | - To create, edit, or remove different application permissions with ease. 14 | -------------------------------------------------------------------------------- /docs/src/authorizations_processors/authorization_contract.md: -------------------------------------------------------------------------------- 1 | # Authorization Contract 2 | 3 | The Authorization contract will be a single contract deployed on the main domain and that will define the authorizations of the top-level application, which can include libraries in different domains (chains). For each domain, there will be one Processor in charge of executing the functions on the libraries. The Authorization contract will connect to all of the Processor contracts using a connector (e.g. Polytone Note, Hyperlane Mailbox…) and will route the message batches to be executed to the right domain. At the same time, for each external domain, we will have a proxy contract (e.g. Polytone Proxy, Hyperlane Mailbox...) in the main domain which will receive the callbacks sent from the processor on the external domain with the `ExecutionResult` of the `MessageBatch`. 4 | 5 | The contract will be instantiated once at the very beginning and will be used during the entire top-level application lifetime. Users will never interact with the individual Smart Contracts of each program, but with the Authorization contract directly. 6 | -------------------------------------------------------------------------------- /docs/src/authorizations_processors/authorization_instantiation.md: -------------------------------------------------------------------------------- 1 | # Instantiation 2 | 3 | When the contract is instantiated, it will be provided the following information: 4 | 5 | - Processor contract on main domain. 6 | 7 | - Owner of the contract. 8 | 9 | - List of subowners (if any). Users that can execute the same actions as the owner except adding/removing other subowners. 10 | 11 | Once the Authorization contract is deployed, we can already start adding and executing authorizations on the domain that the Authorization contract was deployed on. To execute functions on other domains, the owner will have to add external domains to the Authorization contract with all the information required for the Authorization contract to route the messages to that domain. 12 | -------------------------------------------------------------------------------- /docs/src/components/_overview.md: -------------------------------------------------------------------------------- 1 | # Valence Programs 2 | 3 | There are two ways to execute Valence Programs. 4 | 5 | 1. **On-chain Execution**: 6 | Valence currently supports CosmWasm and EVM. SVM support coming soon. The rest of this section provides a high-level breakdown of the components that comprise a Valence Program using on-chain coprocessors. 7 | - [Domains](./domains.md) 8 | - [Accounts](../accounts/_overview.md) 9 | - [Libraries and Functions](./libraries_and_functions.md) 10 | - [Programs and Authorizations](./programs_and_authorizations.md) 11 | - [Middleware](./middleware.md) 12 | 13 | 2. **Off-chain Execution via ZK Coprocessor**: 14 | Early specifications for the [Valence ZK System](./../zk/_overview.md). We aim to move as much computation off-chain as possible since off-chain computation is a more scalable approach to building a cross-chain execution environment. -------------------------------------------------------------------------------- /docs/src/components/middleware.md: -------------------------------------------------------------------------------- 1 | # WIP: Middleware 2 | 3 | The Valence Middleware is a set of components that provide a unified interface for the Valence Type system. 4 | 5 | At its core, middleware is made up from the following components. 6 | 7 | ## Design goals 8 | 9 | TODO: describe modifiable middleware, design goals and philosophy behind it 10 | 11 | These means are achieved with three key components: 12 | 13 | - brokers 14 | - type registries 15 | - Valence types 16 | 17 | ## Middleware Brokers 18 | 19 | Middleware brokers are responsible for managing the lifecycle of middleware instances and their associated types. 20 | 21 | ## Middleware Type Registries 22 | 23 | Middleware Type Registries are responsible for unifying a set of foreign types to be used in Valence Programs. 24 | 25 | ## Valence Types 26 | 27 | Valence Types are the canonical representations of various external domain implementations of some types. 28 | 29 | ## Valence Asserter 30 | 31 | Valence Asserter enables Valence Programs to assert specific predicates during runtime. This is useful for programs that wish to enable conditional execution of a given function as long as some predicate evaluates to `true`. 32 | -------------------------------------------------------------------------------- /docs/src/deployment/_overview.md: -------------------------------------------------------------------------------- 1 | # Deployment 2 | 3 | This section contains a detailed explanation of how to deploy programs on different environments. 4 | 5 | **Environments** 6 | - [Local](./local.md) 7 | -------------------------------------------------------------------------------- /docs/src/examples/_overview.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | Here are some examples of Valence Programs that you can use to get started. 4 | 5 | - [Token Swap](./token_swap.md) 6 | - [Crosschain Vaults](./crosschain_vaults.md) 7 | - [Vault Strategist](./vault_strategist.md) 8 | -------------------------------------------------------------------------------- /docs/src/img/authorization_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/docs/src/img/authorization_table.png -------------------------------------------------------------------------------- /docs/src/img/user_flowchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/docs/src/img/user_flowchart.png -------------------------------------------------------------------------------- /docs/src/libraries/_overview.md: -------------------------------------------------------------------------------- 1 | # Libraries 2 | 3 | This section contains a detailed description of the various libraries that can be used to rapidly build Valence cross-chain programs for each execution environment. 4 | -------------------------------------------------------------------------------- /docs/src/libraries/cosmwasm/_overview.md: -------------------------------------------------------------------------------- 1 | # CosmWasm Libraries 2 | 3 | This section contains a detailed description of all the libraries that can be used in CosmWasm execution environments. 4 | -------------------------------------------------------------------------------- /docs/src/libraries/evm/_overview.md: -------------------------------------------------------------------------------- 1 | # EVM Libraries 2 | 3 | This section contains a detailed description of all the libraries that can be used in EVM Execution Environments. 4 | -------------------------------------------------------------------------------- /docs/src/middleware/_overview.md: -------------------------------------------------------------------------------- 1 | # Middleware 2 | 3 | This section contains a description of the Valence Protocol middleware design. 4 | 5 | **Valence Protocol Middleware components**: 6 | 7 | - [Middleware Broker](./broker.md) 8 | - [Middleware Type Registry](./type_registry.md) 9 | - [Valence Types](./valence_types.md) 10 | - [Asserters](./valence_asserter.md) 11 | -------------------------------------------------------------------------------- /docs/src/program_manager/_overview.md: -------------------------------------------------------------------------------- 1 | # Program manager 2 | 3 | The program manager is an off-chain tool that helps instantiate, update and migrate a program. 4 | 5 | **Guides** 6 | - [How to](./how_to.md) 7 | - [Build program config](./build_program_config.md) 8 | 9 | **Program manager components**: 10 | 11 | - [Manager config](./manager_config.md) 12 | - [Program config](./program_configs/instantiate.md) 13 | - [Program config update](./program_configs/update.md) 14 | - [Program config migrate](./program_configs/migrate.md) 15 | - [Library Account Type](./library_account_type.md) 16 | -------------------------------------------------------------------------------- /docs/src/security.md: -------------------------------------------------------------------------------- 1 | # Security 2 | Valence Programs have been independently audited. Please find audit reports [here](https://github.com/timewave-computer/valence-protocol/tree/main/audits/). 3 | 4 | If you believe you've found a security-related issue with Valence Programs, please disclose responsibly by contacting the Timewave team at [security@timewave.computer](mailto:security@timewave.computer). -------------------------------------------------------------------------------- /e2e/examples/eth_cctp_vault/strategist/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod astroport; 2 | pub(crate) mod routing; 3 | pub mod strategy; 4 | pub mod strategy_config; 5 | -------------------------------------------------------------------------------- /e2e/examples/eth_eureka_vault/strategist/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod astroport; 2 | pub(crate) mod routing; 3 | pub mod strategy; 4 | pub mod strategy_config; 5 | pub(crate) mod vault; 6 | -------------------------------------------------------------------------------- /e2e/examples/eth_to_base_vault_pancake/strategist/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod aave_utils; 2 | pub mod pancake_v3_utils; 3 | pub mod strategy; 4 | pub mod strategy_config; 5 | -------------------------------------------------------------------------------- /e2e/examples/manager_server_dev.rs: -------------------------------------------------------------------------------- 1 | use std::{env, error::Error, fs}; 2 | 3 | use localic_utils::{ConfigChainBuilder, TestContextBuilder, GAIA_CHAIN_NAME, LOCAL_IC_API_URL}; 4 | use valence_e2e::utils::{ 5 | manager::{get_global_config, setup_manager, SPLITTER_NAME}, 6 | LOGS_FILE_PATH, NEUTRON_CONFIG_FILE, VALENCE_ARTIFACTS_PATH, 7 | }; 8 | 9 | fn main() -> Result<(), Box> { 10 | let mut test_ctx = TestContextBuilder::default() 11 | .with_unwrap_raw_logs(true) 12 | .with_api_url(LOCAL_IC_API_URL) 13 | .with_artifacts_dir(VALENCE_ARTIFACTS_PATH) 14 | .with_chain(ConfigChainBuilder::default_neutron().build()?) 15 | .with_log_file_path(LOGS_FILE_PATH) 16 | .build()?; 17 | 18 | setup_manager( 19 | &mut test_ctx, 20 | NEUTRON_CONFIG_FILE, 21 | vec![GAIA_CHAIN_NAME], 22 | vec![SPLITTER_NAME], 23 | )?; 24 | 25 | let gc = get_global_config(); 26 | 27 | // Save the config to a file 28 | let curr_path = env::current_dir()?; 29 | let config_dev_path = format!( 30 | "{}/e2e/configs/config_dev.toml", 31 | curr_path.to_str().unwrap() 32 | ); 33 | 34 | let t = toml::to_string(&*gc).unwrap(); 35 | fs::write(config_dev_path, t)?; 36 | 37 | Ok(()) 38 | } 39 | -------------------------------------------------------------------------------- /e2e/hyperlane/contracts/cosmwasm/hpl_hook_merkle.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/hyperlane/contracts/cosmwasm/hpl_hook_merkle.wasm -------------------------------------------------------------------------------- /e2e/hyperlane/contracts/cosmwasm/hpl_igp.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/hyperlane/contracts/cosmwasm/hpl_igp.wasm -------------------------------------------------------------------------------- /e2e/hyperlane/contracts/cosmwasm/hpl_ism_pausable.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/hyperlane/contracts/cosmwasm/hpl_ism_pausable.wasm -------------------------------------------------------------------------------- /e2e/hyperlane/contracts/cosmwasm/hpl_mailbox.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/hyperlane/contracts/cosmwasm/hpl_mailbox.wasm -------------------------------------------------------------------------------- /e2e/hyperlane/contracts/cosmwasm/hpl_validator_announce.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/hyperlane/contracts/cosmwasm/hpl_validator_announce.wasm -------------------------------------------------------------------------------- /e2e/polytone_contracts/polytone_note.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/polytone_contracts/polytone_note.wasm -------------------------------------------------------------------------------- /e2e/polytone_contracts/polytone_proxy.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/polytone_contracts/polytone_proxy.wasm -------------------------------------------------------------------------------- /e2e/polytone_contracts/polytone_voice.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/e2e/polytone_contracts/polytone_voice.wasm -------------------------------------------------------------------------------- /e2e/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod utils; 2 | -------------------------------------------------------------------------------- /e2e/src/utils/mocks/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cctp_relayer_evm_evm; 2 | pub mod cctp_relayer_evm_noble; 3 | pub mod eureka_rly_evm_gaia_neutron; 4 | pub mod standard_bridge_relayer; 5 | -------------------------------------------------------------------------------- /e2e/src/utils/relayer.rs: -------------------------------------------------------------------------------- 1 | use localic_utils::utils::test_context::TestContext; 2 | 3 | pub fn restart_relayer(test_ctx: &mut TestContext) { 4 | test_ctx.stop_relayer(); 5 | test_ctx.start_relayer(); 6 | } 7 | -------------------------------------------------------------------------------- /examples/osmo_cl/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod osmo_cl; 2 | -------------------------------------------------------------------------------- /examples/osmo_gamm/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod osmo_gamm; 2 | -------------------------------------------------------------------------------- /examples/token_swap/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod token_swap; 2 | -------------------------------------------------------------------------------- /justfile: -------------------------------------------------------------------------------- 1 | optimize: 2 | ./devtools/optimize.sh 3 | 4 | network_inspect := "docker network inspect hyperlane-net -f '{{range .Containers}}{{.Name}} {{end}}'" 5 | disconnect-hyperlane-network: 6 | #!/usr/bin/env sh 7 | containers=$({{network_inspect}}) 8 | for container in $containers; do 9 | docker network disconnect hyperlane-net $container 10 | done 11 | docker network rm hyperlane-net 12 | 13 | run-example program: 14 | RUST_LOG=debug cargo run --package {{program}} 15 | 16 | run-e2e test: 17 | RUST_LOG=info cargo run --package valence-e2e --example {{test}} 18 | 19 | precommit: 20 | cargo fmt --all -- --check 21 | cargo clippy --all-targets --verbose -- -D warnings 22 | just toml_fmt --check 23 | ./devtools/schema.sh 24 | 25 | toml_fmt flag="": 26 | ./devtools/toml_fmt.sh {{flag}} 27 | -------------------------------------------------------------------------------- /packages/account-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-account-utils" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [features] 10 | default = [] 11 | testing = ["dep:cw-multi-test", "dep:cw20", "dep:cw20-base", "dep:sha2"] 12 | 13 | [dependencies] 14 | cosmwasm-schema = { workspace = true } 15 | cosmwasm-std = { workspace = true } 16 | cw-ownable = { workspace = true } 17 | cw-utils = { workspace = true } 18 | serde = { workspace = true } 19 | serde_json = { workspace = true } 20 | thiserror = { workspace = true } 21 | valence-macros = { workspace = true } 22 | valence-ibc-utils = { workspace = true } 23 | 24 | # Testing dependencies 25 | cw-multi-test = { workspace = true, optional = true } 26 | cw20 = { workspace = true, optional = true } 27 | cw20-base = { workspace = true, optional = true } 28 | sha2 = { workspace = true, optional = true } 29 | -------------------------------------------------------------------------------- /packages/account-utils/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_ownable::OwnershipError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | OwnershipError(#[from] OwnershipError), 12 | 13 | #[error("Unauthorized: {0}")] 14 | Unauthorized(#[from] UnauthorizedReason), 15 | } 16 | 17 | #[derive(Error, Debug, PartialEq)] 18 | pub enum UnauthorizedReason { 19 | #[error("Unauthorized: Not the admin")] 20 | NotAdmin, 21 | 22 | #[error("Unauthorized: Not an approved library")] 23 | NotApprovedLibrary, 24 | 25 | #[error("Unauthorized: Not the admin or an approved library")] 26 | NotAdminOrApprovedLibrary, 27 | } 28 | -------------------------------------------------------------------------------- /packages/account-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod error; 2 | pub mod ica; 3 | pub mod msg; 4 | 5 | #[cfg(feature = "testing")] 6 | pub mod testing; 7 | -------------------------------------------------------------------------------- /packages/astroport-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-astroport-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Utils for astroport libraries" 7 | 8 | [features] 9 | default = [] 10 | testing = ["dep:neutron-test-tube"] 11 | 12 | [dependencies] 13 | cosmwasm-std = { workspace = true } 14 | cosmwasm-schema = { workspace = true } 15 | neutron-test-tube = { workspace = true, optional = true } 16 | valence-library-utils = { workspace = true } 17 | -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_factory.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_factory.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_factory_cw20.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_factory_cw20.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_factory_native.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_factory_native.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_native_coin_registry.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_native_coin_registry.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_pair_concentrated.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_pair_concentrated.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_pair_cw20.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_pair_cw20.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_pair_native.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_pair_native.wasm -------------------------------------------------------------------------------- /packages/astroport-utils/contracts/astroport_token.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/packages/astroport-utils/contracts/astroport_token.wasm -------------------------------------------------------------------------------- /packages/authorization-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-authorization-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for authorization contract" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cw-utils = { workspace = true } 11 | cosmwasm-schema = { workspace = true } 12 | cw-ownable = { workspace = true } 13 | valence-gmp-utils = { workspace = true } 14 | valence-library-utils = { workspace = true } 15 | valence-verification-gateway = { workspace = true } 16 | serde_json = { workspace = true } 17 | -------------------------------------------------------------------------------- /packages/authorization-utils/src/authorization_message.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::Binary; 3 | 4 | use crate::msg::EncoderInfo; 5 | 6 | #[cw_serde] 7 | pub struct MessageDetails { 8 | pub message_type: MessageType, 9 | pub message: Message, 10 | } 11 | 12 | #[cw_serde] 13 | pub enum MessageType { 14 | CosmwasmExecuteMsg, 15 | CosmwasmMigrateMsg, 16 | // Provide the EncoderInfo and the LibraryName that we want to encode the message into 17 | EvmCall(EncoderInfo, String), 18 | EvmRawCall, 19 | } 20 | 21 | #[cw_serde] 22 | pub struct Message { 23 | // Name of the message that is passed to the contract, e.g. in CosmWasm: the snake_case name of the ExecuteMsg, how it's passed in the JSON 24 | pub name: String, 25 | pub params_restrictions: Option>, 26 | } 27 | 28 | #[cw_serde] 29 | pub enum ParamRestriction { 30 | // First parameter is an array of indexes in the json to know what we have to look for 31 | // Example: ["msg", "amount"] means that we have to look for the amount index inside the msg index 32 | // example_json = { "msg": { "amount": 100 } } 33 | MustBeIncluded(Vec), 34 | CannotBeIncluded(Vec), 35 | MustBeValue(Vec, Binary), 36 | // Used when we are passing the raw bytes to be executed in another domain, e.g. ABI encoded bytes for EVM 37 | // This will restrict that the bytes passed are restricted to this value. 38 | MustBeBytes(Binary), 39 | } 40 | -------------------------------------------------------------------------------- /packages/authorization-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod authorization; 2 | pub mod authorization_message; 3 | pub mod builders; 4 | pub mod callback; 5 | pub mod domain; 6 | pub mod function; 7 | pub mod msg; 8 | pub mod zk_authorization; 9 | -------------------------------------------------------------------------------- /packages/encoder-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-encoder-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for encoding functionalities" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | valence-authorization-utils = { workspace = true } 12 | alloy-sol-types = "0.7.7" 13 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod libraries; 2 | pub mod msg; 3 | pub mod processor; 4 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/aave_position_manager/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/aave_position_manager/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct AavePositionManagerConfig { 5 | address poolAddress; 6 | address inputAccount; 7 | address outputAccount; 8 | address supplyAsset; 9 | address borrowAsset; 10 | uint16 referralCode; 11 | } 12 | 13 | function supply(uint256 amount) external; 14 | function borrow(uint256 amount) external; 15 | function withdraw(uint256 amount) external; 16 | function repay(uint256 amount) external; 17 | function repayWithShares(uint256 amount) external; 18 | } 19 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/balancer_v2_swap/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/balancer_v2_swap/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct BalancerV2SwapConfig { 5 | address inputAccount; 6 | address outputAccount; 7 | address vaultAddress; 8 | } 9 | 10 | function swap( 11 | bytes32 poolId, 12 | address tokenIn, 13 | address tokenOut, 14 | bytes memory userData, 15 | uint256 amountIn, 16 | uint256 minAmountOut, 17 | uint256 timeout 18 | ) external; 19 | 20 | function multiSwap( 21 | bytes32[] calldata poolIds, 22 | address[] calldata tokens, 23 | bytes[] calldata userDataArray, 24 | uint256 amountIn, 25 | uint256 minAmountOut, 26 | uint256 timeout 27 | ) external; 28 | } 29 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/cctp_transfer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/cctp_transfer/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | #[sol(rpc)] 5 | #[derive(Debug, PartialEq, Eq)] 6 | struct CCTPTransferConfig { 7 | uint256 amount; // If we want to transfer all tokens, we can set this to 0. 8 | bytes32 mintRecipient; 9 | address inputAccount; 10 | uint32 destinationDomain; 11 | address cctpTokenMessenger; 12 | address transferToken; 13 | } 14 | 15 | function transfer() external view; 16 | } 17 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/forwarder/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/forwarder/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct ForwardingConfig { 5 | address tokenAddress; 6 | uint256 maxAmount; 7 | } 8 | 9 | enum IntervalType { 10 | TIME, 11 | BLOCKS 12 | } 13 | 14 | struct ForwarderConfig { 15 | // We can use address here directly because that's what Smart contracts are under the hood in Solidity 16 | address inputAccount; 17 | address outputAccount; 18 | ForwardingConfig[] forwardingConfigs; 19 | IntervalType intervalType; 20 | uint64 minInterval; 21 | } 22 | 23 | function forward() external view; 24 | } 25 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/ibc_eureka_transfer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/ibc_eureka_transfer/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct IBCEurekaTransferConfig { 5 | uint256 amount; 6 | address transferToken; 7 | address inputAccount; 8 | string recipient; 9 | string sourceClient; 10 | uint64 timeout; 11 | address eurekaHandler; 12 | } 13 | 14 | struct Fees { 15 | uint256 relayFee; 16 | address relayFeeRecipient; 17 | uint64 quoteExpiry; 18 | } 19 | 20 | function transfer(Fees calldata fees, string calldata memo) external; 21 | } 22 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/pancake_v3_position_manager/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/pancake_v3_position_manager/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct PancakeSwapV3PositionManagerConfig { 5 | address inputAccount; 6 | address outputAccount; 7 | address positionManager; 8 | address masterChef; 9 | address token0; 10 | address token1; 11 | uint24 poolFee; 12 | uint16 slippageBps; 13 | uint256 timeout; 14 | } 15 | 16 | function createPosition(int24 tickLower, int24 tickUpper, uint256 amount0, uint256 amount1) external; 17 | 18 | function withdrawPosition(uint256 tokenId) external; 19 | } 20 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/standard_bridge_transfer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/standard_bridge_transfer/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct StandardBridgeTransferConfig { 5 | uint256 amount; 6 | address inputAccount; 7 | address recipient; 8 | address standardBridge; 9 | address token; 10 | address remoteToken; 11 | uint32 minGasLimit; 12 | bytes extraData; 13 | } 14 | 15 | function transfer() external view; 16 | } 17 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/stargate_transfer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/libraries/stargate_transfer/solidity_types.rs: -------------------------------------------------------------------------------- 1 | use alloy_sol_types::sol; 2 | 3 | sol! { 4 | struct StargateTransferConfig { 5 | bytes32 recipient; 6 | address inputAccount; 7 | uint32 destinationDomain; 8 | address stargateAddress; 9 | address transferToken; 10 | uint256 amount; 11 | uint256 minAmountToReceive; 12 | address refundAddress; 13 | bytes extraOptions; 14 | bytes composeMsg; 15 | bytes oftCmd; 16 | } 17 | 18 | function transfer() external view; 19 | } 20 | -------------------------------------------------------------------------------- /packages/encoder-utils/src/processor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solidity_types; 2 | -------------------------------------------------------------------------------- /packages/gmp-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-gmp-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for general message passing" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | -------------------------------------------------------------------------------- /packages/gmp-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod hyperlane; 2 | pub mod polytone; 3 | -------------------------------------------------------------------------------- /packages/ibc-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-ibc-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for IBC functionalities" 7 | 8 | [features] 9 | default = ["generic"] 10 | generic = [] 11 | neutron = ["dep:neutron-sdk"] 12 | 13 | [dependencies] 14 | cw-denom = { workspace = true } 15 | cw-storage-plus = { workspace = true } 16 | cosmos-sdk-proto = { workspace = true } 17 | cosmwasm-std = { workspace = true } 18 | cosmwasm-schema = { workspace = true } 19 | serde = { workspace = true } 20 | 21 | # Optional dependencies 22 | neutron-sdk = { workspace = true, optional = true } 23 | -------------------------------------------------------------------------------- /packages/ibc-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod types; 2 | 3 | #[cfg(feature = "generic")] 4 | pub mod generic; 5 | 6 | #[cfg(feature = "neutron")] 7 | pub mod neutron; 8 | -------------------------------------------------------------------------------- /packages/lending-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-lending-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for lending integrations" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | -------------------------------------------------------------------------------- /packages/lending-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod mars; 2 | -------------------------------------------------------------------------------- /packages/library-base/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-library-base" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [dependencies] 10 | cosmwasm-schema = { workspace = true } 11 | cosmwasm-std = { workspace = true } 12 | cw-ownable = { workspace = true } 13 | cw-storage-plus = { workspace = true } 14 | cw2 = { workspace = true } 15 | schemars = { workspace = true } 16 | serde = { workspace = true } 17 | thiserror = { workspace = true } 18 | valence-macros = { workspace = true } 19 | valence-library-utils = { workspace = true } 20 | 21 | [dev-dependencies] 22 | cw-multi-test = { workspace = true } 23 | -------------------------------------------------------------------------------- /packages/library-base/README.md: -------------------------------------------------------------------------------- 1 | # Base library template 2 | 3 | This is a template for creating new libraries, it contains the basic structure and some examples with a list of TODOs to guide you through the process. 4 | -------------------------------------------------------------------------------- /packages/library-base/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Storage}; 2 | use valence_library_utils::error::{LibraryError, UnauthorizedReason}; 3 | 4 | use crate::state::PROCESSOR; 5 | 6 | pub fn assert_processor(store: &dyn Storage, sender: &Addr) -> Result<(), LibraryError> { 7 | let processor = PROCESSOR.load(store)?; 8 | if sender != processor { 9 | return Err(LibraryError::Unauthorized( 10 | UnauthorizedReason::NotAllowed {}, 11 | )); 12 | } 13 | Ok(()) 14 | } 15 | -------------------------------------------------------------------------------- /packages/library-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-library-utils" 3 | authors = { workspace = true } 4 | edition = { workspace = true } 5 | license = { workspace = true } 6 | version = { workspace = true } 7 | repository = { workspace = true } 8 | 9 | [features] 10 | default = [] 11 | testing = ["dep:cw-multi-test", "dep:cw20", "dep:cw20-base", "dep:sha2", "dep:valence-base-account"] 12 | 13 | [dependencies] 14 | cosmwasm-schema = { workspace = true } 15 | cosmwasm-std = { workspace = true } 16 | cw-denom = { workspace = true } 17 | cw-ownable = { workspace = true } 18 | cw-utils = { workspace = true } 19 | serde = { workspace = true } 20 | serde_json = { workspace = true } 21 | thiserror = { workspace = true } 22 | valence-account-utils = { workspace = true } 23 | valence-macros = { workspace = true } 24 | cw-storage-plus = { workspace = true } 25 | valence-ibc-utils = { workspace = true } 26 | 27 | # Testing dependencies 28 | cw-multi-test = { workspace = true, optional = true } 29 | cw20 = { workspace = true, optional = true } 30 | cw20-base = { workspace = true, optional = true } 31 | sha2 = { workspace = true, optional = true } 32 | valence-base-account = { workspace = true, optional = true } 33 | -------------------------------------------------------------------------------- /packages/library-utils/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_ownable::OwnershipError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug)] 6 | pub enum LibraryError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | OwnershipError(#[from] OwnershipError), 12 | 13 | #[error("Unauthorized: {0}")] 14 | Unauthorized(#[from] UnauthorizedReason), 15 | 16 | #[error("Configuration error: {0}")] 17 | ConfigurationError(String), 18 | 19 | #[error("Execution error: {0}")] 20 | ExecutionError(String), 21 | } 22 | 23 | #[derive(Error, Debug, PartialEq)] 24 | pub enum UnauthorizedReason { 25 | #[error("This address is not allowed to execute this action")] 26 | NotAllowed {}, 27 | } 28 | -------------------------------------------------------------------------------- /packages/library-utils/src/ica.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{to_json_binary, Addr, AnyMsg, CosmosMsg, Deps, StdError, StdResult, WasmMsg}; 2 | use valence_account_utils::ica::{IcaState, QueryMsg}; 3 | 4 | /// Helper function to execute proto messages using the Valence interchain account 5 | pub fn execute_on_behalf_of(msgs: Vec, account: &Addr) -> StdResult { 6 | Ok(CosmosMsg::Wasm(WasmMsg::Execute { 7 | contract_addr: account.to_string(), 8 | msg: to_json_binary(&valence_account_utils::ica::ExecuteMsg::ExecuteIcaMsg { msgs })?, 9 | funds: vec![], 10 | })) 11 | } 12 | 13 | /// Helper to get the remote address of the ICA after verifying it's created 14 | pub fn get_remote_ica_address(deps: Deps, contract_addr: &str) -> StdResult { 15 | let ica_state: IcaState = deps 16 | .querier 17 | .query_wasm_smart(contract_addr, &QueryMsg::IcaState {})?; 18 | 19 | match ica_state { 20 | IcaState::Created(ica_information) => Ok(ica_information.address), 21 | _ => Err(StdError::generic_err("ICA not created")), 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/library-utils/src/liquidity_utils.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{ensure, Decimal}; 3 | 4 | use crate::error::LibraryError; 5 | 6 | #[cw_serde] 7 | pub struct AssetData { 8 | /// Denom of the first asset 9 | pub asset1: String, 10 | /// Denom of the second asset 11 | pub asset2: String, 12 | } 13 | 14 | #[cw_serde] 15 | pub struct DecimalRange { 16 | min: Decimal, 17 | max: Decimal, 18 | } 19 | 20 | impl DecimalRange { 21 | pub fn new(min: Decimal, max: Decimal) -> Self { 22 | DecimalRange { min, max } 23 | } 24 | } 25 | 26 | impl DecimalRange { 27 | pub fn contains(&self, value: Decimal) -> Result<(), LibraryError> { 28 | ensure!( 29 | value >= self.min && value <= self.max, 30 | LibraryError::ExecutionError("Value is not within the expected range".to_string()) 31 | ); 32 | Ok(()) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/library-utils/src/msg.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use cosmwasm_schema::{cw_serde, QueryResponses}; 4 | use cosmwasm_std::{Api, Decimal, Deps}; 5 | use cw_ownable::cw_ownable_execute; 6 | 7 | use crate::error::LibraryError; 8 | 9 | #[cw_serde] 10 | pub struct InstantiateMsg { 11 | pub owner: String, 12 | pub processor: String, 13 | pub config: T, 14 | } 15 | 16 | pub trait LibraryConfigValidation { 17 | #[cfg(not(target_arch = "wasm32"))] 18 | fn pre_validate(&self, api: &dyn Api) -> Result<(), LibraryError>; 19 | fn validate(&self, deps: Deps) -> Result; 20 | } 21 | 22 | #[cw_ownable_execute] 23 | #[cw_serde] 24 | pub enum ExecuteMsg { 25 | ProcessFunction(T), 26 | UpdateConfig { new_config: U }, 27 | UpdateProcessor { processor: String }, 28 | } 29 | 30 | #[cw_serde] 31 | #[derive(QueryResponses)] 32 | pub enum DynamicRatioQueryMsg { 33 | #[returns(DynamicRatioResponse)] 34 | DynamicRatio { denoms: Vec, params: String }, 35 | } 36 | 37 | #[cw_serde] 38 | #[allow(dead_code)] 39 | pub struct DynamicRatioResponse { 40 | pub denom_ratios: HashMap, 41 | } 42 | -------------------------------------------------------------------------------- /packages/library-utils/src/raw_config.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{StdError, StdResult, Storage}; 2 | use cw_storage_plus::Item; 3 | use serde::{de::DeserializeOwned, Serialize}; 4 | 5 | /// Get the Item helper for the raw library config 6 | pub fn get_library_config_item() -> Item { 7 | Item::new("raw_library_config") 8 | } 9 | 10 | pub fn load_raw_library_config( 11 | storage: &dyn Storage, 12 | ) -> StdResult { 13 | get_library_config_item::().load(storage) 14 | } 15 | 16 | pub fn save_raw_library_config( 17 | storage: &mut dyn Storage, 18 | config: &T, 19 | ) -> StdResult<()> { 20 | get_library_config_item::().save(storage, config) 21 | } 22 | 23 | pub fn update_raw_library_config( 24 | storage: &mut dyn Storage, 25 | action: F, 26 | ) -> Result 27 | where 28 | F: FnOnce(T) -> Result, 29 | E: From, 30 | { 31 | get_library_config_item::().update(storage, action) 32 | } 33 | 34 | pub fn query_raw_library_config( 35 | storage: &dyn Storage, 36 | ) -> StdResult { 37 | load_raw_library_config(storage) 38 | } 39 | -------------------------------------------------------------------------------- /packages/liquid-staking-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-liquid-staking-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for liquid staking integrations" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | -------------------------------------------------------------------------------- /packages/liquid-staking-utils/src/drop.rs: -------------------------------------------------------------------------------- 1 | // Since drop is using an old CosmWasm version, to make it compatible with our packages, we are going to redefine the messages here using Cosmwasm 2.x that we need 2 | // for our library 3 | // The content here is from https://github.com/hadronlabs-org/drop-contracts/, which is the stable API for drop contracts 4 | 5 | use cosmwasm_schema::cw_serde; 6 | 7 | #[cw_serde] 8 | pub enum LiquidStakerExecuteMsg { 9 | Bond { 10 | receiver: Option, 11 | r#ref: Option, 12 | }, 13 | Unbond {}, 14 | } 15 | 16 | #[cw_serde] 17 | pub enum WithdrawalManagerExecuteMsg { 18 | Withdraw {}, 19 | } 20 | 21 | // NFT hook message 22 | #[cw_serde] 23 | pub enum ReceiveNftMsg { 24 | Withdraw { receiver: Option }, 25 | } 26 | -------------------------------------------------------------------------------- /packages/liquid-staking-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod drop; 2 | -------------------------------------------------------------------------------- /packages/middleware-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-middleware-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "valence middleware utilities" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | neutron-sdk = { workspace = true } 12 | thiserror = { workspace = true } 13 | prost = { workspace = true } 14 | semver = { workspace = true } 15 | -------------------------------------------------------------------------------- /packages/middleware-utils/README.md: -------------------------------------------------------------------------------- 1 | # Middleware utils 2 | 3 | Middleware utils package defines the unified types and interfaces that 4 | are used meant to be used by middleware contracts. 5 | 6 | There are two main types of such definitions: 7 | - canonical types 8 | - middleware API 9 | 10 | ## Canonical Types 11 | 12 | Types declared in `./src/canonical_types` package are ones ready to be 13 | used by Valence Programs. 14 | 15 | ## Type Registry 16 | 17 | Type registry declarations define the common API used by the middleware. 18 | All instances of type registries are expected to use those declarations 19 | in order to be compatible with Valence Protocol. 20 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/canonical_types/bank/balance.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::{from_json, Binary, Coin, StdError, StdResult}; 3 | 4 | use crate::type_registry::queries::{ValencePrimitive, ValenceTypeQuery}; 5 | 6 | #[cw_serde] 7 | pub struct ValenceBankBalance { 8 | pub assets: Vec, 9 | } 10 | 11 | #[cw_serde] 12 | #[derive(QueryResponses)] 13 | pub enum BankBalanceQuery { 14 | // IMPORTANT: if you add new variants here that return one of the following response types: 15 | // - String 16 | // - Uint64 17 | // - Uint256 18 | // make sure to extend the unit tests under contracts/middleware/asserter/src/testing 19 | // to cover that response type assertions. 20 | #[returns(ValencePrimitive)] 21 | GetDenomAmount { denom: String }, 22 | } 23 | 24 | impl ValenceTypeQuery for ValenceBankBalance { 25 | fn query(&self, msg: Binary) -> StdResult { 26 | let query_msg: BankBalanceQuery = from_json(&msg)?; 27 | match query_msg { 28 | BankBalanceQuery::GetDenomAmount { denom } => { 29 | for coin in &self.assets { 30 | if coin.denom == denom { 31 | return Ok(ValencePrimitive::Uint128(coin.amount)); 32 | } 33 | } 34 | Err(StdError::generic_err("denom not found")) 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/canonical_types/bank/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod balance; 2 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/canonical_types/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{type_registry::types::ValenceType, MiddlewareError}; 2 | 3 | pub mod bank; 4 | pub mod pools; 5 | 6 | pub trait ValenceTypeAdapter { 7 | type External; 8 | 9 | fn try_to_canonical(&self) -> Result; 10 | fn try_from_canonical(canonical: ValenceType) -> Result; 11 | } 12 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/canonical_types/pools/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod xyk; 2 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/type_registry/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod macros; 2 | pub mod queries; 3 | pub mod types; 4 | -------------------------------------------------------------------------------- /packages/middleware-utils/src/type_registry/queries.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Binary, Decimal, StdResult, Uint128, Uint256, Uint64}; 3 | 4 | use super::types::ValenceType; 5 | 6 | /// supported evaluation types. both assertion values must be of this type 7 | /// in order to evaluate the condition. 8 | #[cw_serde] 9 | pub enum ValencePrimitive { 10 | Decimal(Decimal), 11 | Uint64(Uint64), 12 | Uint128(Uint128), 13 | Uint256(Uint256), 14 | String(String), 15 | } 16 | 17 | pub trait ValenceTypeQuery { 18 | fn query(&self, msg: Binary) -> StdResult; 19 | } 20 | 21 | impl ValenceTypeQuery for ValenceType { 22 | fn query(&self, query: Binary) -> StdResult { 23 | // IMPORTANT: if you add new variants here that are capable of querying with 24 | // response values of: 25 | // - String 26 | // - Uint64 27 | // - Uint256 28 | // make sure to extend the unit tests under contracts/middleware/asserter/src/testing 29 | // with the new variant and the expected response type. 30 | let queryable: &dyn ValenceTypeQuery = match self { 31 | ValenceType::XykPool(var) => var, 32 | ValenceType::BankBalance(var) => var, 33 | }; 34 | queryable.query(query) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/osmosis-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-osmosis-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Utils for osmosis libraries" 7 | 8 | [features] 9 | default = [] 10 | testing = ["dep:osmosis-test-tube"] 11 | 12 | [dependencies] 13 | cosmwasm-std = { workspace = true } 14 | cosmwasm-schema = { workspace = true } 15 | osmosis-test-tube = { workspace = true, optional = true } 16 | valence-account-utils = { workspace = true } 17 | osmosis-std = { workspace = true } 18 | valence-library-utils = { workspace = true } 19 | -------------------------------------------------------------------------------- /packages/osmosis-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "testing")] 2 | pub mod suite; 3 | 4 | pub mod utils; 5 | 6 | #[cfg(feature = "testing")] 7 | pub mod testing; 8 | -------------------------------------------------------------------------------- /packages/osmosis-utils/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod balancer; 2 | pub mod concentrated_liquidity; 3 | -------------------------------------------------------------------------------- /packages/processor-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-processor-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Helpers for processor contract" 7 | 8 | [dependencies] 9 | cosmwasm-std = { workspace = true } 10 | cosmwasm-schema = { workspace = true } 11 | valence-authorization-utils = { workspace = true } 12 | valence-gmp-utils = { workspace = true } 13 | cw-storage-plus = { workspace = true } 14 | serde = { workspace = true } 15 | cw-utils = { workspace = true } 16 | serde_json = { workspace = true } 17 | -------------------------------------------------------------------------------- /packages/processor-utils/src/callback.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, Binary}; 3 | use valence_authorization_utils::callback::ExecutionResult; 4 | 5 | use crate::processor::MessageBatch; 6 | 7 | #[cw_serde] 8 | pub struct PendingCallback { 9 | // Address that needed to send the callback 10 | pub address: Addr, 11 | // Message that we are expecting 12 | pub callback_msg: Binary, 13 | // Batch that the callback is for (so that we can requeue if wrong callback is received) 14 | pub message_batch: MessageBatch, 15 | } 16 | 17 | #[cw_serde] 18 | pub struct PendingPolytoneCallbackInfo { 19 | pub execution_result: ExecutionResult, 20 | pub state: PolytoneCallbackState, 21 | } 22 | 23 | #[cw_serde] 24 | pub enum PolytoneCallbackState { 25 | UnexpectedError(String), 26 | Pending, 27 | TimedOut, 28 | } 29 | 30 | #[cw_serde] 31 | pub enum PolytoneCallbackMsg { 32 | ExecutionID(u64), 33 | CreateProxy, 34 | } 35 | -------------------------------------------------------------------------------- /packages/processor-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod callback; 2 | pub mod msg; 3 | pub mod processor; 4 | pub mod queue; 5 | -------------------------------------------------------------------------------- /packages/program-registry-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-program-registry-utils" 3 | edition = { workspace = true } 4 | license = { workspace = true } 5 | version = { workspace = true } 6 | repository = { workspace = true } 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | cosmwasm-schema = { workspace = true } 12 | cosmwasm-std = { workspace = true } 13 | serde = { workspace = true } 14 | serde_json = { workspace = true } 15 | -------------------------------------------------------------------------------- /packages/supervaults-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-supervaults-utils" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Utils for Neutron supervaults" 7 | 8 | [features] 9 | default = [] 10 | 11 | [dependencies] 12 | cosmwasm-std = { workspace = true } 13 | cosmwasm-schema = { workspace = true } 14 | valence-account-utils = { workspace = true } 15 | valence-library-utils = { workspace = true } 16 | # TODO: update these to point to respective releases once cut 17 | neutron-std = { git = "https://github.com/neutron-org/neutron-std", branch = "temp/pd_and_sod" } 18 | mmvault = { git = "https://github.com/neutron-org/slinky-vault", package = "mmvault" } 19 | -------------------------------------------------------------------------------- /packages/supervaults-utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{ensure, Deps}; 2 | use valence_library_utils::{error::LibraryError, liquidity_utils::AssetData}; 3 | 4 | pub mod msg; 5 | pub mod prec_dec_range; 6 | pub mod queries; 7 | 8 | pub fn ensure_correct_vault( 9 | deps: Deps, 10 | vault_addr: String, 11 | asset_data: &AssetData, 12 | lp_denom: &str, 13 | ) -> Result<(), LibraryError> { 14 | let vault_config: mmvault::state::Config = deps 15 | .querier 16 | .query_wasm_smart(vault_addr, &mmvault::msg::QueryMsg::GetConfig {})?; 17 | 18 | ensure!( 19 | asset_data.asset1 == vault_config.pair_data.token_0.denom 20 | && asset_data.asset2 == vault_config.pair_data.token_1.denom, 21 | LibraryError::ConfigurationError( 22 | "Vault validation failed due to asset mismatch".to_string(), 23 | ) 24 | ); 25 | 26 | ensure!( 27 | vault_config.lp_denom == lp_denom, 28 | LibraryError::ConfigurationError(format!( 29 | "Vault LP denom mismatch; expected: {lp_denom}, got {}", 30 | vault_config.lp_denom 31 | )) 32 | ); 33 | 34 | Ok(()) 35 | } 36 | -------------------------------------------------------------------------------- /packages/supervaults-utils/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Uint128; 2 | 3 | pub fn get_mmvault_withdraw_msg(amount: Uint128) -> mmvault::msg::ExecuteMsg { 4 | mmvault::msg::ExecuteMsg::Withdraw { amount } 5 | } 6 | 7 | pub fn get_mmvault_deposit_msg() -> mmvault::msg::ExecuteMsg { 8 | mmvault::msg::ExecuteMsg::Deposit {} 9 | } 10 | -------------------------------------------------------------------------------- /packages/supervaults-utils/src/prec_dec_range.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Display; 2 | 3 | use cosmwasm_schema::cw_serde; 4 | use cosmwasm_std::ensure; 5 | use neutron_std::types::neutron::util::precdec::PrecDec; 6 | use valence_library_utils::error::LibraryError; 7 | 8 | #[cw_serde] 9 | pub struct PrecDecimalRange { 10 | pub min: PrecDec, 11 | pub max: PrecDec, 12 | } 13 | 14 | impl Display for PrecDecimalRange { 15 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 16 | write!(f, "[{}, {}]", self.min, self.max) 17 | } 18 | } 19 | 20 | impl PrecDecimalRange { 21 | /// validates that given `PrecDec` value is contained in the range 22 | pub fn ensure_contains(&self, val: PrecDec) -> Result<(), LibraryError> { 23 | ensure!( 24 | val.ge(&self.min) && val.lt(&self.max), 25 | LibraryError::ExecutionError(format!("expected range: {self}, got: {val}")) 26 | ); 27 | Ok(()) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/supervaults-utils/src/queries.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Deps; 2 | use neutron_std::types::neutron::util::precdec::PrecDec; 3 | use valence_library_utils::error::LibraryError; 4 | 5 | pub fn query_vault_price(deps: Deps, vault_addr: String) -> Result { 6 | let price_response: mmvault::msg::CombinedPriceResponse = deps 7 | .querier 8 | .query_wasm_smart(vault_addr, &mmvault::msg::QueryMsg::GetPrices {})?; 9 | 10 | Ok(price_response.price_0_to_1) 11 | } 12 | -------------------------------------------------------------------------------- /packages/valence-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "valence-macros" 3 | version = { workspace = true } 4 | edition = { workspace = true } 5 | authors = { workspace = true } 6 | description = "Macros for Valence libraries and accounts" 7 | license = { workspace = true } 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | cosmwasm-schema = { workspace = true } 14 | cosmwasm-std = { workspace = true } 15 | proc-macro2 = "1.0" 16 | quote = "1.0" 17 | syn = { version = "2.0", features = ["full", "parsing", "extra-traits"] } 18 | -------------------------------------------------------------------------------- /program-manager/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | schema = "run --bin schema" 4 | -------------------------------------------------------------------------------- /program-manager/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timewave-computer/valence-protocol/b96ab6eff27383987b7deecacdea60efd2496331/program-manager/README.md -------------------------------------------------------------------------------- /program-manager/src/bin/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, write_api}; 2 | use valence_program_manager::{ 3 | program_config::ProgramConfig, program_migration::ProgramConfigMigrate, 4 | program_update::ProgramConfigUpdate, 5 | }; 6 | 7 | #[cw_serde] 8 | struct Types { 9 | program_config: ProgramConfig, 10 | program_config_update: ProgramConfigUpdate, 11 | program_config_migration: ProgramConfigMigrate, 12 | } 13 | 14 | fn main() { 15 | write_api! { 16 | instantiate: Types, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /program-manager/src/connectors.rs: -------------------------------------------------------------------------------- 1 | use dashmap::DashMap; 2 | 3 | use crate::{ 4 | domain::{Connector, Domain}, 5 | error::{ManagerError, ManagerResult}, 6 | }; 7 | 8 | #[derive(Debug, Default)] 9 | pub struct Connectors { 10 | connectors: DashMap>, 11 | } 12 | 13 | impl Connectors { 14 | /// Get the domain from ctx if exists 15 | /// otherwise it gets a new domain connector and save it in cache 16 | pub async fn get_or_create_connector( 17 | &self, 18 | domain: &Domain, 19 | ) -> ManagerResult>> { 20 | if !self.connectors.contains_key(domain) { 21 | let connector = domain.generate_connector().await?; 22 | self.connectors.insert(domain.clone(), connector); 23 | } 24 | 25 | self.connectors 26 | .get_mut(domain) 27 | .ok_or(ManagerError::generic_err( 28 | "Failed to get connector from cache", 29 | )) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /program-manager/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use crate::config::{ConfigResult, GLOBAL_CONFIG}; 4 | 5 | pub async fn get_polytone_info( 6 | main_chain: &str, 7 | other_chain: &str, 8 | ) -> ConfigResult> { 9 | let gc = GLOBAL_CONFIG.lock().await; 10 | // get from neutron to current domain bridge info 11 | Ok(gc 12 | .get_bridge_info(main_chain, other_chain)? 13 | .get_polytone_info() 14 | .clone()) 15 | } 16 | -------------------------------------------------------------------------------- /program-manager/src/macros.rs: -------------------------------------------------------------------------------- 1 | macro_rules! ensure { 2 | ($cond:expr, $($err:tt)*) => { 3 | if !$cond { 4 | return Err(anyhow::anyhow!($($err)*).into()); 5 | } 6 | }; 7 | } 8 | 9 | pub(crate) use ensure; 10 | -------------------------------------------------------------------------------- /scripts/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CHAIN=$1 4 | shift 5 | COMMAND=$1 6 | shift 7 | 8 | if [[ "$CHAIN" == 'neutron' || "$CHAIN" == 'ntrn' ]]; then 9 | BINARY="neutrond" 10 | GAS_PRICES="0.1untrn" 11 | OWNER_ADDR="neutron1tl0w0djc5y53aqfr60a794f02drwktpujm5xxe" 12 | ADMIN_ADDR="neutron1tl0w0djc5y53aqfr60a794f02drwktpujm5xxe" 13 | 14 | CODE_ID_REGISTRY=6774 15 | 16 | else 17 | echo "Unknown chain" 18 | fi 19 | 20 | TESTNET_INFO="--node https://neutron-testnet-rpc.polkachu.com:443 --chain-id pion-1" 21 | LOCAL_IC_INFO="--node http://0.0.0.0:45791 --chain-id localneutron-1" 22 | 23 | TESTNET_EXECUTE_FLAGS="--gas-prices $GAS_PRICES --gas auto --gas-adjustment 1.5 --output json $TESTNET_INFO -y" 24 | LOCAL_IC_EXECUTE_FLAGS="--gas-prices $GAS_PRICES --gas auto --gas-adjustment 1.5 --output json $LOCAL_IC_INFO -y" 25 | 26 | ################################################ 27 | ################### Registry ################### 28 | ################################################ 29 | if [[ "$COMMAND" == 'registry' ]]; then 30 | init_msg=$(jq -n \ 31 | --arg admin "$ADMIN_ADDR" \ 32 | '{ 33 | admin: $admin 34 | }') 35 | 36 | $BINARY tx wasm init $CODE_ID_REGISTRY "$init_msg" --label "Valence program registry" \ 37 | --admin $OWNER_ADDR --from $OWNER_ADDR $TESTNET_EXECUTE_FLAGS 38 | 39 | else 40 | echo "Unknown command" 41 | fi 42 | -------------------------------------------------------------------------------- /scripts/start-local-ic.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cd e2e 3 | 4 | CHAIN_CONFIG=$1 5 | MAX_ATTEMPTS=10 6 | ATTEMPT=1 7 | SUCCESS=false 8 | 9 | # Determine the path to the local-ic binary 10 | LOCAL_IC_BIN=${LOCAL_IC_BIN:-} 11 | 12 | if [[ -z "$LOCAL_IC_BIN" ]]; then 13 | if command -v local-ic &>/dev/null; then 14 | LOCAL_IC_BIN=$(command -v local-ic) 15 | elif [[ -x "/tmp/local-ic" ]]; then 16 | LOCAL_IC_BIN="/tmp/local-ic" 17 | else 18 | echo "Error: local-ic binary not found in PATH or /tmp. Please set LOCAL_IC_BIN environment variable." 19 | exit 1 20 | fi 21 | fi 22 | 23 | while [[ "$SUCCESS" = false && "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]]; do 24 | "$LOCAL_IC_BIN" start $CHAIN_CONFIG --api-port 42069 & 25 | curl --head -X GET --retry 200 --retry-connrefused --retry-delay 5 http://localhost:42069 26 | echo "$(date): Successfully queried Local-IC" 27 | sleep 20 28 | # Check to see if chain config has been created which is the last step of local-ic startup 29 | CHAIN_INFO=$( uint256) public tokenRatios; 9 | 10 | function setRatio(IERC20 token, uint256 ratio) external { 11 | tokenRatios[token] = ratio; 12 | } 13 | 14 | function queryDynamicRatio(IERC20 token, bytes calldata /*params*/ ) external view returns (uint256) { 15 | uint256 ratio = tokenRatios[token]; 16 | return ratio > 0 ? ratio : 300_000_000_000_000_000; // Default 30% if not set 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /solidity/test/mocks/MockERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | pragma solidity ^0.8.28; 3 | 4 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; 6 | 7 | contract MockERC20 is ERC20, ERC20Burnable { 8 | uint8 private _decimals; 9 | 10 | constructor(string memory name, string memory symbol, uint8 decimalsValue) ERC20(name, symbol) { 11 | _decimals = decimalsValue; 12 | } 13 | 14 | function decimals() public view virtual override returns (uint8) { 15 | return _decimals; 16 | } 17 | 18 | function mint(address to, uint256 amount) public { 19 | _mint(to, amount); 20 | } 21 | 22 | function burn(address from, uint256 amount) public { 23 | _burn(from, amount); 24 | } 25 | } 26 | --------------------------------------------------------------------------------