├── .env.example ├── .gitignore ├── README.md ├── bun.lockb ├── example ├── package.json ├── swap.ts └── tsconfig.json ├── jest.config.mjs ├── package-lock.json ├── package.json ├── packages ├── cetus-aggregator-v2-extended-v1 │ ├── .gitignore │ ├── Move.toml │ └── sources │ │ ├── alphafi.move │ │ ├── bluefin.move │ │ ├── deepbookv3.move │ │ ├── haedalpmm.move │ │ ├── hawal.move │ │ ├── metastable.move │ │ ├── obric.move │ │ ├── scallop.move │ │ ├── steamm.move │ │ └── suilend.move ├── cetus-aggregator-v2-extended-v2 │ ├── .gitignore │ ├── Move.toml │ └── sources │ │ ├── momentum.move │ │ ├── steamm_cpmm.move │ │ ├── steamm_omm.move │ │ └── utils.move ├── cetus-aggregator-v2 │ ├── mainnet │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── afsui.move │ │ │ ├── aftermath.move │ │ │ ├── bluemove.move │ │ │ ├── cetus.move │ │ │ ├── deepbook.move │ │ │ ├── deepbookv3.move │ │ │ ├── flowx_amm.move │ │ │ ├── flowx_clmm.move │ │ │ ├── haedal.move │ │ │ ├── kriya_amm.move │ │ │ ├── kriya_clmm.move │ │ │ ├── turbos.move │ │ │ ├── utils.move │ │ │ └── volo.move │ ├── simple-mainnet │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── bluefin.move │ │ │ ├── cetus.move │ │ │ ├── flowx_clmm.move │ │ │ ├── haedalpmm.move │ │ │ ├── momentum.move │ │ │ ├── obric.move │ │ │ ├── turbos.move │ │ │ └── utils.move │ ├── testnet │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── cetus.move │ │ │ ├── deepbook.move │ │ │ ├── haedal_pmm.move │ │ │ └── utils.move │ └── utils.move ├── externals │ ├── .gitignore │ ├── aftermath │ │ ├── aftermath-amm │ │ │ ├── .gitignore │ │ │ ├── Move.lock │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ ├── deposit.move │ │ │ │ ├── math.move │ │ │ │ ├── pool.move │ │ │ │ ├── pool_factory.move │ │ │ │ ├── pool_registry.move │ │ │ │ ├── protocol_fees.move │ │ │ │ └── swap.move │ │ ├── amm-insurance-fund │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── insurance_fund.move │ │ ├── amm-math │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ ├── geometric_mean_calculations.move │ │ │ │ └── stable_calculations.move │ │ ├── amm-protocol-fee-vault │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── vault.move │ │ ├── amm-referral-vault │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── referral_vault.move │ │ ├── amm-treasury │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── treasury.move │ │ ├── staking-afsui │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── afsui.move │ │ ├── staking-refer │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── referral_vault.move │ │ ├── staking-treasury │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── treasury.move │ │ ├── staking │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── staked_sui_vault.move │ │ └── utility │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ ├── linked-set │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── linked_set.move │ │ │ ├── safe │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── safe.move │ │ │ ├── sui-system-utils │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── sui_system_utils.move │ │ │ └── utilities │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ ├── decimals.move │ │ │ ├── fixed.move │ │ │ ├── i256.move │ │ │ ├── ifixed.move │ │ │ ├── log_exp.move │ │ │ ├── numerical.move │ │ │ ├── pay.move │ │ │ └── vector.move │ ├── alphafi │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── cell.move │ │ │ ├── fees.move │ │ │ ├── liquid_staking.move │ │ │ ├── storage.move │ │ │ └── version.move │ ├── bluefin │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── config.move │ │ │ ├── oracle.move │ │ │ ├── pool.move │ │ │ └── tick.move │ ├── bluemove │ │ ├── .gitignore │ │ ├── Move.toml │ │ ├── sources │ │ │ └── swap.move │ │ └── tests │ │ │ └── bluemove_tests.move │ ├── deepbookv3-old │ │ ├── deepbook │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ ├── balance_manager.move │ │ │ │ ├── book │ │ │ │ ├── book.move │ │ │ │ ├── fill.move │ │ │ │ ├── order.move │ │ │ │ └── order_info.move │ │ │ │ ├── helper │ │ │ │ ├── big_vector.move │ │ │ │ ├── constants.move │ │ │ │ ├── math.move │ │ │ │ └── utils.move │ │ │ │ ├── order_query.move │ │ │ │ ├── pool.move │ │ │ │ ├── registry.move │ │ │ │ ├── state │ │ │ │ ├── account.move │ │ │ │ ├── balances.move │ │ │ │ ├── governance.move │ │ │ │ ├── history.move │ │ │ │ ├── state.move │ │ │ │ └── trade_params.move │ │ │ │ └── vault │ │ │ │ ├── deep_price.move │ │ │ │ └── vault.move │ │ └── token │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ └── deep.move │ ├── deepbookv3 │ │ ├── deepbook │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ ├── balance_manager.move │ │ │ │ ├── book │ │ │ │ ├── book.move │ │ │ │ ├── fill.move │ │ │ │ ├── order.move │ │ │ │ └── order_info.move │ │ │ │ ├── helper │ │ │ │ ├── big_vector.move │ │ │ │ └── constants.move │ │ │ │ ├── order_query.move │ │ │ │ ├── pool.move │ │ │ │ ├── registry.move │ │ │ │ ├── state │ │ │ │ ├── account.move │ │ │ │ ├── balances.move │ │ │ │ ├── governance.move │ │ │ │ ├── history.move │ │ │ │ ├── state.move │ │ │ │ └── trade_params.move │ │ │ │ └── vault │ │ │ │ ├── deep_price.move │ │ │ │ └── vault.move │ │ └── token │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ └── deep.move │ ├── flowx-amm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── factory.move │ │ │ └── treasury.move │ ├── flowx-clmm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── i128.move │ │ │ ├── i32.move │ │ │ ├── i64.move │ │ │ ├── oracle.move │ │ │ ├── pool.move │ │ │ ├── pool_manager.move │ │ │ ├── tick.move │ │ │ ├── tick_math.move │ │ │ └── versioned.move │ ├── haedal-pmm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── oracle_driven_pool.move │ │ │ └── trader.move │ ├── hasui │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── config.move │ │ │ ├── hasui.move │ │ │ ├── staking.move │ │ │ ├── table_queue.move │ │ │ └── vault.move │ ├── hawal │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── config.move │ │ │ ├── hawal.move │ │ │ ├── vault.move │ │ │ └── walstaking.move │ ├── kriya-amm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ └── spot_dex.move │ ├── kriya-clmm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── i128.move │ │ │ ├── i32.move │ │ │ ├── i64.move │ │ │ ├── oracle.move │ │ │ ├── pool.move │ │ │ ├── tick.move │ │ │ ├── trade.move │ │ │ └── version.move │ ├── metastable │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── vault.move │ │ │ └── version.move │ ├── mmt_v3 │ │ ├── Move.toml │ │ └── sources │ │ │ ├── collect.move │ │ │ ├── create_pool.move │ │ │ ├── global_config.move │ │ │ ├── i128.move │ │ │ ├── i32.move │ │ │ ├── i64.move │ │ │ ├── liquidity.move │ │ │ ├── pool.move │ │ │ ├── position.move │ │ │ ├── tick.move │ │ │ ├── trade.move │ │ │ ├── utils │ │ │ ├── bit_math.move │ │ │ ├── comparator.move │ │ │ ├── constants.move │ │ │ ├── liquidity_math.move │ │ │ ├── oracle.move │ │ │ ├── sqrt_price_math.move │ │ │ ├── swap_math.move │ │ │ ├── tick_math.move │ │ │ └── utils.move │ │ │ └── version.move │ ├── obric │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ └── v2.move │ ├── scallop │ │ └── scallop_scoin │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ └── s_coin_converter.move │ ├── steamm-v1 │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── bank.move │ │ │ ├── cpmm.move │ │ │ ├── fees.move │ │ │ ├── pool.move │ │ │ ├── quote.move │ │ │ └── version.move │ ├── steamm │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── bank.move │ │ │ ├── cpmm.move │ │ │ ├── fees.move │ │ │ ├── omm.move │ │ │ ├── pool.move │ │ │ ├── quote.move │ │ │ └── version.move │ ├── suilend │ │ ├── oracles │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ ├── oracle_decimal.move │ │ │ │ ├── oracles.move │ │ │ │ └── version.move │ │ ├── sprungsui │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ │ └── sprungsui.move │ │ └── suilend │ │ │ ├── .gitignore │ │ │ ├── Move.toml │ │ │ └── sources │ │ │ ├── cell.move │ │ │ ├── decimal.move │ │ │ ├── lending_market.move │ │ │ ├── lending_market_registry.move │ │ │ ├── liquidity_mining.move │ │ │ ├── obligation.move │ │ │ ├── rate_limiter.move │ │ │ ├── reserve.move │ │ │ ├── reserve_config.move │ │ │ ├── staker.move │ │ │ ├── suilend.code-workspace │ │ │ └── suilend.move │ ├── turbos-dex │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ ├── i32.move │ │ │ ├── pool.move │ │ │ └── swap_router.move │ ├── vsui │ │ ├── Move.toml │ │ └── sources │ │ │ ├── cert.move │ │ │ ├── native_pool.move │ │ │ ├── unstake_ticket.move │ │ │ └── validator_set.move │ └── walrus │ │ ├── wal │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ └── wal.move │ │ └── walrus │ │ ├── Move.toml │ │ └── sources │ │ ├── staking.move │ │ ├── staking │ │ └── staked_wal.move │ │ └── system.move ├── internals │ ├── deepbookv3-vaults-v2 │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ │ └── global_config.move │ └── deepbookv3-vaults │ │ ├── .gitignore │ │ ├── Move.toml │ │ └── sources │ │ └── global_config.move └── test │ ├── .gitignore │ ├── Move.toml │ └── sources │ └── swap.move ├── src ├── api.ts ├── client.ts ├── const.ts ├── errors.ts ├── index.ts ├── math.ts ├── transaction │ ├── afsui.ts │ ├── aftermath.ts │ ├── alphafi.ts │ ├── bluefin.ts │ ├── bluemove.ts │ ├── cetus.ts │ ├── deepbook_v2.ts │ ├── deepbook_v3.ts │ ├── flowx_v2.ts │ ├── flowx_v3.ts │ ├── haedal.ts │ ├── haedal_pmm.ts │ ├── hawal.ts │ ├── index.ts │ ├── kriya_v2.ts │ ├── kriya_v3.ts │ ├── metastable.ts │ ├── momentum.ts │ ├── obric.ts │ ├── scallop.ts │ ├── steamm_cpmm.ts │ ├── steamm_omm.ts │ ├── steamm_omm_v2.ts │ ├── suilend.ts │ ├── swap.ts │ ├── turbos.ts │ └── volo.ts ├── types │ ├── CoinAssist.ts │ └── sui.ts └── utils │ ├── api.ts │ ├── coin.ts │ ├── contracts.ts │ ├── index.ts │ ├── msafe.ts │ └── transaction.ts ├── tests ├── math.test.ts ├── router.test.ts ├── router │ ├── alphafi.test.ts │ ├── cetus.test.ts │ ├── deepbookv3.test.ts │ ├── hawal.test.ts │ ├── metastable.test.ts │ ├── momentum.test.ts │ ├── obric.test.ts │ ├── scallop.test.ts │ ├── steamm.test.ts │ ├── steamm_cpmm.test.ts │ ├── steamm_omm.test.ts │ ├── steamm_omm_v2.test.ts │ └── volo.test.ts ├── test_data.test.ts └── wallet.test.ts ├── tsconfig.json ├── tsup.config.ts └── version.mjs /.env.example: -------------------------------------------------------------------------------- 1 | SUI_PRC= 2 | SUI_WALLET_SECRET= 3 | SUI_WALLET_MNEMONICS= 4 | CETUS_AGGREGATOR= 5 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CetusProtocol/aggregator/aaa404cebcbd37bd6240512304b56513b51cbe76/bun.lockb -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aggregator-example", 3 | "version": "1.0.0", 4 | "description": "Cetus Aggregator SDK usage example", 5 | "main": "index.js", 6 | "scripts": { 7 | "swap": "ts-node swap.ts" 8 | }, 9 | "dependencies": { 10 | "@cetusprotocol/aggregator-sdk": "^0.7.0", 11 | "@mysten/sui.js": "^0.49.1" 12 | }, 13 | "devDependencies": { 14 | "typescript": "^5.0.0", 15 | "ts-node": "^10.9.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/swap.ts: -------------------------------------------------------------------------------- 1 | import { AggregatorClient } from "@cetusprotocol/aggregator-sdk" 2 | import BN from "bn.js" 3 | 4 | async function main() { 5 | // default to mainnet 6 | const client = new AggregatorClient() 7 | 8 | const from = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI" 9 | const target = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS" 10 | 11 | const routers = await client.findRouters({ 12 | from, 13 | target, 14 | amount: new BN(1000000000), 15 | byAmountIn: true, 16 | }) 17 | 18 | console.log(routers) 19 | } 20 | 21 | main() 22 | -------------------------------------------------------------------------------- /example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "strict": true, 6 | "esModuleInterop": true, 7 | "skipLibCheck": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "outDir": "./dist" 10 | }, 11 | "include": ["examples/**/*"] 12 | } 13 | -------------------------------------------------------------------------------- /jest.config.mjs: -------------------------------------------------------------------------------- 1 | // jest.config.mjs 2 | export default { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | transform: { 6 | '^.+\\.tsx?$': ['ts-jest', { 7 | tsconfig: './tsconfig.json' 8 | }] 9 | }, 10 | moduleNameMapper: { 11 | '^~/(.*)$': '/src/$1' 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cetusprotocol/aggregator-sdk", 3 | "version": "0.11.1", 4 | "sideEffects": false, 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "module": "dist/index.mjs", 8 | "scripts": { 9 | "build": "tsup --format cjs,esm --dts", 10 | "dev": "tsup --watch", 11 | "test": "node -r esm node_modules/.bin/jest", 12 | "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", 13 | "publish:test": "node version.mjs && npm publish --tag experimental" 14 | }, 15 | "devDependencies": { 16 | "@types/bn.js": "^5.1.5", 17 | "@types/bun": "latest", 18 | "bn.js": "^5.2.1", 19 | "decimal.js": "^10.4.3", 20 | "tsup": "^8.0.2" 21 | }, 22 | "peerDependencies": { 23 | "typescript": "^5.0.0" 24 | }, 25 | "dependencies": { 26 | "@babel/core": "^7.24.5", 27 | "@babel/preset-env": "^7.24.5", 28 | "@babel/preset-typescript": "^7.24.1", 29 | "@jest/globals": "^29.7.0", 30 | "@mysten/sui": "^1.6.0", 31 | "@pythnetwork/pyth-sui-js": "^2.1.0", 32 | "@types/jest": "^29.5.12", 33 | "@types/node": "^20.12.12", 34 | "babel-jest": "^29.7.0", 35 | "bip39": "^3.1.0", 36 | "dotenv": "^16.4.5", 37 | "jest": "^29.7.0", 38 | "node-fetch": "^3.3.2", 39 | "ts-jest": "^29.1.3", 40 | "typescript": "^5.4.5" 41 | } 42 | } -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/alphafi.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::alphafi; 3 | 4 | use alphafi_liquid_staking::liquid_staking::LiquidStakingInfo; 5 | use std::type_name::TypeName; 6 | use sui::coin::Coin; 7 | use sui::sui::SUI; 8 | use sui_system::sui_system::SuiSystemState; 9 | 10 | public struct AlphafiSwapEvent has copy, drop, store { 11 | amount_in: u64, 12 | amount_out: u64, 13 | a2b: bool, 14 | by_amount_in: bool, 15 | coin_a: TypeName, 16 | coin_b: TypeName, 17 | } 18 | 19 | // mint st_sui: sui -> st_sui 20 | public fun swap_a2b( 21 | liquid_staking_info: &mut LiquidStakingInfo

, 22 | system_state: &mut SuiSystemState, 23 | sui_coin: Coin, 24 | ctx: &mut TxContext, 25 | ): Coin

{ 26 | abort 0 27 | } 28 | 29 | // redeem st_sui: st_sui -> sui 30 | public fun swap_b2a( 31 | liquid_staking_info: &mut LiquidStakingInfo

, 32 | system_state: &mut SuiSystemState, 33 | st_sui: Coin

