├── solana
├── scripts
│ ├── omniswap
│ │ ├── __init__.py
│ │ ├── program_id.py
│ │ ├── accounts
│ │ │ └── __init__.py
│ │ ├── types
│ │ │ └── __init__.py
│ │ ├── errors
│ │ │ └── __init__.py
│ │ └── instructions
│ │ │ ├── set_so_fee.py
│ │ │ ├── set_redeem_proxy.py
│ │ │ ├── so_swap_close_pending_request.py
│ │ │ ├── set_wormhole_reserve.py
│ │ │ ├── set_price_ratio.py
│ │ │ └── wrap_sol.py
│ ├── get_token_decimals.py
│ ├── get_tx.py
│ ├── check_request.py
│ ├── get_or_create_ata.py
│ ├── custom_simulate.py
│ └── test_dex
│ │ ├── get_or_create_ata.ts
│ │ └── postvaa.ts
├── latestFromBlock.json
├── programs
│ └── omniswap
│ │ ├── Xargo.toml
│ │ ├── src
│ │ ├── dex
│ │ │ └── mod.rs
│ │ ├── constants.rs
│ │ ├── utils.rs
│ │ ├── state
│ │ │ ├── mod.rs
│ │ │ ├── price_manager.rs
│ │ │ ├── fee_config.rs
│ │ │ ├── cross_request.rs
│ │ │ └── redeemer_config.rs
│ │ └── instructions
│ │ │ ├── set_redeem_proxy.rs
│ │ │ ├── set_so_fee.rs
│ │ │ ├── set_wormhole_reserve.rs
│ │ │ ├── close_pending_request.rs
│ │ │ ├── set_price_ratio.rs
│ │ │ ├── wrap_sol.rs
│ │ │ └── mod.rs
│ │ └── Cargo.toml
├── .prettierignore
├── modules
│ └── wormhole-anchor-sdk
│ │ ├── src
│ │ ├── lib.rs
│ │ ├── wormhole
│ │ │ ├── mod.rs
│ │ │ ├── types.rs
│ │ │ ├── program.rs
│ │ │ ├── message.rs
│ │ │ └── constants.rs
│ │ └── token_bridge
│ │ │ ├── mod.rs
│ │ │ ├── constants.rs
│ │ │ ├── program.rs
│ │ │ └── utils.rs
│ │ └── Cargo.toml
├── Cargo.toml
├── tsconfig.json
├── omniswap-keypair-4edLhT4MAausnqaxvB4ezcVG1adFnGw1QUMTvDMp4JVY.json
├── Anchor.toml
├── .rustfmt.toml
├── .env.example
└── package.json
├── .gitattributes
├── aptos
├── scripts
│ ├── __init__.py
│ ├── relayer
│ │ └── README.md
│ └── compile.py
├── .env.example
├── requirements.txt
├── mocks
│ ├── README.md
│ └── Move.toml
├── README.md
└── sources
│ ├── external_interface.move
│ ├── utils
│ └── u16.move
│ └── so_diamond.move
├── sui
├── cetus
│ ├── move-stl
│ │ ├── README.md
│ │ ├── SkipList.jpg
│ │ ├── .gitignore
│ │ ├── aptos
│ │ │ ├── Move.toml
│ │ │ └── Move.lock
│ │ └── sui
│ │ │ ├── Move.toml
│ │ │ └── Move.lock
│ ├── integer-mate
│ │ ├── README.md
│ │ ├── .gitignore
│ │ ├── aptos
│ │ │ ├── Move.toml
│ │ │ └── sources
│ │ │ │ ├── full_math_u64.move
│ │ │ │ ├── math_u256.move
│ │ │ │ └── full_math_u128.move
│ │ └── sui
│ │ │ ├── Move.toml
│ │ │ ├── Move.lock
│ │ │ └── sources
│ │ │ ├── full_math_u64.move
│ │ │ ├── full_math_u128.move
│ │ │ └── math_u256.move
│ └── cetus-clmm-interface
│ │ └── sui
│ │ └── clmmpool
│ │ ├── sources
│ │ ├── acl.move
│ │ ├── partner.move
│ │ ├── tick.move
│ │ ├── rewarder.move
│ │ ├── config.move
│ │ └── position.move
│ │ ├── Move.toml
│ │ └── Move.lock
├── .env.example
├── requirements.txt
├── scripts
│ ├── relayer
│ │ └── README.md
│ └── __init__.py
├── test_coins
│ ├── Move.toml
│ ├── Move.lock
│ ├── sources
│ │ ├── usdc.move
│ │ ├── btc.move
│ │ ├── usdt.move
│ │ └── coins.move
│ └── README.md
├── README.md
├── sources
│ └── lib
│ │ └── helper.move
└── Move.toml
├── ethereum
├── scripts
│ ├── data
│ │ ├── chunks
│ │ │ ├── root.json
│ │ │ └── mapping.json
│ │ ├── README.md
│ │ ├── 20240709-bevm-ordinals-runes-15.json
│ │ └── package.json
│ ├── relayer
│ │ └── README.md
│ ├── deploy_genesis_box.py
│ ├── chainx_bridge.py
│ └── publish.py
├── package.json
├── requirements.txt
├── .env.example
├── contracts
│ ├── Interfaces
│ │ ├── UniswapV2
│ │ │ ├── INetswapRouter02.sol
│ │ │ ├── IUniswapV2Factory.sol
│ │ │ ├── IUniswapV2Router02.sol
│ │ │ └── IUniswapV2Router02AVAX.sol
│ │ ├── IWETH.sol
│ │ ├── Bool
│ │ │ ├── IBoolSwapConsumer.sol
│ │ │ ├── IBoolSwapPool.sol
│ │ │ ├── IBoolSwapFactory.sol
│ │ │ └── IBoolSwapRouter.sol
│ │ ├── Stargate
│ │ │ ├── IStargateRouterEth.sol
│ │ │ ├── IStargateFactory.sol
│ │ │ ├── IStargateReceiver.sol
│ │ │ ├── IStargateFeeLibrary.sol
│ │ │ └── IStargateEthVault.sol
│ │ ├── ILibPrice.sol
│ │ ├── GMX
│ │ │ ├── IGMXV1Reader.sol
│ │ │ └── IGMXV1Router.sol
│ │ ├── ICorrectSwap.sol
│ │ ├── Multichain
│ │ │ ├── IMultiChainUnderlying.sol
│ │ │ └── IMultiChainAnycallProxy.sol
│ │ ├── TraderJoe
│ │ │ ├── IWNATIVE.sol
│ │ │ ├── ILBFlashLoanCallback.sol
│ │ │ ├── IPendingOwnable.sol
│ │ │ └── IJoeFactory.sol
│ │ ├── ILibSoFee.sol
│ │ ├── ILibPriceV2.sol
│ │ ├── CCTP
│ │ │ ├── IReceiver.sol
│ │ │ ├── ITokenMessenger.sol
│ │ │ ├── IMessageTransmitter.sol
│ │ │ └── IMessageHandler.sol
│ │ ├── IERC165.sol
│ │ ├── ILibSoFeeV2.sol
│ │ ├── CoreBridge
│ │ │ ├── IWrappedTokenBridge.sol
│ │ │ └── IOriginalTokenBridge.sol
│ │ ├── IERC173.sol
│ │ ├── Chainlink
│ │ │ └── IAggregatorV3Interface.sol
│ │ ├── Curve
│ │ │ └── ICurveFi.sol
│ │ ├── Lynex
│ │ │ └── ILynexRouter.sol
│ │ ├── IDiamondCut.sol
│ │ ├── Pearl
│ │ │ └── IPearlRouter.sol
│ │ ├── Balancer
│ │ │ └── IAsset.sol
│ │ ├── Quickswap
│ │ │ └── IQuickSwapCallback.sol
│ │ ├── ISo.sol
│ │ ├── IDiamondLoupe.sol
│ │ └── Camelot
│ │ │ └── ICamelotRouter.sol
│ ├── Libraries
│ │ ├── LibStorage.sol
│ │ ├── LibUtil.sol
│ │ ├── LibSoFeeCCTPV1.sol
│ │ ├── LibSoFeeMultiChainV1.sol
│ │ └── LibSoFeeBoolV1.sol
│ ├── Helpers
│ │ ├── MockToken.sol
│ │ ├── MockNFT.sol
│ │ ├── BoolSwapPathConverter.sol
│ │ ├── GenesisBoxStaking.sol
│ │ └── ReentrancyGuard.sol
│ ├── Deployer
│ │ └── ContractDeployerFactory.sol
│ ├── Errors
│ │ └── GenericErrors.sol
│ └── Facets
│ │ └── DiamondCutFacet.sol
├── interfaces
│ ├── IStargateBridge.sol
│ ├── ILayerZeroMessagingLibrary.sol
│ └── ILayerZeroUserApplicationConfig.sol
├── zksync-era
│ ├── contracts
│ │ ├── Interfaces
│ │ │ ├── IWETH.sol
│ │ │ ├── Bool
│ │ │ │ ├── IBoolSwapConsumer.sol
│ │ │ │ ├── IBoolSwapPool.sol
│ │ │ │ ├── IBoolSwapFactory.sol
│ │ │ │ └── IBoolSwapRouter.sol
│ │ │ ├── Stargate
│ │ │ │ ├── IStargateRouterEth.sol
│ │ │ │ ├── IStargateFactory.sol
│ │ │ │ ├── IStargateReceiver.sol
│ │ │ │ ├── IStargateFeeLibrary.sol
│ │ │ │ └── IStargateEthVault.sol
│ │ │ ├── ICorrectSwap.sol
│ │ │ ├── GMX
│ │ │ │ ├── IGMXV1Reader.sol
│ │ │ │ └── IGMXV1Router.sol
│ │ │ ├── ILibPrice.sol
│ │ │ ├── Multichain
│ │ │ │ ├── IMultiChainUnderlying.sol
│ │ │ │ └── IMultiChainAnycallProxy.sol
│ │ │ ├── TraderJoe
│ │ │ │ ├── IWNATIVE.sol
│ │ │ │ ├── ILBFlashLoanCallback.sol
│ │ │ │ ├── IPendingOwnable.sol
│ │ │ │ └── IJoeFactory.sol
│ │ │ ├── ILibSoFee.sol
│ │ │ ├── ILibPriceV2.sol
│ │ │ ├── CCTP
│ │ │ │ ├── IReceiver.sol
│ │ │ │ ├── ITokenMessenger.sol
│ │ │ │ ├── IMessageTransmitter.sol
│ │ │ │ └── IMessageHandler.sol
│ │ │ ├── IERC165.sol
│ │ │ ├── ILibSoFeeV2.sol
│ │ │ ├── IERC173.sol
│ │ │ ├── UniswapV2
│ │ │ │ ├── IUniswapV2Factory.sol
│ │ │ │ ├── IUniswapV2Router02.sol
│ │ │ │ └── IUniswapV2Router02AVAX.sol
│ │ │ ├── Chainlink
│ │ │ │ └── IAggregatorV3Interface.sol
│ │ │ ├── Curve
│ │ │ │ └── ICurveFi.sol
│ │ │ ├── IDiamondCut.sol
│ │ │ ├── Pearl
│ │ │ │ └── IPearlRouter.sol
│ │ │ ├── Balancer
│ │ │ │ └── IAsset.sol
│ │ │ ├── Quickswap
│ │ │ │ └── IQuickSwapCallback.sol
│ │ │ ├── ISo.sol
│ │ │ ├── IDiamondLoupe.sol
│ │ │ └── Camelot
│ │ │ │ └── ICamelotRouter.sol
│ │ ├── Libraries
│ │ │ ├── LibStorage.sol
│ │ │ ├── LibUtil.sol
│ │ │ ├── LibSoFeeCCTPV1.sol
│ │ │ ├── LibSoFeeMultiChainV1.sol
│ │ │ └── LibSoFeeBoolV1.sol
│ │ ├── Helpers
│ │ │ ├── MockToken.sol
│ │ │ ├── BoolSwapPathConverter.sol
│ │ │ └── ReentrancyGuard.sol
│ │ ├── Errors
│ │ │ └── GenericErrors.sol
│ │ └── Facets
│ │ │ └── DiamondCutFacet.sol
│ ├── package.json
│ ├── deployed.json
│ └── hardhat.config.ts
├── tests
│ └── test_gensis_box.py
└── export
│ └── ContractDeployed.json
├── utils
├── README.md
└── setup.py
├── LICENSE
└── README.md
/solana/scripts/omniswap/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/solana/latestFromBlock.json:
--------------------------------------------------------------------------------
1 | {
2 | "bsc-test": 34042250
3 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.sol linguist-language=Solidity
2 | *.vy linguist-language=Python
3 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/Xargo.toml:
--------------------------------------------------------------------------------
1 | [target.bpfel-unknown-unknown.dependencies.std]
2 | features = []
3 |
--------------------------------------------------------------------------------
/aptos/scripts/__init__.py:
--------------------------------------------------------------------------------
1 | # @Time : 2023/3/7 13:25
2 | # @Author : WeiDai
3 | # @FileName: __init__.py
4 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/README.md:
--------------------------------------------------------------------------------
1 | # SkipList
2 |
3 | A skip link list implement by Move language in Aptos and Sui.
--------------------------------------------------------------------------------
/aptos/.env.example:
--------------------------------------------------------------------------------
1 | ### uncomment me to use the variables
2 | export PRIVATE_KEY='0xasdfasdfasdfasdfasdfasdfasdfas'
3 |
--------------------------------------------------------------------------------
/solana/.prettierignore:
--------------------------------------------------------------------------------
1 |
2 | .anchor
3 | .DS_Store
4 | target
5 | node_modules
6 | dist
7 | build
8 | test-ledger
9 |
--------------------------------------------------------------------------------
/sui/.env.example:
--------------------------------------------------------------------------------
1 | ### uncomment me to use the variables
2 | export PRIVATE_KEY='0xasdfasdfasdfasdfasdfasdfasdfas'
3 |
--------------------------------------------------------------------------------
/ethereum/scripts/data/chunks/root.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": "0x0af56c4a460194df83b31f068a4c5bf9a915e97532de75437f651c488f3fd7d2"
3 | }
--------------------------------------------------------------------------------
/sui/cetus/move-stl/SkipList.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luckypenny1632333/OmniSwap/HEAD/sui/cetus/move-stl/SkipList.jpg
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/dex/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod swap_whirlpool_cpi;
2 |
3 | pub const ORCA_WHIRLPOOL_SWAP: [u8; 9] = *b"Whirlpool";
4 |
--------------------------------------------------------------------------------
/ethereum/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "prettier": "^3.2.5",
4 | "prettier-plugin-solidity": "^1.3.1"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/ethereum/requirements.txt:
--------------------------------------------------------------------------------
1 | aptos_sdk
2 | python-dotenv
3 | pathlib
4 | pyyaml
5 | toml
6 | requests
7 | eth-brownie
8 | aptos-brownie
9 | ccxt
10 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/README.md:
--------------------------------------------------------------------------------
1 | # IntegerMate
2 |
3 | A Library of move module provides signed integer and some integer math functions.
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/aptos/requirements.txt:
--------------------------------------------------------------------------------
1 | aptos_sdk
2 | python-dotenv
3 | pathlib
4 | pyyaml
5 | toml
6 | requests
7 | eth-brownie
8 | aptos-brownie
9 | ccxt==1.72.64
10 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/program_id.py:
--------------------------------------------------------------------------------
1 | from solders.pubkey import Pubkey
2 |
3 | PROGRAM_ID = Pubkey.from_string("4edLhT4MAausnqaxvB4ezcVG1adFnGw1QUMTvDMp4JVY")
4 |
--------------------------------------------------------------------------------
/aptos/mocks/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | The Omniswap test environment is initialized here to facilitate off-chain testing:
4 | 1. Initialize Coin
5 | 2. Add liquidity
6 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/.gitignore:
--------------------------------------------------------------------------------
1 | /sui/.idea
2 | /sui/sui.log.*
3 | /aptos/.idea
4 | /aptos/.aptos
5 | /sui/build
6 | /aptos/build
7 | /build
8 | /.idea
9 | /.aptos
10 |
--------------------------------------------------------------------------------
/sui/requirements.txt:
--------------------------------------------------------------------------------
1 | aptos_sdk
2 | python-dotenv
3 | pathlib
4 | pyyaml
5 | toml
6 | requests
7 | eth-brownie
8 | aptos-brownie
9 | sui-brownie
10 | ccxt==1.72.64
11 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/.gitignore:
--------------------------------------------------------------------------------
1 | # Added by cargo
2 | .idea/*
3 | /.idea
4 | /aptos/.idea
5 | /aptos/build
6 | /aptos/.aptos
7 | /sui/.idea
8 | /sui/build
9 | /sui/sui.log*
10 |
--------------------------------------------------------------------------------
/ethereum/.env.example:
--------------------------------------------------------------------------------
1 | ### uncomment me to use the variables
2 | # export WEB3_INFURA_PROJECT_ID='aaa5aa5a5a5a55555aaa555a5a5555a'
3 | # export PRIVATE_KEY='0xasdfasdfasdfasdfasdfasdfasdfas'
4 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/UniswapV2/INetswapRouter02.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | import "./INetswapRouter01.sol";
4 |
5 | interface INetswapRouter02 is INetswapRouter01 {}
6 |
--------------------------------------------------------------------------------
/ethereum/scripts/relayer/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | This is a relay program. Responsible for omniswap's wormhole aptos relay.
4 |
5 | ~~~shell
6 | brownie run scripts/relayer/evm.py
7 | ~~~
8 |
--------------------------------------------------------------------------------
/sui/scripts/relayer/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | This is a relay program. Responsible for omniswap's wormhole sui and evm relay.
4 |
5 | ~~~shell
6 | brownie run scripts/relayer/sui.py
7 | ~~~
8 |
--------------------------------------------------------------------------------
/aptos/scripts/relayer/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | This is a relay program. Responsible for omniswap's wormhole aptos and evm relay.
4 |
5 | ~~~shell
6 | brownie run scripts/relayer/aptos.py
7 | ~~~
8 |
--------------------------------------------------------------------------------
/ethereum/scripts/data/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | Since python did not find a warehouse consistent with openzeppelin's MerkleProof, I chose to use js to generate
4 |
5 | ~~~
6 | npm run start
7 | ~~~
8 |
9 |
--------------------------------------------------------------------------------
/ethereum/interfaces/IStargateBridge.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 |
6 | interface IStargateBridge {
7 | function layerZeroEndpoint() external view returns (address);
8 | }
9 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![allow(clippy::result_large_err)]
2 |
3 | pub mod wormhole;
4 |
5 | #[cfg(feature = "token-bridge")]
6 | pub mod token_bridge;
7 |
8 | #[macro_use]
9 | extern crate cfg_if;
10 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/acl.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::acl {
2 | use move_stl::linked_table::LinkedTable;
3 |
4 | struct ACL has store {
5 | permissions: LinkedTable
6 | }
7 | }
--------------------------------------------------------------------------------
/solana/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | members = [
3 | "programs/*"
4 | ]
5 |
6 | [profile.release]
7 | overflow-checks = true
8 | lto = "fat"
9 | codegen-units = 1
10 | [profile.release.build-override]
11 | opt-level = 3
12 | incremental = false
13 | codegen-units = 1
14 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/aptos/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = 'MoveSTL'
3 | version = '1.0.0'
4 | [dependencies.AptosFramework]
5 | git = 'https://github.com/aptos-labs/aptos-core.git'
6 | rev = 'main'
7 | subdir = 'aptos-move/framework/aptos-framework'
8 | [addresses]
9 | move_stl = "0x1234"
10 |
--------------------------------------------------------------------------------
/sui/scripts/__init__.py:
--------------------------------------------------------------------------------
1 | # @Time : 2023/3/7 13:25
2 | # @Author : WeiDai
3 | # @FileName: __init__.py
4 | from pathlib import Path
5 |
6 | import sui_brownie
7 |
8 | sui_project = sui_brownie.SuiProject(project_path=Path(__file__).parent.parent, network="sui-mainnet")
9 | sui_project.active_account("Fee")
10 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/wormhole/mod.rs:
--------------------------------------------------------------------------------
1 | pub use accounts::*;
2 | pub use constants::*;
3 | pub use instructions::*;
4 | pub use message::*;
5 | pub use types::*;
6 |
7 | pub mod accounts;
8 | pub mod constants;
9 | pub mod instructions;
10 | pub mod message;
11 | pub mod program;
12 | pub mod types;
13 |
--------------------------------------------------------------------------------
/aptos/scripts/compile.py:
--------------------------------------------------------------------------------
1 | from scripts.serde_struct import omniswap_aptos_path
2 | import aptos_brownie
3 |
4 |
5 | def main(net="aptos-testnet"):
6 | aptos_brownie.AptosPackage(
7 | project_path=omniswap_aptos_path,
8 | network=net
9 | )
10 |
11 |
12 | if __name__ == '__main__':
13 | main()
14 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/token_bridge/mod.rs:
--------------------------------------------------------------------------------
1 | pub use accounts::*;
2 | pub use constants::*;
3 | pub use instructions::*;
4 | pub use message::*;
5 | pub use utils::*;
6 |
7 | pub mod accounts;
8 | pub mod constants;
9 | pub mod instructions;
10 | pub mod message;
11 | pub mod program;
12 | pub mod utils;
13 |
--------------------------------------------------------------------------------
/sui/test_coins/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "TestCoins"
3 | version = "1.0.0"
4 |
5 | [addresses]
6 | test_coins = "0x0"
7 | sui = "0x2"
8 |
9 | [dependencies.Sui]
10 | git = "https://github.com/MystenLabs/sui.git"
11 | subdir = "crates/sui-framework/packages/sui-framework"
12 | rev = "cab7e9762d4d75126a78fdd009b405745657fe57"
13 |
--------------------------------------------------------------------------------
/solana/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "types": ["mocha", "chai", "node"],
4 | "typeRoots": ["./node_modules/@types"],
5 | "lib": ["es2015"],
6 | "module": "commonjs",
7 | "target": "es6",
8 | "esModuleInterop": true,
9 | "resolveJsonModule": true,
10 | "skipLibCheck": true
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sui/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Overview
4 |
5 | Here is OmniSwap's sui contract repository.
6 |
7 | ## Deploy
8 |
9 | ~~~shell
10 | brownie run scripts/deploy.py
11 | ~~~
12 |
13 | ## Swap
14 |
15 | ~~~shell
16 | brownie run scripts/wormhole.py
17 | ~~~
18 |
19 | ## Relayer
20 |
21 | ~~~shell
22 | brownie run scripts/relayer/relayer.py
23 | ~~~
24 |
--------------------------------------------------------------------------------
/aptos/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Overview
4 |
5 | Here is OmniSwap's aptos contract repository.
6 |
7 | ## Deploy
8 |
9 | ~~~shell
10 | brownie run scripts/deploy.py
11 | ~~~
12 |
13 | ## Swap
14 |
15 | ~~~shell
16 | brownie run scripts/wormhole.py
17 | ~~~
18 |
19 | ## Relayer
20 |
21 | ~~~shell
22 | brownie run scripts/relayer/relayer.py
23 | ~~~
24 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/IWETH.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.13;
2 |
3 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4 |
5 | interface IWETH is IERC20 {
6 | function deposit() external payable;
7 |
8 | function transfer(address to, uint256 value) external returns (bool);
9 |
10 | function withdraw(uint256) external;
11 | }
12 |
--------------------------------------------------------------------------------
/solana/omniswap-keypair-4edLhT4MAausnqaxvB4ezcVG1adFnGw1QUMTvDMp4JVY.json:
--------------------------------------------------------------------------------
1 | [249, 217, 177, 216, 27, 114, 214, 209, 135, 74, 223, 193, 6, 208, 188, 21, 156, 48, 48, 190, 80, 210, 237, 121, 93, 42, 101, 149, 119, 85, 98, 106, 54, 54, 163, 217, 224, 45, 204, 177, 33, 17, 137, 9, 164, 199, 252, 251, 178, 146, 182, 28, 119, 70, 56, 206, 11, 9, 60, 36, 65, 191, 168, 67]
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/IWETH.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.13;
2 |
3 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4 |
5 | interface IWETH is IERC20 {
6 | function deposit() external payable;
7 |
8 | function transfer(address to, uint256 value) external returns (bool);
9 |
10 | function withdraw(uint256) external;
11 | }
12 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Bool/IBoolSwapConsumer.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapConsumer {
6 | function receiveFromBoolSwap(
7 | uint32 srcChainId,
8 | address bridgeToken,
9 | uint256 bridgeAmount,
10 | bytes calldata payload
11 | ) external payable;
12 | }
13 |
--------------------------------------------------------------------------------
/sui/sources/lib/helper.move:
--------------------------------------------------------------------------------
1 | module omniswap::helper {
2 | use sui::coin::Coin;
3 | use std::vector;
4 |
5 | public fun make_vector(
6 | coin: Coin
7 | ): vector> {
8 | let result = vector::empty>();
9 | vector::push_back(&mut result, coin);
10 | result
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Stargate/IStargateRouterEth.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IStargateRouterEth {
5 | function stargateEthVault() external view returns (address);
6 |
7 | function stargateRouter() external view returns (address);
8 |
9 | function poolId() external view returns (uint16);
10 | }
11 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Bool/IBoolSwapConsumer.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapConsumer {
6 | function receiveFromBoolSwap(
7 | uint32 srcChainId,
8 | address bridgeToken,
9 | uint256 bridgeAmount,
10 | bytes calldata payload
11 | ) external payable;
12 | }
13 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Stargate/IStargateRouterEth.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IStargateRouterEth {
5 | function stargateEthVault() external view returns (address);
6 |
7 | function stargateRouter() external view returns (address);
8 |
9 | function poolId() external view returns (uint16);
10 | }
11 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/constants.rs:
--------------------------------------------------------------------------------
1 | /// AKA `b"bridged"`.
2 | pub const SEED_PREFIX_BRIDGED: &[u8; 7] = b"bridged";
3 | /// AKA `b"tmp"`.
4 | pub const SEED_PREFIX_TMP: &[u8; 3] = b"tmp";
5 |
6 | pub const SEED_UNWRAP: &[u8; 6] = b"unwrap";
7 |
8 | pub const RAY: u64 = 100_000_000u64;
9 |
10 | // Swap call data delimiter, represent ","
11 | pub const DELIMITER: u8 = 44;
12 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Stargate/IStargateFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IStargateFactory {
6 | function allPoolsLength() external view returns (uint256);
7 |
8 | function allPools(uint256 index) external view returns (address);
9 |
10 | function getPool(uint256 poolId) external view returns (address);
11 | }
12 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/aptos/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = 'IntegerMate'
3 | version = '1.0.0'
4 |
5 | [addresses]
6 | std = "0x1"
7 | aptos_std = "0x1"
8 | aptos_framework = "0x1"
9 | integer_mate = "_"
10 |
11 | [dependencies.MoveStdlib]
12 | git = "https://github.com/aptos-labs/aptos-core.git"
13 | subdir = "aptos-move/framework/move-stdlib"
14 | rev = "40d169ad5ace6298a84b0f401b4b5e7ccce701fc"
15 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ILibPrice.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibPrice {
6 | function getPriceRatio(
7 | uint16 _chainId
8 | ) external view returns (uint256, bool);
9 |
10 | function updatePriceRatio(uint16 _chainId) external returns (uint256);
11 |
12 | function RAY() external view returns (uint256);
13 | }
14 |
--------------------------------------------------------------------------------
/utils/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | This is an aptos python tool to quickly implement aptos calls.
4 |
5 | # Setup
6 |
7 | ~~~shell
8 | pip install aptos_brownie
9 | ~~~
10 |
11 | # Use
12 |
13 | ~~~python
14 | import aptos_brownie
15 |
16 | package = aptos_brownie.AptosPackage(
17 | project_path=omniswap_aptos_path,
18 | network=net
19 | )
20 |
21 | package["so_fee_wormhole::initialize"](2)
22 | ~~~
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Stargate/IStargateReceiver.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IStargateReceiver {
6 | function sgReceive(
7 | uint16 _chainId,
8 | bytes memory _srcAddress,
9 | uint256 _nonce,
10 | address _token,
11 | uint256 _amount,
12 | bytes memory _payload
13 | ) external;
14 | }
15 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Stargate/IStargateFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IStargateFactory {
6 | function allPoolsLength() external view returns (uint256);
7 |
8 | function allPools(uint256 index) external view returns (address);
9 |
10 | function getPool(uint256 poolId) external view returns (address);
11 | }
12 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Bool/IBoolSwapPool.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapPool {
6 | function feeRatio() external view returns (uint16);
7 |
8 | function token() external view returns (address);
9 |
10 | function swapLimit() external view returns (uint256);
11 |
12 | function liquidity() external view returns (uint256);
13 | }
14 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/accounts/__init__.py:
--------------------------------------------------------------------------------
1 | from .cross_request import CrossRequest, CrossRequestJSON
2 | from .so_fee_config import SoFeeConfig, SoFeeConfigJSON
3 | from .foreign_contract import ForeignContract, ForeignContractJSON
4 | from .price_manager import PriceManager, PriceManagerJSON
5 | from .redeemer_config import RedeemerConfig, RedeemerConfigJSON
6 | from .sender_config import SenderConfig, SenderConfigJSON
7 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/GMX/IGMXV1Reader.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | import {IGMXV1Vault} from "./IGMXV1Vault.sol";
5 |
6 | interface IGMXV1Reader {
7 | function getAmountOut(
8 | IGMXV1Vault _vault,
9 | address _tokenIn,
10 | address _tokenOut,
11 | uint256 _amountIn
12 | ) external view returns (uint256, uint256);
13 | }
14 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ICorrectSwap.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ICorrectSwap {
6 | function correctSwap(
7 | bytes calldata,
8 | uint256
9 | ) external returns (bytes memory);
10 |
11 | function fixMinAmount(
12 | bytes calldata,
13 | uint256
14 | ) external view returns (uint256, bytes memory);
15 | }
16 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ICorrectSwap.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ICorrectSwap {
6 | function correctSwap(bytes calldata, uint256)
7 | external
8 | returns (bytes memory);
9 |
10 | function fixMinAmount(bytes calldata, uint256)
11 | external
12 | view
13 | returns (uint256, bytes memory);
14 | }
15 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Stargate/IStargateReceiver.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IStargateReceiver {
6 | function sgReceive(
7 | uint16 _chainId,
8 | bytes memory _srcAddress,
9 | uint256 _nonce,
10 | address _token,
11 | uint256 _amount,
12 | bytes memory _payload
13 | ) external;
14 | }
15 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/types/__init__.py:
--------------------------------------------------------------------------------
1 | import typing
2 | from . import inbound_token_bridge_addresses
3 | from .inbound_token_bridge_addresses import (
4 | InboundTokenBridgeAddresses,
5 | InboundTokenBridgeAddressesJSON,
6 | )
7 | from . import outbound_token_bridge_addresses
8 | from .outbound_token_bridge_addresses import (
9 | OutboundTokenBridgeAddresses,
10 | OutboundTokenBridgeAddressesJSON,
11 | )
12 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Multichain/IMultiChainUnderlying.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IMultiChainUnderlying {
6 | function underlying() external view returns (address);
7 |
8 | function deposit(uint256 amount, address to) external returns (uint256);
9 |
10 | function withdraw(uint256 amount, address to) external returns (uint256);
11 | }
12 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Bool/IBoolSwapPool.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapPool {
6 | function feeRatio() external view returns (uint16);
7 |
8 | function token() external view returns (address);
9 |
10 | function swapLimit() external view returns (uint256);
11 |
12 | function liquidity() external view returns (uint256);
13 | }
14 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/GMX/IGMXV1Reader.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | import {IGMXV1Vault} from "./IGMXV1Vault.sol";
5 |
6 | interface IGMXV1Reader {
7 | function getAmountOut(
8 | IGMXV1Vault _vault,
9 | address _tokenIn,
10 | address _tokenOut,
11 | uint256 _amountIn
12 | ) external view returns (uint256, uint256);
13 | }
14 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ILibPrice.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibPrice {
6 | function getPriceRatio(uint16 _chainId)
7 | external
8 | view
9 | returns (uint256, bool);
10 |
11 | function updatePriceRatio(uint16 _chainId) external returns (uint256);
12 |
13 | function RAY() external view returns (uint256);
14 | }
15 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Multichain/IMultiChainUnderlying.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IMultiChainUnderlying {
6 | function underlying() external view returns (address);
7 |
8 | function deposit(uint256 amount, address to) external returns (uint256);
9 |
10 | function withdraw(uint256 amount, address to) external returns (uint256);
11 | }
12 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/TraderJoe/IWNATIVE.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6 |
7 | /**
8 | * @title WNATIVE Interface
9 | * @notice Required interface of Wrapped NATIVE contract
10 | */
11 | interface IWNATIVE is IERC20 {
12 | function deposit() external payable;
13 |
14 | function withdraw(uint256) external;
15 | }
16 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/token_bridge/constants.rs:
--------------------------------------------------------------------------------
1 | // seeds
2 | pub const SEED_PREFIX_AUTHORITY_SIGNER: &[u8; 16] = b"authority_signer";
3 | pub const SEED_PREFIX_CUSTODY_SIGNER: &[u8; 14] = b"custody_signer";
4 | pub const SEED_PREFIX_MINT_AUTHORITY: &[u8; 11] = b"mint_signer";
5 | pub const SEED_PREFIX_SENDER: &[u8; 6] = b"sender";
6 | pub const SEED_PREFIX_REDEEMER: &[u8; 8] = b"redeemer";
7 | pub const SEED_PREFIX_EMITTER: &[u8; 7] = b"emitter";
8 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/utils.rs:
--------------------------------------------------------------------------------
1 | pub fn bytes_to_hex(bytes: &Vec) -> String {
2 | let hex_chars: [char; 16] =
3 | ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
4 |
5 | let mut hex_string = String::with_capacity(bytes.len() * 2);
6 |
7 | for byte in bytes {
8 | hex_string.push(hex_chars[(byte >> 4) as usize]);
9 | hex_string.push(hex_chars[(byte & 0xF) as usize]);
10 | }
11 |
12 | hex_string
13 | }
14 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/TraderJoe/IWNATIVE.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6 |
7 | /**
8 | * @title WNATIVE Interface
9 | * @notice Required interface of Wrapped NATIVE contract
10 | */
11 | interface IWNATIVE is IERC20 {
12 | function deposit() external payable;
13 |
14 | function withdraw(uint256) external;
15 | }
16 |
--------------------------------------------------------------------------------
/ethereum/contracts/Libraries/LibStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | struct LibStorage {
5 | mapping(address => bool) dexAllowlist;
6 | mapping(bytes32 => bool) dexFuncSignatureAllowList;
7 | address[] dexs;
8 | // maps gateway facet addresses to sofee address
9 | mapping(address => address) gatewaySoFeeSelectors;
10 | // Storage correct swap address
11 | address correctSwapRouterSelectors;
12 | }
13 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Libraries/LibStorage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | struct LibStorage {
5 | mapping(address => bool) dexAllowlist;
6 | mapping(bytes32 => bool) dexFuncSignatureAllowList;
7 | address[] dexs;
8 | // maps gateway facet addresses to sofee address
9 | mapping(address => address) gatewaySoFeeSelectors;
10 | // Storage correct swap address
11 | address correctSwapRouterSelectors;
12 | }
13 |
--------------------------------------------------------------------------------
/solana/Anchor.toml:
--------------------------------------------------------------------------------
1 | [features]
2 | seeds = false
3 | skip-lint = false
4 |
5 | [programs.devnet]
6 | omniswap = "4edLhT4MAausnqaxvB4ezcVG1adFnGw1QUMTvDMp4JVY"
7 |
8 | [programs.mainnet]
9 | omniswap = "4edLhT4MAausnqaxvB4ezcVG1adFnGw1QUMTvDMp4JVY"
10 |
11 | [registry]
12 | url = "https://api.apr.dev"
13 |
14 | [provider]
15 | cluster = "Devnet"
16 | wallet = "/home/chain/.config/solana/id.json"
17 |
18 | [toolchain]
19 | anchor_version = "0.28.0"
20 | solana_version = "1.16.13"
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/state/mod.rs:
--------------------------------------------------------------------------------
1 | pub use fee_config::SoFeeConfig;
2 | pub use foreign_contract::ForeignContract;
3 | pub use price_manager::PriceManager;
4 | pub use redeemer_config::{InboundTokenBridgeAddresses, RedeemerConfig};
5 | pub use sender_config::{OutboundTokenBridgeAddresses, SenderConfig};
6 |
7 | pub mod cross_request;
8 | pub mod fee_config;
9 | pub mod foreign_contract;
10 | pub mod price_manager;
11 | pub mod redeemer_config;
12 | pub mod sender_config;
13 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/sui/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "MoveSTL"
3 | version = "1.0.0"
4 | published-at = "0xbe21a06129308e0495431d12286127897aff07a8ade3970495a4404d97f9eaaa"
5 |
6 | [addresses]
7 | sui = "0x2"
8 | move_stl = "0xbe21a06129308e0495431d12286127897aff07a8ade3970495a4404d97f9eaaa"
9 |
10 | [dependencies.Sui]
11 | git = "https://github.com/MystenLabs/sui.git"
12 | subdir = "crates/sui-framework/packages/sui-framework"
13 | rev = "09b2081498366df936abae26eea4b2d5cafb2788"
14 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ILibSoFee.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibSoFee {
6 | function getFees(uint256 _amount) external view returns (uint256 s);
7 |
8 | function getRestoredAmount(
9 | uint256 _amount
10 | ) external view returns (uint256 r);
11 |
12 | function getTransferForGas() external view returns (uint256);
13 |
14 | function getVersion() external view returns (string memory);
15 | }
16 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/sui/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "IntegerMate"
3 | version = "1.0.0"
4 | published-at = "0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57"
5 |
6 | [addresses]
7 | sui = "0x2"
8 | integer_mate = "0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57"
9 |
10 | [dependencies.Sui]
11 | git = "https://github.com/MystenLabs/sui.git"
12 | subdir = "crates/sui-framework/packages/sui-framework"
13 | rev = "09b2081498366df936abae26eea4b2d5cafb2788"
14 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Bool/IBoolSwapFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapFactory {
6 | struct PoolInfo {
7 | uint16 fee;
8 | address pool;
9 | address token;
10 | address anchor;
11 | uint256 liquidity;
12 | }
13 |
14 | function fetchPool(uint32 poolId) external view returns (address);
15 |
16 | function fetchInfo(uint32 poolId) external view returns (PoolInfo memory);
17 | }
18 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ILibPriceV2.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | // Celer chain id is u64, stargate and wormhole are u16
6 | // ILibPriceV2 for Celer bridge
7 | interface ILibPriceV2 {
8 | function getPriceRatio(
9 | uint64 _chainId
10 | ) external view returns (uint256, bool);
11 |
12 | function updatePriceRatio(uint64 _chainId) external returns (uint256);
13 |
14 | function RAY() external view returns (uint256);
15 | }
16 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Bool/IBoolSwapFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapFactory {
6 | struct PoolInfo {
7 | uint16 fee;
8 | address pool;
9 | address token;
10 | address anchor;
11 | uint256 liquidity;
12 | }
13 |
14 | function fetchPool(uint32 poolId) external view returns (address);
15 |
16 | function fetchInfo(uint32 poolId) external view returns (PoolInfo memory);
17 | }
18 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ILibSoFee.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibSoFee {
6 | function getFees(uint256 _amount) external view returns (uint256 s);
7 |
8 | function getRestoredAmount(uint256 _amount)
9 | external
10 | view
11 | returns (uint256 r);
12 |
13 | function getTransferForGas() external view returns (uint256);
14 |
15 | function getVersion() external view returns (string memory);
16 | }
17 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ILibPriceV2.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | // Celer chain id is u64, stargate and wormhole are u16
6 | // ILibPriceV2 for Celer bridge
7 | interface ILibPriceV2 {
8 | function getPriceRatio(uint64 _chainId)
9 | external
10 | view
11 | returns (uint256, bool);
12 |
13 | function updatePriceRatio(uint64 _chainId) external returns (uint256);
14 |
15 | function RAY() external view returns (uint256);
16 | }
17 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Multichain/IMultiChainAnycallProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 | pragma solidity 0.8.13;
3 |
4 | /// IMultiChainAnycallProxy interface of the anycall proxy
5 | /// Note: `receiver` is the `fallback receive address` when exec failed.
6 | interface IMultiChainAnycallProxy {
7 | function exec(
8 | address token,
9 | address receiver,
10 | uint256 amount,
11 | bytes calldata data
12 | ) external returns (bool success, bytes memory result);
13 | }
14 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Helpers/MockToken.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity >=0.7.6;
4 |
5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6 |
7 | // this is a MOCK
8 | contract MockToken is ERC20 {
9 | constructor(string memory name_, string memory symbol_)
10 | ERC20(name_, symbol_)
11 | {
12 | _mint(msg.sender, 1000000000 * 10**18);
13 | }
14 |
15 | function mint(address _to, uint256 _amount) public {
16 | _mint(_to, _amount);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ethereum/contracts/Helpers/MockToken.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity >=0.7.6;
4 |
5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6 |
7 | // this is a MOCK
8 | contract MockToken is ERC20 {
9 | constructor(
10 | string memory name_,
11 | string memory symbol_
12 | ) ERC20(name_, symbol_) {
13 | _mint(msg.sender, 1000000000 * 10 ** 18);
14 | }
15 |
16 | function mint(address _to, uint256 _amount) public {
17 | _mint(_to, _amount);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Stargate/IStargateFeeLibrary.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "./IStargatePool.sol";
6 |
7 | interface IStargateFeeLibrary {
8 | function getFees(
9 | uint256 _srcPoolId,
10 | uint256 _dstPoolId,
11 | uint16 _dstChainId,
12 | address _from,
13 | uint256 _amountSD
14 | ) external view returns (IStargatePool.SwapObj memory s);
15 |
16 | function getVersion() external view returns (string memory);
17 | }
18 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Multichain/IMultiChainAnycallProxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 | pragma solidity 0.8.13;
3 |
4 | /// IMultiChainAnycallProxy interface of the anycall proxy
5 | /// Note: `receiver` is the `fallback receive address` when exec failed.
6 | interface IMultiChainAnycallProxy {
7 | function exec(
8 | address token,
9 | address receiver,
10 | uint256 amount,
11 | bytes calldata data
12 | ) external returns (bool success, bytes memory result);
13 | }
14 |
--------------------------------------------------------------------------------
/solana/scripts/get_token_decimals.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from solders.pubkey import Pubkey
4 |
5 | from solana_config import get_client
6 |
7 |
8 | async def get_token_decimals(token_mint):
9 | client = get_client()
10 |
11 | token_mint_key = Pubkey.from_string(token_mint)
12 |
13 | resp = await client.get_account_info_json_parsed(token_mint_key)
14 |
15 | print(resp.value.data.parsed["info"]["decimals"])
16 |
17 | pass
18 |
19 |
20 | asyncio.run(get_token_decimals("xxtdhpCgop5gZSeCkRRHqiVu7hqEC9MKkd1xMRUZqrz"))
21 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Stargate/IStargateFeeLibrary.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "./IStargatePool.sol";
6 |
7 | interface IStargateFeeLibrary {
8 | function getFees(
9 | uint256 _srcPoolId,
10 | uint256 _dstPoolId,
11 | uint16 _dstChainId,
12 | address _from,
13 | uint256 _amountSD
14 | ) external view returns (IStargatePool.SwapObj memory s);
15 |
16 | function getVersion() external view returns (string memory);
17 | }
18 |
--------------------------------------------------------------------------------
/aptos/mocks/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "OmniSwapMock"
3 | version = "0.1.0"
4 |
5 | [addresses]
6 | std = "0x1"
7 | aptos-stdlib = "0x1"
8 | aptos_framework = "0x1"
9 | aptos_std = "0x1"
10 | omniswap_mock = "_"
11 |
12 | [dependencies.AptosFramework]
13 | git = "https://github.com/aptos-labs/aptos-core.git"
14 | rev = "a2a3bf79b68823287f962bded2abfaefc688e71c"
15 | subdir = "aptos-move/framework/aptos-framework"
16 |
17 | [dependencies.Liquidswap]
18 | git = "https://github.com/pontem-network/liquidswap.git"
19 | rev = 'b89aed9adb96c0b083134765f75be814418be670'
20 |
21 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/wormhole/types.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | #[derive(AnchorDeserialize, AnchorSerialize, Clone, Copy, PartialEq, Eq)]
4 | pub enum Finality {
5 | Confirmed,
6 | Finalized,
7 | }
8 |
9 | impl TryFrom for Finality {
10 | type Error = std::io::Error;
11 |
12 | fn try_from(value: u8) -> std::result::Result {
13 | match value {
14 | 0 => Ok(Finality::Confirmed),
15 | 1 => Ok(Finality::Finalized),
16 | _ => Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "invalid finality")),
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/solana/scripts/get_tx.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from solders.signature import Signature
4 | from solana_config import get_client
5 |
6 |
7 | async def get_tx():
8 | client = get_client()
9 | await client.is_connected()
10 |
11 | tx_id = "4eDqgghqZL4Hn7TMMZvCBBe87PL439Ytyc3kqovA9WetJd9h8MFFAKpUPp4VKp5BKLrw6J6x43yPhfGviFRjFht8"
12 | resp = await client.get_transaction(
13 | Signature.from_string(tx_id), max_supported_transaction_version=0
14 | )
15 | print(resp.value.transaction.meta)
16 |
17 | await client.close()
18 |
19 |
20 | asyncio.run(get_tx())
21 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/wormhole/program.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | cfg_if! {
4 | if #[cfg(feature = "mainnet")] {
5 | declare_id!("worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth");
6 | } else if #[cfg(feature = "solana-devnet")] {
7 | declare_id!("3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5");
8 | } else if #[cfg(feature = "tilt-devnet")]{
9 | declare_id!("Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o");
10 | }
11 | }
12 |
13 | #[derive(Debug, Clone)]
14 | pub struct Wormhole;
15 |
16 | impl Id for Wormhole {
17 | fn id() -> Pubkey {
18 | ID
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CCTP/IReceiver.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IReceiver {
5 | /**
6 | * @notice Receives an incoming message, validating the header and passing
7 | * the body to application-specific handler.
8 | * @param message The message raw bytes
9 | * @param signature The message signature
10 | * @return success bool, true if successful
11 | */
12 | function receiveMessage(
13 | bytes calldata message,
14 | bytes calldata signature
15 | ) external returns (bool success);
16 | }
17 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/CCTP/IReceiver.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IReceiver {
5 | /**
6 | * @notice Receives an incoming message, validating the header and passing
7 | * the body to application-specific handler.
8 | * @param message The message raw bytes
9 | * @param signature The message signature
10 | * @return success bool, true if successful
11 | */
12 | function receiveMessage(bytes calldata message, bytes calldata signature)
13 | external
14 | returns (bool success);
15 | }
16 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/token_bridge/program.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | cfg_if! {
4 | if #[cfg(feature = "mainnet")] {
5 | declare_id!("wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb");
6 | } else if #[cfg(feature = "solana-devnet")] {
7 | declare_id!("DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe");
8 | } else if #[cfg(feature = "tilt-devnet")] {
9 | declare_id!("B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE");
10 | }
11 | }
12 |
13 | #[derive(Debug, Clone)]
14 | pub struct TokenBridge;
15 |
16 | impl Id for TokenBridge {
17 | fn id() -> Pubkey {
18 | ID
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/IERC165.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IERC165 {
5 | /// @notice Query if a contract implements an interface
6 | /// @param interfaceId The interface identifier, as specified in ERC-165
7 | /// @dev Interface identification is specified in ERC-165. This function
8 | /// uses less than 30,000 gas.
9 | /// @return `true` if the contract implements `interfaceID` and
10 | /// `interfaceID` is not 0xffffffff, `false` otherwise
11 | function supportsInterface(bytes4 interfaceId) external view returns (bool);
12 | }
13 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/partner.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::partner {
2 | use sui::object::{UID, ID};
3 | use sui::vec_map::VecMap;
4 | use std::string::String;
5 | use sui::bag::Bag;
6 |
7 | // =============== Structs =================
8 |
9 | struct Partners has key {
10 | id: UID,
11 | partners: VecMap
12 | }
13 |
14 | struct Partner has key, store {
15 | id: UID,
16 | name: String,
17 | ref_fee_rate: u64,
18 | start_time: u64,
19 | end_time: u64,
20 | balances: Bag,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/sui/Move.lock:
--------------------------------------------------------------------------------
1 | # @generated by Move, please check-in and do not edit manually.
2 |
3 | [move]
4 | version = 0
5 |
6 | dependencies = [
7 | { name = "Sui" },
8 | ]
9 |
10 | [[move.package]]
11 | name = "MoveStdlib"
12 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "sui-v1.0.0", subdir = "crates/sui-framework/packages/move-stdlib" }
13 |
14 | [[move.package]]
15 | name = "Sui"
16 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "sui-v1.0.0", subdir = "crates/sui-framework/packages/sui-framework" }
17 |
18 | dependencies = [
19 | { name = "MoveStdlib" },
20 | ]
21 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/sui/Move.lock:
--------------------------------------------------------------------------------
1 | # @generated by Move, please check-in and do not edit manually.
2 |
3 | [move]
4 | version = 0
5 |
6 | dependencies = [
7 | { name = "Sui" },
8 | ]
9 |
10 | [[move.package]]
11 | name = "MoveStdlib"
12 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "sui-v1.0.0", subdir = "crates/sui-framework/packages/move-stdlib" }
13 |
14 | [[move.package]]
15 | name = "Sui"
16 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "sui-v1.0.0", subdir = "crates/sui-framework/packages/sui-framework" }
17 |
18 | dependencies = [
19 | { name = "MoveStdlib" },
20 | ]
21 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/IERC165.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IERC165 {
5 | /// @notice Query if a contract implements an interface
6 | /// @param interfaceId The interface identifier, as specified in ERC-165
7 | /// @dev Interface identification is specified in ERC-165. This function
8 | /// uses less than 30,000 gas.
9 | /// @return `true` if the contract implements `interfaceID` and
10 | /// `interfaceID` is not 0xffffffff, `false` otherwise
11 | function supportsInterface(bytes4 interfaceId) external view returns (bool);
12 | }
13 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CCTP/ITokenMessenger.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface ITokenMessenger {
5 | function depositForBurn(
6 | uint256 amount,
7 | uint32 destinationDomain,
8 | bytes32 mintRecipient,
9 | address burnToken
10 | ) external returns (uint64 _nonce);
11 |
12 | function depositForBurnWithCaller(
13 | uint256 amount,
14 | uint32 destinationDomain,
15 | bytes32 mintRecipient,
16 | address burnToken,
17 | bytes32 destinationCaller
18 | ) external returns (uint64 nonce);
19 | }
20 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ILibSoFeeV2.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibSoFeeV2 {
6 | function getFees(uint256 _amount) external view returns (uint256 s);
7 |
8 | function getRestoredAmount(
9 | uint256 _amount
10 | ) external view returns (uint256 r);
11 |
12 | function getTransferForGas() external view returns (uint256);
13 |
14 | function getVersion() external view returns (string memory);
15 |
16 | function getBasicBeneficiary() external view returns (address);
17 |
18 | function getBasicFee() external view returns (uint256);
19 | }
20 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/CCTP/ITokenMessenger.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface ITokenMessenger {
5 | function depositForBurn(
6 | uint256 amount,
7 | uint32 destinationDomain,
8 | bytes32 mintRecipient,
9 | address burnToken
10 | ) external returns (uint64 _nonce);
11 |
12 | function depositForBurnWithCaller(
13 | uint256 amount,
14 | uint32 destinationDomain,
15 | bytes32 mintRecipient,
16 | address burnToken,
17 | bytes32 destinationCaller
18 | ) external returns (uint64 nonce);
19 | }
20 |
--------------------------------------------------------------------------------
/solana/.rustfmt.toml:
--------------------------------------------------------------------------------
1 | # Basic
2 | edition = "2021"
3 | hard_tabs = true
4 | max_width = 100
5 | use_small_heuristics = "Max"
6 | # Imports
7 | imports_granularity = "Crate"
8 | reorder_imports = true
9 | # Consistency
10 | newline_style = "Unix"
11 | # Misc
12 | chain_width = 80
13 | spaces_around_ranges = false
14 | binop_separator = "Back"
15 | reorder_impl_items = false
16 | match_arm_leading_pipes = "Preserve"
17 | match_arm_blocks = false
18 | match_block_trailing_comma = true
19 | trailing_comma = "Vertical"
20 | trailing_semicolon = false
21 | use_field_init_shorthand = true
22 | # Format comments
23 | comment_width = 100
24 | wrap_comments = true
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/TraderJoe/ILBFlashLoanCallback.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6 |
7 | /// @title Liquidity Book Flashloan Callback Interface
8 | /// @author Trader Joe
9 | /// @notice Required interface to interact with LB flash loans
10 | interface ILBFlashLoanCallback {
11 | function LBFlashLoanCallback(
12 | address sender,
13 | IERC20 tokenX,
14 | IERC20 tokenY,
15 | bytes32 amounts,
16 | bytes32 totalFees,
17 | bytes calldata data
18 | ) external returns (bytes32);
19 | }
20 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ILibSoFeeV2.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ILibSoFeeV2 {
6 | function getFees(uint256 _amount) external view returns (uint256 s);
7 |
8 | function getRestoredAmount(uint256 _amount)
9 | external
10 | view
11 | returns (uint256 r);
12 |
13 | function getTransferForGas() external view returns (uint256);
14 |
15 | function getVersion() external view returns (string memory);
16 |
17 | function getBasicBeneficiary() external view returns (address);
18 |
19 | function getBasicFee() external view returns (uint256);
20 | }
21 |
--------------------------------------------------------------------------------
/sui/test_coins/Move.lock:
--------------------------------------------------------------------------------
1 | # @generated by Move, please check-in and do not edit manually.
2 |
3 | [move]
4 | version = 0
5 |
6 | dependencies = [
7 | { name = "Sui" },
8 | ]
9 |
10 | [[move.package]]
11 | name = "MoveStdlib"
12 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "cab7e9762d4d75126a78fdd009b405745657fe57", subdir = "crates/sui-framework/packages/move-stdlib" }
13 |
14 | [[move.package]]
15 | name = "Sui"
16 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "cab7e9762d4d75126a78fdd009b405745657fe57", subdir = "crates/sui-framework/packages/sui-framework" }
17 |
18 | dependencies = [
19 | { name = "MoveStdlib" },
20 | ]
21 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/TraderJoe/ILBFlashLoanCallback.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6 |
7 | /// @title Liquidity Book Flashloan Callback Interface
8 | /// @author Trader Joe
9 | /// @notice Required interface to interact with LB flash loans
10 | interface ILBFlashLoanCallback {
11 | function LBFlashLoanCallback(
12 | address sender,
13 | IERC20 tokenX,
14 | IERC20 tokenY,
15 | bytes32 amounts,
16 | bytes32 totalFees,
17 | bytes calldata data
18 | ) external returns (bytes32);
19 | }
20 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/GMX/IGMXV1Router.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.0;
3 |
4 | interface IGMXV1Router {
5 | function swap(
6 | address[] memory _path,
7 | uint256 _amountIn,
8 | uint256 _minOut,
9 | address _receiver
10 | ) external;
11 |
12 | function swapETHToTokens(
13 | address[] memory _path,
14 | uint256 _minOut,
15 | address _receiver
16 | ) external payable;
17 |
18 | function swapTokensToETH(
19 | address[] memory _path,
20 | uint256 _amountIn,
21 | uint256 _minOut,
22 | address payable _receiver
23 | ) external;
24 | }
25 |
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "wormhole-anchor-sdk"
3 | version = "0.1.0-alpha.2"
4 | description = "SDK using Anchor interfaces to interact with Wormhole Solana Programs"
5 | edition = "2021"
6 | authors = ["W7"]
7 | license = "Apache-2.0"
8 | homepage = "https://github.com/wormhole-foundation/wormhole-scaffolding"
9 | repository = "https://github.com/wormhole-foundation/wormhole-scaffolding"
10 |
11 | [features]
12 | default = ["mainnet", "token-bridge"]
13 | mainnet = []
14 | solana-devnet = []
15 | tilt-devnet = []
16 | token-bridge = []
17 |
18 | [dependencies]
19 | anchor-lang = "0.28.0"
20 | anchor-spl = "0.28.0"
21 | cfg-if = "1.0.0"
22 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/tick.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::tick {
2 | use move_stl::skip_list::SkipList;
3 | use integer_mate::i32::I32;
4 | use integer_mate::i128::I128;
5 |
6 | struct TickManager has store {
7 | tick_spacing: u32,
8 | ticks: SkipList
9 | }
10 |
11 | struct Tick has copy, drop, store {
12 | index: I32,
13 | sqrt_price: u128,
14 | liquidity_net: I128,
15 | liquidity_gross: u128,
16 | fee_growth_outside_a: u128,
17 | fee_growth_outside_b: u128,
18 | points_growth_outside: u128,
19 | rewards_growth_outside: vector,
20 | }
21 | }
--------------------------------------------------------------------------------
/ethereum/scripts/deploy_genesis_box.py:
--------------------------------------------------------------------------------
1 | from brownie import GenesisBoxStaking
2 |
3 | from scripts.helpful_scripts import get_account
4 |
5 |
6 | def deploy_genesis_box_staking(nft_contract_address):
7 | account = get_account("deploy_key")
8 | genesis_box_staking = GenesisBoxStaking.deploy(nft_contract_address, {"from": account, "gas_price": "0.05 gwei"})
9 | return genesis_box_staking
10 |
11 |
12 | def main():
13 | # testnet: 0x0AC2782a9f6Aef6073792c56ea8292c45Fc7c12B
14 | # mainnet: 0x09Ff8E49D0EA411A3422ed95E8f5497D4241F532
15 | nft_contract_address = "0x0AC2782a9f6Aef6073792c56ea8292c45Fc7c12B"
16 | deploy_genesis_box_staking(nft_contract_address)
17 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/GMX/IGMXV1Router.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.0;
3 |
4 | interface IGMXV1Router {
5 | function swap(
6 | address[] memory _path,
7 | uint256 _amountIn,
8 | uint256 _minOut,
9 | address _receiver
10 | ) external;
11 |
12 | function swapETHToTokens(
13 | address[] memory _path,
14 | uint256 _minOut,
15 | address _receiver
16 | ) external payable;
17 |
18 | function swapTokensToETH(
19 | address[] memory _path,
20 | uint256 _amountIn,
21 | uint256 _minOut,
22 | address payable _receiver
23 | ) external;
24 | }
25 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CoreBridge/IWrappedTokenBridge.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.13;
3 |
4 | import "../../Libraries/LzLib.sol";
5 |
6 | interface IWrappedTokenBridge {
7 | function estimateBridgeFee(
8 | uint16 remoteChainId,
9 | bool useZro,
10 | bytes calldata adapterParams
11 | ) external view returns (uint nativeFee, uint zroFee);
12 | function bridge(
13 | address localToken,
14 | uint16 remoteChainId,
15 | uint amount,
16 | address to,
17 | bool unwrapWeth,
18 | LzLib.CallParams calldata callParams,
19 | bytes memory adapterParams
20 | ) external payable;
21 | }
22 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/set_redeem_proxy.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | use crate::{error::SoSwapError, state::RedeemerConfig};
4 |
5 | #[derive(Accounts)]
6 | pub struct SetRedeemProxy<'info> {
7 | #[account(mut)]
8 | pub owner: Signer<'info>,
9 |
10 | #[account(
11 | mut,
12 | seeds = [RedeemerConfig::SEED_PREFIX],
13 | bump,
14 | has_one = owner @ SoSwapError::OwnerOnly,
15 | )]
16 | /// Sender Config account.
17 | pub config: Box>,
18 | }
19 |
20 | pub fn handler(ctx: Context, new_proxy: Pubkey) -> Result<()> {
21 | let config = &mut ctx.accounts.config;
22 | config.proxy = new_proxy;
23 |
24 | // Done.
25 | Ok(())
26 | }
27 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/rewarder.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::rewarder {
2 | use sui::bag::Bag;
3 | use std::type_name::TypeName;
4 |
5 | use sui::object::UID;
6 |
7 | friend cetus_clmm::pool;
8 |
9 | struct RewarderManager has store {
10 | rewarders: vector,
11 | points_released: u128,
12 | points_growth_global: u128,
13 | last_updated_time: u64,
14 | }
15 |
16 | struct Rewarder has copy, drop, store {
17 | reward_coin: TypeName,
18 | emissions_per_second: u128,
19 | growth_global: u128,
20 | }
21 |
22 | struct RewarderGlobalVault has key, store {
23 | id: UID,
24 | balances: Bag
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Bool/IBoolSwapRouter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapRouter {
6 | function factory() external view returns (address);
7 |
8 | function swap(
9 | uint32 poolId,
10 | uint32 dstChainId,
11 | uint256 amount,
12 | bytes32 recipient,
13 | address payable refundAddress,
14 | bytes calldata consumerData
15 | ) external payable returns (bytes32 crossId);
16 |
17 | function estimateBNFee(
18 | uint32 poolId,
19 | uint32 dstChainId,
20 | uint256 amount,
21 | bytes32 recipient,
22 | bytes calldata consumerData
23 | ) external view returns (uint256 fee);
24 | }
25 |
--------------------------------------------------------------------------------
/ethereum/contracts/Deployer/ContractDeployerFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | contract ContractDeployerFactory {
5 | event ContractDeployed(bytes32 salt, address addr);
6 |
7 | function deployContract(
8 | bytes32 salt,
9 | bytes memory contractBytecode
10 | ) public {
11 | address addr;
12 | assembly {
13 | addr := create2(
14 | 0,
15 | add(contractBytecode, 0x20),
16 | mload(contractBytecode),
17 | salt
18 | )
19 | if iszero(extcodesize(addr)) {
20 | revert(0, 0)
21 | }
22 | }
23 | emit ContractDeployed(salt, addr);
24 | }
25 | }
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Bool/IBoolSwapRouter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface IBoolSwapRouter {
6 | function factory() external view returns (address);
7 |
8 | function swap(
9 | uint32 poolId,
10 | uint32 dstChainId,
11 | uint256 amount,
12 | bytes32 recipient,
13 | address payable refundAddress,
14 | bytes calldata consumerData
15 | ) external payable returns (bytes32 crossId);
16 |
17 | function estimateBNFee(
18 | uint32 poolId,
19 | uint32 dstChainId,
20 | uint256 amount,
21 | bytes32 recipient,
22 | bytes calldata consumerData
23 | ) external view returns (uint256 fee);
24 | }
25 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/set_so_fee.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | use crate::{error::SoSwapError, state::SoFeeConfig};
4 |
5 | #[derive(Accounts)]
6 | pub struct SetSoFee<'info> {
7 | #[account(mut)]
8 | pub payer: Signer<'info>,
9 |
10 | #[account(
11 | mut,
12 | seeds = [SoFeeConfig::SEED_PREFIX],
13 | bump,
14 | constraint = payer.key() == config.owner || payer.key() == config.beneficiary @ SoSwapError::OwnerOnly
15 | )]
16 | /// Sender Config account.
17 | pub config: Box>,
18 | }
19 |
20 | pub fn handler(ctx: Context, so_fee_by_ray: u64) -> Result<()> {
21 | let config = &mut ctx.accounts.config;
22 | config.so_fee = so_fee_by_ray;
23 |
24 | // Done.
25 | Ok(())
26 | }
27 |
--------------------------------------------------------------------------------
/solana/.env.example:
--------------------------------------------------------------------------------
1 | ### uncomment me to use the variables
2 | TEST_DEPLOYER=[224,193,65,247,1,184,100,111,196,2,155,2,252,4,81,187,107,102,5,105,60,184,237,119,230,139,28,237,82,26,183,134,56,225,33,112,154,217,107,211,122,47,135,2,41,50,51,110,154,41,15,98,174,243,212,29,174,0,177,84,124,111,25,56]
3 | TEST_PRICE_MANAGER=[224,193,65,247,1,184,100,111,196,2,155,2,252,4,81,187,107,102,5,105,60,184,237,119,230,139,28,237,82,26,183,134,56,225,33,112,154,217,107,211,122,47,135,2,41,50,51,110,154,41,15,98,174,243,212,29,174,0,177,84,124,111,25,56]
4 | TEST_REDEEM_PROXY=[224,193,65,247,1,184,100,111,196,2,155,2,252,4,81,187,107,102,5,105,60,184,237,119,230,139,28,237,82,26,183,134,56,225,33,112,154,217,107,211,122,47,135,2,41,50,51,110,154,41,15,98,174,243,212,29,174,0,177,84,124,111,25,56]
5 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CoreBridge/IOriginalTokenBridge.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.13;
3 |
4 | import "../../Libraries/LzLib.sol";
5 |
6 | interface IOriginalTokenBridge {
7 | function estimateBridgeFee(
8 | bool useZro,
9 | bytes calldata adapterParams
10 | ) external view returns (uint nativeFee, uint zroFee);
11 | function bridge(
12 | address token,
13 | uint amountLD,
14 | address to,
15 | LzLib.CallParams calldata callParams,
16 | bytes memory adapterParams
17 | ) external payable;
18 | function bridgeNative(
19 | uint amountLD,
20 | address to,
21 | LzLib.CallParams calldata callParams,
22 | bytes memory adapterParams
23 | ) external payable;
24 | }
25 |
--------------------------------------------------------------------------------
/aptos/sources/external_interface.move:
--------------------------------------------------------------------------------
1 | module omniswap::external_interface {
2 | use omniswap::wormhole_facet;
3 | use omniswap::u256::{Self, U256};
4 |
5 | struct DstGas has key {
6 | dst_base_gas: U256,
7 | dst_gas_per_bytes: U256
8 | }
9 |
10 | struct DstGasData has key {
11 | dst_base_gas: u64,
12 | dst_gas_per_bytes: u64
13 | }
14 |
15 |
16 | public entry fun get_dst_gas(account: &signer, dst_wormhole_chain_id: u64) {
17 | let (dst_base_gas, dst_gas_per_bytes) = wormhole_facet::get_dst_gas(dst_wormhole_chain_id);
18 | let dst_base_gas = u256::as_u64(dst_base_gas);
19 | let dst_gas_per_bytes = u256::as_u64(dst_gas_per_bytes);
20 | move_to(account, DstGasData { dst_base_gas, dst_gas_per_bytes });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "zksync-era",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "devDependencies": {
7 | "@ethersproject/hash": "^5.7.0",
8 | "@ethersproject/web": "^5.7.1",
9 | "@matterlabs/hardhat-zksync-deploy": "^0.6.3",
10 | "@matterlabs/hardhat-zksync-solc": "^0.3.17",
11 | "@matterlabs/hardhat-zksync-verify": "^0.1.7",
12 | "@nomiclabs/hardhat-etherscan": "^3.1.7",
13 | "@types/node": "^18.15.11",
14 | "ethers": "^5.7.2",
15 | "hardhat": "^2.14.0",
16 | "ts-node": "^10.9.1",
17 | "typescript": "^5.0.3",
18 | "zksync-web3": "^0.14.3"
19 | },
20 | "dependencies": {
21 | "@openzeppelin/contracts": "^4.8.2",
22 | "@uniswap/v3-core": "^1.0.1",
23 | "dotenv": "^16.0.3"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "CetusClmm"
3 | version = "1.0.0"
4 | published-at = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb"
5 |
6 | [addresses]
7 | integer_mate = "0x714a63a0dba6da4f017b42d5d0fb78867f18bcde904868e51d951a5a6f5b7f57"
8 | move_stl = "0xbe21a06129308e0495431d12286127897aff07a8ade3970495a4404d97f9eaaa"
9 | cetus_clmm = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb"
10 |
11 | [dependencies.Sui]
12 | git = "https://github.com/MystenLabs/sui.git"
13 | subdir = "crates/sui-framework/packages/sui-framework"
14 | rev = "09b2081498366df936abae26eea4b2d5cafb2788"
15 |
16 | [dependencies.MoveSTL]
17 | local = "../../../move-stl/sui"
18 |
19 | [dependencies.IntegerMate]
20 | local = "../../../integer-mate/sui"
21 |
--------------------------------------------------------------------------------
/ethereum/contracts/Errors/GenericErrors.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | error InvalidAmount(); // 0x2c5211c6
6 | error TokenAddressIsZero(); // 0xdc2e5e8d
7 | error CannotBridgeToSameNetwork(); // 0x4ac09ad3
8 | error ZeroPostSwapBalance(); // 0xf74e8909
9 | error InvalidBridgeConfigLength(); // 0x10502ef9
10 | error NoSwapDataProvided(); // 0x0503c3ed
11 | error NotSupportedSwapRouter(); // 0xe986f686
12 | error NativeValueWithERC(); // 0x003f45b5
13 | error ContractCallNotAllowed(); // 0x94539804
14 | error NullAddrIsNotAValidSpender(); // 0x63ba9bff
15 | error NullAddrIsNotAnERC20Token(); // 0xd1bebf0c
16 | error NoTransferToNullAddress(); // 0x21f74345
17 | error NativeAssetTransferFailed(); // 0x5a046737
18 | error InvalidContract(); // 0x6eefed20
19 | error InvalidConfig(); // 0x35be3ac8
--------------------------------------------------------------------------------
/solana/programs/omniswap/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "omniswap"
3 | version = "0.3.1"
4 | description = "www.omnibtc.finance"
5 | edition = "2021"
6 |
7 | [lib]
8 | crate-type = ["cdylib", "lib"]
9 | name = "omniswap"
10 |
11 | [features]
12 | mainnet = ["wormhole-anchor-sdk/mainnet"]
13 | testnet = ["wormhole-anchor-sdk/solana-devnet"]
14 |
15 | no-entrypoint = []
16 | no-idl = []
17 | no-log-ix-name = []
18 | cpi = ["no-entrypoint"]
19 | default = ["testnet"]
20 |
21 | [dependencies]
22 | anchor-lang = { version = "0.28.0", features = ["init-if-needed"]}
23 | anchor-spl = "0.28.0"
24 | spl-math = { version = "0.2.0", features = ["no-entrypoint"] }
25 | wormhole-anchor-sdk = { path = "../../modules/wormhole-anchor-sdk", default-features = false, features = ["token-bridge"]}
26 |
27 | [dev-dependencies]
28 | hex-literal = "0.4.1"
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Errors/GenericErrors.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | error InvalidAmount(); // 0x2c5211c6
5 | error TokenAddressIsZero(); // 0xdc2e5e8d
6 | error CannotBridgeToSameNetwork(); // 0x4ac09ad3
7 | error ZeroPostSwapBalance(); // 0xf74e8909
8 | error InvalidBridgeConfigLength(); // 0x10502ef9
9 | error NoSwapDataProvided(); // 0x0503c3ed
10 | error NotSupportedSwapRouter(); // 0xe986f686
11 | error NativeValueWithERC(); // 0x003f45b5
12 | error ContractCallNotAllowed(); // 0x94539804
13 | error NullAddrIsNotAValidSpender(); // 0x63ba9bff
14 | error NullAddrIsNotAnERC20Token(); // 0xd1bebf0c
15 | error NoTransferToNullAddress(); // 0x21f74345
16 | error NativeAssetTransferFailed(); // 0x5a046737
17 | error InvalidContract(); // 0x6eefed20
18 | error InvalidConfig(); // 0x35be3ac8
19 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/config.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::config {
2 |
3 | use sui::object::UID;
4 | use sui::vec_map::VecMap;
5 |
6 | use cetus_clmm::acl;
7 |
8 | /// The clmmpools fee tier data
9 | struct FeeTier has store, copy, drop {
10 | /// The tick spacing
11 | tick_spacing: u32,
12 |
13 | /// The default fee rate
14 | fee_rate: u64,
15 | }
16 |
17 | struct GlobalConfig has key, store {
18 | id: UID,
19 | /// `protocol_fee_rate` The protocol fee rate
20 | protocol_fee_rate: u64,
21 | /// 'fee_tiers' The Clmmpools fee tire map
22 | fee_tiers: VecMap,
23 | /// `acl` The Clmmpools ACL
24 | acl: acl::ACL,
25 |
26 | /// The current package version
27 | package_version: u64
28 | }
29 | }
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/wormhole/message.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | #[derive(Default, AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Eq)]
4 | pub struct PostedVaaMeta {
5 | /// Header of the posted VAA
6 | pub version: u8,
7 |
8 | /// Level of consistency requested by the emitter
9 | pub finality: u8,
10 |
11 | /// Time the message was submitted
12 | pub timestamp: u32,
13 |
14 | /// Account where signatures are stored
15 | pub signature_set: Pubkey,
16 |
17 | /// Time the posted message was created
18 | pub posted_timestamp: u32,
19 |
20 | /// Unique id for this message
21 | pub batch_id: u32,
22 |
23 | /// Sequence number of this message
24 | pub sequence: u64,
25 |
26 | /// Emitter of the message
27 | pub emitter_chain: u16,
28 |
29 | /// Emitter of the message
30 | pub emitter_address: [u8; 32],
31 | }
32 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/set_wormhole_reserve.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | use crate::{error::SoSwapError, state::SoFeeConfig};
4 |
5 | #[derive(Accounts)]
6 | pub struct SetWormholeReserve<'info> {
7 | #[account(mut)]
8 | pub payer: Signer<'info>,
9 |
10 | #[account(
11 | mut,
12 | seeds = [SoFeeConfig::SEED_PREFIX],
13 | bump,
14 | constraint = payer.key() == config.owner || payer.key() == config.beneficiary @ SoSwapError::OwnerOnly
15 | )]
16 | /// Sender Config account.
17 | pub config: Box>,
18 | }
19 |
20 | pub fn handler(
21 | ctx: Context,
22 | actual_reserve: u64,
23 | estimate_reserve: u64,
24 | ) -> Result<()> {
25 | let config = &mut ctx.accounts.config;
26 | config.actual_reserve = actual_reserve;
27 | config.estimate_reserve = estimate_reserve;
28 |
29 | // Done.
30 | Ok(())
31 | }
32 |
--------------------------------------------------------------------------------
/sui/cetus/move-stl/aptos/Move.lock:
--------------------------------------------------------------------------------
1 | # @generated by Move, please check-in and do not edit manually.
2 |
3 | [move]
4 | version = 0
5 |
6 | dependencies = [
7 | { name = "AptosFramework" },
8 | ]
9 |
10 | [[move.package]]
11 | name = "AptosFramework"
12 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "main", subdir = "aptos-move/framework/aptos-framework" }
13 |
14 | dependencies = [
15 | { name = "AptosStdlib" },
16 | { name = "MoveStdlib" },
17 | ]
18 |
19 | [[move.package]]
20 | name = "AptosStdlib"
21 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "main", subdir = "aptos-move/framework/aptos-stdlib" }
22 |
23 | dependencies = [
24 | { name = "MoveStdlib" },
25 | ]
26 |
27 | [[move.package]]
28 | name = "MoveStdlib"
29 | source = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "main", subdir = "aptos-move/framework/move-stdlib" }
30 |
--------------------------------------------------------------------------------
/sui/test_coins/sources/usdc.move:
--------------------------------------------------------------------------------
1 | // Copyright (c) OmniBTC, Inc.
2 | // SPDX-License-Identifier: GPL-3.0
3 | module test_coins::usdc {
4 | use std::option;
5 |
6 | use sui::coin;
7 | use sui::transfer;
8 | use sui::tx_context::{Self, TxContext};
9 |
10 | friend test_coins::faucet;
11 |
12 | ////////////////////////////////////
13 | struct USDC has drop {}
14 |
15 | ////////////////////////////////////
16 |
17 | fun init(usdc_witness: USDC, ctx: &mut TxContext) {
18 | let (cap, metadata) = coin::create_currency(
19 | usdc_witness,
20 | 6,
21 | b"USDC",
22 | b"USD Coin",
23 | b"https://www.centre.io/",
24 | option::none(),
25 | ctx
26 | );
27 | transfer::public_share_object(metadata);
28 | transfer::public_transfer(cap, tx_context::sender(ctx));
29 | }
30 | }
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/wormhole/constants.rs:
--------------------------------------------------------------------------------
1 | pub const CHAIN_ID_SOLANA: u16 = 1;
2 |
3 | // seeds
4 | pub const SEED_PREFIX_EMITTER: &[u8; 7] = b"emitter";
5 | pub const SEED_PREFIX_POSTED_VAA: &[u8; 9] = b"PostedVAA";
6 |
7 | // version 1 message
8 | pub const MESSAGE_INDEX_VERSION: usize = 3;
9 | pub const MESSAGE_INDEX_FINALITY: usize = 4;
10 | pub const MESSAGE_INDEX_TIMESTAMP: usize = 5;
11 | pub const MESSAGE_INDEX_SIGNATURE_ACCOUNT: usize = 9;
12 | pub const MESSAGE_INDEX_POSTED_TIMESTAMP: usize = 41;
13 | pub const MESSAGE_INDEX_BATCH_ID: usize = 45;
14 | pub const MESSAGE_INDEX_SEQUENCE: usize = 49;
15 | pub const MESSAGE_INDEX_EMITTER_CHAIN: usize = 57;
16 | pub const MESSAGE_INDEX_EMITTER_ADDRESS: usize = 59;
17 | pub const MESSAGE_INDEX_PAYLOAD_LENGTH: usize = 91;
18 | pub const MESSAGE_INDEX_PAYLOAD: usize = 95;
19 |
20 | // other useful constants
21 | pub const INITIAL_SEQUENCE: u64 = 1;
22 |
--------------------------------------------------------------------------------
/sui/test_coins/sources/btc.move:
--------------------------------------------------------------------------------
1 | // Copyright (c) OmniBTC, Inc.
2 | // SPDX-License-Identifier: GPL-3.0
3 | module test_coins::btc {
4 | use std::option;
5 |
6 | use sui::coin;
7 | use sui::transfer;
8 | use sui::tx_context::{Self, TxContext};
9 |
10 | friend test_coins::faucet;
11 |
12 | ////////////////////////////////////
13 |
14 | /// Witness
15 | struct BTC has drop {}
16 |
17 | ////////////////////////////////////
18 |
19 | fun init(btc_witness: BTC, ctx: &mut TxContext) {
20 | let (cap, metadata) = coin::create_currency(
21 | btc_witness,
22 | 8,
23 | b"BTC",
24 | b"Bitcoin",
25 | b"https://bitcoin.org/",
26 | option::none(),
27 | ctx
28 | );
29 | transfer::public_share_object(metadata);
30 | transfer::public_transfer(cap, tx_context::sender(ctx));
31 | }
32 | }
--------------------------------------------------------------------------------
/sui/test_coins/sources/usdt.move:
--------------------------------------------------------------------------------
1 | // Copyright (c) OmniBTC, Inc.
2 | // SPDX-License-Identifier: GPL-3.0
3 | module test_coins::usdt {
4 | use std::option;
5 |
6 | use sui::coin;
7 | use sui::transfer;
8 | use sui::tx_context::{Self, TxContext};
9 |
10 | friend test_coins::faucet;
11 |
12 | ////////////////////////////////////
13 | struct USDT has drop {}
14 |
15 | ////////////////////////////////////
16 |
17 | fun init(usdt_witness: USDT, ctx: &mut TxContext) {
18 | let (cap, metadata) = coin::create_currency(
19 | usdt_witness,
20 | 6,
21 | b"USDT",
22 | b"Tether USD stablecoin",
23 | b"https://tether.to/",
24 | option::none(),
25 | ctx
26 | );
27 | transfer::public_share_object(metadata);
28 | transfer::public_transfer(cap, tx_context::sender(ctx));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/IERC173.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | /// @title ERC-173 Contract Ownership Standard
5 | /// Note: the ERC-165 identifier for this interface is 0x7f5828d0
6 | /* is ERC165 */
7 | interface IERC173 {
8 | /// @dev This emits when ownership of a contract changes.
9 | event OwnershipTransferred(
10 | address indexed previousOwner,
11 | address indexed newOwner
12 | );
13 |
14 | /// @notice Get the address of the owner
15 | /// @return owner_ The address of the owner.
16 | function owner() external view returns (address owner_);
17 |
18 | /// @notice Set the address of the new owner of the contract
19 | /// @dev Set _newOwner to address(0) to renounce any ownership.
20 | /// @param _newOwner The address of the new owner of the contract
21 | function transferOwnership(address _newOwner) external;
22 | }
23 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/IERC173.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | /// @title ERC-173 Contract Ownership Standard
5 | /// Note: the ERC-165 identifier for this interface is 0x7f5828d0
6 | /* is ERC165 */
7 | interface IERC173 {
8 | /// @dev This emits when ownership of a contract changes.
9 | event OwnershipTransferred(
10 | address indexed previousOwner,
11 | address indexed newOwner
12 | );
13 |
14 | /// @notice Get the address of the owner
15 | /// @return owner_ The address of the owner.
16 | function owner() external view returns (address owner_);
17 |
18 | /// @notice Set the address of the new owner of the contract
19 | /// @dev Set _newOwner to address(0) to renounce any ownership.
20 | /// @param _newOwner The address of the new owner of the contract
21 | function transferOwnership(address _newOwner) external;
22 | }
23 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/UniswapV2/IUniswapV2Factory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.5.0;
2 |
3 | interface IUniswapV2Factory {
4 | event PairCreated(
5 | address indexed token0,
6 | address indexed token1,
7 | address pair,
8 | uint256
9 | );
10 |
11 | function feeTo() external view returns (address);
12 |
13 | function feeToSetter() external view returns (address);
14 |
15 | function getPair(
16 | address tokenA,
17 | address tokenB
18 | ) external view returns (address pair);
19 |
20 | function allPairs(uint256) external view returns (address pair);
21 |
22 | function allPairsLength() external view returns (uint256);
23 |
24 | function createPair(
25 | address tokenA,
26 | address tokenB
27 | ) external returns (address pair);
28 |
29 | function setFeeTo(address) external;
30 |
31 | function setFeeToSetter(address) external;
32 | }
33 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/UniswapV2/IUniswapV2Factory.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.5.0;
2 |
3 | interface IUniswapV2Factory {
4 | event PairCreated(
5 | address indexed token0,
6 | address indexed token1,
7 | address pair,
8 | uint256
9 | );
10 |
11 | function feeTo() external view returns (address);
12 |
13 | function feeToSetter() external view returns (address);
14 |
15 | function getPair(address tokenA, address tokenB)
16 | external
17 | view
18 | returns (address pair);
19 |
20 | function allPairs(uint256) external view returns (address pair);
21 |
22 | function allPairsLength() external view returns (uint256);
23 |
24 | function createPair(address tokenA, address tokenB)
25 | external
26 | returns (address pair);
27 |
28 | function setFeeTo(address) external;
29 |
30 | function setFeeToSetter(address) external;
31 | }
32 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Chainlink/IAggregatorV3Interface.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IAggregatorV3Interface {
5 | function decimals() external view returns (uint8);
6 |
7 | function description() external view returns (string memory);
8 |
9 | function version() external view returns (uint256);
10 |
11 | function getRoundData(uint80 _roundId)
12 | external
13 | view
14 | returns (
15 | uint80 roundId,
16 | int256 answer,
17 | uint256 startedAt,
18 | uint256 updatedAt,
19 | uint80 answeredInRound
20 | );
21 |
22 | function latestRoundData()
23 | external
24 | view
25 | returns (
26 | uint80 roundId,
27 | int256 answer,
28 | uint256 startedAt,
29 | uint256 updatedAt,
30 | uint80 answeredInRound
31 | );
32 | }
33 |
--------------------------------------------------------------------------------
/ethereum/contracts/Facets/DiamondCutFacet.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | import "../Interfaces/IDiamondCut.sol";
5 | import "../Libraries/LibDiamond.sol";
6 |
7 | contract DiamondCutFacet is IDiamondCut {
8 | /// @notice Add/replace/remove any number of functions and optionally execute
9 | /// a function with delegatecall
10 | /// @param facetCut Contains the facet addresses and function selectors
11 | /// @param init The address of the contract or facet to execute calldata
12 | /// @param callData A function call, including function selector and arguments
13 | /// calldata is executed with delegatecall on init
14 | function diamondCut(
15 | FacetCut[] calldata facetCut,
16 | address init,
17 | bytes calldata callData
18 | ) external override {
19 | LibDiamond.enforceIsContractOwner();
20 | LibDiamond.diamondCut(facetCut, init, callData);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Chainlink/IAggregatorV3Interface.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IAggregatorV3Interface {
5 | function decimals() external view returns (uint8);
6 |
7 | function description() external view returns (string memory);
8 |
9 | function version() external view returns (uint256);
10 |
11 | function getRoundData(
12 | uint80 _roundId
13 | )
14 | external
15 | view
16 | returns (
17 | uint80 roundId,
18 | int256 answer,
19 | uint256 startedAt,
20 | uint256 updatedAt,
21 | uint80 answeredInRound
22 | );
23 |
24 | function latestRoundData()
25 | external
26 | view
27 | returns (
28 | uint80 roundId,
29 | int256 answer,
30 | uint256 startedAt,
31 | uint256 updatedAt,
32 | uint80 answeredInRound
33 | );
34 | }
35 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Facets/DiamondCutFacet.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | import "../Interfaces/IDiamondCut.sol";
5 | import "../Libraries/LibDiamond.sol";
6 |
7 | contract DiamondCutFacet is IDiamondCut {
8 | /// @notice Add/replace/remove any number of functions and optionally execute
9 | /// a function with delegatecall
10 | /// @param facetCut Contains the facet addresses and function selectors
11 | /// @param init The address of the contract or facet to execute calldata
12 | /// @param callData A function call, including function selector and arguments
13 | /// calldata is executed with delegatecall on init
14 | function diamondCut(
15 | FacetCut[] calldata facetCut,
16 | address init,
17 | bytes calldata callData
18 | ) external override {
19 | LibDiamond.enforceIsContractOwner();
20 | LibDiamond.diamondCut(facetCut, init, callData);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ethereum/scripts/data/chunks/mapping.json:
--------------------------------------------------------------------------------
1 | {
2 | "0x000f87d197d05e556495f292c2e1ad2194216f66": "0x20f0bed2d3204136519df30bcef067107941dc9b",
3 | "0x2122e338707245c71429f6442877c3365a51147e": "0x3892d5ef49609377526058e481e74d829b2e8c8a",
4 | "0x3899dd51aeae32366d74527f7fd53821bf92ef15": "0x54d277454114b254c57172c7c050d0ab00f2322a",
5 | "0x5538f671cc914111cf44989b3b930b0c72b679f4": "0x6725b0e53ed3b3b9e8540f819e688b7303db44cc",
6 | "0x6740d8eee0b543c87b1631681a305d86408d5747": "0x8311a7e8470782cc795c1cc2f5b76df16751eeb7",
7 | "0x831e90d74dffa0d834790cd919733a44b82138dd": "0x9c0d317489fc0fcb3b040e034d9c0bed380291a3",
8 | "0x9cc969ce3cbedd90fedded96b0840a9c0c58b8e0": "0xb33390ce83dfdae40cf4f7cea6968f0b27493818",
9 | "0xb348e8ada3b35897892c14852f21fcee6da56c9a": "0xcc5b320990aee0704cae23eb98739d9e9e8cdcfb",
10 | "0xcc7473f4cad6e3daf8186b571a51bde7ea18319a": "0xe9f005e1a4b089069236eda44d5cc90cd0cba3c9",
11 | "0xea49819f669c224c7782cc4f6b6b122573d092e7": "0xffbf39188234ab732590ec6b232c535e35437639"
12 | }
--------------------------------------------------------------------------------
/solana/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
4 | "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
5 | "start": "tsc && node dist/solana.js",
6 | "build": "tsc"
7 | },
8 | "dependencies": {
9 | "@certusone/wormhole-sdk": "^0.10.13",
10 | "@coral-xyz/anchor": "^0.28.0",
11 | "@orca-so/common-sdk": "^0.3.4",
12 | "@orca-so/whirlpools-sdk": "^0.11.5",
13 | "axios": "^1.5.1",
14 | "bs58": "^5.0.0",
15 | "csv-writer": "^1.6.0",
16 | "dotenv": "^16.3.1",
17 | "ethers": "^5.6.8",
18 | "prompt": "^1.3.0",
19 | "toml": "^3.0.0"
20 | },
21 | "devDependencies": {
22 | "@types/bn.js": "^5.1.0",
23 | "@types/chai": "^4.3.0",
24 | "@types/mocha": "^9.0.0",
25 | "chai": "^4.3.4",
26 | "mocha": "^9.0.3",
27 | "prettier": "^2.6.2",
28 | "ts-mocha": "^10.0.0",
29 | "typescript": "^4.3.5"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/state/price_manager.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | #[account]
4 | #[derive(Default)]
5 | pub struct PriceManager {
6 | /// Who can update current_price_ratio
7 | pub owner: Pubkey,
8 | /// The currnet price ratio of native coins
9 | pub current_price_ratio: u64,
10 | // Last update timestamp for price ratio
11 | pub last_update_timestamp: u64,
12 | }
13 |
14 | impl PriceManager {
15 | pub const MAXIMUM_SIZE: usize = 8 // discriminator
16 | + 32 // price_manager
17 | + 8 // current_price_ratio
18 | + 8 // last_update_timestamp
19 | ;
20 | /// AKA `b"price_manager"`.
21 | pub const SEED_PREFIX: &'static [u8; 13] = b"price_manager";
22 | }
23 |
24 | #[cfg(test)]
25 | pub mod test {
26 | use super::*;
27 | use std::mem::size_of;
28 |
29 | #[test]
30 | fn test_config() -> Result<()> {
31 | assert_eq!(
32 | PriceManager::MAXIMUM_SIZE,
33 | size_of::() + size_of::() + size_of::() + size_of::()
34 | );
35 |
36 | Ok(())
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/solana/scripts/check_request.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from solders.pubkey import Pubkey
4 |
5 | from omniswap.accounts.cross_request import CrossRequest
6 | from helper import deriveCrossRequestKey
7 | from solana_config import get_client, get_config
8 |
9 |
10 | async def omniswap_estimate_relayer_fee(
11 | network="devnet",
12 | ):
13 | client = get_client(network)
14 | await client.is_connected()
15 |
16 | config = get_config(network)
17 |
18 | omniswap_program_id = config["program"]["SoDiamond"]
19 |
20 | start = 0
21 | requester = Pubkey.from_string("")
22 | while True:
23 | req_key = deriveCrossRequestKey(
24 | omniswap_program_id, sequence=start, requester=requester
25 | )
26 |
27 | req = await CrossRequest.fetch(client, req_key)
28 | if req is None:
29 | print(f"request={req_key}, None")
30 | else:
31 | print(f"request={req_key}, Some")
32 |
33 | start += 1
34 |
35 |
36 | asyncio.run(omniswap_estimate_relayer_fee())
37 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/errors/__init__.py:
--------------------------------------------------------------------------------
1 | import typing
2 | import re
3 | from solders.transaction_status import (
4 | InstructionErrorCustom,
5 | TransactionErrorInstructionError,
6 | )
7 | from solana.rpc.core import RPCException
8 | from solders.rpc.errors import SendTransactionPreflightFailureMessage
9 | from anchorpy.error import extract_code_and_logs
10 | from ..program_id import PROGRAM_ID
11 | from . import anchor
12 | from . import custom
13 |
14 |
15 | def from_code(code: int) -> typing.Union[custom.CustomError, anchor.AnchorError, None]:
16 | return custom.from_code(code) if code >= 6000 else anchor.from_code(code)
17 |
18 |
19 | error_re = re.compile(r"Program (\w+) failed: custom program error: (\w+)")
20 |
21 |
22 | def from_tx_error(
23 | error: RPCException,
24 | ) -> typing.Union[anchor.AnchorError, custom.CustomError, None]:
25 | err_info = error.args[0]
26 | extracted = extract_code_and_logs(err_info, PROGRAM_ID)
27 | if extracted is None:
28 | return None
29 | return from_code(extracted[0])
30 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/close_pending_request.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | use crate::{cross_request::CrossRequest, RedeemerConfig, SoSwapError};
4 |
5 | #[derive(Accounts)]
6 | pub struct CloseRequest<'info> {
7 | #[account(mut)]
8 | /// The requester or proxy
9 | pub payer: Signer<'info>,
10 |
11 | #[account(mut)]
12 | /// CHECK: the requester
13 | pub recipient: UncheckedAccount<'info>,
14 |
15 | #[account(
16 | seeds = [RedeemerConfig::SEED_PREFIX],
17 | bump
18 | )]
19 | /// Redeemer Config account.
20 | pub config: Box>,
21 |
22 | #[account(mut, close = recipient)]
23 | pub request: Box>,
24 |
25 | /// System program.
26 | pub system_program: Program<'info, System>,
27 | }
28 |
29 | pub fn handler(ctx: Context) -> Result<()> {
30 | require!(
31 | ctx.accounts.payer.key() == ctx.accounts.config.proxy ||
32 | ctx.accounts.payer.key() == ctx.accounts.request.payer,
33 | SoSwapError::OwnerOnly
34 | );
35 |
36 | Ok(())
37 | }
38 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Curve/ICurveFi.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface ICurveFi {
5 | function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external;
6 |
7 | function exchange_underlying(
8 | int128 i,
9 | int128 j,
10 | uint256 dx,
11 | uint256 min_dy
12 | ) external;
13 |
14 | function get_dx_underlying(
15 | int128 i,
16 | int128 j,
17 | uint256 dy
18 | ) external view returns (uint256);
19 |
20 | function get_dy_underlying(
21 | int128 i,
22 | int128 j,
23 | uint256 dx
24 | ) external view returns (uint256);
25 |
26 | function get_dx(
27 | int128 i,
28 | int128 j,
29 | uint256 dy
30 | ) external view returns (uint256);
31 |
32 | function get_dy(
33 | int128 i,
34 | int128 j,
35 | uint256 dx
36 | ) external view returns (uint256);
37 |
38 | function get_virtual_price() external view returns (uint256);
39 | }
40 |
--------------------------------------------------------------------------------
/ethereum/contracts/Helpers/MockNFT.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity >=0.7.6;
4 |
5 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
6 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
7 | import "@openzeppelin/contracts/access/Ownable.sol";
8 |
9 | contract MockNFT is ERC721URIStorage, Ownable {
10 | uint256 private _nextTokenId;
11 |
12 | constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {
13 | _nextTokenId = 1;
14 | }
15 |
16 | function mint(address to) public onlyOwner {
17 | uint256 tokenId = _nextTokenId;
18 | _nextTokenId++;
19 | _mint(to, tokenId);
20 | _setTokenURI(tokenId, "");
21 | }
22 |
23 | function mintBatch(address to, uint256 amount) public onlyOwner {
24 | for (uint256 i = 0; i < amount; i++) {
25 | uint256 tokenId = _nextTokenId;
26 | _nextTokenId++;
27 | _mint(to, tokenId);
28 | _setTokenURI(tokenId, "");
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/Move.lock:
--------------------------------------------------------------------------------
1 | # @generated by Move, please check-in and do not edit manually.
2 |
3 | [move]
4 | version = 0
5 |
6 | dependencies = [
7 | { name = "IntegerMate" },
8 | { name = "MoveSTL" },
9 | { name = "Sui" },
10 | ]
11 |
12 | [[move.package]]
13 | name = "IntegerMate"
14 | source = { local = "../../../integer-mate/sui" }
15 |
16 | dependencies = [
17 | { name = "Sui" },
18 | ]
19 |
20 | [[move.package]]
21 | name = "MoveSTL"
22 | source = { local = "../../../move-stl/sui" }
23 |
24 | dependencies = [
25 | { name = "Sui" },
26 | ]
27 |
28 | [[move.package]]
29 | name = "MoveStdlib"
30 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "09b2081498366df936abae26eea4b2d5cafb2788", subdir = "crates/sui-framework/packages/move-stdlib" }
31 |
32 | [[move.package]]
33 | name = "Sui"
34 | source = { git = "https://github.com/MystenLabs/sui.git", rev = "09b2081498366df936abae26eea4b2d5cafb2788", subdir = "crates/sui-framework/packages/sui-framework" }
35 |
36 | dependencies = [
37 | { name = "MoveStdlib" },
38 | ]
39 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CCTP/IMessageTransmitter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IMessageTransmitter {
5 | event MessageSent(bytes message);
6 |
7 | /**
8 | * @notice Sends an outgoing message from the source domain.
9 | * @dev Increment nonce, format the message, and emit `MessageSent` event with message information.
10 | * @param destinationDomain Domain of destination chain
11 | * @param recipient Address of message recipient on destination domain as bytes32
12 | * @param messageBody Raw bytes content of message
13 | * @return nonce reserved by message
14 | */
15 | function sendMessage(
16 | uint32 destinationDomain,
17 | bytes32 recipient,
18 | bytes calldata messageBody
19 | ) external returns (uint64);
20 |
21 | function sendMessageWithCaller(
22 | uint32 destinationDomain,
23 | bytes32 recipient,
24 | bytes32 destinationCaller,
25 | bytes calldata messageBody
26 | ) external returns (uint64);
27 | }
28 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Stargate/IStargateEthVault.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IStargateEthVault {
5 | event Approval(address indexed src, address indexed guy, uint256 wad);
6 | event Transfer(address indexed src, address indexed dst, uint256 wad);
7 | event Deposit(address indexed dst, uint256 wad);
8 | event Withdrawal(address indexed src, uint256 wad);
9 | event TransferNative(address indexed src, address indexed dst, uint256 wad);
10 |
11 | function balanceOf(address account) external view returns (uint256);
12 |
13 | function noUnwrapTo(address) external view returns (bool);
14 |
15 | function deposit() external payable;
16 |
17 | function transfer(address to, uint256 value) external returns (bool);
18 |
19 | function withdraw(uint256) external;
20 |
21 | function approve(address guy, uint256 wad) external returns (bool);
22 |
23 | function transferFrom(
24 | address src,
25 | address dst,
26 | uint256 wad
27 | ) external returns (bool);
28 | }
29 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/CCTP/IMessageTransmitter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IMessageTransmitter {
5 | event MessageSent(bytes message);
6 |
7 | /**
8 | * @notice Sends an outgoing message from the source domain.
9 | * @dev Increment nonce, format the message, and emit `MessageSent` event with message information.
10 | * @param destinationDomain Domain of destination chain
11 | * @param recipient Address of message recipient on destination domain as bytes32
12 | * @param messageBody Raw bytes content of message
13 | * @return nonce reserved by message
14 | */
15 | function sendMessage(
16 | uint32 destinationDomain,
17 | bytes32 recipient,
18 | bytes calldata messageBody
19 | ) external returns (uint64);
20 |
21 | function sendMessageWithCaller(
22 | uint32 destinationDomain,
23 | bytes32 recipient,
24 | bytes32 destinationCaller,
25 | bytes calldata messageBody
26 | ) external returns (uint64);
27 | }
28 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Stargate/IStargateEthVault.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IStargateEthVault {
5 | event Approval(address indexed src, address indexed guy, uint256 wad);
6 | event Transfer(address indexed src, address indexed dst, uint256 wad);
7 | event Deposit(address indexed dst, uint256 wad);
8 | event Withdrawal(address indexed src, uint256 wad);
9 | event TransferNative(address indexed src, address indexed dst, uint256 wad);
10 |
11 | function balanceOf(address account) external view returns (uint256);
12 |
13 | function noUnwrapTo(address) external view returns (bool);
14 |
15 | function deposit() external payable;
16 |
17 | function transfer(address to, uint256 value) external returns (bool);
18 |
19 | function withdraw(uint256) external;
20 |
21 | function approve(address guy, uint256 wad) external returns (bool);
22 |
23 | function transferFrom(
24 | address src,
25 | address dst,
26 | uint256 wad
27 | ) external returns (bool);
28 | }
29 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/deployed.json:
--------------------------------------------------------------------------------
1 | {
2 | "DiamondCutFacet": "0x834d27FC014c5D91a2586E5725dE11D6Ef8B2BCD",
3 | "DiamondLoupeFacet": "0x40543888511eeC02d42468d4FefD4A09d64022c1",
4 | "DexManagerFacet": "0xaf641eE8f18e93aF201f7f136E01eD5C9F9f6E6c",
5 | "WithdrawFacet": "0x7374f5ED3Ce6Cbf9DFD73ceE17d78350aE692a52",
6 | "OwnershipFacet": "0x61e0feE9Af073f28F017BB497a7152f00db9b0dC",
7 | "GenericSwapFacet": "0x9AeB91bF0B0Cb415FD0c31CEE8B83639e1e82A76",
8 | "SerdeFacet": "0x73a25CA98F9268114b6501cf22CA911fdba7cb6B",
9 | "SoDiamond": "0x2350D92F6Bf51C202395B10D6b8a6ae0B37bB577",
10 | "LibCorrectSwapV1": "0x567386348D0CF10f5805B88adE54Fc03F238a9b4",
11 | "CelerFacet": "0x1A8BEEF9299233811C3a9936748e14c8C77876D2",
12 | "LibSoFeeCelerV1": "0x8bB2d077D0911459d80d5010f85EBa2232ca6d25",
13 | "LibSoFeeBoolV2": "0xABf86bd9f5c6385992B80AcC0286f4B176313a51",
14 | "BoolFacet": "0x01765a7309B6C1085d73c1F31424E720cC921457",
15 | "LibSoFeeGenericV2": "0x4bc6913746266b7C22F71ca8B48Eb0184a7Ae3e7",
16 | "LibCorrectSwapV2": "0x4B0492bCc5316257153c087735198D5B6e57D42d"
17 | }
--------------------------------------------------------------------------------
/solana/modules/wormhole-anchor-sdk/src/token_bridge/utils.rs:
--------------------------------------------------------------------------------
1 | pub const MAX_WRAPPED_ASSET_DECIMALS: u8 = 8;
2 |
3 | /// Normalize raw amount based on this native mint's decimals.
4 | pub fn normalize_amount(amount: u64, mint_decimals: u8) -> u64 {
5 | amount / amount_adjustment(mint_decimals)
6 | }
7 |
8 | /// Denormalize encoded amount based on this native mint's decimals. This will
9 | /// be the amount transferred from the Token Bridge program's token (custody)
10 | /// account.
11 | pub fn denormalize_amount(amount: u64, mint_decimals: u8) -> u64 {
12 | amount * amount_adjustment(mint_decimals)
13 | }
14 |
15 | // Truncate raw amount based on this native mint's decimals before bridging
16 | /// to prevent dust left in a token account.
17 | pub fn truncate_amount(amount: u64, mint_decimals: u8) -> u64 {
18 | denormalize_amount(normalize_amount(amount, mint_decimals), mint_decimals)
19 | }
20 |
21 | fn amount_adjustment(mint_decimals: u8) -> u64 {
22 | if mint_decimals > MAX_WRAPPED_ASSET_DECIMALS {
23 | 10u64.pow((mint_decimals - MAX_WRAPPED_ASSET_DECIMALS) as u32)
24 | } else {
25 | 1
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/sui/sources/full_math_u64.move:
--------------------------------------------------------------------------------
1 | module integer_mate::full_math_u64 {
2 | public fun mul_div_floor(num1: u64, num2: u64, denom: u64): u64 {
3 | let r = full_mul(num1, num2) / (denom as u128);
4 | (r as u64)
5 | }
6 |
7 | public fun mul_div_round(num1: u64, num2: u64, denom: u64): u64 {
8 | let r = (full_mul(num1, num2) + ((denom as u128) >> 1)) / (denom as u128);
9 | (r as u64)
10 | }
11 |
12 | public fun mul_div_ceil(num1: u64, num2: u64, denom: u64): u64 {
13 | let r = (full_mul(num1, num2) + ((denom as u128) - 1)) / (denom as u128);
14 | (r as u64)
15 | }
16 |
17 | public fun mul_shr(num1: u64, num2: u64, shift: u8): u64 {
18 | let r = full_mul(num1, num2) >> shift;
19 | (r as u64)
20 | }
21 |
22 | public fun mul_shl(num1: u64, num2: u64, shift: u8): u64 {
23 | let r = full_mul(num1, num2) << shift;
24 | (r as u64)
25 | }
26 |
27 | public fun full_mul(num1: u64, num2: u64): u128 {
28 | ((num1 as u128) * (num2 as u128))
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/aptos/sources/utils/u16.move:
--------------------------------------------------------------------------------
1 | module omniswap::u16 {
2 |
3 | const MAX_U16: u64 = (1 << 16) - 1;
4 |
5 | const E_OVERFLOW: u64 = 0x0;
6 |
7 | struct U16 has key, store, copy, drop {
8 | number: u64
9 | }
10 |
11 | fun check_overflow(u: &U16) {
12 | assert!(u.number <= MAX_U16, E_OVERFLOW)
13 | }
14 |
15 | public fun from_u64(number: u64): U16 {
16 | let u = U16 { number };
17 | check_overflow(&u);
18 | u
19 | }
20 |
21 | public fun to_u64(u: U16): u64 {
22 | u.number
23 | }
24 |
25 | public fun zero(): U16 {
26 | U16 { number: 0 }
27 | }
28 |
29 | public fun split_u8(number: U16): (u8, u8) {
30 | let U16 { number } = number;
31 | let v0: u8 = ((number >> 8) % (0xFF + 1) as u8);
32 | let v1: u8 = (number % (0xFF + 1) as u8);
33 | (v0, v1)
34 | }
35 |
36 | #[test]
37 | public fun test_split_u8() {
38 | let u = from_u64(0x1234);
39 | let (v0, v1) = split_u8(u);
40 | assert!(v0 == 0x12, 0);
41 | assert!(v1 == 0x34, 0);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/aptos/sources/full_math_u64.move:
--------------------------------------------------------------------------------
1 | module integer_mate::full_math_u64 {
2 | public fun mul_div_floor(num1: u64, num2: u64, denom: u64): u64 {
3 | let r = full_mul(num1, num2) / (denom as u128);
4 | (r as u64)
5 | }
6 |
7 | public fun mul_div_round(num1: u64, num2: u64, denom: u64): u64 {
8 | let r = (full_mul(num1, num2) + ((denom as u128) >> 1)) / (denom as u128);
9 | (r as u64)
10 | }
11 |
12 | public fun mul_div_ceil(num1: u64, num2: u64, denom: u64): u64 {
13 | let r = (full_mul(num1, num2) + ((denom as u128) - 1)) / (denom as u128);
14 | (r as u64)
15 | }
16 |
17 | public fun mul_shr(num1: u64, num2: u64, shift: u8): u64 {
18 | let r = full_mul(num1, num2) >> shift;
19 | (r as u64)
20 | }
21 |
22 | public fun mul_shl(num1: u64, num2: u64, shift: u8): u64 {
23 | let r = full_mul(num1, num2) << shift;
24 | (r as u64)
25 | }
26 |
27 | public fun full_mul(num1: u64, num2: u64): u128 {
28 | ((num1 as u128) * (num2 as u128))
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Lynex/ILynexRouter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface ILynexRouter {
5 | struct route {
6 | address from;
7 | address to;
8 | bool stable;
9 | }
10 |
11 | function getAmountsOut(
12 | uint amountIn,
13 | route[] memory routes
14 | ) external view returns (uint[] memory amounts);
15 |
16 | function swapExactTokensForTokens(
17 | uint amountIn,
18 | uint amountOutMin,
19 | route[] calldata routes,
20 | address to,
21 | uint deadline
22 | ) external returns (uint[] memory amounts);
23 |
24 | function swapExactETHForTokens(
25 | uint amountOutMin,
26 | route[] calldata routes,
27 | address to,
28 | uint deadline
29 | ) external payable returns (uint[] memory amounts);
30 |
31 | function swapExactTokensForETH(
32 | uint amountIn,
33 | uint amountOutMin,
34 | route[] calldata routes,
35 | address to,
36 | uint deadline
37 | ) external returns (uint[] memory amounts);
38 | }
39 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Curve/ICurveFi.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface ICurveFi {
5 | function exchange(
6 | int128 i,
7 | int128 j,
8 | uint256 dx,
9 | uint256 min_dy
10 | ) external;
11 |
12 | function exchange_underlying(
13 | int128 i,
14 | int128 j,
15 | uint256 dx,
16 | uint256 min_dy
17 | ) external;
18 |
19 | function get_dx_underlying(
20 | int128 i,
21 | int128 j,
22 | uint256 dy
23 | ) external view returns (uint256);
24 |
25 | function get_dy_underlying(
26 | int128 i,
27 | int128 j,
28 | uint256 dx
29 | ) external view returns (uint256);
30 |
31 | function get_dx(
32 | int128 i,
33 | int128 j,
34 | uint256 dy
35 | ) external view returns (uint256);
36 |
37 | function get_dy(
38 | int128 i,
39 | int128 j,
40 | uint256 dx
41 | ) external view returns (uint256);
42 |
43 | function get_virtual_price() external view returns (uint256);
44 | }
45 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/TraderJoe/IPendingOwnable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | /**
6 | * @title Liquidity Book Pending Ownable Interface
7 | * @author Trader Joe
8 | * @notice Required interface of Pending Ownable contract used for LBFactory
9 | */
10 | interface IPendingOwnable {
11 | error PendingOwnable__AddressZero();
12 | error PendingOwnable__NoPendingOwner();
13 | error PendingOwnable__NotOwner();
14 | error PendingOwnable__NotPendingOwner();
15 | error PendingOwnable__PendingOwnerAlreadySet();
16 |
17 | event PendingOwnerSet(address indexed pendingOwner);
18 |
19 | event OwnershipTransferred(
20 | address indexed previousOwner,
21 | address indexed newOwner
22 | );
23 |
24 | function owner() external view returns (address);
25 |
26 | function pendingOwner() external view returns (address);
27 |
28 | function setPendingOwner(address pendingOwner) external;
29 |
30 | function revokePendingOwner() external;
31 |
32 | function becomeOwner() external;
33 |
34 | function renounceOwnership() external;
35 | }
36 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/sui/sources/full_math_u128.move:
--------------------------------------------------------------------------------
1 | module integer_mate::full_math_u128 {
2 | public fun mul_div_floor(num1: u128, num2: u128, denom: u128): u128 {
3 | let r = full_mul(num1, num2) / (denom as u256);
4 | (r as u128)
5 | }
6 |
7 | public fun mul_div_round(num1: u128, num2: u128, denom: u128): u128 {
8 | let r = (full_mul(num1, num2) + ((denom as u256) >> 1)) / (denom as u256);
9 | (r as u128)
10 | }
11 |
12 | public fun mul_div_ceil(num1: u128, num2: u128, denom: u128): u128 {
13 | let r = (full_mul(num1, num2) + ((denom as u256) - 1)) / (denom as u256);
14 | (r as u128)
15 | }
16 |
17 | public fun mul_shr(num1: u128, num2: u128, shift: u8): u128 {
18 | let product = full_mul(num1, num2) >> shift;
19 | (product as u128)
20 | }
21 |
22 | public fun mul_shl(num1: u128, num2: u128, shift: u8): u128 {
23 | let product = full_mul(num1, num2) << shift;
24 | (product as u128)
25 | }
26 |
27 | public fun full_mul(num1: u128, num2: u128): u256 {
28 | (num1 as u256) * (num2 as u256)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Steven Piao
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/IDiamondCut.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IDiamondCut {
5 | enum FacetCutAction {
6 | Add,
7 | Replace,
8 | Remove
9 | }
10 | // Add=0, Replace=1, Remove=2
11 |
12 | struct FacetCut {
13 | address facetAddress;
14 | FacetCutAction action;
15 | bytes4[] functionSelectors;
16 | }
17 |
18 | /// @notice Add/replace/remove any number of functions and optionally execute
19 | /// a function with delegatecall
20 | /// @param _diamondCut Contains the facet addresses and function selectors
21 | /// @param _init The address of the contract or facet to execute _calldata
22 | /// @param _calldata A function call, including function selector and arguments
23 | /// _calldata is executed with delegatecall on _init
24 | function diamondCut(
25 | FacetCut[] calldata _diamondCut,
26 | address _init,
27 | bytes calldata _calldata
28 | ) external;
29 |
30 | event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
31 | }
32 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/hardhat.config.ts:
--------------------------------------------------------------------------------
1 | import "@matterlabs/hardhat-zksync-deploy";
2 | import "@matterlabs/hardhat-zksync-solc";
3 | import "@matterlabs/hardhat-zksync-verify";
4 |
5 | module.exports = {
6 | zksolc: {
7 | version: "1.3.7",
8 | compilerSource: "binary",
9 | settings: {},
10 | },
11 | defaultNetwork: "zkTestnet",
12 | networks: {
13 | zkTestnet: {
14 | // url: "https://zksync2-testnet.zksync.dev",
15 | url: "https://testnet.era.zksync.dev",// URL of the zkSync network RPC
16 | ethNetwork: "goerli", // Can also be the RPC URL of the Ethereum network (e.g. `https://goerli.infura.io/v3/`)
17 | zksync: true,
18 | // Verification endpoint
19 | verifyURL: 'https://zksync2-testnet-explorer.zksync.dev/contract_verification'
20 | },
21 | zkMainnet: {
22 | url: "https://mainnet.era.zksync.io",
23 | ethNetwork: "mainnet",
24 | zksync: true,
25 | // Verification endpoint
26 | verifyURL: 'https://zksync2-mainnet-explorer.zksync.io/contract_verification'
27 | }
28 | },
29 | solidity: {
30 | version: "0.8.13",
31 | },
32 | };
33 |
34 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/TraderJoe/IPendingOwnable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | /**
6 | * @title Liquidity Book Pending Ownable Interface
7 | * @author Trader Joe
8 | * @notice Required interface of Pending Ownable contract used for LBFactory
9 | */
10 | interface IPendingOwnable {
11 | error PendingOwnable__AddressZero();
12 | error PendingOwnable__NoPendingOwner();
13 | error PendingOwnable__NotOwner();
14 | error PendingOwnable__NotPendingOwner();
15 | error PendingOwnable__PendingOwnerAlreadySet();
16 |
17 | event PendingOwnerSet(address indexed pendingOwner);
18 |
19 | event OwnershipTransferred(
20 | address indexed previousOwner,
21 | address indexed newOwner
22 | );
23 |
24 | function owner() external view returns (address);
25 |
26 | function pendingOwner() external view returns (address);
27 |
28 | function setPendingOwner(address pendingOwner) external;
29 |
30 | function revokePendingOwner() external;
31 |
32 | function becomeOwner() external;
33 |
34 | function renounceOwnership() external;
35 | }
36 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/IDiamondCut.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | interface IDiamondCut {
5 | enum FacetCutAction {
6 | Add,
7 | Replace,
8 | Remove
9 | }
10 | // Add=0, Replace=1, Remove=2
11 |
12 | struct FacetCut {
13 | address facetAddress;
14 | FacetCutAction action;
15 | bytes4[] functionSelectors;
16 | }
17 |
18 | /// @notice Add/replace/remove any number of functions and optionally execute
19 | /// a function with delegatecall
20 | /// @param _diamondCut Contains the facet addresses and function selectors
21 | /// @param _init The address of the contract or facet to execute _calldata
22 | /// @param _calldata A function call, including function selector and arguments
23 | /// _calldata is executed with delegatecall on _init
24 | function diamondCut(
25 | FacetCut[] calldata _diamondCut,
26 | address _init,
27 | bytes calldata _calldata
28 | ) external;
29 |
30 | event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
31 | }
32 |
--------------------------------------------------------------------------------
/ethereum/contracts/Libraries/LibUtil.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | import "./LibBytes.sol";
5 |
6 | library LibUtil {
7 | using LibBytes for bytes;
8 |
9 | function getRevertMsg(
10 | bytes memory _res
11 | ) internal pure returns (string memory) {
12 | // If the _res length is less than 68, then the transaction failed silently (without a revert message)
13 | if (_res.length < 68) return "Transaction reverted silently";
14 | bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes
15 | return abi.decode(revertData, (string)); // All that remains is the revert string
16 | }
17 |
18 | function getSlice(
19 | bytes memory _data,
20 | uint256 _start,
21 | uint256 _end
22 | ) internal pure returns (bytes memory) {
23 | require(_start < _end && _end <= _data.length, "DataLength error!");
24 | bytes memory _out = bytes("");
25 | for (uint256 i = _start; i < _end; i++) {
26 | _out = bytes.concat(_out, _data[i]);
27 | }
28 | return _out;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Pearl/IPearlRouter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IPearlRouter {
5 | struct route {
6 | address from;
7 | address to;
8 | bool stable;
9 | }
10 |
11 | function swapExactTokensForTokens(
12 | uint256 amountIn,
13 | uint256 amountOutMin,
14 | route[] calldata routes,
15 | address to,
16 | uint256 deadline
17 | ) external returns (uint256[] memory amounts);
18 |
19 | function swapExactTokensForETH(
20 | uint256 amountIn,
21 | uint256 amountOutMin,
22 | route[] calldata routes,
23 | address to,
24 | uint256 deadline
25 | ) external returns (uint256[] memory amounts);
26 |
27 | function swapExactETHForTokens(
28 | uint256 amountOutMin,
29 | route[] calldata routes,
30 | address to,
31 | uint256 deadline
32 | ) external payable returns (uint256[] memory amounts);
33 |
34 | function getAmountsOut(
35 | uint256 amountIn,
36 | route[] memory routes
37 | ) external view returns (uint256[] memory amounts);
38 | }
39 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Pearl/IPearlRouter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity ^0.8.0;
3 |
4 | interface IPearlRouter {
5 | struct route {
6 | address from;
7 | address to;
8 | bool stable;
9 | }
10 |
11 | function swapExactTokensForTokens(
12 | uint256 amountIn,
13 | uint256 amountOutMin,
14 | route[] calldata routes,
15 | address to,
16 | uint256 deadline
17 | ) external returns (uint256[] memory amounts);
18 |
19 | function swapExactTokensForETH(
20 | uint256 amountIn,
21 | uint256 amountOutMin,
22 | route[] calldata routes,
23 | address to,
24 | uint256 deadline
25 | ) external returns (uint256[] memory amounts);
26 |
27 | function swapExactETHForTokens(
28 | uint256 amountOutMin,
29 | route[] calldata routes,
30 | address to,
31 | uint256 deadline
32 | ) external payable returns (uint256[] memory amounts);
33 |
34 | function getAmountsOut(uint256 amountIn, route[] memory routes)
35 | external
36 | view
37 | returns (uint256[] memory amounts);
38 | }
39 |
--------------------------------------------------------------------------------
/solana/scripts/get_or_create_ata.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 | from pathlib import Path
4 |
5 | from solders.pubkey import Pubkey
6 |
7 | from solana_config import get_config
8 |
9 |
10 | def get_or_create_associated_token_account(
11 | token_mint: str, user_address: str, network="devnet"
12 | ):
13 | config = get_config(network)
14 |
15 | js_file_name = "get_or_create_ata.js"
16 | js_file_path = Path(__file__).parent.joinpath("test_dex").joinpath(js_file_name)
17 |
18 | new_env = {
19 | "ANCHOR_PROVIDER_URL": config["rpc_url"],
20 | "ANCHOR_WALLET": os.environ.get("TEST_OWNER"),
21 | }
22 |
23 | result = subprocess.run(
24 | ["node", str(js_file_path), token_mint, user_address],
25 | env={**os.environ, **new_env},
26 | capture_output=True,
27 | text=True,
28 | check=True,
29 | )
30 |
31 | return Pubkey.from_string(str(result.stdout).strip())
32 |
33 |
34 | if __name__ == "__main__":
35 | ata = get_or_create_associated_token_account(
36 | "xxtdhpCgop5gZSeCkRRHqiVu7hqEC9MKkd1xMRUZqrz",
37 | "4q2wPZMys1zCoAVpNmhgmofb6YM9MqLXmV25LdtEMAf9",
38 | )
39 | print(ata)
40 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/TraderJoe/IJoeFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity 0.8.13;
4 |
5 | /// @title Joe V1 Factory Interface
6 | /// @notice Interface to interact with Joe V1 Factory
7 | interface IJoeFactory {
8 | event PairCreated(
9 | address indexed token0,
10 | address indexed token1,
11 | address pair,
12 | uint256
13 | );
14 |
15 | function feeTo() external view returns (address);
16 |
17 | function feeToSetter() external view returns (address);
18 |
19 | function migrator() external view returns (address);
20 |
21 | function getPair(
22 | address tokenA,
23 | address tokenB
24 | ) external view returns (address pair);
25 |
26 | function allPairs(uint256) external view returns (address pair);
27 |
28 | function allPairsLength() external view returns (uint256);
29 |
30 | function createPair(
31 | address tokenA,
32 | address tokenB
33 | ) external returns (address pair);
34 |
35 | function setFeeTo(address) external;
36 |
37 | function setFeeToSetter(address) external;
38 |
39 | function setMigrator(address) external;
40 | }
41 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/TraderJoe/IJoeFactory.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity 0.8.13;
4 |
5 | /// @title Joe V1 Factory Interface
6 | /// @notice Interface to interact with Joe V1 Factory
7 | interface IJoeFactory {
8 | event PairCreated(
9 | address indexed token0,
10 | address indexed token1,
11 | address pair,
12 | uint256
13 | );
14 |
15 | function feeTo() external view returns (address);
16 |
17 | function feeToSetter() external view returns (address);
18 |
19 | function migrator() external view returns (address);
20 |
21 | function getPair(address tokenA, address tokenB)
22 | external
23 | view
24 | returns (address pair);
25 |
26 | function allPairs(uint256) external view returns (address pair);
27 |
28 | function allPairsLength() external view returns (uint256);
29 |
30 | function createPair(address tokenA, address tokenB)
31 | external
32 | returns (address pair);
33 |
34 | function setFeeTo(address) external;
35 |
36 | function setFeeToSetter(address) external;
37 |
38 | function setMigrator(address) external;
39 | }
40 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Libraries/LibUtil.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | import "./LibBytes.sol";
5 |
6 | library LibUtil {
7 | using LibBytes for bytes;
8 |
9 | function getRevertMsg(bytes memory _res)
10 | internal
11 | pure
12 | returns (string memory)
13 | {
14 | // If the _res length is less than 68, then the transaction failed silently (without a revert message)
15 | if (_res.length < 68) return "Transaction reverted silently";
16 | bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes
17 | return abi.decode(revertData, (string)); // All that remains is the revert string
18 | }
19 |
20 | function getSlice(
21 | bytes memory _data,
22 | uint256 _start,
23 | uint256 _end
24 | ) internal pure returns (bytes memory) {
25 | require(_start < _end && _end <= _data.length, "DataLength error!");
26 | bytes memory _out = bytes("");
27 | for (uint256 i = _start; i < _end; i++) {
28 | _out = bytes.concat(_out, _data[i]);
29 | }
30 | return _out;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/set_price_ratio.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | use crate::{
4 | error::SoSwapError,
5 | state::{ForeignContract, PriceManager},
6 | };
7 |
8 | #[derive(Accounts)]
9 | #[instruction(chain: u16)]
10 | pub struct SetPriceManager<'info> {
11 | #[account(mut)]
12 | /// Owner of the program set in the [`PriceManager`] account. Signer for
13 | /// updating [`PriceManager`] account.
14 | pub owner: Signer<'info>,
15 |
16 | #[account(
17 | mut,
18 | has_one = owner @ SoSwapError::OwnerOnly,
19 | seeds = [
20 | ForeignContract::SEED_PREFIX,
21 | &chain.to_le_bytes()[..],
22 | PriceManager::SEED_PREFIX
23 | ],
24 | bump
25 | )]
26 | /// Price Manager account.
27 | pub price_manager: Box>,
28 |
29 | /// Clock used for price manager.
30 | pub clock: Sysvar<'info, Clock>,
31 | }
32 |
33 | pub fn handler(ctx: Context, _chain: u16, new_price_ratio: u64) -> Result<()> {
34 | let price_manager = &mut ctx.accounts.price_manager;
35 | price_manager.current_price_ratio = new_price_ratio;
36 | price_manager.last_update_timestamp = ctx.accounts.clock.unix_timestamp as u64;
37 |
38 | // Done.
39 | Ok(())
40 | }
41 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Balancer/IAsset.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 | // This program is free software: you can redistribute it and/or modify
3 | // it under the terms of the GNU General Public License as published by
4 | // the Free Software Foundation, either version 3 of the License, or
5 | // (at your option) any later version.
6 |
7 | // This program is distributed in the hope that it will be useful,
8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | // GNU General Public License for more details.
11 |
12 | // You should have received a copy of the GNU General Public License
13 | // along with this program. If not, see .
14 |
15 | pragma solidity ^0.8.0;
16 |
17 | /**
18 | * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero
19 | * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like
20 | * types.
21 | *
22 | * This concept is unrelated to a Pool's Asset Managers.
23 | */
24 | interface IAsset {
25 | // solhint-disable-previous-line no-empty-blocks
26 | }
27 |
--------------------------------------------------------------------------------
/ethereum/interfaces/ILayerZeroMessagingLibrary.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity >=0.7.0;
4 |
5 | import "./ILayerZeroUserApplicationConfig.sol";
6 |
7 | interface ILayerZeroMessagingLibrary {
8 | // send(), messages will be inflight.
9 | function send(address _userApplication, uint64 _lastNonce, uint16 _chainId, bytes calldata _destination, bytes calldata _payload, address payable refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;
10 |
11 | // estimate native fee at the send side
12 | function estimateFees(uint16 _chainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);
13 |
14 | //---------------------------------------------------------------------------
15 | // setConfig / getConfig are User Application (UA) functions to specify Oracle, Relayer, blockConfirmations, libraryVersion
16 | function setConfig(uint16 _chainId, address _userApplication, uint _configType, bytes calldata _config) external;
17 |
18 | function getConfig(uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);
19 | }
20 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/state/fee_config.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 |
3 | #[account]
4 | #[derive(Default)]
5 | /// The so fee of cross token
6 | pub struct SoFeeConfig {
7 | /// Program's owner.
8 | pub owner: Pubkey,
9 | /// The recipient of [relayer_fee + so_fee].
10 | pub beneficiary: Pubkey,
11 | /// SoFee by RAY
12 | pub so_fee: u64,
13 | /// Actual relayer fee scale factor
14 | pub actual_reserve: u64,
15 | /// Estimate relayer fee scale factor
16 | pub estimate_reserve: u64,
17 | }
18 |
19 | impl SoFeeConfig {
20 | pub const MAXIMUM_SIZE: usize = 8 // discriminator
21 | + 32 // owner
22 | + 32 // beneficiary
23 | + 8 // so_fee
24 | + 8 // actual_reserve
25 | + 8 // estimate_reserve
26 | ;
27 | /// AKA `b"so_fee"`.
28 | pub const SEED_PREFIX: &'static [u8; 6] = b"so_fee";
29 | }
30 |
31 | #[cfg(test)]
32 | pub mod test {
33 | use super::*;
34 | use std::mem::size_of;
35 |
36 | #[test]
37 | fn test_config() -> Result<()> {
38 | assert_eq!(
39 | SoFeeConfig::MAXIMUM_SIZE,
40 | size_of::() +
41 | size_of::() +
42 | size_of::() +
43 | size_of::() + size_of::() +
44 | size_of::()
45 | );
46 |
47 | Ok(())
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Balancer/IAsset.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0-or-later
2 | // This program is free software: you can redistribute it and/or modify
3 | // it under the terms of the GNU General Public License as published by
4 | // the Free Software Foundation, either version 3 of the License, or
5 | // (at your option) any later version.
6 |
7 | // This program is distributed in the hope that it will be useful,
8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | // GNU General Public License for more details.
11 |
12 | // You should have received a copy of the GNU General Public License
13 | // along with this program. If not, see .
14 |
15 | pragma solidity ^0.8.0;
16 |
17 | /**
18 | * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero
19 | * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like
20 | * types.
21 | *
22 | * This concept is unrelated to a Pool's Asset Managers.
23 | */
24 | interface IAsset {
25 | // solhint-disable-previous-line no-empty-blocks
26 | }
27 |
--------------------------------------------------------------------------------
/ethereum/contracts/Helpers/BoolSwapPathConverter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | abstract contract BoolSwapPathConverter {
5 | event PathPairUpdated(
6 | uint32 indexed consumerChainId,
7 | uint32 indexed boolChainId
8 | );
9 |
10 | mapping(uint32 => uint32) private _fromCToB;
11 | mapping(uint32 => uint32) private _fromBToC;
12 |
13 | function fromConsumerToBool(
14 | uint32 consumerChainId
15 | ) external view returns (uint32 boolChainId) {}
16 |
17 | function fromBoolToConsumer(
18 | uint32 boolChainId
19 | ) external view returns (uint32 consumerChainId) {}
20 |
21 | /** Permission Required Functions (should override this) */
22 | function updatePathPair(
23 | uint32[] calldata consumerChainIds,
24 | uint32[] calldata boolChainIds
25 | ) external virtual {
26 | require(
27 | consumerChainIds.length == boolChainIds.length,
28 | "LENGTH_MISSMATCH"
29 | );
30 | for (uint256 i = 0; i < consumerChainIds.length; i++) {
31 | _fromCToB[consumerChainIds[i]] = boolChainIds[i];
32 | _fromBToC[boolChainIds[i]] = consumerChainIds[i];
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ethereum/scripts/chainx_bridge.py:
--------------------------------------------------------------------------------
1 | import secrets
2 |
3 | from brownie import (
4 | ChainXBridge,
5 | Contract,
6 | config, network
7 | )
8 |
9 | from scripts.helpful_scripts import get_account
10 |
11 |
12 | def load_chainx_bridge():
13 | return Contract.from_abi(
14 | "ChainXBridge",
15 | config["networks"][network.show_active()]["chainx_bridge"]
16 | , ChainXBridge.abi)
17 |
18 |
19 | def main():
20 | chainx_bridge = load_chainx_bridge()
21 | acc = get_account()
22 | amount = int(1 / 1e8 * 1e18)
23 | print("nonce", acc.nonce)
24 | while True:
25 | start = acc.nonce
26 | end = 1000
27 | try:
28 | for _ in range(start, end):
29 | swap_id = f"0x{secrets.token_bytes(32).hex()}"
30 | swap_id = swap_id[:-4] + "cccc"
31 | chainx_bridge.swap_out(
32 | swap_id,
33 | 10,
34 | str(acc.address)[2:],
35 | amount,
36 | 100,
37 | {"from": acc, "value": amount}
38 | )
39 | except Exception as e:
40 | print("Error:", e)
41 | if acc.nonce >= end:
42 | break
43 |
--------------------------------------------------------------------------------
/sui/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "OmniSwap"
3 | version = "0.1.0"
4 |
5 | [addresses]
6 | sui = "0x2"
7 | omniswap = "0x0"
8 | wormhole = "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a"
9 | token_bridge = "0x26efee2b51c911237888e5dc6702868abca3c7ac12c53f76ef8eba0697695e3d"
10 | cetus_clmm = "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb"
11 | omniswap_mock = "0x0"
12 | deepbook = "0xdee9"
13 |
14 | [dependencies.Sui]
15 | git = "https://github.com/MystenLabs/sui.git"
16 | subdir = "crates/sui-framework/packages/sui-framework"
17 | rev = "cc4ad6d8a3f05ad8641e977fad228e09a77453b8"
18 | override = true
19 |
20 | [dependencies.DeepBook]
21 | git = "https://github.com/MystenLabs/sui.git"
22 | subdir = "crates/sui-framework/packages/deepbook"
23 | rev = "cc4ad6d8a3f05ad8641e977fad228e09a77453b8"
24 |
25 | [dependencies.Wormhole]
26 | git = "https://github.com/OmniBTC/wormhole.git"
27 | subdir = "sui/wormhole"
28 | rev = "fcfe551da0f46b704b76b09ae11dca3dd9387837"
29 |
30 | [dependencies.TokenBridge]
31 | git = "https://github.com/OmniBTC/wormhole.git"
32 | subdir = "sui/token_bridge"
33 | rev = "fcfe551da0f46b704b76b09ae11dca3dd9387837"
34 |
35 | [dependencies.CetusClmm]
36 | local = "cetus/cetus-clmm-interface/sui/clmmpool"
37 |
--------------------------------------------------------------------------------
/solana/scripts/custom_simulate.py:
--------------------------------------------------------------------------------
1 | from solana.rpc.async_api import AsyncClient
2 | from solana.transaction import Transaction
3 | from solders.commitment_config import CommitmentLevel
4 | from solders.rpc.config import (
5 | RpcSimulateTransactionConfig,
6 | RpcSimulateTransactionAccountsConfig,
7 | )
8 | from solders.rpc.requests import SimulateVersionedTransaction, SimulateLegacyTransaction
9 | from solders.rpc.responses import SimulateTransactionResp
10 | from solders.transaction import VersionedTransaction
11 |
12 |
13 | def simulate_body(txn, addresses):
14 | config = RpcSimulateTransactionConfig(
15 | sig_verify=True,
16 | commitment=CommitmentLevel.Confirmed,
17 | accounts=RpcSimulateTransactionAccountsConfig(addresses=addresses),
18 | )
19 | if isinstance(txn, Transaction):
20 | if txn.recent_blockhash is None:
21 | raise ValueError("transaction must have a valid blockhash")
22 | return SimulateLegacyTransaction(txn.to_solders(), config)
23 | return SimulateVersionedTransaction(txn, config)
24 |
25 |
26 | async def custom_simulate(client: AsyncClient, txn, addresses):
27 | body = simulate_body(txn, addresses)
28 | return await client._provider.make_request(body, SimulateTransactionResp)
29 |
--------------------------------------------------------------------------------
/ethereum/scripts/data/20240709-bevm-ordinals-runes-15.json:
--------------------------------------------------------------------------------
1 | [
2 | [
3 | "0x5b19bb2977f452e6381274797c18455e0edcba15",
4 | 1
5 | ],
6 | [
7 | "0xa1cba1fe466dfd6266e11ff0cd85145cb31b78c6",
8 | 1
9 | ],
10 | [
11 | "0xE3D651953c39b1442D162d718Fcc319d84b4355B",
12 | 1
13 | ],
14 | [
15 | "0x232b15DA3718840fc41De4f892B0719700C5701d",
16 | 1
17 | ],
18 | [
19 | "0x83AdDB5c1604FA4166F15760b85B701617f6D560",
20 | 1
21 | ],
22 | [
23 | "0xcdde6821bae6c434cde4b468722f8ab6b7e4bc52",
24 | 1
25 | ],
26 | [
27 | "0x2051fd92602573fa3df3f717135b8228e0bdb370",
28 | 1
29 | ],
30 | [
31 | "0xffe585b52885473b0678d97fb81f91042e0d09c1",
32 | 1
33 | ],
34 | [
35 | "0xea61ace0a744480aa605936eb494292b3d9c45dc",
36 | 1
37 | ],
38 | [
39 | "0x6e0e002fba8c06fc895ada43ee14f924f7b0eb97",
40 | 1
41 | ],
42 | [
43 | "0x7c08bdb8413b5ac3d97773c5a5ada76406d31d65",
44 | 1
45 | ],
46 | [
47 | "0x7ac49632ff51254d643dc669c666cf46de618d57",
48 | 1
49 | ],
50 | [
51 | "0x8af0998f361e89a7bfe04d8a5b5e7e02ff1cff43",
52 | 1
53 | ],
54 | [
55 | "0x32989d0385687f779eceff26e73e28ede2603c8c",
56 | 1
57 | ],
58 | [
59 | "0x2cd6fbbc1dd73f6b1151a57e55eb56e2bb521c3c",
60 | 1
61 | ]
62 | ]
--------------------------------------------------------------------------------
/utils/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 | from os import path
3 |
4 | here = path.abspath(path.dirname(__file__))
5 |
6 | setup(
7 | name='aptos-brownie',
8 | version='3.0.6',
9 | description='Aptos Package Tool',
10 | long_description="This is an aptos python tool to quickly implement aptos calls",
11 | # The project's main homepage.
12 | url='https://github.com/OmniBTC/OmniSwap/blob/main/utils',
13 | # Author details
14 | author='DaiWei',
15 | author_email='dw1253464613@gmail.com',
16 | # Choose your license
17 | license='MIT',
18 | classifiers=[
19 | 'Development Status :: 4 - Beta',
20 | 'Intended Audience :: Developers',
21 | 'Topic :: System :: Logging',
22 | 'License :: OSI Approved :: MIT License',
23 | 'Programming Language :: Python :: 3',
24 | 'Programming Language :: Python :: 3.3',
25 | 'Programming Language :: Python :: 3.4',
26 | 'Programming Language :: Python :: 3.5',
27 | 'Programming Language :: Python :: 3.6',
28 | 'Programming Language :: Python :: 3.7',
29 | 'Programming Language :: Python :: 3.8',
30 | ],
31 | python_requires=">=3.6",
32 | py_modules=["aptos_brownie"],
33 | install_requires=['aptos_sdk', "pyyaml", "toml"]
34 | )
35 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Helpers/BoolSwapPathConverter.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | abstract contract BoolSwapPathConverter {
5 | event PathPairUpdated(
6 | uint32 indexed consumerChainId,
7 | uint32 indexed boolChainId
8 | );
9 |
10 | mapping(uint32 => uint32) private _fromCToB;
11 | mapping(uint32 => uint32) private _fromBToC;
12 |
13 | function fromConsumerToBool(uint32 consumerChainId)
14 | external
15 | view
16 | returns (uint32 boolChainId)
17 | {}
18 |
19 | function fromBoolToConsumer(uint32 boolChainId)
20 | external
21 | view
22 | returns (uint32 consumerChainId)
23 | {}
24 |
25 | /** Permission Required Functions (should override this) */
26 | function updatePathPair(
27 | uint32[] calldata consumerChainIds,
28 | uint32[] calldata boolChainIds
29 | ) external virtual {
30 | require(
31 | consumerChainIds.length == boolChainIds.length,
32 | "LENGTH_MISSMATCH"
33 | );
34 | for (uint256 i = 0; i < consumerChainIds.length; i++) {
35 | _fromCToB[consumerChainIds[i]] = boolChainIds[i];
36 | _fromBToC[boolChainIds[i]] = consumerChainIds[i];
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/aptos/sources/math_u256.move:
--------------------------------------------------------------------------------
1 | module integer_mate::math_u256 {
2 | const MAX_U256: u256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
3 |
4 | public fun div_mod(num: u256, denom: u256): (u256, u256) {
5 | let p = num / denom;
6 | let r: u256 = num - (p * denom);
7 | (p, r)
8 | }
9 |
10 | public fun shlw(n: u256): u256 {
11 | n << 64
12 | }
13 |
14 | public fun shrw(n: u256): u256 {
15 | n >> 64
16 | }
17 |
18 | public fun checked_shlw(n: u256): (u256, bool) {
19 | let mask = 0xffffffffffffffff << 192;
20 | if (n > mask) {
21 | (0, true)
22 | } else {
23 | ((n << 64), false)
24 | }
25 | }
26 |
27 | public fun div_round(num: u256, denom: u256, round_up: bool): u256 {
28 | let p = num / denom;
29 | if (round_up && ((p * denom) != num)) {
30 | p + 1
31 | } else {
32 | p
33 | }
34 | }
35 |
36 | public fun add_check(num1: u256, num2: u256): bool {
37 | (MAX_U256 - num1 >= num2)
38 | }
39 |
40 | #[test]
41 | fun test_div_round() {
42 | div_round(1, 1, true);
43 | }
44 |
45 | #[test]
46 | fun test_add() {
47 | 1000u256 + 1000u256;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/sui/sources/math_u256.move:
--------------------------------------------------------------------------------
1 | module integer_mate::math_u256 {
2 | const MAX_U256: u256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
3 |
4 | public fun div_mod(num: u256, denom: u256): (u256, u256) {
5 | let p = num / denom;
6 | let r: u256 = num - (p * denom);
7 | (p, r)
8 | }
9 |
10 | public fun shlw(n: u256): u256 {
11 | n << 64
12 | }
13 |
14 | public fun shrw(n: u256): u256 {
15 | n >> 64
16 | }
17 |
18 | public fun checked_shlw(n: u256): (u256, bool) {
19 | let mask = 0xffffffffffffffff << 192;
20 | if (n > mask) {
21 | (0, true)
22 | } else {
23 | ((n << 64), false)
24 | }
25 | }
26 |
27 | public fun div_round(num: u256, denom: u256, round_up: bool): u256 {
28 | let p = num / denom;
29 | if (round_up && ((p * denom) != num)) {
30 | p + 1
31 | } else {
32 | p
33 | }
34 | }
35 |
36 | public fun add_check(num1: u256, num2: u256): bool {
37 | (MAX_U256 - num1 >= num2)
38 | }
39 |
40 | #[test]
41 | fun test_div_round() {
42 | div_round(1, 1, true);
43 | }
44 |
45 | #[test]
46 | fun test_add() {
47 | 1000u256 + 1000u256;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/set_so_fee.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.instruction import Instruction, AccountMeta
5 | import borsh_construct as borsh
6 | from ..program_id import PROGRAM_ID
7 |
8 |
9 | class SetSoFeeArgs(typing.TypedDict):
10 | so_fee_by_ray: int
11 |
12 |
13 | layout = borsh.CStruct("so_fee_by_ray" / borsh.U64)
14 |
15 |
16 | class SetSoFeeAccounts(typing.TypedDict):
17 | payer: Pubkey
18 | config: Pubkey
19 |
20 |
21 | def set_so_fee(
22 | args: SetSoFeeArgs,
23 | accounts: SetSoFeeAccounts,
24 | program_id: Pubkey = PROGRAM_ID,
25 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
26 | ) -> Instruction:
27 | keys: list[AccountMeta] = [
28 | AccountMeta(pubkey=accounts["payer"], is_signer=True, is_writable=True),
29 | AccountMeta(pubkey=accounts["config"], is_signer=False, is_writable=True),
30 | ]
31 | if remaining_accounts is not None:
32 | keys += remaining_accounts
33 | identifier = b"\xa4\x9e\xd5\xe2X\x05\xc8$"
34 | encoded_args = layout.build(
35 | {
36 | "so_fee_by_ray": args["so_fee_by_ray"],
37 | }
38 | )
39 | data = identifier + encoded_args
40 | return Instruction(program_id, data, keys)
41 |
--------------------------------------------------------------------------------
/ethereum/scripts/data/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hardhat-project",
3 | "scripts": {
4 | "start": "node ./split.js"
5 | },
6 | "devDependencies": {
7 | "@apollo/client": "^3.7.14",
8 | "@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
9 | "@nomicfoundation/hardhat-network-helpers": "^1.0.8",
10 | "@nomicfoundation/hardhat-toolbox": "^2.0.2",
11 | "@nomiclabs/hardhat-etherscan": "^3.1.7",
12 | "@typechain/ethers-v5": "^10.2.1",
13 | "@typechain/hardhat": "^6.1.6",
14 | "@types/chai": "^4.3.5",
15 | "@types/mocha": "^10.0.1",
16 | "chai": "^4.3.7",
17 | "ethers": "^5.7.2",
18 | "graphql": "^16.6.0",
19 | "hardhat": "^2.14.0",
20 | "hardhat-gas-reporter": "^1.0.9",
21 | "react": "^18.2.0",
22 | "solidity-coverage": "^0.8.2",
23 | "ts-node": "^10.9.1",
24 | "typechain": "^8.2.0",
25 | "typescript": "^5.0.4",
26 | "xlsx": "^0.18.5"
27 | },
28 | "dependencies": {
29 | "@nomiclabs/hardhat-ethers": "^2.2.3",
30 | "@openzeppelin/contracts": "^4.9.0",
31 | "@openzeppelin/contracts-upgradeable": "^4.9.0",
32 | "@openzeppelin/hardhat-upgrades": "^1.26.0",
33 | "bignumber.js": "^9.1.1",
34 | "dotenv": "^16.0.3",
35 | "fs": "^0.0.1-security",
36 | "keccak256": "^1.0.6",
37 | "merkletreejs": "^0.3.10",
38 | "openzeppelin-solidity": "^2.3.0",
39 | "unix-timestamp": "^1.0.3"
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/CCTP/IMessageHandler.sol:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, Circle Internet Financial Limited.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | pragma solidity ^0.8.0;
17 |
18 | /**
19 | * @title IMessageHandler
20 | * @notice Handles messages on destination domain forwarded from
21 | * an IReceiver
22 | */
23 | interface IMessageHandler {
24 | /**
25 | * @notice handles an incoming message from a Receiver
26 | * @param sourceDomain the source domain of the message
27 | * @param sender the sender of the message
28 | * @param messageBody The message raw bytes
29 | * @return success bool, true if successful
30 | */
31 | function handleReceiveMessage(
32 | uint32 sourceDomain,
33 | bytes32 sender,
34 | bytes calldata messageBody
35 | ) external returns (bool);
36 | }
37 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/set_redeem_proxy.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.instruction import Instruction, AccountMeta
5 | from anchorpy.borsh_extension import BorshPubkey
6 | import borsh_construct as borsh
7 | from ..program_id import PROGRAM_ID
8 |
9 |
10 | class SetRedeemProxyArgs(typing.TypedDict):
11 | new_proxy: Pubkey
12 |
13 |
14 | layout = borsh.CStruct("new_proxy" / BorshPubkey)
15 |
16 |
17 | class SetRedeemProxyAccounts(typing.TypedDict):
18 | owner: Pubkey
19 | config: Pubkey
20 |
21 |
22 | def set_redeem_proxy(
23 | args: SetRedeemProxyArgs,
24 | accounts: SetRedeemProxyAccounts,
25 | program_id: Pubkey = PROGRAM_ID,
26 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
27 | ) -> Instruction:
28 | keys: list[AccountMeta] = [
29 | AccountMeta(pubkey=accounts["owner"], is_signer=True, is_writable=True),
30 | AccountMeta(pubkey=accounts["config"], is_signer=False, is_writable=True),
31 | ]
32 | if remaining_accounts is not None:
33 | keys += remaining_accounts
34 | identifier = b"\x94\xdc\xcb\x06>\xb2k\x9c"
35 | encoded_args = layout.build(
36 | {
37 | "new_proxy": args["new_proxy"],
38 | }
39 | )
40 | data = identifier + encoded_args
41 | return Instruction(program_id, data, keys)
42 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/CCTP/IMessageHandler.sol:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, Circle Internet Financial Limited.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | pragma solidity ^0.8.0;
17 |
18 | /**
19 | * @title IMessageHandler
20 | * @notice Handles messages on destination domain forwarded from
21 | * an IReceiver
22 | */
23 | interface IMessageHandler {
24 | /**
25 | * @notice handles an incoming message from a Receiver
26 | * @param sourceDomain the source domain of the message
27 | * @param sender the sender of the message
28 | * @param messageBody The message raw bytes
29 | * @return success bool, true if successful
30 | */
31 | function handleReceiveMessage(
32 | uint32 sourceDomain,
33 | bytes32 sender,
34 | bytes calldata messageBody
35 | ) external returns (bool);
36 | }
37 |
--------------------------------------------------------------------------------
/ethereum/contracts/Helpers/GenesisBoxStaking.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.13;
3 |
4 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
5 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
6 |
7 | contract GenesisBoxStaking {
8 | using SafeMath for uint256;
9 |
10 | IERC721 public nftContract;
11 |
12 | mapping(uint256 => uint256) public tokenPoints;
13 |
14 | event NFTReceived(address from, uint256 tokenId, uint256 points);
15 |
16 | constructor(address _nftContract) {
17 | nftContract = IERC721(_nftContract);
18 | }
19 |
20 | function receiveNFT(uint256 tokenId) public {
21 | require(nftContract.ownerOf(tokenId) == msg.sender, "NOT OWNER");
22 |
23 | nftContract.transferFrom(msg.sender, address(this), tokenId);
24 |
25 | uint256 points = calculatePoints(tokenId);
26 |
27 | tokenPoints[tokenId] = points;
28 |
29 | emit NFTReceived(msg.sender, tokenId, points);
30 | }
31 |
32 | function calculatePoints(uint256 tokenId) internal view returns (uint256) {
33 | uint256 random = uint256(keccak256(abi.encodePacked(address(msg.sender), tokenId)));
34 |
35 | uint256 points = random.mod(1001).add(500);
36 |
37 | return points;
38 | }
39 |
40 | function getPoints(uint256 tokenId) public view returns (uint256) {
41 | return tokenPoints[tokenId];
42 | }
43 | }
--------------------------------------------------------------------------------
/sui/test_coins/README.md:
--------------------------------------------------------------------------------
1 | # Test coins
2 |
3 | ## cmd
4 |
5 | ```bash
6 | # deploy on sui testnet
7 | sui client publish --gas-budget 10000
8 | package=0xc7fb1756b094e8d3ae5f766ff5800b89e31bd72a
9 | faucet=0xef48dfe069d691da85e5195559264e96c0817850
10 | USDT="0xc7fb1756b094e8d3ae5f766ff5800b89e31bd72a::coins::USDT"
11 | XBTC="0xc7fb1756b094e8d3ae5f766ff5800b89e31bd72a::coins::XBTC"
12 |
13 | # add faucet admin
14 | sui client call \
15 | --gas-budget 10000 \
16 | --package $package \
17 | --module faucet \
18 | --function add_admin \
19 | --args $faucet \
20 | 0x4d7a8549beb8d9349d76a71fd4f479513622532b
21 |
22 | # claim usdt
23 | sui client call \
24 | --gas-budget 10000 \
25 | --package $package \
26 | --module faucet \
27 | --function claim \
28 | --args $faucet \
29 | --type-args $USDT
30 |
31 | # force claim xbtc with amount
32 | # 10 means 10*ONE_COIN
33 | sui client call \
34 | --gas-budget 10000 \
35 | --package $package \
36 | --module faucet \
37 | --function force_claim \
38 | --args $faucet 10 \
39 | --type-args $XBTC
40 |
41 | # add new coin supply
42 | PCX_CAP=0xfe6db5a5802acb32b566d7b7d1fbdf55a496eb7f
43 | PCX="0x44984b1d38594dc64a380391359b46ae4207d165::pcx::PCX"
44 | sui client call \
45 | --gas-budget 10000 \
46 | --package $package \
47 | --module faucet \
48 | --function add_supply \
49 | --args $faucet \
50 | $PCX_CAP \
51 | --type-args $PCX
52 | ```
53 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/so_swap_close_pending_request.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.system_program import ID as SYS_PROGRAM_ID
5 | from solders.instruction import Instruction, AccountMeta
6 | from ..program_id import PROGRAM_ID
7 |
8 |
9 | class SoSwapClosePendingRequestAccounts(typing.TypedDict):
10 | payer: Pubkey
11 | recipient: Pubkey
12 | config: Pubkey
13 | request: Pubkey
14 |
15 |
16 | def so_swap_close_pending_request(
17 | accounts: SoSwapClosePendingRequestAccounts,
18 | program_id: Pubkey = PROGRAM_ID,
19 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
20 | ) -> Instruction:
21 | keys: list[AccountMeta] = [
22 | AccountMeta(pubkey=accounts["payer"], is_signer=True, is_writable=True),
23 | AccountMeta(pubkey=accounts["recipient"], is_signer=False, is_writable=True),
24 | AccountMeta(pubkey=accounts["config"], is_signer=False, is_writable=False),
25 | AccountMeta(pubkey=accounts["request"], is_signer=False, is_writable=True),
26 | AccountMeta(pubkey=SYS_PROGRAM_ID, is_signer=False, is_writable=False),
27 | ]
28 | if remaining_accounts is not None:
29 | keys += remaining_accounts
30 | identifier = b"\xd9\x91+\x80Z&\xf9p"
31 | encoded_args = b""
32 | data = identifier + encoded_args
33 | return Instruction(program_id, data, keys)
34 |
--------------------------------------------------------------------------------
/ethereum/contracts/Helpers/ReentrancyGuard.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity 0.8.13;
3 |
4 | /// @title Reentrancy Guard
5 | /// @author LI.FI (https://li.fi)
6 | /// @notice Abstract contract to provide protection against reentrancy
7 | abstract contract ReentrancyGuard {
8 | /// Storage ///
9 |
10 | bytes32 private constant NAMESPACE =
11 | hex"a65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b";
12 |
13 | /// Types ///
14 |
15 | struct ReentrancyStorage {
16 | uint256 status;
17 | }
18 |
19 | /// Errors ///
20 |
21 | error ReentrancyError();
22 |
23 | /// Constants ///
24 |
25 | uint256 private constant _NOT_ENTERED = 0;
26 | uint256 private constant _ENTERED = 1;
27 |
28 | /// Modifiers ///
29 |
30 | modifier nonReentrant() {
31 | ReentrancyStorage storage s = reentrancyStorage();
32 | if (s.status == _ENTERED) revert ReentrancyError();
33 | s.status = _ENTERED;
34 | _;
35 | s.status = _NOT_ENTERED;
36 | }
37 |
38 | /// Private Methods ///
39 |
40 | /// @dev fetch local storage
41 | function reentrancyStorage()
42 | private
43 | pure
44 | returns (ReentrancyStorage storage data)
45 | {
46 | bytes32 position = NAMESPACE;
47 | // solhint-disable-next-line no-inline-assembly
48 | assembly {
49 | data.slot := position
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/state/cross_request.rs:
--------------------------------------------------------------------------------
1 | use crate::cross::NormalizedWormholeData;
2 | use anchor_lang::prelude::*;
3 |
4 | #[account]
5 | #[derive(Default)]
6 | pub struct CrossRequest {
7 | /// The SenderConfig address.
8 | pub owner: Pubkey,
9 | /// The requester.
10 | pub payer: Pubkey,
11 | /// The cross data.
12 | pub so_data: Vec,
13 | pub swap_data_src: Vec,
14 | pub wormhole_data: Vec,
15 | pub swap_data_dst: Vec,
16 | }
17 |
18 | impl CrossRequest {
19 | pub const MAXIMUM_SIZE: usize = 1200;
20 | pub const MINIMUM_SIZE: usize = 8 // discriminator
21 | + 32 // owner
22 | + 32 // bump
23 | + 24 // empty vec
24 | + 24 // empty vec
25 | + 24 // empty vec
26 | + 24; // empty vec
27 |
28 | pub const SEED_PREFIX: &'static [u8; 7] = b"request";
29 | pub fn dst_chain_id(&self) -> Result {
30 | let wormhole_data =
31 | NormalizedWormholeData::decode_normalized_wormhole_data(&self.wormhole_data)?;
32 |
33 | Ok(wormhole_data.dst_wormhole_chain_id)
34 | }
35 | }
36 |
37 | #[cfg(test)]
38 | pub mod test {
39 | use super::*;
40 | use std::mem::size_of;
41 |
42 | #[test]
43 | fn test_request() -> Result<()> {
44 | assert_eq!(
45 | CrossRequest::MINIMUM_SIZE,
46 | size_of::() +
47 | size_of::() +
48 | size_of::() +
49 | size_of::>() +
50 | size_of::>() +
51 | size_of::>() +
52 | size_of::>()
53 | );
54 |
55 | Ok(())
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ethereum/interfaces/ILayerZeroUserApplicationConfig.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity >=0.5.0;
4 |
5 | interface ILayerZeroUserApplicationConfig {
6 | // @notice set the configuration of the LayerZero messaging library of the specified version
7 | // @param _version - messaging library version
8 | // @param _chainId - the chainId for the pending config change
9 | // @param _configType - type of configuration. every messaging library has its own convention.
10 | // @param _config - configuration in the bytes. can encode arbitrary content.
11 | function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
12 |
13 | // @notice set the send() LayerZero messaging library version to _version
14 | // @param _version - new messaging library version
15 | function setSendVersion(uint16 _version) external;
16 |
17 | // @notice set the lzReceive() LayerZero messaging library version to _version
18 | // @param _version - new messaging library version
19 | function setReceiveVersion(uint16 _version) external;
20 |
21 | // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
22 | // @param _srcChainId - the chainId of the source chain
23 | // @param _srcAddress - the contract address of the source contract at the source chain
24 | function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
25 | }
26 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Helpers/ReentrancyGuard.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: UNLICENSED
2 | pragma solidity 0.8.13;
3 |
4 | /// @title Reentrancy Guard
5 | /// @author LI.FI (https://li.fi)
6 | /// @notice Abstract contract to provide protection against reentrancy
7 | abstract contract ReentrancyGuard {
8 | /// Storage ///
9 |
10 | bytes32 private constant NAMESPACE =
11 | hex"a65bb2f450488ab0858c00edc14abc5297769bf42adb48cfb77752890e8b697b";
12 |
13 | /// Types ///
14 |
15 | struct ReentrancyStorage {
16 | uint256 status;
17 | }
18 |
19 | /// Errors ///
20 |
21 | error ReentrancyError();
22 |
23 | /// Constants ///
24 |
25 | uint256 private constant _NOT_ENTERED = 0;
26 | uint256 private constant _ENTERED = 1;
27 |
28 | /// Modifiers ///
29 |
30 | modifier nonReentrant() {
31 | ReentrancyStorage storage s = reentrancyStorage();
32 | if (s.status == _ENTERED) revert ReentrancyError();
33 | s.status = _ENTERED;
34 | _;
35 | s.status = _NOT_ENTERED;
36 | }
37 |
38 | /// Private Methods ///
39 |
40 | /// @dev fetch local storage
41 | function reentrancyStorage()
42 | private
43 | pure
44 | returns (ReentrancyStorage storage data)
45 | {
46 | bytes32 position = NAMESPACE;
47 | // solhint-disable-next-line no-inline-assembly
48 | assembly {
49 | data.slot := position
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ethereum/tests/test_gensis_box.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | import brownie
4 | import pytest
5 |
6 | from brownie import GenesisBoxStaking, MockNFT
7 | from scripts.helpful_scripts import get_account, read_json
8 |
9 | file_path = Path(__file__).parent.parent.joinpath("scripts/data")
10 |
11 |
12 | @pytest.fixture
13 | def nft():
14 | account = get_account()
15 | return account.deploy(MockNFT, "GenesisBox", "GBX")
16 |
17 |
18 | @pytest.fixture
19 | def genesis_box_staking(nft):
20 | account = get_account()
21 | return account.deploy(GenesisBoxStaking, nft.address)
22 |
23 |
24 | def test_receive_nft(nft, genesis_box_staking):
25 | account = get_account()
26 |
27 | # Mint an NFT to the account
28 | nft.mint(account, {"from": account})
29 | token_id = 1
30 |
31 | # Approve and transfer the NFT to the staking contract
32 | nft.approve(genesis_box_staking.address, token_id, {"from": account})
33 | genesis_box_staking.receiveNFT(token_id, {"from": account})
34 |
35 | # Check the points assigned
36 | points = genesis_box_staking.getPoints(token_id)
37 | assert 500 <= points <= 1500, "Points should be between 500 and 1500"
38 |
39 | # Ensure the contract now owns the NFT
40 | assert nft.ownerOf(token_id) == genesis_box_staking.address, "Staking contract should own the NFT"
41 |
42 | # Try to claim the points
43 | with brownie.reverts("NOT OWNER"):
44 | genesis_box_staking.receiveNFT(token_id, {"from": account})
45 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/wrap_sol.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::{prelude::*, system_program::Transfer};
2 | use anchor_spl::token::{Mint, SyncNative, Token, TokenAccount};
3 |
4 | use crate::WrapSOLKey;
5 |
6 | #[derive(Accounts)]
7 | pub struct WrapSOL<'info> {
8 | #[account(mut)]
9 | pub payer: Signer<'info>,
10 |
11 | #[account(
12 | mut,
13 | associated_token::mint = wsol_mint,
14 | associated_token::authority = payer,
15 | )]
16 | pub wrap_sol_account: Box>,
17 |
18 | #[account(
19 | constraint = wsol_mint.key() == WrapSOLKey
20 | )]
21 | pub wsol_mint: Account<'info, Mint>,
22 |
23 | /// Token program.
24 | pub token_program: Program<'info, Token>,
25 |
26 | /// System program.
27 | pub system_program: Program<'info, System>,
28 | }
29 |
30 | pub fn handler(ctx: Context, amount_to_be_wrapped: u64) -> Result<()> {
31 | // 1. transfer sol to wrap_sol_account
32 | anchor_lang::system_program::transfer(
33 | CpiContext::new(
34 | ctx.accounts.system_program.to_account_info(),
35 | Transfer {
36 | from: ctx.accounts.payer.to_account_info(),
37 | to: ctx.accounts.wrap_sol_account.to_account_info(),
38 | },
39 | ),
40 | amount_to_be_wrapped,
41 | )?;
42 |
43 | // 2. sync native
44 | anchor_spl::token::sync_native(CpiContext::new(
45 | ctx.accounts.token_program.to_account_info(),
46 | SyncNative { account: ctx.accounts.wrap_sol_account.to_account_info() },
47 | ))
48 | }
49 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/set_wormhole_reserve.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.instruction import Instruction, AccountMeta
5 | import borsh_construct as borsh
6 | from ..program_id import PROGRAM_ID
7 |
8 |
9 | class SetWormholeReserveArgs(typing.TypedDict):
10 | actual_reserve: int
11 | estimate_reserve: int
12 |
13 |
14 | layout = borsh.CStruct("actual_reserve" / borsh.U64, "estimate_reserve" / borsh.U64)
15 |
16 |
17 | class SetWormholeReserveAccounts(typing.TypedDict):
18 | payer: Pubkey
19 | config: Pubkey
20 |
21 |
22 | def set_wormhole_reserve(
23 | args: SetWormholeReserveArgs,
24 | accounts: SetWormholeReserveAccounts,
25 | program_id: Pubkey = PROGRAM_ID,
26 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
27 | ) -> Instruction:
28 | keys: list[AccountMeta] = [
29 | AccountMeta(pubkey=accounts["payer"], is_signer=True, is_writable=True),
30 | AccountMeta(pubkey=accounts["config"], is_signer=False, is_writable=True),
31 | ]
32 | if remaining_accounts is not None:
33 | keys += remaining_accounts
34 | identifier = b"A\xbc\x15\xdc\x15]\xcf\xf5"
35 | encoded_args = layout.build(
36 | {
37 | "actual_reserve": args["actual_reserve"],
38 | "estimate_reserve": args["estimate_reserve"],
39 | }
40 | )
41 | data = identifier + encoded_args
42 | return Instruction(program_id, data, keys)
43 |
--------------------------------------------------------------------------------
/solana/scripts/test_dex/get_or_create_ata.ts:
--------------------------------------------------------------------------------
1 | import {Connection, Keypair, PublicKey} from "@solana/web3.js";
2 | import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token"
3 | import * as fs from 'fs';
4 | import * as path from 'path';
5 |
6 |
7 | // export ANCHOR_PROVIDER_URL=""
8 | const ANCHOR_PROVIDER_URL = process.env.ANCHOR_PROVIDER_URL;
9 | const ANCHOR_WALLET = process.env.ANCHOR_WALLET;
10 |
11 | const connection = new Connection(ANCHOR_PROVIDER_URL);
12 | const defaultPath = path.join(process.env.HOME, '.config/solana/id.json');
13 | const rawKey = JSON.parse(fs.readFileSync(defaultPath, 'utf-8'));
14 | const keypair = Keypair.fromSecretKey(Uint8Array.from(rawKey));
15 | async function main(mint_key: string, user_address: string) {
16 | let local_keypair
17 | if (ANCHOR_WALLET === undefined || ANCHOR_WALLET === "") {
18 | local_keypair = keypair;
19 | } else {
20 | const rawKey = new Uint8Array(JSON.parse(ANCHOR_WALLET));
21 | local_keypair = Keypair.fromSecretKey(Uint8Array.from(rawKey));
22 | }
23 |
24 | const user_pubkey = new PublicKey(user_address);
25 | const mint_pubkey = new PublicKey(mint_key)
26 |
27 | const associatedTokenAccount = await getOrCreateAssociatedTokenAccount(
28 | connection,
29 | local_keypair,
30 | mint_pubkey,
31 | user_pubkey,
32 | false,
33 | "processed"
34 | )
35 |
36 | console.log(associatedTokenAccount.address.toBase58())
37 | }
38 |
39 | main(process.argv[2], process.argv[3]);
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/instructions/mod.rs:
--------------------------------------------------------------------------------
1 | #![allow(ambiguous_glob_reexports)]
2 | pub mod close_pending_request;
3 | pub mod complete_so_swap_native_with_whirlpool;
4 | pub mod complete_so_swap_native_without_swap;
5 | pub mod complete_so_swap_wrapped_with_whirlpool;
6 | pub mod complete_so_swap_wrapped_without_swap;
7 | pub mod estimate_relayer_fee;
8 | pub mod initialize;
9 | pub mod post_request;
10 | pub mod register_foreign_contract;
11 | mod relayer_fee;
12 | pub mod set_price_ratio;
13 | pub mod set_redeem_proxy;
14 | pub mod set_so_fee;
15 | pub mod set_wormhole_reserve;
16 | pub mod so_swap_native_with_whirlpool;
17 | pub mod so_swap_native_without_swap;
18 | pub mod so_swap_wrapped_with_whirlpool;
19 | pub mod so_swap_wrapped_without_swap;
20 | mod swap_whirlpool;
21 | pub mod wrap_sol;
22 |
23 | pub use close_pending_request::*;
24 | pub use complete_so_swap_native_with_whirlpool::*;
25 | pub use complete_so_swap_native_without_swap::*;
26 | pub use complete_so_swap_wrapped_with_whirlpool::*;
27 | pub use complete_so_swap_wrapped_without_swap::*;
28 | pub use estimate_relayer_fee::*;
29 | pub use initialize::*;
30 | pub use post_request::*;
31 | pub use register_foreign_contract::*;
32 | pub use set_price_ratio::*;
33 | pub use set_redeem_proxy::*;
34 | pub use set_so_fee::*;
35 | pub use set_wormhole_reserve::*;
36 | pub use so_swap_native_with_whirlpool::*;
37 | pub use so_swap_native_without_swap::*;
38 | pub use so_swap_wrapped_with_whirlpool::*;
39 | pub use so_swap_wrapped_without_swap::*;
40 | pub use wrap_sol::*;
41 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Quickswap/IQuickSwapCallback.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-2.0-or-later
2 | pragma solidity >=0.5.0;
3 |
4 | /// @title Callback for IAlgebraPoolActions#swap
5 | /// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface
6 | /// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
7 | /// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
8 | interface IQuickSwapCallback {
9 | /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.
10 | /// @dev In the implementation you must pay the pool tokens owed for the swap.
11 | /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.
12 | /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
13 | /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
14 | /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
15 | /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
16 | /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
17 | /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call
18 | function algebraSwapCallback(
19 | int256 amount0Delta,
20 | int256 amount1Delta,
21 | bytes calldata data
22 | ) external;
23 | }
24 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/ISo.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ISo {
6 | /// Structs ///
7 |
8 | struct SoData {
9 | bytes32 transactionId; // unique identification id
10 | address payable receiver; // token receiving account
11 | uint16 sourceChainId; // source chain id
12 | address sendingAssetId; // The starting token address of the source chain
13 | uint16 destinationChainId; // destination chain id
14 | address receivingAssetId; // The final token address of the destination chain
15 | uint256 amount; // User enters amount
16 | }
17 |
18 | struct NormalizedSoData {
19 | bytes transactionId; // unique identification id
20 | bytes receiver; // token receiving account
21 | uint16 sourceChainId; // source chain id
22 | bytes sendingAssetId; // The starting token address of the source chain
23 | uint16 destinationChainId; // destination chain id
24 | bytes receivingAssetId; // The final token address of the destination chain
25 | uint256 amount; // User enters amount
26 | }
27 |
28 | /// Events ///
29 |
30 | event SoTransferStarted(bytes32 indexed transactionId);
31 |
32 | event SoTransferFailed(
33 | bytes32 indexed transactionId,
34 | string revertReason,
35 | bytes otherReason
36 | );
37 |
38 | event SoTransferCompleted(
39 | bytes32 indexed transactionId,
40 | uint256 receiveAmount
41 | );
42 | }
43 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Quickswap/IQuickSwapCallback.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-2.0-or-later
2 | pragma solidity >=0.5.0;
3 |
4 | /// @title Callback for IAlgebraPoolActions#swap
5 | /// @notice Any contract that calls IAlgebraPoolActions#swap must implement this interface
6 | /// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
7 | /// https://github.com/Uniswap/v3-core/tree/main/contracts/interfaces
8 | interface IQuickSwapCallback {
9 | /// @notice Called to `msg.sender` after executing a swap via IAlgebraPool#swap.
10 | /// @dev In the implementation you must pay the pool tokens owed for the swap.
11 | /// The caller of this method must be checked to be a AlgebraPool deployed by the canonical AlgebraFactory.
12 | /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
13 | /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
14 | /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
15 | /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
16 | /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
17 | /// @param data Any data passed through by the caller via the IAlgebraPoolActions#swap call
18 | function algebraSwapCallback(
19 | int256 amount0Delta,
20 | int256 amount1Delta,
21 | bytes calldata data
22 | ) external;
23 | }
24 |
--------------------------------------------------------------------------------
/solana/scripts/test_dex/postvaa.ts:
--------------------------------------------------------------------------------
1 | import { postVaaSolana } from "@certusone/wormhole-sdk";
2 | import { Connection, Keypair } from "@solana/web3.js";
3 | import path from "path";
4 | import fs from "fs";
5 |
6 |
7 | // export ANCHOR_PROVIDER_URL=""
8 | const ANCHOR_PROVIDER_URL = process.env.ANCHOR_PROVIDER_URL;
9 | const ANCHOR_WALLET = process.env.ANCHOR_WALLET;
10 |
11 | const defaultPath = path.join(process.env.HOME, '.config/solana/id.json');
12 | const rawKey = JSON.parse(fs.readFileSync(defaultPath, 'utf-8'));
13 | const keypair = Keypair.fromSecretKey(Uint8Array.from(rawKey));
14 | async function main(
15 | wormhole_program: string,
16 | signed_vaa: string
17 | ) {
18 | let local_keypair
19 | if (ANCHOR_WALLET === undefined || ANCHOR_WALLET === "") {
20 | local_keypair = keypair;
21 | } else {
22 | const rawKey = new Uint8Array(JSON.parse(ANCHOR_WALLET));
23 | local_keypair = Keypair.fromSecretKey(Uint8Array.from(rawKey));
24 | }
25 |
26 | const resp = await postVaaSolana(
27 | new Connection(ANCHOR_PROVIDER_URL, "processed"),
28 | async (transaction) => {
29 | transaction.partialSign(local_keypair);
30 | return transaction;
31 | },
32 | wormhole_program,
33 | local_keypair.publicKey.toString(),
34 | Buffer.from(signed_vaa, "hex")
35 | );
36 |
37 | console.log("LegacyVerifySignatures: ", resp[0].signature)
38 | console.log("LegacyPostVaa:", resp[1].signature)
39 | }
40 |
41 | main(process.argv[2], process.argv[3]);
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/ISo.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.13;
4 |
5 | interface ISo {
6 | /// Structs ///
7 |
8 | struct SoData {
9 | bytes32 transactionId; // unique identification id
10 | address payable receiver; // token receiving account
11 | uint16 sourceChainId; // source chain id
12 | address sendingAssetId; // The starting token address of the source chain
13 | uint16 destinationChainId; // destination chain id
14 | address receivingAssetId; // The final token address of the destination chain
15 | uint256 amount; // User enters amount
16 | }
17 |
18 | struct NormalizedSoData {
19 | bytes transactionId; // unique identification id
20 | bytes receiver; // token receiving account
21 | uint16 sourceChainId; // source chain id
22 | bytes sendingAssetId; // The starting token address of the source chain
23 | uint16 destinationChainId; // destination chain id
24 | bytes receivingAssetId; // The final token address of the destination chain
25 | uint256 amount; // User enters amount
26 | }
27 |
28 | /// Events ///
29 |
30 | event SoTransferStarted(bytes32 indexed transactionId);
31 |
32 | event SoTransferFailed(
33 | bytes32 indexed transactionId,
34 | string revertReason,
35 | bytes otherReason
36 | );
37 |
38 | event SoTransferCompleted(
39 | bytes32 indexed transactionId,
40 | uint256 receiveAmount
41 | );
42 | }
43 |
--------------------------------------------------------------------------------
/sui/cetus/integer-mate/aptos/sources/full_math_u128.move:
--------------------------------------------------------------------------------
1 | module integer_mate::full_math_u128 {
2 | use integer_mate::u256;
3 | use integer_mate::math_u128;
4 |
5 | public fun mul_div_floor(num1: u128, num2: u128, denom: u128): u128 {
6 | let r = full_mul_v2(num1, num2) / (denom as u256);
7 | (r as u128)
8 | }
9 |
10 | public fun mul_div_round(num1: u128, num2: u128, denom: u128): u128 {
11 | let r = (full_mul_v2(num1, num2) + ((denom as u256) >> 1)) / (denom as u256);
12 | (r as u128)
13 | }
14 |
15 | public fun mul_div_ceil(num1: u128, num2: u128, denom: u128): u128 {
16 | let r = (full_mul_v2(num1, num2) + ((denom as u256) - 1)) / (denom as u256);
17 | (r as u128)
18 | }
19 |
20 | public fun mul_shr(num1: u128, num2: u128, shift: u8): u128 {
21 | let product = full_mul_v2(num1, num2) >> shift;
22 | (product as u128)
23 | }
24 |
25 | public fun mul_shl(num1: u128, num2: u128, shift: u8): u128 {
26 | let product = full_mul_v2(num1, num2) << shift;
27 | (product as u128)
28 | }
29 |
30 | public fun full_mul(num1: u128, num2: u128): u256::U256 {
31 | let (lo, hi) = math_u128::full_mul(num1, num2);
32 | u256::new(
33 | math_u128::lo(lo),
34 | math_u128::hi(lo),
35 | math_u128::lo(hi),
36 | math_u128::hi(hi),
37 | )
38 | }
39 |
40 | public fun full_mul_v2(num1: u128, num2: u128): u256 {
41 | (num1 as u256) * (num2 as u256)
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/aptos/sources/so_diamond.move:
--------------------------------------------------------------------------------
1 | module omniswap::so_diamond {
2 |
3 | use omniswap::wormhole_facet;
4 |
5 | /// Cross-swap via wormhole
6 | /// * so_data Track user data across the chain and record the final destination of tokens
7 | /// * swap_data_src Swap data at source chain
8 | /// * wormhole_data Data needed to use the wormhole cross-link bridge
9 | /// * swap_data_dst Swap data at destination chain
10 | ///
11 | /// The parameters passed in are serialized.
12 | public entry fun so_swap_via_wormhole(
13 | account: &signer,
14 | so_data: vector,
15 | swap_data_src: vector,
16 | wormhole_data: vector,
17 | swap_data_dst: vector
18 | ) {
19 | wormhole_facet::so_swap(account, so_data, swap_data_src, wormhole_data, swap_data_dst);
20 | }
21 |
22 | /// To complete a cross-chain transaction, it needs to be called manually by the
23 | /// user or automatically by Relayer for the tokens to be sent to the user.
24 | public entry fun complete_so_swap(vaa: vector) {
25 | wormhole_facet::complete_so_swap(vaa);
26 | }
27 |
28 | /// To complete a cross-chain transaction, it needs to be called manually by the
29 | /// user or automatically by Relayer for the tokens to be sent to the user.
30 | public entry fun complete_so_swap_by_account(account: &signer, vaa: vector) {
31 | wormhole_facet::complete_so_swap_by_account(account, vaa);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/IDiamondLoupe.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | // A loupe is a small magnifying glass used to look at diamonds.
5 | // These functions look at diamonds
6 | interface IDiamondLoupe {
7 | /// These functions are expected to be called frequently
8 | /// by tools.
9 |
10 | struct Facet {
11 | address facetAddress;
12 | bytes4[] functionSelectors;
13 | }
14 |
15 | /// @notice Gets all facet addresses and their four byte function selectors.
16 | /// @return facets_ Facet
17 | function facets() external view returns (Facet[] memory facets_);
18 |
19 | /// @notice Gets all the function selectors supported by a specific facet.
20 | /// @param _facet The facet address.
21 | /// @return facetFunctionSelectors_
22 | function facetFunctionSelectors(
23 | address _facet
24 | ) external view returns (bytes4[] memory facetFunctionSelectors_);
25 |
26 | /// @notice Get all the facet addresses used by a diamond.
27 | /// @return facetAddresses_
28 | function facetAddresses()
29 | external
30 | view
31 | returns (address[] memory facetAddresses_);
32 |
33 | /// @notice Gets the facet that supports the given selector.
34 | /// @dev If facet is not found return address(0).
35 | /// @param _functionSelector The function selector.
36 | /// @return facetAddress_ The facet address.
37 | function facetAddress(
38 | bytes4 _functionSelector
39 | ) external view returns (address facetAddress_);
40 | }
41 |
--------------------------------------------------------------------------------
/sui/test_coins/sources/coins.move:
--------------------------------------------------------------------------------
1 | // Copyright (c) OmniBTC, Inc.
2 | // SPDX-License-Identifier: GPL-3.0
3 | module test_coins::coins {
4 | use std::type_name::{into_string, get};
5 |
6 | use sui::bag::{Self, Bag};
7 | use sui::balance;
8 | use sui::tx_context::TxContext;
9 |
10 | friend test_coins::faucet;
11 |
12 | ////////////////////////////////////
13 | struct USDT has drop {}
14 |
15 | struct XBTC has drop {}
16 |
17 | struct BTC has drop {}
18 |
19 | struct ETH has drop {}
20 |
21 | struct BNB has drop {}
22 |
23 | struct WBTC has drop {}
24 |
25 | struct USDC has drop {}
26 |
27 | struct DAI has drop {}
28 |
29 | struct MATIC has drop {}
30 |
31 | struct APT has drop {}
32 |
33 | ////////////////////////////////////
34 |
35 | public(friend) fun get_coins(ctx: &mut TxContext): Bag {
36 | let coins = bag::new(ctx);
37 |
38 | bag::add(&mut coins, into_string(get()), balance::create_supply(XBTC {}));
39 | bag::add(&mut coins, into_string(get()), balance::create_supply(ETH {}));
40 | bag::add(&mut coins, into_string(get()), balance::create_supply(BNB {}));
41 | bag::add(&mut coins, into_string(get()), balance::create_supply(WBTC {}));
42 | bag::add(&mut coins, into_string(get()), balance::create_supply(DAI {}));
43 | bag::add(&mut coins, into_string(get()), balance::create_supply(MATIC {}));
44 | bag::add(&mut coins, into_string(get()), balance::create_supply(APT {}));
45 |
46 | coins
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ethereum/contracts/Libraries/LibSoFeeCCTPV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
9 |
10 | // Celer
11 | contract LibSoFeeCCTPV1 is ILibSoFee, Ownable {
12 | using SafeMath for uint256;
13 |
14 | //---------------------------------------------------------------------------
15 | // VARIABLES
16 |
17 | uint256 public constant RAY = 1e27;
18 |
19 | uint256 public soFee;
20 |
21 | constructor(uint256 _soFee) {
22 | soFee = _soFee;
23 | }
24 |
25 | function setFee(uint256 _soFee) external onlyOwner {
26 | soFee = _soFee;
27 | }
28 |
29 | function getRestoredAmount(
30 | uint256 _amountIn
31 | ) external view override returns (uint256 r) {
32 | // calculate the amount to be restored
33 | r = _amountIn.mul(RAY).div((RAY - soFee));
34 | return r;
35 | }
36 |
37 | function getFees(
38 | uint256 _amountIn
39 | ) external view override returns (uint256 s) {
40 | // calculate the so fee
41 | s = _amountIn.mul(soFee).div(RAY);
42 | return s;
43 | }
44 |
45 | function getTransferForGas() external view override returns (uint256) {
46 | return 0;
47 | }
48 |
49 | function getVersion() external pure override returns (string memory) {
50 | return "CCTPV1";
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/set_price_ratio.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.sysvar import CLOCK
5 | from solders.instruction import Instruction, AccountMeta
6 | import borsh_construct as borsh
7 | from ..program_id import PROGRAM_ID
8 |
9 |
10 | class SetPriceRatioArgs(typing.TypedDict):
11 | chain: int
12 | new_price_ratio: int
13 |
14 |
15 | layout = borsh.CStruct("chain" / borsh.U16, "new_price_ratio" / borsh.U64)
16 |
17 |
18 | class SetPriceRatioAccounts(typing.TypedDict):
19 | owner: Pubkey
20 | price_manager: Pubkey
21 |
22 |
23 | def set_price_ratio(
24 | args: SetPriceRatioArgs,
25 | accounts: SetPriceRatioAccounts,
26 | program_id: Pubkey = PROGRAM_ID,
27 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
28 | ) -> Instruction:
29 | keys: list[AccountMeta] = [
30 | AccountMeta(pubkey=accounts["owner"], is_signer=True, is_writable=True),
31 | AccountMeta(
32 | pubkey=accounts["price_manager"], is_signer=False, is_writable=True
33 | ),
34 | AccountMeta(pubkey=CLOCK, is_signer=False, is_writable=False),
35 | ]
36 | if remaining_accounts is not None:
37 | keys += remaining_accounts
38 | identifier = b'\x19\n\xe4%\xf5"\xe8\x03'
39 | encoded_args = layout.build(
40 | {
41 | "chain": args["chain"],
42 | "new_price_ratio": args["new_price_ratio"],
43 | }
44 | )
45 | data = identifier + encoded_args
46 | return Instruction(program_id, data, keys)
47 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/IDiamondLoupe.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.13;
3 |
4 | // A loupe is a small magnifying glass used to look at diamonds.
5 | // These functions look at diamonds
6 | interface IDiamondLoupe {
7 | /// These functions are expected to be called frequently
8 | /// by tools.
9 |
10 | struct Facet {
11 | address facetAddress;
12 | bytes4[] functionSelectors;
13 | }
14 |
15 | /// @notice Gets all facet addresses and their four byte function selectors.
16 | /// @return facets_ Facet
17 | function facets() external view returns (Facet[] memory facets_);
18 |
19 | /// @notice Gets all the function selectors supported by a specific facet.
20 | /// @param _facet The facet address.
21 | /// @return facetFunctionSelectors_
22 | function facetFunctionSelectors(address _facet)
23 | external
24 | view
25 | returns (bytes4[] memory facetFunctionSelectors_);
26 |
27 | /// @notice Get all the facet addresses used by a diamond.
28 | /// @return facetAddresses_
29 | function facetAddresses()
30 | external
31 | view
32 | returns (address[] memory facetAddresses_);
33 |
34 | /// @notice Gets the facet that supports the given selector.
35 | /// @dev If facet is not found return address(0).
36 | /// @param _functionSelector The function selector.
37 | /// @return facetAddress_ The facet address.
38 | function facetAddress(bytes4 _functionSelector)
39 | external
40 | view
41 | returns (address facetAddress_);
42 | }
43 |
--------------------------------------------------------------------------------
/ethereum/contracts/Libraries/LibSoFeeMultiChainV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
8 | import {ReentrancyGuard} from "../Helpers/ReentrancyGuard.sol";
9 |
10 | // MultiChain
11 | contract LibSoFeeMultiChainV1 is ILibSoFee, Ownable, ReentrancyGuard {
12 | using SafeMath for uint256;
13 |
14 | //---------------------------------------------------------------------------
15 | // VARIABLES
16 |
17 | uint256 public constant RAY = 1e27;
18 | uint256 public soFee;
19 |
20 | constructor(uint256 _soFee) {
21 | soFee = _soFee;
22 | }
23 |
24 | function setFee(uint256 _soFee) external onlyOwner {
25 | soFee = _soFee;
26 | }
27 |
28 | function getRestoredAmount(
29 | uint256 _amountIn
30 | ) external view override returns (uint256 r) {
31 | // calculate the amount to be restored
32 | r = _amountIn.mul(RAY).div((RAY - soFee));
33 | return r;
34 | }
35 |
36 | function getFees(
37 | uint256 _amountIn
38 | ) external view override returns (uint256 s) {
39 | // calculate the so fee
40 | s = _amountIn.mul(soFee).div(RAY);
41 | return s;
42 | }
43 |
44 | function getTransferForGas() external view returns (uint256) {
45 | return 0;
46 | }
47 |
48 | function getVersion() external pure override returns (string memory) {
49 | return "MultiChainV1";
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/UniswapV2/IUniswapV2Router02.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | import "./IUniswapV2Router01.sol";
4 |
5 | interface IUniswapV2Router02 is IUniswapV2Router01 {
6 | function removeLiquidityETHSupportingFeeOnTransferTokens(
7 | address token,
8 | uint256 liquidity,
9 | uint256 amountTokenMin,
10 | uint256 amountETHMin,
11 | address to,
12 | uint256 deadline
13 | ) external returns (uint256 amountETH);
14 |
15 | function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
16 | address token,
17 | uint256 liquidity,
18 | uint256 amountTokenMin,
19 | uint256 amountETHMin,
20 | address to,
21 | uint256 deadline,
22 | bool approveMax,
23 | uint8 v,
24 | bytes32 r,
25 | bytes32 s
26 | ) external returns (uint256 amountETH);
27 |
28 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
29 | uint256 amountIn,
30 | uint256 amountOutMin,
31 | address[] calldata path,
32 | address to,
33 | uint256 deadline
34 | ) external;
35 |
36 | function swapExactETHForTokensSupportingFeeOnTransferTokens(
37 | uint256 amountOutMin,
38 | address[] calldata path,
39 | address to,
40 | uint256 deadline
41 | ) external payable;
42 |
43 | function swapExactTokensForETHSupportingFeeOnTransferTokens(
44 | uint256 amountIn,
45 | uint256 amountOutMin,
46 | address[] calldata path,
47 | address to,
48 | uint256 deadline
49 | ) external;
50 | }
51 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/UniswapV2/IUniswapV2Router02.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | import "./IUniswapV2Router01.sol";
4 |
5 | interface IUniswapV2Router02 is IUniswapV2Router01 {
6 | function removeLiquidityETHSupportingFeeOnTransferTokens(
7 | address token,
8 | uint256 liquidity,
9 | uint256 amountTokenMin,
10 | uint256 amountETHMin,
11 | address to,
12 | uint256 deadline
13 | ) external returns (uint256 amountETH);
14 |
15 | function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
16 | address token,
17 | uint256 liquidity,
18 | uint256 amountTokenMin,
19 | uint256 amountETHMin,
20 | address to,
21 | uint256 deadline,
22 | bool approveMax,
23 | uint8 v,
24 | bytes32 r,
25 | bytes32 s
26 | ) external returns (uint256 amountETH);
27 |
28 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
29 | uint256 amountIn,
30 | uint256 amountOutMin,
31 | address[] calldata path,
32 | address to,
33 | uint256 deadline
34 | ) external;
35 |
36 | function swapExactETHForTokensSupportingFeeOnTransferTokens(
37 | uint256 amountOutMin,
38 | address[] calldata path,
39 | address to,
40 | uint256 deadline
41 | ) external payable;
42 |
43 | function swapExactTokensForETHSupportingFeeOnTransferTokens(
44 | uint256 amountIn,
45 | uint256 amountOutMin,
46 | address[] calldata path,
47 | address to,
48 | uint256 deadline
49 | ) external;
50 | }
51 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/UniswapV2/IUniswapV2Router02AVAX.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | import "./IUniswapV2Router01AVAX.sol";
4 |
5 | interface IUniswapV2Router02AVAX is IUniswapV2Router01AVAX {
6 | function removeLiquidityAVAXSupportingFeeOnTransferTokens(
7 | address token,
8 | uint256 liquidity,
9 | uint256 amountTokenMin,
10 | uint256 amountAVAXMin,
11 | address to,
12 | uint256 deadline
13 | ) external returns (uint256 amountAVAX);
14 |
15 | function removeLiquidityAVAXWithPermitSupportingFeeOnTransferTokens(
16 | address token,
17 | uint256 liquidity,
18 | uint256 amountTokenMin,
19 | uint256 amountAVAXMin,
20 | address to,
21 | uint256 deadline,
22 | bool approveMax,
23 | uint8 v,
24 | bytes32 r,
25 | bytes32 s
26 | ) external returns (uint256 amountAVAX);
27 |
28 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
29 | uint256 amountIn,
30 | uint256 amountOutMin,
31 | address[] calldata path,
32 | address to,
33 | uint256 deadline
34 | ) external;
35 |
36 | function swapExactAVAXForTokensSupportingFeeOnTransferTokens(
37 | uint256 amountOutMin,
38 | address[] calldata path,
39 | address to,
40 | uint256 deadline
41 | ) external payable;
42 |
43 | function swapExactTokensForAVAXSupportingFeeOnTransferTokens(
44 | uint256 amountIn,
45 | uint256 amountOutMin,
46 | address[] calldata path,
47 | address to,
48 | uint256 deadline
49 | ) external;
50 | }
51 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/UniswapV2/IUniswapV2Router02AVAX.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | import "./IUniswapV2Router01AVAX.sol";
4 |
5 | interface IUniswapV2Router02AVAX is IUniswapV2Router01AVAX {
6 | function removeLiquidityAVAXSupportingFeeOnTransferTokens(
7 | address token,
8 | uint256 liquidity,
9 | uint256 amountTokenMin,
10 | uint256 amountAVAXMin,
11 | address to,
12 | uint256 deadline
13 | ) external returns (uint256 amountAVAX);
14 |
15 | function removeLiquidityAVAXWithPermitSupportingFeeOnTransferTokens(
16 | address token,
17 | uint256 liquidity,
18 | uint256 amountTokenMin,
19 | uint256 amountAVAXMin,
20 | address to,
21 | uint256 deadline,
22 | bool approveMax,
23 | uint8 v,
24 | bytes32 r,
25 | bytes32 s
26 | ) external returns (uint256 amountAVAX);
27 |
28 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
29 | uint256 amountIn,
30 | uint256 amountOutMin,
31 | address[] calldata path,
32 | address to,
33 | uint256 deadline
34 | ) external;
35 |
36 | function swapExactAVAXForTokensSupportingFeeOnTransferTokens(
37 | uint256 amountOutMin,
38 | address[] calldata path,
39 | address to,
40 | uint256 deadline
41 | ) external payable;
42 |
43 | function swapExactTokensForAVAXSupportingFeeOnTransferTokens(
44 | uint256 amountIn,
45 | uint256 amountOutMin,
46 | address[] calldata path,
47 | address to,
48 | uint256 deadline
49 | ) external;
50 | }
51 |
--------------------------------------------------------------------------------
/ethereum/contracts/Libraries/LibSoFeeBoolV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
9 | import {ReentrancyGuard} from "../Helpers/ReentrancyGuard.sol";
10 |
11 | // Stargate
12 | contract LibSoFeeBoolV1 is ILibSoFee, Ownable, ReentrancyGuard {
13 | using SafeMath for uint256;
14 |
15 | //---------------------------------------------------------------------------
16 | // VARIABLES
17 |
18 | uint256 public constant RAY = 1e27;
19 | uint256 public soFee;
20 |
21 | constructor(uint256 _soFee) {
22 | soFee = _soFee;
23 | }
24 |
25 | function setFee(uint256 _soFee) external onlyOwner {
26 | soFee = _soFee;
27 | }
28 |
29 | function getRestoredAmount(
30 | uint256 _amountIn
31 | ) external view override returns (uint256 r) {
32 | // calculate the amount to be restored
33 | r = _amountIn.mul(RAY).div((RAY - soFee));
34 | return r;
35 | }
36 |
37 | function getFees(
38 | uint256 _amountIn
39 | ) external view override returns (uint256 s) {
40 | // calculate the so fee
41 | s = _amountIn.mul(soFee).div(RAY);
42 | return s;
43 | }
44 |
45 | function getTransferForGas() external view override returns (uint256) {
46 | return 0;
47 | }
48 |
49 | function getVersion() external pure override returns (string memory) {
50 | return "BoolV1";
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Libraries/LibSoFeeCCTPV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
9 |
10 | // Celer
11 | contract LibSoFeeCCTPV1 is ILibSoFee, Ownable {
12 | using SafeMath for uint256;
13 |
14 | //---------------------------------------------------------------------------
15 | // VARIABLES
16 |
17 | uint256 public constant RAY = 1e27;
18 |
19 | uint256 public soFee;
20 |
21 | constructor(uint256 _soFee) {
22 | soFee = _soFee;
23 | }
24 |
25 | function setFee(uint256 _soFee) external onlyOwner {
26 | soFee = _soFee;
27 | }
28 |
29 | function getRestoredAmount(uint256 _amountIn)
30 | external
31 | view
32 | override
33 | returns (uint256 r)
34 | {
35 | // calculate the amount to be restored
36 | r = _amountIn.mul(RAY).div((RAY - soFee));
37 | return r;
38 | }
39 |
40 | function getFees(uint256 _amountIn)
41 | external
42 | view
43 | override
44 | returns (uint256 s)
45 | {
46 | // calculate the so fee
47 | s = _amountIn.mul(soFee).div(RAY);
48 | return s;
49 | }
50 |
51 | function getTransferForGas() external view override returns (uint256) {
52 | return 0;
53 | }
54 |
55 | function getVersion() external pure override returns (string memory) {
56 | return "CCTPV1";
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/sui/cetus/cetus-clmm-interface/sui/clmmpool/sources/position.move:
--------------------------------------------------------------------------------
1 | module cetus_clmm::position {
2 | use std::string::String;
3 | use std::type_name::TypeName;
4 |
5 | use sui::object::{UID, ID};
6 |
7 | use integer_mate::i32::I32;
8 |
9 | use move_stl::linked_table;
10 |
11 | struct PositionManager has store {
12 | tick_spacing: u32,
13 | position_index: u64,
14 | positions: linked_table::LinkedTable
15 | }
16 |
17 | /// The Cetus clmmpool's position NFT.
18 | struct Position has key, store {
19 | id: UID,
20 | pool: ID,
21 | index: u64,
22 | coin_type_a: TypeName,
23 | coin_type_b: TypeName,
24 | name: String,
25 | description: String,
26 | url: String,
27 | tick_lower_index: I32,
28 | tick_upper_index: I32,
29 | liquidity: u128,
30 | }
31 |
32 | /// The Cetus clmmpool's position information.
33 | struct PositionInfo has store, drop, copy {
34 | position_id: ID,
35 | liquidity: u128,
36 | tick_lower_index: I32,
37 | tick_upper_index: I32,
38 | fee_growth_inside_a: u128,
39 | fee_growth_inside_b: u128,
40 | fee_owned_a: u64,
41 | fee_owned_b: u64,
42 | points_owned: u128,
43 | points_growth_inside: u128,
44 | rewards: vector,
45 | }
46 |
47 | /// The Position's rewarder
48 | struct PositionReward has drop, copy, store {
49 | growth_inside: u128,
50 | amount_owned: u64,
51 | }
52 |
53 | public fun liquidity(_position_nft: &Position): u128 {
54 | abort 0
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Libraries/LibSoFeeMultiChainV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
8 | import {ReentrancyGuard} from "../Helpers/ReentrancyGuard.sol";
9 |
10 | // MultiChain
11 | contract LibSoFeeMultiChainV1 is ILibSoFee, Ownable, ReentrancyGuard {
12 | using SafeMath for uint256;
13 |
14 | //---------------------------------------------------------------------------
15 | // VARIABLES
16 |
17 | uint256 public constant RAY = 1e27;
18 | uint256 public soFee;
19 |
20 | constructor(uint256 _soFee) {
21 | soFee = _soFee;
22 | }
23 |
24 | function setFee(uint256 _soFee) external onlyOwner {
25 | soFee = _soFee;
26 | }
27 |
28 | function getRestoredAmount(uint256 _amountIn)
29 | external
30 | view
31 | override
32 | returns (uint256 r)
33 | {
34 | // calculate the amount to be restored
35 | r = _amountIn.mul(RAY).div((RAY - soFee));
36 | return r;
37 | }
38 |
39 | function getFees(uint256 _amountIn)
40 | external
41 | view
42 | override
43 | returns (uint256 s)
44 | {
45 | // calculate the so fee
46 | s = _amountIn.mul(soFee).div(RAY);
47 | return s;
48 | }
49 |
50 | function getTransferForGas() external view returns (uint256) {
51 | return 0;
52 | }
53 |
54 | function getVersion() external pure override returns (string memory) {
55 | return "MultiChainV1";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/solana/programs/omniswap/src/state/redeemer_config.rs:
--------------------------------------------------------------------------------
1 | use anchor_lang::prelude::*;
2 | use wormhole_anchor_sdk::token_bridge;
3 |
4 | #[derive(Default, AnchorSerialize, AnchorDeserialize, Copy, Clone, PartialEq, Eq)]
5 | pub struct InboundTokenBridgeAddresses {
6 | // program pdas
7 | pub config: Pubkey,
8 | pub custody_signer: Pubkey,
9 | pub mint_authority: Pubkey,
10 | }
11 |
12 | impl InboundTokenBridgeAddresses {
13 | pub const LEN: usize =
14 | 32 // config
15 | + 32 // custody_signer
16 | + 32 // mint_authority
17 | ;
18 | }
19 |
20 | #[account]
21 | #[derive(Default)]
22 | pub struct RedeemerConfig {
23 | /// Program's owner.
24 | pub owner: Pubkey,
25 | /// PDA bump.
26 | pub bump: u8,
27 | /// Token Bridge program's relevant addresses.
28 | pub token_bridge: InboundTokenBridgeAddresses,
29 | /// Proxy account
30 | pub proxy: Pubkey,
31 | }
32 |
33 | impl RedeemerConfig {
34 | pub const MAXIMUM_SIZE: usize = 8 // discriminator
35 | + 32 // owner
36 | + 1 // bump
37 | + InboundTokenBridgeAddresses::LEN
38 | + 32; // proxy
39 |
40 | /// AKA `b"redeemer"`.
41 | pub const SEED_PREFIX: &'static [u8; 8] = token_bridge::SEED_PREFIX_REDEEMER;
42 | }
43 |
44 | #[cfg(test)]
45 | pub mod test {
46 | use super::*;
47 | use std::mem::size_of;
48 |
49 | #[test]
50 | fn test_config() -> Result<()> {
51 | assert_eq!(InboundTokenBridgeAddresses::LEN, size_of::());
52 | assert_eq!(
53 | RedeemerConfig::MAXIMUM_SIZE,
54 | size_of::() +
55 | size_of::() +
56 | size_of::() + size_of::() +
57 | size_of::()
58 | );
59 |
60 | Ok(())
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OmniSwap
2 |
3 | 
4 |
5 | # Overview
6 |
7 | The original intention of OmniSwap is to achieve the purpose of **Omnichain** interoperability by aggregating the liquidity of various bridges.
8 |
9 | With the help of OmniSwap:
10 | 1. Rapid circulation of user assets in different chains.
11 | 2. Aggregate different bridges such as **Stargate**, **Wormhole**, etc. Users have the best cross-chain experience, covering security, speed and fees.
12 | 3. Aggregate the swap of different chains, users can swap different assets of the two chains with one click, such as **ETH** of **Ethereum** and **BNB** of **BSC**.
13 |
14 | # Supported
15 |
16 | ## Bridge
17 |
18 | - [x] **[Stargate](https://stargate.finance/)**: Based on the [LayerZero](https://layerzero.network/) cross -chain message protocol, a single currency pool cross-chain bridge.
19 | - [x] **[Wormhole](https://wormhole.com/)**: Wormhole is a universal interoperability protocol, xAsset allows tokens to circulate across chains.
20 | - [x] cBridge
21 | - [x] Multichain
22 | - [x] Connext
23 | - [x] CCTP
24 |
25 | ## Chain
26 |
27 | - [x] Ethereum
28 | - [x] Bsc
29 | - [x] Arbitrum
30 | - [x] Optimism
31 | - [x] Polygon
32 | - [x] Avalanche
33 | - [x] Aptos
34 | - [x] Sui
35 | - [x] Zksync
36 | - [x] Polygon-zkevm
37 |
38 | # Acknowledge
39 | Many thanks to [Wormhole](https://wormhole.com/) and [Stargate](https://stargate.finance/) for the secure and reliable lower layer construction. Many thanks, of course, to the authors and contributors of [EIP-2535: Diamonds, Multi-Facet Proxy](https://eips.ethereum.org/EIPS/eip-2535).
40 |
41 | # License
42 | [GPLv3](./LICENSE)
43 |
--------------------------------------------------------------------------------
/ethereum/scripts/publish.py:
--------------------------------------------------------------------------------
1 | # @Time : 2022/7/22 14:41
2 | # @Author : WeiDai
3 | # @FileName: publish.py
4 | import functools
5 | import os
6 |
7 | from brownie import project, network
8 | from sui_brownie.parallelism import ProcessExecutor
9 |
10 | from helpful_scripts import change_network
11 |
12 | root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
13 |
14 |
15 | def worker(net: str = None):
16 | if net is None:
17 | if network.is_connected():
18 | net = network.show_active()
19 | else:
20 | net = "mainnet"
21 |
22 | p = project.load(root_path, name=net)
23 | p.load_config()
24 | change_network(net)
25 | deployed_contract = [
26 | # "LibSoFeeGenericV2",
27 | # "GenericSwapFacet",
28 | "StargateFacet"
29 | # "LibCorrectSwapV1"
30 | # "Claim"
31 | # "CCTPFacet",
32 | # "LibCorrectSwapV1",
33 | # "GenericSwapFacet",
34 | # "SerdeFacet",
35 | # "SoDiamond",
36 | # "DiamondCutFacet",
37 | # "DiamondLoupeFacet",
38 | # "DexManagerFacet",
39 | # "WithdrawFacet",
40 | # "OwnershipFacet",
41 | ]
42 | for c in deployed_contract:
43 | print(f"network:{net} publish source: {c}")
44 | try:
45 | p[c].publish_source(p[c][-1])
46 | except Exception as e:
47 | print("error:", e)
48 |
49 |
50 | def main():
51 | nets = ["avax-main", "base-main", "optimism-main", "arbitrum-main", "bsc-main", "mainnet", "polygon-main"]
52 | pt = ProcessExecutor(executor=len(nets))
53 | pt.run([functools.partial(worker, net) for net in nets])
54 |
55 |
56 | if __name__ == "__main__":
57 | main()
58 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Libraries/LibSoFeeBoolV1.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: BUSL-1.1
2 |
3 | pragma solidity 0.8.13;
4 |
5 | import "@openzeppelin/contracts/access/Ownable.sol";
6 | import "@openzeppelin/contracts/utils/math/SafeMath.sol";
7 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8 | import {ILibSoFee} from "../Interfaces/ILibSoFee.sol";
9 | import {ReentrancyGuard} from "../Helpers/ReentrancyGuard.sol";
10 |
11 | // Stargate
12 | contract LibSoFeeBoolV1 is ILibSoFee, Ownable, ReentrancyGuard {
13 | using SafeMath for uint256;
14 |
15 | //---------------------------------------------------------------------------
16 | // VARIABLES
17 |
18 | uint256 public constant RAY = 1e27;
19 | uint256 public soFee;
20 |
21 | constructor(uint256 _soFee) {
22 | soFee = _soFee;
23 | }
24 |
25 | function setFee(uint256 _soFee) external onlyOwner {
26 | soFee = _soFee;
27 | }
28 |
29 | function getRestoredAmount(uint256 _amountIn)
30 | external
31 | view
32 | override
33 | returns (uint256 r)
34 | {
35 | // calculate the amount to be restored
36 | r = _amountIn.mul(RAY).div((RAY - soFee));
37 | return r;
38 | }
39 |
40 | function getFees(uint256 _amountIn)
41 | external
42 | view
43 | override
44 | returns (uint256 s)
45 | {
46 | // calculate the so fee
47 | s = _amountIn.mul(soFee).div(RAY);
48 | return s;
49 | }
50 |
51 | function getTransferForGas() external view override returns (uint256) {
52 | return 0;
53 | }
54 |
55 | function getVersion() external pure override returns (string memory) {
56 | return "BoolV1";
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ethereum/export/ContractDeployed.json:
--------------------------------------------------------------------------------
1 | {
2 | "bsc-test": {
3 | "DexManagerFacet": "0xD3996303C9d4E1a55f3b8e9C6824839eF8141bd4",
4 | "DiamondCutFacet": "0x8D2c8173f35F49a196D003207AB67235eA0DD2Df",
5 | "DiamondLoupeFacet": "0x748E69591Fe651f7a8564577fB0A8A6DC294C663",
6 | "GenericSwapFacet": "0x6A146B07AaA86925B5aec255C5C914a5Fd940C54",
7 | "LibCorrectSwapV1": "0xfd8553faf9c954E5bed99c07727d73E31D09e971",
8 | "LibSoFeeMultiChainV1": "0x072f4e174d804Dd2c1Dd1916567Eef7adF25226A",
9 | "MultiChainFacet": "0x289e0a9848096f49a333A0a399cDd46b29ff55eb",
10 | "OwnershipFacet": "0xa6c137990B1607E964fac5751671F675f0117781",
11 | "SerdeFacet": "0x3b3a6bE42b8eeF544FB61555D02d44fc3487562F",
12 | "SoDiamond": "0x65430554edE8609aFb6bE7b89d9dC61E8D7F1AAb",
13 | "WithdrawFacet": "0xB1BC748cF66C5DD6613D5Db2De8a42232cd3484d"
14 | },
15 | "polygon-test": {
16 | "DexManagerFacet": "0xb9228839eb3403526d2b41AaE73C95bBf31d7226",
17 | "DiamondCutFacet": "0x51abb19F1ebc7B64040aFd0ef3C789d75C8707e0",
18 | "DiamondLoupeFacet": "0xe922A087CA192ffdaA32eCB6A3ad3320bfFDd83b",
19 | "GenericSwapFacet": "0xe4c19e1ad3aE361d79982c1563fb46a624997d7F",
20 | "LibCorrectSwapV1": "0x343d912715bFf7cD505722BD3Fbdcba766fD1177",
21 | "LibSoFeeMultiChainV1": "0x80cBDD4471c3534B9fe972B984f0eB9a47625402",
22 | "MultiChainFacet": "0x0Ab6A79ded3DBFbDF8fBA8F75adF760A9F9561f7",
23 | "OwnershipFacet": "0x21b782d2357797D78D48813048033F187AAa2F9C",
24 | "SerdeFacet": "0x881568956304d287EDa7cCF73722809E071680D9",
25 | "SoDiamond": "0x974bEA4Fe275b58f006dB50d9Eb06Fc68E972e1e",
26 | "WithdrawFacet": "0x784ea1566D3820DaE6aa220eA8C5a0836297fcD3"
27 | }
28 | }
--------------------------------------------------------------------------------
/solana/scripts/omniswap/instructions/wrap_sol.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 | import typing
3 | from solders.pubkey import Pubkey
4 | from solders.system_program import ID as SYS_PROGRAM_ID
5 | from spl.token.constants import TOKEN_PROGRAM_ID
6 | from solders.instruction import Instruction, AccountMeta
7 | import borsh_construct as borsh
8 | from ..program_id import PROGRAM_ID
9 |
10 |
11 | class WrapSolArgs(typing.TypedDict):
12 | amount_to_be_wrapped: int
13 |
14 |
15 | layout = borsh.CStruct("amount_to_be_wrapped" / borsh.U64)
16 |
17 |
18 | class WrapSolAccounts(typing.TypedDict):
19 | payer: Pubkey
20 | wrap_sol_account: Pubkey
21 | wsol_mint: Pubkey
22 |
23 |
24 | def wrap_sol(
25 | args: WrapSolArgs,
26 | accounts: WrapSolAccounts,
27 | program_id: Pubkey = PROGRAM_ID,
28 | remaining_accounts: typing.Optional[typing.List[AccountMeta]] = None,
29 | ) -> Instruction:
30 | keys: list[AccountMeta] = [
31 | AccountMeta(pubkey=accounts["payer"], is_signer=True, is_writable=True),
32 | AccountMeta(
33 | pubkey=accounts["wrap_sol_account"], is_signer=False, is_writable=True
34 | ),
35 | AccountMeta(pubkey=accounts["wsol_mint"], is_signer=False, is_writable=False),
36 | AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False),
37 | AccountMeta(pubkey=SYS_PROGRAM_ID, is_signer=False, is_writable=False),
38 | ]
39 | if remaining_accounts is not None:
40 | keys += remaining_accounts
41 | identifier = b"/>\x9b\xac\x83\xcd%\xc9"
42 | encoded_args = layout.build(
43 | {
44 | "amount_to_be_wrapped": args["amount_to_be_wrapped"],
45 | }
46 | )
47 | data = identifier + encoded_args
48 | return Instruction(program_id, data, keys)
49 |
--------------------------------------------------------------------------------
/ethereum/contracts/Interfaces/Camelot/ICamelotRouter.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | interface ICamelotRouter {
4 | function getAmountsOut(
5 | uint256 amountIn,
6 | address[] calldata path
7 | ) external view returns (uint256[] memory amounts);
8 |
9 | function removeLiquidityETHSupportingFeeOnTransferTokens(
10 | address token,
11 | uint256 liquidity,
12 | uint256 amountTokenMin,
13 | uint256 amountETHMin,
14 | address to,
15 | uint256 deadline
16 | ) external returns (uint256 amountETH);
17 |
18 | function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
19 | address token,
20 | uint256 liquidity,
21 | uint256 amountTokenMin,
22 | uint256 amountETHMin,
23 | address to,
24 | uint256 deadline,
25 | bool approveMax,
26 | uint8 v,
27 | bytes32 r,
28 | bytes32 s
29 | ) external returns (uint256 amountETH);
30 |
31 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
32 | uint256 amountIn,
33 | uint256 amountOutMin,
34 | address[] calldata path,
35 | address to,
36 | address referrer,
37 | uint256 deadline
38 | ) external;
39 |
40 | function swapExactETHForTokensSupportingFeeOnTransferTokens(
41 | uint256 amountOutMin,
42 | address[] calldata path,
43 | address to,
44 | address referrer,
45 | uint256 deadline
46 | ) external payable;
47 |
48 | function swapExactTokensForETHSupportingFeeOnTransferTokens(
49 | uint256 amountIn,
50 | uint256 amountOutMin,
51 | address[] calldata path,
52 | address to,
53 | address referrer,
54 | uint256 deadline
55 | ) external;
56 | }
57 |
--------------------------------------------------------------------------------
/ethereum/zksync-era/contracts/Interfaces/Camelot/ICamelotRouter.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.6.2;
2 |
3 | interface ICamelotRouter {
4 | function getAmountsOut(uint256 amountIn, address[] calldata path)
5 | external
6 | view
7 | returns (uint256[] memory amounts);
8 |
9 | function removeLiquidityETHSupportingFeeOnTransferTokens(
10 | address token,
11 | uint256 liquidity,
12 | uint256 amountTokenMin,
13 | uint256 amountETHMin,
14 | address to,
15 | uint256 deadline
16 | ) external returns (uint256 amountETH);
17 |
18 | function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
19 | address token,
20 | uint256 liquidity,
21 | uint256 amountTokenMin,
22 | uint256 amountETHMin,
23 | address to,
24 | uint256 deadline,
25 | bool approveMax,
26 | uint8 v,
27 | bytes32 r,
28 | bytes32 s
29 | ) external returns (uint256 amountETH);
30 |
31 | function swapExactTokensForTokensSupportingFeeOnTransferTokens(
32 | uint256 amountIn,
33 | uint256 amountOutMin,
34 | address[] calldata path,
35 | address to,
36 | address referrer,
37 | uint256 deadline
38 | ) external;
39 |
40 | function swapExactETHForTokensSupportingFeeOnTransferTokens(
41 | uint256 amountOutMin,
42 | address[] calldata path,
43 | address to,
44 | address referrer,
45 | uint256 deadline
46 | ) external payable;
47 |
48 | function swapExactTokensForETHSupportingFeeOnTransferTokens(
49 | uint256 amountIn,
50 | uint256 amountOutMin,
51 | address[] calldata path,
52 | address to,
53 | address referrer,
54 | uint256 deadline
55 | ) external;
56 | }
57 |
--------------------------------------------------------------------------------