├── .prettierignore ├── vercel.json ├── src ├── index.ts ├── consts │ ├── index.ts │ └── price.ts ├── utils │ ├── index.ts │ ├── transaction.ts │ └── resolvers.ts ├── _generated │ ├── bucket_v2_cdp │ │ ├── witness.ts │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── coin.ts │ │ │ │ ├── vec_set.ts │ │ │ │ └── vec_map.ts │ │ │ ├── bucket_v2_framework │ │ │ │ ├── float.ts │ │ │ │ ├── double.ts │ │ │ │ ├── liability.ts │ │ │ │ ├── sheet.ts │ │ │ │ └── linked_table.ts │ │ │ ├── bucket_v2_usd │ │ │ │ └── limited_supply.ts │ │ │ └── std │ │ │ │ └── type_name.ts │ │ ├── version.ts │ │ ├── acl.ts │ │ ├── memo.ts │ │ ├── events.ts │ │ ├── response.ts │ │ └── request.ts │ ├── bucket_v2_psm │ │ ├── witness.ts │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── vec_set.ts │ │ │ │ └── vec_map.ts │ │ │ ├── bucket_v2_framework │ │ │ │ ├── float.ts │ │ │ │ ├── liability.ts │ │ │ │ └── sheet.ts │ │ │ └── std │ │ │ │ └── type_name.ts │ │ ├── version.ts │ │ ├── memo.ts │ │ └── events.ts │ ├── bucket_v2_flash │ │ ├── witness.ts │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ └── vec_map.ts │ │ │ └── bucket_v2_framework │ │ │ │ └── float.ts │ │ ├── memo.ts │ │ ├── version.ts │ │ ├── events.ts │ │ └── config.ts │ ├── bucket_v2_saving │ │ ├── witness.ts │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── vec_set.ts │ │ │ │ └── table.ts │ │ │ ├── bucket_v2_framework │ │ │ │ └── double.ts │ │ │ └── std │ │ │ │ └── type_name.ts │ │ ├── version.ts │ │ └── events.ts │ ├── bucket_v2_framework │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── vec_set.ts │ │ │ │ └── vec_map.ts │ │ │ └── std │ │ │ │ └── type_name.ts │ │ ├── account.ts │ │ └── liability.ts │ ├── bucket_v2_borrow_incentive │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── coin.ts │ │ │ │ ├── vec_set.ts │ │ │ │ └── table.ts │ │ │ ├── bucket_v2_framework │ │ │ │ └── double.ts │ │ │ ├── bucket_v2_cdp │ │ │ │ └── request.ts │ │ │ └── std │ │ │ │ └── type_name.ts │ │ └── borrow_incentive_events.ts │ ├── bucket_v2_saving_incentive │ │ ├── deps │ │ │ ├── sui │ │ │ │ ├── object.ts │ │ │ │ ├── balance.ts │ │ │ │ ├── vec_set.ts │ │ │ │ ├── table.ts │ │ │ │ ├── vec_map.ts │ │ │ │ └── dynamic_field.ts │ │ │ ├── bucket_v2_framework │ │ │ │ └── double.ts │ │ │ ├── std │ │ │ │ └── type_name.ts │ │ │ └── bucket_v2_saving │ │ │ │ └── saving.ts │ │ ├── memo.ts │ │ ├── saving_incentive_events.ts │ │ └── incentive_config.ts │ └── utils │ │ └── index.ts └── types │ ├── index.ts │ └── config.ts ├── .vscode └── settings.json ├── tsconfig.types.json ├── tsconfig.cjs.json ├── tsconfig.esm.json ├── vitest.config.ts ├── .gitignore ├── .github └── workflows │ ├── auto-merge.yml │ ├── check-secrets.yml │ ├── lint.yml │ ├── unit-test.yml │ ├── remove-stale-branches.yml │ ├── publish-test.yml │ └── publish.yml ├── prettier.config.js ├── tsconfig.json ├── eslint.config.js ├── package.json ├── LICENSE └── test └── e2e └── client.test.ts /.prettierignore: -------------------------------------------------------------------------------- 1 | README.md 2 | node_modules 3 | cache 4 | coverage* 5 | dist 6 | .turbo 7 | src/_generated 8 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "git": { 3 | "deploymentEnabled": { 4 | "main": false 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from '@/client.js'; 2 | export * from '@/types/index.js'; 3 | export * from '@/utils/index.js'; 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.fixAll.eslint": "explicit" 4 | }, 5 | "editor.defaultFormatter": "esbenp.prettier-vscode", 6 | "editor.formatOnSave": true, 7 | "editor.tabSize": 2 8 | } 9 | -------------------------------------------------------------------------------- /src/consts/index.ts: -------------------------------------------------------------------------------- 1 | import { normalizeSuiAddress } from '@mysten/sui/utils'; 2 | 3 | export * from './config.js'; 4 | 5 | export const DUMMY_ADDRESS = normalizeSuiAddress('0x0'); 6 | 7 | export const FLOAT_OFFSET = 10n ** 9n; 8 | export const DOUBLE_OFFSET = 10n ** 18n; 9 | -------------------------------------------------------------------------------- /tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/types", 5 | "module": "nodenext", 6 | "moduleResolution": "nodenext", 7 | "noEmit": false, 8 | "declaration": true, 9 | "emitDeclarationOnly": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.cjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/cjs", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "noEmit": false, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.esm.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/esm", 5 | "module": "esnext", 6 | "moduleResolution": "bundler", 7 | "noEmit": false, 8 | "declaration": true, 9 | "declarationMap": true, 10 | "sourceMap": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transaction.js'; 2 | 3 | export function splitIntoChunks(arr: T[], chunkSize: number): T[][] { 4 | const result: T[][] = []; 5 | 6 | for (let i = 0; i < arr.length; i += chunkSize) { 7 | const chunk = arr.slice(i, i + chunkSize); 8 | result.push(chunk); 9 | } 10 | return result; 11 | } 12 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import { defineConfig } from 'vitest/config'; 3 | 4 | export default defineConfig({ 5 | resolve: { 6 | alias: { 7 | '@': path.resolve(__dirname, './src'), 8 | }, 9 | }, 10 | test: { 11 | include: ['./test/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | /.pnp 4 | .pnp.js 5 | .yarn/install-state.gz 6 | 7 | # testing 8 | /coverage 9 | dummy.test.ts 10 | 11 | # build 12 | .turbo 13 | dist 14 | 15 | # misc 16 | .DS_Store 17 | *.pem 18 | 19 | # debug 20 | npm-debug.log* 21 | yarn-debug.log* 22 | yarn-error.log* 23 | 24 | # local env files 25 | .env*.local 26 | .env.development 27 | .env 28 | 29 | # nvm 30 | .nvmrc 31 | CLAUDE.md 32 | .claude/settings.local.json 33 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/witness.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_cdp::witness'; 7 | export const BucketV2CDP = new MoveStruct({ name: `${$moduleName}::BucketV2CDP`, fields: { 8 | dummy_field: bcs.bool() 9 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/witness.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_psm::witness'; 7 | export const BucketV2PSM = new MoveStruct({ name: `${$moduleName}::BucketV2PSM`, fields: { 8 | dummy_field: bcs.bool() 9 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/witness.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_flash::witness'; 7 | export const BucketV2Flash = new MoveStruct({ name: `${$moduleName}::BucketV2Flash`, fields: { 8 | dummy_field: bcs.bool() 9 | } }); -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Enable auto-merge for PRs 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | enable-auto-merge: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Enable auto-merge for PRs 17 | run: gh pr merge --auto --squash "$PR_URL" 18 | env: 19 | PR_URL: ${{ github.event.pull_request.html_url }} 20 | GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }} 21 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/witness.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_saving::witness'; 7 | export const BucketV2Saving = new MoveStruct({ name: `${$moduleName}::BucketV2Saving`, fields: { 8 | dummy_field: bcs.bool() 9 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/object.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Sui object identifiers */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = '0x2::object'; 11 | export const UID = new MoveStruct({ name: `${$moduleName}::UID`, fields: { 12 | id: bcs.Address 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_framework/float.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::float'; 11 | export const Float = new MoveStruct({ name: `${$moduleName}::Float`, fields: { 12 | value: bcs.u128() 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/deps/bucket_v2_framework/float.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::float'; 11 | export const Float = new MoveStruct({ name: `${$moduleName}::Float`, fields: { 12 | value: bcs.u128() 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/bucket_v2_framework/float.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::float'; 11 | export const Float = new MoveStruct({ name: `${$moduleName}::Float`, fields: { 12 | value: bcs.u128() 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_framework/double.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for double precision floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::double'; 11 | export const Double = new MoveStruct({ name: `${$moduleName}::Double`, fields: { 12 | value: bcs.u256() 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/bucket_v2_framework/double.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for double precision floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::double'; 11 | export const Double = new MoveStruct({ name: `${$moduleName}::Double`, fields: { 12 | value: bcs.u256() 13 | } }); -------------------------------------------------------------------------------- /.github/workflows/check-secrets.yml: -------------------------------------------------------------------------------- 1 | name: Check Secrets 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | check-secrets: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v5 14 | - name: Install pnpm 15 | uses: pnpm/action-setup@v4 16 | - name: Setup Node 17 | uses: actions/setup-node@v5 18 | with: 19 | node-version: 20 20 | - name: Install Git Secrets 21 | run: sudo apt-get install git-secrets 22 | - name: Scan for secrets 23 | run: git secrets --scan 24 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/bucket_v2_framework/double.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for double precision floating points */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::double'; 11 | export const Double = new MoveStruct({ name: `${$moduleName}::Double`, fields: { 12 | value: bcs.u256() 13 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/bucket_v2_framework/double.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | /** Module for double precision floating points */ 6 | 7 | import { bcs } from '@mysten/sui/bcs'; 8 | 9 | import { MoveStruct } from '../../../utils/index.js'; 10 | 11 | const $moduleName = 'bucket_v2_framework::double'; 12 | export const Double = new MoveStruct({ 13 | name: `${$moduleName}::Double`, 14 | fields: { 15 | value: bcs.u256(), 16 | }, 17 | }); 18 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | pull-requests: write 11 | issues: write 12 | 13 | jobs: 14 | lint: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v5 19 | - name: Install pnpm 20 | uses: pnpm/action-setup@v4 21 | - name: Setup Node 22 | uses: actions/setup-node@v5 23 | with: 24 | node-version: 20 25 | cache: 'pnpm' 26 | - name: Install Dependencies 27 | run: pnpm install --frozen-lockfile 28 | - name: Run ESLint 29 | run: pnpm lint 30 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/memo.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface FlashMintOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | export function flashMint(options: FlashMintOptions = {}) { 11 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 12 | return (tx: Transaction) => tx.moveCall({ 13 | package: packageAddress, 14 | module: 'memo', 15 | function: 'flash_mint', 16 | }); 17 | } -------------------------------------------------------------------------------- /.github/workflows/unit-test.yml: -------------------------------------------------------------------------------- 1 | name: E2E test 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | pull-requests: write 11 | issues: write 12 | 13 | jobs: 14 | e2e-test: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v5 19 | - name: Install pnpm 20 | uses: pnpm/action-setup@v4 21 | - name: Setup Node 22 | uses: actions/setup-node@v5 23 | with: 24 | node-version: 20 25 | cache: 'pnpm' 26 | - name: Install Dependencies 27 | run: pnpm install --frozen-lockfile 28 | - name: Run E2E test 29 | run: pnpm test 30 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/memo.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | 6 | export interface SavingPoolOptions { 7 | package?: string; 8 | arguments?: []; 9 | } 10 | export function savingPool(options: SavingPoolOptions = {}) { 11 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 12 | return (tx: Transaction) => 13 | tx.moveCall({ 14 | package: packageAddress, 15 | module: 'memo', 16 | function: 'saving_pool', 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_framework/liability.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for managing Credit and Debt for DeFi protocol usage */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::liability'; 11 | export const Credit = new MoveStruct({ name: `${$moduleName}::Credit`, fields: { 12 | value: bcs.u64() 13 | } }); 14 | export const Debt = new MoveStruct({ name: `${$moduleName}::Debt`, fields: { 15 | value: bcs.u64() 16 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/bucket_v2_framework/liability.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for managing Credit and Debt for DeFi protocol usage */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'bucket_v2_framework::liability'; 11 | export const Credit = new MoveStruct({ name: `${$moduleName}::Credit`, fields: { 12 | value: bcs.u64() 13 | } }); 14 | export const Debt = new MoveStruct({ name: `${$moduleName}::Debt`, fields: { 15 | value: bcs.u64() 16 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/version.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface PackageVersionOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | /** Public Funs */ 11 | export function packageVersion(options: PackageVersionOptions = {}) { 12 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 13 | return (tx: Transaction) => tx.moveCall({ 14 | package: packageAddress, 15 | module: 'version', 16 | function: 'package_version', 17 | }); 18 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/version.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface PackageVersionOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | /** Public Funs */ 11 | export function packageVersion(options: PackageVersionOptions = {}) { 12 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 13 | return (tx: Transaction) => tx.moveCall({ 14 | package: packageAddress, 15 | module: 'version', 16 | function: 'package_version', 17 | }); 18 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/version.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface PackageVersionOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | /** Public Funs */ 11 | export function packageVersion(options: PackageVersionOptions = {}) { 12 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_psm'; 13 | return (tx: Transaction) => tx.moveCall({ 14 | package: packageAddress, 15 | module: 'version', 16 | function: 'package_version', 17 | }); 18 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/version.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface PackageVersionOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | /** Public Funs */ 11 | export function packageVersion(options: PackageVersionOptions = {}) { 12 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_saving'; 13 | return (tx: Transaction) => tx.moveCall({ 14 | package: packageAddress, 15 | module: 'version', 16 | function: 'package_version', 17 | }); 18 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/sui/coin.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * Defines the `Coin` type - platform wide representation of fungible tokens and 8 | * coins. `Coin` can be described as a secure wrapper around `Balance` type. 9 | */ 10 | 11 | import { MoveStruct } from '../../../utils/index.js'; 12 | import * as object from './object.js'; 13 | import * as balance from './balance.js'; 14 | const $moduleName = '0x2::coin'; 15 | export const Coin = new MoveStruct({ name: `${$moduleName}::Coin`, fields: { 16 | id: object.UID, 17 | balance: balance.Balance 18 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/sui/coin.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * Defines the `Coin` type - platform wide representation of fungible tokens and 8 | * coins. `Coin` can be described as a secure wrapper around `Balance` type. 9 | */ 10 | 11 | import { MoveStruct } from '../../../utils/index.js'; 12 | import * as object from './object.js'; 13 | import * as balance from './balance.js'; 14 | const $moduleName = '0x2::coin'; 15 | export const Coin = new MoveStruct({ name: `${$moduleName}::Coin`, fields: { 16 | id: object.UID, 17 | balance: balance.Balance 18 | } }); -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('prettier').Config} */ 2 | const config = { 3 | endOfLine: 'lf', 4 | semi: true, 5 | singleQuote: true, 6 | tabWidth: 2, 7 | trailingComma: 'all', 8 | bracketSpacing: true, 9 | bracketSameLine: false, 10 | arrowParens: 'always', 11 | singleAttributePerLine: true, 12 | printWidth: 120, 13 | importOrder: [ 14 | '', 15 | '', 16 | '^@/((?!(types|consts|structs|utils|_generated)).*)$', 17 | '^@/types(.*)$', 18 | '^@/consts(.*)$', 19 | '^@/structs(.*)$', 20 | '^@/utils(.*)$', 21 | '', 22 | '^@/_generated/(.*)$', 23 | '', 24 | '^[./]', 25 | '^[../]', 26 | ], 27 | importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], 28 | plugins: ['@ianvs/prettier-plugin-sort-imports'], 29 | }; 30 | 31 | export default config; 32 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/sui/balance.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A storable handler for Balances in general. Is used in the `Coin` module to 8 | * allow balance operations and can be used to implement custom coins with `Supply` 9 | * and `Balance`s. 10 | */ 11 | 12 | import { MoveStruct } from '../../../utils/index.js'; 13 | import { bcs } from '@mysten/sui/bcs'; 14 | const $moduleName = '0x2::balance'; 15 | export const Balance = new MoveStruct({ name: `${$moduleName}::Balance`, fields: { 16 | value: bcs.u64() 17 | } }); 18 | export const Supply = new MoveStruct({ name: `${$moduleName}::Supply`, fields: { 19 | value: bcs.u64() 20 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_usd/limited_supply.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * Module for managing a limited supply of tokens or assets. Provides functionality 8 | * to create, increase, decrease, and destroy a supply with an upper limit. 9 | */ 10 | 11 | import { MoveStruct } from '../../../utils/index.js'; 12 | import { bcs } from '@mysten/sui/bcs'; 13 | const $moduleName = 'bucket_v2_usd::limited_supply'; 14 | export const LimitedSupply = new MoveStruct({ name: `${$moduleName}::LimitedSupply`, fields: { 15 | /** The maximum allowed supply. */ 16 | limit: bcs.u64(), 17 | /** The current supply. */ 18 | supply: bcs.u64() 19 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_flash::events'; 7 | export const UpdateFlashMintConfig = new MoveStruct({ name: `${$moduleName}::UpdateFlashMintConfig`, fields: { 8 | config_id: bcs.Address, 9 | partner_address: bcs.option(bcs.Address), 10 | fee_rate_bps: bcs.u64(), 11 | max_amount: bcs.u64() 12 | } }); 13 | export const FlashMint = new MoveStruct({ name: `${$moduleName}::FlashMint`, fields: { 14 | partner_address: bcs.option(bcs.Address), 15 | value: bcs.u64(), 16 | fee_amount: bcs.u64() 17 | } }); -------------------------------------------------------------------------------- /.github/workflows/remove-stale-branches.yml: -------------------------------------------------------------------------------- 1 | name: Remove Stale Branches 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * 1' 6 | workflow_dispatch: 7 | inputs: 8 | dryrun: 9 | description: 'Dryrun' 10 | required: true 11 | type: boolean 12 | default: false 13 | 14 | permissions: 15 | pull-requests: write 16 | contents: write 17 | issues: write 18 | 19 | jobs: 20 | remove-stale-branches: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Remove stale branches 24 | uses: crs-k/stale-branches@v7.0.0 25 | with: 26 | repo-token: '${{ secrets.GITHUB_TOKEN }}' 27 | days-before-stale: 60 28 | days-before-delete: 90 29 | max-issues: 100 30 | stale-branch-label: 'stale' 31 | pr-check: true 32 | dry-run: ${{ inputs.dryrun }} 33 | ignore-issue-interaction: true 34 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Base Options: */ 4 | "target": "esnext", 5 | "esModuleInterop": true, 6 | "allowSyntheticDefaultImports": true, 7 | "skipLibCheck": true, 8 | "allowJs": false, 9 | "resolveJsonModule": true, 10 | "moduleDetection": "force", 11 | "isolatedModules": true, 12 | 13 | /* Strictness */ 14 | "strict": true, 15 | "noUncheckedIndexedAccess": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "forceConsistentCasingInFileNames": true, 21 | 22 | /* Bundled projects */ 23 | "lib": ["esnext"], 24 | "module": "nodenext", 25 | "moduleResolution": "nodenext", 26 | "noEmit": true, 27 | 28 | /* Path Aliases */ 29 | "rootDir": "./src", 30 | "baseUrl": ".", 31 | "paths": { 32 | "@/*": ["./src/*"] 33 | } 34 | }, 35 | "include": ["src"], 36 | "exclude": ["node_modules", "dist"] 37 | } 38 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_framework/sheet.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for the record of Credit and Debt of certain entity */ 7 | 8 | import { MoveTuple, MoveStruct } from '../../../utils/index.js'; 9 | import * as type_name from '../std/type_name.js'; 10 | import * as vec_map from '../sui/vec_map.js'; 11 | import * as liability from './liability.js'; 12 | import * as vec_set from '../sui/vec_set.js'; 13 | const $moduleName = 'bucket_v2_framework::sheet'; 14 | export const Entity = new MoveTuple({ name: `${$moduleName}::Entity`, fields: [type_name.TypeName] }); 15 | export const Sheet = new MoveStruct({ name: `${$moduleName}::Sheet`, fields: { 16 | credits: vec_map.VecMap(Entity, liability.Credit), 17 | debts: vec_map.VecMap(Entity, liability.Debt), 18 | blacklist: vec_set.VecSet(Entity) 19 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/bucket_v2_framework/sheet.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for the record of Credit and Debt of certain entity */ 7 | 8 | import { MoveTuple, MoveStruct } from '../../../utils/index.js'; 9 | import * as type_name from '../std/type_name.js'; 10 | import * as vec_map from '../sui/vec_map.js'; 11 | import * as liability from './liability.js'; 12 | import * as vec_set from '../sui/vec_set.js'; 13 | const $moduleName = 'bucket_v2_framework::sheet'; 14 | export const Entity = new MoveTuple({ name: `${$moduleName}::Entity`, fields: [type_name.TypeName] }); 15 | export const Sheet = new MoveStruct({ name: `${$moduleName}::Sheet`, fields: { 16 | credits: vec_map.VecMap(Entity, liability.Credit), 17 | debts: vec_map.VecMap(Entity, liability.Debt), 18 | blacklist: vec_set.VecSet(Entity) 19 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/bucket_v2_cdp/request.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for handling requests in the BucketV2 CDP system. */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | import * as coin from '../sui/coin.js'; 11 | import * as vec_set from '../sui/vec_set.js'; 12 | import * as type_name from '../std/type_name.js'; 13 | const $moduleName = 'bucket_v2_cdp::request'; 14 | export const UpdateRequest = new MoveStruct({ name: `${$moduleName}::UpdateRequest`, fields: { 15 | vault_id: bcs.Address, 16 | account: bcs.Address, 17 | deposit: coin.Coin, 18 | borrow_amount: bcs.u64(), 19 | repayment: coin.Coin, 20 | withdraw_amount: bcs.u64(), 21 | witnesses: vec_set.VecSet(type_name.TypeName), 22 | memo: bcs.string() 23 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /.github/workflows/publish-test.yml: -------------------------------------------------------------------------------- 1 | name: Publish test package 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | pre-release-tag: 7 | description: 'Pre-release tag' 8 | required: true 9 | default: 'dev' 10 | type: string 11 | 12 | permissions: 13 | contents: write 14 | id-token: write 15 | 16 | jobs: 17 | publish: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v5 22 | - name: Install pnpm 23 | uses: pnpm/action-setup@v4 24 | - name: Setup Node 25 | uses: actions/setup-node@v5 26 | with: 27 | node-version: 20 28 | registry-url: 'https://registry.npmjs.org/' 29 | cache: 'pnpm' 30 | - name: Install Dependencies 31 | run: pnpm install --frozen-lockfile 32 | - name: Compile 33 | run: pnpm build 34 | - name: Bump & publish package 35 | run: pnpm version prerelease --preid ${{ inputs.pre-release-tag }} --no-git-tag-version && pnpm publish --access public --tag dev --no-git-checks 36 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/vec_set.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_set'; 7 | /** 8 | * A set data structure backed by a vector. The set is guaranteed not to contain 9 | * duplicate keys. All operations are O(N) in the size of the set 10 | * 11 | * - the intention of this data structure is only to provide the convenience of 12 | * programming against a set API. Sets that need sorted iteration rather than 13 | * insertion order iteration should be handwritten. 14 | */ 15 | export function VecSet>(...typeParameters: [ 16 | K 17 | ]) { 18 | return new MoveStruct({ name: `${$moduleName}::VecSet<${typeParameters[0].name as K['name']}>`, fields: { 19 | contents: bcs.vector(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/memo.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface SwapInOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | export function swapIn(options: SwapInOptions = {}) { 11 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_psm'; 12 | return (tx: Transaction) => tx.moveCall({ 13 | package: packageAddress, 14 | module: 'memo', 15 | function: 'swap_in', 16 | }); 17 | } 18 | export interface SwapOutOptions { 19 | package?: string; 20 | arguments?: [ 21 | ]; 22 | } 23 | export function swapOut(options: SwapOutOptions = {}) { 24 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_psm'; 25 | return (tx: Transaction) => tx.moveCall({ 26 | package: packageAddress, 27 | module: 'memo', 28 | function: 'swap_out', 29 | }); 30 | } -------------------------------------------------------------------------------- /src/consts/price.ts: -------------------------------------------------------------------------------- 1 | import { SharedObjectRef } from '@/types/index.js'; 2 | 3 | export const SCOIN_RULE_CONFIG: SharedObjectRef = { 4 | objectId: '0xe5a7b5c2a17811b03a48b9fa277319ffe4e629ce93b862c08fed71fb11b27618', 5 | initialSharedVersion: 610893718, 6 | mutable: false, 7 | }; 8 | 9 | export const SCALLOP_VERSION: SharedObjectRef = { 10 | objectId: '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7', 11 | initialSharedVersion: 7765848, 12 | mutable: false, 13 | }; 14 | 15 | export const SCALLOP_MARKET: SharedObjectRef = { 16 | objectId: '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9', 17 | initialSharedVersion: 7765848, 18 | mutable: true, 19 | }; 20 | 21 | export const GCOIN_RULE_CONFIG: SharedObjectRef = { 22 | objectId: '0x6466f287d8864c56de1459ad294907d2a06767e9589ae953cc5e0f009fc1cfd7', 23 | initialSharedVersion: 610893721, 24 | mutable: false, 25 | }; 26 | 27 | export const UNIHOUSE_OBJECT: SharedObjectRef = { 28 | objectId: '0x75c63644536b1a7155d20d62d9f88bf794dc847ea296288ddaf306aa320168ab', 29 | initialSharedVersion: 333730283, 30 | mutable: false, 31 | }; 32 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/bucket_v2_framework/linked_table.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | import * as object from '../sui/object.js'; 7 | const $moduleName = 'bucket_v2_framework::linked_table'; 8 | export function LinkedTable>(...typeParameters: [ 9 | K 10 | ]) { 11 | return new MoveStruct({ name: `${$moduleName}::LinkedTable<${typeParameters[0].name as K['name']}>`, fields: { 12 | /** the ID of this table */ 13 | id: object.UID, 14 | /** the number of key-value pairs in the table */ 15 | size: bcs.u64(), 16 | /** the front of the table, i.e. the key of the first entry */ 17 | head: bcs.option(typeParameters[0]), 18 | /** the back of the table, i.e. the key of the last entry */ 19 | tail: bcs.option(typeParameters[0]) 20 | } }); 21 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_psm::events'; 7 | export const NewPsmPool = new MoveStruct({ name: `${$moduleName}::NewPsmPool`, fields: { 8 | pool_id: bcs.Address, 9 | coin_type: bcs.string(), 10 | decimal: bcs.u8(), 11 | swap_in_fee_bps: bcs.u64(), 12 | swap_out_fee_bps: bcs.u64() 13 | } }); 14 | export const PsmSwapIn = new MoveStruct({ name: `${$moduleName}::PsmSwapIn`, fields: { 15 | asset_type: bcs.string(), 16 | asset_in_amount: bcs.u64(), 17 | asset_balance: bcs.u64(), 18 | usdb_out_amount: bcs.u64(), 19 | usdb_supply: bcs.u64() 20 | } }); 21 | export const PsmSwapOut = new MoveStruct({ name: `${$moduleName}::PsmSwapOut`, fields: { 22 | usdb_in_amount: bcs.u64(), 23 | usdb_supply: bcs.u64(), 24 | asset_type: bcs.string(), 25 | asset_out_amount: bcs.u64(), 26 | asset_balance: bcs.u64() 27 | } }); -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import { fileURLToPath } from 'node:url'; 3 | import { FlatCompat } from '@eslint/eslintrc'; 4 | import js from '@eslint/js'; 5 | import tsParser from '@typescript-eslint/parser'; 6 | import unusedImports from 'eslint-plugin-unused-imports'; 7 | 8 | const __filename = fileURLToPath(import.meta.url); 9 | const __dirname = path.dirname(__filename); 10 | const compat = new FlatCompat({ 11 | baseDirectory: __dirname, 12 | recommendedConfig: js.configs.recommended, 13 | allConfig: js.configs.all, 14 | }); 15 | 16 | const config = [ 17 | { 18 | ignores: ['dist', '.turbo', 'artifacts', 'cache', 'coverage*', 'src/_generated'], 19 | }, 20 | ...compat.extends('plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'), 21 | { 22 | plugins: { 23 | 'unused-imports': unusedImports, 24 | }, 25 | languageOptions: { 26 | parser: tsParser, 27 | }, 28 | rules: { 29 | eqeqeq: 'error', 30 | 'no-console': ['error', { allow: ['error'] }], 31 | '@typescript-eslint/no-unused-vars': 'off', 32 | 'unused-imports/no-unused-imports': 'error', 33 | 'unused-imports/no-unused-vars': 'error', 34 | }, 35 | }, 36 | ]; 37 | 38 | export default config; 39 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/std/type_name.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Functionality for converting Move types into values. Use with care! */ 7 | 8 | import { MoveStruct } from '../../../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | const $moduleName = 'std::type_name'; 11 | export const TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: { 12 | /** 13 | * String representation of the type. All types are represented using their source 14 | * syntax: "u8", "u64", "bool", "address", "vector", and so on for primitive types. 15 | * Struct types are represented as fully qualified type names; e.g. 16 | * `00000000000000000000000000000001::string::String` or 17 | * `0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2>` 18 | * Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 19 | * 32 depending on the Move platform) 20 | */ 21 | name: bcs.string() 22 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_saving::events'; 7 | export const NewSavingPoolEvent = new MoveStruct({ name: `${$moduleName}::NewSavingPoolEvent`, fields: { 8 | saving_pool_id: bcs.Address 9 | } }); 10 | export const UpdateSavingRateEvent = new MoveStruct({ name: `${$moduleName}::UpdateSavingRateEvent`, fields: { 11 | saving_pool_id: bcs.Address, 12 | saving_rate_bps: bcs.u64() 13 | } }); 14 | export const DepositEvent = new MoveStruct({ name: `${$moduleName}::DepositEvent`, fields: { 15 | saving_pool_id: bcs.Address, 16 | account_address: bcs.Address, 17 | deposited_usdb_amount: bcs.u64(), 18 | minted_lp_amount: bcs.u64() 19 | } }); 20 | export const WithdrawEvent = new MoveStruct({ name: `${$moduleName}::WithdrawEvent`, fields: { 21 | saving_pool_id: bcs.Address, 22 | account_address: bcs.Address, 23 | burned_lp_amount: bcs.u64(), 24 | withdrawal_usdb_amount: bcs.u64() 25 | } }); 26 | export const InterestEmittedEvent = new MoveStruct({ name: `${$moduleName}::InterestEmittedEvent`, fields: { 27 | saving_pool_id: bcs.Address, 28 | interest_amount: bcs.u64() 29 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving/deps/sui/table.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A table is a map-like collection. But unlike a traditional collection, it's keys 8 | * and values are not stored within the `Table` value, but instead are stored using 9 | * Sui's object system. The `Table` struct acts only as a handle into the object 10 | * system to retrieve those keys and values. Note that this means that `Table` 11 | * values with exactly the same key-value mapping will not be equal, with `==`, at 12 | * runtime. For example 13 | * 14 | * ``` 15 | * let table1 = table::new(); 16 | * let table2 = table::new(); 17 | * table::add(&mut table1, 0, false); 18 | * table::add(&mut table1, 1, true); 19 | * table::add(&mut table2, 0, false); 20 | * table::add(&mut table2, 1, true); 21 | * // table1 does not equal table2, despite having the same entries 22 | * assert!(&table1 != &table2); 23 | * ``` 24 | */ 25 | 26 | import { MoveStruct } from '../../../utils/index.js'; 27 | import { bcs } from '@mysten/sui/bcs'; 28 | import * as object from './object.js'; 29 | const $moduleName = '0x2::table'; 30 | export const Table = new MoveStruct({ name: `${$moduleName}::Table`, fields: { 31 | /** the ID of this table */ 32 | id: object.UID, 33 | /** the number of key-value pairs in the table */ 34 | size: bcs.u64() 35 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/deps/sui/table.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A table is a map-like collection. But unlike a traditional collection, it's keys 8 | * and values are not stored within the `Table` value, but instead are stored using 9 | * Sui's object system. The `Table` struct acts only as a handle into the object 10 | * system to retrieve those keys and values. Note that this means that `Table` 11 | * values with exactly the same key-value mapping will not be equal, with `==`, at 12 | * runtime. For example 13 | * 14 | * ``` 15 | * let table1 = table::new(); 16 | * let table2 = table::new(); 17 | * table::add(&mut table1, 0, false); 18 | * table::add(&mut table1, 1, true); 19 | * table::add(&mut table2, 0, false); 20 | * table::add(&mut table2, 1, true); 21 | * // table1 does not equal table2, despite having the same entries 22 | * assert!(&table1 != &table2); 23 | * ``` 24 | */ 25 | 26 | import { MoveStruct } from '../../../utils/index.js'; 27 | import { bcs } from '@mysten/sui/bcs'; 28 | import * as object from './object.js'; 29 | const $moduleName = '0x2::table'; 30 | export const Table = new MoveStruct({ name: `${$moduleName}::Table`, fields: { 31 | /** the ID of this table */ 32 | id: object.UID, 33 | /** the number of key-value pairs in the table */ 34 | size: bcs.u64() 35 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/table.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * A table is a map-like collection. But unlike a traditional collection, it's keys 8 | * and values are not stored within the `Table` value, but instead are stored using 9 | * Sui's object system. The `Table` struct acts only as a handle into the object 10 | * system to retrieve those keys and values. Note that this means that `Table` 11 | * values with exactly the same key-value mapping will not be equal, with `==`, at 12 | * runtime. For example 13 | * 14 | * ``` 15 | * let table1 = table::new(); 16 | * let table2 = table::new(); 17 | * table::add(&mut table1, 0, false); 18 | * table::add(&mut table1, 1, true); 19 | * table::add(&mut table2, 0, false); 20 | * table::add(&mut table2, 1, true); 21 | * // table1 does not equal table2, despite having the same entries 22 | * assert!(&table1 != &table2); 23 | * ``` 24 | */ 25 | 26 | import { MoveStruct } from '../../../utils/index.js'; 27 | import { bcs } from '@mysten/sui/bcs'; 28 | import * as object from './object.js'; 29 | const $moduleName = '0x2::table'; 30 | export const Table = new MoveStruct({ name: `${$moduleName}::Table`, fields: { 31 | /** the ID of this table */ 32 | id: object.UID, 33 | /** the number of key-value pairs in the table */ 34 | size: bcs.u64() 35 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_borrow_incentive/borrow_incentive_events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | const $moduleName = '@local-pkg/bucket_v2_borrow_incentive::borrow_incentive_events'; 7 | export const RewarderCreated = new MoveStruct({ name: `${$moduleName}::RewarderCreated`, fields: { 8 | vault_id: bcs.Address, 9 | rewarder_id: bcs.Address, 10 | asset_type: bcs.string(), 11 | reward_type: bcs.string(), 12 | start_timestamp: bcs.u64(), 13 | flow_rate: bcs.u256() 14 | } }); 15 | export const SourceChanged = new MoveStruct({ name: `${$moduleName}::SourceChanged`, fields: { 16 | rewarder_id: bcs.Address, 17 | reward_type: bcs.string(), 18 | amount: bcs.u64(), 19 | is_deposit: bcs.bool() 20 | } }); 21 | export const FlowRateChanged = new MoveStruct({ name: `${$moduleName}::FlowRateChanged`, fields: { 22 | rewarder_id: bcs.Address, 23 | asset_type: bcs.string(), 24 | reward_type: bcs.string(), 25 | flow_rate: bcs.u256() 26 | } }); 27 | export const ClaimReward = new MoveStruct({ name: `${$moduleName}::ClaimReward`, fields: { 28 | rewarder_id: bcs.Address, 29 | account: bcs.Address, 30 | asset_type: bcs.string(), 31 | reward_type: bcs.string(), 32 | amount: bcs.u64() 33 | } }); -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/acl.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Vault module for assigning managers for each security level */ 7 | 8 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | import { type Transaction } from '@mysten/sui/transactions'; 11 | import * as vec_map from './deps/sui/vec_map.js'; 12 | const $moduleName = '@local-pkg/bucket_v2_cdp::acl'; 13 | export const Acl = new MoveStruct({ name: `${$moduleName}::Acl`, fields: { 14 | managers: vec_map.VecMap(bcs.Address, bcs.u8()) 15 | } }); 16 | export interface RoleLevelArguments { 17 | self: RawTransactionArgument; 18 | manager: RawTransactionArgument; 19 | } 20 | export interface RoleLevelOptions { 21 | package?: string; 22 | arguments: RoleLevelArguments | [ 23 | self: RawTransactionArgument, 24 | manager: RawTransactionArgument 25 | ]; 26 | } 27 | export function roleLevel(options: RoleLevelOptions) { 28 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 29 | const argumentsTypes = [ 30 | `${packageAddress}::acl::Acl`, 31 | 'address' 32 | ] satisfies string[]; 33 | const parameterNames = ["self", "manager"]; 34 | return (tx: Transaction) => tx.moveCall({ 35 | package: packageAddress, 36 | module: 'acl', 37 | function: 'role_level', 38 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 39 | }); 40 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/deps/sui/vec_map.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_map'; 7 | /** An entry in the map */ 8 | export function Entry, V extends BcsType>(...typeParameters: [ 9 | K, 10 | V 11 | ]) { 12 | return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 13 | key: typeParameters[0], 14 | value: typeParameters[1] 15 | } }); 16 | } 17 | /** 18 | * A map data structure backed by a vector. The map is guaranteed not to contain 19 | * duplicate keys, but entries are _not_ sorted by key--entries are included in 20 | * insertion order. All operations are O(N) in the size of the map--the intention 21 | * of this data structure is only to provide the convenience of programming against 22 | * a map API. Large maps should use handwritten parent/child relationships instead. 23 | * Maps that need sorted iteration rather than insertion order iteration should 24 | * also be handwritten. 25 | */ 26 | export function VecMap, V extends BcsType>(...typeParameters: [ 27 | K, 28 | V 29 | ]) { 30 | return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 31 | contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) 32 | } }); 33 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/deps/sui/vec_map.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_map'; 7 | /** An entry in the map */ 8 | export function Entry, V extends BcsType>(...typeParameters: [ 9 | K, 10 | V 11 | ]) { 12 | return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 13 | key: typeParameters[0], 14 | value: typeParameters[1] 15 | } }); 16 | } 17 | /** 18 | * A map data structure backed by a vector. The map is guaranteed not to contain 19 | * duplicate keys, but entries are _not_ sorted by key--entries are included in 20 | * insertion order. All operations are O(N) in the size of the map--the intention 21 | * of this data structure is only to provide the convenience of programming against 22 | * a map API. Large maps should use handwritten parent/child relationships instead. 23 | * Maps that need sorted iteration rather than insertion order iteration should 24 | * also be handwritten. 25 | */ 26 | export function VecMap, V extends BcsType>(...typeParameters: [ 27 | K, 28 | V 29 | ]) { 30 | return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 31 | contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) 32 | } }); 33 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_psm/deps/sui/vec_map.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_map'; 7 | /** An entry in the map */ 8 | export function Entry, V extends BcsType>(...typeParameters: [ 9 | K, 10 | V 11 | ]) { 12 | return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 13 | key: typeParameters[0], 14 | value: typeParameters[1] 15 | } }); 16 | } 17 | /** 18 | * A map data structure backed by a vector. The map is guaranteed not to contain 19 | * duplicate keys, but entries are _not_ sorted by key--entries are included in 20 | * insertion order. All operations are O(N) in the size of the map--the intention 21 | * of this data structure is only to provide the convenience of programming against 22 | * a map API. Large maps should use handwritten parent/child relationships instead. 23 | * Maps that need sorted iteration rather than insertion order iteration should 24 | * also be handwritten. 25 | */ 26 | export function VecMap, V extends BcsType>(...typeParameters: [ 27 | K, 28 | V 29 | ]) { 30 | return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 31 | contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) 32 | } }); 33 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/deps/sui/vec_map.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_map'; 7 | /** An entry in the map */ 8 | export function Entry, V extends BcsType>(...typeParameters: [ 9 | K, 10 | V 11 | ]) { 12 | return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 13 | key: typeParameters[0], 14 | value: typeParameters[1] 15 | } }); 16 | } 17 | /** 18 | * A map data structure backed by a vector. The map is guaranteed not to contain 19 | * duplicate keys, but entries are _not_ sorted by key--entries are included in 20 | * insertion order. All operations are O(N) in the size of the map--the intention 21 | * of this data structure is only to provide the convenience of programming against 22 | * a map API. Large maps should use handwritten parent/child relationships instead. 23 | * Maps that need sorted iteration rather than insertion order iteration should 24 | * also be handwritten. 25 | */ 26 | export function VecMap, V extends BcsType>(...typeParameters: [ 27 | K, 28 | V 29 | ]) { 30 | return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 31 | contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) 32 | } }); 33 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/vec_map.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type BcsType, bcs } from '@mysten/sui/bcs'; 5 | import { MoveStruct } from '../../../utils/index.js'; 6 | const $moduleName = '0x2::vec_map'; 7 | /** An entry in the map */ 8 | export function Entry, V extends BcsType>(...typeParameters: [ 9 | K, 10 | V 11 | ]) { 12 | return new MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 13 | key: typeParameters[0], 14 | value: typeParameters[1] 15 | } }); 16 | } 17 | /** 18 | * A map data structure backed by a vector. The map is guaranteed not to contain 19 | * duplicate keys, but entries are _not_ sorted by key--entries are included in 20 | * insertion order. All operations are O(N) in the size of the map--the intention 21 | * of this data structure is only to provide the convenience of programming against 22 | * a map API. Large maps should use handwritten parent/child relationships instead. 23 | * Maps that need sorted iteration rather than insertion order iteration should 24 | * also be handwritten. 25 | */ 26 | export function VecMap, V extends BcsType>(...typeParameters: [ 27 | K, 28 | V 29 | ]) { 30 | return new MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`, fields: { 31 | contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) 32 | } }); 33 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/memo.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { type Transaction } from '@mysten/sui/transactions'; 5 | export interface ManageOptions { 6 | package?: string; 7 | arguments?: [ 8 | ]; 9 | } 10 | export function manage(options: ManageOptions = {}) { 11 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 12 | return (tx: Transaction) => tx.moveCall({ 13 | package: packageAddress, 14 | module: 'memo', 15 | function: 'manage', 16 | }); 17 | } 18 | export interface DonateOptions { 19 | package?: string; 20 | arguments?: [ 21 | ]; 22 | } 23 | export function donate(options: DonateOptions = {}) { 24 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 25 | return (tx: Transaction) => tx.moveCall({ 26 | package: packageAddress, 27 | module: 'memo', 28 | function: 'donate', 29 | }); 30 | } 31 | export interface LiquidateOptions { 32 | package?: string; 33 | arguments?: [ 34 | ]; 35 | } 36 | export function liquidate(options: LiquidateOptions = {}) { 37 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 38 | return (tx: Transaction) => tx.moveCall({ 39 | package: packageAddress, 40 | module: 'memo', 41 | function: 'liquidate', 42 | }); 43 | } 44 | export interface InterestOptions { 45 | package?: string; 46 | arguments?: [ 47 | ]; 48 | } 49 | export function interest(options: InterestOptions = {}) { 50 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 51 | return (tx: Transaction) => tx.moveCall({ 52 | package: packageAddress, 53 | module: 'memo', 54 | function: 'interest', 55 | }); 56 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/saving_incentive_events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { bcs } from '@mysten/sui/bcs'; 5 | 6 | import { MoveStruct } from '../utils/index.js'; 7 | 8 | const $moduleName = '@local-pkg/bucket_saving_incentive::saving_incentive_events'; 9 | export const CreateSavingPoolRewardManager = new MoveStruct({ 10 | name: `${$moduleName}::CreateSavingPoolRewardManager`, 11 | fields: { 12 | reward_manager_id: bcs.Address, 13 | }, 14 | }); 15 | export const AddRewarder = new MoveStruct({ 16 | name: `${$moduleName}::AddRewarder`, 17 | fields: { 18 | reward_manager_id: bcs.Address, 19 | rewarder_id: bcs.Address, 20 | }, 21 | }); 22 | export const SourceChanged = new MoveStruct({ 23 | name: `${$moduleName}::SourceChanged`, 24 | fields: { 25 | kind: bcs.string(), 26 | rewarder_id: bcs.Address, 27 | reward_type: bcs.string(), 28 | reward_amount: bcs.u64(), 29 | is_deposit: bcs.bool(), 30 | }, 31 | }); 32 | export const FlowRateChanged = new MoveStruct({ 33 | name: `${$moduleName}::FlowRateChanged`, 34 | fields: { 35 | kind: bcs.string(), 36 | rewarder_id: bcs.Address, 37 | asset_type: bcs.string(), 38 | reward_type: bcs.string(), 39 | flow_rate: bcs.u256(), 40 | }, 41 | }); 42 | export const RewarderTimestampChanged = new MoveStruct({ 43 | name: `${$moduleName}::RewarderTimestampChanged`, 44 | fields: { 45 | kind: bcs.string(), 46 | rewarder_id: bcs.Address, 47 | reward_timestamp: bcs.u64(), 48 | }, 49 | }); 50 | export const ClaimReward = new MoveStruct({ 51 | name: `${$moduleName}::ClaimReward`, 52 | fields: { 53 | kind: bcs.string(), 54 | rewarder_id: bcs.Address, 55 | account_address: bcs.Address, 56 | asset_type: bcs.string(), 57 | reward_type: bcs.string(), 58 | reward_amount: bcs.u64(), 59 | }, 60 | }); 61 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/bucket_v2_saving/saving.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { bcs } from '@mysten/sui/bcs'; 5 | 6 | import { MoveStruct } from '../../../utils/index.js'; 7 | import * as type_name from '../std/type_name.js'; 8 | import * as vec_set from '../sui/vec_set.js'; 9 | 10 | const $moduleName = 'bucket_v2_saving::saving'; 11 | export const DepositResponse = new MoveStruct({ 12 | name: `${$moduleName}::DepositResponse`, 13 | fields: { 14 | /** Address of the account that made the deposit */ 15 | account_address: bcs.Address, 16 | /** Amount of USDB deposited into the pool */ 17 | deposited_usdb_amount: bcs.u64(), 18 | /** Amount of LP tokens minted for this deposit */ 19 | minted_lp_amount: bcs.u64(), 20 | /** Previous LP token balance before this deposit */ 21 | prev_lp_balance: bcs.u64(), 22 | /** Previous last update timestamp before this deposit */ 23 | prev_last_update_timestamp: bcs.u64(), 24 | /** Set of witness types that have been validated */ 25 | witnesses: vec_set.VecSet(type_name.TypeName), 26 | }, 27 | }); 28 | export const WithdrawResponse = new MoveStruct({ 29 | name: `${$moduleName}::WithdrawResponse`, 30 | fields: { 31 | /** Address of the account that made the withdrawal */ 32 | account_address: bcs.Address, 33 | /** Amount of LP tokens burned for this withdrawal */ 34 | burned_lp_amount: bcs.u64(), 35 | /** Previous LP token balance before this withdrawal */ 36 | prev_lp_balance: bcs.u64(), 37 | /** Previous last update timestamp before this withdrawal */ 38 | prev_last_update_timestamp: bcs.u64(), 39 | /** Amount of USDB withdrawn from the pool */ 40 | withdrawal_usdb_amount: bcs.u64(), 41 | /** Set of witness types that have been validated */ 42 | witnesses: vec_set.VecSet(type_name.TypeName), 43 | }, 44 | }); 45 | -------------------------------------------------------------------------------- /src/types/index.ts: -------------------------------------------------------------------------------- 1 | import { Argument } from '@mysten/sui/transactions'; 2 | 3 | export * from './config.js'; 4 | 5 | export type SharedObjectRef = { 6 | objectId: string; 7 | initialSharedVersion: number | string; 8 | mutable: boolean; 9 | }; 10 | 11 | export type TransactionNestedResult = Extract< 12 | Argument, 13 | { 14 | NestedResult: unknown; 15 | } 16 | >; 17 | 18 | export type Float = { fields: { value: string } }; 19 | export type Double = { fields: { value: string } }; 20 | 21 | export type VaultInfo = { 22 | collateralType: string; 23 | collateralDecimal: number; 24 | collateralBalance: bigint; 25 | usdbSupply: bigint; 26 | maxUsdbSupply: bigint; 27 | minCollateralRatio: number; 28 | interestRate: number; 29 | positionTableSize: number; 30 | rewardRate: Record; 31 | }; 32 | 33 | export type SavingPoolInfo = { 34 | lpType: string; 35 | lpSupply: bigint; 36 | usdbBalance: bigint; 37 | usdbDepositCap: bigint | null; 38 | savingRate: number; 39 | rewardRate: Record; 40 | }; 41 | 42 | export type PsmPoolInfo = { 43 | coinType: string; 44 | decimal: number; 45 | balance: bigint; 46 | usdbSupply: bigint; 47 | feeRate: { 48 | swapIn: number; 49 | swapOut: number; 50 | }; 51 | partnerFeeRate: Record< 52 | string, 53 | { 54 | swapIn: number; 55 | swapOut: number; 56 | } 57 | >; 58 | }; 59 | 60 | export type FlashMintInfo = { 61 | feeRate: number; 62 | partner: Record; 63 | }; 64 | 65 | export type PositionInfo = { 66 | collateralType: string; 67 | collateralAmount: bigint; 68 | debtAmount: bigint; 69 | debtor: string; 70 | accountId?: string; 71 | rewards?: Record; 72 | }; 73 | 74 | export type SavingInfo = { 75 | lpType: string; 76 | address: string; 77 | accountId?: string; 78 | usdbBalance: bigint; 79 | lpBalance: bigint; 80 | rewards: Record; 81 | }; 82 | 83 | export type PaginatedPositionsResult = { 84 | positions: PositionInfo[]; 85 | nextCursor: string | null; 86 | }; 87 | -------------------------------------------------------------------------------- /src/types/config.ts: -------------------------------------------------------------------------------- 1 | import { SharedObjectRef } from './index.js'; 2 | 3 | export type Network = 'mainnet' | 'testnet'; 4 | 5 | export type DerivativeKind = 'sCoin' | 'gCoin' | 'TLP' | 'BFBTC'; 6 | 7 | export type AggregatorObjectInfo = { 8 | priceAggregator: SharedObjectRef; 9 | } & ( 10 | | { 11 | pythPriceId: string; 12 | } 13 | | { 14 | derivativeInfo: { 15 | underlyingCoinType: string; 16 | derivativeKind: DerivativeKind; 17 | }; 18 | } 19 | ); 20 | 21 | export type RewarderInfo = { 22 | rewarderId: string; 23 | rewardType: string; 24 | }; 25 | 26 | export type VaultObjectInfo = { 27 | vault: SharedObjectRef; 28 | rewarders?: RewarderInfo[]; 29 | }; 30 | 31 | export type PsmPoolObjectInfo = { 32 | pool: SharedObjectRef; 33 | }; 34 | 35 | export type SavingPoolObjectInfo = { 36 | pool: SharedObjectRef; 37 | reward?: { 38 | rewardManager: SharedObjectRef; 39 | rewardTypes: string[]; 40 | }; 41 | }; 42 | 43 | export type ConfigType = { 44 | PRICE_SERVICE_ENDPOINT: string; 45 | PYTH_STATE_ID: string; 46 | WORMHOLE_STATE_ID: string; 47 | PYTH_RULE_PACKAGE_ID: string; 48 | PYTH_RULE_CONFIG_OBJ: SharedObjectRef; 49 | 50 | ORIGINAL_FRAMEWORK_PACKAGE_ID: string; 51 | ORIGINAL_USDB_PACKAGE_ID: string; 52 | ORIGINAL_ORACLE_PACKAGE_ID: string; 53 | ORIGINAL_CDP_PACKAGE_ID: string; 54 | ORIGINAL_PSM_PACKAGE_ID: string; 55 | ORIGINAL_FLASH_PACKAGE_ID: string; 56 | ORIGINAL_SAVING_PACKAGE_ID: string; 57 | ORIGINAL_SAVING_INCENTIVE_PACKAGE_ID: string; 58 | ORIGINAL_BORROW_INCENTIVE_PACKAGE_ID: string; 59 | 60 | FRAMEWORK_PACKAGE_ID: string; 61 | USDB_PACKAGE_ID: string; 62 | ORACLE_PACKAGE_ID: string; 63 | CDP_PACKAGE_ID: string; 64 | PSM_PACKAGE_ID: string; 65 | FLASH_PACKAGE_ID: string; 66 | SAVING_PACKAGE_ID: string; 67 | SAVING_INCENTIVE_PACKAGE_ID: string; 68 | BORROW_INCENTIVE_PACKAGE_ID: string; 69 | 70 | TREASURY_OBJ: SharedObjectRef; 71 | VAULT_REWARDER_REGISTRY: SharedObjectRef; 72 | SAVING_POOL_INCENTIVE_GLOBAL_CONFIG_OBJ: SharedObjectRef; 73 | FLASH_GLOBAL_CONFIG_OBJ: SharedObjectRef; 74 | 75 | AGGREGATOR_OBJS: Record; 76 | VAULT_OBJS: Record; 77 | SAVING_POOL_OBJS: Record; 78 | PSM_POOL_OBJS: Record; 79 | }; 80 | -------------------------------------------------------------------------------- /src/utils/transaction.ts: -------------------------------------------------------------------------------- 1 | import { CoinStruct, SuiClient } from '@mysten/sui/client'; 2 | import { Commands, Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions'; 3 | import { normalizeStructTag, SUI_TYPE_ARG } from '@mysten/sui/utils'; 4 | 5 | import { COIN_WITH_BALANCE_RESOLVER, resolveCoinBalance } from '@/utils/resolvers.js'; 6 | 7 | /** 8 | * @description new zero coin 9 | */ 10 | export const getZeroCoin = (tx: Transaction, { coinType }: { coinType: string }): TransactionResult => { 11 | return tx.moveCall({ 12 | target: '0x2::coin::zero', 13 | typeArguments: [coinType], 14 | }); 15 | }; 16 | 17 | /** 18 | * @description destroy zero coin 19 | */ 20 | export const destroyZeroCoin = ( 21 | tx: Transaction, 22 | { coinType, coin }: { coinType: string; coin: TransactionArgument }, 23 | ) => { 24 | tx.moveCall({ 25 | target: '0x2::coin::destroy_zero', 26 | typeArguments: [coinType], 27 | arguments: [coin], 28 | }); 29 | }; 30 | 31 | /** 32 | * @description 33 | */ 34 | export const getCoinsOfType = async ({ 35 | coinType, 36 | client, 37 | owner, 38 | usedIds, 39 | }: { 40 | coinType: string; 41 | client: SuiClient; 42 | owner: string; 43 | usedIds: Set; 44 | }): Promise => { 45 | const coins: CoinStruct[] = []; 46 | 47 | const loadMoreCoins = async (cursor: string | null = null): Promise => { 48 | const { data, hasNextPage, nextCursor } = await client.getCoins({ owner, coinType, cursor }); 49 | 50 | for (const coin of data) { 51 | if (usedIds.has(coin.coinObjectId)) { 52 | continue; 53 | } 54 | coins.push(coin); 55 | } 56 | if (hasNextPage) { 57 | return loadMoreCoins(nextCursor); 58 | } 59 | return coins; 60 | }; 61 | return loadMoreCoins(); 62 | }; 63 | 64 | /** 65 | * @description 66 | */ 67 | export const coinWithBalance = ({ 68 | type = SUI_TYPE_ARG, 69 | balance, 70 | useGasCoin = true, 71 | }: { 72 | balance: bigint | number | TransactionArgument; 73 | type?: string; 74 | useGasCoin?: boolean; 75 | }): ((tx: Transaction) => TransactionResult) => { 76 | let coinResult: TransactionResult | null = null; 77 | 78 | return (tx: Transaction) => { 79 | if (coinResult) { 80 | return coinResult; 81 | } 82 | tx.addIntentResolver(COIN_WITH_BALANCE_RESOLVER, resolveCoinBalance); 83 | const coinType = type === 'gas' ? type : normalizeStructTag(type); 84 | 85 | coinResult = tx.add( 86 | Commands.Intent({ 87 | name: COIN_WITH_BALANCE_RESOLVER, 88 | inputs: {}, 89 | data: { 90 | type: coinType === normalizeStructTag(SUI_TYPE_ARG) && useGasCoin ? 'gas' : coinType, 91 | balance: typeof balance === 'number' ? BigInt(balance) : balance, 92 | }, 93 | }), 94 | ); 95 | return coinResult; 96 | }; 97 | }; 98 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@bucket-protocol/sdk", 3 | "author": "Bucket Protocol ", 4 | "version": "1.2.0", 5 | "license": "Apache-2.0", 6 | "description": "Bucket Protocol TypeScript SDK", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/Bucket-Protocol/bucket-protocol-sdk.git" 10 | }, 11 | "homepage": "https://github.com/Bucket-Protocol/bucket-protocol-sdk#readme", 12 | "bugs": { 13 | "url": "https://github.com/Bucket-Protocol/bucket-protocol-sdk/issues" 14 | }, 15 | "type": "module", 16 | "main": "./dist/cjs/index.js", 17 | "module": "./dist/esm/index.js", 18 | "exports": { 19 | ".": { 20 | "import": { 21 | "types": "./dist/esm/index.d.ts", 22 | "default": "./dist/esm/index.js" 23 | }, 24 | "require": { 25 | "types": "./dist/cjs/index.d.ts", 26 | "default": "./dist/cjs/index.js" 27 | } 28 | }, 29 | "./*": { 30 | "import": { 31 | "types": "./dist/esm/*.d.ts", 32 | "default": "./dist/esm/*.js" 33 | }, 34 | "require": { 35 | "types": "./dist/cjs/*.d.ts", 36 | "default": "./dist/cjs/*.js" 37 | } 38 | } 39 | }, 40 | "files": [ 41 | "dist", 42 | "CHANGELOG.md", 43 | "LICENSE", 44 | "README.md", 45 | "package.json" 46 | ], 47 | "scripts": { 48 | "lint": "eslint", 49 | "clean": "rm -rf tsconfig.tsbuildinfo ./dist", 50 | "build:cjs": "tsc -p ./tsconfig.cjs.json && tsc-alias -p ./tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json", 51 | "build:esm": "tsc -p ./tsconfig.esm.json && tsc-alias -p ./tsconfig.esm.json && echo '{\"type\": \"module\"}' > dist/esm/package.json", 52 | "build": "pnpm clean && npm-run-all --parallel build:cjs build:esm", 53 | "test": "vitest" 54 | }, 55 | "dependencies": { 56 | "@pythnetwork/pyth-sui-js": "^2.2.0" 57 | }, 58 | "peerDependencies": { 59 | "@mysten/sui": ">=1.38.0", 60 | "@mysten/bcs": ">=1.8.0" 61 | }, 62 | "devDependencies": { 63 | "@changesets/cli": "^2.26.2", 64 | "@eslint/eslintrc": "^3.3.1", 65 | "@eslint/js": "^9.35.0", 66 | "@ianvs/prettier-plugin-sort-imports": "^4.7.0", 67 | "@typescript-eslint/eslint-plugin": "^8.44.0", 68 | "@typescript-eslint/parser": "^8.44.0", 69 | "eslint": "^9.35.0", 70 | "eslint-config-prettier": "^10.1.8", 71 | "eslint-plugin-prettier": "^5.5.4", 72 | "eslint-plugin-unused-imports": "^4.2.0", 73 | "npm-run-all": "^4.1.5", 74 | "prettier": "^3.6.2", 75 | "tsc-alias": "^1.8.16", 76 | "typescript": "5.9.2", 77 | "vitest": "^0.34.1", 78 | "@mysten/bcs": "1.8.0", 79 | "@mysten/sui": "1.38.0" 80 | }, 81 | "engines": { 82 | "node": ">=20", 83 | "pnpm": ">=10" 84 | }, 85 | "packageManager": "pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706" 86 | } 87 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish package 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version-bump-type: 7 | description: 'Version bump type' 8 | required: true 9 | default: 'patch' 10 | type: choice 11 | options: 12 | - major 13 | - minor 14 | - patch 15 | 16 | permissions: 17 | contents: write 18 | id-token: write 19 | 20 | jobs: 21 | publish: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Check permission 25 | if: ${{ !contains('["17008875", "33892812", "2819672"]', github.actor_id) }} 26 | run: echo 'Permission denied' && exit 1 27 | - name: Checkout 28 | uses: actions/checkout@v5 29 | with: 30 | token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} 31 | - name: Install pnpm 32 | uses: pnpm/action-setup@v4 33 | - name: Setup Node 34 | uses: actions/setup-node@v5 35 | with: 36 | node-version: 24 37 | registry-url: 'https://registry.npmjs.org/' 38 | cache: 'pnpm' 39 | - name: Install Dependencies 40 | run: pnpm install --frozen-lockfile 41 | - name: Compile 42 | run: pnpm build 43 | - name: Configure git user 44 | run: | 45 | git config --global user.name "GitHub Actions Bot" 46 | git config --global user.email "github-actions[bot]@users.noreply.github.com" 47 | - name: Bump package version 48 | run: pnpm version ${{ inputs.version-bump-type }} --no-git-tag-version 49 | - name: Publish package to NPM 50 | run: pnpm publish --provenance --access public --no-git-checks 51 | - name: Commit version change 52 | uses: stefanzweifel/git-auto-commit-action@v7 53 | with: 54 | commit_message: 'chore(release): bump sdk version to new release' 55 | 56 | create-pr: 57 | runs-on: ubuntu-latest 58 | needs: publish 59 | strategy: 60 | matrix: 61 | repo: 62 | - bucket-frontend-v5 63 | steps: 64 | - name: Checkout 65 | uses: actions/checkout@v5 66 | with: 67 | repository: Bucket-Protocol/${{ matrix.repo }} 68 | token: ${{ secrets.ADMIN_TOKEN }} 69 | - name: Install pnpm 70 | uses: pnpm/action-setup@v4 71 | - name: Setup Node 72 | uses: actions/setup-node@v5 73 | with: 74 | node-version: 24 75 | - name: Bump version 76 | id: bump-version 77 | run: | 78 | pnpm update @bucket-protocol/sdk --latest --save-exact 79 | echo SDK_VERSION=$(pnpm info @bucket-protocol/sdk version) >> "$GITHUB_OUTPUT" 80 | - name: Create PR 81 | uses: peter-evans/create-pull-request@v7 82 | with: 83 | branch: bump-bucket-protocol-sdk-v${{ steps.bump-version.outputs.SDK_VERSION }} 84 | title: 'chore: bump @bucket-protocol/sdk to v${{ steps.bump-version.outputs.SDK_VERSION }}' 85 | token: ${{ secrets.ADMIN_TOKEN }} 86 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/events.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** 7 | * Module for emitting events related to the BucketV2 CDP (Collateralized Debt 8 | * Position) system. This module defines event structs and emit functions for 9 | * tracking important changes and actions within the CDP system, such as vault 10 | * creation, supply limit updates, liquidation rule changes, and position updates. 11 | */ 12 | 13 | import { MoveStruct } from '../utils/index.js'; 14 | import { bcs } from '@mysten/sui/bcs'; 15 | const $moduleName = '@local-pkg/bucket_v2_cdp::events'; 16 | export const VaultCreated = new MoveStruct({ name: `${$moduleName}::VaultCreated`, fields: { 17 | /** Unique identifier for the vault */ 18 | vault_id: bcs.Address, 19 | /** The coll type of the vault */ 20 | coll_type: bcs.string(), 21 | /** The interest rate for the vault (scaled value) */ 22 | interest_rate: bcs.u256(), 23 | /** The supply limit for the vault */ 24 | supply_limit: bcs.u64(), 25 | /** The minimum coll ratio required */ 26 | min_coll_ratio: bcs.u128() 27 | } }); 28 | export const SupplyLimitUpdated = new MoveStruct({ name: `${$moduleName}::SupplyLimitUpdated`, fields: { 29 | /** Unique identifier for the vault */ 30 | vault_id: bcs.Address, 31 | /** The coll type of the vault */ 32 | coll_type: bcs.string(), 33 | /** Previous supply limit */ 34 | before: bcs.u64(), 35 | /** New supply limit */ 36 | after: bcs.u64() 37 | } }); 38 | export const InterestRateUpdated = new MoveStruct({ name: `${$moduleName}::InterestRateUpdated`, fields: { 39 | /** Unique identifier for the vault */ 40 | vault_id: bcs.Address, 41 | /** The coll type of the vault */ 42 | coll_type: bcs.string(), 43 | /** New interest rate */ 44 | interest_rate_bps: bcs.u64() 45 | } }); 46 | export const LiquidationRuleUpdated = new MoveStruct({ name: `${$moduleName}::LiquidationRuleUpdated`, fields: { 47 | /** Unique identifier for the vault */ 48 | vault_id: bcs.Address, 49 | /** The coll type of the vault */ 50 | coll_type: bcs.string(), 51 | /** Previous liquidation rule type */ 52 | before: bcs.string(), 53 | /** New liquidation rule type */ 54 | after: bcs.string() 55 | } }); 56 | export const PositionUpdated = new MoveStruct({ name: `${$moduleName}::PositionUpdated`, fields: { 57 | /** Unique identifier for the vault */ 58 | vault_id: bcs.Address, 59 | /** The coll type of the vault */ 60 | coll_type: bcs.string(), 61 | /** Address of the debtor (user) */ 62 | debtor: bcs.Address, 63 | /** Amount deposited in this update */ 64 | deposit_amount: bcs.u64(), 65 | /** Amount borrowed in this update */ 66 | borrow_amount: bcs.u64(), 67 | /** Amount withdrawn in this update */ 68 | withdraw_amount: bcs.u64(), 69 | /** Amount repaid in this update */ 70 | repay_amount: bcs.u64(), 71 | /** Interest accrued in this update */ 72 | interest_amount: bcs.u64(), 73 | /** Current coll after the update */ 74 | current_coll_amount: bcs.u64(), 75 | /** Current debt after the update */ 76 | current_debt_amount: bcs.u64(), 77 | /** Optional memo or note for the update */ 78 | memo: bcs.string() 79 | } }); 80 | export const SetSecurity = new MoveStruct({ name: `${$moduleName}::SetSecurity`, fields: { 81 | vault_id: bcs.Address, 82 | coll_type: bcs.string(), 83 | sender: bcs.Address, 84 | level: bcs.option(bcs.u8()) 85 | } }); -------------------------------------------------------------------------------- /src/utils/resolvers.ts: -------------------------------------------------------------------------------- 1 | import { bcs } from '@mysten/sui/bcs'; 2 | import { CoinStruct, SuiClient } from '@mysten/sui/client'; 3 | import { 4 | Argument, 5 | BuildTransactionOptions, 6 | Commands, 7 | Inputs, 8 | TransactionDataBuilder, 9 | TransactionResult, 10 | } from '@mysten/sui/transactions'; 11 | 12 | import { TransactionNestedResult } from '@/types/index.js'; 13 | import { getCoinsOfType } from '@/utils/transaction.js'; 14 | 15 | export const COIN_WITH_BALANCE_RESOLVER = 'AugmentedCoinWithBalance'; 16 | 17 | export const resolveCoinBalance = async ( 18 | transactionData: TransactionDataBuilder, 19 | buildOptions: BuildTransactionOptions, 20 | next: () => Promise, 21 | ) => { 22 | const coinTypes = new Set(); 23 | 24 | if (!transactionData.sender) { 25 | throw new Error('Sender must be set to resolve CoinWithBalance'); 26 | } 27 | for (const command of transactionData.commands) { 28 | if (command.$kind === '$Intent' && command.$Intent.name === COIN_WITH_BALANCE_RESOLVER) { 29 | const { type, balance } = command.$Intent.data as { 30 | type: string; 31 | balance: bigint | TransactionResult | TransactionNestedResult; 32 | }; 33 | if (type !== 'gas' && (typeof balance !== 'bigint' || balance > 0n)) { 34 | coinTypes.add(type); 35 | } 36 | } 37 | } 38 | const usedIds = new Set(); 39 | 40 | for (const input of transactionData.inputs) { 41 | if (input.Object?.ImmOrOwnedObject) { 42 | usedIds.add(input.Object.ImmOrOwnedObject.objectId); 43 | } 44 | if (input.UnresolvedObject?.objectId) { 45 | usedIds.add(input.UnresolvedObject.objectId); 46 | } 47 | } 48 | const coinsByType = new Map(); 49 | const { client } = buildOptions; 50 | if (!client) { 51 | throw new Error( 52 | `No sui client passed to Transaction#build, but transaction data was not sufficient to build offline.`, 53 | ); 54 | } 55 | await Promise.all( 56 | [...coinTypes].map(async (coinType) => { 57 | coinsByType.set( 58 | coinType, 59 | await getCoinsOfType({ 60 | coinType, 61 | client: client as SuiClient, 62 | owner: transactionData.sender!, 63 | usedIds, 64 | }), 65 | ); 66 | }), 67 | ); 68 | const mergedCoins = new Map(); 69 | 70 | mergedCoins.set('gas', { $kind: 'GasCoin', GasCoin: true }); 71 | 72 | for (const [index, transaction] of transactionData.commands.entries()) { 73 | if (transaction.$kind !== '$Intent' || transaction.$Intent.name !== COIN_WITH_BALANCE_RESOLVER) { 74 | continue; 75 | } 76 | const { type, balance } = transaction.$Intent.data as { 77 | type: string; 78 | balance: bigint; 79 | }; 80 | if (balance === 0n && type !== 'gas') { 81 | transactionData.replaceCommand(index, Commands.MoveCall({ target: '0x2::coin::zero', typeArguments: [type] })); 82 | continue; 83 | } 84 | const commands = []; 85 | 86 | if (!mergedCoins.has(type)) { 87 | const [first, ...rest] = coinsByType.get(type)!.map((coin) => 88 | transactionData.addInput( 89 | 'object', 90 | Inputs.ObjectRef({ 91 | objectId: coin.coinObjectId, 92 | digest: coin.digest, 93 | version: coin.version, 94 | }), 95 | ), 96 | ); 97 | if (rest.length > 0) { 98 | commands.push(Commands.MergeCoins(first, rest)); 99 | } 100 | mergedCoins.set(type, first); 101 | } 102 | commands.push( 103 | Commands.SplitCoins(mergedCoins.get(type)!, [ 104 | typeof balance === 'bigint' 105 | ? transactionData.addInput('pure', Inputs.Pure(bcs.u64().serialize(balance))) 106 | : balance, 107 | ]), 108 | ); 109 | transactionData.replaceCommand(index, commands); 110 | 111 | transactionData.mapArguments((arg) => { 112 | if (arg.$kind === 'Result' && arg.Result === index) { 113 | return { 114 | $kind: 'NestedResult', 115 | NestedResult: [index + commands.length - 1, 0], 116 | }; 117 | } 118 | return arg; 119 | }); 120 | } 121 | return next(); 122 | }; 123 | -------------------------------------------------------------------------------- /src/_generated/utils/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import { bcs, BcsType, TypeTag, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs'; 3 | import { normalizeSuiAddress } from '@mysten/sui/utils'; 4 | import { TransactionArgument, isArgument } from '@mysten/sui/transactions'; 5 | 6 | const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1'); 7 | const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2'); 8 | const SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3'); 9 | 10 | export type RawTransactionArgument = T | TransactionArgument; 11 | 12 | export function getPureBcsSchema(typeTag: string | TypeTag): BcsType | null { 13 | const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag; 14 | 15 | if ('u8' in parsedTag) { 16 | return bcs.U8; 17 | } else if ('u16' in parsedTag) { 18 | return bcs.U16; 19 | } else if ('u32' in parsedTag) { 20 | return bcs.U32; 21 | } else if ('u64' in parsedTag) { 22 | return bcs.U64; 23 | } else if ('u128' in parsedTag) { 24 | return bcs.U128; 25 | } else if ('u256' in parsedTag) { 26 | return bcs.U256; 27 | } else if ('address' in parsedTag) { 28 | return bcs.Address; 29 | } else if ('bool' in parsedTag) { 30 | return bcs.Bool; 31 | } else if ('vector' in parsedTag) { 32 | const type = getPureBcsSchema(parsedTag.vector); 33 | return type ? bcs.vector(type) : null; 34 | } else if ('struct' in parsedTag) { 35 | const structTag = parsedTag.struct; 36 | const pkg = normalizeSuiAddress(parsedTag.struct.address); 37 | 38 | if (pkg === MOVE_STDLIB_ADDRESS) { 39 | if ( 40 | (structTag.module === 'ascii' || structTag.module === 'string') && 41 | structTag.name === 'String' 42 | ) { 43 | return bcs.String; 44 | } 45 | 46 | if (structTag.module === 'option' && structTag.name === 'Option') { 47 | const type = getPureBcsSchema(structTag.typeParams[0]!); 48 | return type ? bcs.vector(type) : null; 49 | } 50 | } 51 | 52 | if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') { 53 | return bcs.Address; 54 | } 55 | } 56 | 57 | return null; 58 | } 59 | 60 | export function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]) { 61 | 62 | if (parameterNames && argTypes.length !== parameterNames.length) { 63 | throw new Error(`Invalid number of parameterNames, expected ${argTypes.length}, got ${parameterNames.length}`); 64 | } 65 | 66 | const normalizedArgs: TransactionArgument[] = []; 67 | 68 | let index = 0; 69 | for (const [i, argType] of argTypes.entries()) { 70 | if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) { 71 | normalizedArgs.push((tx) => tx.object.denyList()); 72 | continue; 73 | } 74 | 75 | if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) { 76 | normalizedArgs.push((tx) => tx.object.random()); 77 | continue; 78 | } 79 | 80 | if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) { 81 | normalizedArgs.push((tx) => tx.object.clock()); 82 | continue; 83 | } 84 | 85 | if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) { 86 | normalizedArgs.push((tx) => tx.object.system()); 87 | continue; 88 | } 89 | 90 | let arg 91 | if (Array.isArray(args)) { 92 | if (index >= args.length) { 93 | throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`); 94 | } 95 | arg = args[index]; 96 | } else { 97 | if (!parameterNames) { 98 | throw new Error(`Expected arguments to be passed as an array`); 99 | } 100 | const name = parameterNames[index]; 101 | arg = args[name as keyof typeof args]; 102 | 103 | if (arg == null) { 104 | throw new Error(`Parameter ${name} is required`); 105 | } 106 | } 107 | 108 | index += 1; 109 | 110 | if (typeof arg === 'function' || isArgument(arg)) { 111 | normalizedArgs.push(arg as TransactionArgument); 112 | continue; 113 | } 114 | 115 | const type = argTypes[i]!; 116 | const bcsType = getPureBcsSchema(type); 117 | 118 | if (bcsType) { 119 | const bytes = bcsType.serialize(arg as never); 120 | normalizedArgs.push((tx) => tx.pure(bytes)); 121 | continue; 122 | } else if (typeof arg === 'string') { 123 | normalizedArgs.push((tx) => tx.object(arg)); 124 | continue; 125 | } 126 | 127 | throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`); 128 | } 129 | 130 | return normalizedArgs; 131 | } 132 | 133 | export class MoveStruct< 134 | T extends Record>, 135 | const Name extends string = string, 136 | > extends BcsStruct {} 137 | 138 | export class MoveEnum< 139 | T extends Record | null>, 140 | const Name extends string, 141 | > extends BcsEnum {} 142 | 143 | export class MoveTuple< 144 | T extends readonly BcsType[], 145 | const Name extends string, 146 | > extends BcsTuple {} 147 | 148 | function stringify(val: unknown) { 149 | if (typeof val === 'object') { 150 | return JSON.stringify(val, (val: unknown) => val); 151 | } 152 | if (typeof val === 'bigint') { 153 | return val.toString(); 154 | } 155 | 156 | return val; 157 | } 158 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/account.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for Account Abstraction */ 7 | 8 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | import { type Transaction } from '@mysten/sui/transactions'; 11 | import * as object from './deps/sui/object.js'; 12 | const $moduleName = '@local-pkg/bucket_v2_framework::account'; 13 | export const ACCOUNT = new MoveStruct({ name: `${$moduleName}::ACCOUNT`, fields: { 14 | dummy_field: bcs.bool() 15 | } }); 16 | export const Account = new MoveStruct({ name: `${$moduleName}::Account`, fields: { 17 | id: object.UID, 18 | alias: bcs.option(bcs.string()) 19 | } }); 20 | export const AccountRequest = new MoveStruct({ name: `${$moduleName}::AccountRequest`, fields: { 21 | account: bcs.Address 22 | } }); 23 | export interface NewArguments { 24 | alias: RawTransactionArgument; 25 | } 26 | export interface NewOptions { 27 | package?: string; 28 | arguments: NewArguments | [ 29 | alias: RawTransactionArgument 30 | ]; 31 | } 32 | /** Public Funs */ 33 | export function _new(options: NewOptions) { 34 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 35 | const argumentsTypes = [ 36 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option<0x0000000000000000000000000000000000000000000000000000000000000001::string::String>' 37 | ] satisfies string[]; 38 | const parameterNames = ["alias"]; 39 | return (tx: Transaction) => tx.moveCall({ 40 | package: packageAddress, 41 | module: 'account', 42 | function: 'new', 43 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 44 | }); 45 | } 46 | export interface RequestOptions { 47 | package?: string; 48 | arguments?: [ 49 | ]; 50 | } 51 | export function request(options: RequestOptions = {}) { 52 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 53 | return (tx: Transaction) => tx.moveCall({ 54 | package: packageAddress, 55 | module: 'account', 56 | function: 'request', 57 | }); 58 | } 59 | export interface RequestWithAccountArguments { 60 | account: RawTransactionArgument; 61 | } 62 | export interface RequestWithAccountOptions { 63 | package?: string; 64 | arguments: RequestWithAccountArguments | [ 65 | account: RawTransactionArgument 66 | ]; 67 | } 68 | export function requestWithAccount(options: RequestWithAccountOptions) { 69 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 70 | const argumentsTypes = [ 71 | `${packageAddress}::account::Account` 72 | ] satisfies string[]; 73 | const parameterNames = ["account"]; 74 | return (tx: Transaction) => tx.moveCall({ 75 | package: packageAddress, 76 | module: 'account', 77 | function: 'request_with_account', 78 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 79 | }); 80 | } 81 | export interface ReceiveArguments { 82 | account: RawTransactionArgument; 83 | receiving: RawTransactionArgument; 84 | } 85 | export interface ReceiveOptions { 86 | package?: string; 87 | arguments: ReceiveArguments | [ 88 | account: RawTransactionArgument, 89 | receiving: RawTransactionArgument 90 | ]; 91 | typeArguments: [ 92 | string 93 | ]; 94 | } 95 | export function receive(options: ReceiveOptions) { 96 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 97 | const argumentsTypes = [ 98 | `${packageAddress}::account::Account`, 99 | `0x0000000000000000000000000000000000000000000000000000000000000002::transfer::Receiving<${options.typeArguments[0]}>` 100 | ] satisfies string[]; 101 | const parameterNames = ["account", "receiving"]; 102 | return (tx: Transaction) => tx.moveCall({ 103 | package: packageAddress, 104 | module: 'account', 105 | function: 'receive', 106 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 107 | typeArguments: options.typeArguments 108 | }); 109 | } 110 | export interface UpdateAliasArguments { 111 | account: RawTransactionArgument; 112 | alias: RawTransactionArgument; 113 | } 114 | export interface UpdateAliasOptions { 115 | package?: string; 116 | arguments: UpdateAliasArguments | [ 117 | account: RawTransactionArgument, 118 | alias: RawTransactionArgument 119 | ]; 120 | } 121 | export function updateAlias(options: UpdateAliasOptions) { 122 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 123 | const argumentsTypes = [ 124 | `${packageAddress}::account::Account`, 125 | '0x0000000000000000000000000000000000000000000000000000000000000001::string::String' 126 | ] satisfies string[]; 127 | const parameterNames = ["account", "alias"]; 128 | return (tx: Transaction) => tx.moveCall({ 129 | package: packageAddress, 130 | module: 'account', 131 | function: 'update_alias', 132 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 133 | }); 134 | } 135 | export interface AccountAddressArguments { 136 | account: RawTransactionArgument; 137 | } 138 | export interface AccountAddressOptions { 139 | package?: string; 140 | arguments: AccountAddressArguments | [ 141 | account: RawTransactionArgument 142 | ]; 143 | } 144 | export function accountAddress(options: AccountAddressOptions) { 145 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 146 | const argumentsTypes = [ 147 | `${packageAddress}::account::Account` 148 | ] satisfies string[]; 149 | const parameterNames = ["account"]; 150 | return (tx: Transaction) => tx.moveCall({ 151 | package: packageAddress, 152 | module: 'account', 153 | function: 'account_address', 154 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 155 | }); 156 | } 157 | export interface RequestAddressArguments { 158 | req: RawTransactionArgument; 159 | } 160 | export interface RequestAddressOptions { 161 | package?: string; 162 | arguments: RequestAddressArguments | [ 163 | req: RawTransactionArgument 164 | ]; 165 | } 166 | export function requestAddress(options: RequestAddressOptions) { 167 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 168 | const argumentsTypes = [ 169 | `${packageAddress}::account::AccountRequest` 170 | ] satisfies string[]; 171 | const parameterNames = ["req"]; 172 | return (tx: Transaction) => tx.moveCall({ 173 | package: packageAddress, 174 | module: 'account', 175 | function: 'request_address', 176 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 177 | }); 178 | } 179 | export interface AliasLengthLimitOptions { 180 | package?: string; 181 | arguments?: [ 182 | ]; 183 | } 184 | export function aliasLengthLimit(options: AliasLengthLimitOptions = {}) { 185 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 186 | return (tx: Transaction) => tx.moveCall({ 187 | package: packageAddress, 188 | module: 'account', 189 | function: 'alias_length_limit', 190 | }); 191 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/incentive_config.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { bcs } from '@mysten/sui/bcs'; 5 | import { type Transaction } from '@mysten/sui/transactions'; 6 | 7 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 8 | import * as object from './deps/sui/object.js'; 9 | import * as vec_set from './deps/sui/vec_set.js'; 10 | 11 | const $moduleName = '@local-pkg/bucket_saving_incentive::incentive_config'; 12 | export const GlobalConfig = new MoveStruct({ 13 | name: `${$moduleName}::GlobalConfig`, 14 | fields: { 15 | id: object.UID, 16 | versions: vec_set.VecSet(bcs.u16()), 17 | managers: vec_set.VecSet(bcs.Address), 18 | }, 19 | }); 20 | export interface PackageVersionOptions { 21 | package?: string; 22 | arguments?: []; 23 | } 24 | export function packageVersion(options: PackageVersionOptions = {}) { 25 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 26 | return (tx: Transaction) => 27 | tx.moveCall({ 28 | package: packageAddress, 29 | module: 'incentive_config', 30 | function: 'package_version', 31 | }); 32 | } 33 | export interface AddVersionArguments { 34 | Cap: RawTransactionArgument; 35 | config: RawTransactionArgument; 36 | version: RawTransactionArgument; 37 | } 38 | export interface AddVersionOptions { 39 | package?: string; 40 | arguments: 41 | | AddVersionArguments 42 | | [ 43 | Cap: RawTransactionArgument, 44 | config: RawTransactionArgument, 45 | version: RawTransactionArgument, 46 | ]; 47 | } 48 | /** Admin Funs */ 49 | export function addVersion(options: AddVersionOptions) { 50 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 51 | const argumentsTypes = [ 52 | `${packageAddress}::admin::AdminCap`, 53 | `${packageAddress}::incentive_config::GlobalConfig`, 54 | 'u16', 55 | ] satisfies string[]; 56 | const parameterNames = ['Cap', 'config', 'version']; 57 | return (tx: Transaction) => 58 | tx.moveCall({ 59 | package: packageAddress, 60 | module: 'incentive_config', 61 | function: 'add_version', 62 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 63 | }); 64 | } 65 | export interface RemoveVersionArguments { 66 | Cap: RawTransactionArgument; 67 | config: RawTransactionArgument; 68 | version: RawTransactionArgument; 69 | } 70 | export interface RemoveVersionOptions { 71 | package?: string; 72 | arguments: 73 | | RemoveVersionArguments 74 | | [ 75 | Cap: RawTransactionArgument, 76 | config: RawTransactionArgument, 77 | version: RawTransactionArgument, 78 | ]; 79 | } 80 | export function removeVersion(options: RemoveVersionOptions) { 81 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 82 | const argumentsTypes = [ 83 | `${packageAddress}::admin::AdminCap`, 84 | `${packageAddress}::incentive_config::GlobalConfig`, 85 | 'u16', 86 | ] satisfies string[]; 87 | const parameterNames = ['Cap', 'config', 'version']; 88 | return (tx: Transaction) => 89 | tx.moveCall({ 90 | package: packageAddress, 91 | module: 'incentive_config', 92 | function: 'remove_version', 93 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 94 | }); 95 | } 96 | export interface AddManagerArguments { 97 | Cap: RawTransactionArgument; 98 | config: RawTransactionArgument; 99 | manager: RawTransactionArgument; 100 | } 101 | export interface AddManagerOptions { 102 | package?: string; 103 | arguments: 104 | | AddManagerArguments 105 | | [ 106 | Cap: RawTransactionArgument, 107 | config: RawTransactionArgument, 108 | manager: RawTransactionArgument, 109 | ]; 110 | } 111 | export function addManager(options: AddManagerOptions) { 112 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 113 | const argumentsTypes = [ 114 | `${packageAddress}::admin::AdminCap`, 115 | `${packageAddress}::incentive_config::GlobalConfig`, 116 | 'address', 117 | ] satisfies string[]; 118 | const parameterNames = ['Cap', 'config', 'manager']; 119 | return (tx: Transaction) => 120 | tx.moveCall({ 121 | package: packageAddress, 122 | module: 'incentive_config', 123 | function: 'add_manager', 124 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 125 | }); 126 | } 127 | export interface RemoveManagerArguments { 128 | Cap: RawTransactionArgument; 129 | config: RawTransactionArgument; 130 | manager: RawTransactionArgument; 131 | } 132 | export interface RemoveManagerOptions { 133 | package?: string; 134 | arguments: 135 | | RemoveManagerArguments 136 | | [ 137 | Cap: RawTransactionArgument, 138 | config: RawTransactionArgument, 139 | manager: RawTransactionArgument, 140 | ]; 141 | } 142 | export function removeManager(options: RemoveManagerOptions) { 143 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 144 | const argumentsTypes = [ 145 | `${packageAddress}::admin::AdminCap`, 146 | `${packageAddress}::incentive_config::GlobalConfig`, 147 | 'address', 148 | ] satisfies string[]; 149 | const parameterNames = ['Cap', 'config', 'manager']; 150 | return (tx: Transaction) => 151 | tx.moveCall({ 152 | package: packageAddress, 153 | module: 'incentive_config', 154 | function: 'remove_manager', 155 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 156 | }); 157 | } 158 | export interface AssertValidPackageVersionArguments { 159 | config: RawTransactionArgument; 160 | } 161 | export interface AssertValidPackageVersionOptions { 162 | package?: string; 163 | arguments: AssertValidPackageVersionArguments | [config: RawTransactionArgument]; 164 | } 165 | /** Public Funs */ 166 | export function assertValidPackageVersion(options: AssertValidPackageVersionOptions) { 167 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 168 | const argumentsTypes = [`${packageAddress}::incentive_config::GlobalConfig`] satisfies string[]; 169 | const parameterNames = ['config']; 170 | return (tx: Transaction) => 171 | tx.moveCall({ 172 | package: packageAddress, 173 | module: 'incentive_config', 174 | function: 'assert_valid_package_version', 175 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 176 | }); 177 | } 178 | export interface AssertSenderIsManagerArguments { 179 | config: RawTransactionArgument; 180 | request: RawTransactionArgument; 181 | } 182 | export interface AssertSenderIsManagerOptions { 183 | package?: string; 184 | arguments: 185 | | AssertSenderIsManagerArguments 186 | | [config: RawTransactionArgument, request: RawTransactionArgument]; 187 | } 188 | export function assertSenderIsManager(options: AssertSenderIsManagerOptions) { 189 | const packageAddress = options.package ?? '@local-pkg/bucket_saving_incentive'; 190 | const argumentsTypes = [ 191 | `${packageAddress}::incentive_config::GlobalConfig`, 192 | `${packageAddress}::account::AccountRequest`, 193 | ] satisfies string[]; 194 | const parameterNames = ['config', 'request']; 195 | return (tx: Transaction) => 196 | tx.moveCall({ 197 | package: packageAddress, 198 | module: 'incentive_config', 199 | function: 'assert_sender_is_manager', 200 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 201 | }); 202 | } 203 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/response.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 5 | import { bcs, type BcsType } from '@mysten/sui/bcs'; 6 | import { type Transaction } from '@mysten/sui/transactions'; 7 | import * as vec_set from './deps/sui/vec_set.js'; 8 | import * as type_name from './deps/std/type_name.js'; 9 | const $moduleName = '@local-pkg/bucket_v2_cdp::response'; 10 | export const UpdateResponse = new MoveStruct({ name: `${$moduleName}::UpdateResponse`, fields: { 11 | vault_id: bcs.Address, 12 | account: bcs.Address, 13 | coll_amount: bcs.u64(), 14 | debt_amount: bcs.u64(), 15 | interest_amount: bcs.u64(), 16 | witnesses: vec_set.VecSet(type_name.TypeName) 17 | } }); 18 | export interface AddWitnessArguments> { 19 | res: RawTransactionArgument; 20 | Witness: RawTransactionArgument; 21 | } 22 | export interface AddWitnessOptions> { 23 | package?: string; 24 | arguments: AddWitnessArguments | [ 25 | res: RawTransactionArgument, 26 | Witness: RawTransactionArgument 27 | ]; 28 | typeArguments: [ 29 | string, 30 | string 31 | ]; 32 | } 33 | /** 34 | * Public Functions Adds a witness of type R to the UpdateResponse, aborting if it 35 | * already exists 36 | */ 37 | export function addWitness>(options: AddWitnessOptions) { 38 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 39 | const argumentsTypes = [ 40 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>`, 41 | `${options.typeArguments[1]}` 42 | ] satisfies string[]; 43 | const parameterNames = ["res", "Witness"]; 44 | return (tx: Transaction) => tx.moveCall({ 45 | package: packageAddress, 46 | module: 'response', 47 | function: 'add_witness', 48 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 49 | typeArguments: options.typeArguments 50 | }); 51 | } 52 | export interface VaultIdArguments { 53 | res: RawTransactionArgument; 54 | } 55 | export interface VaultIdOptions { 56 | package?: string; 57 | arguments: VaultIdArguments | [ 58 | res: RawTransactionArgument 59 | ]; 60 | typeArguments: [ 61 | string 62 | ]; 63 | } 64 | /** Getter Functions Returns the vault ID from the response */ 65 | export function vaultId(options: VaultIdOptions) { 66 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 67 | const argumentsTypes = [ 68 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 69 | ] satisfies string[]; 70 | const parameterNames = ["res"]; 71 | return (tx: Transaction) => tx.moveCall({ 72 | package: packageAddress, 73 | module: 'response', 74 | function: 'vault_id', 75 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 76 | typeArguments: options.typeArguments 77 | }); 78 | } 79 | export interface AccountArguments { 80 | res: RawTransactionArgument; 81 | } 82 | export interface AccountOptions { 83 | package?: string; 84 | arguments: AccountArguments | [ 85 | res: RawTransactionArgument 86 | ]; 87 | typeArguments: [ 88 | string 89 | ]; 90 | } 91 | /** Returns the account address from the response */ 92 | export function account(options: AccountOptions) { 93 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 94 | const argumentsTypes = [ 95 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 96 | ] satisfies string[]; 97 | const parameterNames = ["res"]; 98 | return (tx: Transaction) => tx.moveCall({ 99 | package: packageAddress, 100 | module: 'response', 101 | function: 'account', 102 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 103 | typeArguments: options.typeArguments 104 | }); 105 | } 106 | export interface CollAmountArguments { 107 | res: RawTransactionArgument; 108 | } 109 | export interface CollAmountOptions { 110 | package?: string; 111 | arguments: CollAmountArguments | [ 112 | res: RawTransactionArgument 113 | ]; 114 | typeArguments: [ 115 | string 116 | ]; 117 | } 118 | /** Returns the collateral amount from the response */ 119 | export function collAmount(options: CollAmountOptions) { 120 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 121 | const argumentsTypes = [ 122 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 123 | ] satisfies string[]; 124 | const parameterNames = ["res"]; 125 | return (tx: Transaction) => tx.moveCall({ 126 | package: packageAddress, 127 | module: 'response', 128 | function: 'coll_amount', 129 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 130 | typeArguments: options.typeArguments 131 | }); 132 | } 133 | export interface DebtAmountArguments { 134 | res: RawTransactionArgument; 135 | } 136 | export interface DebtAmountOptions { 137 | package?: string; 138 | arguments: DebtAmountArguments | [ 139 | res: RawTransactionArgument 140 | ]; 141 | typeArguments: [ 142 | string 143 | ]; 144 | } 145 | /** Returns the debt amount from the response */ 146 | export function debtAmount(options: DebtAmountOptions) { 147 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 148 | const argumentsTypes = [ 149 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 150 | ] satisfies string[]; 151 | const parameterNames = ["res"]; 152 | return (tx: Transaction) => tx.moveCall({ 153 | package: packageAddress, 154 | module: 'response', 155 | function: 'debt_amount', 156 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 157 | typeArguments: options.typeArguments 158 | }); 159 | } 160 | export interface InterestAmountArguments { 161 | res: RawTransactionArgument; 162 | } 163 | export interface InterestAmountOptions { 164 | package?: string; 165 | arguments: InterestAmountArguments | [ 166 | res: RawTransactionArgument 167 | ]; 168 | typeArguments: [ 169 | string 170 | ]; 171 | } 172 | /** Returns the interest amount from the response */ 173 | export function interestAmount(options: InterestAmountOptions) { 174 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 175 | const argumentsTypes = [ 176 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 177 | ] satisfies string[]; 178 | const parameterNames = ["res"]; 179 | return (tx: Transaction) => tx.moveCall({ 180 | package: packageAddress, 181 | module: 'response', 182 | function: 'interest_amount', 183 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 184 | typeArguments: options.typeArguments 185 | }); 186 | } 187 | export interface WitnessesArguments { 188 | res: RawTransactionArgument; 189 | } 190 | export interface WitnessesOptions { 191 | package?: string; 192 | arguments: WitnessesArguments | [ 193 | res: RawTransactionArgument 194 | ]; 195 | typeArguments: [ 196 | string 197 | ]; 198 | } 199 | /** Returns a reference to the set of witnesses from the response */ 200 | export function witnesses(options: WitnessesOptions) { 201 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 202 | const argumentsTypes = [ 203 | `${packageAddress}::response::UpdateResponse<${options.typeArguments[0]}>` 204 | ] satisfies string[]; 205 | const parameterNames = ["res"]; 206 | return (tx: Transaction) => tx.moveCall({ 207 | package: packageAddress, 208 | module: 'response', 209 | function: 'witnesses', 210 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 211 | typeArguments: options.typeArguments 212 | }); 213 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_saving_incentive/deps/sui/dynamic_field.ts: -------------------------------------------------------------------------------- 1 | import { type BcsType } from '@mysten/sui/bcs'; 2 | import { type Transaction } from '@mysten/sui/transactions'; 3 | 4 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../../../utils/index.js'; 5 | import * as object from './object.js'; 6 | 7 | const $moduleName = '@local-pkg/suiii::dynamic_field'; 8 | /** Internal object used for storing the field and value */ 9 | export function Field, Value extends BcsType>(...typeParameters: [Name, Value]) { 10 | return new MoveStruct({ 11 | name: `${$moduleName}::Field<${typeParameters[0].name as Name['name']}, ${typeParameters[1].name as Value['name']}>`, 12 | fields: { 13 | /** 14 | * Determined by the hash of the object ID, the field name value and it's type, 15 | * i.e. hash(parent.id || name || Name) 16 | */ 17 | id: object.UID, 18 | /** The value for the name of this field */ 19 | name: typeParameters[0], 20 | /** The value bound to this field */ 21 | value: typeParameters[1], 22 | }, 23 | }); 24 | } 25 | export interface BorrowArguments> { 26 | object: RawTransactionArgument; 27 | name: RawTransactionArgument; 28 | } 29 | export interface BorrowOptions> { 30 | package?: string; 31 | arguments: BorrowArguments | [object: RawTransactionArgument, name: RawTransactionArgument]; 32 | typeArguments: [string, string]; 33 | } 34 | /** 35 | * Immutably borrows the `object`s dynamic field with the name specified by 36 | * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a 37 | * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but 38 | * the value does not have the specified type. 39 | */ 40 | export function borrow>(options: BorrowOptions) { 41 | const packageAddress = options.package ?? '@local-pkg/suiii'; 42 | const argumentsTypes = [ 43 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 44 | `${options.typeArguments[0]}`, 45 | ] satisfies string[]; 46 | const parameterNames = ['object', 'name']; 47 | return (tx: Transaction) => 48 | tx.moveCall({ 49 | package: packageAddress, 50 | module: 'dynamic_field', 51 | function: 'borrow', 52 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 53 | typeArguments: options.typeArguments, 54 | }); 55 | } 56 | export interface BorrowMutArguments> { 57 | object: RawTransactionArgument; 58 | name: RawTransactionArgument; 59 | } 60 | export interface BorrowMutOptions> { 61 | package?: string; 62 | arguments: BorrowMutArguments | [object: RawTransactionArgument, name: RawTransactionArgument]; 63 | typeArguments: [string, string]; 64 | } 65 | /** 66 | * Mutably borrows the `object`s dynamic field with the name specified by 67 | * `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a 68 | * field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but 69 | * the value does not have the specified type. 70 | */ 71 | export function borrowMut>(options: BorrowMutOptions) { 72 | const packageAddress = options.package ?? '@local-pkg/suiii'; 73 | const argumentsTypes = [ 74 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 75 | `${options.typeArguments[0]}`, 76 | ] satisfies string[]; 77 | const parameterNames = ['object', 'name']; 78 | return (tx: Transaction) => 79 | tx.moveCall({ 80 | package: packageAddress, 81 | module: 'dynamic_field', 82 | function: 'borrow_mut', 83 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 84 | typeArguments: options.typeArguments, 85 | }); 86 | } 87 | export interface RemoveArguments> { 88 | object: RawTransactionArgument; 89 | name: RawTransactionArgument; 90 | } 91 | export interface RemoveOptions> { 92 | package?: string; 93 | arguments: RemoveArguments | [object: RawTransactionArgument, name: RawTransactionArgument]; 94 | typeArguments: [string, string]; 95 | } 96 | /** 97 | * Removes the `object`s dynamic field with the name specified by `name: Name` and 98 | * returns the bound value. Aborts with `EFieldDoesNotExist` if the object does not 99 | * have a field with that name. Aborts with `EFieldTypeMismatch` if the field 100 | * exists, but the value does not have the specified type. 101 | */ 102 | export function remove>(options: RemoveOptions) { 103 | const packageAddress = options.package ?? '@local-pkg/suiii'; 104 | const argumentsTypes = [ 105 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 106 | `${options.typeArguments[0]}`, 107 | ] satisfies string[]; 108 | const parameterNames = ['object', 'name']; 109 | return (tx: Transaction) => 110 | tx.moveCall({ 111 | package: packageAddress, 112 | module: 'dynamic_field', 113 | function: 'remove', 114 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 115 | typeArguments: options.typeArguments, 116 | }); 117 | } 118 | export interface Exists_Arguments> { 119 | object: RawTransactionArgument; 120 | name: RawTransactionArgument; 121 | } 122 | export interface Exists_Options> { 123 | package?: string; 124 | arguments: Exists_Arguments | [object: RawTransactionArgument, name: RawTransactionArgument]; 125 | typeArguments: [string]; 126 | } 127 | /** 128 | * Returns true if and only if the `object` has a dynamic field with the name 129 | * specified by `name: Name` but without specifying the `Value` type 130 | */ 131 | export function exists_>(options: Exists_Options) { 132 | const packageAddress = options.package ?? '@local-pkg/suiii'; 133 | const argumentsTypes = [ 134 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 135 | `${options.typeArguments[0]}`, 136 | ] satisfies string[]; 137 | const parameterNames = ['object', 'name']; 138 | return (tx: Transaction) => 139 | tx.moveCall({ 140 | package: packageAddress, 141 | module: 'dynamic_field', 142 | function: 'exists_', 143 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 144 | typeArguments: options.typeArguments, 145 | }); 146 | } 147 | export interface RemoveIfExistsArguments> { 148 | object: RawTransactionArgument; 149 | name: RawTransactionArgument; 150 | } 151 | export interface RemoveIfExistsOptions> { 152 | package?: string; 153 | arguments: 154 | | RemoveIfExistsArguments 155 | | [object: RawTransactionArgument, name: RawTransactionArgument]; 156 | typeArguments: [string, string]; 157 | } 158 | /** 159 | * Removes the dynamic field if it exists. Returns the `some(Value)` if it exists 160 | * or none otherwise. 161 | */ 162 | export function removeIfExists>(options: RemoveIfExistsOptions) { 163 | const packageAddress = options.package ?? '@local-pkg/suiii'; 164 | const argumentsTypes = [ 165 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 166 | `${options.typeArguments[0]}`, 167 | ] satisfies string[]; 168 | const parameterNames = ['object', 'name']; 169 | return (tx: Transaction) => 170 | tx.moveCall({ 171 | package: packageAddress, 172 | module: 'dynamic_field', 173 | function: 'remove_if_exists', 174 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 175 | typeArguments: options.typeArguments, 176 | }); 177 | } 178 | export interface ExistsWithTypeArguments> { 179 | object: RawTransactionArgument; 180 | name: RawTransactionArgument; 181 | } 182 | export interface ExistsWithTypeOptions> { 183 | package?: string; 184 | arguments: 185 | | ExistsWithTypeArguments 186 | | [object: RawTransactionArgument, name: RawTransactionArgument]; 187 | typeArguments: [string, string]; 188 | } 189 | /** 190 | * Returns true if and only if the `object` has a dynamic field with the name 191 | * specified by `name: Name` with an assigned value of type `Value`. 192 | */ 193 | export function existsWithType>(options: ExistsWithTypeOptions) { 194 | const packageAddress = options.package ?? '@local-pkg/suiii'; 195 | const argumentsTypes = [ 196 | '0x0000000000000000000000000000000000000000000000000000000000000002::object::UID', 197 | `${options.typeArguments[0]}`, 198 | ] satisfies string[]; 199 | const parameterNames = ['object', 'name']; 200 | return (tx: Transaction) => 201 | tx.moveCall({ 202 | package: packageAddress, 203 | module: 'dynamic_field', 204 | function: 'exists_with_type', 205 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 206 | typeArguments: options.typeArguments, 207 | }); 208 | } 209 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_cdp/request.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for handling requests in the BucketV2 CDP system. */ 7 | 8 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 9 | import { bcs, type BcsType } from '@mysten/sui/bcs'; 10 | import { type Transaction } from '@mysten/sui/transactions'; 11 | import * as coin from './deps/sui/coin.js'; 12 | import * as vec_set from './deps/sui/vec_set.js'; 13 | import * as type_name from './deps/std/type_name.js'; 14 | const $moduleName = '@local-pkg/bucket_v2_cdp::request'; 15 | export const UpdateRequest = new MoveStruct({ name: `${$moduleName}::UpdateRequest`, fields: { 16 | vault_id: bcs.Address, 17 | account: bcs.Address, 18 | deposit: coin.Coin, 19 | borrow_amount: bcs.u64(), 20 | repayment: coin.Coin, 21 | withdraw_amount: bcs.u64(), 22 | witnesses: vec_set.VecSet(type_name.TypeName), 23 | memo: bcs.string() 24 | } }); 25 | export interface AddWitnessArguments> { 26 | self: RawTransactionArgument; 27 | Witness: RawTransactionArgument; 28 | } 29 | export interface AddWitnessOptions> { 30 | package?: string; 31 | arguments: AddWitnessArguments | [ 32 | self: RawTransactionArgument, 33 | Witness: RawTransactionArgument 34 | ]; 35 | typeArguments: [ 36 | string, 37 | string 38 | ]; 39 | } 40 | /** Adds a witness type to the request, aborts if already present */ 41 | export function addWitness>(options: AddWitnessOptions) { 42 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 43 | const argumentsTypes = [ 44 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>`, 45 | `${options.typeArguments[1]}` 46 | ] satisfies string[]; 47 | const parameterNames = ["self", "Witness"]; 48 | return (tx: Transaction) => tx.moveCall({ 49 | package: packageAddress, 50 | module: 'request', 51 | function: 'add_witness', 52 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 53 | typeArguments: options.typeArguments 54 | }); 55 | } 56 | export interface VaultIdArguments { 57 | self: RawTransactionArgument; 58 | } 59 | export interface VaultIdOptions { 60 | package?: string; 61 | arguments: VaultIdArguments | [ 62 | self: RawTransactionArgument 63 | ]; 64 | typeArguments: [ 65 | string 66 | ]; 67 | } 68 | /** Getter for vault_id field */ 69 | export function vaultId(options: VaultIdOptions) { 70 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 71 | const argumentsTypes = [ 72 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 73 | ] satisfies string[]; 74 | const parameterNames = ["self"]; 75 | return (tx: Transaction) => tx.moveCall({ 76 | package: packageAddress, 77 | module: 'request', 78 | function: 'vault_id', 79 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 80 | typeArguments: options.typeArguments 81 | }); 82 | } 83 | export interface AccountArguments { 84 | self: RawTransactionArgument; 85 | } 86 | export interface AccountOptions { 87 | package?: string; 88 | arguments: AccountArguments | [ 89 | self: RawTransactionArgument 90 | ]; 91 | typeArguments: [ 92 | string 93 | ]; 94 | } 95 | /** Getter for account field */ 96 | export function account(options: AccountOptions) { 97 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 98 | const argumentsTypes = [ 99 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 100 | ] satisfies string[]; 101 | const parameterNames = ["self"]; 102 | return (tx: Transaction) => tx.moveCall({ 103 | package: packageAddress, 104 | module: 'request', 105 | function: 'account', 106 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 107 | typeArguments: options.typeArguments 108 | }); 109 | } 110 | export interface DepositAmountArguments { 111 | self: RawTransactionArgument; 112 | } 113 | export interface DepositAmountOptions { 114 | package?: string; 115 | arguments: DepositAmountArguments | [ 116 | self: RawTransactionArgument 117 | ]; 118 | typeArguments: [ 119 | string 120 | ]; 121 | } 122 | /** Getter for deposit amount (value of Coin) */ 123 | export function depositAmount(options: DepositAmountOptions) { 124 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 125 | const argumentsTypes = [ 126 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 127 | ] satisfies string[]; 128 | const parameterNames = ["self"]; 129 | return (tx: Transaction) => tx.moveCall({ 130 | package: packageAddress, 131 | module: 'request', 132 | function: 'deposit_amount', 133 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 134 | typeArguments: options.typeArguments 135 | }); 136 | } 137 | export interface RepayAmountArguments { 138 | self: RawTransactionArgument; 139 | } 140 | export interface RepayAmountOptions { 141 | package?: string; 142 | arguments: RepayAmountArguments | [ 143 | self: RawTransactionArgument 144 | ]; 145 | typeArguments: [ 146 | string 147 | ]; 148 | } 149 | /** Getter for repay amount (value of Coin) */ 150 | export function repayAmount(options: RepayAmountOptions) { 151 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 152 | const argumentsTypes = [ 153 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 154 | ] satisfies string[]; 155 | const parameterNames = ["self"]; 156 | return (tx: Transaction) => tx.moveCall({ 157 | package: packageAddress, 158 | module: 'request', 159 | function: 'repay_amount', 160 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 161 | typeArguments: options.typeArguments 162 | }); 163 | } 164 | export interface BorrowAmountArguments { 165 | self: RawTransactionArgument; 166 | } 167 | export interface BorrowAmountOptions { 168 | package?: string; 169 | arguments: BorrowAmountArguments | [ 170 | self: RawTransactionArgument 171 | ]; 172 | typeArguments: [ 173 | string 174 | ]; 175 | } 176 | /** Getter for borrow amount */ 177 | export function borrowAmount(options: BorrowAmountOptions) { 178 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 179 | const argumentsTypes = [ 180 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 181 | ] satisfies string[]; 182 | const parameterNames = ["self"]; 183 | return (tx: Transaction) => tx.moveCall({ 184 | package: packageAddress, 185 | module: 'request', 186 | function: 'borrow_amount', 187 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 188 | typeArguments: options.typeArguments 189 | }); 190 | } 191 | export interface WithdrawAmountArguments { 192 | self: RawTransactionArgument; 193 | } 194 | export interface WithdrawAmountOptions { 195 | package?: string; 196 | arguments: WithdrawAmountArguments | [ 197 | self: RawTransactionArgument 198 | ]; 199 | typeArguments: [ 200 | string 201 | ]; 202 | } 203 | /** Getter for withdraw amount */ 204 | export function withdrawAmount(options: WithdrawAmountOptions) { 205 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 206 | const argumentsTypes = [ 207 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 208 | ] satisfies string[]; 209 | const parameterNames = ["self"]; 210 | return (tx: Transaction) => tx.moveCall({ 211 | package: packageAddress, 212 | module: 'request', 213 | function: 'withdraw_amount', 214 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 215 | typeArguments: options.typeArguments 216 | }); 217 | } 218 | export interface MemoArguments { 219 | self: RawTransactionArgument; 220 | } 221 | export interface MemoOptions { 222 | package?: string; 223 | arguments: MemoArguments | [ 224 | self: RawTransactionArgument 225 | ]; 226 | typeArguments: [ 227 | string 228 | ]; 229 | } 230 | /** Getter for memo field */ 231 | export function memo(options: MemoOptions) { 232 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 233 | const argumentsTypes = [ 234 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 235 | ] satisfies string[]; 236 | const parameterNames = ["self"]; 237 | return (tx: Transaction) => tx.moveCall({ 238 | package: packageAddress, 239 | module: 'request', 240 | function: 'memo', 241 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 242 | typeArguments: options.typeArguments 243 | }); 244 | } 245 | export interface WitnessesArguments { 246 | self: RawTransactionArgument; 247 | } 248 | export interface WitnessesOptions { 249 | package?: string; 250 | arguments: WitnessesArguments | [ 251 | self: RawTransactionArgument 252 | ]; 253 | typeArguments: [ 254 | string 255 | ]; 256 | } 257 | /** Getter for witnesses set */ 258 | export function witnesses(options: WitnessesOptions) { 259 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_cdp'; 260 | const argumentsTypes = [ 261 | `${packageAddress}::request::UpdateRequest<${options.typeArguments[0]}>` 262 | ] satisfies string[]; 263 | const parameterNames = ["self"]; 264 | return (tx: Transaction) => tx.moveCall({ 265 | package: packageAddress, 266 | module: 'request', 267 | function: 'witnesses', 268 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 269 | typeArguments: options.typeArguments 270 | }); 271 | } -------------------------------------------------------------------------------- /src/_generated/bucket_v2_flash/config.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 5 | import { bcs } from '@mysten/sui/bcs'; 6 | import { type Transaction } from '@mysten/sui/transactions'; 7 | import * as float from './deps/bucket_v2_framework/float.js'; 8 | import * as object from './deps/sui/object.js'; 9 | import * as vec_map from './deps/sui/vec_map.js'; 10 | const $moduleName = '@local-pkg/bucket_v2_flash::config'; 11 | export const Config = new MoveStruct({ name: `${$moduleName}::Config`, fields: { 12 | fee_rate: float.Float, 13 | max_amount: bcs.u64(), 14 | total_amount: bcs.u64() 15 | } }); 16 | export const GlobalConfig = new MoveStruct({ name: `${$moduleName}::GlobalConfig`, fields: { 17 | id: object.UID, 18 | default_config: Config, 19 | partner_configs: vec_map.VecMap(bcs.Address, Config) 20 | } }); 21 | export const FlashMintReceipt = new MoveStruct({ name: `${$moduleName}::FlashMintReceipt`, fields: { 22 | partner: bcs.option(bcs.Address), 23 | mint_amount: bcs.u64(), 24 | fee_amount: bcs.u64() 25 | } }); 26 | export interface SetFlashConfigArguments { 27 | self: RawTransactionArgument; 28 | _: RawTransactionArgument; 29 | partner: RawTransactionArgument; 30 | feeRateBps: RawTransactionArgument; 31 | maxAmount: RawTransactionArgument; 32 | } 33 | export interface SetFlashConfigOptions { 34 | package?: string; 35 | arguments: SetFlashConfigArguments | [ 36 | self: RawTransactionArgument, 37 | _: RawTransactionArgument, 38 | partner: RawTransactionArgument, 39 | feeRateBps: RawTransactionArgument, 40 | maxAmount: RawTransactionArgument 41 | ]; 42 | } 43 | export function setFlashConfig(options: SetFlashConfigOptions) { 44 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 45 | const argumentsTypes = [ 46 | `${packageAddress}::config::GlobalConfig`, 47 | `${packageAddress}::admin::AdminCap`, 48 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option
', 49 | 'u64', 50 | 'u64' 51 | ] satisfies string[]; 52 | const parameterNames = ["self", "_", "partner", "feeRateBps", "maxAmount"]; 53 | return (tx: Transaction) => tx.moveCall({ 54 | package: packageAddress, 55 | module: 'config', 56 | function: 'set_flash_config', 57 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 58 | }); 59 | } 60 | export interface FlashMintArguments { 61 | self: RawTransactionArgument; 62 | treasury: RawTransactionArgument; 63 | partner: RawTransactionArgument; 64 | value: RawTransactionArgument; 65 | } 66 | export interface FlashMintOptions { 67 | package?: string; 68 | arguments: FlashMintArguments | [ 69 | self: RawTransactionArgument, 70 | treasury: RawTransactionArgument, 71 | partner: RawTransactionArgument, 72 | value: RawTransactionArgument 73 | ]; 74 | } 75 | export function flashMint(options: FlashMintOptions) { 76 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 77 | const argumentsTypes = [ 78 | `${packageAddress}::config::GlobalConfig`, 79 | `${packageAddress}::usdb::Treasury`, 80 | `0x0000000000000000000000000000000000000000000000000000000000000001::option::Option<${packageAddress}::account::AccountRequest>`, 81 | 'u64' 82 | ] satisfies string[]; 83 | const parameterNames = ["self", "treasury", "partner", "value"]; 84 | return (tx: Transaction) => tx.moveCall({ 85 | package: packageAddress, 86 | module: 'config', 87 | function: 'flash_mint', 88 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 89 | }); 90 | } 91 | export interface FlashBurnArguments { 92 | self: RawTransactionArgument; 93 | treasury: RawTransactionArgument; 94 | repayment: RawTransactionArgument; 95 | receipt: RawTransactionArgument; 96 | } 97 | export interface FlashBurnOptions { 98 | package?: string; 99 | arguments: FlashBurnArguments | [ 100 | self: RawTransactionArgument, 101 | treasury: RawTransactionArgument, 102 | repayment: RawTransactionArgument, 103 | receipt: RawTransactionArgument 104 | ]; 105 | } 106 | export function flashBurn(options: FlashBurnOptions) { 107 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 108 | const argumentsTypes = [ 109 | `${packageAddress}::config::GlobalConfig`, 110 | `${packageAddress}::usdb::Treasury`, 111 | `0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::usdb::USDB>`, 112 | `${packageAddress}::config::FlashMintReceipt` 113 | ] satisfies string[]; 114 | const parameterNames = ["self", "treasury", "repayment", "receipt"]; 115 | return (tx: Transaction) => tx.moveCall({ 116 | package: packageAddress, 117 | module: 'config', 118 | function: 'flash_burn', 119 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 120 | }); 121 | } 122 | export interface ConfigArguments { 123 | self: RawTransactionArgument; 124 | partnerOpt: RawTransactionArgument; 125 | } 126 | export interface ConfigOptions { 127 | package?: string; 128 | arguments: ConfigArguments | [ 129 | self: RawTransactionArgument, 130 | partnerOpt: RawTransactionArgument 131 | ]; 132 | } 133 | export function config(options: ConfigOptions) { 134 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 135 | const argumentsTypes = [ 136 | `${packageAddress}::config::GlobalConfig`, 137 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option
' 138 | ] satisfies string[]; 139 | const parameterNames = ["self", "partnerOpt"]; 140 | return (tx: Transaction) => tx.moveCall({ 141 | package: packageAddress, 142 | module: 'config', 143 | function: 'config', 144 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 145 | }); 146 | } 147 | export interface FeeRateArguments { 148 | self: RawTransactionArgument; 149 | partnerOpt: RawTransactionArgument; 150 | } 151 | export interface FeeRateOptions { 152 | package?: string; 153 | arguments: FeeRateArguments | [ 154 | self: RawTransactionArgument, 155 | partnerOpt: RawTransactionArgument 156 | ]; 157 | } 158 | export function feeRate(options: FeeRateOptions) { 159 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 160 | const argumentsTypes = [ 161 | `${packageAddress}::config::GlobalConfig`, 162 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option
' 163 | ] satisfies string[]; 164 | const parameterNames = ["self", "partnerOpt"]; 165 | return (tx: Transaction) => tx.moveCall({ 166 | package: packageAddress, 167 | module: 'config', 168 | function: 'fee_rate', 169 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 170 | }); 171 | } 172 | export interface MaxAmountArguments { 173 | self: RawTransactionArgument; 174 | partnerOpt: RawTransactionArgument; 175 | } 176 | export interface MaxAmountOptions { 177 | package?: string; 178 | arguments: MaxAmountArguments | [ 179 | self: RawTransactionArgument, 180 | partnerOpt: RawTransactionArgument 181 | ]; 182 | } 183 | export function maxAmount(options: MaxAmountOptions) { 184 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 185 | const argumentsTypes = [ 186 | `${packageAddress}::config::GlobalConfig`, 187 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option
' 188 | ] satisfies string[]; 189 | const parameterNames = ["self", "partnerOpt"]; 190 | return (tx: Transaction) => tx.moveCall({ 191 | package: packageAddress, 192 | module: 'config', 193 | function: 'max_amount', 194 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 195 | }); 196 | } 197 | export interface TotalAmountArguments { 198 | self: RawTransactionArgument; 199 | partnerOpt: RawTransactionArgument; 200 | } 201 | export interface TotalAmountOptions { 202 | package?: string; 203 | arguments: TotalAmountArguments | [ 204 | self: RawTransactionArgument, 205 | partnerOpt: RawTransactionArgument 206 | ]; 207 | } 208 | export function totalAmount(options: TotalAmountOptions) { 209 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 210 | const argumentsTypes = [ 211 | `${packageAddress}::config::GlobalConfig`, 212 | '0x0000000000000000000000000000000000000000000000000000000000000001::option::Option
' 213 | ] satisfies string[]; 214 | const parameterNames = ["self", "partnerOpt"]; 215 | return (tx: Transaction) => tx.moveCall({ 216 | package: packageAddress, 217 | module: 'config', 218 | function: 'total_amount', 219 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 220 | }); 221 | } 222 | export interface MintAmountArguments { 223 | receipt: RawTransactionArgument; 224 | } 225 | export interface MintAmountOptions { 226 | package?: string; 227 | arguments: MintAmountArguments | [ 228 | receipt: RawTransactionArgument 229 | ]; 230 | } 231 | export function mintAmount(options: MintAmountOptions) { 232 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 233 | const argumentsTypes = [ 234 | `${packageAddress}::config::FlashMintReceipt` 235 | ] satisfies string[]; 236 | const parameterNames = ["receipt"]; 237 | return (tx: Transaction) => tx.moveCall({ 238 | package: packageAddress, 239 | module: 'config', 240 | function: 'mint_amount', 241 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 242 | }); 243 | } 244 | export interface FeeAmountArguments { 245 | receipt: RawTransactionArgument; 246 | } 247 | export interface FeeAmountOptions { 248 | package?: string; 249 | arguments: FeeAmountArguments | [ 250 | receipt: RawTransactionArgument 251 | ]; 252 | } 253 | export function feeAmount(options: FeeAmountOptions) { 254 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_flash'; 255 | const argumentsTypes = [ 256 | `${packageAddress}::config::FlashMintReceipt` 257 | ] satisfies string[]; 258 | const parameterNames = ["receipt"]; 259 | return (tx: Transaction) => tx.moveCall({ 260 | package: packageAddress, 261 | module: 'config', 262 | function: 'fee_amount', 263 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 264 | }); 265 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/_generated/bucket_v2_framework/liability.ts: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * 3 | **************************************************************/ 4 | 5 | 6 | /** Module for managing Credit and Debt for DeFi protocol usage */ 7 | 8 | import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js'; 9 | import { bcs } from '@mysten/sui/bcs'; 10 | import { type Transaction } from '@mysten/sui/transactions'; 11 | const $moduleName = '@local-pkg/bucket_v2_framework::liability'; 12 | export const Credit = new MoveStruct({ name: `${$moduleName}::Credit`, fields: { 13 | value: bcs.u64() 14 | } }); 15 | export const Debt = new MoveStruct({ name: `${$moduleName}::Debt`, fields: { 16 | value: bcs.u64() 17 | } }); 18 | export interface NewArguments { 19 | value: RawTransactionArgument; 20 | } 21 | export interface NewOptions { 22 | package?: string; 23 | arguments: NewArguments | [ 24 | value: RawTransactionArgument 25 | ]; 26 | typeArguments: [ 27 | string 28 | ]; 29 | } 30 | /** Public Funs */ 31 | export function _new(options: NewOptions) { 32 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 33 | const argumentsTypes = [ 34 | 'u64' 35 | ] satisfies string[]; 36 | const parameterNames = ["value"]; 37 | return (tx: Transaction) => tx.moveCall({ 38 | package: packageAddress, 39 | module: 'liability', 40 | function: 'new', 41 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 42 | typeArguments: options.typeArguments 43 | }); 44 | } 45 | export interface ZeroCreditOptions { 46 | package?: string; 47 | arguments?: [ 48 | ]; 49 | typeArguments: [ 50 | string 51 | ]; 52 | } 53 | export function zeroCredit(options: ZeroCreditOptions) { 54 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 55 | return (tx: Transaction) => tx.moveCall({ 56 | package: packageAddress, 57 | module: 'liability', 58 | function: 'zero_credit', 59 | typeArguments: options.typeArguments 60 | }); 61 | } 62 | export interface ZeroDebtOptions { 63 | package?: string; 64 | arguments?: [ 65 | ]; 66 | typeArguments: [ 67 | string 68 | ]; 69 | } 70 | export function zeroDebt(options: ZeroDebtOptions) { 71 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 72 | return (tx: Transaction) => tx.moveCall({ 73 | package: packageAddress, 74 | module: 'liability', 75 | function: 'zero_debt', 76 | typeArguments: options.typeArguments 77 | }); 78 | } 79 | export interface DestroyZeroCreditArguments { 80 | credit: RawTransactionArgument; 81 | } 82 | export interface DestroyZeroCreditOptions { 83 | package?: string; 84 | arguments: DestroyZeroCreditArguments | [ 85 | credit: RawTransactionArgument 86 | ]; 87 | typeArguments: [ 88 | string 89 | ]; 90 | } 91 | export function destroyZeroCredit(options: DestroyZeroCreditOptions) { 92 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 93 | const argumentsTypes = [ 94 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>` 95 | ] satisfies string[]; 96 | const parameterNames = ["credit"]; 97 | return (tx: Transaction) => tx.moveCall({ 98 | package: packageAddress, 99 | module: 'liability', 100 | function: 'destroy_zero_credit', 101 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 102 | typeArguments: options.typeArguments 103 | }); 104 | } 105 | export interface DestroyZeroDebtArguments { 106 | debt: RawTransactionArgument; 107 | } 108 | export interface DestroyZeroDebtOptions { 109 | package?: string; 110 | arguments: DestroyZeroDebtArguments | [ 111 | debt: RawTransactionArgument 112 | ]; 113 | typeArguments: [ 114 | string 115 | ]; 116 | } 117 | export function destroyZeroDebt(options: DestroyZeroDebtOptions) { 118 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 119 | const argumentsTypes = [ 120 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 121 | ] satisfies string[]; 122 | const parameterNames = ["debt"]; 123 | return (tx: Transaction) => tx.moveCall({ 124 | package: packageAddress, 125 | module: 'liability', 126 | function: 'destroy_zero_debt', 127 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 128 | typeArguments: options.typeArguments 129 | }); 130 | } 131 | export interface AddCreditArguments { 132 | self: RawTransactionArgument; 133 | credit: RawTransactionArgument; 134 | } 135 | export interface AddCreditOptions { 136 | package?: string; 137 | arguments: AddCreditArguments | [ 138 | self: RawTransactionArgument, 139 | credit: RawTransactionArgument 140 | ]; 141 | typeArguments: [ 142 | string 143 | ]; 144 | } 145 | export function addCredit(options: AddCreditOptions) { 146 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 147 | const argumentsTypes = [ 148 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>`, 149 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>` 150 | ] satisfies string[]; 151 | const parameterNames = ["self", "credit"]; 152 | return (tx: Transaction) => tx.moveCall({ 153 | package: packageAddress, 154 | module: 'liability', 155 | function: 'add_credit', 156 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 157 | typeArguments: options.typeArguments 158 | }); 159 | } 160 | export interface AddDebtArguments { 161 | self: RawTransactionArgument; 162 | debt: RawTransactionArgument; 163 | } 164 | export interface AddDebtOptions { 165 | package?: string; 166 | arguments: AddDebtArguments | [ 167 | self: RawTransactionArgument, 168 | debt: RawTransactionArgument 169 | ]; 170 | typeArguments: [ 171 | string 172 | ]; 173 | } 174 | export function addDebt(options: AddDebtOptions) { 175 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 176 | const argumentsTypes = [ 177 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>`, 178 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 179 | ] satisfies string[]; 180 | const parameterNames = ["self", "debt"]; 181 | return (tx: Transaction) => tx.moveCall({ 182 | package: packageAddress, 183 | module: 'liability', 184 | function: 'add_debt', 185 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 186 | typeArguments: options.typeArguments 187 | }); 188 | } 189 | export interface AutoSettleArguments { 190 | credit: RawTransactionArgument; 191 | debt: RawTransactionArgument; 192 | } 193 | export interface AutoSettleOptions { 194 | package?: string; 195 | arguments: AutoSettleArguments | [ 196 | credit: RawTransactionArgument, 197 | debt: RawTransactionArgument 198 | ]; 199 | typeArguments: [ 200 | string 201 | ]; 202 | } 203 | export function autoSettle(options: AutoSettleOptions) { 204 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 205 | const argumentsTypes = [ 206 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>`, 207 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 208 | ] satisfies string[]; 209 | const parameterNames = ["credit", "debt"]; 210 | return (tx: Transaction) => tx.moveCall({ 211 | package: packageAddress, 212 | module: 'liability', 213 | function: 'auto_settle', 214 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 215 | typeArguments: options.typeArguments 216 | }); 217 | } 218 | export interface SettleDebtArguments { 219 | credit: RawTransactionArgument; 220 | debt: RawTransactionArgument; 221 | } 222 | export interface SettleDebtOptions { 223 | package?: string; 224 | arguments: SettleDebtArguments | [ 225 | credit: RawTransactionArgument, 226 | debt: RawTransactionArgument 227 | ]; 228 | typeArguments: [ 229 | string 230 | ]; 231 | } 232 | export function settleDebt(options: SettleDebtOptions) { 233 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 234 | const argumentsTypes = [ 235 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>`, 236 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 237 | ] satisfies string[]; 238 | const parameterNames = ["credit", "debt"]; 239 | return (tx: Transaction) => tx.moveCall({ 240 | package: packageAddress, 241 | module: 'liability', 242 | function: 'settle_debt', 243 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 244 | typeArguments: options.typeArguments 245 | }); 246 | } 247 | export interface SettleCreditArguments { 248 | debt: RawTransactionArgument; 249 | credit: RawTransactionArgument; 250 | } 251 | export interface SettleCreditOptions { 252 | package?: string; 253 | arguments: SettleCreditArguments | [ 254 | debt: RawTransactionArgument, 255 | credit: RawTransactionArgument 256 | ]; 257 | typeArguments: [ 258 | string 259 | ]; 260 | } 261 | export function settleCredit(options: SettleCreditOptions) { 262 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 263 | const argumentsTypes = [ 264 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>`, 265 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>` 266 | ] satisfies string[]; 267 | const parameterNames = ["debt", "credit"]; 268 | return (tx: Transaction) => tx.moveCall({ 269 | package: packageAddress, 270 | module: 'liability', 271 | function: 'settle_credit', 272 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 273 | typeArguments: options.typeArguments 274 | }); 275 | } 276 | export interface CreditValueArguments { 277 | credit: RawTransactionArgument; 278 | } 279 | export interface CreditValueOptions { 280 | package?: string; 281 | arguments: CreditValueArguments | [ 282 | credit: RawTransactionArgument 283 | ]; 284 | typeArguments: [ 285 | string 286 | ]; 287 | } 288 | export function creditValue(options: CreditValueOptions) { 289 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 290 | const argumentsTypes = [ 291 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>` 292 | ] satisfies string[]; 293 | const parameterNames = ["credit"]; 294 | return (tx: Transaction) => tx.moveCall({ 295 | package: packageAddress, 296 | module: 'liability', 297 | function: 'credit_value', 298 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 299 | typeArguments: options.typeArguments 300 | }); 301 | } 302 | export interface DebtValueArguments { 303 | debt: RawTransactionArgument; 304 | } 305 | export interface DebtValueOptions { 306 | package?: string; 307 | arguments: DebtValueArguments | [ 308 | debt: RawTransactionArgument 309 | ]; 310 | typeArguments: [ 311 | string 312 | ]; 313 | } 314 | export function debtValue(options: DebtValueOptions) { 315 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 316 | const argumentsTypes = [ 317 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 318 | ] satisfies string[]; 319 | const parameterNames = ["debt"]; 320 | return (tx: Transaction) => tx.moveCall({ 321 | package: packageAddress, 322 | module: 'liability', 323 | function: 'debt_value', 324 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 325 | typeArguments: options.typeArguments 326 | }); 327 | } 328 | export interface DestroyCreditForTestingArguments { 329 | credit: RawTransactionArgument; 330 | } 331 | export interface DestroyCreditForTestingOptions { 332 | package?: string; 333 | arguments: DestroyCreditForTestingArguments | [ 334 | credit: RawTransactionArgument 335 | ]; 336 | typeArguments: [ 337 | string 338 | ]; 339 | } 340 | export function destroyCreditForTesting(options: DestroyCreditForTestingOptions) { 341 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 342 | const argumentsTypes = [ 343 | `${packageAddress}::liability::Credit<${options.typeArguments[0]}>` 344 | ] satisfies string[]; 345 | const parameterNames = ["credit"]; 346 | return (tx: Transaction) => tx.moveCall({ 347 | package: packageAddress, 348 | module: 'liability', 349 | function: 'destroy_credit_for_testing', 350 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 351 | typeArguments: options.typeArguments 352 | }); 353 | } 354 | export interface DestroyDebtForTestingArguments { 355 | debt: RawTransactionArgument; 356 | } 357 | export interface DestroyDebtForTestingOptions { 358 | package?: string; 359 | arguments: DestroyDebtForTestingArguments | [ 360 | debt: RawTransactionArgument 361 | ]; 362 | typeArguments: [ 363 | string 364 | ]; 365 | } 366 | export function destroyDebtForTesting(options: DestroyDebtForTestingOptions) { 367 | const packageAddress = options.package ?? '@local-pkg/bucket_v2_framework'; 368 | const argumentsTypes = [ 369 | `${packageAddress}::liability::Debt<${options.typeArguments[0]}>` 370 | ] satisfies string[]; 371 | const parameterNames = ["debt"]; 372 | return (tx: Transaction) => tx.moveCall({ 373 | package: packageAddress, 374 | module: 'liability', 375 | function: 'destroy_debt_for_testing', 376 | arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames), 377 | typeArguments: options.typeArguments 378 | }); 379 | } -------------------------------------------------------------------------------- /test/e2e/client.test.ts: -------------------------------------------------------------------------------- 1 | import { getFullnodeUrl, SuiClient } from '@mysten/sui/client'; 2 | import { Transaction, TransactionResult } from '@mysten/sui/transactions'; 3 | import { normalizeStructTag, SUI_TYPE_ARG } from '@mysten/sui/utils'; 4 | import { describe, expect, it } from 'vitest'; 5 | 6 | import { BucketClient } from '../../src/client.js'; 7 | import { coinWithBalance, destroyZeroCoin, getZeroCoin } from '../../src/utils/transaction.js'; 8 | 9 | describe('Interacting with Bucket Client on mainnet', () => { 10 | const network = 'mainnet'; 11 | const testAccount = '0x7a718956581fbe4a568d135fef5161024e74af87a073a1489e57ebef53744652'; 12 | const suiClient = new SuiClient({ url: getFullnodeUrl(network) }); 13 | const bucketClient = new BucketClient({ suiClient, network }); 14 | const usdbCoinType = bucketClient.getUsdbCoinType(); 15 | const usdcCoinType = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'; 16 | 17 | it('test usdbCoinType()', async () => { 18 | const usdbMetadata = await suiClient.getCoinMetadata({ 19 | coinType: usdbCoinType, 20 | }); 21 | expect(usdbMetadata?.decimals).toBe(6); 22 | expect(usdbMetadata?.symbol).toBe('USDB'); 23 | expect(usdbMetadata?.name).toBe('Bucket USD'); 24 | }, 20_000); 25 | 26 | it('test getAllOraclePrices()', async () => { 27 | const prices = await bucketClient.getAllOraclePrices(); 28 | Object.keys(prices).map((coinType) => { 29 | const price = prices[coinType]; 30 | if (coinType.includes('BTC')) { 31 | expect(price).toBeLessThan(500000); 32 | expect(price).toBeGreaterThan(10000); 33 | } else if (coinType.includes('ETH')) { 34 | expect(price).toBeLessThan(10000); 35 | expect(price).toBeGreaterThan(1000); 36 | } else if (coinType.includes('::USD') || coinType.includes('::BUCK')) { 37 | expect(price).toBeLessThan(1.1); 38 | expect(price).toBeGreaterThan(0.9); 39 | } else { 40 | expect(price).toBeDefined(); 41 | } 42 | }); 43 | }, 20_000); 44 | 45 | it('test getAccountPositions() and getUserPositions()', async () => { 46 | const accountPositions = await bucketClient.getAccountPositions({ address: testAccount }); 47 | const userPositions = await bucketClient.getUserPositions({ address: testAccount }); 48 | expect(accountPositions.length).toBeLessThanOrEqual(userPositions.length); 49 | }, 20_000); 50 | 51 | it('test buildClaimBorrowRewardsTransaction()', async () => { 52 | const tx = new Transaction(); 53 | tx.setSender(testAccount); 54 | const result = bucketClient.getAllCollateralTypes().reduce( 55 | (result, coinType) => { 56 | const newResult = result; 57 | const rewardsRecord = bucketClient.buildClaimBorrowRewardsTransaction(tx, { coinType }); 58 | Object.entries(rewardsRecord).map(([coinType, rewardCoin]) => { 59 | if (newResult[coinType]) { 60 | tx.mergeCoins(newResult[coinType], [rewardCoin]); 61 | } else { 62 | newResult[coinType] = rewardCoin; 63 | } 64 | }); 65 | return newResult; 66 | }, 67 | {} as Record, 68 | ); 69 | tx.transferObjects(Object.values(result), testAccount); 70 | const res = await suiClient.dryRunTransactionBlock({ 71 | transactionBlock: await tx.build({ client: suiClient }), 72 | }); 73 | expect(res.balanceChanges.length).toBe(3); 74 | res.balanceChanges.map((bc) => { 75 | if (normalizeStructTag(bc.coinType) !== normalizeStructTag('0x2::sui::SUI')) { 76 | expect(Number(bc.amount)).toBeGreaterThan(0); 77 | } 78 | }); 79 | }, 20_000); 80 | 81 | it('test psmSwapIn()', async () => { 82 | // tx 83 | const tx = new Transaction(); 84 | tx.setSender(testAccount); 85 | 86 | const amount = 1 * 10 ** 6; // 1 USDC or USDT 87 | 88 | const usdcCoin = coinWithBalance({ type: usdcCoinType, balance: amount }); 89 | const usdbCoin1 = await bucketClient.buildPSMSwapInTransaction(tx, { 90 | coinType: usdcCoinType, 91 | inputCoinOrAmount: usdcCoin, 92 | }); 93 | 94 | tx.transferObjects([usdbCoin1], testAccount); 95 | 96 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 97 | transactionBlock: await tx.build({ client: suiClient }), 98 | }); 99 | expect(dryrunRes.effects.status.status).toBe('success'); 100 | expect(dryrunRes.balanceChanges.find((c) => c.coinType === usdcCoinType)?.amount).toBe('-1000000'); 101 | expect(dryrunRes.balanceChanges.find((c) => c.coinType === usdbCoinType)?.amount).toBe('1000000'); 102 | }, 20_000); 103 | 104 | it('test flashMint 1000 USDB with default fee config', async () => { 105 | // tx 106 | const tx = new Transaction(); 107 | tx.setSender(testAccount); 108 | 109 | const amount = 1_000 * 10 ** 6; // 1000 USDB 110 | const feeAmount = amount * 0.0005; 111 | 112 | // flash mint 113 | const [usdbCoin, flashMintReceipt] = bucketClient.flashMint(tx, { amount }); 114 | const feeCollateralCoin = coinWithBalance({ type: usdcCoinType, balance: feeAmount }); 115 | const feeUsdbCoin = await bucketClient.buildPSMSwapInTransaction(tx, { 116 | coinType: usdcCoinType, 117 | inputCoinOrAmount: feeCollateralCoin, 118 | }); 119 | tx.mergeCoins(usdbCoin, [feeUsdbCoin]); 120 | bucketClient.flashBurn(tx, { usdbCoin, flashMintReceipt }); 121 | 122 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 123 | transactionBlock: await tx.build({ client: suiClient }), 124 | }); 125 | 126 | expect(dryrunRes.effects.status.status).toBe('success'); 127 | }, 20_000); 128 | 129 | it('test psmSwapIn() then deposit to saving pool', async () => { 130 | // tx 131 | const tx = new Transaction(); 132 | tx.setSender(testAccount); 133 | 134 | const amount = 0.1 * 10 ** 6; // 0.1 USDB 135 | const usdcCoin = coinWithBalance({ type: usdcCoinType, balance: amount }); 136 | 137 | // psmSwapIn 138 | const usdbCoin = await bucketClient.buildPSMSwapInTransaction(tx, { 139 | coinType: usdcCoinType, 140 | inputCoinOrAmount: usdcCoin, 141 | }); 142 | 143 | bucketClient.buildDepositToSavingPoolTransaction(tx, { 144 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 145 | address: testAccount, 146 | depositCoinOrAmount: usdbCoin, 147 | }); 148 | 149 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 150 | transactionBlock: await tx.build({ client: suiClient }), 151 | }); 152 | 153 | expect(dryrunRes.effects.status.status).toBe('success'); 154 | }, 20_000); 155 | 156 | it('test deposit to saving pool', async () => { 157 | // tx 158 | const tx = new Transaction(); 159 | tx.setSender(testAccount); 160 | 161 | const amount = 0.1 * 10 ** 6; // 0.1 USDB 162 | 163 | const usdbCoin = coinWithBalance({ type: usdbCoinType, balance: amount }); 164 | bucketClient.buildDepositToSavingPoolTransaction(tx, { 165 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 166 | address: testAccount, 167 | depositCoinOrAmount: usdbCoin, 168 | }); 169 | 170 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 171 | transactionBlock: await tx.build({ client: suiClient }), 172 | }); 173 | 174 | expect(dryrunRes.effects.status.status).toBe('success'); 175 | }, 20_000); 176 | 177 | it('test withdraw from saving pool', async () => { 178 | // tx 179 | const tx = new Transaction(); 180 | tx.setSender(testAccount); 181 | 182 | const amount = 0.1 * 10 ** 6; // 0.1 SUSDB 183 | 184 | const usdbCoin = bucketClient.buildWithdrawFromSavingPoolTransaction(tx, { 185 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 186 | amount, 187 | }); 188 | 189 | tx.transferObjects([usdbCoin], testAccount); 190 | 191 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 192 | transactionBlock: await tx.build({ client: suiClient }), 193 | }); 194 | 195 | expect(dryrunRes.effects.status.status).toBe('success'); 196 | }, 20_000); 197 | 198 | it('test claim from saving pool', async () => { 199 | // tx 200 | const tx = new Transaction(); 201 | tx.setSender(testAccount); 202 | 203 | const rewardsRecord = bucketClient.buildClaimSavingRewardsTransaction(tx, { 204 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 205 | }); 206 | 207 | tx.transferObjects(Object.values(rewardsRecord), testAccount); 208 | 209 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 210 | transactionBlock: await tx.build({ client: suiClient }), 211 | }); 212 | 213 | expect(dryrunRes.effects.status.status).toBe('success'); 214 | }, 20_000); 215 | 216 | it('test getAllVaultObjects()', async () => { 217 | const allVaults = await bucketClient.getAllVaultObjects(); 218 | Object.entries(allVaults) 219 | .filter(([coinType]) => coinType.includes('SCALLOP_') && !coinType.includes('_DEEP')) 220 | .map(([, vault]) => { 221 | expect( 222 | vault.rewardRate['0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA'], 223 | ).toBeDefined(); 224 | }); 225 | }, 20_000); 226 | 227 | it('test buildManagePositionTransaction()', async () => { 228 | const depositAmount = 1 * 10 ** 9; // 1 SUI 229 | const borrowAmount = 1 * 10 ** 6; // 1 USDB 230 | const tx = new Transaction(); 231 | tx.setSender(testAccount); 232 | 233 | const [, usdbCoin] = await bucketClient.buildManagePositionTransaction(tx, { 234 | coinType: SUI_TYPE_ARG, 235 | depositCoinOrAmount: depositAmount, 236 | borrowAmount, 237 | }); 238 | tx.transferObjects([usdbCoin], testAccount); 239 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 240 | transactionBlock: await tx.build({ client: suiClient }), 241 | }); 242 | expect(dryrunRes.effects.status.status).toBe('success'); 243 | const positionUpdatedEvent = dryrunRes.events.find((e) => e.type.includes('PositionUpdated')); 244 | expect(positionUpdatedEvent).toBeDefined(); 245 | if (!positionUpdatedEvent) return; 246 | const positionUpdatedEventData = positionUpdatedEvent.parsedJson as { 247 | vault_id: string; 248 | coll_type: string; 249 | debtor: string; 250 | deposit_amount: string; 251 | borrow_amount: string; 252 | withdraw_amount: string; 253 | repay_amount: string; 254 | interest_amount: string; 255 | current_coll_amount: string; 256 | current_debt_amount: string; 257 | memo: string; 258 | }; 259 | expect(positionUpdatedEventData.debtor).toBe(testAccount); 260 | expect(+positionUpdatedEventData.deposit_amount).toBe(depositAmount); 261 | expect(+positionUpdatedEventData.borrow_amount).toBe(borrowAmount); 262 | expect(+positionUpdatedEventData.withdraw_amount).toBe(0); 263 | expect(+positionUpdatedEventData.repay_amount).toBe(0); 264 | expect(positionUpdatedEventData.memo).toBe('cdp_manage'); 265 | }, 20_000); 266 | 267 | it('test deposit/withdraw zero to saving pool', async () => { 268 | // tx 269 | const tx = new Transaction(); 270 | tx.setSender(testAccount); 271 | const zeroUsdbCoin = getZeroCoin(tx, { coinType: usdbCoinType }); 272 | bucketClient.buildDepositToSavingPoolTransaction(tx, { 273 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 274 | address: testAccount, 275 | depositCoinOrAmount: zeroUsdbCoin, 276 | }); 277 | 278 | const usdbOut = bucketClient.buildWithdrawFromSavingPoolTransaction(tx, { 279 | lpType: '0x38f61c75fa8407140294c84167dd57684580b55c3066883b48dedc344b1cde1e::susdb::SUSDB', 280 | amount: 0, 281 | }); 282 | destroyZeroCoin(tx, { coinType: usdbCoinType, coin: usdbOut }); 283 | 284 | const dryrunRes = await suiClient.dryRunTransactionBlock({ 285 | transactionBlock: await tx.build({ client: suiClient }), 286 | }); 287 | 288 | expect(dryrunRes.effects.status.status).toBe('success'); 289 | }, 20_000); 290 | }); 291 | 292 | // describe('Interacting with Bucket Client on testnet', () => { 293 | // const network = 'testnet'; 294 | // const testAccount = '0xa718efc9ae5452b22865101438a8286a5b0ca609cc58018298108c636cdda89c'; 295 | // const suiClient = new SuiClient({ url: getFullnodeUrl(network) }); 296 | // const bucketClient = new BucketClient({ suiClient, network }); 297 | // const usdbCoinType = bucketClient.getUsdbCoinType(); 298 | // const usdcCoinType = '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC'; 299 | 300 | // it('test psmSwapIn()', async () => { 301 | // // tx 302 | // const tx = new Transaction(); 303 | // tx.setSender(testAccount); 304 | 305 | // const amount = 0.1 * 10 ** 6; // 1 USDC 306 | // const coinType = usdcCoinType; 307 | 308 | // const inputCoin = coinWithBalance({ type: coinType, balance: amount }); 309 | // const usdbCoin = await bucketClient.buildPSMSwapInTransaction(tx, { 310 | // coinType, 311 | // inputCoinOrAmount: inputCoin, 312 | // }); 313 | // tx.transferObjects([usdbCoin], testAccount); 314 | 315 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 316 | // transactionBlock: await tx.build({ client: suiClient }), 317 | // }); 318 | // expect(dryrunRes.effects.status.status).toBe('success'); 319 | // }); 320 | 321 | // it('test psmSwapOut()', async () => { 322 | // // tx 323 | // const tx = new Transaction(); 324 | // tx.setSender(testAccount); 325 | 326 | // const amount = 0.1 * 10 ** 6; // 1 USDB 327 | // const usdbCoin = coinWithBalance({ type: usdbCoinType, balance: amount }); 328 | 329 | // const inputCoin = await bucketClient.buildPSMSwapOutTransaction(tx, { 330 | // coinType: usdcCoinType, 331 | // usdbCoinOrAmount: usdbCoin, 332 | // }); 333 | // tx.transferObjects([inputCoin], testAccount); 334 | 335 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 336 | // transactionBlock: await tx.build({ client: suiClient }), 337 | // }); 338 | 339 | // expect(dryrunRes.effects.status.status).toBe('success'); 340 | // }); 341 | 342 | // it('test flashMint 1 USDB with default fee config', async () => { 343 | // // tx 344 | // const tx = new Transaction(); 345 | // tx.setSender(testAccount); 346 | 347 | // const amount = 0.1 * 10 ** 6; // 1 USDB 348 | // const feeAmount = (amount * 30) / 10000; 349 | // const coinType = usdcCoinType; 350 | 351 | // // flash mint 352 | // const [usdbCoin, flashMintReceipt] = bucketClient.flashMint(tx, { amount }); 353 | // const feeCollateralCoin = coinWithBalance({ type: coinType, balance: feeAmount }); 354 | // const feeUsdbCoin = await bucketClient.buildPSMSwapInTransaction(tx, { 355 | // coinType, 356 | // inputCoinOrAmount: feeCollateralCoin, 357 | // }); 358 | // tx.mergeCoins(usdbCoin, [feeUsdbCoin]); 359 | // bucketClient.flashBurn(tx, { usdbCoin, flashMintReceipt }); 360 | 361 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 362 | // transactionBlock: await tx.build({ client: suiClient }), 363 | // }); 364 | 365 | // expect(dryrunRes.effects.status.status).toBe('success'); 366 | // }); 367 | 368 | // it('test psmSwapIn() then deposit to saving pool', async () => { 369 | // // tx 370 | // const tx = new Transaction(); 371 | // tx.setSender(testAccount); 372 | 373 | // const amount = 0.1 * 10 ** 6; // 0.1 USDB 374 | // const usdcCoin = coinWithBalance({ type: usdcCoinType, balance: amount }); 375 | 376 | // // psmSwapIn 377 | // const usdbCoin = await bucketClient.buildPSMSwapInTransaction(tx, { 378 | // coinType: usdcCoinType, 379 | // inputCoinOrAmount: usdcCoin, 380 | // }); 381 | 382 | // bucketClient.buildDepositToSavingPoolTransaction(tx, { 383 | // lpType: '0x784660d93d9f013f1c77c4bcb2e04a374fdb4038abf2637c75ca27828b2ac18c::allen_susdb::ALLEN_SUSDB', 384 | // account: testAccount, 385 | // usdbCoin, 386 | // }); 387 | 388 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 389 | // transactionBlock: await tx.build({ client: suiClient }), 390 | // }); 391 | 392 | // expect(dryrunRes.effects.status.status).toBe('success'); 393 | // }); 394 | 395 | // it('test deposit to saving pool', async () => { 396 | // // tx 397 | // const tx = new Transaction(); 398 | // tx.setSender(testAccount); 399 | 400 | // const amount = 0.1 * 10 ** 6; // 0.1 USDB 401 | 402 | // const usdbCoin = coinWithBalance({ type: usdbCoinType, balance: amount }); 403 | // bucketClient.buildDepositToSavingPoolTransaction(tx, { 404 | // lpType: '0x784660d93d9f013f1c77c4bcb2e04a374fdb4038abf2637c75ca27828b2ac18c::allen_susdb::ALLEN_SUSDB', 405 | // account: testAccount, 406 | // usdbCoin, 407 | // }); 408 | 409 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 410 | // transactionBlock: await tx.build({ client: suiClient }), 411 | // }); 412 | 413 | // expect(dryrunRes.effects.status.status).toBe('success'); 414 | // }); 415 | 416 | // it('test withdraw from saving pool', async () => { 417 | // // tx 418 | // const tx = new Transaction(); 419 | // tx.setSender(testAccount); 420 | 421 | // const amount = 0.1 * 10 ** 6; // 0.1 SUSDB 422 | 423 | // const usdbCoin = bucketClient.buildWithdrawFromSavingPoolTransaction(tx, { 424 | // lpType: '0x784660d93d9f013f1c77c4bcb2e04a374fdb4038abf2637c75ca27828b2ac18c::allen_susdb::ALLEN_SUSDB', 425 | // amount, 426 | // }); 427 | 428 | // tx.transferObjects([usdbCoin], testAccount); 429 | 430 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 431 | // transactionBlock: await tx.build({ client: suiClient }), 432 | // }); 433 | 434 | // expect(dryrunRes.effects.status.status).toBe('success'); 435 | // }); 436 | 437 | // it('test claim from saving pool', async () => { 438 | // // tx 439 | // const tx = new Transaction(); 440 | // tx.setSender(testAccount); 441 | 442 | // const rewardCoins = bucketClient.buildClaimSavingRewardsTransaction(tx, { 443 | // lpType: '0x784660d93d9f013f1c77c4bcb2e04a374fdb4038abf2637c75ca27828b2ac18c::allen_susdb::ALLEN_SUSDB', 444 | // }); 445 | 446 | // tx.transferObjects([...rewardCoins], testAccount); 447 | 448 | // const dryrunRes = await suiClient.dryRunTransactionBlock({ 449 | // transactionBlock: await tx.build({ client: suiClient }), 450 | // }); 451 | 452 | // expect(dryrunRes.effects.status.status).toBe('success'); 453 | // }); 454 | // }); 455 | --------------------------------------------------------------------------------