, 34 | ctx: &mut TxContext, 35 | ): Coin { 36 | abort 0 37 | } 38 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/bluefin.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::bluefin; 3 | 4 | use bluefin_spot::config::GlobalConfig; 5 | use bluefin_spot::pool::Pool; 6 | use std::type_name::TypeName; 7 | use sui::clock::Clock; 8 | use sui::coin::Coin; 9 | 10 | public struct BluefinSwapEvent has copy, drop, store { 11 | pool: ID, 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | public fun swap_a2b( 21 | global_config: &mut GlobalConfig, 22 | pool: &mut Pool, 23 | coin_a: Coin, 24 | clock: &Clock, 25 | ctx: &mut TxContext, 26 | ): Coin { 27 | abort 0 28 | } 29 | 30 | public fun swap_b2a( 31 | global_config: &mut GlobalConfig, 32 | pool: &mut Pool, 33 | coin_b: Coin, 34 | clock: &Clock, 35 | ctx: &mut TxContext, 36 | ): Coin { 37 | abort 0 38 | } 39 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/deepbookv3.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::deepbookv3; 3 | 4 | use deepbookv3::pool::Pool; 5 | use deepbookv3_vaults::global_config::GlobalConfig; 6 | use deepbookv3_vaults_v2::global_config::GlobalConfig as GlobalConfigV2; 7 | use std::type_name::{Self, TypeName}; 8 | use sui::clock::Clock; 9 | use sui::coin::{Self, Coin}; 10 | use sui::event::emit; 11 | use token::deep::DEEP; 12 | 13 | public struct DeepbookV3SwapEvent has copy, drop, store { 14 | pool: ID, 15 | amount_in: u64, 16 | amount_out: u64, 17 | a2b: bool, 18 | by_amount_in: bool, 19 | coin_a: TypeName, 20 | coin_b: TypeName, 21 | } 22 | 23 | public fun swap_a2b_v2( 24 | config: &mut GlobalConfigV2, 25 | pool: &mut Pool, 26 | coin_a: Coin, 27 | coin_deep: Coin, 28 | clock: &Clock, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | 34 | public fun swap_b2a_v2( 35 | config: &mut GlobalConfigV2, 36 | pool: &mut Pool, 37 | coin_b: Coin, 38 | coin_deep: Coin, 39 | clock: &Clock, 40 | ctx: &mut TxContext, 41 | ): Coin { 42 | abort 0 43 | } 44 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/haedalpmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::haedalpmm; 3 | 4 | use haedal_pmm::oracle_driven_pool::Pool; 5 | use pyth::price_info::PriceInfoObject; 6 | use std::type_name::TypeName; 7 | use sui::clock::Clock; 8 | use sui::coin::Coin; 9 | 10 | public struct HaedalPmmSwapEvent has copy, drop, store { 11 | pool: ID, 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | public fun swap_a2b( 21 | pool: &mut Pool, 22 | base_price_pair_obj: &PriceInfoObject, 23 | quote_price_pair_obj: &PriceInfoObject, 24 | coin_a: Coin, 25 | clock: &Clock, 26 | ctx: &mut TxContext, 27 | ): Coin { 28 | abort 0 29 | } 30 | 31 | public fun swap_b2a( 32 | pool: &mut Pool, 33 | base_price_pair_obj: &PriceInfoObject, 34 | quote_price_pair_obj: &PriceInfoObject, 35 | coin_b: Coin, 36 | clock: &Clock, 37 | ctx: &mut TxContext, 38 | ): Coin { 39 | abort 0 40 | } 41 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/hawal.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::hawal; 3 | 4 | use hawal::hawal::HAWAL; 5 | use hawal::walstaking::Staking; 6 | use std::type_name::TypeName; 7 | use sui::coin::Coin; 8 | use wal::wal::WAL; 9 | use walrus::staking::Staking as WalStaking; 10 | 11 | public struct HawalSwapEvent has copy, drop, store { 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | // mint st_sui: sui -> st_sui 21 | public fun swap_a2b( 22 | wal_staking: &mut WalStaking, 23 | staking: &mut Staking, 24 | wal_coin: Coin, 25 | validator: ID, 26 | ctx: &mut TxContext, 27 | ): Coin { 28 | abort 0 29 | } 30 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/metastable.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::metastable; 3 | 4 | use aftermath_mstable::vault::{Vault, DepositCap, WithdrawCap}; 5 | use aftermath_mstable::version::Version; 6 | use std::type_name::TypeName; 7 | use sui::coin::Coin; 8 | 9 | public struct MetastableSwapEvent has copy, drop, store { 10 | pool: ID, 11 | amount_in: u64, 12 | amount_out: u64, 13 | a2b: bool, 14 | by_amount_in: bool, 15 | coin_a: TypeName, 16 | coin_b: TypeName, 17 | } 18 | 19 | // deposit coin => metacoin 20 | public fun swap_a2b( 21 | vault_info: &mut Vault, 22 | version: &Version, 23 | deposit_cap: DepositCap, 24 | coin_in: Coin, 25 | ctx: &mut TxContext, 26 | ): Coin { 27 | abort 0 28 | } 29 | 30 | // withdraw metacoin => coin 31 | public fun swap_b2a( 32 | vault_info: &mut Vault, 33 | version: &Version, 34 | deposit_cap: WithdrawCap, 35 | coin_in: Coin, 36 | ctx: &mut TxContext, 37 | ): Coin { 38 | abort 0 39 | } 40 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/obric.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::obric; 3 | 4 | use obric::v2::TradingPair; 5 | use pyth::price_info::PriceInfoObject; 6 | use pyth::state::State as PythState; 7 | use std::type_name::TypeName; 8 | use sui::clock::Clock; 9 | use sui::coin::Coin; 10 | 11 | public struct ObricSwapEvent has copy, drop, store { 12 | pool_id: ID, 13 | amount_in: u64, 14 | amount_out: u64, 15 | a2b: bool, 16 | by_amount_in: bool, 17 | coin_a: TypeName, 18 | coin_b: TypeName, 19 | } 20 | 21 | public fun swap_a2b( 22 | pool: &mut TradingPair, 23 | coin_a: Coin, 24 | pyth_state: &PythState, 25 | a_price_info_object: &PriceInfoObject, 26 | b_price_info_object: &PriceInfoObject, 27 | clock: &Clock, 28 | ctx: &mut TxContext, 29 | ): Coin { 30 | abort 0 31 | } 32 | 33 | public fun swap_b2a( 34 | pool: &mut TradingPair, 35 | coin_b: Coin, 36 | pyth_state: &PythState, 37 | a_price_info_object: &PriceInfoObject, 38 | b_price_info_object: &PriceInfoObject, 39 | clock: &Clock, 40 | ctx: &mut TxContext, 41 | ): Coin { 42 | abort 0 43 | } 44 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/scallop.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::scallop; 3 | 4 | use protocol::market::Market; 5 | use protocol::version::Version; 6 | use scallop_scoin::s_coin_converter::SCoinTreasury; 7 | use std::type_name::TypeName; 8 | use sui::clock::Clock; 9 | use sui::coin::Coin; 10 | 11 | public struct ScallopSwapEvent has copy, drop, store { 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | // mint s_coin: coin -> s_coin 21 | public fun swap_a2b( 22 | version: &Version, 23 | market: &mut Market, 24 | treasury: &mut SCoinTreasury, 25 | coin_a: Coin, 26 | clock: &Clock, 27 | ctx: &mut TxContext, 28 | ): Coin { 29 | abort 0 30 | } 31 | 32 | // redeem s_coin: s_coin -> coin 33 | public fun swap_b2a( 34 | version: &Version, 35 | market: &mut Market, 36 | treasury: &mut SCoinTreasury, 37 | coin_b: Coin, 38 | clock: &Clock, 39 | ctx: &mut TxContext, 40 | ): Coin { 41 | abort 0 42 | } 43 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/steamm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::steamm; 3 | 4 | use std::type_name::TypeName; 5 | use steamm::bank::Bank; 6 | use steamm::cpmm::CpQuoter; 7 | use steamm::pool::Pool; 8 | use sui::clock::Clock; 9 | use sui::coin::Coin; 10 | use suilend::lending_market::LendingMarket; 11 | 12 | public struct SteammSwapEvent has copy, drop, store { 13 | amount_in: u64, 14 | amount_out: u64, 15 | a2b: bool, 16 | by_amount_in: bool, 17 | coin_a: TypeName, 18 | coin_b: TypeName, 19 | } 20 | 21 | public fun swap_a2b( 22 | pool: &mut Pool, 23 | bank_a: &mut Bank, 24 | bank_b: &mut Bank, 25 | lending_market: &mut LendingMarket, 26 | coin_a: Coin, 27 | clock: &Clock, 28 | ctx: &mut TxContext, 29 | ): Coin { 30 | abort 0 31 | } 32 | 33 | public fun swap_b2a( 34 | pool: &mut Pool, 35 | bank_a: &mut Bank, 36 | bank_b: &mut Bank, 37 | lending_market: &mut LendingMarket, 38 | coin_b: Coin, 39 | clock: &Clock, 40 | ctx: &mut TxContext, 41 | ): Coin { 42 | abort 0 43 | } 44 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v1/sources/suilend.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v1::suilend; 3 | 4 | use liquid_staking::liquid_staking::{mint, redeem, LiquidStakingInfo}; 5 | use std::type_name::{Self, TypeName}; 6 | use sui::coin::{Self, Coin}; 7 | use sui::event::emit; 8 | use sui::sui::SUI; 9 | use sui_system::sui_system::SuiSystemState; 10 | 11 | public struct SuilendSwapEvent has copy, drop, store { 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | // mint spring_sui: sui -> spring_sui 21 | public fun swap_a2b( 22 | liquid_staking_info: &mut LiquidStakingInfo

, 23 | system_state: &mut SuiSystemState, 24 | sui_coin: Coin, 25 | ctx: &mut TxContext, 26 | ): Coin

{ 27 | abort 0 28 | } 29 | 30 | // redeem spring_sui: spring_sui -> sui 31 | public fun swap_b2a( 32 | liquid_staking_info: &mut LiquidStakingInfo

, 33 | system_state: &mut SuiSystemState, 34 | spring_sui: Coin

, 35 | ctx: &mut TxContext, 36 | ): Coin { 37 | abort 0 38 | } 39 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/Move.toml: -------------------------------------------------------------------------------- 1 | ## Mainnet 2 | [package] 3 | name = "CetusAggregatorV2ExtendV2" 4 | version = "0.1.1" 5 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 6 | published-at = "0x368d13376443a8051b22b42a9125f6a3bc836422bb2d9c4a53984b8d6624c326" 7 | 8 | [dependencies] 9 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override = true } 10 | Steamm = { local = "../externals/steamm", override = true } 11 | suilend = { local = "../externals/suilend/suilend", override = true } 12 | oracles = { local = "../externals/suilend/oracles", override = true } 13 | mmt_v3 = { git = "https://github.com/mmt-finance/mmt-contract-interface.git", subdir = "mmt_v3", rev = "mainnet", override = true } 14 | 15 | [addresses] 16 | cetus_aggregator_v2_extend_v2 = "0x368d13376443a8051b22b42a9125f6a3bc836422bb2d9c4a53984b8d6624c326" 17 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/sources/momentum.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator_v2_extend_v2::momentum; 2 | 3 | use mmt_v3::pool::Pool; 4 | use mmt_v3::version::Version; 5 | use std::type_name::{Self, TypeName}; 6 | use sui::balance; 7 | use sui::clock::Clock; 8 | use sui::coin::{Self, Coin}; 9 | use sui::event::emit; 10 | 11 | public struct MomentumSwapEvent has copy, drop, store { 12 | pool: ID, 13 | amount_in: u64, 14 | amount_out: u64, 15 | a2b: bool, 16 | by_amount_in: bool, 17 | coin_a: TypeName, 18 | coin_b: TypeName, 19 | } 20 | 21 | public fun swap_a2b( 22 | pool: &mut Pool, 23 | coin_a: Coin, 24 | version: &Version, 25 | clock: &Clock, 26 | ctx: &mut TxContext, 27 | ): Coin { 28 | abort 0 29 | } 30 | 31 | public fun swap_b2a( 32 | pool: &mut Pool, 33 | coin_b: Coin, 34 | version: &Version, 35 | clock: &Clock, 36 | ctx: &mut TxContext, 37 | ): Coin { 38 | abort 0 39 | } 40 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/sources/steamm_cpmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v2::steamm_cpmm; 3 | 4 | use std::type_name::{Self, TypeName}; 5 | use steamm::bank::Bank; 6 | use steamm::cpmm::{Self, CpQuoter}; 7 | use steamm::pool::Pool; 8 | use sui::clock::Clock; 9 | use sui::coin::{Self, Coin}; 10 | use sui::event::emit; 11 | use suilend::lending_market::LendingMarket; 12 | 13 | public struct SteammCPMMSwapEvent has copy, drop, store { 14 | pool_id: ID, 15 | amount_in: u64, 16 | amount_out: u64, 17 | a2b: bool, 18 | by_amount_in: bool, 19 | coin_a: TypeName, 20 | coin_b: TypeName, 21 | } 22 | 23 | // cpmm swap 24 | public fun swap_a2b( 25 | pool: &mut Pool, 26 | bank_a: &mut Bank, 27 | bank_b: &mut Bank, 28 | lending_market: &mut LendingMarket, 29 | coin_a: Coin, 30 | clock: &Clock, 31 | ctx: &mut TxContext, 32 | ): Coin { 33 | abort 0 34 | } 35 | 36 | public fun swap_b2a( 37 | pool: &mut Pool, 38 | bank_a: &mut Bank, 39 | bank_b: &mut Bank, 40 | lending_market: &mut LendingMarket, 41 | coin_b: Coin, 42 | clock: &Clock, 43 | ctx: &mut TxContext, 44 | ): Coin { 45 | abort 0 46 | } 47 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/sources/steamm_omm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2_extend_v2::steamm_omm; 3 | 4 | use oracles::oracles::OraclePriceUpdate; 5 | use std::type_name::{Self, TypeName}; 6 | use steamm::bank::Bank; 7 | use steamm::omm::OracleQuoter; 8 | use steamm::pool::Pool; 9 | use sui::clock::Clock; 10 | use sui::coin::{Self, Coin}; 11 | use suilend::lending_market::LendingMarket; 12 | 13 | public struct SteammOMMSwapEvent has copy, drop, store { 14 | pool_id: ID, 15 | amount_in: u64, 16 | amount_out: u64, 17 | a2b: bool, 18 | by_amount_in: bool, 19 | coin_a: TypeName, 20 | coin_b: TypeName, 21 | } 22 | 23 | // omm swap 24 | public fun swap_a2b( 25 | pool: &mut Pool, 26 | bank_a: &mut Bank, 27 | bank_b: &mut Bank, 28 | lending_market: &mut LendingMarket, 29 | oracle_price_update_a: OraclePriceUpdate, 30 | oracle_price_update_b: OraclePriceUpdate, 31 | coin_a: Coin, 32 | clock: &Clock, 33 | ctx: &mut TxContext, 34 | ): Coin { 35 | abort 0 36 | } 37 | 38 | public fun swap_b2a( 39 | pool: &mut Pool, 40 | bank_a: &mut Bank, 41 | bank_b: &mut Bank, 42 | lending_market: &mut LendingMarket, 43 | oracle_price_update_a: OraclePriceUpdate, 44 | oracle_price_update_b: OraclePriceUpdate, 45 | coin_b: Coin, 46 | clock: &Clock, 47 | ctx: &mut TxContext, 48 | ): Coin { 49 | abort 0 50 | } 51 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2-extended-v2/sources/utils.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator_v2_extend_v2::utils; 2 | 3 | use sui::coin::{Self, Coin}; 4 | 5 | const MAX_SQRT_PRICE_X64: u128 = 79226673515401279992447579055; 6 | const MIN_SQRT_PRICE_X64: u128 = 4295048016; 7 | 8 | const ECoinBelowThreshold: u64 = 1; 9 | 10 | public fun max_sqrt_price(): u128 { 11 | MAX_SQRT_PRICE_X64 12 | } 13 | 14 | public fun min_sqrt_price(): u128 { 15 | MIN_SQRT_PRICE_X64 16 | } 17 | 18 | #[allow(lint(self_transfer))] 19 | public fun transfer_or_destroy_coin(coin: Coin, ctx: &TxContext) { 20 | if (coin::value(&coin) > 0) { 21 | transfer::public_transfer(coin, tx_context::sender(ctx)) 22 | } else { 23 | coin::destroy_zero(coin) 24 | } 25 | } 26 | 27 | public fun check_coin_threshold(coin: &Coin, threshold: u64) { 28 | assert!(coin::value(coin) >= threshold, ECoinBelowThreshold); 29 | } 30 | 31 | public fun check_coins_threshold(coins: &vector>, threshold: u64) { 32 | let mut i = 0; 33 | let mut sum = 0; 34 | let length = vector::length(coins); 35 | while (i < length) { 36 | let coin = vector::borrow(coins, i); 37 | sum = sum + coin::value(coin); 38 | i = i + 1; 39 | }; 40 | 41 | assert!(sum >= threshold, ECoinBelowThreshold); 42 | } 43 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/afsui.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::afsui; 3 | 4 | use afsui::staked_sui_vault::StakedSuiVault; 5 | use safe::safe::Safe; 6 | use staking_afsui::afsui::AFSUI; 7 | use staking_refer::referral_vault::ReferralVault; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::coin::{Self, Coin, TreasuryCap}; 10 | use sui::event; 11 | use sui::sui::SUI; 12 | use sui_system::sui_system::SuiSystemState; 13 | 14 | public struct AfsuiSwapEvent has copy, drop, store { 15 | amount_in: u64, 16 | amount_out: u64, 17 | coin_a: TypeName, 18 | coin_b: TypeName, 19 | } 20 | 21 | public fun swap_a2b( 22 | vault: &mut StakedSuiVault, 23 | safe: &mut Safe>, 24 | sui_system: &mut SuiSystemState, 25 | refer: &ReferralVault, 26 | addr: address, 27 | coin_input: Coin, 28 | ctx: &mut TxContext, 29 | ): Coin { 30 | abort 0 31 | } 32 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/aftermath.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::aftermath; 3 | 4 | use aftermath_amm::pool::Pool; 5 | use aftermath_amm::pool_registry::PoolRegistry; 6 | use insurance_fund::insurance_fund::InsuranceFund; 7 | use protocol_fee_vault::vault::ProtocolFeeVault; 8 | use referral_vault::referral_vault::ReferralVault; 9 | use std::type_name::{Self, TypeName}; 10 | use sui::coin::{Self, Coin}; 11 | use sui::event::emit; 12 | use treasury::treasury::Treasury; 13 | 14 | public struct AftermathSwapEvent has copy, drop, store { 15 | pool: ID, 16 | amount_in: u64, 17 | amount_out: u64, 18 | a2b: bool, 19 | by_amount_in: bool, 20 | coin_a: TypeName, 21 | coin_b: TypeName, 22 | } 23 | 24 | public fun swap_a2b( 25 | pool: &mut Pool, 26 | pool_registry: &PoolRegistry, 27 | vault: &ProtocolFeeVault, 28 | treasury: &mut Treasury, 29 | insurance_fund: &mut InsuranceFund, 30 | referral_vault: &ReferralVault, 31 | expect_amount_out: u64, 32 | slippage: u64, 33 | coin_a: Coin, 34 | ctx: &mut TxContext, 35 | ): Coin { 36 | abort 0 37 | } 38 | 39 | public fun swap_b2a( 40 | pool: &mut Pool, 41 | pool_registry: &PoolRegistry, 42 | vault: &ProtocolFeeVault, 43 | treasury: &mut Treasury, 44 | insurance_fund: &mut InsuranceFund, 45 | referral_vault: &ReferralVault, 46 | expect_amount_out: u64, 47 | slippage: u64, 48 | coin_b: Coin, 49 | ctx: &mut TxContext, 50 | ): Coin { 51 | abort 0 52 | } 53 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/bluemove.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::bluemove; 3 | 4 | use bluemove::swap::Dex_Info; 5 | use std::type_name::{Self, TypeName}; 6 | use sui::coin::{Self, Coin}; 7 | 8 | public struct BlueMoveSwapEvent has copy, drop, store { 9 | amount_in: u64, 10 | amount_out: u64, 11 | a2b: bool, 12 | by_amount_in: bool, 13 | coin_a: TypeName, 14 | coin_b: TypeName, 15 | } 16 | 17 | public fun swap_a2b( 18 | dex_info: &mut Dex_Info, 19 | coin_a: Coin, 20 | ctx: &mut TxContext, 21 | ): Coin { 22 | abort 0 23 | } 24 | 25 | public fun swap_b2a( 26 | dex_info: &mut Dex_Info, 27 | coin_b: Coin, 28 | ctx: &mut TxContext, 29 | ): Coin { 30 | abort 0 31 | } 32 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/cetus.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::cetus { 3 | use cetus_aggregator_v2::utils::transfer_or_destroy_coin; 4 | use cetus_clmm::config::GlobalConfig; 5 | use cetus_clmm::partner::Partner; 6 | use cetus_clmm::pool::{Self, Pool, FlashSwapReceipt}; 7 | use cetus_clmm::tick_math; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::balance; 10 | use sui::clock::Clock; 11 | use sui::coin::{Self, Coin}; 12 | use sui::event::emit; 13 | 14 | public struct CetusSwapEvent has copy, drop, store { 15 | pool: ID, 16 | amount_in: u64, 17 | amount_out: u64, 18 | a2b: bool, 19 | by_amount_in: bool, 20 | partner_id: ID, 21 | coin_a: TypeName, 22 | coin_b: TypeName, 23 | } 24 | 25 | public fun swap_a2b( 26 | config: &GlobalConfig, 27 | pool: &mut Pool, 28 | partner: &mut Partner, 29 | coin_a: Coin, 30 | clock: &Clock, 31 | ctx: &mut TxContext, 32 | ): Coin { 33 | abort 0 34 | } 35 | 36 | public fun swap_b2a( 37 | config: &GlobalConfig, 38 | pool: &mut Pool, 39 | partner: &mut Partner, 40 | coin_b: Coin, 41 | clock: &Clock, 42 | ctx: &mut TxContext, 43 | ): Coin { 44 | abort 0 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/flowx_amm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::flowx_amm; 3 | 4 | use flowx_amm::factory::Container; 5 | use std::type_name::{Self, TypeName}; 6 | use sui::coin::{Self, Coin}; 7 | use sui::event::emit; 8 | 9 | public struct FlowxSwapEvent has copy, drop, store { 10 | amount_in: u64, 11 | amount_out: u64, 12 | a2b: bool, 13 | by_amount_in: bool, 14 | coin_a: TypeName, 15 | coin_b: TypeName, 16 | } 17 | 18 | public fun swap_a2b( 19 | container: &mut Container, 20 | coin_a: Coin, 21 | ctx: &mut TxContext, 22 | ): Coin { 23 | abort 0 24 | } 25 | 26 | public fun swap_b2a( 27 | container: &mut Container, 28 | coin_b: Coin, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/flowx_clmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::flowx_clmm; 3 | 4 | use flowx_clmm::pool_manager::PoolRegistry; 5 | use flowx_clmm::versioned::Versioned; 6 | use std::type_name::{Self, TypeName}; 7 | use sui::balance; 8 | use sui::clock::Clock; 9 | use sui::coin::{Self, Coin}; 10 | use sui::event::emit; 11 | 12 | public struct FlowxClmmSwapEvent has copy, drop, store { 13 | pool: ID, 14 | amount_in: u64, 15 | amount_out: u64, 16 | a2b: bool, 17 | by_amount_in: bool, 18 | coin_a: TypeName, 19 | coin_b: TypeName, 20 | } 21 | 22 | public fun swap_a2b( 23 | pool_register: &mut PoolRegistry, 24 | fee: u64, 25 | coin_a: Coin, 26 | versioned: &Versioned, 27 | clock: &Clock, 28 | ctx: &mut TxContext, 29 | ): Coin { 30 | abort 0 31 | } 32 | 33 | public fun swap_b2a( 34 | pool_register: &mut PoolRegistry, 35 | fee: u64, 36 | coin_b: Coin, 37 | versioned: &Versioned, 38 | clock: &Clock, 39 | ctx: &mut TxContext, 40 | ): Coin { 41 | abort 0 42 | } 43 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/haedal.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::haedal; 3 | 4 | use hasui::hasui::HASUI; 5 | use hasui::staking::Staking; 6 | use std::type_name::{Self, TypeName}; 7 | use sui::coin::{Self, Coin}; 8 | use sui::event; 9 | use sui::sui::SUI; 10 | use sui_system::sui_system::SuiSystemState; 11 | 12 | public struct HedalSwapEvent has copy, drop, store { 13 | amount_in: u64, 14 | amount_out: u64, 15 | coin_a: TypeName, 16 | coin_b: TypeName, 17 | } 18 | 19 | // a2b: true -> stake from SUI to HASUI 20 | // a2b: false -> unstake from HASUI to SUI 21 | // now haedak lsd support two direction swap, so we need to add a2b to the event 22 | public struct HaedalSwapEvent has copy, drop, store { 23 | amount_in: u64, 24 | amount_out: u64, 25 | a2b: bool, 26 | coin_a: TypeName, 27 | coin_b: TypeName, 28 | } 29 | 30 | public fun swap_a2b( 31 | pool: &mut Staking, 32 | sui_system: &mut SuiSystemState, 33 | coin_input: Coin, 34 | ctx: &mut TxContext, 35 | ): Coin { 36 | abort 0 37 | } 38 | 39 | public fun swap_b2a( 40 | pool: &mut Staking, 41 | sui_system: &mut SuiSystemState, 42 | coin_input: Coin, 43 | ctx: &mut TxContext, 44 | ): Coin { 45 | abort 0 46 | } 47 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/kriya_amm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::kriya_amm; 3 | 4 | use kriya_amm::spot_dex::Pool; 5 | use std::type_name::{Self, TypeName}; 6 | use sui::coin::{Self, Coin}; 7 | use sui::event::emit; 8 | 9 | public struct KriyaAmmSwapEvent has copy, drop, store { 10 | pool: ID, 11 | amount_in: u64, 12 | amount_out: u64, 13 | a2b: bool, 14 | by_amount_in: bool, 15 | coin_a: TypeName, 16 | coin_b: TypeName, 17 | } 18 | 19 | public fun swap_a2b( 20 | pool: &mut Pool, 21 | coin_a: Coin, 22 | ctx: &mut TxContext, 23 | ): Coin { 24 | abort 0 25 | } 26 | 27 | public fun swap_b2a( 28 | pool: &mut Pool, 29 | coin_b: Coin, 30 | ctx: &mut TxContext, 31 | ): Coin { 32 | abort 0 33 | } 34 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/kriya_clmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::kriya_clmm; 3 | 4 | use kriya_clmm::pool::Pool; 5 | use kriya_clmm::version::Version; 6 | use std::type_name::{Self, TypeName}; 7 | use sui::balance; 8 | use sui::clock::Clock; 9 | use sui::coin::{Self, Coin}; 10 | use sui::event::emit; 11 | 12 | public struct KriyaClmmSwapEvent has copy, drop, store { 13 | pool: ID, 14 | amount_in: u64, 15 | amount_out: u64, 16 | a2b: bool, 17 | by_amount_in: bool, 18 | coin_a: TypeName, 19 | coin_b: TypeName, 20 | } 21 | 22 | public fun swap_a2b( 23 | pool: &mut Pool, 24 | coin_a: Coin, 25 | version: &Version, 26 | clock: &Clock, 27 | ctx: &mut TxContext, 28 | ): Coin { 29 | abort 0 30 | } 31 | 32 | public fun swap_b2a( 33 | pool: &mut Pool, 34 | coin_b: Coin, 35 | version: &Version, 36 | clock: &Clock, 37 | ctx: &mut TxContext, 38 | ): Coin { 39 | abort 0 40 | } 41 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/turbos.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::turbos; 3 | 4 | use std::type_name::{Self, TypeName}; 5 | use sui::clock::{Self, Clock}; 6 | use sui::coin::{Self, Coin}; 7 | use sui::event::emit; 8 | use turbos_dex::pool::{Pool, Versioned}; 9 | 10 | public struct TurbosSwapEvent has copy, drop, store { 11 | pool: ID, 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | fee: TypeName, 19 | } 20 | 21 | public fun swap_a2b( 22 | pool: &mut Pool, 23 | coin_a: Coin, 24 | clock: &Clock, 25 | versioned: &Versioned, 26 | ctx: &mut TxContext, 27 | ): Coin { 28 | abort 0 29 | } 30 | 31 | public fun swap_b2a( 32 | pool: &mut Pool, 33 | coin_b: Coin, 34 | clock: &Clock, 35 | versioned: &Versioned, 36 | ctx: &mut TxContext, 37 | ): Coin { 38 | abort 0 39 | } 40 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/utils.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator_v2::utils; 2 | 3 | use sui::coin::{Self, Coin}; 4 | 5 | const ECoinBelowThreshold: u64 = 1; 6 | 7 | #[allow(lint(self_transfer))] 8 | public fun transfer_or_destroy_coin(coin: Coin, ctx: &TxContext) { 9 | if (coin::value(&coin) > 0) { 10 | transfer::public_transfer(coin, tx_context::sender(ctx)) 11 | } else { 12 | coin::destroy_zero(coin) 13 | } 14 | } 15 | 16 | public fun check_coin_threshold(coin: &Coin, threshold: u64) { 17 | assert!(coin::value(coin) >= threshold, ECoinBelowThreshold); 18 | } 19 | 20 | public fun check_coins_threshold(coins: &vector>, threshold: u64) { 21 | let mut i = 0; 22 | let mut sum = 0; 23 | let length = vector::length(coins); 24 | while (i < length) { 25 | let coin = vector::borrow(coins, i); 26 | sum = sum + coin::value(coin); 27 | i = i + 1; 28 | }; 29 | 30 | assert!(sum >= threshold, ECoinBelowThreshold); 31 | } 32 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/mainnet/sources/volo.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_v2::volo; 3 | 4 | use std::type_name::{Self, TypeName}; 5 | use sui::coin::{Self, Coin}; 6 | use sui::event; 7 | use sui::sui::SUI; 8 | use sui_system::sui_system::SuiSystemState; 9 | use vsui::cert::CERT; 10 | use vsui::native_pool::NativePool; 11 | 12 | public struct VoloSwapEvent has copy, drop, store { 13 | amount_in: u64, 14 | amount_out: u64, 15 | coin_a: TypeName, 16 | coin_b: TypeName, 17 | } 18 | 19 | public fun swap_a2b( 20 | pool: &mut NativePool, 21 | metadata: &mut vsui::cert::Metadata, 22 | sui_system: &mut SuiSystemState, 23 | coin_input: Coin, 24 | ctx: &mut TxContext, 25 | ): Coin { 26 | abort 0 27 | } 28 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "CetusAggregatorSimple" 3 | version = "0.1.1" 4 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 5 | published-at = "0x895265c0ddc1786ebe445c1f039b9fd09be8949972478ccbdb5d9c06d3423bcc" 6 | 7 | [dependencies] 8 | IntegerMate = { git = "https://github.com/CetusProtocol/integer-mate.git", subdir = "sui", rev = "sui-v1.2.0", override = true } 9 | CetusClmm = { git = "https://github.com/CetusProtocol/cetus-clmm-interface.git", subdir = "sui/cetus_clmm", rev = "mainnet-v1.49.0", override = true } 10 | FlowxClmm = { local = "../../externals/flowx-clmm", override = true } 11 | TurbosDex = { local = "../../externals/turbos-dex", override = true } 12 | BluefinSpot = { git = "https://github.com/fireflyprotocol/bluefin-spot-contract-interface.git", subdir = "", rev = "main", override = true } 13 | Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "sui-contract-mainnet", override = true } 14 | haedal_pmm = { local = "../../externals/haedal-pmm", override = true } 15 | mmt_v3 = { local = "../../externals/mmt_v3", override = true } 16 | obric = { local = "../../externals/obric", override = true } 17 | 18 | [addresses] 19 | cetus_aggregator_simple = "0x3239061b389dcc35be021bb13d174da82fafcc87bf3d8e176e6c62619311a90c" 20 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/bluefin.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::bluefin; 3 | 4 | use bluefin_spot::config::GlobalConfig; 5 | use bluefin_spot::pool::Pool; 6 | use std::type_name::TypeName; 7 | use sui::clock::Clock; 8 | use sui::coin::Coin; 9 | 10 | public struct BluefinSwapEvent has copy, drop, store { 11 | pool: ID, 12 | amount_in: u64, 13 | amount_out: u64, 14 | a2b: bool, 15 | by_amount_in: bool, 16 | coin_a: TypeName, 17 | coin_b: TypeName, 18 | } 19 | 20 | public fun swap_a2b( 21 | global_config: &mut GlobalConfig, 22 | pool: &mut Pool, 23 | coin_a: Coin, 24 | clock: &Clock, 25 | ctx: &mut TxContext, 26 | ): Coin { 27 | abort 0 28 | } 29 | 30 | public fun swap_b2a( 31 | global_config: &mut GlobalConfig, 32 | pool: &mut Pool, 33 | coin_b: Coin, 34 | clock: &Clock, 35 | ctx: &mut TxContext, 36 | ): Coin { 37 | abort 0 38 | } 39 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/cetus.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::cetus; 3 | 4 | use cetus_aggregator_simple::utils::transfer_or_destroy_coin; 5 | use cetusclmm::config::GlobalConfig; 6 | use cetusclmm::partner::Partner; 7 | use cetusclmm::pool::{Self, Pool, FlashSwapReceipt}; 8 | use cetusclmm::tick_math; 9 | use std::type_name::{Self, TypeName}; 10 | use sui::balance; 11 | use sui::clock::Clock; 12 | use sui::coin::{Self, Coin}; 13 | use sui::event::emit; 14 | 15 | public struct CetusSwapEvent has copy, drop, store { 16 | pool: ID, 17 | amount_in: u64, 18 | amount_out: u64, 19 | a2b: bool, 20 | by_amount_in: bool, 21 | partner_id: ID, 22 | coin_a: TypeName, 23 | coin_b: TypeName, 24 | } 25 | 26 | public fun swap_a2b( 27 | config: &GlobalConfig, 28 | pool: &mut Pool, 29 | partner: &mut Partner, 30 | coin_a: Coin, 31 | clock: &Clock, 32 | ctx: &mut TxContext, 33 | ): Coin { 34 | abort 0 35 | } 36 | 37 | public fun swap_b2a( 38 | config: &GlobalConfig, 39 | pool: &mut Pool, 40 | partner: &mut Partner, 41 | coin_b: Coin, 42 | clock: &Clock, 43 | ctx: &mut TxContext, 44 | ): Coin { 45 | abort 0 46 | } 47 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/flowx_clmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::flowx_clmm; 3 | 4 | use flowx_clmm::pool::{swap, pay}; 5 | use flowx_clmm::pool_manager::{PoolRegistry, borrow_mut_pool}; 6 | use flowx_clmm::tick_math; 7 | use flowx_clmm::versioned::Versioned; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::balance; 10 | use sui::clock::Clock; 11 | use sui::coin::{Self, Coin}; 12 | use sui::event::emit; 13 | 14 | public struct FlowxClmmSwapEvent has copy, drop, store { 15 | pool: ID, 16 | amount_in: u64, 17 | amount_out: u64, 18 | a2b: bool, 19 | by_amount_in: bool, 20 | coin_a: TypeName, 21 | coin_b: TypeName, 22 | } 23 | 24 | public fun swap_a2b( 25 | pool_register: &mut PoolRegistry, 26 | fee: u64, 27 | coin_a: Coin, 28 | versioned: &Versioned, 29 | clock: &Clock, 30 | ctx: &mut TxContext, 31 | ): Coin { 32 | abort 0 33 | } 34 | 35 | public fun swap_b2a( 36 | pool_register: &mut PoolRegistry, 37 | fee: u64, 38 | coin_b: Coin, 39 | versioned: &Versioned, 40 | clock: &Clock, 41 | ctx: &mut TxContext, 42 | ): Coin { 43 | abort 0 44 | } 45 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/haedalpmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::haedalpmm; 3 | 4 | use cetus_aggregator_simple::utils; 5 | use haedal_pmm::oracle_driven_pool::Pool; 6 | use haedal_pmm::trader::{sell_base_coin, sell_quote_coin}; 7 | use pyth::price_info::PriceInfoObject; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::clock::Clock; 10 | use sui::coin::{Self, Coin}; 11 | use sui::event::emit; 12 | 13 | public struct HaedalPmmSwapEvent has copy, drop, store { 14 | pool: ID, 15 | amount_in: u64, 16 | amount_out: u64, 17 | a2b: bool, 18 | by_amount_in: bool, 19 | coin_a: TypeName, 20 | coin_b: TypeName, 21 | } 22 | 23 | public fun swap_a2b( 24 | pool: &mut Pool, 25 | base_price_pair_obj: &PriceInfoObject, 26 | quote_price_pair_obj: &PriceInfoObject, 27 | coin_a: Coin, 28 | clock: &Clock, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | 34 | public fun swap_b2a( 35 | pool: &mut Pool, 36 | base_price_pair_obj: &PriceInfoObject, 37 | quote_price_pair_obj: &PriceInfoObject, 38 | coin_b: Coin, 39 | clock: &Clock, 40 | ctx: &mut TxContext, 41 | ): Coin { 42 | abort 0 43 | } 44 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/momentum.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::momentum; 3 | 4 | use mmt_v3::pool::Pool; 5 | use mmt_v3::tick_math; 6 | use mmt_v3::trade::{flash_swap, repay_flash_swap}; 7 | use mmt_v3::version::Version; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::balance; 10 | use sui::clock::Clock; 11 | use sui::coin::{Self, Coin}; 12 | use sui::event::emit; 13 | 14 | public struct MomentumSwapEvent has copy, drop, store { 15 | pool: ID, 16 | amount_in: u64, 17 | amount_out: u64, 18 | a2b: bool, 19 | by_amount_in: bool, 20 | coin_a: TypeName, 21 | coin_b: TypeName, 22 | } 23 | 24 | public fun swap_a2b( 25 | pool: &mut Pool, 26 | coin_a: Coin, 27 | version: &Version, 28 | clock: &Clock, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | 34 | public fun swap_b2a( 35 | pool: &mut Pool, 36 | coin_b: Coin, 37 | version: &Version, 38 | clock: &Clock, 39 | ctx: &mut TxContext, 40 | ): Coin { 41 | abort 0 42 | } 43 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/obric.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::obric; 3 | 4 | use obric::v2::{TradingPair, swap_x_to_y, swap_y_to_x}; 5 | use pyth::price_info::PriceInfoObject; 6 | use pyth::state::State as PythState; 7 | use std::type_name::{Self, TypeName}; 8 | use sui::clock::Clock; 9 | use sui::coin::{Self, Coin}; 10 | use sui::event::emit; 11 | 12 | public struct ObricSwapEvent has copy, drop, store { 13 | pool_id: ID, 14 | amount_in: u64, 15 | amount_out: u64, 16 | a2b: bool, 17 | by_amount_in: bool, 18 | coin_a: TypeName, 19 | coin_b: TypeName, 20 | } 21 | 22 | public fun swap_a2b( 23 | pool: &mut TradingPair, 24 | coin_a: Coin, 25 | pyth_state: &PythState, 26 | a_price_info_object: &PriceInfoObject, 27 | b_price_info_object: &PriceInfoObject, 28 | clock: &Clock, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | 34 | public fun swap_b2a( 35 | pool: &mut TradingPair, 36 | coin_b: Coin, 37 | pyth_state: &PythState, 38 | a_price_info_object: &PriceInfoObject, 39 | b_price_info_object: &PriceInfoObject, 40 | clock: &Clock, 41 | ctx: &mut TxContext, 42 | ): Coin { 43 | abort 0 44 | } 45 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/turbos.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_use, unused_field, unused_variable)] 2 | module cetus_aggregator_simple::turbos; 3 | 4 | use cetus_aggregator_simple::utils::transfer_or_destroy_coin; 5 | use cetusclmm::tick_math; 6 | use std::type_name::{Self, TypeName}; 7 | use sui::clock::{Self, Clock}; 8 | use sui::coin::{Self, Coin}; 9 | use sui::event::emit; 10 | use turbos_dex::pool::{Pool, Versioned}; 11 | use turbos_dex::swap_router::{swap_a_b_with_return_, swap_b_a_with_return_}; 12 | 13 | public struct TurbosSwapEvent has copy, drop, store { 14 | pool: ID, 15 | amount_in: u64, 16 | amount_out: u64, 17 | a2b: bool, 18 | by_amount_in: bool, 19 | coin_a: TypeName, 20 | coin_b: TypeName, 21 | fee: TypeName, 22 | } 23 | 24 | public fun swap_a2b( 25 | pool: &mut Pool, 26 | coin_a: Coin, 27 | clock: &Clock, 28 | versioned: &Versioned, 29 | ctx: &mut TxContext, 30 | ): Coin { 31 | abort 0 32 | } 33 | 34 | public fun swap_b2a( 35 | pool: &mut Pool, 36 | coin_b: Coin, 37 | clock: &Clock, 38 | versioned: &Versioned, 39 | ctx: &mut TxContext, 40 | ): Coin { 41 | abort 0 42 | } 43 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/simple-mainnet/sources/utils.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator_simple::utils; 2 | 3 | use sui::coin::{Self, Coin}; 4 | 5 | const ECoinBelowThreshold: u64 = 1; 6 | 7 | #[allow(lint(self_transfer))] 8 | public fun transfer_or_destroy_coin(coin: Coin, ctx: &TxContext) { 9 | if (coin::value(&coin) > 0) { 10 | transfer::public_transfer(coin, tx_context::sender(ctx)) 11 | } else { 12 | coin::destroy_zero(coin) 13 | } 14 | } 15 | 16 | public fun check_coin_threshold(coin: &Coin, threshold: u64) { 17 | assert!(coin::value(coin) >= threshold, ECoinBelowThreshold); 18 | } 19 | 20 | public fun check_coins_threshold(coins: &vector>, threshold: u64) { 21 | let mut i = 0; 22 | let mut sum = 0; 23 | let length = vector::length(coins); 24 | while (i < length) { 25 | let coin = vector::borrow(coins, i); 26 | sum = sum + coin::value(coin); 27 | i = i + 1; 28 | }; 29 | 30 | assert!(sum >= threshold, ECoinBelowThreshold); 31 | } 32 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/testnet/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/testnet/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "CetusAggregatorV2" 3 | edition = "2024.beta" 4 | version = "0.1.1" 5 | published-at = "0x0" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet", override = true } 9 | MoveSTL = { git = "https://github.com/CetusProtocol/move-stl.git", subdir = "sui", rev = "testnet-v1.23.1", override = true } 10 | IntegerMate = { git = "https://github.com/CetusProtocol/integer-mate.git", subdir = "sui", rev = "testnet-v1.23.1", override = true } 11 | DeepBook= { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/deepbook", rev = "framework/testnet", override = true } 12 | CetusClmm = { git = "https://github.com/CetusProtocol/cetus-clmm-interface.git", subdir = "sui/cetus_clmm", rev = "testnet-v1.35.1", override = true } 13 | haedal_pmm = { local = "../../externals/haedal-pmm", override = true } 14 | Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "sui-contract-testnet", override = true } 15 | 16 | [addresses] 17 | cetus_aggregator_v2 = "0x0" 18 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/testnet/sources/utils.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator::utils; 2 | 3 | use sui::coin::{Self, Coin}; 4 | 5 | const ECoinBelowThreshold: u64 = 1; 6 | 7 | #[allow(lint(self_transfer))] 8 | public fun transfer_or_destroy_coin(coin: Coin, ctx: &TxContext) { 9 | if (coin::value(&coin) > 0) { 10 | transfer::public_transfer(coin, tx_context::sender(ctx)) 11 | } else { 12 | coin::destroy_zero(coin) 13 | } 14 | } 15 | 16 | public fun check_coin_threshold(coin: &Coin, threshold: u64) { 17 | assert!(coin::value(coin) >= threshold, ECoinBelowThreshold); 18 | } 19 | 20 | public fun check_coins_threshold(coins: &vector>, threshold: u64) { 21 | let mut i = 0; 22 | let mut sum = 0; 23 | let length = vector::length(coins); 24 | while (i < length) { 25 | let coin = vector::borrow(coins, i); 26 | sum = sum + coin::value(coin); 27 | i = i + 1; 28 | }; 29 | 30 | assert!(sum >= threshold, ECoinBelowThreshold); 31 | } 32 | -------------------------------------------------------------------------------- /packages/cetus-aggregator-v2/utils.move: -------------------------------------------------------------------------------- 1 | module cetus_aggregator_v2_extend_v1::utils; 2 | 3 | use sui::coin::{Self, Coin}; 4 | 5 | const MAX_SQRT_PRICE_X64: u128 = 79226673515401279992447579055; 6 | const MIN_SQRT_PRICE_X64: u128 = 4295048016; 7 | 8 | const ECoinBelowThreshold: u64 = 1; 9 | 10 | public fun max_sqrt_price(): u128 { 11 | MAX_SQRT_PRICE_X64 12 | } 13 | 14 | public fun min_sqrt_price(): u128 { 15 | MIN_SQRT_PRICE_X64 16 | } 17 | 18 | #[allow(lint(self_transfer))] 19 | public fun transfer_or_destroy_coin(coin: Coin, ctx: &TxContext) { 20 | if (coin::value(&coin) > 0) { 21 | transfer::public_transfer(coin, tx_context::sender(ctx)) 22 | } else { 23 | coin::destroy_zero(coin) 24 | } 25 | } 26 | 27 | public fun check_coin_threshold(coin: &Coin, threshold: u64) { 28 | assert!(coin::value(coin) >= threshold, ECoinBelowThreshold); 29 | } 30 | 31 | public fun check_coins_threshold(coins: &vector>, threshold: u64) { 32 | let mut i = 0; 33 | let mut sum = 0; 34 | let length = vector::length(coins); 35 | while (i < length) { 36 | let coin = vector::borrow(coins, i); 37 | sum = sum + coin::value(coin); 38 | i = i + 1; 39 | }; 40 | 41 | assert!(sum >= threshold, ECoinBelowThreshold); 42 | } 43 | -------------------------------------------------------------------------------- /packages/externals/.gitignore: -------------------------------------------------------------------------------- 1 | **/Move.lock 2 | **/*/Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/aftermath/aftermath-amm/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/aftermath-amm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "AftermathAMM" 3 | version = "0.1.1" 4 | published-at = "0xc4049b2d1cc0f6e017fda8260e4377cecd236bd7f56a54fee120816e72e2e0dd" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 8 | ProtocolFeeVault = { local = "../amm-protocol-fee-vault" } 9 | AmmMath = { local = "../amm-math" } 10 | 11 | [addresses] 12 | aftermath_amm = "0xefe170ec0be4d762196bedecd7a065816576198a6527c99282a2551aaa7da38c" 13 | -------------------------------------------------------------------------------- /packages/externals/aftermath/aftermath-amm/sources/pool_registry.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #[allow(unused_type_parameter, unused_field)] 5 | module aftermath_amm::pool_registry { 6 | struct PoolRegistryStateV1 has store, key { 7 | id: sui::object::UID, 8 | coins: sui::table::Table, 9 | lp_coin_map: sui::table::Table, 10 | registered_pools: sui::table::Table, bool> 11 | } 12 | 13 | struct PoolRegistry has store, key { 14 | id: sui::object::UID, 15 | protocol_version: u64 16 | } 17 | 18 | fun init( 19 | _arg0: &mut sui::tx_context::TxContext 20 | ) 21 | { 22 | abort 0 23 | } 24 | 25 | public fun protocol_version( 26 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 27 | ): u64 28 | { 29 | abort 0 30 | } 31 | 32 | public fun lp_coin_map( 33 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 34 | ): &sui::table::Table 35 | { 36 | abort 0 37 | } 38 | 39 | public fun contains_lp_coin( 40 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 41 | ): bool 42 | { 43 | abort 0 44 | } 45 | 46 | public fun lp_type_to_pool_id( 47 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 48 | ): sui::object::ID 49 | { 50 | abort 0 51 | } 52 | 53 | public fun supported_coins( 54 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 55 | ): &sui::table::Table 56 | { 57 | abort 0 58 | } 59 | 60 | public fun contains_coin( 61 | _arg0: &aftermath_amm::pool_registry::PoolRegistry 62 | ): bool 63 | { 64 | abort 0 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/externals/aftermath/aftermath-amm/sources/swap.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module aftermath_amm::swap { 5 | public fun swap_exact_in( 6 | _arg0: &mut aftermath_amm::pool::Pool, 7 | _arg1: &aftermath_amm::pool_registry::PoolRegistry, 8 | _arg2: &protocol_fee_vault::vault::ProtocolFeeVault, 9 | _arg3: &mut treasury::treasury::Treasury, 10 | _arg4: &mut insurance_fund::insurance_fund::InsuranceFund, 11 | _arg5: &referral_vault::referral_vault::ReferralVault, 12 | _arg6: sui::coin::Coin, 13 | _arg7: u64, 14 | _arg8: u64, 15 | _arg9: &mut sui::tx_context::TxContext 16 | ): sui::coin::Coin 17 | { 18 | abort 0 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-insurance-fund/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-insurance-fund/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "InsuranceFund" 3 | version = "0.0.1" 4 | published-at = "0xa6baab1e668c7868991c1c3c11e144100f5734c407d020f72a01b9d1a8bcb97f" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | [addresses] 13 | insurance_fund = "0xa6baab1e668c7868991c1c3c11e144100f5734c407d020f72a01b9d1a8bcb97f" 14 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-insurance-fund/sources/insurance_fund.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module insurance_fund::insurance_fund { 5 | struct AdminReceipt { 6 | dummy_field: bool 7 | } 8 | 9 | struct AdminCap has key { 10 | id: sui::object::UID 11 | } 12 | 13 | struct InsuranceFund has key { 14 | id: sui::object::UID, 15 | version: u64, 16 | funds: sui::bag::Bag 17 | } 18 | 19 | public fun transfer( 20 | _arg0: insurance_fund::insurance_fund::AdminCap, 21 | _arg1: address 22 | ) 23 | { 24 | abort 0 25 | } 26 | 27 | fun init( 28 | _arg0: &mut sui::tx_context::TxContext 29 | ) 30 | { 31 | abort 0 32 | } 33 | 34 | public fun admin_withdraw( 35 | _arg0: &insurance_fund::insurance_fund::AdminCap, 36 | _arg1: &mut insurance_fund::insurance_fund::InsuranceFund, 37 | _arg2: u64, 38 | _arg3: &mut sui::tx_context::TxContext 39 | ): (sui::coin::Coin, insurance_fund::insurance_fund::AdminReceipt) 40 | { 41 | abort 0 42 | } 43 | 44 | public fun admin_deposit( 45 | _arg0: &insurance_fund::insurance_fund::AdminCap, 46 | _arg1: &mut insurance_fund::insurance_fund::InsuranceFund, 47 | _arg2: insurance_fund::insurance_fund::AdminReceipt, 48 | _arg3: sui::coin::Coin 49 | ) 50 | { 51 | abort 0 52 | } 53 | 54 | public fun balance_of( 55 | _arg0: &mut insurance_fund::insurance_fund::InsuranceFund 56 | ): u64 57 | { 58 | abort 0 59 | } 60 | 61 | public fun deposit( 62 | _arg0: &mut insurance_fund::insurance_fund::InsuranceFund, 63 | _arg1: sui::coin::Coin 64 | ) 65 | { 66 | abort 0 67 | } 68 | 69 | public fun assert_version( 70 | _arg0: &insurance_fund::insurance_fund::InsuranceFund 71 | ) 72 | { 73 | abort 0 74 | } 75 | } -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-math/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-math/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "AmmMath" 3 | version = "0.0.1" 4 | published-at = "0x712579292f80c11a0c9de4ff553d6e5c4757105e83a8a3129823d2b39e65d062" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | [addresses] 13 | amm_math = "0x712579292f80c11a0c9de4ff553d6e5c4757105e83a8a3129823d2b39e65d062" 14 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-protocol-fee-vault/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-protocol-fee-vault/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ProtocolFeeVault" 3 | version = "0.0.1" 4 | published-at = "0x2d9316f1f1a95f6d7c85a4e690ef7c359e6649773ef2c37ad7d9857adb6bef06" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | [dependencies.InsuranceFund] 13 | local = "../amm-insurance-fund" 14 | 15 | [dependencies.ReferralVault] 16 | local = "../amm-referral-vault" 17 | 18 | [dependencies.Treasury] 19 | local = "../amm-treasury" 20 | 21 | [dependencies.utilities] 22 | local = "../utility/utilities" 23 | 24 | [addresses] 25 | protocol_fee_vault = "0x2d9316f1f1a95f6d7c85a4e690ef7c359e6649773ef2c37ad7d9857adb6bef06" 26 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-referral-vault/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-referral-vault/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ReferralVault" 3 | version = "0.0.1" 4 | published-at = "0xc66fabf1a9253e43c70f1cc02d40a1d18db183140ecaae2a3f58fa6b66c55acf" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | 13 | [addresses] 14 | referral_vault = "0xc66fabf1a9253e43c70f1cc02d40a1d18db183140ecaae2a3f58fa6b66c55acf" 15 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-treasury/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-treasury/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Treasury" 3 | version = "0.0.1" 4 | published-at = "0x64213b0e4a52bac468d4ac3f140242f70714381653a1919a6d57cd49c628207a" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | [addresses] 13 | treasury = "0x64213b0e4a52bac468d4ac3f140242f70714381653a1919a6d57cd49c628207a" 14 | -------------------------------------------------------------------------------- /packages/externals/aftermath/amm-treasury/sources/treasury.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module treasury::treasury { 5 | struct Treasury has key { 6 | id: sui::object::UID, 7 | version: u64, 8 | funds: sui::bag::Bag 9 | } 10 | 11 | fun init( 12 | _arg0: &mut sui::tx_context::TxContext 13 | ) 14 | { 15 | abort 0 16 | } 17 | 18 | public fun balance_of( 19 | _arg0: &mut treasury::treasury::Treasury 20 | ): u64 21 | { 22 | abort 0 23 | } 24 | 25 | public fun deposit( 26 | _arg0: &mut treasury::treasury::Treasury, 27 | _arg1: sui::coin::Coin 28 | ) 29 | { 30 | abort 0 31 | } 32 | 33 | public fun assert_version( 34 | _arg0: &treasury::treasury::Treasury 35 | ) 36 | { 37 | abort 0 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-afsui/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "StakingAfsui" 3 | version = "1.0.0" 4 | published-at = "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1" } 8 | 9 | [addresses] 10 | sui = "0x2" 11 | staking_afsui = "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc" 12 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-afsui/sources/afsui.move: -------------------------------------------------------------------------------- 1 | module staking_afsui::afsui { 2 | struct AFSUI has drop { 3 | dummy_field: bool 4 | } 5 | } -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-refer/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "StakingRefer" 3 | published-at = "0xb196672db3293fdebdbd4cbea950823ff84805547c7345710a1cf9d0db52938f" 4 | 5 | [dependencies] 6 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1" } 7 | 8 | [addresses] 9 | staking_refer= "0xb196672db3293fdebdbd4cbea950823ff84805547c7345710a1cf9d0db52938f" 10 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-refer/sources/referral_vault.move: -------------------------------------------------------------------------------- 1 | /// Module: staking-refer 2 | module staking_refer::referral_vault{ 3 | use sui::bag::Bag; 4 | use sui::object::UID; 5 | use sui::table::Table; 6 | 7 | #[allow(unused_field)] 8 | struct ReferralVault has key { 9 | id: UID, 10 | version: u64, 11 | referrer_addresses: Table, 12 | rebates: Table 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-treasury/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "StakingTreasury" 3 | version = "0.0.1" 4 | published-at = "0xceb3b6f35b71dbd0296cd96f8c00959c230854c7797294148b413094b9621b0e" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 8 | 9 | [addresses] 10 | staking_treasury = "0xceb3b6f35b71dbd0296cd96f8c00959c230854c7797294148b413094b9621b0e" 11 | 12 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking-treasury/sources/treasury.move: -------------------------------------------------------------------------------- 1 | module staking_treasury::treasury { 2 | use sui::bag::Bag; 3 | use sui::object::UID; 4 | 5 | #[allow(unused_field)] 6 | struct Treasury has key { 7 | id: UID, 8 | version: u64, 9 | funds: Bag 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Afsui" 3 | version = "1.0.0" 4 | published-at = "0x7f6ce7ade63857c4fd16ef7783fed2dfc4d7fb7e40615abdb653030b76aef0c6" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.23.1", override = true } 8 | SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "mainnet-v1.23.1", override = true } 9 | SuiSystemUtils = { local = "../utility/sui-system-utils" } 10 | LinkedSet = { local = "../utility/linked-set" } 11 | 12 | [dependencies.Safe] 13 | local = "../utility/safe" 14 | 15 | [dependencies.StakingAfsui] 16 | local = "../staking-afsui" 17 | 18 | [dependencies.StakingRefer] 19 | local = "../staking-refer" 20 | 21 | 22 | [dependencies.StakingTreasury] 23 | local = "../staking-treasury" 24 | 25 | 26 | [addresses] 27 | sui = "0x2" 28 | afsui = "0x7f6ce7ade63857c4fd16ef7783fed2dfc4d7fb7e40615abdb653030b76aef0c6" 29 | -------------------------------------------------------------------------------- /packages/externals/aftermath/staking/sources/staked_sui_vault.move: -------------------------------------------------------------------------------- 1 | module afsui::staked_sui_vault { 2 | 3 | use safe::safe::Safe; 4 | use sui::coin::{Coin, TreasuryCap}; 5 | use sui::object::UID; 6 | use sui::sui::SUI; 7 | use sui::tx_context::TxContext; 8 | use staking_afsui::afsui::AFSUI; 9 | use staking_refer::referral_vault::ReferralVault; 10 | use sui_system::sui_system::SuiSystemState; 11 | 12 | 13 | #[allow(unused_field)] 14 | struct StakedSuiVault has key { 15 | id: UID, 16 | version: u64 17 | } 18 | 19 | 20 | public fun request_stake( 21 | _rg0: &mut StakedSuiVault, 22 | _rg1: &mut Safe>, 23 | _rg2: &mut SuiSystemState, 24 | _rg3: &ReferralVault, 25 | _rg4: Coin, 26 | _rg5: address, 27 | _rg6: &mut TxContext): Coin 28 | { 29 | abort 1 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Safe" 3 | version = "0.0.1" 4 | published-at = "0x0b572349baf4526c92c4e5242306e07a1658fa329ae93d1b9db0fc38b8a592bb" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | [addresses] 13 | safe = "0x0b572349baf4526c92c4e5242306e07a1658fa329ae93d1b9db0fc38b8a592bb" 14 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/linked-set/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "LinkedSet" 3 | version = "0.0.1" 4 | published-at = "0xdb982f402a039f196f3e13cd73795db441393b5bc6eef7a0295a333808982a7d" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | 13 | [addresses] 14 | linked_set = "0xdb982f402a039f196f3e13cd73795db441393b5bc6eef7a0295a333808982a7d" 15 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/safe/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Safe" 3 | version = "0.0.1" 4 | published-at = "0x0b572349baf4526c92c4e5242306e07a1658fa329ae93d1b9db0fc38b8a592bb" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | 13 | [addresses] 14 | safe = "0x0b572349baf4526c92c4e5242306e07a1658fa329ae93d1b9db0fc38b8a592bb" 15 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/safe/sources/safe.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module safe::safe { 5 | struct OwnerCap has key { 6 | id: sui::object::UID 7 | } 8 | 9 | struct Safe has key { 10 | id: sui::object::UID, 11 | owner_cap_id: sui::object::ID, 12 | authorized_object_id: std::option::Option, 13 | obj: T0 14 | } 15 | 16 | public fun create( 17 | _arg0: T0, 18 | _arg1: std::option::Option, 19 | _arg2: &mut sui::tx_context::TxContext 20 | ) 21 | { 22 | abort 0 23 | } 24 | 25 | public fun borrow_obj_mut( 26 | _arg0: &mut safe::safe::Safe, 27 | _arg1: &sui::object::UID 28 | ): &mut T0 29 | { 30 | abort 0 31 | } 32 | 33 | public fun borrow_obj( 34 | _arg0: &safe::safe::Safe 35 | ): &T0 36 | { 37 | abort 0 38 | } 39 | 40 | public fun assert_authorization( 41 | _arg0: &safe::safe::Safe, 42 | _arg1: sui::object::ID 43 | ) 44 | { 45 | abort 0 46 | } 47 | 48 | public fun authorize( 49 | _arg0: &mut safe::safe::Safe, 50 | _arg1: &safe::safe::OwnerCap, 51 | _arg2: sui::object::ID 52 | ) 53 | { 54 | abort 0 55 | } 56 | 57 | public fun revoke_auth( 58 | _arg0: &mut safe::safe::Safe, 59 | _arg1: &safe::safe::OwnerCap 60 | ) 61 | { 62 | abort 0 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/sui-system-utils/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "SuiSystemUtils" 3 | version = "0.0.1" 4 | published-at = "0x8e6adb40c50cf2ce81d7dd12d240fb881df715343ab61233124aadb87a9fd1fd" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | 13 | [dependencies.SuiSystem] 14 | git = "https://github.com/MystenLabs/sui.git" 15 | subdir = "crates/sui-framework/packages/sui-system" 16 | rev = "mainnet-v1.24.1" 17 | override = true 18 | 19 | 20 | [addresses] 21 | sui_system_utils = "0x8e6adb40c50cf2ce81d7dd12d240fb881df715343ab61233124aadb87a9fd1fd" 22 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/sui-system-utils/sources/sui_system_utils.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module sui_system_utils::sui_system_utils { 5 | public fun calculate_rewards_at_epoch( 6 | _arg0: &mut sui_system::sui_system::SuiSystemState, 7 | _arg1: &sui_system::staking_pool::StakedSui, 8 | _arg2: u64 9 | ): u64 10 | { 11 | abort 0 12 | } 13 | 14 | public fun calculate_rewards( 15 | _arg0: &mut sui_system::sui_system::SuiSystemState, 16 | _arg1: &sui_system::staking_pool::StakedSui, 17 | _arg2: &sui::tx_context::TxContext 18 | ): u64 19 | { 20 | abort 0 21 | } 22 | 23 | public fun staked_sui_principal_and_rewards( 24 | _arg0: &mut sui_system::sui_system::SuiSystemState, 25 | _arg1: &sui_system::staking_pool::StakedSui, 26 | _arg2: &sui::tx_context::TxContext 27 | ): (u64, u64) 28 | { 29 | abort 0 30 | } 31 | 32 | public fun request_withdraw_stake_vec_non_entry( 33 | _arg0: &mut sui_system::sui_system::SuiSystemState, 34 | _arg1: vector, 35 | _arg2: &mut sui::tx_context::TxContext 36 | ): sui::balance::Balance 37 | { 38 | abort 0 39 | } 40 | 41 | public fun is_validator_active( 42 | _arg0: &mut sui_system::sui_system::SuiSystemState, 43 | _arg1: &address 44 | ): bool 45 | { 46 | abort 0 47 | } 48 | 49 | public fun pool_token_exchange_rate_at_epoch( 50 | _arg0: &mut sui_system::sui_system::SuiSystemState, 51 | _arg1: &sui_system::staking_pool::StakedSui, 52 | _arg2: u64 53 | ): sui_system::staking_pool::PoolTokenExchangeRate 54 | { 55 | abort 0 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/utilities/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "utilities" 3 | version = "0.0.1" 4 | published-at = "0x73baa782c55003b3a359dec04b189312565d18e7309d4a51f5f112f891e3b2ab" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "mainnet-v1.24.1" 10 | override = true 11 | 12 | 13 | [addresses] 14 | utilities = "0x73baa782c55003b3a359dec04b189312565d18e7309d4a51f5f112f891e3b2ab" 15 | -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/utilities/sources/decimals.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module utilities::decimals { 5 | public fun decimal_scalars_from_decimals( 6 | _arg0: &vector 7 | ): (u8, vector) 8 | { 9 | abort 0 10 | } 11 | 12 | public fun min( 13 | _arg0: &vector 14 | ): u8 15 | { 16 | abort 0 17 | } 18 | 19 | public fun mean( 20 | _arg0: &vector 21 | ): u8 22 | { 23 | abort 0 24 | } 25 | 26 | public fun change_decimals_128( 27 | _arg0: u128, 28 | _arg1: u8, 29 | _arg2: u8 30 | ): u128 31 | { 32 | abort 0 33 | } 34 | 35 | public fun close_enough_decimals( 36 | _arg0: u64, 37 | _arg1: u64, 38 | _arg2: u64, 39 | _arg3: u8 40 | ): bool 41 | { 42 | abort 0 43 | } 44 | } -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/utilities/sources/log_exp.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module utilities::log_exp { 5 | public fun pow( 6 | _arg0: u256, 7 | _arg1: u256 8 | ): u256 9 | { 10 | abort 0 11 | } 12 | 13 | public fun exp( 14 | _arg0: u256 15 | ): u256 16 | { 17 | abort 0 18 | } 19 | 20 | public fun log( 21 | _arg0: u256, 22 | _arg1: u256 23 | ): u256 24 | { 25 | abort 0 26 | } 27 | 28 | public fun ln( 29 | _arg0: u256 30 | ): u256 31 | { 32 | abort 0 33 | } 34 | } -------------------------------------------------------------------------------- /packages/externals/aftermath/utility/utilities/sources/pay.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Aftermath Technologies, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | module utilities::pay { 5 | public entry fun zero( 6 | _arg0: &mut sui::tx_context::TxContext 7 | ) 8 | { 9 | abort 0 10 | } 11 | 12 | public entry fun join_vec_and_split( 13 | _arg0: sui::coin::Coin, 14 | _arg1: vector>, 15 | _arg2: u64, 16 | _arg3: &mut sui::tx_context::TxContext 17 | ) 18 | { 19 | abort 0 20 | } 21 | } -------------------------------------------------------------------------------- /packages/externals/alphafi/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CetusProtocol/aggregator/aaa404cebcbd37bd6240512304b56513b51cbe76/packages/externals/alphafi/.gitignore -------------------------------------------------------------------------------- /packages/externals/alphafi/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "alphafi_liquid_staking" 3 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 4 | published-at = "0x059f94b85c07eb74d2847f8255d8cc0a67c9a8dcc039eabf9f8b9e23a0de2700" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet" } 8 | SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "mainnet" } 9 | 10 | [addresses] 11 | alphafi_liquid_staking = "0xc35ee7fee75782806890cf8ed8536b52b4ba0ace0fb46b944f1155cc5945baa3" 12 | -------------------------------------------------------------------------------- /packages/externals/alphafi/sources/cell.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module alphafi_liquid_staking::cell; 3 | 4 | public struct Cell has store { 5 | element: Option, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/alphafi/sources/fees.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module alphafi_liquid_staking::fees; 3 | 4 | use sui::bag::{Self, Bag}; 5 | 6 | public struct FeeConfig has store { 7 | sui_mint_fee_bps: u64, 8 | staked_sui_mint_fee_bps: u64, // unused 9 | redeem_fee_bps: u64, 10 | staked_sui_redeem_fee_bps: u64, // unused 11 | spread_fee_bps: u64, 12 | flash_stake_fee_bps: u64, 13 | custom_redeem_fee_bps: u64, // unused 14 | redeem_fee_distribution_component_bps: u64, 15 | extra_fields: Bag, // in case we add other fees later 16 | } 17 | -------------------------------------------------------------------------------- /packages/externals/alphafi/sources/liquid_staking.move: -------------------------------------------------------------------------------- 1 | /// Module: liquid_staking 2 | module alphafi_liquid_staking::liquid_staking; 3 | 4 | use alphafi_liquid_staking::cell::{Self, Cell}; 5 | use alphafi_liquid_staking::fees::FeeConfig; 6 | use alphafi_liquid_staking::storage::{Self, Storage}; 7 | use alphafi_liquid_staking::version::{Self, Version}; 8 | use std::type_name::{Self, TypeName}; 9 | use sui::bag::{Self, Bag}; 10 | use sui::balance::{Self, Balance}; 11 | use sui::coin::{Self, Coin, TreasuryCap}; 12 | use sui::package; 13 | use sui::sui::SUI; 14 | use sui::vec_map::VecMap; 15 | use sui_system::sui_system::SuiSystemState; 16 | 17 | public struct LIQUID_STAKING has drop {} 18 | 19 | public struct LiquidStakingInfo has key, store { 20 | id: UID, 21 | lst_treasury_cap: TreasuryCap

, 22 | fee_config: Cell, 23 | fees: Balance, 24 | accrued_spread_fees: u64, 25 | storage: Storage, 26 | flash_stake_lst: u64, 27 | collection_fee_cap_id: ID, 28 | is_paused: bool, 29 | version: Version, 30 | extra_fields: Bag, 31 | } 32 | -------------------------------------------------------------------------------- /packages/externals/alphafi/sources/version.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module alphafi_liquid_staking::version; 3 | 4 | // When the package called has an outdated version 5 | const EIncorrectVersion: u64 = 0; 6 | 7 | /// Capability object given to the pool creator 8 | public struct Version has drop, store (u16) 9 | -------------------------------------------------------------------------------- /packages/externals/bluefin/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/bluefin/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "BluefinSpot" 3 | version = "1.0.0" 4 | edition = "2024.beta" 5 | published-at = "0x6c796c3ab3421a68158e0df18e4657b2827b1f8fed5ed4b82dba9c935988711b" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.35.2", override=true } 9 | CetusClmm = { git = "https://github.com/CetusProtocol/cetus-clmm-interface.git", subdir = "sui/clmmpool", rev = "mainnet-v1.23.1", override=true } 10 | IntegerMate = { git = "https://github.com/CetusProtocol/integer-mate.git", subdir = "sui", rev = "mainnet-v1.23.1", override=true } 11 | 12 | [addresses] 13 | bluefin_spot = "0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267" 14 | -------------------------------------------------------------------------------- /packages/externals/bluefin/sources/config.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Seed Labs 2 | 3 | #[allow(unused_field, unused_variable, unused_type_parameter, unused_mut_parameter)] 4 | /// Config Module 5 | /// The config module stores the protocol configs and exposes methods for admin to update the config 6 | /// and getter methods to retrive config values 7 | module bluefin_spot::config; 8 | 9 | use integer_mate::i32::I32; 10 | use sui::object::UID; 11 | 12 | //===========================================================// 13 | // Constants // 14 | //===========================================================// 15 | 16 | /// The protocol's config 17 | public struct GlobalConfig has key, store { 18 | id: UID, 19 | /// min tick supported 20 | min_tick: I32, 21 | /// max tick supported 22 | max_tick: I32, 23 | /// the current pkg version supported 24 | version: u64, 25 | /// Accounts that are whitelisted to update rewards on any pool 26 | reward_managers: vector

, 27 | } 28 | -------------------------------------------------------------------------------- /packages/externals/bluefin/sources/oracle.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Seed Labs 2 | 3 | #[allow(unused_field, unused_variable, unused_type_parameter, unused_mut_parameter)] 4 | /// Oracle Module 5 | /// This module is responsible for managing observations needed for oracle price 6 | /// More on this over here: https://uniswapv3book.com/milestone_5/price-oracle.html 7 | module bluefin_spot::oracle; 8 | 9 | use integer_mate::i64::I64; 10 | 11 | //===========================================================// 12 | // Structs // 13 | //===========================================================// 14 | 15 | /// Observation Manager to keep track of all available 16 | /// observations and the current/next cardinality 17 | public struct ObservationManager has copy, drop, store { 18 | observations: vector, 19 | observation_index: u64, 20 | observation_cardinality: u64, 21 | observation_cardinality_next: u64, 22 | } 23 | 24 | /// Struct representing a single observation 25 | public struct Observation has copy, drop, store { 26 | timestamp: u64, 27 | tick_cumulative: I64, 28 | seconds_per_liquidity_cumulative: u256, 29 | initialized: bool, 30 | } 31 | -------------------------------------------------------------------------------- /packages/externals/bluefin/sources/tick.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Seed Labs 2 | 3 | #[allow(unused_field, unused_variable, unused_type_parameter, unused_mut_parameter)] 4 | /// Tick Module 5 | /// The module is responsible for creating/managing/manipluating ticks information 6 | module bluefin_spot::tick; 7 | 8 | use integer_mate::i128::I128; 9 | use integer_mate::i32::I32; 10 | use integer_mate::i64::I64; 11 | use sui::table::Table; 12 | 13 | //===========================================================// 14 | // Structs // 15 | //===========================================================// 16 | 17 | /// Ticks manager 18 | /// Stores all current ticks and their bitmap 19 | public struct TickManager has store { 20 | tick_spacing: u32, 21 | ticks: Table, 22 | bitmap: Table, 23 | } 24 | 25 | /// Struct representing a single Tick 26 | public struct TickInfo has copy, drop, store { 27 | index: I32, 28 | sqrt_price: u128, 29 | liquidity_gross: u128, 30 | liquidity_net: I128, 31 | fee_growth_outside_a: u128, 32 | fee_growth_outside_b: u128, 33 | tick_cumulative_out_side: I64, 34 | seconds_per_liquidity_out_side: u256, 35 | seconds_out_side: u64, 36 | reward_growths_outside: vector, 37 | } 38 | -------------------------------------------------------------------------------- /packages/externals/bluemove/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/bluemove/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "BlueMove" 3 | published-at = "0x7be61b62d902f3fe78d0a5e20b81b4715a47ff06cae292db8991dfea422cf57e" 4 | edition = "2024.beta" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 8 | 9 | [addresses] 10 | bluemove = "0xb24b6789e088b876afabca733bed2299fbc9e2d6369be4d1acfa17d8145454d9" 11 | -------------------------------------------------------------------------------- /packages/externals/bluemove/sources/swap.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module bluemove::swap; 3 | 4 | public struct Dex_Info has key, store { 5 | id: sui::object::UID, 6 | fee_to: address, 7 | dev: address, 8 | total_pool_created: u64, 9 | } 10 | -------------------------------------------------------------------------------- /packages/externals/bluemove/tests/bluemove_tests.move: -------------------------------------------------------------------------------- 1 | /* 2 | #[test_only] 3 | module bluemove::bluemove_tests { 4 | // uncomment this line to import the module 5 | // use bluemove::bluemove; 6 | 7 | const ENotImplemented: u64 = 0; 8 | 9 | #[test] 10 | fun test_bluemove() { 11 | // pass 12 | } 13 | 14 | #[test, expected_failure(abort_code = ::bluemove::bluemove_tests::ENotImplemented)] 15 | fun test_bluemove_fail() { 16 | abort ENotImplemented 17 | } 18 | } 19 | */ 20 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/Move.toml: -------------------------------------------------------------------------------- 1 | # Mainnet 2 | [package] 3 | name = "deepbookv3" 4 | edition = "2024.beta" 5 | version = "0.0.1" 6 | published-at = "0x2c8d603bc51326b8c13cef9dd07031a408a48dddb541963357661df5d3204809" 7 | 8 | [dependencies] 9 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 10 | token = { local = "../token"} 11 | 12 | [addresses] 13 | deepbookv3 = "0x2c8d603bc51326b8c13cef9dd07031a408a48dddb541963357661df5d3204809" 14 | 15 | # ## Testnet 16 | # [package] 17 | # name = "deepbookv3" 18 | # edition = "2024.beta" 19 | # version = "0.0.1" 20 | # published-at = "0xcbf4748a965d469ea3a36cf0ccc5743b96c2d0ae6dee0762ed3eca65fac07f7e" 21 | 22 | # [dependencies] 23 | # Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 24 | # token = { local = "../token"} 25 | 26 | # [addresses] 27 | # deepbookv3 = "0xa706f5eebcfde58ee1b03d642f222c646fe09b8d2d7a59fbee0fdc73fa21eb33" 28 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/sources/helper/math.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | #[allow(unused_field)] 4 | module deepbookv3::math; 5 | 6 | /// Multiply two floating numbers. 7 | /// This function will round down the result. 8 | public(package) fun mul(_x: u64, _y: u64): u64 { 9 | abort 0 10 | } 11 | 12 | public(package) fun mul_u128(_x: u128, _y: u128): u128 { 13 | abort 0 14 | } 15 | 16 | public(package) fun mul_round_up(_x: u64, _y: u64): u64 { 17 | abort 0 18 | } 19 | 20 | public(package) fun div(_x: u64, _y: u64): u64 { 21 | abort 0 22 | } 23 | 24 | public(package) fun div_u128(_x: u128, _y: u128): u128 { 25 | abort 0 26 | } 27 | 28 | public(package) fun div_round_up(_x: u64, _y: u64): u64 { 29 | abort 0 30 | } 31 | 32 | public(package) fun median(_v: vector): u128 { 33 | abort 0 34 | } 35 | 36 | public(package) fun sqrt(_x: u64, _precision: u64): u64 { 37 | abort 0 38 | } 39 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/sources/helper/utils.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// Deepbook utility functions. 5 | #[allow(unused_field)] 6 | module deepbookv3::utils; 7 | 8 | /// Pop elements from the back of `v` until its length equals `n`, 9 | /// returning the elements that were popped in the order they 10 | /// appeared in `v`. 11 | public(package) fun pop_until(_v: &mut vector, _n: u64): vector { 12 | abort 0 13 | } 14 | 15 | public(package) fun pop_n(_v: &mut vector, _n: u64): vector { 16 | abort 0 17 | } 18 | 19 | public(package) fun encode_order_id( 20 | _is_bid: bool, 21 | _price: u64, 22 | _order_id: u64, 23 | ): u128 { 24 | abort 0 25 | } 26 | 27 | public(package) fun decode_order_id(_encoded_order_id: u128): (bool, u64, u64) { 28 | abort 0 29 | } 30 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/sources/order_query.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// This module defines the OrderPage struct and its methods to iterate over orders in a pool. 5 | #[allow(unused_field)] 6 | module deepbookv3::order_query; 7 | 8 | use deepbookv3::order::Order; 9 | use deepbookv3::pool::Pool; 10 | 11 | // === Structs === 12 | public struct OrderPage has drop { 13 | orders: vector, 14 | has_next_page: bool, 15 | } 16 | 17 | // === Public Functions === 18 | /// Bid minimum order id has 0 for its first bit, 0 for next 63 bits for price, and 1 for next 64 bits for order id. 19 | /// Ask minimum order id has 1 for its first bit, 0 for next 63 bits for price, and 0 for next 64 bits for order id. 20 | /// Bids are iterated from high to low order id, and asks are iterated from low to high order id. 21 | public fun iter_orders( 22 | _self: &Pool, 23 | _start_order_id: Option, 24 | _end_order_id: Option, 25 | _min_expire_timestamp: Option, 26 | _limit: u64, 27 | _bids: bool, 28 | ): OrderPage { 29 | abort 0 30 | } 31 | 32 | public fun orders(_self: &OrderPage): &vector { 33 | abort 0 34 | } 35 | 36 | public fun has_next_page(_self: &OrderPage): bool { 37 | abort 0 38 | } 39 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/sources/state/balances.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// `Balances` represents the three assets make up a pool: base, quote, and deep. 5 | /// Whenever funds are moved, they are moved in the form of `Balances`. 6 | #[allow(unused_field)] 7 | module deepbookv3::balances; 8 | 9 | // === Structs === 10 | public struct Balances has store, copy, drop { 11 | base: u64, 12 | quote: u64, 13 | deep: u64, 14 | } 15 | 16 | // === Public-Package Functions === 17 | // ... existing code ... 18 | 19 | public(package) fun empty(): Balances { 20 | abort 0 21 | } 22 | 23 | public(package) fun new(_base: u64, _quote: u64, _deep: u64): Balances { 24 | abort 0 25 | } 26 | 27 | public(package) fun reset(_balances: &mut Balances): Balances { 28 | abort 0 29 | } 30 | 31 | public(package) fun add_balances(_balances: &mut Balances, _other: Balances) { 32 | abort 0 33 | } 34 | 35 | public(package) fun add_base(_balances: &mut Balances, _base: u64) { 36 | abort 0 37 | } 38 | 39 | public(package) fun add_quote(_balances: &mut Balances, _quote: u64) { 40 | abort 0 41 | } 42 | 43 | public(package) fun add_deep(_balances: &mut Balances, _deep: u64) { 44 | abort 0 45 | } 46 | 47 | public(package) fun base(_balances: &Balances): u64 { 48 | abort 0 49 | } 50 | 51 | public(package) fun quote(_balances: &Balances): u64 { 52 | abort 0 53 | } 54 | 55 | public(package) fun deep(_balances: &Balances): u64 { 56 | abort 0 57 | } 58 | 59 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/deepbook/sources/state/trade_params.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// TradeParams module contains the trade parameters for a trading pair. 5 | #[allow(unused_field)] 6 | module deepbookv3::trade_params; 7 | 8 | // === Structs === 9 | public struct TradeParams has store, drop, copy { 10 | taker_fee: u64, 11 | maker_fee: u64, 12 | stake_required: u64, 13 | } 14 | 15 | // === Public-Package Functions === 16 | // ... existing code ... 17 | 18 | public(package) fun new( 19 | _taker_fee: u64, 20 | _maker_fee: u64, 21 | _stake_required: u64, 22 | ): TradeParams { 23 | abort 0 24 | } 25 | 26 | public(package) fun maker_fee(_trade_params: &TradeParams): u64 { 27 | abort 0 28 | } 29 | 30 | public(package) fun taker_fee(_trade_params: &TradeParams): u64 { 31 | abort 0 32 | } 33 | 34 | public(package) fun taker_fee_for_user( 35 | _self: &TradeParams, 36 | _active_stake: u64, 37 | _volume_in_deep: u128, 38 | ): u64 { 39 | abort 0 40 | } 41 | 42 | public(package) fun stake_required(_trade_params: &TradeParams): u64 { 43 | abort 0 44 | } 45 | 46 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/token/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3-old/token/Move.toml: -------------------------------------------------------------------------------- 1 | # Mainnet 2 | [package] 3 | name = "token" 4 | edition = "2024.beta" 5 | published-at = "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 9 | 10 | [addresses] 11 | token = "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270" 12 | 13 | # # Testnet 14 | # [package] 15 | # name = "token" 16 | # edition = "2024.beta" 17 | # published-at = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8" 18 | 19 | # [dependencies] 20 | # Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 21 | 22 | # [addresses] 23 | # token = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8" 24 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "deepbookv3" 3 | edition = "2024.beta" 4 | version = "0.0.1" 5 | published-at = "0xcaf6ba059d539a97646d47f0b9ddf843e138d215e2a12ca1f4585d386f7aec3a" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 9 | token = { local = "../token"} 10 | 11 | [addresses] 12 | deepbookv3 = "0x2c8d603bc51326b8c13cef9dd07031a408a48dddb541963357661df5d3204809" 13 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/order_query.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// This module defines the OrderPage struct and its methods to iterate over orders in a pool. 5 | #[allow(unused_variable, unused_const, unused_use)] 6 | module deepbookv3::order_query; 7 | 8 | use deepbookv3::constants; 9 | use deepbookv3::order::Order; 10 | use deepbookv3::pool::Pool; 11 | 12 | // === Structs === 13 | public struct OrderPage has drop { 14 | orders: vector, 15 | has_next_page: bool, 16 | } 17 | 18 | // === Public Functions === 19 | /// Bid minimum order id has 0 for its first bit, 0 for next 63 bits for price, and 1 for next 64 bits for order id. 20 | /// Ask minimum order id has 1 for its first bit, 0 for next 63 bits for price, and 0 for next 64 bits for order id. 21 | /// Bids are iterated from high to low order id, and asks are iterated from low to high order id. 22 | public fun iter_orders( 23 | self: &Pool, 24 | start_order_id: Option, 25 | end_order_id: Option, 26 | min_expire_timestamp: Option, 27 | limit: u64, 28 | bids: bool, 29 | ): OrderPage { 30 | abort 0 31 | } 32 | 33 | public fun orders(self: &OrderPage): &vector { 34 | abort 0 35 | } 36 | 37 | public fun has_next_page(self: &OrderPage): bool { 38 | abort 0 39 | } 40 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/state/account.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// Account module manages the account data for each user. 5 | #[allow(unused_variable, unused_const, unused_use)] 6 | module deepbookv3::account; 7 | 8 | use deepbookv3::balances::{Self, Balances}; 9 | use deepbookv3::fill::Fill; 10 | use sui::vec_set::{Self, VecSet}; 11 | 12 | // === Structs === 13 | /// Account data that is updated every epoch. 14 | /// One Account struct per BalanceManager object. 15 | public struct Account has copy, drop, store { 16 | epoch: u64, 17 | open_orders: VecSet, 18 | taker_volume: u128, 19 | maker_volume: u128, 20 | active_stake: u64, 21 | inactive_stake: u64, 22 | created_proposal: bool, 23 | voted_proposal: Option, 24 | unclaimed_rebates: Balances, 25 | settled_balances: Balances, 26 | owed_balances: Balances, 27 | } 28 | 29 | // === Public-View Functions === 30 | public fun open_orders(self: &Account): VecSet { 31 | self.open_orders 32 | } 33 | 34 | public fun taker_volume(self: &Account): u128 { 35 | self.taker_volume 36 | } 37 | 38 | public fun maker_volume(self: &Account): u128 { 39 | self.maker_volume 40 | } 41 | 42 | public fun total_volume(self: &Account): u128 { 43 | self.taker_volume + self.maker_volume 44 | } 45 | 46 | public fun active_stake(self: &Account): u64 { 47 | self.active_stake 48 | } 49 | 50 | public fun inactive_stake(self: &Account): u64 { 51 | self.inactive_stake 52 | } 53 | 54 | public fun created_proposal(self: &Account): bool { 55 | self.created_proposal 56 | } 57 | 58 | public fun voted_proposal(self: &Account): Option { 59 | self.voted_proposal 60 | } 61 | 62 | public fun settled_balances(self: &Account): Balances { 63 | self.settled_balances 64 | } 65 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/state/balances.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// `Balances` represents the three assets make up a pool: base, quote, and 5 | /// deep. Whenever funds are moved, they are moved in the form of `Balances`. 6 | #[allow(unused_variable, unused_const, unused_use)] 7 | module deepbookv3::balances; 8 | 9 | // === Structs === 10 | public struct Balances has copy, drop, store { 11 | base: u64, 12 | quote: u64, 13 | deep: u64, 14 | } 15 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/state/trade_params.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// TradeParams module contains the trade parameters for a trading pair. 5 | #[allow(unused_variable, unused_const, unused_use)] 6 | module deepbookv3::trade_params; 7 | 8 | // === Structs === 9 | public struct TradeParams has copy, drop, store { 10 | taker_fee: u64, 11 | maker_fee: u64, 12 | stake_required: u64, 13 | } 14 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/vault/deep_price.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// DEEP price module. This module maintains the conversion rate 5 | /// between DEEP and the base and quote assets. 6 | #[allow(unused_variable, unused_const, unused_use)] 7 | module deepbookv3::deep_price; 8 | 9 | use deepbookv3::balances::{Self, Balances}; 10 | use deepbookv3::constants; 11 | use sui::event; 12 | 13 | // === Errors === 14 | const EDataPointRecentlyAdded: u64 = 1; 15 | const ENoDataPoints: u64 = 2; 16 | 17 | // === Constants === 18 | // Minimum of 1 minutes between data points 19 | const MIN_DURATION_BETWEEN_DATA_POINTS_MS: u64 = 1000 * 60; 20 | // Price points older than 1 day will be removed 21 | const MAX_DATA_POINT_AGE_MS: u64 = 1000 * 60 * 60 * 24; 22 | // Maximum number of data points to maintan 23 | const MAX_DATA_POINTS: u64 = 100; 24 | 25 | // === Structs === 26 | /// DEEP price point. 27 | public struct Price has drop, store { 28 | conversion_rate: u64, 29 | timestamp: u64, 30 | } 31 | 32 | /// DEEP price point added event. 33 | public struct PriceAdded has copy, drop { 34 | conversion_rate: u64, 35 | timestamp: u64, 36 | is_base_conversion: bool, 37 | reference_pool: ID, 38 | target_pool: ID, 39 | } 40 | 41 | /// DEEP price points used for trading fee calculations. 42 | public struct DeepPrice has drop, store { 43 | base_prices: vector, 44 | cumulative_base: u64, 45 | quote_prices: vector, 46 | cumulative_quote: u64, 47 | } 48 | 49 | public struct OrderDeepPrice has copy, drop, store { 50 | asset_is_base: bool, 51 | deep_per_asset: u64, 52 | } 53 | 54 | // === Public-View Functions === 55 | public fun asset_is_base(self: &OrderDeepPrice): bool { 56 | self.asset_is_base 57 | } 58 | 59 | public fun deep_per_asset(self: &OrderDeepPrice): u64 { 60 | self.deep_per_asset 61 | } 62 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/deepbook/sources/vault/vault.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// The vault holds all of the assets for this pool. At the end of all 5 | /// transaction processing, the vault is used to settle the balances for the user. 6 | module deepbookv3::vault; 7 | 8 | use deepbookv3::balance_manager::{TradeProof, BalanceManager}; 9 | use deepbookv3::balances::Balances; 10 | use std::type_name::{Self, TypeName}; 11 | use sui::balance::{Self, Balance}; 12 | use sui::coin::Coin; 13 | use sui::event; 14 | use token::deep::DEEP; 15 | 16 | // === Errors === 17 | const ENotEnoughBaseForLoan: u64 = 1; 18 | const ENotEnoughQuoteForLoan: u64 = 2; 19 | const EInvalidLoanQuantity: u64 = 3; 20 | const EIncorrectLoanPool: u64 = 4; 21 | const EIncorrectTypeReturned: u64 = 5; 22 | const EIncorrectQuantityReturned: u64 = 6; 23 | 24 | // === Structs === 25 | public struct Vault has store { 26 | base_balance: Balance, 27 | quote_balance: Balance, 28 | deep_balance: Balance, 29 | } 30 | 31 | public struct FlashLoan { 32 | pool_id: ID, 33 | borrow_quantity: u64, 34 | type_name: TypeName, 35 | } 36 | 37 | public struct FlashLoanBorrowed has copy, drop { 38 | pool_id: ID, 39 | borrow_quantity: u64, 40 | type_name: TypeName, 41 | } 42 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/token/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | target/ 4 | build/ 5 | Move.lock 6 | -------------------------------------------------------------------------------- /packages/externals/deepbookv3/token/Move.toml: -------------------------------------------------------------------------------- 1 | # Mainnet 2 | [package] 3 | name = "token" 4 | edition = "2024.beta" 5 | published-at = "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 9 | 10 | [addresses] 11 | token = "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270" 12 | 13 | # # Testnet 14 | # [package] 15 | # name = "token" 16 | # edition = "2024.beta" 17 | # published-at = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8" 18 | 19 | # [dependencies] 20 | # Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" } 21 | 22 | # [addresses] 23 | # token = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8" 24 | -------------------------------------------------------------------------------- /packages/externals/flowx-amm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/flowx-amm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "FlowxAMM" 3 | version = "0.1.1" 4 | published-at = "0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 9 | 10 | [addresses] 11 | flowx_amm = "0xba153169476e8c3114962261d1edc70de5ad9781b83cc617ecc8c1923191cae0" 12 | -------------------------------------------------------------------------------- /packages/externals/flowx-amm/sources/factory.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module flowx_amm::factory; 3 | 4 | use flowx_amm::treasury::Treasury; 5 | use sui::bag::Bag; 6 | use sui::object::UID; 7 | 8 | public struct Container has key { 9 | id: UID, 10 | pairs: Bag, 11 | treasury: Treasury, 12 | } 13 | -------------------------------------------------------------------------------- /packages/externals/flowx-amm/sources/treasury.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module flowx_amm::treasury; 3 | 4 | public struct Treasury has store { 5 | treasurer: address, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "FlowxClmm" 3 | version = "0.1.1" 4 | published-at = "0xcd83322a271ef764063a44fc079a7e349fb7b0744465d76e2f39c8bcf5708bd2" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.30.1", override = true } 9 | 10 | [addresses] 11 | flowx_clmm = "0x25929e7f29e0a30eb4e692952ba1b5b65a3a4d65ab5f2a32e1ba3edcb587f26d" 12 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/i128.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::i128 { 2 | #[allow(unused_field)] 3 | public struct I128 has copy, drop, store { 4 | bits: u128, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/i32.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::i32 { 2 | #[allow(unused_field)] 3 | public struct I32 has copy, drop, store { 4 | bits: u32, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/i64.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::i64 { 2 | #[allow(unused_field)] 3 | public struct I64 has copy, drop, store { 4 | bits: u64, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/oracle.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::oracle { 2 | use flowx_clmm::i64::I64; 3 | 4 | #[allow(unused_field)] 5 | public struct Observation has copy, drop, store { 6 | timestamp_s: u64, 7 | tick_cumulative: I64, 8 | seconds_per_liquidity_cumulative: u256, 9 | initialized: bool, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/pool_manager.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::pool_manager { 2 | use flowx_clmm::pool::Pool; 3 | use sui::object::UID; 4 | use sui::table::Table; 5 | 6 | #[allow(unused_field)] 7 | public struct PoolRegistry has key, store { 8 | id: UID, 9 | fee_amount_tick_spacing: Table, 10 | num_pools: u64, 11 | } 12 | 13 | public fun borrow_mut_pool( 14 | _pool_registry: &mut PoolRegistry, 15 | _fee: u64, 16 | ): &mut Pool { 17 | abort 0 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/tick.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::tick { 2 | use flowx_clmm::i128::I128; 3 | use flowx_clmm::i64::I64; 4 | 5 | #[allow(unused_field)] 6 | public struct TickInfo has copy, drop, store { 7 | liquidity_gross: u128, 8 | liquidity_net: I128, 9 | fee_growth_outside_x: u128, 10 | fee_growth_outside_y: u128, 11 | reward_growths_outside: vector, 12 | tick_cumulative_out_side: I64, 13 | seconds_per_liquidity_out_side: u256, 14 | seconds_out_side: u64, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/tick_math.move: -------------------------------------------------------------------------------- 1 | module flowx_clmm::tick_math { 2 | public fun max_sqrt_price() : u128 { 3 | 79226673515401279992447579055 4 | } 5 | 6 | public fun min_sqrt_price() : u128 { 7 | 4295048016 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/externals/flowx-clmm/sources/versioned.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module flowx_clmm::versioned { 3 | use sui::object::UID; 4 | 5 | public struct Versioned has key, store { 6 | id: UID, 7 | version: u64, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/externals/haedal-pmm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/haedal-pmm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "haedal_pmm" 3 | edition = "2024.beta" 4 | published-at = "0xa0e3b011012b80af4957afa30e556486eb3da0a7d96eeb733cf16ccd3aec32e0" 5 | 6 | [dependencies.Pyth] 7 | git = "https://github.com/pyth-network/pyth-crosschain.git" 8 | subdir = "target_chains/sui/contracts" 9 | rev = "sui-contract-mainnet" 10 | override = true 11 | 12 | [dependencies.Wormhole] 13 | git = "https://github.com/wormhole-foundation/wormhole.git" 14 | subdir = "sui/wormhole" 15 | rev = "sui/mainnet" 16 | override = true 17 | 18 | # Pyth is locked into this specific `rev` because the package depends on Wormhole and is pinned to this version. 19 | 20 | [dependencies.Sui] 21 | git = "https://github.com/MystenLabs/sui.git" 22 | subdir = "crates/sui-framework/packages/sui-framework" 23 | rev = "framework/mainnet" 24 | override = true 25 | 26 | # For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. 27 | # Revision can be a branch, a tag, and a commit hash. 28 | # MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" } 29 | 30 | # For local dependencies use `local = path`. Path is relative to the package root 31 | # Local = { local = "../path/to" } 32 | 33 | # To resolve a version conflict and force a specific version for dependency 34 | # override use `override = true` 35 | # Override = { local = "../conflicting/version", override = true } 36 | 37 | [addresses] 38 | haedal_pmm = "0xa0e3b011012b80af4957afa30e556486eb3da0a7d96eeb733cf16ccd3aec32e0" 39 | 40 | 41 | -------------------------------------------------------------------------------- /packages/externals/haedal-pmm/sources/trader.move: -------------------------------------------------------------------------------- 1 | module haedal_pmm::trader; 2 | 3 | use haedal_pmm::oracle_driven_pool::Pool; 4 | use pyth::price_info::PriceInfoObject; 5 | use sui::clock::Clock; 6 | use sui::coin::Coin; 7 | use sui::event; 8 | 9 | public fun sell_base_coin( 10 | pool: &mut Pool, 11 | clock: &Clock, 12 | base_price_pair_obj: &PriceInfoObject, 13 | quote_price_pair_obj: &PriceInfoObject, 14 | base_coin: &mut Coin, 15 | amount: u64, 16 | min_receive_quote: u64, 17 | ctx: &mut TxContext, 18 | ): Coin { 19 | abort 0 20 | } 21 | 22 | public fun sell_quote_coin( 23 | pool: &mut Pool, 24 | clock: &Clock, 25 | base_price_pair_obj: &PriceInfoObject, 26 | quote_price_pair_obj: &PriceInfoObject, 27 | quote_coin: &mut Coin, 28 | amount: u64, 29 | min_receive_base: u64, 30 | ctx: &mut TxContext, 31 | ): Coin { 32 | abort 0 33 | } 34 | -------------------------------------------------------------------------------- /packages/externals/hasui/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/hasui/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Hasui" 3 | published-at = "0x3f45767c1aa95b25422f675800f02d8a813ec793a00b60667d071a77ba7178a2" 4 | edition = "2024.beta" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.23.1", override = true } 8 | SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "mainnet-v1.23.1", override = true } 9 | 10 | [addresses] 11 | hasui = "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d" 12 | -------------------------------------------------------------------------------- /packages/externals/hasui/sources/config.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module hasui::config; 3 | 4 | public struct StakingConfig has store { 5 | deposit_fee: u64, 6 | reward_fee: u64, 7 | validator_reward_fee: u64, 8 | service_fee: u64, 9 | withdraw_time_limit: u64, 10 | validator_count: u64, 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/hasui/sources/hasui.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module hasui::hasui; 3 | 4 | public struct HASUI has drop { 5 | dummy_field: bool, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/hasui/sources/table_queue.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module hasui::table_queue; 3 | 4 | use sui::table::Table; 5 | 6 | public struct TableQueue has store { 7 | head: u64, 8 | tail: u64, 9 | contents: Table, 10 | } 11 | -------------------------------------------------------------------------------- /packages/externals/hasui/sources/vault.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module hasui::vault; 3 | 4 | use sui::balance::Balance; 5 | use sui::object::UID; 6 | 7 | public struct Vault has key, store { 8 | id: UID, 9 | cache_pool: Balance, 10 | } 11 | -------------------------------------------------------------------------------- /packages/externals/hawal/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/hawal/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Hawal" 3 | version = "0.0.1" 4 | edition = "2024.beta" 5 | published-at = "0x8b4d553839b219c3fd47608a0cc3d5fcc572cb25d41b7df3833208586a8d2470" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override = true } 9 | SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "framework/mainnet", override = true } 10 | Walrus = { local = "../walrus/walrus", override = true } 11 | WAL = { local = "../walrus/wal", override = true } 12 | 13 | [addresses] 14 | hawal = "0x8b4d553839b219c3fd47608a0cc3d5fcc572cb25d41b7df3833208586a8d2470" 15 | -------------------------------------------------------------------------------- /packages/externals/hawal/sources/config.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module hawal::config; 3 | 4 | /// `StakingConfig` holds configuration for Staking, will be stored in `Staking`. 5 | public struct StakingConfig has store { 6 | /// Deposit fee rate, default is 0, reserved for future use 7 | deposit_fee: u64, 8 | /// Reward fee rate, default is 10 percent of rewards 9 | reward_fee: u64, 10 | /// Validator reward fee rate, take from the reward_fee, reserved for future use 11 | validator_reward_fee: u64, 12 | /// Unstake instant service fee rate 13 | service_fee: u64, 14 | /// Unstake normal wait time for claim 15 | withdraw_time_limit: u64, 16 | /// Validator count when calling do_stake 17 | validator_count: u64, 18 | /// Unstake walurs epoch is a built-in differentiator for walrus.system.epoch 19 | walrus_start_epoch: u32, 20 | /// Unstake walurs epoch start timestamp 21 | walrus_start_timestamp_ms: u64, 22 | /// Unstake walurs epoch duration time 23 | walrus_epoch_duration: u64, 24 | } 25 | -------------------------------------------------------------------------------- /packages/externals/hawal/sources/hawal.move: -------------------------------------------------------------------------------- 1 | module hawal::hawal; 2 | 3 | use sui::coin; 4 | use sui::url; 5 | 6 | public struct HAWAL has drop {} 7 | -------------------------------------------------------------------------------- /packages/externals/hawal/sources/vault.move: -------------------------------------------------------------------------------- 1 | module hawal::vault; 2 | 3 | use sui::balance::{Self, Balance}; 4 | 5 | public struct Vault has key, store { 6 | id: UID, 7 | cache_pool: Balance, 8 | } 9 | -------------------------------------------------------------------------------- /packages/externals/kriya-amm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/kriya-amm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "KriyaAmm" 3 | version = "0.1.1" 4 | published-at = "0xa0eba10b173538c8fecca1dff298e488402cc9ff374f8a12ca7758eebe830b66" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 9 | 10 | [addresses] 11 | kriya_amm = "0xa0eba10b173538c8fecca1dff298e488402cc9ff374f8a12ca7758eebe830b66" 12 | -------------------------------------------------------------------------------- /packages/externals/kriya-amm/sources/spot_dex.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_amm::spot_dex; 3 | 4 | use sui::balance; 5 | use sui::coin; 6 | use sui::object::UID; 7 | use sui::tx_context; 8 | 9 | public struct LSP has drop { 10 | dummy_field: bool, 11 | } 12 | 13 | public struct Pool has key { 14 | id: UID, 15 | token_y: balance::Balance, 16 | token_x: balance::Balance, 17 | lsp_supply: balance::Supply>, 18 | lsp_locked: balance::Balance>, 19 | lp_fee_percent: u64, 20 | protocol_fee_percent: u64, 21 | protocol_fee_x: balance::Balance, 22 | protocol_fee_y: balance::Balance, 23 | is_stable: bool, 24 | scaleX: u64, 25 | scaleY: u64, 26 | is_swap_enabled: bool, 27 | is_deposit_enabled: bool, 28 | is_withdraw_enabled: bool, 29 | } 30 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "KriyaClmm" 3 | version = "0.1.1" 4 | published-at = "0x7cfee19b76f44a30cd7b8edcbb24eff1cc3fdc3495d3d07e99f1af46f5719861" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 9 | 10 | [addresses] 11 | kriya_clmm = "0xf6c05e2d9301e6e91dc6ab6c3ca918f7d55896e1f1edd64adc0e615cde27ebf1" 12 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/i128.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::i128; 3 | 4 | public struct I128 has copy, drop, store { 5 | bits: u128, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/i32.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::i32; 3 | 4 | public struct I32 has copy, drop, store { 5 | bits: u32, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/i64.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::i64; 3 | 4 | public struct I64 has copy, drop, store { 5 | bits: u64, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/oracle.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::oracle; 3 | 4 | use kriya_clmm::i64::I64; 5 | 6 | public struct Observation has copy, drop, store { 7 | timestamp_s: u64, 8 | tick_cumulative: I64, 9 | seconds_per_liquidity_cumulative: u256, 10 | initialized: bool, 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/pool.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::pool; 3 | 4 | use kriya_clmm::i32::I32; 5 | use kriya_clmm::oracle::Observation; 6 | use kriya_clmm::tick::TickInfo; 7 | use std::type_name::TypeName; 8 | use sui::balance::Balance; 9 | use sui::object::UID; 10 | use sui::table::Table; 11 | 12 | public struct Pool has key { 13 | id: UID, 14 | type_x: TypeName, 15 | type_y: TypeName, 16 | sqrt_price: u128, 17 | liquidity: u128, 18 | tick_index: I32, 19 | tick_spacing: u32, 20 | max_liquidity_per_tick: u128, 21 | fee_growth_global_x: u128, 22 | fee_growth_global_y: u128, 23 | reserve_x: Balance, 24 | reserve_y: Balance, 25 | swap_fee_rate: u64, 26 | flash_loan_fee_rate: u64, 27 | protocol_fee_share: u64, 28 | protocol_flash_loan_fee_share: u64, 29 | protocol_fee_x: u64, 30 | protocol_fee_y: u64, 31 | ticks: Table, 32 | tick_bitmap: Table, 33 | reward_infos: vector, 34 | observation_index: u64, 35 | observation_cardinality: u64, 36 | observation_cardinality_next: u64, 37 | observations: vector, 38 | } 39 | 40 | public struct PoolRewardInfo has copy, drop, store { 41 | reward_coin_type: TypeName, 42 | last_update_time: u64, 43 | ended_at_seconds: u64, 44 | total_reward: u64, 45 | total_reward_allocated: u64, 46 | reward_per_seconds: u128, 47 | reward_growth_global: u128, 48 | } 49 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/tick.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::tick; 3 | 4 | use kriya_clmm::i128::I128; 5 | use kriya_clmm::i64::I64; 6 | 7 | public struct TickInfo has copy, drop, store { 8 | liquidity_gross: u128, 9 | liquidity_net: I128, 10 | fee_growth_outside_x: u128, 11 | fee_growth_outside_y: u128, 12 | reward_growths_outside: vector, 13 | tick_cumulative_out_side: I64, 14 | seconds_per_liquidity_out_side: u256, 15 | seconds_out_side: u64, 16 | } 17 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/trade.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::trade; 3 | 4 | use sui::object::ID; 5 | 6 | public struct FlashSwapReceipt { 7 | pool_id: ID, 8 | amount_x_debt: u64, 9 | amount_y_debt: u64, 10 | } 11 | -------------------------------------------------------------------------------- /packages/externals/kriya-clmm/sources/version.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module kriya_clmm::version; 3 | 4 | use sui::object::UID; 5 | 6 | public struct Version has key, store { 7 | id: UID, 8 | major_version: u64, 9 | minor_version: u64, 10 | } 11 | 12 | public struct VersionCap has key, store { 13 | id: UID, 14 | } 15 | -------------------------------------------------------------------------------- /packages/externals/metastable/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/metastable/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aftermath_mstable" 3 | edition = "2024.beta" 4 | published-at = "0x74ecdeabc36974da37a3e2052592b2bc2c83e878bbd74690e00816e91f93a505" 5 | 6 | [dependencies.Pyth] 7 | git = "https://github.com/pyth-network/pyth-crosschain.git" 8 | subdir = "target_chains/sui/contracts" 9 | rev = "sui-contract-mainnet" 10 | override = true 11 | 12 | [dependencies.Wormhole] 13 | git = "https://github.com/wormhole-foundation/wormhole.git" 14 | subdir = "sui/wormhole" 15 | rev = "sui-upgrade-mainnet" 16 | override = true 17 | 18 | # Pyth is locked into this specific `rev` because the package depends on Wormhole and is pinned to this version. 19 | 20 | [dependencies.Sui] 21 | git = "https://github.com/MystenLabs/sui.git" 22 | subdir = "crates/sui-framework/packages/sui-framework" 23 | rev = "framework/mainnet" 24 | override = true 25 | 26 | 27 | [addresses] 28 | aftermath_mstable = "0xca653d2fac70a49549c7ff8792027fa4fa418fd6619954ea0f45d6fd0d081b8e" 29 | 30 | -------------------------------------------------------------------------------- /packages/externals/metastable/sources/vault.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module aftermath_mstable::vault; 3 | 4 | use aftermath_mstable::version::Version; 5 | use sui::balance::Supply; 6 | use sui::clock::Clock; 7 | use sui::coin::Coin; 8 | use sui::event; 9 | use sui::object::{UID, ID}; 10 | use sui::object_bag::ObjectBag; 11 | 12 | public struct Vault has key { 13 | id: UID, 14 | supply: Supply, 15 | meta_coin_decimals: u8, 16 | active_assistant_cap: ID, 17 | metadata: ObjectBag, 18 | total_priorities: u64, 19 | funds: ObjectBag, 20 | fees: ObjectBag, 21 | } 22 | 23 | public struct DepositCap { 24 | exchange_rate_meta_coin_to_coin_in: u128, 25 | } 26 | 27 | public struct WithdrawCap { 28 | exchange_rate_meta_coin_to_coin_out: u128, 29 | } 30 | -------------------------------------------------------------------------------- /packages/externals/metastable/sources/version.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module aftermath_mstable::version; 3 | 4 | public struct Version has key { 5 | id: 0x2::object::UID, 6 | version: u64, 7 | } 8 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mmt_v3" 3 | edition = "2024.beta" 4 | published-at = "0x60e8683e01d5611cd13a69aca2b0c9aace7c6b559734df1b4a7ad9d6bddf007b" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet", override = true } 8 | 9 | 10 | [addresses] 11 | mmt_v3 = "0x70285592c97965e811e0c6f98dccc3a9c2b4ad854b3594faab9597ada267b860" 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/collect.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::collect { 2 | use sui::coin::{Coin}; 3 | use sui::clock::{Clock}; 4 | use mmt_v3::pool::{Pool}; 5 | use mmt_v3::position::{Position}; 6 | use std::type_name::{TypeName}; 7 | use mmt_v3::version::{Version}; 8 | 9 | public struct FeeCollectedEvent has copy, drop, store { 10 | sender: address, 11 | pool_id: ID, 12 | position_id: ID, 13 | amount_x: u64, 14 | amount_y: u64, 15 | } 16 | 17 | public struct CollectPoolRewardEvent has copy, drop, store { 18 | sender: address, 19 | pool_id: ID, 20 | position_id: ID, 21 | reward_coin_type: TypeName, 22 | amount: u64, 23 | } 24 | 25 | public fun fee( 26 | pool: &mut Pool, 27 | position: &mut Position, 28 | clock: &Clock, 29 | version: &Version, 30 | tx_context: &mut TxContext 31 | ) : (Coin, Coin) { 32 | abort 0 33 | } 34 | 35 | public fun reward( 36 | pool: &mut Pool, 37 | position: &mut Position, 38 | clock: &Clock, 39 | version: &Version, 40 | ctx: &mut TxContext 41 | ) : Coin { 42 | abort 0 43 | } 44 | } -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/create_pool.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::create_pool { 2 | use std::type_name::{TypeName}; 3 | use mmt_v3::pool::{ Pool}; 4 | use mmt_v3::global_config::{GlobalConfig}; 5 | use mmt_v3::version::{Version}; 6 | 7 | public struct PoolCreatedEvent has copy, drop, store { 8 | sender: address, 9 | pool_id: ID, 10 | type_x: TypeName, 11 | type_y: TypeName, 12 | fee_rate: u64, 13 | tick_spacing: u32, 14 | } 15 | 16 | #[allow(lint(share_owned))] 17 | public fun new( 18 | global_config: &mut GlobalConfig, 19 | fee_rate: u64, 20 | version: &Version, 21 | tx_context: &mut TxContext 22 | ): Pool { 23 | abort 0 24 | } 25 | 26 | fun create_pool_internal( 27 | global_config: &GlobalConfig, 28 | fee_rate: u64, 29 | version: &Version, 30 | tx_context: &mut TxContext 31 | ): Pool { 32 | abort 0 33 | } 34 | } -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/global_config.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::global_config { 2 | use sui::table::Table; 3 | 4 | public struct EnableFeeRateEvent has copy, drop, store { 5 | sender: address, 6 | fee_rate: u64, 7 | tick_spacing: u32, 8 | } 9 | 10 | public struct GlobalConfig has key, store { 11 | id: UID, 12 | fee_amount_tick_spacing: Table, 13 | } 14 | 15 | fun init(tx_context: &mut TxContext) { 16 | abort 0 17 | } 18 | 19 | public fun contains_fee_rate(self: &GlobalConfig, fee_rate: u64): bool { abort 0 } 20 | 21 | public fun get_tick_spacing(self: &GlobalConfig, fee_rate: u64): u32 { 22 | abort 0 23 | } 24 | 25 | fun enable_fee_rate_internal( 26 | self: &mut GlobalConfig, 27 | fee_rate: u64, 28 | tick_spacing: u32, 29 | tx_context: &mut TxContext, 30 | ) { 31 | abort 0 32 | } 33 | 34 | #[test_only] 35 | use sui::table; 36 | 37 | #[test_only] 38 | public fun init_(tx_context: &mut TxContext) { 39 | let mut global_config = GlobalConfig { 40 | id: object::new(tx_context), 41 | fee_amount_tick_spacing: table::new(tx_context), 42 | }; 43 | enable_fee_rate_internal(&mut global_config, 100, 2, tx_context); 44 | enable_fee_rate_internal(&mut global_config, 500, 10, tx_context); 45 | enable_fee_rate_internal(&mut global_config, 3000, 60, tx_context); 46 | enable_fee_rate_internal(&mut global_config, 10000, 200, tx_context); 47 | 48 | transfer::share_object(global_config); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/bit_math.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::bit_math { 2 | public fun least_significant_bit(mut value: u256) : u8 { 3 | abort 0 4 | } 5 | 6 | public fun most_significant_bit(mut value: u256) : u8 { 7 | abort 0 8 | } 9 | } -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/comparator.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::comparator { 2 | 3 | public struct Result has drop { 4 | inner: u8, 5 | } 6 | 7 | public fun compare(value1: &X, value2: &X) : Result { 8 | abort 0 9 | } 10 | 11 | public fun compare_u8_vector(vec1: vector, vec2: vector) : Result { 12 | abort 0 13 | } 14 | 15 | public fun is_equal(result: &Result) : bool { 16 | abort 0 17 | } 18 | 19 | public fun is_greater_than(result: &Result) : bool { 20 | abort 0 21 | } 22 | 23 | public fun is_smaller_than(result: &Result) : bool { 24 | abort 0 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/constants.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::constants { 2 | public fun fee_rate_denominator() : u64 { 3 | abort 0 4 | } 5 | 6 | public fun protocol_fee_share_denominator() : u64 { 7 | abort 0 8 | } 9 | 10 | public fun rewarder_admin_df_key(): u64 { 11 | abort 0 12 | } 13 | 14 | public fun pool_admin_df_key(): u64 { 15 | abort 0 16 | } 17 | 18 | public fun pool_trading_enabled_df_key(): vector { 19 | abort 0 20 | } 21 | 22 | public fun is_pause_df_key(): vector { 23 | abort 0 24 | } 25 | 26 | public fun max_u128() : u128 { 27 | abort 0 28 | } 29 | 30 | public fun max_u16() : u16 { 31 | abort 0 32 | } 33 | 34 | public fun max_u256() : u256 { 35 | abort 0 36 | } 37 | 38 | public fun max_u32() : u32 { 39 | abort 0 40 | } 41 | 42 | public fun max_u64() : u64 { 43 | abort 0 44 | } 45 | 46 | public fun max_u8() : u8 { 47 | abort 0 48 | } 49 | 50 | public fun q64() : u128 { 51 | abort 0 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/sqrt_price_math.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::sqrt_price_math { 2 | public fun get_amount_x_delta( 3 | sqrt_price_start: u128, 4 | sqrt_price_end: u128, 5 | liquidity: u128, 6 | round_up: bool 7 | ) : u64 { 8 | abort 0 9 | } 10 | 11 | public fun get_amount_y_delta(sqrt_price_start: u128, sqrt_price_end: u128, liquidity: u128, round_up: bool) : u64 { 12 | abort 0 13 | } 14 | 15 | public fun get_next_sqrt_price_from_amount_x_rouding_up(current_price: u128, liquidity: u128, amount: u64, round_up: bool) : u128 { 16 | abort 0 17 | } 18 | 19 | public fun get_next_sqrt_price_from_amount_y_rouding_down(current_price: u128, liquidity: u128, amount: u64, round_up: bool) : u128 { 20 | abort 0 21 | } 22 | 23 | public fun get_next_sqrt_price_from_input(current_price: u128, liquidity: u128, amount: u64, is_token0: bool) : u128 { 24 | abort 0 25 | } 26 | 27 | public fun get_next_sqrt_price_from_output(current_price: u128, liquidity: u128, amount: u64, is_token0: bool) : u128 { 28 | abort 0 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/swap_math.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::swap_math { 2 | public fun compute_swap_step( 3 | current_sqrt_price: u128, 4 | target_sqrt_price: u128, 5 | liquidity: u128, 6 | amount_remaining: u64, 7 | fee_rate: u64, 8 | is_exact_input: bool 9 | ) : (u128, u64, u64, u64) { 10 | abort 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/tick_math.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::tick_math { 2 | use mmt_v3::i32::{I32}; 3 | 4 | public fun get_sqrt_price_at_tick(arg0: I32) : u128 { 5 | abort 0 6 | } 7 | 8 | public fun get_tick_at_sqrt_price(arg0: u128) : I32 { 9 | abort 0 10 | } 11 | 12 | public fun is_valid_index(arg0: I32, arg1: u32) : bool { 13 | abort 0 14 | } 15 | 16 | public fun max_sqrt_price() : u128 { 17 | abort 0 18 | } 19 | 20 | public fun max_tick() : I32 { 21 | abort 0 22 | } 23 | 24 | public fun min_sqrt_price() : u128 { 25 | abort 0 26 | } 27 | 28 | public fun min_tick() : I32 { 29 | abort 0 30 | } 31 | 32 | public fun tick_bound() : u32 { 33 | abort 0 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /packages/externals/mmt_v3/sources/utils/utils.move: -------------------------------------------------------------------------------- 1 | module mmt_v3::utils { 2 | use sui::coin::{Self, Coin}; 3 | 4 | public fun refund(coin: Coin, recipient: address) { 5 | abort 0 6 | } 7 | 8 | public fun to_seconds(milliseconds: u64) : u64 { 9 | abort 0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/obric/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/obric/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "obric" 3 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 4 | published-at = "0x0faf21b90a31e7d9a233be3b16138b23da34a243bb1d2497e0c01a2cc566b310" 5 | 6 | [dependencies.Pyth] 7 | git = "https://github.com/pyth-network/pyth-crosschain.git" 8 | subdir = "target_chains/sui/contracts" 9 | rev = "sui-contract-mainnet" 10 | 11 | [dependencies.Wormhole] 12 | git = "https://github.com/wormhole-foundation/wormhole.git" 13 | subdir = "sui/wormhole" 14 | rev = "sui/mainnet" 15 | 16 | [dependencies.Sui] 17 | git = "https://github.com/MystenLabs/sui.git" 18 | subdir = "crates/sui-framework/packages/sui-framework" 19 | rev = "framework/mainnet" 20 | override = true 21 | 22 | [addresses] 23 | obric = "0xb84e63d22ea4822a0a333c250e790f69bf5c2ef0c63f4e120e05a6415991368f" 24 | -------------------------------------------------------------------------------- /packages/externals/obric/sources/v2.move: -------------------------------------------------------------------------------- 1 | /// Module: obric 2 | #[allow(unused_field)] 3 | module obric::v2; 4 | 5 | use pyth::price_info::PriceInfoObject; 6 | use pyth::state::State as PythState; 7 | use sui::balance; 8 | use sui::coin; 9 | 10 | public struct PairRegistry has key { 11 | id: UID, 12 | pair_ids: vector
, 13 | } 14 | 15 | public struct TradingPair has key { 16 | id: UID, 17 | // actual coin balance 18 | reserve_x: balance::Balance, 19 | reserve_y: balance::Balance, 20 | concentration: u64, 21 | big_k: u128, 22 | target_x: u64, 23 | mult_x: u64, 24 | mult_y: u64, 25 | fee_millionth: u64, 26 | x_price_id: address, 27 | y_price_id: address, 28 | x_retain_decimals: u64, 29 | y_retain_decimals: u64, 30 | cumulative_volume: u64, 31 | volumes: vector, 32 | times: vector, 33 | target_y_based_lock: bool, 34 | target_y_reference: u64, 35 | pyth_mode: bool, 36 | pyth_y_add: u64, 37 | pyth_y_sub: u64, 38 | } 39 | 40 | public fun swap_x_to_y( 41 | _pair: &mut TradingPair, 42 | _clock: &sui::clock::Clock, 43 | _pyth_state: &PythState, 44 | _x_price_info_object: &PriceInfoObject, 45 | _y_price_info_object: &PriceInfoObject, 46 | x_coin: coin::Coin, 47 | ctx: &mut TxContext, 48 | ): coin::Coin { 49 | abort 0 50 | } 51 | 52 | public fun swap_y_to_x( 53 | _pair: &mut TradingPair, 54 | _clock: &sui::clock::Clock, 55 | _pyth_state: &PythState, 56 | _x_price_info_object: &PriceInfoObject, 57 | _y_price_info_object: &PriceInfoObject, 58 | y_coin: coin::Coin, 59 | ctx: &mut TxContext, 60 | ): coin::Coin { 61 | abort 0 62 | } 63 | -------------------------------------------------------------------------------- /packages/externals/scallop/scallop_scoin/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/scallop/scallop_scoin/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ScallopScoin" 3 | version = "0.1.1" 4 | published-at = "0x80ca577876dec91ae6d22090e56c39bc60dce9086ab0729930c6900bc4162b4c" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 9 | ScallopProtocol = { git = "https://github.com/scallop-io/sui-lending-protocol.git", subdir = "contracts/protocol", rev = "mainnet", override = true } 10 | 11 | [addresses] 12 | scallop_scoin = "0x80ca577876dec91ae6d22090e56c39bc60dce9086ab0729930c6900bc4162b4c" 13 | -------------------------------------------------------------------------------- /packages/externals/scallop/scallop_scoin/sources/s_coin_converter.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module scallop_scoin::s_coin_converter; 3 | 4 | use protocol::reserve::MarketCoin; 5 | use sui::balance::{Balance, Supply}; 6 | use sui::object::UID; 7 | 8 | public struct SCoinTreasury has key { 9 | id: UID, 10 | s_coin_supply: Supply, 11 | market_coin_balance: Balance>, 12 | } 13 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Steamm" 3 | version = "0.1.1" 4 | edition = "2024.beta" 5 | published-at = "0x4fb1cf45dffd6230305f1d269dd1816678cc8e3ba0b747a813a556921219f261" #pre 6 | 7 | [dependencies.Sui] 8 | git = "https://github.com/MystenLabs/sui.git" 9 | subdir = "crates/sui-framework/packages/sui-framework" 10 | rev = "framework/mainnet" 11 | override = true 12 | 13 | [dependencies.liquid_staking] 14 | git = "https://github.com/solendprotocol/liquid-staking.git" 15 | subdir = "contracts" 16 | rev = "main" 17 | override = true 18 | 19 | [dependencies.suilend] 20 | local = "../suilend/suilend" 21 | override = true 22 | 23 | [dependencies.oracles] 24 | local = "../suilend/oracles" 25 | override = true 26 | 27 | [addresses] 28 | steamm = "0x4fb1cf45dffd6230305f1d269dd1816678cc8e3ba0b747a813a556921219f261" 29 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/bank.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_variable)] 2 | module steamm::bank; 3 | 4 | use steamm::version::Version; 5 | use sui::balance::Balance; 6 | use sui::clock::Clock; 7 | use sui::coin::Coin; 8 | use suilend::lending_market::{ObligationOwnerCap, LendingMarket}; 9 | 10 | public struct Bank has key { 11 | id: UID, 12 | funds_available: Balance, 13 | lending: Option>, 14 | min_token_block_size: u64, 15 | btoken_supply: Balance, 16 | version: Version, 17 | } 18 | 19 | public struct Lending has store { 20 | ctokens: u64, 21 | target_utilisation_bps: u16, 22 | utilisation_buffer_bps: u16, 23 | reserve_array_index: u64, 24 | obligation_cap: ObligationOwnerCap, 25 | } 26 | 27 | public fun mint_btokens( 28 | bank: &mut Bank, 29 | lending_market: &mut LendingMarket, 30 | coin: &mut Coin, 31 | amount: u64, 32 | clock: &Clock, 33 | ctx: &mut TxContext, 34 | ): Coin { 35 | abort 0 36 | } 37 | 38 | public fun burn_btokens( 39 | bank: &mut Bank, 40 | lending_market: &mut LendingMarket, 41 | coin: &mut Coin, 42 | amount: u64, 43 | clock: &Clock, 44 | ctx: &mut TxContext, 45 | ): Coin { 46 | abort 0 47 | } 48 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/cpmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_variable)] 2 | module steamm::cpmm; 3 | 4 | use steamm::pool::{Pool, SwapResult}; 5 | use steamm::version::Version; 6 | use sui::coin::Coin; 7 | 8 | public struct CpQuoter has store { 9 | version: Version, 10 | offset: u64, 11 | } 12 | 13 | public fun swap( 14 | arg0: &mut Pool, 15 | arg1: &mut Coin, 16 | arg2: &mut Coin, 17 | arg3: bool, 18 | arg4: u64, 19 | arg5: u64, 20 | arg6: &mut TxContext, 21 | ): SwapResult { 22 | abort 0 23 | } 24 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/fees.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::fees; 3 | 4 | use sui::balance::Balance; 5 | 6 | public struct Fees has store { 7 | config: FeeConfig, 8 | fee_a: Balance, 9 | fee_b: Balance, 10 | } 11 | 12 | public struct FeeConfig has copy, drop, store { 13 | fee_numerator: u64, 14 | fee_denominator: u64, 15 | min_fee: u64, 16 | } 17 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/pool.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::pool; 3 | 4 | use steamm::fees::{Fees, FeeConfig}; 5 | use steamm::quote::SwapFee; 6 | use steamm::version::Version; 7 | use sui::balance::{Balance, Supply}; 8 | 9 | public struct Pool has key, store { 10 | id: UID, 11 | quoter: T2, 12 | balance_a: Balance, 13 | balance_b: Balance, 14 | lp_supply: Supply, 15 | protocol_fees: Fees, 16 | pool_fee_config: FeeConfig, 17 | trading_data: TradingData, 18 | version: Version, 19 | } 20 | 21 | public struct TradingData has store { 22 | swap_a_in_amount: u128, 23 | swap_b_out_amount: u128, 24 | swap_a_out_amount: u128, 25 | swap_b_in_amount: u128, 26 | protocol_fees_a: u64, 27 | protocol_fees_b: u64, 28 | pool_fees_a: u64, 29 | pool_fees_b: u64, 30 | } 31 | 32 | public struct SwapResult has copy, drop, store { 33 | user: address, 34 | pool_id: ID, 35 | amount_in: u64, 36 | amount_out: u64, 37 | output_fees: SwapFee, 38 | a2b: bool, 39 | balance_a: u64, 40 | balance_b: u64, 41 | } 42 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/quote.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::quote; 3 | 4 | public struct SwapFee has copy, drop, store { 5 | protocol_fees: u64, 6 | pool_fees: u64, 7 | } 8 | -------------------------------------------------------------------------------- /packages/externals/steamm-v1/sources/version.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::version; 3 | 4 | public struct Version has store { 5 | pos0: u16, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/steamm/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/steamm/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Steamm" 3 | version = "0.1.1" 4 | edition = "2024.beta" 5 | published-at = "0xf0e2245d9351b94a6aca77c91a9a4b310508fee953a97667b4dee5f9d59ad025" #pre 6 | 7 | [dependencies.Sui] 8 | git = "https://github.com/MystenLabs/sui.git" 9 | subdir = "crates/sui-framework/packages/sui-framework" 10 | rev = "framework/mainnet" 11 | override = true 12 | 13 | [dependencies.liquid_staking] 14 | git = "https://github.com/solendprotocol/liquid-staking.git" 15 | subdir = "contracts" 16 | rev = "main" 17 | override = true 18 | 19 | [dependencies.suilend] 20 | local = "../suilend/suilend" 21 | override = true 22 | 23 | [dependencies.oracles] 24 | local = "../suilend/oracles" 25 | override = true 26 | 27 | [addresses] 28 | steamm = "0x4fb1cf45dffd6230305f1d269dd1816678cc8e3ba0b747a813a556921219f261" 29 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/cpmm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_variable)] 2 | module steamm::cpmm; 3 | 4 | use steamm::pool::{Pool, SwapResult}; 5 | use steamm::version::Version; 6 | use sui::coin::Coin; 7 | 8 | public struct CpQuoter has store { 9 | version: Version, 10 | offset: u64, 11 | } 12 | 13 | public fun swap( 14 | arg0: &mut Pool, 15 | arg1: &mut Coin, 16 | arg2: &mut Coin, 17 | arg3: bool, 18 | arg4: u64, 19 | arg5: u64, 20 | arg6: &mut TxContext, 21 | ): SwapResult { 22 | abort 0 23 | } 24 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/fees.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::fees; 3 | 4 | use sui::balance::Balance; 5 | 6 | public struct Fees has store { 7 | config: FeeConfig, 8 | fee_a: Balance, 9 | fee_b: Balance, 10 | } 11 | 12 | public struct FeeConfig has copy, drop, store { 13 | fee_numerator: u64, 14 | fee_denominator: u64, 15 | min_fee: u64, 16 | } 17 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/omm.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_variable, unused_const, unused_use)] 2 | module steamm::omm; 3 | 4 | use oracles::oracles::{OracleRegistry, OraclePriceUpdate}; 5 | use steamm::bank::Bank; 6 | use steamm::pool::{Pool, SwapResult}; 7 | use steamm::version::Version; 8 | use sui::clock::Clock; 9 | use sui::coin::Coin; 10 | use suilend::lending_market::LendingMarket; 11 | 12 | public struct OracleQuoter has store { 13 | version: Version, 14 | // oracle params 15 | oracle_registry_id: ID, 16 | oracle_index_a: u64, 17 | oracle_index_b: u64, 18 | // coin info 19 | decimals_a: u8, 20 | decimals_b: u8, 21 | } 22 | 23 | public fun swap( 24 | pool: &mut Pool, 25 | bank_a: &Bank, 26 | bank_b: &Bank, 27 | lending_market: &LendingMarket

, 28 | oracle_price_update_a: OraclePriceUpdate, 29 | oracle_price_update_b: OraclePriceUpdate, 30 | coin_a: &mut Coin, 31 | coin_b: &mut Coin, 32 | a2b: bool, 33 | amount_in: u64, 34 | min_amount_out: u64, 35 | clock: &Clock, 36 | ctx: &mut TxContext, 37 | ): SwapResult { 38 | abort 0 39 | } 40 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/pool.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::pool; 3 | 4 | use steamm::fees::{Fees, FeeConfig}; 5 | use steamm::quote::SwapFee; 6 | use steamm::version::Version; 7 | use sui::balance::{Balance, Supply}; 8 | 9 | public use fun steamm::omm::swap as Pool.omm_swap; 10 | 11 | public struct Pool has key, store { 12 | id: UID, 13 | quoter: T2, 14 | balance_a: Balance, 15 | balance_b: Balance, 16 | lp_supply: Supply, 17 | protocol_fees: Fees, 18 | pool_fee_config: FeeConfig, 19 | trading_data: TradingData, 20 | version: Version, 21 | } 22 | 23 | public struct TradingData has store { 24 | swap_a_in_amount: u128, 25 | swap_b_out_amount: u128, 26 | swap_a_out_amount: u128, 27 | swap_b_in_amount: u128, 28 | protocol_fees_a: u64, 29 | protocol_fees_b: u64, 30 | pool_fees_a: u64, 31 | pool_fees_b: u64, 32 | } 33 | 34 | public struct SwapResult has copy, drop, store { 35 | user: address, 36 | pool_id: ID, 37 | amount_in: u64, 38 | amount_out: u64, 39 | output_fees: SwapFee, 40 | a2b: bool, 41 | balance_a: u64, 42 | balance_b: u64, 43 | } 44 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/quote.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::quote; 3 | 4 | public struct SwapFee has copy, drop, store { 5 | protocol_fees: u64, 6 | pool_fees: u64, 7 | } 8 | -------------------------------------------------------------------------------- /packages/externals/steamm/sources/version.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module steamm::version; 3 | 4 | public struct Version has store { 5 | pos0: u16, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/suilend/oracles/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "oracles" 3 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 4 | published-at = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b" 5 | 6 | [dependencies.Sui] 7 | git = "https://github.com/MystenLabs/sui.git" 8 | subdir = "crates/sui-framework/packages/sui-framework" 9 | rev = "framework/mainnet" 10 | override = true 11 | 12 | [dependencies.Pyth] 13 | git = "https://github.com/solendprotocol/pyth-crosschain.git" 14 | subdir = "target_chains/sui/contracts" 15 | rev = "98e218c64bb75cf1350eb7b021e1ffcc3aedfd62" 16 | override = true 17 | 18 | [dependencies.Switchboard] 19 | git = "https://github.com/suilend/switchboard.git" 20 | subdir = "on_demand/" 21 | rev = "mainnet" 22 | override = true 23 | 24 | [addresses] 25 | oracles = "0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b" 26 | -------------------------------------------------------------------------------- /packages/externals/suilend/oracles/sources/oracle_decimal.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_variable)] 2 | module oracles::oracle_decimal; 3 | 4 | public struct OracleDecimal has copy, drop, store { 5 | base: u128, 6 | expo: u64, 7 | is_expo_negative: bool, 8 | } 9 | 10 | public fun new(base: u128, expo: u64, is_expo_negative: bool): OracleDecimal { 11 | abort 0 12 | } 13 | 14 | public fun base(decimal: &OracleDecimal): u128 { 15 | abort 0 16 | } 17 | 18 | public fun expo(decimal: &OracleDecimal): u64 { 19 | abort 0 20 | } 21 | 22 | public fun is_expo_negative(decimal: &OracleDecimal): bool { 23 | abort 0 24 | } 25 | -------------------------------------------------------------------------------- /packages/externals/suilend/oracles/sources/version.move: -------------------------------------------------------------------------------- 1 | module oracles::version; 2 | 3 | /// Capability object given to the pool creator 4 | public struct Version has drop, store (u16) 5 | -------------------------------------------------------------------------------- /packages/externals/suilend/sprungsui/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/suilend/sprungsui/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sprungsui" 3 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 4 | published-at = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override = true } 8 | 9 | [addresses] 10 | sprungsui = "0xb87cea7e4220461e35dff856185814d6a37ef479ce895ffbe4efa1d1af5aacbc" 11 | -------------------------------------------------------------------------------- /packages/externals/suilend/sprungsui/sources/sprungsui.move: -------------------------------------------------------------------------------- 1 | module sprungsui::sprungsui; 2 | 3 | public struct SPRUNGSUI has drop {} 4 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "suilend" 3 | version = "0.0.1" 4 | published-at = "0xd2a67633ccb8de063163e25bcfca242929caf5cf1a26c2929dab519ee0b8f331" 5 | edition = "2024.beta" 6 | 7 | [dependencies.Sui] 8 | git = "https://github.com/MystenLabs/sui.git" 9 | subdir = "crates/sui-framework/packages/sui-framework" 10 | rev = "framework/mainnet" 11 | override = true 12 | 13 | [dependencies.Pyth] 14 | git = "https://github.com/solendprotocol/pyth-crosschain.git" 15 | subdir = "target_chains/sui/contracts" 16 | rev = "98e218c64bb75cf1350eb7b021e1ffcc3aedfd62" 17 | override = true 18 | 19 | [dependencies.liquid_staking] 20 | git = "https://github.com/solendprotocol/liquid-staking.git" 21 | subdir = "contracts" 22 | rev = "main" 23 | override = true 24 | 25 | [dependencies.sprungsui] 26 | local = "../sprungsui" 27 | 28 | [addresses] 29 | sui = "0x2" 30 | suilend = "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf" 31 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/cell.move: -------------------------------------------------------------------------------- 1 | module suilend::cell; 2 | 3 | public struct Cell has store { 4 | element: Option, 5 | } 6 | 7 | public fun new(element: Element): Cell { 8 | Cell { element: option::some(element) } 9 | } 10 | 11 | public fun set(cell: &mut Cell, element: Element): Element { 12 | option::swap(&mut cell.element, element) 13 | } 14 | 15 | public fun get(cell: &Cell): &Element { 16 | option::borrow(&cell.element) 17 | } 18 | 19 | public fun destroy(cell: Cell): Element { 20 | let Cell { element } = cell; 21 | option::destroy_some(element) 22 | } 23 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/decimal.move: -------------------------------------------------------------------------------- 1 | /// fixed point decimal representation. 18 decimal places are kept. 2 | module suilend::decimal; 3 | 4 | public struct Decimal has copy, drop, store { 5 | value: u256, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/lending_market.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module suilend::lending_market; 3 | 4 | use pyth::price_info::PriceInfoObject; 5 | use std::ascii; 6 | use std::type_name::TypeName; 7 | use sui::balance::Balance; 8 | use sui::clock::Clock; 9 | use sui::coin::{Coin, CoinMetadata, TreasuryCap}; 10 | use sui::dynamic_field; 11 | use sui::event; 12 | use sui::object_table::ObjectTable; 13 | use sui::sui::SUI; 14 | use sui_system::sui_system::SuiSystemState; 15 | use suilend::decimal::Decimal; 16 | use suilend::obligation::Obligation; 17 | use suilend::rate_limiter::RateLimiter; 18 | use suilend::reserve::Reserve; 19 | 20 | // === Structs === 21 | public struct LendingMarket has key, store { 22 | id: UID, 23 | version: u64, 24 | reserves: vector>, 25 | obligations: ObjectTable>, 26 | // window duration is in seconds 27 | rate_limiter: RateLimiter, 28 | fee_receiver: address, // deprecated 29 | /// unused 30 | bad_debt_usd: Decimal, 31 | /// unused 32 | bad_debt_limit_usd: Decimal, 33 | } 34 | 35 | public struct LendingMarketOwnerCap has key, store { 36 | id: UID, 37 | lending_market_id: ID, 38 | } 39 | 40 | public struct ObligationOwnerCap has key, store { 41 | id: UID, 42 | obligation_id: ID, 43 | } 44 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/lending_market_registry.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module suilend::lending_market_registry; 3 | 4 | use std::type_name::TypeName; 5 | use sui::object::UID; 6 | use sui::table::Table; 7 | 8 | public struct Registry has key { 9 | id: UID, 10 | version: u64, 11 | lending_markets: Table, 12 | } 13 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/liquidity_mining.move: -------------------------------------------------------------------------------- 1 | /// A user_reward_manager farms pool_rewards to receive rewards proportional to their stake in the pool. 2 | module suilend::liquidity_mining; 3 | 4 | use std::type_name::TypeName; 5 | use sui::bag::Bag; 6 | use sui::balance::Balance; 7 | use sui::clock::Clock; 8 | use suilend::decimal::Decimal; 9 | 10 | /// This struct manages all pool_rewards for a given stake pool. 11 | public struct PoolRewardManager has key, store { 12 | id: UID, 13 | total_shares: u64, 14 | pool_rewards: vector>, 15 | last_update_time_ms: u64, 16 | } 17 | 18 | public struct PoolReward has key, store { 19 | id: UID, 20 | pool_reward_manager_id: ID, 21 | coin_type: TypeName, 22 | start_time_ms: u64, 23 | end_time_ms: u64, 24 | total_rewards: u64, 25 | /// amount of rewards that have been earned by users 26 | allocated_rewards: Decimal, 27 | cumulative_rewards_per_share: Decimal, 28 | num_user_reward_managers: u64, 29 | additional_fields: Bag, 30 | } 31 | 32 | // == Dynamic Field Keys 33 | public struct RewardBalance has copy, drop, store {} 34 | 35 | public struct UserRewardManager has store { 36 | pool_reward_manager_id: ID, 37 | share: u64, 38 | rewards: vector>, 39 | last_update_time_ms: u64, 40 | } 41 | 42 | public struct UserReward has store { 43 | pool_reward_id: ID, 44 | earned_rewards: Decimal, 45 | cumulative_rewards_per_share: Decimal, 46 | } 47 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/rate_limiter.move: -------------------------------------------------------------------------------- 1 | module suilend::rate_limiter; 2 | 3 | use suilend::decimal::Decimal; 4 | 5 | public struct RateLimiter has copy, drop, store { 6 | /// configuration parameters 7 | config: RateLimiterConfig, 8 | // state 9 | /// prev qty is the sum of all outflows from [window_start - config.window_duration, window_start) 10 | prev_qty: Decimal, 11 | /// time when window started 12 | window_start: u64, 13 | /// cur qty is the sum of all outflows from [window_start, window_start + config.window_duration) 14 | cur_qty: Decimal, 15 | } 16 | 17 | public struct RateLimiterConfig has copy, drop, store { 18 | /// Rate limiter window duration 19 | window_duration: u64, 20 | /// Rate limiter param. Max outflow in a window 21 | max_outflow: u64, 22 | } 23 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/reserve_config.move: -------------------------------------------------------------------------------- 1 | /// parameters for a Reserve. 2 | module suilend::reserve_config; 3 | 4 | use sui::bag::Bag; 5 | 6 | public struct ReserveConfig has store { 7 | // risk params 8 | open_ltv_pct: u8, 9 | close_ltv_pct: u8, 10 | max_close_ltv_pct: u8, // unused 11 | borrow_weight_bps: u64, 12 | // deposit limit in token amounts 13 | deposit_limit: u64, 14 | // borrow limit in token amounts 15 | borrow_limit: u64, 16 | // extra withdraw amount as bonus for liquidators 17 | liquidation_bonus_bps: u64, 18 | max_liquidation_bonus_bps: u64, // unused 19 | // deposit limit in usd 20 | deposit_limit_usd: u64, 21 | // borrow limit in usd 22 | borrow_limit_usd: u64, 23 | // interest params 24 | interest_rate_utils: vector, 25 | // in basis points 26 | interest_rate_aprs: vector, 27 | // fees 28 | borrow_fee_bps: u64, 29 | spread_fee_bps: u64, 30 | // extra withdraw amount as fee for protocol on liquidations 31 | protocol_liquidation_fee_bps: u64, 32 | // if true, the asset cannot be used as collateral 33 | // and can only be borrowed in isolation 34 | isolated: bool, 35 | // unused 36 | open_attributed_borrow_limit_usd: u64, 37 | close_attributed_borrow_limit_usd: u64, 38 | additional_fields: Bag, 39 | } 40 | 41 | public struct ReserveConfigBuilder has store { 42 | fields: Bag, 43 | } 44 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/staker.move: -------------------------------------------------------------------------------- 1 | /// Stake unlent Sui. 2 | module suilend::staker; 3 | 4 | use liquid_staking::liquid_staking::{LiquidStakingInfo, AdminCap}; 5 | use sui::balance::Balance; 6 | use sui::sui::SUI; 7 | 8 | public struct Staker has store { 9 | admin: AdminCap

, 10 | liquid_staking_info: LiquidStakingInfo

, 11 | lst_balance: Balance

, 12 | sui_balance: Balance, 13 | liabilities: u64, // how much sui is owed to the reserve 14 | } 15 | -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/suilend.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": ".." 5 | }, 6 | { 7 | "path": "../../suilend-old" 8 | }, 9 | { 10 | "path": "../../../github/sui" 11 | }, 12 | { 13 | "path": "../../solana-program-library" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /packages/externals/suilend/suilend/sources/suilend.move: -------------------------------------------------------------------------------- 1 | module suilend::suilend; 2 | 3 | public struct MAIN_POOL has drop {} 4 | -------------------------------------------------------------------------------- /packages/externals/turbos-dex/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | .vscode 4 | target/ 5 | build/ 6 | -------------------------------------------------------------------------------- /packages/externals/turbos-dex/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "TurbosDex" 3 | version = "0.0.9" 4 | published-at = "0x2476333f61ab625ae25205b6726048295fe8b356d26ca841ddf93c69bbd616c8" 5 | edition = "2024.beta" 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.24.1", override = true } 9 | 10 | [addresses] 11 | turbos_dex = "0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1" 12 | -------------------------------------------------------------------------------- /packages/externals/turbos-dex/sources/i32.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module turbos_dex::i32; 3 | 4 | public struct I32 has copy, drop, store { 5 | bits: u32, 6 | } 7 | -------------------------------------------------------------------------------- /packages/externals/turbos-dex/sources/pool.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module turbos_dex::pool { 3 | use std::string::String; 4 | use sui::balance::Balance; 5 | use sui::object::UID; 6 | use sui::table::Table; 7 | use turbos_dex::i32::I32; 8 | 9 | public struct Versioned has key, store { 10 | id: UID, 11 | version: u64, 12 | } 13 | 14 | public struct PoolRewardInfo has key, store { 15 | id: UID, 16 | vault: address, 17 | vault_coin_type: String, 18 | emissions_per_second: u128, 19 | growth_global: u128, 20 | manager: address, 21 | } 22 | 23 | public struct Pool has key, store { 24 | id: UID, 25 | coin_a: Balance, 26 | coin_b: Balance, 27 | protocol_fees_a: u64, 28 | protocol_fees_b: u64, 29 | sqrt_price: u128, 30 | tick_current_index: I32, 31 | tick_spacing: u32, 32 | max_liquidity_per_tick: u128, 33 | fee: u32, 34 | fee_protocol: u32, 35 | unlocked: bool, 36 | fee_growth_global_a: u128, 37 | fee_growth_global_b: u128, 38 | liquidity: u128, 39 | tick_map: Table, 40 | deploy_time_ms: u64, 41 | reward_infos: vector, 42 | reward_last_updated_time_ms: u64, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/externals/turbos-dex/sources/swap_router.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field, unused_use)] 2 | module turbos_dex::swap_router { 3 | use std::vector; 4 | use sui::clock::Clock; 5 | use sui::coin::Coin; 6 | use sui::tx_context::TxContext; 7 | use turbos_dex::pool::{Pool, Versioned}; 8 | 9 | public fun swap_a_b_with_return_( 10 | _pool: &mut Pool, 11 | _coin_a: vector>, 12 | _amount: u64, 13 | _amount_limit: u64, 14 | _sqrt_price_limit: u128, 15 | _by_amount_in: bool, 16 | _sender: address, 17 | _time_out: u64, 18 | _clock: &Clock, 19 | _versioned: &Versioned, 20 | _ctx: &mut TxContext, 21 | ): (Coin, Coin) { 22 | abort 0 23 | } 24 | 25 | public fun swap_b_a_with_return_( 26 | _pool: &mut Pool, 27 | _coin_b: vector>, 28 | _amount: u64, 29 | _amount_limit: u64, 30 | _sqrt_price_limit: u128, 31 | _by_amount_in: bool, 32 | _sender: address, 33 | _time_out: u64, 34 | _clock: &Clock, 35 | _versioned: &Versioned, 36 | _ctx: &mut TxContext, 37 | ): (Coin, Coin) { 38 | abort 0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/externals/vsui/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Vsui" 3 | published-at = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55" 4 | edition = "2024.beta" 5 | 6 | [dependencies] 7 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.23.1", override = true } 8 | SuiSystem = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-system", rev = "mainnet-v1.23.1", override = true } 9 | 10 | [addresses] 11 | vsui = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55" 12 | 13 | -------------------------------------------------------------------------------- /packages/externals/vsui/sources/cert.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module vsui::cert; 3 | 4 | use sui::balance::Supply; 5 | use sui::object::UID; 6 | 7 | public struct CERT has drop { 8 | dummy_field: bool, 9 | } 10 | 11 | public struct Metadata has key, store { 12 | id: UID, 13 | version: u64, 14 | total_supply: Supply, 15 | } 16 | -------------------------------------------------------------------------------- /packages/externals/vsui/sources/native_pool.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module vsui::native_pool; 3 | 4 | use sui::coin::Coin; 5 | use sui::object::UID; 6 | use sui::sui::SUI; 7 | use sui::table::Table; 8 | use sui_system::validator_set::ValidatorSet; 9 | use vsui::cert::{Self, CERT}; 10 | use vsui::unstake_ticket::Metadata; 11 | 12 | #[allow(unused_field, lint(coin_field))] 13 | // #[allow(lint(coin_field))] 14 | public struct NativePool has key { 15 | id: UID, 16 | pending: Coin, 17 | collectable_fee: Coin, 18 | validator_set: ValidatorSet, 19 | ticket_metadata: Metadata, 20 | total_staked: Table, 21 | staked_update_epoch: u64, 22 | base_unstake_fee: u64, 23 | unstake_fee_threshold: u64, 24 | base_reward_fee: u64, 25 | version: u64, 26 | paused: bool, 27 | min_stake: u64, 28 | total_rewards: u64, 29 | collected_rewards: u64, 30 | rewards_threshold: u64, 31 | rewards_update_ts: u64, 32 | } 33 | -------------------------------------------------------------------------------- /packages/externals/vsui/sources/unstake_ticket.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module vsui::unstake_ticket; 3 | 4 | use sui::object::UID; 5 | use sui::table::Table; 6 | 7 | public struct Metadata has key, store { 8 | id: UID, 9 | version: u64, 10 | total_supply: u64, 11 | max_history_value: Table, 12 | } 13 | -------------------------------------------------------------------------------- /packages/externals/vsui/sources/validator_set.move: -------------------------------------------------------------------------------- 1 | #[allow(unused_field)] 2 | module vsui::validator_set; 3 | 4 | use sui::object::UID; 5 | use sui::object_table::ObjectTable; 6 | use sui::table::Table; 7 | use sui::vec_map::VecMap; 8 | use sui_system::staking_pool::StakedSui; 9 | 10 | public struct Vault has store { 11 | stakes: ObjectTable, 12 | gap: u64, 13 | length: u64, 14 | total_staked: u64, 15 | } 16 | 17 | public struct ValidatorSet has key, store { 18 | id: UID, 19 | vaults: Table, 20 | validators: VecMap, 21 | sorted_validators: vector

, 22 | is_sorted: bool, 23 | } 24 | -------------------------------------------------------------------------------- /packages/externals/walrus/wal/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /Move.lock 3 | -------------------------------------------------------------------------------- /packages/externals/walrus/wal/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "WAL" 3 | license = "Apache-2.0" 4 | authors = ["Mysten Labs "] 5 | edition = "2024.beta" 6 | published-at = "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59" 7 | 8 | [dependencies] 9 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.35.2", override = true } 10 | 11 | [addresses] 12 | wal = "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59" 13 | -------------------------------------------------------------------------------- /packages/externals/walrus/wal/sources/wal.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// Module: wal 5 | module wal::wal; 6 | 7 | use sui::coin; 8 | 9 | /// The OTW for the `WAL` coin. 10 | public struct WAL has drop {} 11 | -------------------------------------------------------------------------------- /packages/externals/walrus/walrus/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Walrus" 3 | license = "Apache-2.0" 4 | authors = ["Mysten Labs "] 5 | edition = "2024.beta" 6 | published-at = "0xfdc88f7d7cf30afab2f82e8380d11ee8f70efb90e863d1de8616fae1bb09ea77" 7 | 8 | [dependencies] 9 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet", override = true } 10 | WAL = { local = "../wal" } 11 | 12 | [addresses] 13 | walrus = "0xfdc88f7d7cf30afab2f82e8380d11ee8f70efb90e863d1de8616fae1bb09ea77" 14 | -------------------------------------------------------------------------------- /packages/externals/walrus/walrus/sources/staking.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | module walrus::staking; 4 | 5 | /// The one and only staking object. 6 | public struct Staking has key { 7 | id: UID, 8 | version: u64, 9 | package_id: ID, 10 | new_package_id: Option, 11 | } 12 | -------------------------------------------------------------------------------- /packages/externals/walrus/walrus/sources/staking/staked_wal.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /// Module: `staked_wal` 5 | /// 6 | /// Implements the `StakedWal` functionality - a staked WAL is an object that 7 | /// represents a staked amount of WALs in a staking pool. It is created in the 8 | /// `staking_pool` on staking and can be split, joined, and burned. The burning 9 | /// is performed via the `withdraw_stake` method in the `staking_pool`. 10 | #[allow(unused_field)] 11 | module walrus::staked_wal; 12 | 13 | use sui::balance::Balance; 14 | use wal::wal::WAL; 15 | 16 | /// The state of the staked WAL. It can be either `Staked` or `Withdrawing`. 17 | /// The `Withdrawing` state contains the epoch when the staked WAL can be 18 | /// withdrawn. 19 | public enum StakedWalState has copy, drop, store { 20 | // Default state of the staked WAL - it is staked in the staking pool. 21 | Staked, 22 | // The staked WAL is in the process of withdrawing. The value inside the 23 | // variant is the epoch when the staked WAL can be withdrawn. 24 | Withdrawing { withdraw_epoch: u32 }, 25 | } 26 | 27 | /// Represents a staked WAL, does not store the `Balance` inside, but uses 28 | /// `u64` to represent the staked amount. Behaves similarly to `Balance` and 29 | /// `Coin` providing methods to `split` and `join`. 30 | public struct StakedWal has key, store { 31 | id: UID, 32 | /// Whether the staked WAL is active or withdrawing. 33 | state: StakedWalState, 34 | /// ID of the staking pool. 35 | node_id: ID, 36 | /// The staked amount. 37 | principal: Balance, 38 | /// The Walrus epoch when the staked WAL was activated. 39 | activation_epoch: u32, 40 | } 41 | -------------------------------------------------------------------------------- /packages/externals/walrus/walrus/sources/system.move: -------------------------------------------------------------------------------- 1 | // Copyright (c) Mysten Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #[allow(unused_variable, unused_function, unused_field, unused_mut_parameter)] 5 | /// Module: system 6 | module walrus::system; 7 | 8 | /// The one and only system object. 9 | public struct System has key { 10 | id: UID, 11 | version: u64, 12 | package_id: ID, 13 | new_package_id: Option, 14 | } 15 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults-v2/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults-v2/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Deepbookv3VaultsV2" 3 | version = "0.1.1" 4 | published-at = "0x3dd6243c54c8bf3cc7e8b9489d7ba16e5fa2fa81f09fee5c2962f158b764cb20" 5 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 6 | 7 | [dependencies] 8 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.23.1", override = true } 9 | deepbookv3 = { local = "../../externals/deepbookv3/deepbook", override = true} 10 | token = { local = "../../externals/deepbookv3/token", override = true } 11 | 12 | [addresses] 13 | deepbookv3_vaults_v2 = "0x79bd71317665179f4f6025df6c478d9ed47fd281c9335c4c51e1ba0996010519" 14 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults-v2/sources/global_config.move: -------------------------------------------------------------------------------- 1 | module deepbookv3_vaults_v2::global_config; 2 | 3 | use deepbookv3::balance_manager::{Self, BalanceManager, TradeCap}; 4 | use std::string::{Self, String}; 5 | use sui::balance::{Self, Balance}; 6 | use sui::table::{Self, Table}; 7 | use token::deep::DEEP; 8 | 9 | // === Constants === 10 | // package version 11 | const VERSION: u64 = 1; 12 | 13 | const SPONSOR_FEE_RECORD_KEY: vector = b"sponsor_fee_record"; 14 | 15 | // === Errors === 16 | const EInsufficientDeepFee: u64 = 0; 17 | const ENotAlternativePayment: u64 = 1; 18 | const EPackageVersionDeprecate: u64 = 2; 19 | const EOverSponsorLimit: u64 = 3; 20 | 21 | // === Structs === 22 | public struct AdminCap has key, store { 23 | id: UID, 24 | } 25 | 26 | public struct GlobalConfig has key, store { 27 | id: UID, 28 | is_alternative_payment: bool, 29 | alternative_payment_amount: u64, 30 | trade_cap: TradeCap, 31 | balance_manager: BalanceManager, 32 | deep_fee_vault: Balance, 33 | whitelist: Table, 34 | package_version: u64, 35 | } 36 | 37 | public struct SponsorFeeRecord has key, store { 38 | id: UID, 39 | sponsor_fee_records: Table, 40 | epoch_sponsor_fee_limit: u64, 41 | whitelist: Table, 42 | } 43 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults/Move.toml: -------------------------------------------------------------------------------- 1 | # Mainnet 2 | [package] 3 | name = "Deepbookv3Vaults" 4 | version = "0.1.1" 5 | published-at = "0x9caccba6a5e9570a7cd712fc849daff8a0290874d4e4bcc046391b9620a253c9" 6 | edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move 7 | 8 | [dependencies] 9 | Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.23.1", override = true } 10 | deepbookv3 = { local = "../../externals/deepbookv3/deepbook", override = true} 11 | token = { local = "../../externals/deepbookv3/token", override = true } 12 | 13 | [addresses] 14 | deepbookv3_vaults = "0x9caccba6a5e9570a7cd712fc849daff8a0290874d4e4bcc046391b9620a253c9" 15 | -------------------------------------------------------------------------------- /packages/internals/deepbookv3-vaults/sources/global_config.move: -------------------------------------------------------------------------------- 1 | module deepbookv3_vaults::global_config; 2 | 3 | use deepbookv3::balance_manager::{BalanceManager, TradeCap}; 4 | use deepbookv3::order_info::OrderInfo; 5 | use deepbookv3::pool::Pool; 6 | use sui::balance::Balance; 7 | use sui::clock::Clock; 8 | use sui::coin::Coin; 9 | use sui::table::Table; 10 | use token::deep::DEEP; 11 | 12 | public struct GlobalConfig has key, store { 13 | id: UID, 14 | is_alternative_payment: bool, 15 | alternative_payment_amount: u64, 16 | trade_cap: TradeCap, 17 | balance_manager: BalanceManager, 18 | deep_fee_vault: Balance, 19 | whitelist: Table, 20 | package_version: u64, 21 | } 22 | -------------------------------------------------------------------------------- /packages/test/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | Move.lock 3 | -------------------------------------------------------------------------------- /packages/test/Move.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test" 3 | version = "0.1.1" 4 | edition = "2024.beta" 5 | published-at = "0x0" 6 | 7 | [dependencies] 8 | IntegerMate = { git = "https://github.com/CetusProtocol/integer-mate.git", subdir = "sui", rev = "sui-v1.2.0", override = true } 9 | CetusClmm = { git = "https://github.com/CetusProtocol/cetus-clmm-interface.git", subdir = "sui/cetus_clmm", rev = "mainnet-v1.49.0", override = true } 10 | FlowxClmm = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/externals/flowx-clmm", rev = "mainnet-v1.49.4", override = true } 11 | TurbosDex = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/externals/turbos-dex", rev = "mainnet-v1.49.4", override = true } 12 | BluefinSpot = { git = "https://github.com/fireflyprotocol/bluefin-spot-contract-interface.git", subdir = "", rev = "main", override = true } 13 | CetusAggregatorSimple = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/cetus-aggregator-v2/simple-mainnet", rev = "mainnet-v1.49.4", override = true } 14 | Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", subdir = "target_chains/sui/contracts", rev = "sui-contract-mainnet", override = true } 15 | haedal_pmm = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/externals/haedal-pmm", rev = "mainnet-v1.49.4", override = true } 16 | mmt_v3 = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/externals/mmt_v3", rev = "mainnet-v1.49.4", override = true } 17 | obric = { git = "https://github.com/CetusProtocol/aggregator.git", subdir = "packages/externals/obric", rev = "mainnet-v1.49.4", override = true } 18 | 19 | 20 | [addresses] 21 | test = "0x0" 22 | -------------------------------------------------------------------------------- /src/const.ts: -------------------------------------------------------------------------------- 1 | import BN from "bn.js" 2 | 3 | export const ZERO = new BN(0) 4 | 5 | export const ONE = new BN(1) 6 | 7 | export const TWO = new BN(2) 8 | 9 | export const U128 = TWO.pow(new BN(128)) 10 | 11 | export const U64_MAX_BN = new BN("18446744073709551615") 12 | 13 | export const U64_MAX = "18446744073709551615" 14 | 15 | export const TEN_POW_NINE = 1000000000 16 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client" 2 | export * from "./transaction" 3 | export * from "./utils" 4 | export * from "./const" 5 | export * from "./api" 6 | 7 | export enum Env { 8 | Mainnet, 9 | Testnet, 10 | } 11 | -------------------------------------------------------------------------------- /src/transaction/afsui.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class Afsui implements Dex { 8 | private stakedSuiVault: string 9 | private safe: string 10 | private referVault: string 11 | private validator: string 12 | 13 | constructor(env: Env) { 14 | if (env !== Env.Mainnet) { 15 | throw new Error("Afsui only supported on mainnet") 16 | } 17 | 18 | this.stakedSuiVault = 19 | "0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d" 20 | this.safe = 21 | "0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610" 22 | this.referVault = 23 | "0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef" 24 | this.validator = 25 | "0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2" 26 | } 27 | 28 | async swap( 29 | client: AggregatorClient, 30 | txb: Transaction, 31 | path: Path, 32 | inputCoin: TransactionObjectArgument, 33 | packages?: Map 34 | ): Promise { 35 | const { direction } = path 36 | 37 | if (!direction) { 38 | throw new Error("Afsui not support b2a swap") 39 | } 40 | 41 | const func = "swap_a2b" 42 | 43 | const args = [ 44 | txb.object(this.stakedSuiVault), 45 | txb.object(this.safe), 46 | txb.object("0x5"), 47 | txb.object(this.referVault), 48 | txb.object(this.validator), 49 | inputCoin, 50 | ] 51 | 52 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 53 | 54 | const res = txb.moveCall({ 55 | target: `${publishedAt}::afsui::${func}`, 56 | typeArguments: [], 57 | arguments: args, 58 | }) as TransactionObjectArgument 59 | 60 | return res 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/transaction/alphafi.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".." 6 | 7 | export class Alphafi implements Dex { 8 | private sui_system_state: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Alphafi only supported on mainnet") 13 | } 14 | 15 | this.sui_system_state = 16 | env === Env.Mainnet 17 | ? "0x0000000000000000000000000000000000000000000000000000000000000005" 18 | : "0x0" 19 | } 20 | 21 | async swap( 22 | client: AggregatorClient, 23 | txb: Transaction, 24 | path: Path, 25 | inputCoin: TransactionObjectArgument, 26 | packages?: Map 27 | ): Promise { 28 | const { direction, from, target } = path 29 | 30 | const [func, stCoinType] = direction 31 | ? ["swap_a2b", target] 32 | : ["swap_b2a", from] 33 | 34 | const args = [ 35 | txb.object(path.id), 36 | txb.object(this.sui_system_state), 37 | inputCoin, 38 | ] 39 | 40 | const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages) 41 | 42 | const res = txb.moveCall({ 43 | target: `${publishedAt}::alphafi::${func}`, 44 | typeArguments: [stCoinType], 45 | arguments: args, 46 | }) as TransactionObjectArgument 47 | 48 | return res 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/transaction/bluefin.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionArgument, 4 | TransactionObjectArgument, 5 | } from "@mysten/sui/transactions" 6 | import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".." 7 | 8 | export class Bluefin implements Dex { 9 | private globalConfig: string 10 | 11 | constructor(env: Env) { 12 | if (env !== Env.Mainnet) { 13 | throw new Error("Bluefin only supported on mainnet") 14 | } 15 | 16 | this.globalConfig = 17 | "0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352" 18 | } 19 | 20 | async swap( 21 | client: AggregatorClient, 22 | txb: Transaction, 23 | path: Path, 24 | inputCoin: TransactionObjectArgument, 25 | packages?: Map 26 | ): Promise { 27 | const { direction, from, target } = path 28 | const [func, coinAType, coinBType] = direction 29 | ? ["swap_a2b", from, target] 30 | : ["swap_b2a", target, from] 31 | const args = [ 32 | txb.object(this.globalConfig), 33 | txb.object(path.id), 34 | inputCoin, 35 | txb.object(CLOCK_ADDRESS), 36 | ] 37 | const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages) 38 | 39 | const res = txb.moveCall({ 40 | target: `${publishedAt}::bluefin::${func}`, 41 | typeArguments: [coinAType, coinBType], 42 | arguments: args, 43 | }) as TransactionArgument 44 | return res 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/transaction/bluemove.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class Bluemove implements Dex { 8 | private dexInfo: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Bluemove only supported on mainnet") 13 | } 14 | 15 | this.dexInfo = 16 | "0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92" 17 | } 18 | 19 | async swap( 20 | client: AggregatorClient, 21 | txb: Transaction, 22 | path: Path, 23 | inputCoin: TransactionObjectArgument, 24 | packages?: Map 25 | ): Promise { 26 | const { direction, from, target } = path 27 | 28 | const [func, coinAType, coinBType] = direction 29 | ? ["swap_a2b", from, target] 30 | : ["swap_b2a", target, from] 31 | 32 | const args = [txb.object(this.dexInfo), inputCoin] 33 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 34 | const res = txb.moveCall({ 35 | target: `${publishedAt}::bluemove::${func}`, 36 | typeArguments: [coinAType, coinBType], 37 | arguments: args, 38 | }) as TransactionObjectArgument 39 | 40 | return res 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/transaction/flowx_v2.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class FlowxV2 implements Dex { 8 | private container: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Flowx only supported on mainnet") 13 | } 14 | 15 | this.container = 16 | "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511" 17 | } 18 | 19 | async swap( 20 | client: AggregatorClient, 21 | txb: Transaction, 22 | path: Path, 23 | inputCoin: TransactionObjectArgument, 24 | packages?: Map 25 | ): Promise { 26 | const { direction, from, target } = path 27 | 28 | const [func, coinAType, coinBType] = direction 29 | ? ["swap_a2b", from, target] 30 | : ["swap_b2a", target, from] 31 | 32 | const args = [txb.object(this.container), inputCoin] 33 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 34 | const res = txb.moveCall({ 35 | target: `${publishedAt}::flowx_amm::${func}`, 36 | typeArguments: [coinAType, coinBType], 37 | arguments: args, 38 | }) as TransactionObjectArgument 39 | 40 | return res 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/transaction/flowx_v3.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class FlowxV3 implements Dex { 8 | private versioned: string 9 | private poolRegistry: string 10 | 11 | constructor(env: Env) { 12 | if (env !== Env.Mainnet) { 13 | throw new Error("Flowx clmm only supported on mainnet") 14 | } 15 | 16 | this.versioned = 17 | "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656" 18 | this.poolRegistry = 19 | "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc" 20 | } 21 | 22 | async swap( 23 | client: AggregatorClient, 24 | txb: Transaction, 25 | path: Path, 26 | inputCoin: TransactionObjectArgument, 27 | packages?: Map 28 | ): Promise { 29 | const { direction, from, target } = path 30 | 31 | const [func, coinAType, coinBType] = direction 32 | ? ["swap_a2b", from, target] 33 | : ["swap_b2a", target, from] 34 | 35 | const args = [ 36 | txb.object(this.poolRegistry), 37 | txb.pure.u64(path.feeRate * 1000000), 38 | inputCoin, 39 | txb.object(this.versioned), 40 | txb.object(CLOCK_ADDRESS), 41 | ] 42 | 43 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 44 | const res = txb.moveCall({ 45 | target: `${publishedAt}::flowx_clmm::${func}`, 46 | typeArguments: [coinAType, coinBType], 47 | arguments: args, 48 | }) as TransactionObjectArgument 49 | 50 | return res 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/transaction/haedal.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class Haedal implements Dex { 8 | constructor(env: Env) { 9 | if (env !== Env.Mainnet) { 10 | throw new Error("Haedal only supported on mainnet") 11 | } 12 | } 13 | 14 | async swap( 15 | client: AggregatorClient, 16 | txb: Transaction, 17 | path: Path, 18 | inputCoin: TransactionObjectArgument, 19 | packages?: Map 20 | ): Promise { 21 | const { direction } = path 22 | const func = direction ? "swap_a2b" : "swap_b2a" 23 | const args = [txb.object(path.id), txb.object("0x5"), inputCoin] 24 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 25 | const res = txb.moveCall({ 26 | target: `${publishedAt}::haedal::${func}`, 27 | typeArguments: [], 28 | arguments: args, 29 | }) as TransactionObjectArgument 30 | 31 | return res 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/transaction/hawal.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".." 6 | 7 | export class HaWAL implements Dex { 8 | private staking: string 9 | private validator: string 10 | 11 | constructor(env: Env) { 12 | if (env !== Env.Mainnet) { 13 | throw new Error("HaWAL only supported on mainnet") 14 | } 15 | 16 | this.staking = 17 | env === Env.Mainnet 18 | ? "0x10b9d30c28448939ce6c4d6c6e0ffce4a7f8a4ada8248bdad09ef8b70e4a3904" 19 | : "0x0" 20 | 21 | this.validator = 22 | env === Env.Mainnet 23 | ? "0x7b3ba6de2ae58283f60d5b8dc04bb9e90e4796b3b2e0dea75569f491275242e7" 24 | : "0x0" 25 | } 26 | 27 | async swap( 28 | client: AggregatorClient, 29 | txb: Transaction, 30 | path: Path, 31 | inputCoin: TransactionObjectArgument, 32 | packages?: Map 33 | ): Promise { 34 | const { direction } = path 35 | const func = direction ? "swap_a2b" : "swap_b2a" 36 | const args = [ 37 | txb.object(this.staking), 38 | txb.object(path.id), 39 | inputCoin, 40 | txb.object(this.validator), 41 | ] 42 | const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages) 43 | const res = txb.moveCall({ 44 | target: `${publishedAt}::hawal::${func}`, 45 | typeArguments: [], 46 | arguments: args, 47 | }) as TransactionObjectArgument 48 | 49 | return res 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/transaction/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Path } from ".." 6 | import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils" 7 | 8 | export const CLOCK_ADDRESS = SUI_CLOCK_OBJECT_ID 9 | 10 | export const AGGREGATOR_V2 = "aggregator_v2" 11 | export const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend" 12 | export const AGGREGATOR_V2_EXTEND2 = "aggregator_v2_extend2" 13 | export function getAggregatorV2PublishedAt( 14 | aggregatorV2PublishedAt: string, 15 | packages?: Map | Record 16 | ) { 17 | if (packages instanceof Map) { 18 | return packages.get(AGGREGATOR_V2) ?? aggregatorV2PublishedAt 19 | } 20 | return aggregatorV2PublishedAt 21 | } 22 | 23 | export function getAggregatorV2ExtendPublishedAt( 24 | aggregatorV2ExtendPublishedAt: string, 25 | packages?: Map | Record 26 | ) { 27 | if (packages instanceof Map) { 28 | return packages.get(AGGREGATOR_V2_EXTEND) ?? aggregatorV2ExtendPublishedAt 29 | } 30 | return aggregatorV2ExtendPublishedAt 31 | } 32 | 33 | export function getAggregatorV2Extend2PublishedAt( 34 | aggregatorV2Extend2PublishedAt: string, 35 | packages?: Map | Record 36 | ) { 37 | if (packages instanceof Map) { 38 | return packages.get(AGGREGATOR_V2_EXTEND2) ?? aggregatorV2Extend2PublishedAt 39 | } 40 | return aggregatorV2Extend2PublishedAt 41 | } 42 | 43 | export interface Dex { 44 | swap( 45 | client: AggregatorClient, 46 | ptb: Transaction, 47 | path: Path, 48 | inputCoin: TransactionObjectArgument, 49 | packages?: Map, 50 | deepbookv3DeepFee?: TransactionObjectArgument 51 | ): Promise 52 | } 53 | -------------------------------------------------------------------------------- /src/transaction/kriya_v2.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class KriyaV2 implements Dex { 8 | constructor(env: Env) { 9 | if (env !== Env.Mainnet) { 10 | throw new Error("Kriya amm only supported on mainnet") 11 | } 12 | } 13 | 14 | async swap( 15 | client: AggregatorClient, 16 | txb: Transaction, 17 | path: Path, 18 | inputCoin: TransactionObjectArgument, 19 | packages?: Map 20 | ): Promise { 21 | const { direction, from, target } = path 22 | 23 | const [func, coinAType, coinBType] = direction 24 | ? ["swap_a2b", from, target] 25 | : ["swap_b2a", target, from] 26 | 27 | const args = [txb.object(path.id), inputCoin] 28 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 29 | const res = txb.moveCall({ 30 | target: `${publishedAt}::kriya_amm::${func}`, 31 | typeArguments: [coinAType, coinBType], 32 | arguments: args, 33 | }) as TransactionObjectArgument 34 | 35 | return res 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/transaction/kriya_v3.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 6 | 7 | export class KriyaV3 implements Dex { 8 | private version: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Kriya clmm only supported on mainnet") 13 | } 14 | 15 | this.version = 16 | "0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78" 17 | } 18 | 19 | async swap( 20 | client: AggregatorClient, 21 | txb: Transaction, 22 | path: Path, 23 | inputCoin: TransactionObjectArgument, 24 | packages?: Map 25 | ): Promise { 26 | const { direction, from, target } = path 27 | 28 | const [func, coinAType, coinBType] = direction 29 | ? ["swap_a2b", from, target] 30 | : ["swap_b2a", target, from] 31 | 32 | const args = [ 33 | txb.object(path.id), 34 | inputCoin, 35 | txb.object(this.version), 36 | txb.object(CLOCK_ADDRESS), 37 | ] 38 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 39 | const res = txb.moveCall({ 40 | target: `${publishedAt}::kriya_clmm::${func}`, 41 | typeArguments: [coinAType, coinBType], 42 | arguments: args, 43 | }) as TransactionObjectArgument 44 | 45 | return res 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/transaction/momentum.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2Extend2PublishedAt, Path } from ".." 6 | 7 | export class Momentum implements Dex { 8 | private version: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Momentum only supported on mainnet") 13 | } 14 | 15 | this.version = 16 | "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a" 17 | } 18 | 19 | async swap( 20 | client: AggregatorClient, 21 | txb: Transaction, 22 | path: Path, 23 | inputCoin: TransactionObjectArgument, 24 | packages?: Map 25 | ): Promise { 26 | const { direction, from, target } = path 27 | 28 | const [func, coinAType, coinBType] = direction 29 | ? ["swap_a2b", from, target] 30 | : ["swap_b2a", target, from] 31 | 32 | const args = [ 33 | txb.object(path.id), 34 | inputCoin, 35 | txb.object(this.version), 36 | txb.object(CLOCK_ADDRESS), 37 | ] 38 | const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages) 39 | const res = txb.moveCall({ 40 | target: `${publishedAt}::momentum::${func}`, 41 | typeArguments: [coinAType, coinBType], 42 | arguments: args, 43 | }) as TransactionObjectArgument 44 | 45 | return res 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/transaction/suilend.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".." 6 | 7 | export class Suilend implements Dex { 8 | private sui_system_state: string 9 | 10 | constructor(env: Env) { 11 | if (env !== Env.Mainnet) { 12 | throw new Error("Suilend only supported on mainnet") 13 | } 14 | 15 | this.sui_system_state = 16 | env === Env.Mainnet 17 | ? "0x0000000000000000000000000000000000000000000000000000000000000005" 18 | : "0x0" 19 | } 20 | 21 | async swap( 22 | client: AggregatorClient, 23 | txb: Transaction, 24 | path: Path, 25 | inputCoin: TransactionObjectArgument, 26 | packages?: Map 27 | ): Promise { 28 | const { direction, from, target } = path 29 | 30 | const [func, springCoinType] = direction 31 | ? ["swap_a2b", target] 32 | : ["swap_b2a", from] 33 | 34 | const args = [ 35 | txb.object(path.id), 36 | txb.object(this.sui_system_state), 37 | inputCoin, 38 | ] 39 | const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages) 40 | const res = txb.moveCall({ 41 | target: `${publishedAt}::suilend::${func}`, 42 | typeArguments: [springCoinType], 43 | arguments: args, 44 | }) as TransactionObjectArgument 45 | 46 | return res 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/transaction/turbos.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionArgument, 4 | TransactionObjectArgument, 5 | } from "@mysten/sui/transactions" 6 | import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".." 7 | 8 | export class Turbos implements Dex { 9 | private versioned: string 10 | 11 | constructor(env: Env) { 12 | if (env !== Env.Mainnet) { 13 | throw new Error("Turbos only supported on mainnet") 14 | } 15 | 16 | this.versioned = 17 | "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f" 18 | } 19 | 20 | async swap( 21 | client: AggregatorClient, 22 | txb: Transaction, 23 | path: Path, 24 | inputCoin: TransactionObjectArgument, 25 | packages?: Map 26 | ): Promise { 27 | const { direction, from, target } = path 28 | 29 | const [func, coinAType, coinBType] = direction 30 | ? ["swap_a2b", from, target] 31 | : ["swap_b2a", target, from] 32 | 33 | if (path.extendedDetails == null) { 34 | throw new Error("Extended details not supported") 35 | } else { 36 | if (path.extendedDetails.turbosFeeType == null) { 37 | throw new Error("Turbos fee type not supported") 38 | } 39 | } 40 | 41 | const args = [ 42 | txb.object(path.id), 43 | inputCoin, 44 | txb.object(CLOCK_ADDRESS), 45 | txb.object(this.versioned), 46 | ] 47 | const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages) 48 | const res = txb.moveCall({ 49 | target: `${publishedAt}::turbos::${func}`, 50 | typeArguments: [coinAType, coinBType, path.extendedDetails.turbosFeeType], 51 | arguments: args, 52 | }) as TransactionObjectArgument 53 | 54 | return res 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/transaction/volo.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Transaction, 3 | TransactionObjectArgument, 4 | } from "@mysten/sui/transactions" 5 | import { AggregatorClient, Dex, Env, getAggregatorV2Extend2PublishedAt, Path } from ".." 6 | 7 | export class Volo implements Dex { 8 | private stakePool: string 9 | private metadata: string 10 | 11 | constructor(env: Env) { 12 | if (env !== Env.Mainnet) { 13 | throw new Error("Volo only supported on mainnet") 14 | } 15 | 16 | this.stakePool = 17 | "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5" 18 | this.metadata = 19 | "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60" 20 | } 21 | 22 | async swap( 23 | client: AggregatorClient, 24 | txb: Transaction, 25 | path: Path, 26 | inputCoin: TransactionObjectArgument, 27 | packages?: Map 28 | ): Promise { 29 | const { direction } = path 30 | 31 | const func = direction ? "swap_a2b" : "swap_b2a" 32 | 33 | const args = [ 34 | txb.object(this.stakePool), 35 | txb.object(this.metadata), 36 | txb.object("0x5"), 37 | inputCoin, 38 | ] 39 | 40 | const publishedAt = getAggregatorV2Extend2PublishedAt(client.publishedAtV2Extend2(), packages) 41 | const res = txb.moveCall({ 42 | target: `${publishedAt}::volo::${func}`, 43 | typeArguments: [], 44 | arguments: args, 45 | }) as TransactionObjectArgument 46 | 47 | return res 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/utils/api.ts: -------------------------------------------------------------------------------- 1 | export function processEndpoint(endpoint: string): string { 2 | if (endpoint.endsWith("/find_routes")) { 3 | return endpoint.replace("/find_routes", "") 4 | } 5 | return endpoint 6 | } 7 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './contracts' 2 | export * from './msafe' 3 | export * from './api' 4 | export * from './coin' 5 | export * from './transaction' 6 | -------------------------------------------------------------------------------- /src/utils/msafe.ts: -------------------------------------------------------------------------------- 1 | 2 | import BN from 'bn.js' 3 | import Decimal from "decimal.js" 4 | 5 | export const dealWithFastRouterSwapParamsForMsafe = (data: any) => { 6 | const result = { 7 | ...data, 8 | amountIn: data?.amountIn?.toString(), 9 | amountOut: data?.amountIn?.toString(), 10 | routes: data?.routes?.map((item:any) => { 11 | return { 12 | ...item, 13 | amountIn: item?.amountIn?.toString(), 14 | amountOut: item?.amountOut?.toString(), 15 | initialPrice: item?.initialPrice?.toString() 16 | } 17 | }) 18 | } 19 | 20 | return result 21 | } 22 | 23 | 24 | export const restituteMsafeFastRouterSwapParams = (data: any) => { 25 | const result = { 26 | ...data, 27 | amountIn: new BN(data?.amountIn), 28 | amountOut: new BN(data?.amountIn), 29 | routes: data?.routes?.map((item:any) => { 30 | return { 31 | ...item, 32 | amountIn: new BN(item?.amountIn), 33 | amountOut: new BN(item?.amountOut), 34 | initialPrice: new Decimal(item?.initialPrice?.toString()) 35 | } 36 | }) 37 | } 38 | 39 | return result 40 | } 41 | -------------------------------------------------------------------------------- /src/utils/transaction.ts: -------------------------------------------------------------------------------- 1 | import { Transaction } from "@mysten/sui/transactions" 2 | 3 | export async function printTransaction(tx: Transaction, isPrint = true) { 4 | console.log(`inputs`, tx.getData().inputs) 5 | let i = 0 6 | 7 | tx.getData().commands.forEach((item, index) => { 8 | if (isPrint) { 9 | console.log(`transaction ${index}: `, JSON.stringify(item, null, 2)) 10 | i++ 11 | } 12 | }) 13 | } 14 | 15 | export function checkInvalidSuiAddress(address: string): boolean { 16 | if (!address.startsWith("0x") || address.length !== 66) { 17 | return false 18 | } 19 | return true 20 | } 21 | -------------------------------------------------------------------------------- /tests/math.test.ts: -------------------------------------------------------------------------------- 1 | import BN from "bn.js" 2 | import { CalculateAmountLimit, sqrtPriceX64ToPrice } from "~/math" 3 | 4 | describe("test math functions", () => { 5 | test("test sqrt price x64 to price", () => { 6 | const sqrtPriceStr = "1312674575678912631" 7 | const decimalsA = 9 8 | const decimalsB = 6 9 | 10 | const price = sqrtPriceX64ToPrice(sqrtPriceStr, decimalsA, decimalsB) 11 | console.log("price", price.toFixed(9)) 12 | }) 13 | 14 | test("calculate amount limit", () => { 15 | const amount = new BN(80017351) 16 | const byAmountIn = true 17 | 18 | const amountLimit = CalculateAmountLimit(amount, byAmountIn, 0.01) 19 | console.log("amount limit", amountLimit.toString()) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /tests/wallet.test.ts: -------------------------------------------------------------------------------- 1 | import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519" 2 | 3 | describe("router module", () => { 4 | const keystoreSecret = [ 5 | "0xd36441c734b1967dd4e65956d0b3e7e5dccc8c92306ad71419e6741b4a7ce6c9", 6 | ] 7 | 8 | test("Parse public key", () => { 9 | for (const secret of keystoreSecret) { 10 | const byte = Buffer.from(secret, "base64") 11 | const u8Array = new Uint8Array(byte) 12 | const keypair = Ed25519Keypair.fromSecretKey(u8Array.slice(1, 33)) 13 | console.log( 14 | "\nsecret:", 15 | secret, 16 | "\nkeypair public key: ", 17 | keypair.toSuiAddress() 18 | ) 19 | } 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | // tsconfig.json 2 | { 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "commonjs", 6 | "strict": true, 7 | "esModuleInterop": true, 8 | "skipLibCheck": true, 9 | "rootDir": "./", 10 | "baseUrl": ".", 11 | "paths": { 12 | "~/*": ["src/*"] 13 | }, 14 | "allowJs": true, 15 | "outDir": "dist/", 16 | }, 17 | "include": ["src", "tests"], 18 | "exclude": [ 19 | "node_modules/**/*", 20 | "dist/**/*", 21 | ], 22 | } 23 | -------------------------------------------------------------------------------- /tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | import { exec } from 'child_process' 3 | 4 | export default defineConfig((options) => ({ 5 | entry: { 6 | index: './src/index.ts', 7 | }, 8 | format: ['esm', 'cjs'], 9 | dts: false, 10 | clean: !options.watch, 11 | treeshake: true, 12 | splitting: true, 13 | onSuccess: async () => { 14 | exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => { 15 | if (err) { 16 | console.error(stdout) 17 | if (!options.watch) { 18 | process.exit(1) 19 | } 20 | } 21 | }) 22 | }, 23 | })) 24 | -------------------------------------------------------------------------------- /version.mjs: -------------------------------------------------------------------------------- 1 | // Don't sync to github 2 | 3 | import fs from 'fs'; 4 | 5 | const packageJsonPath = './package.json'; 6 | const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); 7 | 8 | const newVersion = `0.0.0-experimental-${getCurrentDateTimeString()}`; 9 | packageJson.version = newVersion; 10 | 11 | fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8'); 12 | 13 | console.log(`Version updated to ${newVersion}`); 14 | 15 | function getCurrentDateTimeString() { 16 | const now = new Date(); 17 | 18 | const year = now.getFullYear(); 19 | const month = String(now.getMonth() + 1).padStart(2, '0'); 20 | const day = String(now.getDate()).padStart(2, '0'); 21 | const hours = String(now.getHours()).padStart(2, '0'); 22 | const minutes = String(now.getMinutes()).padStart(2, '0'); 23 | const seconds = String(now.getSeconds()).padStart(2, '0'); 24 | 25 | const dateTimeString = `${year}${month}${day}${hours}${minutes}${seconds}`; 26 | 27 | return dateTimeString; 28 | } 29 | --------------------------------------------------------------------------------