diff --git a/package.json b/package.json index 3100888..94c47f4 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ } ], "dependencies": { - "clarity-codegen": "^0.2.6" + "clarity-codegen": "^0.3.5" }, "peerDependencies": { "@stacks/network": "*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 392954a..833dbec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: clarity-codegen: - specifier: ^0.2.6 - version: 0.2.6(@stacks/transactions@6.5.0) + specifier: ^0.3.5 + version: 0.3.5(@stacks/transactions@6.5.0) devDependencies: '@size-limit/preset-small-lib': @@ -2720,8 +2720,8 @@ packages: resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==} dev: true - /clarity-codegen@0.2.6(@stacks/transactions@6.5.0): - resolution: {integrity: sha512-1ZZoPO4VcqPkOaOPaj0OxgVeAJAjpga2nbbMTVynrYBEwN77hrWIwYfnICR0K3XFoyeW+mzxnYw9CpOvEA9eWQ==} + /clarity-codegen@0.3.5(@stacks/transactions@6.5.0): + resolution: {integrity: sha512-tMYXP0lyZ/WViR2vRHCdv/vD+VLhzguawa+GyGRhwMTaYzBRzgyvaZf1qipEf8tIhd8wQGI+3e9KGaWC8TRcaA==} hasBin: true peerDependencies: '@stacks/transactions': '*' diff --git a/scripts/gen-contract.ts b/scripts/gen-contract.ts index 7b9cda8..1cc43ee 100644 --- a/scripts/gen-contract.ts +++ b/scripts/gen-contract.ts @@ -10,7 +10,7 @@ const contracts = [ 'amm-swap-pool', 'amm-swap-pool-v1-1', 'token-amm-swap-pool', - + 'swap-helper-bridged', 'swap-helper-bridged-v1-1', ]; diff --git a/src/config.ts b/src/config.ts index a68fff6..74e846d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -90,6 +90,26 @@ const NATIVE_TOKEN_MAPPING: { decimals: 1e8, assetIdentifier: `SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.brc20-chax::brc20-chax`, }, + [Currency.LEO]: { + decimals: 1e6, + assetIdentifier: 'SP1AY6K3PQV5MRT6R4S671NWW2FRVPKM0BR162CT6.leo-token::leo', + }, + [Currency.MEGA]: { + decimals: 1e2, + assetIdentifier: 'SP3D6PV2ACBPEKYJTCMH7HEN02KP87QSP8KTEH335.mega::mega', + }, + [Currency.GUS]: { + decimals: 1e6, + assetIdentifier: 'SP1JFFSYTSH7VBM54K29ZFS9H4SVB67EA8VT2MYJ9.gus-token::gus', + }, + [Currency.BRC20_ORMM]: { + decimals: 1e8, + assetIdentifier: `SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.brc20-ormm::brc20-ormm`, + }, + [Currency.BRC20_ORDG]: { + decimals: 1e8, + assetIdentifier: `SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.brc20-ordg::brc20-ordg`, + }, }; export const configs = { diff --git a/src/currency.ts b/src/currency.ts index 0df736e..cda6f52 100644 --- a/src/currency.ts +++ b/src/currency.ts @@ -17,4 +17,9 @@ export enum Currency { aBTC = 'token-abtc', sLUNR = 'token-slunr', BRC20_CHAX = 'brc20-chax', + LEO = "token-wleo", + MEGA = "token-wmega-v2", + GUS = "token-wgus", + BRC20_ORDG = "brc20-ordg", + BRC20_ORMM = "brc20-ormm", } diff --git a/src/generated/smartContract/contract_swap-helper-bridged.ts b/src/generated/smartContract/contract_swap-helper-bridged.ts new file mode 100644 index 0000000..a021a39 --- /dev/null +++ b/src/generated/smartContract/contract_swap-helper-bridged.ts @@ -0,0 +1,142 @@ + +import { +defineContract, +principalT, +uintT, +optionalT, +responseSimpleT, +listT +} from "../smartContractHelpers/codegenImport" + +export const swapHelperBridged = defineContract({ +"swap-helper-bridged": { + 'swap-helper-from-amm': { + input: [ + { name: 'token-x-trait', type: principalT }, + { name: 'token-y-trait', type: principalT }, + { name: 'token-z-trait', type: principalT }, + { name: 'factor-x', type: uintT }, + { name: 'dx', type: uintT }, + { name: 'min-dz', type: optionalT(uintT, ) } + ], + output: responseSimpleT(uintT, ), + mode: 'public' + }, + 'swap-helper-to-amm': { + input: [ + { name: 'token-x-trait', type: principalT }, + { name: 'token-y-trait', type: principalT }, + { name: 'token-z-trait', type: principalT }, + { name: 'factor-y', type: uintT }, + { name: 'dx', type: uintT }, + { name: 'min-dz', type: optionalT(uintT, ) } + ], + output: responseSimpleT(uintT, ), + mode: 'public' + }, + 'fee-helper-from-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-x', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'fee-helper-to-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-y', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'get-helper-from-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-x', type: uintT }, + { name: 'dx', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'get-helper-to-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-y', type: uintT }, + { name: 'dx', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'oracle-instant-helper-from-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-x', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'oracle-instant-helper-to-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-y', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'oracle-resilient-helper-from-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-x', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'oracle-resilient-helper-to-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-y', type: uintT } + ], + output: responseSimpleT(uintT, ), + mode: 'readonly' + }, + 'route-helper-from-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-x', type: uintT } + ], + output: responseSimpleT(listT(principalT, ), ), + mode: 'readonly' + }, + 'route-helper-to-amm': { + input: [ + { name: 'token-x', type: principalT }, + { name: 'token-y', type: principalT }, + { name: 'token-z', type: principalT }, + { name: 'factor-y', type: uintT } + ], + output: responseSimpleT(listT(principalT, ), ), + mode: 'readonly' + } +} +} as const) + + diff --git a/src/generated/smartContract/contracts_Alex.ts b/src/generated/smartContract/contracts_Alex.ts index 0d00457..6c875b7 100644 --- a/src/generated/smartContract/contracts_Alex.ts +++ b/src/generated/smartContract/contracts_Alex.ts @@ -4,6 +4,7 @@ import { swapHelperV103 } from "./contract_swap-helper-v1-03" import { ammSwapPool } from "./contract_amm-swap-pool" import { ammSwapPoolV11 } from "./contract_amm-swap-pool-v1-1" import { tokenAmmSwapPool } from "./contract_token-amm-swap-pool" +import { swapHelperBridged } from "./contract_swap-helper-bridged" import { swapHelperBridgedV11 } from "./contract_swap-helper-bridged-v1-1" export const AlexContracts = defineContract({ @@ -12,6 +13,7 @@ export const AlexContracts = defineContract({ ...ammSwapPool, ...ammSwapPoolV11, ...tokenAmmSwapPool, +...swapHelperBridged, ...swapHelperBridgedV11 }); diff --git a/src/utils/ammPool.ts b/src/utils/ammPool.ts index f4fc989..35749c1 100644 --- a/src/utils/ammPool.ts +++ b/src/utils/ammPool.ts @@ -28,6 +28,11 @@ export namespace AMMSwapPool { AMM_SWAP_POOL_V1_1_WSTX_LUNAR = 'token-amm-swap-pool-v1-1:token-wstx,token-slunr,1e8', AMM_SWAP_POOL_V1_1_SUSDT_CHAX = 'token-amm-swap-pool-v1-1:token-susdt,brc20-chax,1e8', AMM_SWAP_POOL_V1_1_WSTX_ABTC = 'token-amm-swap-pool-v1-1:token-wstx,token-abtc,1e8', + AMM_SWAP_POOL_V1_1_WSTX_WLEO = 'token-amm-swap-pool-v1-1:token-wstx,token-wleo,1e8', + AMM_SWAP_POOL_V1_1_WSTX_WMEGA = 'token-amm-swap-pool-v1-1:token-wstx,token-wmega-v2,1e8', + AMM_SWAP_POOL_V1_1_ABTC_BRC20ORDG = 'token-amm-swap-pool-v1-1:token-abtc,brc20-ordg,1e8', + AMM_SWAP_POOL_V1_1_ABTC_BRC20ORMM = 'token-amm-swap-pool-v1-1:token-abtc,brc20-ormm,1e8', + AMM_SWAP_POOL_V1_1_WSTX_WGUS = 'token-amm-swap-pool-v1-1:token-wstx,token-wgues,1e8', } export type SwapTokens = Currency; @@ -70,6 +75,11 @@ export namespace AMMSwapPool { Pool.AMM_SWAP_POOL_V1_1_WSTX_LUNAR, Pool.AMM_SWAP_POOL_V1_1_SUSDT_CHAX, Pool.AMM_SWAP_POOL_V1_1_WSTX_ABTC, + Pool.AMM_SWAP_POOL_V1_1_WSTX_WLEO, + Pool.AMM_SWAP_POOL_V1_1_WSTX_WMEGA, + Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORDG, + Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORMM, + Pool.AMM_SWAP_POOL_V1_1_WSTX_WGUS, ]; export type PoolTokens = Pool; @@ -94,7 +104,13 @@ export namespace AMMSwapPool { export function breakDown( poolToken: AMMSwapPool.PoolTokens ): [ - Currency.STX | Currency.ALEX | Currency.XUSD | Currency.sUSDT, + ( + | Currency.STX + | Currency.ALEX + | Currency.XUSD + | Currency.sUSDT + | Currency.aBTC + ), AMMSwapPool.SwapTokens ] { switch (poolToken) { @@ -137,6 +153,16 @@ export namespace AMMSwapPool { return [Currency.sUSDT, Currency.BRC20_CHAX]; case Pool.AMM_SWAP_POOL_V1_1_WSTX_ABTC: return [Currency.STX, Currency.aBTC]; + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WLEO: + return [Currency.STX, Currency.LEO]; + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WMEGA: + return [Currency.STX, Currency.MEGA]; + case Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORDG: + return [Currency.aBTC, Currency.BRC20_ORDG]; + case Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORMM: + return [Currency.aBTC, Currency.BRC20_ORMM]; + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WGUS: + return [Currency.STX, Currency.GUS]; default: assertNever(poolToken); } @@ -165,6 +191,11 @@ export namespace AMMSwapPool { case Pool.AMM_SWAP_POOL_V1_1_WSTX_LUNAR: case Pool.AMM_SWAP_POOL_V1_1_SUSDT_CHAX: case Pool.AMM_SWAP_POOL_V1_1_WSTX_ABTC: + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WLEO: + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WMEGA: + case Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORDG: + case Pool.AMM_SWAP_POOL_V1_1_ABTC_BRC20ORMM: + case Pool.AMM_SWAP_POOL_V1_1_WSTX_WGUS: return BigInt(1e8); case Pool.AMM_SWAP_POOL_V1_1_SUSDT_XUSD: return BigInt(0.05e8);