aftermath-ts-sdk 1.3.28 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16828 -5
- package/dist/index.js +22695 -19
- package/dist/index.js.map +1 -0
- package/package.json +69 -60
- package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts +0 -41
- package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts.map +0 -1
- package/dist/general/apiHelpers/dynamicFieldsApiHelpers.js +0 -110
- package/dist/general/apiHelpers/eventsApiHelpers.d.ts +0 -43
- package/dist/general/apiHelpers/eventsApiHelpers.d.ts.map +0 -1
- package/dist/general/apiHelpers/eventsApiHelpers.js +0 -170
- package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts +0 -28
- package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts.map +0 -1
- package/dist/general/apiHelpers/inspectionsApiHelpers.js +0 -58
- package/dist/general/apiHelpers/objectsApiHelpers.d.ts +0 -77
- package/dist/general/apiHelpers/objectsApiHelpers.d.ts.map +0 -1
- package/dist/general/apiHelpers/objectsApiHelpers.js +0 -197
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +0 -50
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +0 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.js +0 -256
- package/dist/general/dynamicGas/dynamicGas.d.ts +0 -48
- package/dist/general/dynamicGas/dynamicGas.d.ts.map +0 -1
- package/dist/general/dynamicGas/dynamicGas.js +0 -69
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts +0 -37
- package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +0 -1
- package/dist/general/dynamicGas/dynamicGasTypes.js +0 -2
- package/dist/general/nfts/nftsApi.d.ts +0 -35
- package/dist/general/nfts/nftsApi.d.ts.map +0 -1
- package/dist/general/nfts/nftsApi.js +0 -124
- package/dist/general/nfts/nftsApiCasting.d.ts +0 -11
- package/dist/general/nfts/nftsApiCasting.d.ts.map +0 -1
- package/dist/general/nfts/nftsApiCasting.js +0 -115
- package/dist/general/nfts/nftsTypes.d.ts +0 -31
- package/dist/general/nfts/nftsTypes.d.ts.map +0 -1
- package/dist/general/nfts/nftsTypes.js +0 -2
- package/dist/general/priceFeeds/priceFeeds.d.ts +0 -3
- package/dist/general/priceFeeds/priceFeeds.d.ts.map +0 -1
- package/dist/general/priceFeeds/priceFeeds.js +0 -26
- package/dist/general/priceFeeds/priceFeedsApi.d.ts +0 -3
- package/dist/general/priceFeeds/priceFeedsApi.d.ts.map +0 -1
- package/dist/general/priceFeeds/priceFeedsApi.js +0 -33
- package/dist/general/priceFeeds/priceFeedsTypes.d.ts +0 -3
- package/dist/general/priceFeeds/priceFeedsTypes.d.ts.map +0 -1
- package/dist/general/priceFeeds/priceFeedsTypes.js +0 -7
- package/dist/general/prices/coinGeckoTypes.d.ts +0 -16
- package/dist/general/prices/coinGeckoTypes.d.ts.map +0 -1
- package/dist/general/prices/coinGeckoTypes.js +0 -2
- package/dist/general/prices/prices.d.ts +0 -92
- package/dist/general/prices/prices.d.ts.map +0 -1
- package/dist/general/prices/prices.js +0 -124
- package/dist/general/providers/aftermath.d.ts +0 -200
- package/dist/general/providers/aftermath.d.ts.map +0 -1
- package/dist/general/providers/aftermath.js +0 -258
- package/dist/general/providers/aftermathApi.d.ts +0 -197
- package/dist/general/providers/aftermathApi.d.ts.map +0 -1
- package/dist/general/providers/aftermathApi.js +0 -255
- package/dist/general/providers/index.d.ts +0 -3
- package/dist/general/providers/index.d.ts.map +0 -1
- package/dist/general/providers/index.js +0 -18
- package/dist/general/types/castingTypes.d.ts +0 -51
- package/dist/general/types/castingTypes.d.ts.map +0 -1
- package/dist/general/types/castingTypes.js +0 -8
- package/dist/general/types/configTypes.d.ts +0 -187
- package/dist/general/types/configTypes.d.ts.map +0 -1
- package/dist/general/types/configTypes.js +0 -2
- package/dist/general/types/generalTypes.d.ts +0 -349
- package/dist/general/types/generalTypes.d.ts.map +0 -1
- package/dist/general/types/generalTypes.js +0 -2
- package/dist/general/types/index.d.ts +0 -7
- package/dist/general/types/index.d.ts.map +0 -1
- package/dist/general/types/index.js +0 -22
- package/dist/general/types/moveErrorsInterface.d.ts +0 -6
- package/dist/general/types/moveErrorsInterface.d.ts.map +0 -1
- package/dist/general/types/moveErrorsInterface.js +0 -2
- package/dist/general/types/suiTypes.d.ts +0 -2
- package/dist/general/types/suiTypes.d.ts.map +0 -1
- package/dist/general/types/suiTypes.js +0 -5
- package/dist/general/utils/caller.d.ts +0 -58
- package/dist/general/utils/caller.d.ts.map +0 -1
- package/dist/general/utils/caller.js +0 -231
- package/dist/general/utils/casting.d.ts +0 -212
- package/dist/general/utils/casting.d.ts.map +0 -1
- package/dist/general/utils/casting.js +0 -273
- package/dist/general/utils/fixedUtils.d.ts +0 -109
- package/dist/general/utils/fixedUtils.d.ts.map +0 -1
- package/dist/general/utils/fixedUtils.js +0 -100
- package/dist/general/utils/helpers.d.ts +0 -408
- package/dist/general/utils/helpers.d.ts.map +0 -1
- package/dist/general/utils/helpers.js +0 -725
- package/dist/general/utils/iFixedUtils.d.ts +0 -78
- package/dist/general/utils/iFixedUtils.d.ts.map +0 -1
- package/dist/general/utils/iFixedUtils.js +0 -109
- package/dist/general/utils/index.d.ts +0 -3
- package/dist/general/utils/index.d.ts.map +0 -1
- package/dist/general/utils/index.js +0 -18
- package/dist/general/wallet/wallet.d.ts +0 -89
- package/dist/general/wallet/wallet.d.ts.map +0 -1
- package/dist/general/wallet/wallet.js +0 -120
- package/dist/general/wallet/walletApi.d.ts +0 -20
- package/dist/general/wallet/walletApi.d.ts.map +0 -1
- package/dist/general/wallet/walletApi.js +0 -66
- package/dist/index.d.ts.map +0 -1
- package/dist/packages/auth/auth.d.ts +0 -135
- package/dist/packages/auth/auth.d.ts.map +0 -1
- package/dist/packages/auth/auth.js +0 -289
- package/dist/packages/auth/authTypes.d.ts +0 -102
- package/dist/packages/auth/authTypes.d.ts.map +0 -1
- package/dist/packages/auth/authTypes.js +0 -2
- package/dist/packages/auth/index.d.ts +0 -2
- package/dist/packages/auth/index.d.ts.map +0 -1
- package/dist/packages/auth/index.js +0 -17
- package/dist/packages/coin/api/coinApi.d.ts +0 -33
- package/dist/packages/coin/api/coinApi.d.ts.map +0 -1
- package/dist/packages/coin/api/coinApi.js +0 -167
- package/dist/packages/coin/coin.d.ts +0 -320
- package/dist/packages/coin/coin.d.ts.map +0 -1
- package/dist/packages/coin/coin.js +0 -467
- package/dist/packages/coin/coinTypes.d.ts +0 -139
- package/dist/packages/coin/coinTypes.d.ts.map +0 -1
- package/dist/packages/coin/coinTypes.js +0 -2
- package/dist/packages/coin/index.d.ts +0 -2
- package/dist/packages/coin/index.d.ts.map +0 -1
- package/dist/packages/coin/index.js +0 -17
- package/dist/packages/dca/api/dcaApi.d.ts +0 -26
- package/dist/packages/dca/api/dcaApi.d.ts.map +0 -1
- package/dist/packages/dca/api/dcaApi.js +0 -60
- package/dist/packages/dca/dca.d.ts +0 -174
- package/dist/packages/dca/dca.d.ts.map +0 -1
- package/dist/packages/dca/dca.js +0 -230
- package/dist/packages/dca/dcaTypes.d.ts +0 -319
- package/dist/packages/dca/dcaTypes.d.ts.map +0 -1
- package/dist/packages/dca/dcaTypes.js +0 -2
- package/dist/packages/dca/index.d.ts +0 -2
- package/dist/packages/dca/index.d.ts.map +0 -1
- package/dist/packages/dca/index.js +0 -17
- package/dist/packages/farms/api/farmsApi.d.ts +0 -996
- package/dist/packages/farms/api/farmsApi.d.ts.map +0 -1
- package/dist/packages/farms/api/farmsApi.js +0 -1826
- package/dist/packages/farms/api/farmsApiCasting.d.ts +0 -39
- package/dist/packages/farms/api/farmsApiCasting.d.ts.map +0 -1
- package/dist/packages/farms/api/farmsApiCasting.js +0 -427
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +0 -235
- package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/farms/api/farmsApiCastingTypes.js +0 -2
- package/dist/packages/farms/farms.d.ts +0 -221
- package/dist/packages/farms/farms.d.ts.map +0 -1
- package/dist/packages/farms/farms.js +0 -302
- package/dist/packages/farms/farmsStakedPosition.d.ts +0 -229
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +0 -1
- package/dist/packages/farms/farmsStakedPosition.js +0 -473
- package/dist/packages/farms/farmsStakingPool.d.ts +0 -285
- package/dist/packages/farms/farmsStakingPool.d.ts.map +0 -1
- package/dist/packages/farms/farmsStakingPool.js +0 -488
- package/dist/packages/farms/farmsTypes.d.ts +0 -571
- package/dist/packages/farms/farmsTypes.d.ts.map +0 -1
- package/dist/packages/farms/farmsTypes.js +0 -49
- package/dist/packages/farms/index.d.ts +0 -4
- package/dist/packages/farms/index.d.ts.map +0 -1
- package/dist/packages/farms/index.js +0 -19
- package/dist/packages/faucet/api/faucetApi.d.ts +0 -37
- package/dist/packages/faucet/api/faucetApi.d.ts.map +0 -1
- package/dist/packages/faucet/api/faucetApi.js +0 -145
- package/dist/packages/faucet/api/faucetApiCasting.d.ts +0 -7
- package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +0 -1
- package/dist/packages/faucet/api/faucetApiCasting.js +0 -33
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +0 -10
- package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/faucet/api/faucetApiCastingTypes.js +0 -2
- package/dist/packages/faucet/faucet.d.ts +0 -16
- package/dist/packages/faucet/faucet.d.ts.map +0 -1
- package/dist/packages/faucet/faucet.js +0 -64
- package/dist/packages/faucet/faucetTypes.d.ts +0 -20
- package/dist/packages/faucet/faucetTypes.d.ts.map +0 -1
- package/dist/packages/faucet/faucetTypes.js +0 -2
- package/dist/packages/faucet/index.d.ts +0 -2
- package/dist/packages/faucet/index.d.ts.map +0 -1
- package/dist/packages/faucet/index.js +0 -17
- package/dist/packages/index.d.ts +0 -14
- package/dist/packages/index.d.ts.map +0 -1
- package/dist/packages/index.js +0 -29
- package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts +0 -202
- package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/api/leveragedStakingApi.js +0 -1104
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts +0 -12
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +0 -69
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts +0 -39
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.js +0 -2
- package/dist/packages/leveragedStaking/index.d.ts +0 -2
- package/dist/packages/leveragedStaking/index.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/index.js +0 -17
- package/dist/packages/leveragedStaking/leveragedStaking.d.ts +0 -68
- package/dist/packages/leveragedStaking/leveragedStaking.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/leveragedStaking.js +0 -154
- package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts +0 -48
- package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts.map +0 -1
- package/dist/packages/leveragedStaking/leveragedStakingTypes.js +0 -16
- package/dist/packages/limitOrders/api/limitOrdersApi.d.ts +0 -12
- package/dist/packages/limitOrders/api/limitOrdersApi.d.ts.map +0 -1
- package/dist/packages/limitOrders/api/limitOrdersApi.js +0 -25
- package/dist/packages/limitOrders/index.d.ts +0 -2
- package/dist/packages/limitOrders/index.d.ts.map +0 -1
- package/dist/packages/limitOrders/index.js +0 -17
- package/dist/packages/limitOrders/limitOrders.d.ts +0 -143
- package/dist/packages/limitOrders/limitOrders.d.ts.map +0 -1
- package/dist/packages/limitOrders/limitOrders.js +0 -190
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts +0 -211
- package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +0 -1
- package/dist/packages/limitOrders/limitOrdersTypes.js +0 -2
- package/dist/packages/multisig/api/multisigApi.d.ts +0 -10
- package/dist/packages/multisig/api/multisigApi.d.ts.map +0 -1
- package/dist/packages/multisig/api/multisigApi.js +0 -39
- package/dist/packages/multisig/index.d.ts +0 -2
- package/dist/packages/multisig/index.d.ts.map +0 -1
- package/dist/packages/multisig/index.js +0 -17
- package/dist/packages/multisig/multisig.d.ts +0 -46
- package/dist/packages/multisig/multisig.d.ts.map +0 -1
- package/dist/packages/multisig/multisig.js +0 -65
- package/dist/packages/multisig/multisigTypes.d.ts +0 -26
- package/dist/packages/multisig/multisigTypes.d.ts.map +0 -1
- package/dist/packages/multisig/multisigTypes.js +0 -2
- package/dist/packages/nftAmm/api/nftAmmApi.d.ts +0 -93
- package/dist/packages/nftAmm/api/nftAmmApi.d.ts.map +0 -1
- package/dist/packages/nftAmm/api/nftAmmApi.js +0 -250
- package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts +0 -6
- package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts.map +0 -1
- package/dist/packages/nftAmm/api/nftAmmApiCasting.js +0 -43
- package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts +0 -10
- package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.js +0 -2
- package/dist/packages/nftAmm/index.d.ts +0 -2
- package/dist/packages/nftAmm/index.d.ts.map +0 -1
- package/dist/packages/nftAmm/index.js +0 -17
- package/dist/packages/nftAmm/nftAmm.d.ts +0 -18
- package/dist/packages/nftAmm/nftAmm.d.ts.map +0 -1
- package/dist/packages/nftAmm/nftAmm.js +0 -73
- package/dist/packages/nftAmm/nftAmmMarket.d.ts +0 -54
- package/dist/packages/nftAmm/nftAmmMarket.d.ts.map +0 -1
- package/dist/packages/nftAmm/nftAmmMarket.js +0 -154
- package/dist/packages/nftAmm/nftAmmTypes.d.ts +0 -51
- package/dist/packages/nftAmm/nftAmmTypes.d.ts.map +0 -1
- package/dist/packages/nftAmm/nftAmmTypes.js +0 -2
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +0 -44
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +0 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +0 -1420
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +0 -27
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +0 -1
- package/dist/packages/perpetuals/api/perpetualsApiCasting.js +0 -463
- package/dist/packages/perpetuals/index.d.ts +0 -5
- package/dist/packages/perpetuals/index.d.ts.map +0 -1
- package/dist/packages/perpetuals/index.js +0 -20
- package/dist/packages/perpetuals/perpetuals.d.ts +0 -860
- package/dist/packages/perpetuals/perpetuals.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetuals.js +0 -1102
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +0 -780
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +0 -1406
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +0 -170
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsCastingTypes.js +0 -2
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +0 -360
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +0 -475
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +0 -2968
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsTypes.js +0 -165
- package/dist/packages/perpetuals/perpetualsVault.d.ts +0 -438
- package/dist/packages/perpetuals/perpetualsVault.d.ts.map +0 -1
- package/dist/packages/perpetuals/perpetualsVault.js +0 -601
- package/dist/packages/perpetuals/utils/index.d.ts +0 -2
- package/dist/packages/perpetuals/utils/index.d.ts.map +0 -1
- package/dist/packages/perpetuals/utils/index.js +0 -17
- package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts +0 -12
- package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts.map +0 -1
- package/dist/packages/perpetuals/utils/perpetualsOrderUtils.js +0 -60
- package/dist/packages/pools/api/poolsApi.d.ts +0 -342
- package/dist/packages/pools/api/poolsApi.d.ts.map +0 -1
- package/dist/packages/pools/api/poolsApi.js +0 -857
- package/dist/packages/pools/api/poolsApiCasting.d.ts +0 -13
- package/dist/packages/pools/api/poolsApiCasting.d.ts.map +0 -1
- package/dist/packages/pools/api/poolsApiCasting.js +0 -91
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +0 -64
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/pools/api/poolsApiCastingTypes.js +0 -2
- package/dist/packages/pools/index.d.ts +0 -3
- package/dist/packages/pools/index.d.ts.map +0 -1
- package/dist/packages/pools/index.js +0 -18
- package/dist/packages/pools/pool.d.ts +0 -459
- package/dist/packages/pools/pool.d.ts.map +0 -1
- package/dist/packages/pools/pool.js +0 -647
- package/dist/packages/pools/pools.d.ts +0 -405
- package/dist/packages/pools/pools.d.ts.map +0 -1
- package/dist/packages/pools/pools.js +0 -533
- package/dist/packages/pools/poolsTypes.d.ts +0 -469
- package/dist/packages/pools/poolsTypes.d.ts.map +0 -1
- package/dist/packages/pools/poolsTypes.js +0 -2
- package/dist/packages/pools/utils/cmmmCalculations.d.ts +0 -42
- package/dist/packages/pools/utils/cmmmCalculations.d.ts.map +0 -1
- package/dist/packages/pools/utils/cmmmCalculations.js +0 -1380
- package/dist/packages/referralVault/api/referralVaultApi.d.ts +0 -39
- package/dist/packages/referralVault/api/referralVaultApi.d.ts.map +0 -1
- package/dist/packages/referralVault/api/referralVaultApi.js +0 -125
- package/dist/packages/referralVault/index.d.ts +0 -2
- package/dist/packages/referralVault/index.d.ts.map +0 -1
- package/dist/packages/referralVault/index.js +0 -17
- package/dist/packages/referralVault/referralVault.d.ts +0 -47
- package/dist/packages/referralVault/referralVault.d.ts.map +0 -1
- package/dist/packages/referralVault/referralVault.js +0 -71
- package/dist/packages/referralVault/referralVaultTypes.d.ts +0 -2
- package/dist/packages/referralVault/referralVaultTypes.d.ts.map +0 -1
- package/dist/packages/referralVault/referralVaultTypes.js +0 -2
- package/dist/packages/referrals/index.d.ts +0 -2
- package/dist/packages/referrals/index.d.ts.map +0 -1
- package/dist/packages/referrals/index.js +0 -17
- package/dist/packages/referrals/referrals.d.ts +0 -27
- package/dist/packages/referrals/referrals.d.ts.map +0 -1
- package/dist/packages/referrals/referrals.js +0 -95
- package/dist/packages/referrals/referralsTypes.d.ts +0 -166
- package/dist/packages/referrals/referralsTypes.d.ts.map +0 -1
- package/dist/packages/referrals/referralsTypes.js +0 -2
- package/dist/packages/rewards/index.d.ts +0 -2
- package/dist/packages/rewards/index.d.ts.map +0 -1
- package/dist/packages/rewards/index.js +0 -17
- package/dist/packages/rewards/rewards.d.ts +0 -21
- package/dist/packages/rewards/rewards.d.ts.map +0 -1
- package/dist/packages/rewards/rewards.js +0 -65
- package/dist/packages/rewards/rewardsTypes.d.ts +0 -169
- package/dist/packages/rewards/rewardsTypes.d.ts.map +0 -1
- package/dist/packages/rewards/rewardsTypes.js +0 -2
- package/dist/packages/router/api/routerApi.d.ts +0 -35
- package/dist/packages/router/api/routerApi.d.ts.map +0 -1
- package/dist/packages/router/api/routerApi.js +0 -88
- package/dist/packages/router/api/routerApiCasting.d.ts +0 -6
- package/dist/packages/router/api/routerApiCasting.d.ts.map +0 -1
- package/dist/packages/router/api/routerApiCasting.js +0 -22
- package/dist/packages/router/api/routerApiCastingTypes.d.ts +0 -12
- package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/router/api/routerApiCastingTypes.js +0 -2
- package/dist/packages/router/index.d.ts +0 -2
- package/dist/packages/router/index.d.ts.map +0 -1
- package/dist/packages/router/index.js +0 -17
- package/dist/packages/router/router.d.ts +0 -224
- package/dist/packages/router/router.d.ts.map +0 -1
- package/dist/packages/router/router.js +0 -283
- package/dist/packages/router/routerTypes.d.ts +0 -300
- package/dist/packages/router/routerTypes.d.ts.map +0 -1
- package/dist/packages/router/routerTypes.js +0 -2
- package/dist/packages/staking/api/stakingApi.d.ts +0 -129
- package/dist/packages/staking/api/stakingApi.d.ts.map +0 -1
- package/dist/packages/staking/api/stakingApi.js +0 -487
- package/dist/packages/staking/api/stakingApiCasting.d.ts +0 -11
- package/dist/packages/staking/api/stakingApiCasting.d.ts.map +0 -1
- package/dist/packages/staking/api/stakingApiCasting.js +0 -87
- package/dist/packages/staking/api/stakingApiCastingTypes.d.ts +0 -97
- package/dist/packages/staking/api/stakingApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/staking/api/stakingApiCastingTypes.js +0 -2
- package/dist/packages/staking/index.d.ts +0 -2
- package/dist/packages/staking/index.d.ts.map +0 -1
- package/dist/packages/staking/index.js +0 -17
- package/dist/packages/staking/staking.d.ts +0 -385
- package/dist/packages/staking/staking.d.ts.map +0 -1
- package/dist/packages/staking/staking.js +0 -501
- package/dist/packages/staking/stakingTypes.d.ts +0 -575
- package/dist/packages/staking/stakingTypes.d.ts.map +0 -1
- package/dist/packages/staking/stakingTypes.js +0 -45
- package/dist/packages/sui/api/suiApi.d.ts +0 -21
- package/dist/packages/sui/api/suiApi.d.ts.map +0 -1
- package/dist/packages/sui/api/suiApi.js +0 -46
- package/dist/packages/sui/index.d.ts +0 -2
- package/dist/packages/sui/index.d.ts.map +0 -1
- package/dist/packages/sui/index.js +0 -17
- package/dist/packages/sui/sui.d.ts +0 -53
- package/dist/packages/sui/sui.d.ts.map +0 -1
- package/dist/packages/sui/sui.js +0 -77
- package/dist/packages/suiFrens/api/suiFrensApi.d.ts +0 -204
- package/dist/packages/suiFrens/api/suiFrensApi.d.ts.map +0 -1
- package/dist/packages/suiFrens/api/suiFrensApi.js +0 -756
- package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts +0 -21
- package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts.map +0 -1
- package/dist/packages/suiFrens/api/suiFrensApiCasting.js +0 -181
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts +0 -77
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.js +0 -2
- package/dist/packages/suiFrens/index.d.ts +0 -4
- package/dist/packages/suiFrens/index.d.ts.map +0 -1
- package/dist/packages/suiFrens/index.js +0 -19
- package/dist/packages/suiFrens/stakedSuiFren.d.ts +0 -31
- package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +0 -1
- package/dist/packages/suiFrens/stakedSuiFren.js +0 -90
- package/dist/packages/suiFrens/suiFren.d.ts +0 -32
- package/dist/packages/suiFrens/suiFren.d.ts.map +0 -1
- package/dist/packages/suiFrens/suiFren.js +0 -150
- package/dist/packages/suiFrens/suiFrens.d.ts +0 -56
- package/dist/packages/suiFrens/suiFrens.d.ts.map +0 -1
- package/dist/packages/suiFrens/suiFrens.js +0 -218
- package/dist/packages/suiFrens/suiFrensTypes.d.ts +0 -148
- package/dist/packages/suiFrens/suiFrensTypes.d.ts.map +0 -1
- package/dist/packages/suiFrens/suiFrensTypes.js +0 -8
- package/dist/packages/userData/index.d.ts +0 -2
- package/dist/packages/userData/index.d.ts.map +0 -1
- package/dist/packages/userData/index.js +0 -17
- package/dist/packages/userData/userData.d.ts +0 -89
- package/dist/packages/userData/userData.d.ts.map +0 -1
- package/dist/packages/userData/userData.js +0 -119
- package/dist/packages/userData/userDataTypes.d.ts +0 -29
- package/dist/packages/userData/userDataTypes.d.ts.map +0 -1
- package/dist/packages/userData/userDataTypes.js +0 -2
- package/dist/types.d.ts +0 -15
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -31
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/general/apiHelpers/dynamicFieldsApiHelpers.ts","../src/general/apiHelpers/eventsApiHelpers.ts","../src/general/apiHelpers/inspectionsApiHelpers.ts","../src/general/prices/prices.ts","../src/packages/coin/coin.ts","../src/general/utils/index.ts","../src/packages/farms/api/farmsApiCasting.ts","../src/packages/coin/index.ts","../src/packages/faucet/api/faucetApiCasting.ts","../src/packages/pools/api/poolsApiCasting.ts","../src/packages/nftAmm/api/nftAmmApiCasting.ts","../src/packages/perpetuals/perpetualsTypes.ts","../src/packages/perpetuals/api/perpetualsApiCasting.ts","../src/packages/router/api/routerApiCasting.ts","../src/general/utils/fixedUtils.ts","../src/packages/staking/api/stakingApiCasting.ts","../src/packages/suiFrens/api/suiFrensApiCasting.ts","../src/general/nfts/nftsApiCasting.ts","../src/general/utils/iFixedUtils.ts","../src/general/utils/casting.ts","../src/general/apiHelpers/objectsApiHelpers.ts","../src/general/apiHelpers/transactionsApiHelpers.ts","../src/general/utils/helpers.ts","../src/general/utils/caller.ts","../src/packages/auth/auth.ts","../src/packages/auth/index.ts","../src/packages/farms/farmsStakingPool.ts","../src/packages/farms/farmsStakedPosition.ts","../src/packages/farms/farms.ts","../src/packages/farms/index.ts","../src/packages/faucet/faucet.ts","../src/packages/faucet/index.ts","../src/packages/pools/utils/cmmmCalculations.ts","../src/packages/pools/pool.ts","../src/packages/pools/pools.ts","../src/packages/pools/index.ts","../src/packages/nftAmm/nftAmmMarket.ts","../src/packages/nftAmm/nftAmm.ts","../src/packages/nftAmm/index.ts","../src/general/types/configTypes.ts","../src/general/types/generalTypes.ts","../src/general/types/suiTypes.ts","../src/general/nfts/nftsTypes.ts","../src/general/dynamicGas/dynamicGasTypes.ts","../src/general/prices/coinGeckoTypes.ts","../src/general/types/index.ts","../src/packages/auth/authTypes.ts","../src/packages/coin/coinTypes.ts","../src/packages/farms/farmsTypes.ts","../src/packages/faucet/faucetTypes.ts","../src/packages/nftAmm/nftAmmTypes.ts","../src/packages/pools/poolsTypes.ts","../src/packages/referrals/referralsTypes.ts","../src/packages/rewards/rewardsTypes.ts","../src/packages/router/routerTypes.ts","../src/packages/staking/stakingTypes.ts","../src/packages/suiFrens/suiFrensTypes.ts","../src/types.ts","../src/packages/perpetuals/perpetualsMarket.ts","../src/packages/perpetuals/perpetualsAccount.ts","../src/packages/perpetuals/utils/perpetualsOrderUtils.ts","../src/packages/perpetuals/utils/index.ts","../src/packages/perpetuals/perpetualsVault.ts","../src/packages/perpetuals/perpetuals.ts","../src/packages/perpetuals/index.ts","../src/packages/referralVault/referralVault.ts","../src/packages/referralVault/index.ts","../src/packages/router/router.ts","../src/packages/router/index.ts","../src/packages/staking/staking.ts","../src/packages/staking/index.ts","../src/packages/sui/sui.ts","../src/packages/sui/index.ts","../src/packages/suiFrens/suiFren.ts","../src/packages/suiFrens/stakedSuiFren.ts","../src/packages/suiFrens/suiFrens.ts","../src/packages/suiFrens/index.ts","../src/packages/index.ts","../src/packages/dca/dca.ts","../src/packages/limitOrders/limitOrders.ts","../src/packages/multisig/multisig.ts","../src/packages/referrals/referrals.ts","../src/packages/rewards/rewards.ts","../src/packages/userData/userData.ts","../src/general/dynamicGas/dynamicGas.ts","../src/general/wallet/wallet.ts","../src/packages/coin/api/coinApi.ts","../src/packages/dca/api/dcaApi.ts","../src/packages/farms/api/farmsApi.ts","../src/packages/faucet/api/faucetApi.ts","../src/packages/limitOrders/api/limitOrdersApi.ts","../src/packages/multisig/api/multisigApi.ts","../src/packages/nftAmm/api/nftAmmApi.ts","../src/packages/perpetuals/api/perpetualsApi.ts","../src/packages/pools/api/poolsApi.ts","../src/packages/referralVault/api/referralVaultApi.ts","../src/packages/router/api/routerApi.ts","../src/packages/staking/api/stakingApi.ts","../src/packages/sui/api/suiApi.ts","../src/packages/suiFrens/api/suiFrensApi.ts","../src/general/nfts/nftsApi.ts","../src/general/wallet/walletApi.ts","../src/general/providers/aftermathApi.ts","../src/general/providers/aftermath.ts","../src/general/providers/index.ts","../src/index.ts"],"sourcesContent":["import type { DynamicFieldInfo, DynamicFieldName } from \"@mysten/sui/jsonRpc\";\nimport {\n\tAnyObjectType,\n\tDynamicFieldObjectsWithCursor,\n\tDynamicFieldsInputs,\n\tDynamicFieldsWithCursor,\n\tObjectId,\n} from \"../../types\";\nimport { AftermathApi } from \"../providers/aftermathApi\";\n\nexport class DynamicFieldsApiHelpers {\n\t// =========================================================================\n\t// Private Static Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tdefaultLimitStepSize: 256,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Dynamic Fields\n\t// =========================================================================\n\n\tpublic fetchCastDynamicFieldsOfTypeWithCursor = async <ObjectType>(inputs: {\n\t\tparentObjectId: ObjectId;\n\t\tobjectsFromObjectIds: (objectIds: ObjectId[]) => Promise<ObjectType[]>;\n\t\tdynamicFieldType?:\n\t\t\t| AnyObjectType\n\t\t\t| ((objectType: AnyObjectType) => boolean);\n\t\tcursor?: ObjectId;\n\t\tlimit?: number;\n\t}): Promise<DynamicFieldObjectsWithCursor<ObjectType>> => {\n\t\tconst { dynamicFields, nextCursor } =\n\t\t\tawait this.fetchDynamicFieldsOfTypeWithCursor(inputs);\n\n\t\tconst dynamicFieldObjectIds = dynamicFields.map(\n\t\t\t(field) => field.objectId\n\t\t);\n\t\tconst dynamicFieldObjects = await inputs.objectsFromObjectIds(\n\t\t\tdynamicFieldObjectIds\n\t\t);\n\n\t\treturn {\n\t\t\tdynamicFieldObjects,\n\t\t\tnextCursor,\n\t\t};\n\t};\n\n\tpublic fetchAllDynamicFieldsOfType = async (inputs: {\n\t\tparentObjectId: ObjectId;\n\t\tdynamicFieldType?:\n\t\t\t| AnyObjectType\n\t\t\t| ((objectType: AnyObjectType) => boolean);\n\t\tlimitStepSize?: number;\n\t}) => {\n\t\tlet allDynamicFields: DynamicFieldInfo[] = [];\n\t\tlet cursor: ObjectId | undefined = undefined;\n\t\tdo {\n\t\t\tconst dynamicFieldsWithCursor: DynamicFieldsWithCursor =\n\t\t\t\tawait this.fetchDynamicFieldsOfTypeWithCursor({\n\t\t\t\t\t...inputs,\n\t\t\t\t\tcursor,\n\t\t\t\t\tlimit:\n\t\t\t\t\t\tinputs.limitStepSize ??\n\t\t\t\t\t\tDynamicFieldsApiHelpers.constants.defaultLimitStepSize,\n\t\t\t\t});\n\t\t\tconst dynamicFields = dynamicFieldsWithCursor.dynamicFields;\n\t\t\tallDynamicFields = [...allDynamicFields, ...dynamicFields];\n\n\t\t\tif (\n\t\t\t\tdynamicFields.length === 0 ||\n\t\t\t\tdynamicFieldsWithCursor.nextCursor === null\n\t\t\t)\n\t\t\t\treturn allDynamicFields;\n\t\t\tcursor = dynamicFieldsWithCursor.nextCursor;\n\t\t} while (true);\n\t};\n\n\tpublic fetchCastAllDynamicFieldsOfType = async <ObjectType>(inputs: {\n\t\tparentObjectId: ObjectId;\n\t\tobjectsFromObjectIds: (\n\t\t\tobjectIds: ObjectId[]\n\t\t) => ObjectType[] | Promise<ObjectType[]>;\n\t\tdynamicFieldType?:\n\t\t\t| AnyObjectType\n\t\t\t| ((objectType: AnyObjectType) => boolean);\n\t\tlimitStepSize?: number;\n\t}) => {\n\t\tconst dynamicFields = await this.fetchAllDynamicFieldsOfType(inputs);\n\t\tconst dynamicFieldObjectIds = dynamicFields.map(\n\t\t\t(field) => field.objectId\n\t\t);\n\t\tconst dynamicFieldObjects = await inputs.objectsFromObjectIds(\n\t\t\tdynamicFieldObjectIds\n\t\t);\n\t\treturn dynamicFieldObjects;\n\t};\n\n\tpublic fetchDynamicFieldsUntil = async <ObjectType>(inputs: {\n\t\tfetchFunc: (\n\t\t\tdynamicFieldsInputs: DynamicFieldsInputs\n\t\t) => Promise<DynamicFieldObjectsWithCursor<ObjectType>>;\n\t\tisComplete: (dynamicFieldObjects: ObjectType[]) => boolean;\n\t\tcursor?: ObjectId;\n\t\tlimitStepSize?: number;\n\t}): Promise<DynamicFieldObjectsWithCursor<ObjectType>> => {\n\t\tconst { fetchFunc, isComplete, cursor, limitStepSize } = inputs;\n\n\t\tlet allDynamicFields: ObjectType[] = [];\n\t\tlet currentCursor = cursor ?? null;\n\n\t\tdo {\n\t\t\tconst dynamicFieldsWithCursor = await fetchFunc({\n\t\t\t\tcursor: currentCursor ?? undefined,\n\t\t\t\tlimit:\n\t\t\t\t\tlimitStepSize ??\n\t\t\t\t\tDynamicFieldsApiHelpers.constants.defaultLimitStepSize,\n\t\t\t});\n\t\t\tconst fetchedDynamicFields =\n\t\t\t\tdynamicFieldsWithCursor.dynamicFieldObjects;\n\t\t\tconst nextCursor = dynamicFieldsWithCursor.nextCursor;\n\n\t\t\tallDynamicFields = [...allDynamicFields, ...fetchedDynamicFields];\n\n\t\t\tif (fetchedDynamicFields.length === 0 || nextCursor === null) {\n\t\t\t\treturn {\n\t\t\t\t\tdynamicFieldObjects: allDynamicFields,\n\t\t\t\t\tnextCursor,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (isComplete(allDynamicFields)) {\n\t\t\t\treturn {\n\t\t\t\t\tdynamicFieldObjects: allDynamicFields,\n\t\t\t\t\tnextCursor,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcurrentCursor = dynamicFieldsWithCursor.nextCursor;\n\t\t} while (true);\n\t};\n\n\tpublic fetchDynamicFieldsOfTypeWithCursor = async (\n\t\tinputs: {\n\t\t\tparentObjectId: ObjectId;\n\t\t\tdynamicFieldType?:\n\t\t\t\t| AnyObjectType\n\t\t\t\t| ((objectType: AnyObjectType) => boolean);\n\t\t} & DynamicFieldsInputs\n\t): Promise<DynamicFieldsWithCursor> => {\n\t\tconst { parentObjectId, dynamicFieldType } = inputs;\n\n\t\tconst dynamicFieldsResponse =\n\t\t\tawait this.Provider.provider.getDynamicFields({\n\t\t\t\t...inputs,\n\t\t\t\tlimit:\n\t\t\t\t\tinputs.limit ??\n\t\t\t\t\tDynamicFieldsApiHelpers.constants.defaultLimitStepSize,\n\t\t\t\tparentId: parentObjectId,\n\t\t\t});\n\n\t\tconst dynamicFields =\n\t\t\tdynamicFieldType === undefined\n\t\t\t\t? dynamicFieldsResponse.data\n\t\t\t\t: dynamicFieldsResponse.data.filter(\n\t\t\t\t\t\t(dynamicField: DynamicFieldInfo) =>\n\t\t\t\t\t\t\ttypeof dynamicFieldType === \"string\"\n\t\t\t\t\t\t\t\t? dynamicField.objectType === dynamicFieldType\n\t\t\t\t\t\t\t\t: dynamicFieldType(dynamicField.objectType)\n\t\t\t\t );\n\n\t\tconst nextCursor = dynamicFieldsResponse.nextCursor;\n\t\treturn {\n\t\t\tdynamicFields,\n\t\t\tnextCursor,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Dynamic Field Objects\n\t// =========================================================================\n\n\tpublic fetchDynamicFieldObject = (inputs: {\n\t\tparentId: ObjectId;\n\t\tname: DynamicFieldName;\n\t}) => {\n\t\treturn this.Provider.provider.getDynamicFieldObject(inputs);\n\t};\n}\n","import {\n\tEvent,\n\tEventsWithCursor,\n\tAnyObjectType,\n\tEventsInputs,\n\tSuiAddress,\n} from \"../../types\";\nimport dayjs, { QUnitType, OpUnitType } from \"dayjs\";\nimport { AftermathApi } from \"../providers/aftermathApi\";\nimport type {\n\tEventId,\n\tSuiEvent,\n\tSuiEventFilter,\n\tSuiTransactionBlockResponse,\n\tUnsubscribe,\n} from \"@mysten/sui/jsonRpc\";\n\nexport class EventsApiHelpers {\n\t// =========================================================================\n\t// Private Static Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tdefaultLimitStepSize: 256,\n\t\tmaxLoops: 20,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\t// TODO: make this filter by looking ONLY at all relevant AF packages\n\t// TODO: move to wallet package ?\n\t/**\n\t * @deprecated `subscribeEvent` was removed from `SuiJsonRpcClient` in\n\t * `@mysten/sui` v2. Poll `queryEvents` instead or use a WebSocket transport.\n\t */\n\tpublic fetchSubscribeToUserEvents = async (_inputs: {\n\t\taddress: SuiAddress;\n\t\tonEvent: (event: SuiEvent) => void;\n\t}): Promise<Unsubscribe> => {\n\t\tthrow new Error(\n\t\t\t\"fetchSubscribeToUserEvents is not supported in @mysten/sui v2. \" +\n\t\t\t\t\"subscribeEvent was removed from SuiJsonRpcClient. \" +\n\t\t\t\t\"Poll queryEvents instead or use a WebSocket transport.\"\n\t\t);\n\t};\n\n\tpublic fetchCastEventsWithCursor = async <EventOnChainType, EventType>(\n\t\tinputs: {\n\t\t\tquery: SuiEventFilter;\n\t\t\teventFromEventOnChain: (\n\t\t\t\teventOnChain: EventOnChainType\n\t\t\t) => EventType;\n\t\t} & EventsInputs\n\t): Promise<EventsWithCursor<EventType>> => {\n\t\tconst { query, eventFromEventOnChain, cursor, limit } = inputs;\n\n\t\tconst fetchedEvents = await this.Provider.provider.queryEvents({\n\t\t\tquery,\n\t\t\tcursor: cursor\n\t\t\t\t? {\n\t\t\t\t\t\t...cursor,\n\t\t\t\t\t\teventSeq: cursor?.eventSeq.toString(),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t\tlimit, // defaultlimit ?\n\t\t});\n\t\tconst eventsOnChain =\n\t\t\tfetchedEvents.data as unknown as EventOnChainType[];\n\t\tconst events = eventsOnChain.map((event) =>\n\t\t\teventFromEventOnChain(event)\n\t\t);\n\t\tconst nextCursor = fetchedEvents.nextCursor ?? null;\n\n\t\treturn { events, nextCursor };\n\t};\n\n\t// TODO: make this function use timestamp passing as one of event filter args\n\tpublic fetchEventsWithinTime = async <T extends Event>(inputs: {\n\t\tfetchEventsFunc: (\n\t\t\teventsInputs: EventsInputs\n\t\t) => Promise<EventsWithCursor<T>>;\n\t\ttimeUnit: QUnitType | OpUnitType;\n\t\ttime: number;\n\t\tlimitStepSize?: number;\n\t}) => {\n\t\tconst { fetchEventsFunc, timeUnit, time, limitStepSize } = inputs;\n\n\t\tlet loopCount = 0;\n\t\tlet eventsWithinTime: T[] = [];\n\t\tlet cursor: EventId | undefined = undefined;\n\t\tdo {\n\t\t\tconst eventsWithCursor: EventsWithCursor<T> = await fetchEventsFunc(\n\t\t\t\t{\n\t\t\t\t\tcursor,\n\t\t\t\t\tlimit:\n\t\t\t\t\t\tlimitStepSize ??\n\t\t\t\t\t\tEventsApiHelpers.constants.defaultLimitStepSize,\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst events = eventsWithCursor.events;\n\n\t\t\tconst now = Date.now();\n\t\t\tconst endIndex = events.findIndex((event) => {\n\t\t\t\tif (event.timestamp === undefined) return false;\n\n\t\t\t\tconst eventDate = dayjs.unix(event.timestamp / 1000);\n\t\t\t\treturn dayjs(now).diff(eventDate, timeUnit, true) > time;\n\t\t\t});\n\t\t\teventsWithinTime = [\n\t\t\t\t...eventsWithinTime,\n\t\t\t\t...(endIndex < 0 ? events : events.slice(0, endIndex)),\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tevents.length === 0 ||\n\t\t\t\t// events.length < limitStepSize ||\n\t\t\t\teventsWithCursor.nextCursor === null ||\n\t\t\t\tendIndex >= 0\n\t\t\t)\n\t\t\t\treturn eventsWithinTime;\n\n\t\t\tcursor = eventsWithCursor.nextCursor;\n\n\t\t\tloopCount += 1;\n\t\t\tif (loopCount >= EventsApiHelpers.constants.maxLoops) {\n\t\t\t\treturn eventsWithinTime;\n\t\t\t}\n\t\t} while (true);\n\t};\n\n\tpublic fetchAllEvents = async <T /* extends Event */>(inputs: {\n\t\tfetchEventsFunc: (\n\t\t\teventsInputs: EventsInputs\n\t\t) => Promise<EventsWithCursor<T>>;\n\t\tlimitStepSize?: number;\n\t}) => {\n\t\tconst { fetchEventsFunc, limitStepSize } = inputs;\n\n\t\tlet allEvents: T[] = [];\n\t\tlet cursor: EventId | undefined = undefined;\n\t\tdo {\n\t\t\tconst eventsWithCursor: EventsWithCursor<T> = await fetchEventsFunc(\n\t\t\t\t{\n\t\t\t\t\tcursor,\n\t\t\t\t\tlimit:\n\t\t\t\t\t\tlimitStepSize ??\n\t\t\t\t\t\tEventsApiHelpers.constants.defaultLimitStepSize,\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst events = eventsWithCursor.events;\n\t\t\tallEvents = [...allEvents, ...events];\n\n\t\t\tif (events.length === 0 || eventsWithCursor.nextCursor === null)\n\t\t\t\treturn allEvents;\n\t\t\tcursor = eventsWithCursor.nextCursor;\n\t\t} while (true);\n\t};\n\n\t// =========================================================================\n\t// Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tpublic static suiEventOfTypeOrUndefined = (\n\t\tevent: SuiEvent,\n\t\teventType: AnyObjectType | (() => AnyObjectType)\n\t): SuiEvent | undefined =>\n\t\t// event.type === (typeof eventType === \"string\" ? eventType : eventType())\n\t\tevent.type.includes(\n\t\t\ttypeof eventType === \"string\" ? eventType : eventType()\n\t\t)\n\t\t\t? event\n\t\t\t: undefined;\n\n\tpublic static castEventOfTypeOrUndefined = <EventTypeOnChain, EventType>(\n\t\tevent: SuiEvent,\n\t\teventType: AnyObjectType | (() => AnyObjectType),\n\t\tcastFunction: (eventOnChain: EventTypeOnChain) => EventType,\n\t\texactMatch?: boolean\n\t): EventType | undefined => {\n\t\tif (\n\t\t\texactMatch\n\t\t\t\t? event.type !==\n\t\t\t\t (typeof eventType === \"string\" ? eventType : eventType())\n\t\t\t\t: !event.type.includes(\n\t\t\t\t\t\ttypeof eventType === \"string\" ? eventType : eventType()\n\t\t\t\t )\n\t\t)\n\t\t\treturn;\n\n\t\tconst castedEvent = castFunction(event as EventTypeOnChain);\n\t\treturn castedEvent;\n\t};\n\n\tpublic static findCastEventsOrUndefined = <\n\t\tEventTypeOnChain,\n\t\tEventType\n\t>(inputs: {\n\t\tevents: SuiEvent[];\n\t\teventType: AnyObjectType | (() => AnyObjectType);\n\t\tcastFunction: (eventOnChain: EventTypeOnChain) => EventType;\n\t}) => {\n\t\tconst { events, eventType, castFunction } = inputs;\n\n\t\tconst foundEvents = events.filter(\n\t\t\t(event) =>\n\t\t\t\tEventsApiHelpers.suiEventOfTypeOrUndefined(event, eventType) !==\n\t\t\t\tundefined\n\t\t);\n\t\tconst castedEvents = foundEvents.map((event) =>\n\t\t\tcastFunction(event as EventTypeOnChain)\n\t\t);\n\t\treturn castedEvents;\n\t};\n\n\tpublic static findCastEventOrUndefined = <\n\t\tEventTypeOnChain,\n\t\tEventType\n\t>(inputs: {\n\t\tevents: SuiEvent[];\n\t\teventType: AnyObjectType | (() => AnyObjectType);\n\t\tcastFunction: (eventOnChain: EventTypeOnChain) => EventType;\n\t}) => {\n\t\tconst events = this.findCastEventsOrUndefined(inputs);\n\t\tif (events.length <= 0) return;\n\t\treturn events[0];\n\t};\n\n\tpublic static findCastEventInTransactionOrUndefined = <\n\t\tEventTypeOnChain,\n\t\tEventType\n\t>(\n\t\ttransaction: SuiTransactionBlockResponse,\n\t\teventType: AnyObjectType | (() => AnyObjectType),\n\t\tcastFunction: (eventOnChain: EventTypeOnChain) => EventType\n\t) => {\n\t\treturn this.findCastEventOrUndefined({\n\t\t\tevents: transaction.events ?? [],\n\t\t\teventType,\n\t\t\tcastFunction,\n\t\t});\n\t};\n\n\tpublic static findCastEventInTransactionsOrUndefined = <\n\t\tEventTypeOnChain,\n\t\tEventType\n\t>(\n\t\ttransactions: SuiTransactionBlockResponse[],\n\t\teventType: AnyObjectType | (() => AnyObjectType),\n\t\tcastFunction: (eventOnChain: EventTypeOnChain) => EventType\n\t) => {\n\t\tif (transactions.length === 0) return;\n\n\t\tconst foundEvent = transactions\n\t\t\t.map((transaction) =>\n\t\t\t\tEventsApiHelpers.findCastEventInTransactionOrUndefined(\n\t\t\t\t\ttransaction,\n\t\t\t\t\teventType,\n\t\t\t\t\tcastFunction\n\t\t\t\t)\n\t\t\t)\n\t\t\t.find((event) => event !== undefined);\n\n\t\treturn foundEvent;\n\t};\n\n\tpublic static createEventType = (\n\t\tpackageAddress: string,\n\t\tpackageName: string,\n\t\teventType: string,\n\t\twrapperType?: string\n\t) => {\n\t\tconst innerType = `${packageAddress}::${packageName}::${eventType}`;\n\t\treturn wrapperType ? `${wrapperType}<${innerType}>` : innerType;\n\t};\n}\n","import type { SuiEvent, TransactionEffects } from \"@mysten/sui/jsonRpc\";\nimport type { Transaction } from \"@mysten/sui/transactions\";\nimport type { Byte, SuiAddress } from \"../../types\";\nimport type { AftermathApi } from \"../providers/aftermathApi\";\n\nexport class InspectionsApiHelpers {\n public static constants = {\n devInspectSigner:\n \"0xacb7cb045c3afac61381cdf272cd24ebe115f86361c9f06490482c238765aeb5\",\n };\n\n // =========================================================================\n // Constructor\n // =========================================================================\n\n constructor(private readonly Provider: AftermathApi) {}\n\n // =========================================================================\n // Public Methods\n // =========================================================================\n\n // =========================================================================\n // Fetching\n // =========================================================================\n\n // TODO: replace all bytes types with uint8array type\n\n public fetchFirstBytesFromTxOutput = async (inputs: {\n tx: Transaction;\n sender?: SuiAddress;\n }) => {\n return (await this.fetchAllBytesFromTxOutput(inputs))[0];\n };\n\n public fetchAllBytesFromTxOutput = async (inputs: {\n tx: Transaction;\n sender?: SuiAddress;\n }): Promise<Byte[][]> => {\n const { allBytes } = await this.fetchAllBytesFromTx(inputs);\n return allBytes[allBytes.length - 1];\n };\n\n public fetchAllBytesFromTx = async (inputs: {\n tx: Transaction;\n sender?: SuiAddress;\n }): Promise<{\n events: SuiEvent[];\n effects: TransactionEffects;\n allBytes: Byte[][][];\n }> => {\n const sender =\n inputs.sender ?? InspectionsApiHelpers.constants.devInspectSigner;\n const response = await this.Provider.provider.devInspectTransactionBlock({\n sender,\n transactionBlock: inputs.tx,\n });\n\n if (response.effects.status.status === \"failure\") {\n throw new Error(\n response.effects.status.error ?? response.error ?? \"dev inspect failed\"\n );\n }\n\n if (!response.results) {\n throw Error(\"dev inspect move call returned no results\");\n }\n\n const resultBytes = response.results.map(\n (result: { returnValues?: [number[], string][] }) =>\n result.returnValues?.map((val: [number[], string]) => val[0]) ?? []\n );\n return {\n events: response.events,\n effects: response.effects,\n allBytes: resultBytes,\n };\n };\n}\n","import { SuiNetwork } from \"../types/suiTypes\";\nimport {\n\tCoinPriceInfo,\n\tCoinSymbol,\n\tCoinSymbolsToPriceInfo,\n\tCoinType,\n\tCoinsToPrice,\n\tCoinsToPriceInfo,\n} from \"../../packages/coin/coinTypes\";\nimport { Caller } from \"../utils/caller\";\nimport { CallerConfig, Url } from \"../types\";\n\n/**\n * The `Prices` class provides methods for fetching price information for various\n * coins on the Sui network, including single-coin or multi-coin queries.\n */\nexport class Prices extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `Prices` instance for retrieving coin price data from\n\t * Aftermath's backend or other data sources.\n\t *\n\t * @param config - Optional configuration, including network and access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"price-info\");\n\t}\n\n\t// =========================================================================\n\t// Prices\n\t// =========================================================================\n\n\t/**\n\t * Retrieves detailed price information (including current price and 24h change)\n\t * for a single coin.\n\t *\n\t * @param inputs - Contains the `coin` type (e.g., \"0x2::sui::SUI\").\n\t * @returns A promise resolving to a `CoinPriceInfo` object.\n\t *\n\t * @example\n\t * ```typescript\n\t *\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const prices = afSdk.Prices();\n\t *\n\t * const suiPriceInfo = await prices.getCoinPriceInfo({\n\t * coin: \"0x2::sui::SUI\"\n\t * });\n\t * console.log(suiPriceInfo.price, suiPriceInfo.priceChange24HoursPercentage);\n\t * ```\n\t */\n\tpublic async getCoinPriceInfo(inputs: {\n\t\tcoin: CoinType;\n\t}): Promise<CoinPriceInfo> {\n\t\tconst coinsToPriceInfo = await this.getCoinsToPriceInfo({\n\t\t\tcoins: [inputs.coin],\n\t\t});\n\t\treturn Object.values(coinsToPriceInfo)[0];\n\t}\n\n\t/**\n\t * Retrieves detailed price information for multiple coins simultaneously,\n\t * returning a record keyed by `CoinType`.\n\t *\n\t * @param inputs - An object containing an array of `coins`.\n\t * @returns A promise resolving to a `CoinsToPriceInfo` mapping each coin type to its price info.\n\t *\n\t * @example\n\t * ```typescript\n\t * const prices = new Prices();\n\t * const info = await prices.getCoinsToPriceInfo({\n\t * coins: [\"0x2::sui::SUI\", \"0x<some_other_coin>\"]\n\t * });\n\t * console.log(info);\n\t * ```\n\t */\n\tpublic async getCoinsToPriceInfo(inputs: {\n\t\tcoins: CoinType[];\n\t}): Promise<CoinsToPriceInfo> {\n\t\treturn this.fetchApi(\"\", inputs);\n\t}\n\n\t/**\n\t * Fetches only the current price in USD for a single coin.\n\t *\n\t * @param inputs - Contains the `coin` type.\n\t * @returns A promise resolving to a `number` representing the price in USD.\n\t *\n\t * @example\n\t * ```typescript\n\t * const prices = new Prices();\n\t * const suiPrice = await prices.getCoinPrice({ coin: \"0x2::sui::SUI\" });\n\t * console.log(\"SUI price in USD:\", suiPrice);\n\t * ```\n\t */\n\tpublic async getCoinPrice(inputs: { coin: CoinType }): Promise<number> {\n\t\tconst priceInfo = await this.getCoinPriceInfo(inputs);\n\t\treturn priceInfo.price;\n\t}\n\n\t/**\n\t * Fetches current prices in USD for multiple coins, returning a record keyed by `CoinType`.\n\t *\n\t * @param inputs - Contains an array of `coins`.\n\t * @returns A promise resolving to a `CoinsToPrice` object mapping coin types to their prices in USD.\n\t *\n\t * @example\n\t * ```typescript\n\t * const prices = new Prices();\n\t * const multiPrices = await prices.getCoinsToPrice({ coins: [\"0x2::sui::SUI\", \"0x<other>\"] });\n\t * console.log(multiPrices[\"0x2::sui::SUI\"]); // e.g. 1.23\n\t * ```\n\t */\n\tpublic async getCoinsToPrice(inputs: {\n\t\tcoins: CoinType[];\n\t}): Promise<CoinsToPrice> {\n\t\tconst coinsToPriceInfo = await this.getCoinsToPriceInfo(inputs);\n\t\tconst coinsToPrice: CoinsToPrice = Object.entries(\n\t\t\tcoinsToPriceInfo\n\t\t).reduce(\n\t\t\t(acc, [coinType, info]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[coinType]: info.price,\n\t\t\t}),\n\t\t\t{}\n\t\t);\n\t\treturn coinsToPrice;\n\t}\n}\n","import {\n\tAnyObjectType,\n\tBalance,\n\tCallerConfig,\n\tCoinDecimal,\n\tCoinMetadaWithInfo,\n\tCoinPriceInfo,\n\tCoinsToBalance,\n\tCoinsToDecimals,\n\tCoinSymbol,\n\tCoinSymbolToCoinTypes,\n\tCoinType,\n\tKeyType,\n\tSuiNetwork,\n\tUrl,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { Helpers } from \"../../general/utils/helpers\";\nimport { Prices } from \"../../general/prices/prices\";\nimport { AftermathApi } from \"../../general/providers\";\nimport type { CoinMetadata } from \"@mysten/sui/jsonRpc\";\n\n/**\n * The `Coin` class provides functionality to manage and inspect coin types,\n * retrieve metadata and prices, and convert balances with respect to coin decimals.\n * It can be instantiated with or without a specific `coinType` for convenience.\n *\n * @example\n * ```typescript\n *\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // initialize provider\n *\n * const coin = afSdk.Coin(\"0x2::sui::SUI\");\n *\n * const metadata = await coin.getCoinMetadata(); // fetch metadata for SUI coin\n * ```\n */\nexport class Coin extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Static configuration and defaults for Sui coin types, including the standard\n\t * SUI coin type, default decimals, and coin object type path.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * The canonical coin type string for SUI.\n\t\t */\n\t\tsuiCoinType:\n\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI\",\n\t\t/**\n\t\t * The default number of decimals for SUI (9).\n\t\t */\n\t\tsuiCoinDecimals: 9,\n\t\t/**\n\t\t * The canonical coin object type path for Sui's Move module, used in verifying coin objects.\n\t\t */\n\t\tcoinObjectType:\n\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin\",\n\t\t/**\n\t\t * The maximum number of decimals\n\t\t */\n\t\tmaxCoinDecimals: 18,\n\t\t/**\n\t\t * Default decimals for various blockchains or ecosystems. For instance,\n\t\t * \"sui\" => 9, \"evm\" => 18, etc.\n\t\t */\n\t\tdefaultCoinDecimals: {\n\t\t\tsui: 9,\n\t\t\tevm: 18,\n\t\t\tsvm: 9,\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Public Members\n\t// =========================================================================\n\n\t/**\n\t * The Move package name portion of this coin type, e.g. the middle \"module\" from \"0x2::sui::SUI\".\n\t * Will be empty if no `coinType` is provided.\n\t */\n\tpublic readonly coinTypePackageName: string;\n\t/**\n\t * The final part of the coin type (the \"symbol\" or short name) from \"0x2::sui::SUI\".\n\t * Will be empty if no `coinType` is provided.\n\t */\n\tpublic readonly coinTypeSymbol: string;\n\t/**\n\t * If the coin type includes a generic argument (like `Coin<0x...>`), this is extracted. Else empty.\n\t * E.g. \"0x5::coin::Coin<0x2::sui::SUI>\" => \"0x2::sui::SUI\".\n\t */\n\tpublic readonly innerCoinType: string;\n\n\t/**\n\t * An optional cached coin metadata object retrieved by `getCoinMetadata`.\n\t */\n\tpublic metadata: CoinMetadaWithInfo | undefined;\n\t/**\n\t * An optional cached price info object retrieved by `getPrice`.\n\t */\n\tpublic priceInfo: CoinPriceInfo | undefined;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of `Coin`.\n\t *\n\t * @param coinType - The coin's type string (e.g., \"0x2::sui::SUI\"). If omitted, methods that require a type will need it passed in manually.\n\t * @param config - Optional caller configuration (network, access token).\n\t * @param Provider - An optional `AftermathApi` instance for coin-specific API calls.\n\t */\n\tconstructor(\n\t\tpublic readonly coinType: CoinType | undefined = undefined,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"coins\");\n\t\tthis.coinType = coinType;\n\n\t\t// Pre-extract segments for convenience\n\t\tthis.coinTypePackageName = this.coinType\n\t\t\t? Coin.getCoinTypePackageName(this.coinType)\n\t\t\t: \"\";\n\t\tthis.coinTypeSymbol = this.coinType\n\t\t\t? Coin.getCoinTypeSymbol(this.coinType)\n\t\t\t: \"\";\n\t\tthis.innerCoinType = this.coinType\n\t\t\t? Coin.getInnerCoinType(this.coinType)\n\t\t\t: \"\";\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the decimals for multiple coins by calling the Aftermath API for metadata\n\t * and extracting the `decimals` property.\n\t *\n\t * @param inputs - An object containing an array of coin types.\n\t * @returns An object mapping each coin type to a numeric decimal count.\n\t *\n\t * @example\n\t * ```typescript\n\t * const decimals = await coin.getCoinsToDecimals({ coins: [\"0x2::sui::SUI\", \"0x<...>\"] });\n\t * console.log(decimals); // { \"0x2::sui::SUI\": 9, \"0x<...>\": 6 }\n\t * ```\n\t */\n\tpublic async getCoinsToDecimals(inputs: {\n\t\tcoins: CoinType[];\n\t}): Promise<CoinsToDecimals> {\n\t\tconst { coins } = inputs;\n\t\tconst metadatas = await this.getCoinMetadatas(inputs);\n\n\t\tconst coinsToDecimals: Record<CoinType, CoinDecimal> = metadatas\n\t\t\t.map((data) => data.decimals)\n\t\t\t.reduce((acc, decimals, index) => {\n\t\t\t\treturn { ...acc, [coins[index]]: decimals };\n\t\t\t}, {});\n\t\treturn coinsToDecimals;\n\t}\n\n\t/**\n\t * Fetches the metadata (name, symbol, decimals) for this coin type or a provided one,\n\t * caching it if already requested.\n\t *\n\t * @param coin - Optionally override the constructor coinType.\n\t * @returns The `CoinMetadaWithInfo` object containing metadata and optional external references.\n\t * @throws If neither constructor nor argument coinType is available.\n\t *\n\t * @example\n\t * ```typescript\n\t * const metadata = await coin.getCoinMetadata(\"0x2::sui::SUI\");\n\t * console.log(metadata.name, metadata.symbol, metadata.decimals);\n\t * ```\n\t */\n\tpublic async getCoinMetadata(coin?: CoinType): Promise<CoinMetadaWithInfo> {\n\t\tif (this.metadata) return this.metadata;\n\n\t\tconst coinType = this.coinType ?? coin;\n\t\tif (!coinType) throw new Error(\"no valid coin type\");\n\n\t\tconst [metadata] = await this.getCoinMetadatas({ coins: [coinType] });\n\t\tthis.setCoinMetadata(metadata);\n\t\treturn metadata;\n\t}\n\n\t/**\n\t * Fetches metadata for multiple coins at once, returning an array in the same order\n\t * as the coin types requested.\n\t *\n\t * @param inputs - An object with `coins`, an array of coin types.\n\t * @returns An array of `CoinMetadaWithInfo` with length matching `coins`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const metas = await coin.getCoinMetadatas({\n\t * coins: [\"0x2::sui::SUI\", \"0x<custom::TOKEN>\"]\n\t * });\n\t * console.log(metas[0].symbol, metas[1].symbol);\n\t * ```\n\t */\n\tpublic async getCoinMetadatas(inputs: {\n\t\tcoins: CoinType[];\n\t}): Promise<CoinMetadaWithInfo[]> {\n\t\treturn this.fetchApi<CoinMetadaWithInfo[], { coins: CoinType[] }>(\n\t\t\t\"metadata\",\n\t\t\t{\n\t\t\t\tcoins: inputs.coins.map((coin) =>\n\t\t\t\t\tHelpers.addLeadingZeroesToType(coin)\n\t\t\t\t),\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Manually sets the metadata in this Coin instance, storing it in `this.metadata`.\n\t *\n\t * @param metadata - A `CoinMetadaWithInfo` object to cache in this instance.\n\t */\n\tpublic setCoinMetadata(metadata: CoinMetadaWithInfo) {\n\t\tthis.metadata = metadata;\n\t}\n\n\t/**\n\t * Retrieves price information (including current price and 24h change) for this coin or a provided coin.\n\t * If already fetched, it returns the cached data.\n\t *\n\t * @param coin - Optionally override the constructor coinType.\n\t * @returns A `CoinPriceInfo` with `price` and `priceChange24HoursPercentage`.\n\t * @throws If no valid coin type is present.\n\t *\n\t * @example\n\t * ```typescript\n\t * const priceInfo = await coin.getPrice(\"0x2::sui::SUI\");\n\t * console.log(priceInfo.price, priceInfo.priceChange24HoursPercentage);\n\t * ```\n\t */\n\tpublic async getPrice(coin?: CoinType): Promise<CoinPriceInfo> {\n\t\tif (this.priceInfo !== undefined) return this.priceInfo;\n\n\t\tconst coinType = this.coinType ?? coin;\n\t\tif (!coinType) throw new Error(\"no valid coin type\");\n\n\t\tconst priceInfo = await new Prices(this.config).getCoinPriceInfo({\n\t\t\tcoin: coinType,\n\t\t});\n\n\t\t// NOTE: do we want this here ? (unexpected behavior)\n\t\t// if (price <= 0) throw new Error(\"No price found.\")\n\n\t\tthis.setPriceInfo(priceInfo);\n\t\treturn priceInfo;\n\t}\n\n\t/**\n\t * Manually sets the price info in this Coin instance, storing it in `this.priceInfo`.\n\t *\n\t * @param priceInfo - A `CoinPriceInfo` object to cache in this instance.\n\t */\n\tpublic setPriceInfo(priceInfo: CoinPriceInfo) {\n\t\tthis.priceInfo = priceInfo;\n\t}\n\n\t/**\n\t * Fetches a list of \"verified\" coin types from the Aftermath backend. Verified coins\n\t * typically pass certain safety or liquidity checks.\n\t *\n\t * @returns An array of `CoinType` strings that are considered verified.\n\t *\n\t * @example\n\t * ```typescript\n\t * const verified = await coin.getVerifiedCoins();\n\t * console.log(verified); // e.g. [\"0x2::sui::SUI\", \"0x...::MYCOIN\", ...]\n\t * ```\n\t */\n\tpublic async getVerifiedCoins() {\n\t\treturn this.fetchApi<CoinType[]>(\"verified\");\n\t}\n\n\t// =========================================================================\n\t// Public Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Coin Type\n\t// =========================================================================\n\n\t/**\n\t * Extracts the Move package name portion from a coin type string.\n\t * E.g., \"0x2::sui::SUI\" => \"sui\".\n\t *\n\t * @param coin - The coin type string (e.g., \"0x2::sui::SUI\").\n\t * @returns The middle segment of the type or empty string if not parseable.\n\t */\n\tpublic static getCoinTypePackageName = (coin: CoinType): string => {\n\t\tconst splitCoin = coin.split(\"::\");\n\t\tif (splitCoin.length !== 3) return \"\";\n\t\tconst packageName = splitCoin[splitCoin.length - 2];\n\t\tif (!packageName) return \"\";\n\t\treturn packageName;\n\t};\n\n\t/**\n\t * Extracts the final part of the coin type (the symbol or short name).\n\t * For example, \"0x2::sui::SUI\" => \"SUI\".\n\t *\n\t * @param coin - The coin type string.\n\t * @returns The extracted symbol or empty string if not found.\n\t */\n\tpublic static getCoinTypeSymbol = (coin: CoinType): string => {\n\t\tconst startIndex = coin.lastIndexOf(\"::\") + 2;\n\t\t// NOTE: should error if coin is not a valid coin type instead of empty string ?\n\t\tif (startIndex <= 1) return \"\";\n\n\t\tconst foundEndIndex = coin.indexOf(\">\");\n\t\tconst endIndex = foundEndIndex < 0 ? coin.length : foundEndIndex;\n\n\t\tconst displayType = coin.slice(startIndex, endIndex);\n\t\treturn displayType;\n\t};\n\n\t/**\n\t * Extracts the inner generic argument of a coin type if present. E.g.,\n\t * \"0x2::coin::Coin<0x2::sui::SUI>\" => \"0x2::sui::SUI\".\n\t *\n\t * @param coin - The coin type with a possible `<...>` suffix.\n\t * @returns The inner type or an empty string if not found.\n\t */\n\tpublic static getInnerCoinType = (coin: CoinType) =>\n\t\tcoin.includes(\"<\") ? coin.split(\"<\")[1].slice(0, -1) : \"\";\n\n\t/**\n\t * If a `KeyType` string references a type in angle brackets, extracts the type\n\t * inside. Typically for \"0x2::coin::Coin<0x2::mycoin::MYCOIN>\" -> \"0x2::mycoin::MYCOIN\".\n\t *\n\t * @param keyType - The key type string to parse.\n\t * @returns The substring inside `<...>` or the original if no brackets found.\n\t */\n\tpublic static coinTypeFromKeyType = (keyType: KeyType) => {\n\t\tconst startIndex = keyType.lastIndexOf(\"<\") + 1;\n\t\tconst endIndex = keyType.indexOf(\">\", startIndex);\n\t\treturn keyType.slice(startIndex, endIndex);\n\t};\n\n\t/**\n\t * Checks if a coin type string corresponds to the canonical SUI coin.\n\t *\n\t * @param coin - A coin type string.\n\t * @returns `true` if it matches \"0x2::sui::SUI\", otherwise `false`.\n\t */\n\tpublic static isSuiCoin = (coin: CoinType) =>\n\t\tHelpers.stripLeadingZeroesFromType(coin) ===\n\t\tHelpers.stripLeadingZeroesFromType(Coin.constants.suiCoinType);\n\n\t/**\n\t * Checks if an object type string is a `Coin<...>` object from the standard Sui Move module.\n\t *\n\t * @param objectType - The object type to test.\n\t * @returns `true` if it matches \"0x2::coin::Coin<...>\", otherwise `false`.\n\t */\n\tpublic static isCoinObjectType = (objectType: AnyObjectType) =>\n\t\tHelpers.stripLeadingZeroesFromType(objectType).startsWith(\n\t\t\tHelpers.stripLeadingZeroesFromType(Coin.constants.coinObjectType)\n\t\t);\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Given a record of coin types => numeric amounts, filters out those\n\t * with zero or negative amounts, returning only the positive pairs.\n\t *\n\t * @param coinAmounts - A record mapping coin types to numeric amounts.\n\t * @returns An object with `coins` array and `amounts` array in matching indexes.\n\t */\n\tpublic static coinsAndAmountsOverZero = (\n\t\tcoinAmounts: Record<CoinType, number>\n\t) => {\n\t\t// NOTE: will these loops always run in same order (is this a js guarantee or not) ?\n\t\tconst coins = Object.keys(coinAmounts).filter(\n\t\t\t(key) => coinAmounts[key] > 0\n\t\t);\n\t\tconst amounts = Object.values(coinAmounts).filter(\n\t\t\t(amount) => amount > 0\n\t\t);\n\n\t\treturn { coins, amounts };\n\t};\n\n\t/**\n\t * Given a record of coin types => bigint balances, filters out those with zero\n\t * or negative balances, returning only the positive pairs.\n\t *\n\t * @param coinsToBalance - A record mapping coin types to bigints.\n\t * @returns An object with `coins` array and `balances` array in matching indexes.\n\t */\n\tpublic static coinsAndBalancesOverZero = (\n\t\tcoinsToBalance: CoinsToBalance\n\t) => {\n\t\t// NOTE: will these loops always run in same order (is this a js guarantee or not) ?\n\t\tconst coins = Object.keys(coinsToBalance).filter(\n\t\t\t(key) => BigInt(coinsToBalance[key]) > BigInt(0)\n\t\t);\n\t\tconst balances = Object.values(coinsToBalance)\n\t\t\t.map(BigInt)\n\t\t\t.filter((amount) => amount > BigInt(0));\n\n\t\treturn { coins, balances };\n\t};\n\n\t/**\n\t * Filters a list of `coinTypes` by a textual query, matching against both zero-padded\n\t * and non-padded forms as well as substring checks.\n\t *\n\t * @param inputs - Contains `filter` (the search string) and `coinTypes`.\n\t * @returns An array of coin types that match the filter in either raw or zero-padded form.\n\t *\n\t * @example\n\t * ```typescript\n\t * const filtered = Coin.filterCoinsByType({\n\t * filter: \"sui\",\n\t * coinTypes: [\"0x2::sui::SUI\", \"0x<...>\"]\n\t * });\n\t * ```\n\t */\n\tpublic static filterCoinsByType = (inputs: {\n\t\tfilter: string;\n\t\tcoinTypes: CoinType[];\n\t}): CoinType[] => {\n\t\tconst filter = inputs.filter.toLowerCase().trim();\n\t\treturn inputs.coinTypes?.filter((coinType) => {\n\t\t\ttry {\n\t\t\t\treturn (\n\t\t\t\t\tHelpers.stripLeadingZeroesFromType(coinType)\n\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t.includes(Helpers.stripLeadingZeroesFromType(filter)) ||\n\t\t\t\t\tcoinType\n\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t.includes(Helpers.addLeadingZeroesToType(filter))\n\t\t\t\t);\n\t\t\t} catch (e) {}\n\t\t\treturn (\n\t\t\t\tHelpers.stripLeadingZeroesFromType(coinType)\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.includes(filter) || coinType.toLowerCase().includes(filter)\n\t\t\t);\n\t\t});\n\t};\n\n\t/**\n\t * Filters a record of coin metadata by a textual query, matching both the coin type\n\t * and the metadata's name/symbol fields.\n\t *\n\t * @param inputs - An object containing `filter` and a record of `coinMetadatas`.\n\t * @returns An array of coin types that match the search criteria.\n\t */\n\tpublic static filterCoinsByMetadata = (inputs: {\n\t\tfilter: string;\n\t\tcoinMetadatas: Record<CoinType, CoinMetadata>;\n\t}): CoinType[] => {\n\t\treturn Object.entries(inputs.coinMetadatas)\n\t\t\t?.filter(([coin, metadata]) => {\n\t\t\t\tconst cleanInput = inputs.filter.toLowerCase().trim();\n\t\t\t\treturn (\n\t\t\t\t\tcoin.startsWith(cleanInput) ||\n\t\t\t\t\t[metadata.name, metadata.symbol].some((str) =>\n\t\t\t\t\t\tstr.toLowerCase().includes(cleanInput)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t})\n\t\t\t.map(([coin]) => coin);\n\t};\n\n\t// =========================================================================\n\t// Balance\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Conversions\n\t// =========================================================================\n\n\t/**\n\t * Converts a user-friendly decimal number (e.g., 1.5) to a raw on-chain\n\t * integer representation by scaling with the given coin decimals.\n\t * For example, `1.5` with `decimals = 9` => `1500000000n`.\n\t *\n\t * @param balance - The user-friendly balance as a number.\n\t * @param decimals - Number of decimal places for this coin.\n\t * @returns A bigint representing the raw on-chain balance.\n\t */\n\tpublic static normalizeBalance = (\n\t\tbalance: number,\n\t\tdecimals: CoinDecimal\n\t): Balance => BigInt(Math.floor(balance * 10 ** decimals));\n\n\t/**\n\t * Scales a raw bigint or numeric `amount` down by `decimals` to get a display-friendly float.\n\t * For example, `1500000000n` with `decimals = 9` => `1.5`.\n\t *\n\t * @param amount - The raw on-chain amount as `bigint` or `number`.\n\t * @param decimals - Number of decimal places for this coin.\n\t * @returns The resulting float as an easily readable balance.\n\t */\n\tpublic static balanceWithDecimals = (\n\t\tamount: bigint | number,\n\t\tdecimals: number\n\t) => {\n\t\t// TODO: make this conversion via string so no overflow or loss when bigint to number ?\n\t\treturn Number(amount) / Number(10 ** decimals);\n\t};\n\n\t/**\n\t * Scales a raw `amount` down by `decimals` and multiplies by a `price` in USD,\n\t * returning a final USD value. E.g., `1500000000n`, `decimals=9`, `price=2.0` => `3.0`.\n\t *\n\t * @param amount - The raw balance as bigint or number.\n\t * @param decimals - The coin decimals.\n\t * @param price - The coin's price in USD.\n\t * @returns The computed float in USD.\n\t */\n\tpublic static balanceWithDecimalsUsd = (\n\t\tamount: bigint | number,\n\t\tdecimals: number,\n\t\tprice: number\n\t) => {\n\t\treturn Coin.balanceWithDecimals(amount, decimals) * price;\n\t};\n\n\t/**\n\t * Looks up a coin's symbol if it is known in a provided `coinSymbolToCoinTypes`\n\t * record. For instance, if \"SUI\" => `[\"0x2::sui::SUI\"]`, we can find \"SUI\" from\n\t * the coin type \"0x2::sui::SUI\".\n\t *\n\t * @param inputs - An object with `coinType` and `coinSymbolToCoinTypes`.\n\t * @returns The coin symbol string or `undefined` if not found.\n\t */\n\tpublic static coinSymbolForCoinType = (inputs: {\n\t\tcoinType: CoinType;\n\t\tcoinSymbolToCoinTypes: CoinSymbolToCoinTypes;\n\t}): CoinSymbol | undefined => {\n\t\tconst { coinType, coinSymbolToCoinTypes } = inputs;\n\t\ttry {\n\t\t\tconst fullCoinType = Helpers.addLeadingZeroesToType(coinType);\n\t\t\tconst foundCoinData = Object.entries(coinSymbolToCoinTypes).find(\n\t\t\t\t([, coinsTypes]) =>\n\t\t\t\t\tcoinsTypes\n\t\t\t\t\t\t.map(Helpers.addLeadingZeroesToType)\n\t\t\t\t\t\t.includes(fullCoinType)\n\t\t\t);\n\n\t\t\tconst foundCoinSymbol = foundCoinData?.[0];\n\t\t\treturn foundCoinSymbol;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t/**\n\t * Internal method to retrieve a specialized coin-related API from `AftermathApi`.\n\t * Throws an error if no provider is set.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Coin();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./casting\";\nexport * from \"./helpers\";\n","import {\n\tFarmsAddedRewardEventOnChainV1,\n\tFarmsAfterburnerVaultFieldsOnChain,\n\tFarmsCreatedVaultEventOnChainV1,\n\tFarmsDepositedPrincipalEventOnChainV1,\n\tFarmsDestroyedStakedPositionEventOnChainV1,\n\tFarmsHarvestedRewardsEventOnChainV1,\n\tFarmsIncreasedEmissionsEventOnChainV1,\n\tFarmsInitializedRewardEventOnChainV1,\n\tFarmsJoinedEventOnChainV1,\n\tFarmsLockedEventOnChainV1,\n\tFarmsSplitEventOnChainV1,\n\tFarmsStakedEventOnChainV1,\n\tFarmsStakedRelaxedEventOnChainV1,\n\tFarmsStakedPositionFieldsOnChainV1,\n\tFarmsStakingPoolOwnerCapFieldsOnChainV1,\n\tFarmsUnlockedEventOnChainV1,\n\tFarmsWithdrewPrincipalEventOnChainV1,\n\tFarmsStakingPoolOneTimeAdminCapFieldsOnChainV1,\n\tFarmsStakedPositionFieldsOnChainV2,\n\tFarmsStakingPoolOneTimeAdminCapFieldsOnChainV2,\n\tFarmsStakingPoolOwnerCapFieldsOnChainV2,\n\tFarmsStakedEventOnChainV2,\n\tFarmsWithdrewPrincipalEventOnChainV2,\n\tFarmsUnlockedEventOnChainV2,\n\tFarmsSplitEventOnChainV2,\n\tFarmsLockedEventOnChainV2,\n\tFarmsJoinedEventOnChainV2,\n\tFarmsInitializedRewardEventOnChainV2,\n\tFarmsUpdatedEmissionsEventOnChainV2,\n\tFarmsHarvestedRewardsEventOnChainV2,\n\tFarmsDestroyedStakedPositionEventOnChainV2,\n\tFarmsDepositedPrincipalEventOnChainV2,\n\tFarmsCreatedVaultEventOnChainV2,\n\tFarmsAddedRewardEventOnChainV2,\n} from \"./farmsApiCastingTypes\";\nimport {\n\tFarmsAddedRewardEvent,\n\tFarmsCreatedVaultEvent,\n\tFarmsDepositedPrincipalEvent,\n\tFarmsDestroyedStakedPositionEvent,\n\tFarmsStakingPoolObject,\n\tFarmsHarvestedRewardsEvent,\n\tFarmsIncreasedEmissionsEvent,\n\tFarmsInitializedRewardEvent,\n\tFarmsJoinedEvent,\n\tFarmsLockedEvent,\n\tFarmsSplitEvent,\n\tFarmsStakedEvent,\n\tFarmsStakedRelaxedEvent,\n\tFarmsUnlockedEvent,\n\tFarmsWithdrewPrincipalEvent,\n\tStakingPoolOwnerCapObject,\n\tPartialFarmsStakedPositionObject,\n\tStakingPoolOneTimeAdminCapObject,\n} from \"../farmsTypes\";\nimport { Coin } from \"../../coin/coin\";\nimport { Helpers } from \"../../../general/utils\";\nimport type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\n\nexport class FarmsApiCasting {\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic static partialStakedPositionObjectFromSuiObjectResponseV1 = (\n\t\tdata: SuiObjectResponse\n\t): PartialFarmsStakedPositionObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakedPositionFieldsOnChainV1;\n\t\tconst stakeCoinType = Helpers.addLeadingZeroesToType(\n\t\t\tCoin.getInnerCoinType(objectType)\n\t\t);\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakeCoinType,\n\t\t\tstakingPoolObjectId: fields.afterburner_vault_id,\n\t\t\tstakedAmount: BigInt(fields.balance),\n\t\t\tstakedAmountWithMultiplier: BigInt(fields.multiplier_staked_amount),\n\t\t\tlockStartTimestamp: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\tlastHarvestRewardsTimestamp: Number(\n\t\t\t\tfields.last_reward_timestamp_ms\n\t\t\t),\n\t\t\trewardCoins: fields.base_rewards_accumulated.map(\n\t\t\t\t(baseRewardsAccumulated, index) => ({\n\t\t\t\t\tbaseRewardsAccumulated: BigInt(baseRewardsAccumulated),\n\t\t\t\t\tbaseRewardsDebt: BigInt(fields.base_rewards_debt[index]),\n\t\t\t\t\tmultiplierRewardsAccumulated: BigInt(\n\t\t\t\t\t\tfields.multiplier_rewards_accumulated[index]\n\t\t\t\t\t),\n\t\t\t\t\tmultiplierRewardsDebt: BigInt(\n\t\t\t\t\t\tfields.multiplier_rewards_debt[index]\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t),\n\t\t\tversion: 1,\n\t\t};\n\t};\n\n\tpublic static partialStakedPositionObjectFromSuiObjectResponseV2 = (\n\t\tdata: SuiObjectResponse\n\t): PartialFarmsStakedPositionObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakedPositionFieldsOnChainV2;\n\t\tconst stakeCoinType = Helpers.addLeadingZeroesToType(\n\t\t\tCoin.getInnerCoinType(objectType)\n\t\t);\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakeCoinType,\n\t\t\tstakingPoolObjectId: fields.vault_id,\n\t\t\tstakedAmount: BigInt(fields.balance),\n\t\t\tstakedAmountWithMultiplier: BigInt(fields.multiplier_staked_amount),\n\t\t\tlockStartTimestamp: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\tlastHarvestRewardsTimestamp: Number(\n\t\t\t\tfields.last_reward_timestamp_ms\n\t\t\t),\n\t\t\trewardCoins: fields.base_rewards_accumulated.map(\n\t\t\t\t(baseRewardsAccumulated, index) => ({\n\t\t\t\t\tbaseRewardsAccumulated: BigInt(baseRewardsAccumulated),\n\t\t\t\t\tbaseRewardsDebt: BigInt(fields.base_rewards_debt[index]),\n\t\t\t\t\tmultiplierRewardsAccumulated: BigInt(\n\t\t\t\t\t\tfields.multiplier_rewards_accumulated[index]\n\t\t\t\t\t),\n\t\t\t\t\tmultiplierRewardsDebt: BigInt(\n\t\t\t\t\t\tfields.multiplier_rewards_debt[index]\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t),\n\t\t\tversion: 2,\n\t\t};\n\t};\n\n\tpublic static stakingPoolOwnerCapObjectFromSuiObjectResponseV1 = (\n\t\tdata: SuiObjectResponse\n\t): StakingPoolOwnerCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakingPoolOwnerCapFieldsOnChainV1;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakingPoolId: fields.afterburner_vault_id,\n\t\t};\n\t};\n\n\tpublic static stakingPoolOwnerCapObjectFromSuiObjectResponseV2 = (\n\t\tdata: SuiObjectResponse\n\t): StakingPoolOwnerCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakingPoolOwnerCapFieldsOnChainV2[\"fields\"];\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakingPoolId: fields.for,\n\t\t};\n\t};\n\n\tpublic static stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV1 = (\n\t\tdata: SuiObjectResponse\n\t): StakingPoolOneTimeAdminCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakingPoolOneTimeAdminCapFieldsOnChainV1;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakingPoolId: fields.afterburner_vault_id,\n\t\t};\n\t};\n\n\tpublic static stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV2 = (\n\t\tdata: SuiObjectResponse\n\t): StakingPoolOneTimeAdminCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as FarmsStakingPoolOneTimeAdminCapFieldsOnChainV2;\n\n\t\t// TODO: add reward coin type ?\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tstakingPoolId: fields.cap.fields.for,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static addedRewardEventFromOnChainV1 = (\n\t\teventOnChain: FarmsAddedRewardEventOnChainV1\n\t): FarmsAddedRewardEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\trewardAmount: BigInt(fields.reward_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static addedRewardEventFromOnChainV2 = (\n\t\teventOnChain: FarmsAddedRewardEventOnChainV2\n\t): FarmsAddedRewardEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\trewardAmount: BigInt(fields.reward_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static createdVaultEventFromOnChainV1 = (\n\t\teventOnChain: FarmsCreatedVaultEventOnChainV1\n\t): FarmsCreatedVaultEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\tminLockDurationMs: Number(fields.min_lock_duration_ms),\n\t\t\tmaxLockDurationMs: Number(fields.max_lock_duration_ms),\n\t\t\tmaxLockMultiplier: BigInt(fields.max_lock_multiplier),\n\t\t\tminStakeAmount: BigInt(fields.min_stake_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static createdVaultEventFromOnChainV2 = (\n\t\teventOnChain: FarmsCreatedVaultEventOnChainV2\n\t): FarmsCreatedVaultEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\tminLockDurationMs: Number(fields.min_lock_duration_ms),\n\t\t\tmaxLockDurationMs: Number(fields.max_lock_duration_ms),\n\t\t\tmaxLockMultiplier: BigInt(fields.max_lock_multiplier),\n\t\t\tminStakeAmount: BigInt(fields.min_stake_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static depositedPrincipalEventFromOnChainV1 = (\n\t\teventOnChain: FarmsDepositedPrincipalEventOnChainV1\n\t): FarmsDepositedPrincipalEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tamount: BigInt(fields.amount),\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static depositedPrincipalEventFromOnChainV2 = (\n\t\teventOnChain: FarmsDepositedPrincipalEventOnChainV2\n\t): FarmsDepositedPrincipalEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tamount: BigInt(fields.amount),\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static destroyedStakedPositionEventFromOnChainV1 = (\n\t\teventOnChain: FarmsDestroyedStakedPositionEventOnChainV1\n\t): FarmsDestroyedStakedPositionEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static destroyedStakedPositionEventFromOnChainV2 = (\n\t\teventOnChain: FarmsDestroyedStakedPositionEventOnChainV2\n\t): FarmsDestroyedStakedPositionEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static harvestedRewardsEventFromOnChainV1 = (\n\t\teventOnChain: FarmsHarvestedRewardsEventOnChainV1\n\t): FarmsHarvestedRewardsEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tvaultId: fields.afterburner_vault_id,\n\t\t\trewardTypes: fields.reward_types.map((rewardType) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + rewardType)\n\t\t\t),\n\t\t\trewardAmounts: fields.reward_amounts.map((amount) =>\n\t\t\t\tBigInt(amount)\n\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static harvestedRewardsEventFromOnChainV2 = (\n\t\teventOnChain: FarmsHarvestedRewardsEventOnChainV2\n\t): FarmsHarvestedRewardsEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tvaultId: fields.afterburner_vault_id,\n\t\t\trewardTypes: fields.reward_types.map((rewardType) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + rewardType)\n\t\t\t),\n\t\t\trewardAmounts: fields.reward_amounts.map((amount) =>\n\t\t\t\tBigInt(amount)\n\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static increasedEmissionsEventFromOnChainV1 = (\n\t\teventOnChain: FarmsIncreasedEmissionsEventOnChainV1\n\t): FarmsIncreasedEmissionsEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\temissionScheduleMs: Number(fields.emission_schedule_ms),\n\t\t\temissionRate: BigInt(fields.emission_rate),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static updatedEmissionsEventFromOnChainV2 = (\n\t\teventOnChain: FarmsUpdatedEmissionsEventOnChainV2\n\t): FarmsIncreasedEmissionsEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\temissionScheduleMs: Number(fields.emission_schedule_ms),\n\t\t\temissionRate: BigInt(fields.emission_rate),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static initializedRewardEventFromOnChainV1 = (\n\t\teventOnChain: FarmsInitializedRewardEventOnChainV1\n\t): FarmsInitializedRewardEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\trewardAmount: BigInt(fields.reward_amount),\n\t\t\temissionRate: BigInt(fields.emission_rate),\n\t\t\temissionStartMs: Number(fields.emission_start_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static initializedRewardEventFromOnChainV2 = (\n\t\teventOnChain: FarmsInitializedRewardEventOnChainV2\n\t): FarmsInitializedRewardEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tvaultId: fields.vault_id,\n\t\t\trewardType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.reward_type\n\t\t\t),\n\t\t\trewardAmount: BigInt(fields.reward_amount),\n\t\t\temissionRate: BigInt(fields.emission_rate),\n\t\t\temissionStartMs: Number(fields.emission_start_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static joinedEventFromOnChainV1 = (\n\t\teventOnChain: FarmsJoinedEventOnChainV1\n\t): FarmsJoinedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\totherStakedPositionId: fields.other_staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static joinedEventFromOnChainV2 = (\n\t\teventOnChain: FarmsJoinedEventOnChainV2\n\t): FarmsJoinedEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\totherStakedPositionId: fields.other_staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static lockedEventFromOnChainV1 = (\n\t\teventOnChain: FarmsLockedEventOnChainV1\n\t): FarmsLockedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\tlockStartTimestampMs: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static lockedEventFromOnChainV2 = (\n\t\teventOnChain: FarmsLockedEventOnChainV2\n\t): FarmsLockedEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\tlockStartTimestampMs: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static splitEventFromOnChainV1 = (\n\t\teventOnChain: FarmsSplitEventOnChainV1\n\t): FarmsSplitEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tsplitStakedPositionId: fields.split_staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static splitEventFromOnChainV2 = (\n\t\teventOnChain: FarmsSplitEventOnChainV2\n\t): FarmsSplitEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tsplitStakedPositionId: fields.split_staked_position_id,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static stakedEventFromOnChainV1 = (\n\t\teventOnChain: FarmsStakedEventOnChainV1\n\t): FarmsStakedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\tmultipliedStakedAmount: BigInt(fields.multiplied_staked_amount),\n\t\t\tlockStartTimestampMs: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static stakedEventFromOnChainV2 = (\n\t\teventOnChain: FarmsStakedEventOnChainV2\n\t): FarmsStakedEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\tmultipliedStakedAmount: BigInt(fields.multiplier_staked_amount),\n\t\t\tlockStartTimestampMs: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockDurationMs: Number(fields.lock_duration_ms),\n\t\t\tlockMultiplier: BigInt(fields.lock_multiplier),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static stakedRelaxedEventFromOnChainV1 = (\n\t\teventOnChain: FarmsStakedRelaxedEventOnChainV1\n\t): FarmsStakedRelaxedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\tlockStartTimestampMs: Number(fields.lock_start_timestamp_ms),\n\t\t\tlockEndTimestampMs: Number(fields.lock_end_timestamp_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static unlockedEventFromOnChainV1 = (\n\t\teventOnChain: FarmsUnlockedEventOnChainV1\n\t): FarmsUnlockedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static unlockedEventFromOnChainV2 = (\n\t\teventOnChain: FarmsUnlockedEventOnChainV2\n\t): FarmsUnlockedEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tstakedType: Helpers.addLeadingZeroesToType(\n\t\t\t\t\"0x\" + fields.staked_type\n\t\t\t),\n\t\t\tstakedAmount: BigInt(fields.staked_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static withdrewPrincipalEventFromOnChainV1 = (\n\t\teventOnChain: FarmsWithdrewPrincipalEventOnChainV1\n\t): FarmsWithdrewPrincipalEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tamount: BigInt(fields.amount),\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static withdrewPrincipalEventFromOnChainV2 = (\n\t\teventOnChain: FarmsWithdrewPrincipalEventOnChainV2\n\t): FarmsWithdrewPrincipalEvent => {\n\t\tconst fields = eventOnChain.parsedJson.pos0;\n\t\treturn {\n\t\t\tstakedPositionId: fields.staked_position_id,\n\t\t\tvaultId: fields.vault_id,\n\t\t\tamount: BigInt(fields.amount),\n\t\t\tstakeType: Helpers.addLeadingZeroesToType(\"0x\" + fields.stake_type),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","export * from \"./coin\";\n","import {\n\tFaucetAddCoinEventOnChain,\n\tFaucetMintCoinEventOnChain,\n} from \"./faucetApiCastingTypes\";\nimport { FaucetAddCoinEvent, FaucetMintCoinEvent } from \"../faucetTypes\";\nimport { Helpers } from \"../../../general/utils\";\nimport { Coin } from \"../../coin\";\n\nexport class FaucetApiCasting {\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static faucetMintCoinEventFromOnChain = (\n\t\teventOnChain: FaucetMintCoinEventOnChain\n\t): FaucetMintCoinEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\tconst coinType = Helpers.addLeadingZeroesToType(\n\t\t\tnew Coin(eventOnChain.type).innerCoinType\n\t\t);\n\t\treturn {\n\t\t\tcoinType,\n\t\t\tminter: Helpers.addLeadingZeroesToType(fields.user),\n\t\t\tamount: BigInt(fields.amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static faucetAddCoinEventFromOnChain = (\n\t\teventOnChain: FaucetAddCoinEventOnChain\n\t): FaucetAddCoinEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\tconst coinType = Helpers.addLeadingZeroesToType(\n\t\t\tnew Coin(eventOnChain.type).innerCoinType\n\t\t);\n\t\treturn {\n\t\t\tcoinType,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import {\n\tDaoFeePoolObject,\n\tDaoFeePoolOwnerCapObject,\n\tPoolCoins,\n\tPoolDepositEvent,\n\tPoolObject,\n\tPoolTradeEvent,\n\tPoolWithdrawEvent,\n} from \"../poolsTypes\";\nimport {\n\tPoolCreateEventOnChain,\n\tPoolFieldsOnChain,\n\tPoolTradeEventOnChainFields,\n\tPoolDepositEventFieldsOnChain,\n\tPoolWithdrawEventFieldsOnChain,\n\tPoolTradeEventOnChain,\n\tPoolDepositEventOnChain,\n\tPoolWithdrawEventOnChain,\n\tDaoFeePoolFieldsOnChain,\n\tDaoFeePoolOwnerCapFieldsOnChain,\n} from \"./poolsApiCastingTypes\";\nimport { Coin } from \"../../coin\";\nimport { Helpers } from \"../../../general/utils\";\nimport { AnyObjectType, ObjectId } from \"../../../types\";\nimport { IndexerEventOnChain } from \"../../../general/types/castingTypes\";\nimport type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\n\nexport class PoolsApiCasting {\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic static poolObjectFromSuiObject = (\n\t\tsuiObject: SuiObjectResponse\n\t): PoolObject => {\n\t\tconst objectId = Helpers.getObjectId(suiObject);\n\t\tconst objectType = Helpers.getObjectType(suiObject);\n\n\t\tconst poolFieldsOnChain = Helpers.getObjectFields(\n\t\t\tsuiObject\n\t\t) as PoolFieldsOnChain;\n\n\t\tconst lpCoinType = Helpers.addLeadingZeroesToType(\n\t\t\tCoin.getInnerCoinType(poolFieldsOnChain.lp_supply.type)\n\t\t);\n\n\t\tconst coins: PoolCoins = poolFieldsOnChain.type_names.reduce(\n\t\t\t(acc, cur, index) => ({\n\t\t\t\t...acc,\n\t\t\t\t[Helpers.addLeadingZeroesToType(\"0x\" + cur)]: {\n\t\t\t\t\tweight: BigInt(poolFieldsOnChain.weights[index]),\n\t\t\t\t\tbalance:\n\t\t\t\t\t\tBigInt(poolFieldsOnChain.normalized_balances[index]) /\n\t\t\t\t\t\tBigInt(poolFieldsOnChain.decimal_scalars[index]),\n\t\t\t\t\ttradeFeeIn: BigInt(poolFieldsOnChain.fees_swap_in[index]),\n\t\t\t\t\ttradeFeeOut: BigInt(poolFieldsOnChain.fees_swap_out[index]),\n\t\t\t\t\tdepositFee: BigInt(poolFieldsOnChain.fees_deposit[index]),\n\t\t\t\t\twithdrawFee: BigInt(poolFieldsOnChain.fees_withdraw[index]),\n\t\t\t\t\tnormalizedBalance: BigInt(\n\t\t\t\t\t\tpoolFieldsOnChain.normalized_balances[index]\n\t\t\t\t\t),\n\t\t\t\t\tdecimalsScalar: BigInt(\n\t\t\t\t\t\tpoolFieldsOnChain.decimal_scalars[index]\n\t\t\t\t\t),\n\t\t\t\t\t...(poolFieldsOnChain.coin_decimals\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdecimals: Number(\n\t\t\t\t\t\t\t\t\tpoolFieldsOnChain.coin_decimals[index]\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{}\n\t\t);\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId,\n\t\t\tlpCoinType,\n\t\t\tname: poolFieldsOnChain.name,\n\t\t\tcreator: poolFieldsOnChain.creator,\n\t\t\tlpCoinSupply: BigInt(poolFieldsOnChain.lp_supply.fields.value),\n\t\t\tilliquidLpCoinSupply: BigInt(poolFieldsOnChain.illiquid_lp_supply),\n\t\t\tflatness: BigInt(poolFieldsOnChain.flatness),\n\t\t\tlpCoinDecimals: Number(poolFieldsOnChain.lp_decimals),\n\t\t\tcoins,\n\t\t};\n\t};\n\n\tpublic static daoFeePoolOwnerCapObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): DaoFeePoolOwnerCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as DaoFeePoolOwnerCapFieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tdaoFeePoolId: Helpers.addLeadingZeroesToType(\n\t\t\t\tfields.dao_fee_pool_id\n\t\t\t),\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static poolObjectIdfromPoolCreateEventOnChain = (\n\t\teventOnChain: PoolCreateEventOnChain\n\t): ObjectId => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn fields.pool_id;\n\t};\n\n\tpublic static poolTradeEventFromOnChain = (\n\t\teventOnChain: PoolTradeEventOnChain\n\t): PoolTradeEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tpoolId: fields.pool_id,\n\t\t\ttrader: fields.issuer,\n\t\t\ttypesIn: fields.types_in.map((type) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + type)\n\t\t\t),\n\t\t\tamountsIn: fields.amounts_in.map((amount) => BigInt(amount)),\n\t\t\ttypesOut: fields.types_out.map((type) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + type)\n\t\t\t),\n\t\t\tamountsOut: fields.amounts_out.map((amount) => BigInt(amount)),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static poolDepositEventFromOnChain = (\n\t\teventOnChain: PoolDepositEventOnChain\n\t): PoolDepositEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tpoolId: fields.pool_id,\n\t\t\tdepositor: fields.issuer,\n\t\t\ttypes: fields.types.map((type) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + type)\n\t\t\t),\n\t\t\tdeposits: fields.deposits.map((deposit) => BigInt(deposit)),\n\t\t\tlpMinted: BigInt(fields.lp_coins_minted),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static poolWithdrawEventFromOnChain = (\n\t\teventOnChain: PoolWithdrawEventOnChain\n\t): PoolWithdrawEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tpoolId: fields.pool_id,\n\t\t\twithdrawer: fields.issuer,\n\t\t\ttypes: fields.types.map((type) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(\"0x\" + type)\n\t\t\t),\n\t\t\twithdrawn: fields.withdrawn.map((withdraw) => BigInt(withdraw)),\n\t\t\tlpBurned: BigInt(fields.lp_coins_burned),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import { NftAmmMarketObject } from \"../nftAmmTypes\";\nimport { Helpers } from \"../../../general/utils\";\nimport { NftAmmMarketFieldsOnChain } from \"./nftAmmApiCastingTypes\";\nimport { Coin } from \"../../coin\";\nimport { PoolsApiCasting } from \"../../pools/api/poolsApiCasting\";\nimport type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\n\nexport class NftAmmApiCasting {\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic static marketObjectFromSuiObject = (\n\t\tsuiObject: SuiObjectResponse\n\t): NftAmmMarketObject => {\n\t\tconst objectId = Helpers.getObjectId(suiObject);\n\t\tconst marketType = Helpers.getObjectType(suiObject);\n\t\tif (!marketType) throw new Error(\"no object type found\");\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tsuiObject\n\t\t) as NftAmmMarketFieldsOnChain;\n\n\t\tconst pool = PoolsApiCasting.poolObjectFromSuiObject(fields.pool);\n\n\t\tconst fractionalizedCoinType = Coin.getInnerCoinType(\n\t\t\tfields.supply.type\n\t\t);\n\n\t\tconst innerMarketTypes = Coin.getInnerCoinType(marketType);\n\t\tconst genericTypes = innerMarketTypes.replaceAll(\" \", \"\").split(\",\");\n\n\t\tconst assetCoinType = genericTypes[2];\n\t\tconst nftType = genericTypes[3];\n\n\t\treturn {\n\t\t\tobjectId,\n\t\t\tpool,\n\t\t\tobjectType: marketType,\n\t\t\tnftsTable: {\n\t\t\t\tobjectId: fields.nfts.fields.id.id,\n\t\t\t\tsize: BigInt(fields.nfts.fields.size),\n\t\t\t},\n\t\t\tfractionalizedSupply: BigInt(fields.supply.fields.value),\n\t\t\tfractionalizedCoinAmount: BigInt(fields.fractions_amount),\n\t\t\tfractionalizedCoinType,\n\t\t\tassetCoinType,\n\t\t\tlpCoinType: pool.lpCoinType,\n\t\t\tnftType,\n\t\t};\n\t};\n}\n","import {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { bcs, type BcsType } from \"@mysten/sui/bcs\";\nimport {\n\tAnyObjectType,\n\tApiDataWithCursorBody,\n\tApiIndexerEventsBody,\n\tBalance,\n\tBigIntAsString,\n\tByte,\n\tEvent,\n\tIFixed,\n\tIFixedAsString,\n\tObject,\n\tObjectDigest,\n\tObjectId,\n\tObjectVersion,\n\tPackageId,\n\tPercentage,\n\tSerializedTransaction,\n\tSlippage,\n\tSuiAddress,\n\tSuiCheckpoint,\n\tTimestamp,\n\tTransactionDigest,\n} from \"../../general/types/generalTypes\";\nimport {\n\tCoinDecimal,\n\tCoinSymbol,\n\tCoinType,\n\tServiceCoinData,\n} from \"../coin/coinTypes\";\n\n// =========================================================================\n// Name Only\n// =========================================================================\n\n/**\n * Unique identifier for a perpetuals market, represented as a Sui object ID\n * (i.e. the `ClearingHouse` object on-chain).\n */\nexport type PerpetualsMarketId = ObjectId;\n\n/**\n * Unique numeric identifier for a perpetuals account.\n *\n * This is a bigint, as it is derived directly from the on-chain representation.\n */\nexport type PerpetualsAccountId = bigint;\n\n/**\n * Unique numeric identifier for a perpetuals order.\n *\n * This ID is stable across events and API responses.\n */\nexport type PerpetualsOrderId = bigint;\n\n/**\n * String representation of a {@link PerpetualsOrderId}.\n *\n * Some APIs serialize order IDs as strings instead of `bigint`.\n */\nexport type PerpetualsOrderIdAsString = string;\n\n/**\n * Price type for orders, represented as a fixed-point `bigint` in the\n * on-chain format (e.g., scaled by `1e9`).\n */\nexport type PerpetualsOrderPrice = bigint;\n\n// =========================================================================\n// Enums\n// =========================================================================\n\n/**\n * Side of a perpetuals order.\n *\n * - `Bid` (0): Long-side orders / buyers.\n * - `Ask` (1): Short-side orders / sellers.\n */\nexport enum PerpetualsOrderSide {\n\tAsk = 1, // true\n\tBid = 0, // false\n}\n\n/**\n * Order execution and posting behavior.\n *\n * - `Standard`: No special constraints.\n * - `FillOrKill`: Either fully fills immediately or cancels.\n * - `PostOnly`: Only posts to the book; will not take liquidity.\n * - `ImmediateOrCancel`: Fills as much as possible immediately; remainder is canceled.\n */\nexport enum PerpetualsOrderType {\n\tStandard = 0,\n\tFillOrKill = 1,\n\tPostOnly = 2,\n\tImmediateOrCancel = 3,\n}\n\n/**\n * Stop order mode.\n *\n * - `SlTp`: Stop Loss / Take Profit order, intended to close a position\n * (fully or partially).\n * - `Standalone`: Independent stop order that can both reduce or increase\n * the position, potentially requiring additional allocated collateral.\n */\nexport enum PerpetualsStopOrderType {\n\t/**\n\t * Stop Loss / Take Profit stop order. Can to be placed to close (fully or partially)\n\t * the position.\n\t */\n\tSlTp = 0,\n\t/**\n\t * Stop order that can be both reduce or increase the position's size. May require\n\t * some collateral to be allocated to be able to be placed.\n\t */\n\tStandalone = 1,\n}\n\n// =========================================================================\n// Market\n// =========================================================================\n\n/**\n * Aggregate market configuration and state for a single perpetuals market.\n */\nexport interface PerpetualsMarketData {\n\t/** Package ID of the deployed perpetuals contract. */\n\tpackageId: PackageId;\n\t/** Object ID for the market (clearing house) on-chain. */\n\tobjectId: ObjectId;\n\t// initialSharedVersion: ObjectVersion;\n\t/** Collateral coin type used for margin in this market. */\n\tcollateralCoinType: CoinType;\n\t/** Static configuration parameters for this market. */\n\tmarketParams: PerpetualsMarketParams;\n\t/** Dynamic runtime state (funding, open interest, etc.). */\n\tmarketState: PerpetualsMarketState;\n\t/** Current price of collateral in USD or the platform's base unit. */\n\tcollateralPrice: number;\n\t/** Oracle/index price of the base asset for this market. */\n\tindexPrice: number;\n\t/** Estimated funding rate for the next funding interval. */\n\testimatedFundingRate: Percentage;\n\t/** Timestamp (ms) for the next funding event, as a bigint. */\n\tnextFundingTimestampMs: bigint;\n}\n\n/**\n * On-chain capability object that grants control over a perpetuals account.\n *\n * This represents an \"owned\" account capability, used to sign and authorize\n * account-level actions.\n */\nexport interface PerpetualsAccountCap {\n\t/** Object ID of the account capability on-chain. */\n\tobjectId: ObjectId;\n\t/** Wallet address that owns this account capability. */\n\twalletAddress: SuiAddress;\n\t/** Logical ID of the associated perpetuals account. */\n\taccountId: PerpetualsAccountId;\n\t/** Object ID of the associated `PerpetualsAccountObject`. */\n\taccountObjectId: ObjectId;\n\t/** Collateral coin type backing this account. */\n\tcollateralCoinType: CoinType;\n\t/** Total collateral (native units) associated with this account. */\n\tcollateral: number;\n\t// collateralDecimals: CoinDecimal;\n\t/** On-chain object version. */\n\tobjectVersion: ObjectVersion;\n\t/** On-chain object digest. */\n\tobjectDigest: ObjectDigest;\n\t// subAccount: PerpetualsSubAccount;\n\t/** True if this account cap was allocated to an agent wallet from the admin account cap owner. */\n\tisAgent: boolean;\n\t/** Initial shared version of the underlying perpetuals `Account` object. Required when constructing transactions that reference the shared account object. */\n\taccountObjectInitialSharedVersion: ObjectVersion;\n\t/** Sui object IDs of agent account caps that have been whitelisted to operate on behalf of this account. */\n\twhitelistedAgentCapIds: ObjectId[];\n}\n\n/**\n * Base vault-capability object, as represented on-chain.\n */\nexport interface PerpetualsVaultCap {\n\t/** Vault object ID that this cap grants permissions for. */\n\tvaultId: ObjectId;\n\t/** Capability object ID. */\n\tobjectId: ObjectId;\n\t/** Owner of the vault-capability. */\n\townerAddress: SuiAddress;\n\t/** Collateral coin type used by the vault account. */\n\tcollateralCoinType: CoinType;\n\t/** Perpetuals account ID controlled by the vault. */\n\taccountId: PerpetualsAccountId;\n\t/** Object ID of the account object owned by the vault. */\n\taccountObjectId: ObjectId;\n}\n\nexport type PerpetualsPartialVaultCap = Omit<PerpetualsVaultCap, \"objectId\">;\n\n/**\n * Representation of an LP (share) coin position for a specific vault.\n *\n * This is typically returned by API endpoints that enumerate a wallet's vault\n * positions. `lpAmount` is the raw on-chain balance for the vault's LP coin type.\n *\n * Notes:\n * - `lpAmountUsd` is a convenience valuation derived from current vault TVL and LP supply.\n * - The LP coin itself is an on-chain `Coin<T>` object, but here we expose the derived,\n * aggregated view needed by UIs.\n */\nexport interface PerpetualsVaultLpCoin {\n\t/** Vault identifier that minted the LP coin. */\n\tvaultId: ObjectId;\n\t/** Object ID of the specific LP coin object held by the user. */\n\tobjectId: ObjectId;\n\t/** Raw LP token amount (native units; not human-decimal adjusted). */\n\tlpAmount: Balance;\n\t/** Estimated USD value of `lpAmount` at query time. */\n\tlpAmountUsd: number;\n}\n\n/**\n * Aggregate position data for a single perpetuals market and account.\n *\n * Values are generally denoted in:\n * - Base asset units (e.g. BTC)\n * - Quote units (e.g. USD)\n * - Collateral units (per `collateralCoinType`)\n */\nexport interface PerpetualsPosition {\n\t/** Allocated collateral (in collateral coins). */\n\tcollateral: number;\n\t/** Net base asset amount (positive = long, negative = short). */\n\tbaseAssetAmount: number;\n\t/** Notional exposure of the position in quote units. */\n\tquoteAssetNotionalAmount: number;\n\t/** Cumulative funding rate accrued on the long side. */\n\tcumFundingRateLong: number;\n\t/** Cumulative funding rate accrued on the short side. */\n\tcumFundingRateShort: number;\n\t/** Aggregate size of resting asks in this market for the account. */\n\tasksQuantity: number;\n\t/** Aggregate size of resting bids in this market for the account. */\n\tbidsQuantity: number;\n\t// collateralCoinType: CoinType;\n\t/** Market identifier for this position. */\n\tmarketId: PerpetualsMarketId;\n\t/** All pending (open) orders associated with this position. */\n\tpendingOrders: {\n\t\t/** Unique ID of the order. */\n\t\torderId: PerpetualsOrderId;\n\t\t/** Side of the order (Bid/Ask). */\n\t\tside: PerpetualsOrderSide;\n\t\t/** Current size remaining of the order in base units (scaled as bigint). */\n\t\tcurrentSize: bigint;\n\t\t/** Initial size of the order in base units (scaled as bigint). */\n\t\tinitialSize: bigint;\n\t}[];\n\t/** Maker fee rate applied to this position (as a fraction). */\n\tmakerFee: Percentage;\n\t/** Taker fee rate applied to this position (as a fraction). */\n\ttakerFee: Percentage;\n\t/** Effective leverage applied to the position. */\n\tleverage: number;\n\t/** Collateral value in USD. */\n\tcollateralUsd: number;\n\t/** Current margin ratio (collateral / exposure). */\n\tmarginRatio: number;\n\t/** Free margin available in USD. */\n\tfreeMarginUsd: number;\n\t/** Free (unlocked) collateral in collateral units. */\n\tfreeCollateral: number;\n\t/** Unrealized funding PnL in USD. */\n\tunrealizedFundingsUsd: number;\n\t/** Unrealized position PnL in USD. */\n\tunrealizedPnlUsd: number;\n\t/** Average entry price of the position. */\n\tentryPrice: number;\n\t/** Approximate liquidation price for the position. */\n\tliquidationPrice: number;\n}\n\n// export interface PerpetualsSubAccount {\n// \taccountId: PerpetualsAccountId;\n// \tcollateralCoinType: CoinType;\n// \tcollateral: number;\n// \tobjectVersion: ObjectVersion;\n// \t// objectDigest: ObjectDigest;\n// \tobjectId: ObjectId;\n// }\n\n// =========================================================================\n// Market\n// =========================================================================\n\n/**\n * Static configuration parameters describing a perpetuals market.\n *\n * These values are typically immutable or rarely changed, and are used\n * to drive risk limits, pricing, and fee schedules.\n */\nexport interface PerpetualsMarketParams {\n\t/** Initial margin requirement for new positions (fraction). */\n\tmarginRatioInitial: number;\n\t/** Maintenance margin requirement for open positions (fraction). */\n\tmarginRatioMaintenance: number;\n\t/** Symbol of the underlying asset. */\n\tbaseAssetSymbol: CoinSymbol;\n\t/** On-chain ID of the oracle providing the base asset price. */\n\tbasePriceFeedId: ObjectId;\n\t/** On-chain ID of the oracle providing the collateral asset price. */\n\tcollateralPriceFeedId: ObjectId;\n\t/** Funding interval duration in milliseconds. */\n\tfundingFrequencyMs: bigint;\n\t/** Funding period used for calculations in milliseconds. */\n\tfundingPeriodMs: bigint;\n\t/** TWAP frequency for the premium in milliseconds. */\n\tpremiumTwapFrequencyMs: bigint;\n\t/** TWAP period for the premium in milliseconds. */\n\tpremiumTwapPeriodMs: bigint;\n\t/** TWAP frequency for the spread in milliseconds. */\n\tspreadTwapFrequencyMs: bigint;\n\t/** TWAP period for the spread in milliseconds. */\n\tspreadTwapPeriodMs: bigint;\n\t/** TWAP period for gas price in milliseconds. */\n\tgasPriceTwapPeriodMs: bigint;\n\t/** Maker fee rate (fraction) charged for providing liquidity. */\n\tmakerFee: Percentage;\n\t/** Taker fee rate (fraction) charged for taking liquidity. */\n\ttakerFee: Percentage;\n\t/** Liquidation fee rate (fraction) charged on liquidations. */\n\tliquidationFee: Percentage;\n\t/** Fee rate (fraction) for forced cancellation. */\n\tforceCancelFee: Percentage;\n\t/** Fraction of fees directed to the insurance fund. */\n\tinsuranceFundFee: Percentage;\n\t/** Minimum notional order value in USD. */\n\tminOrderUsdValue: number;\n\t/** Minimum base size increment for orders (lot size, scaled bigint). */\n\tlotSize: bigint;\n\t/** Minimum price increment (tick size, scaled bigint). */\n\ttickSize: bigint;\n\t/** Scaling factor used in internal fixed-point conversions. */\n\tscalingFactor: number;\n\t/** Additional taker fee that depends on gas cost. */\n\tgasPriceTakerFee: Percentage;\n\t/** Z-score threshold used for outlier detection in pricing. */\n\tzScoreThreshold: number;\n\t/** Maximum open interest (notional or base) allowed in the market. */\n\tmaxPendingOrders: bigint;\n\t/** Oracle tolerance for the base asset price (scaled bigint). */\n\tbaseOracleTolerance: bigint;\n\t/** Oracle tolerance for the collateral price (scaled bigint). */\n\tcollateralOracleTolerance: bigint;\n\t/** Maximum open interest (absolute). */\n\tmaxOpenInterest: number;\n\t/** Threshold above which open interest is considered elevated. */\n\tmaxOpenInterestThreshold: number;\n\t/** Maximum fraction of open interest a single position can hold. */\n\tmaxOpenInterestPositionPercent: number;\n}\n\n/**\n * Dynamic runtime state of a perpetuals market.\n *\n * These values are updated frequently and used to compute funding\n * and other time-variant metrics.\n */\nexport interface PerpetualsMarketState {\n\t/** Cumulative funding rate for long positions. */\n\tcumFundingRateLong: number;\n\t/** Cumulative funding rate for short positions. */\n\tcumFundingRateShort: number;\n\t/** Last timestamp when funding was updated. */\n\tfundingLastUpdateTimestamp: Timestamp;\n\t/** Premium TWAP value (book vs index). */\n\tpremiumTwap: number;\n\t/** Timestamp of last premium TWAP update. */\n\tpremiumTwapLastUpdateTimestamp: Timestamp;\n\t/** Spread TWAP value. */\n\tspreadTwap: number;\n\t/** Timestamp of last spread TWAP update. */\n\tspreadTwapLastUpdateTimestamp: Timestamp;\n\t/** Current open interest in the market. */\n\topenInterest: number;\n\t/** Total fees accrued by the market. */\n\tfeesAccrued: number;\n\t// nextFundingTimestamp: Timestamp;\n\t// estimatedFundingRate: Percentage;\n}\n\n/**\n * Single OHLCV data point for a market candle.\n *\n * Typically used in charts and historical data views.\n */\nexport interface PerpetualsMarketCandleDataPoint {\n\t/** Start timestamp of this candle. */\n\ttimestamp: Timestamp;\n\t/** High price within this interval. */\n\thigh: number;\n\t/** Low price within this interval. */\n\tlow: number;\n\t/** Open price at the beginning of the interval. */\n\topen: number;\n\t/** Close price at the end of the interval. */\n\tclose: number;\n\t/** Traded volume (base units) during the interval. */\n\tvolume: number;\n}\n\n// =========================================================================\n// Orderbook\n// =========================================================================\n\n/**\n * A single entry (price level) in an orderbook side.\n */\nexport interface PerpetualsOrderbookItem {\n\t/** Total size resting at this price level (base units). */\n\tsize: number;\n\t/** Price level for the aggregated orders. */\n\tprice: number;\n}\n\n/**\n * Aggregated orderbook snapshot for a perpetuals market.\n */\nexport interface PerpetualsOrderbook {\n\t/** Bid-side price levels (sorted descending by price). */\n\tbids: PerpetualsOrderbookItem[];\n\t/** Ask-side price levels (sorted ascending by price). */\n\tasks: PerpetualsOrderbookItem[];\n\t/** Sum of bid-side size across all levels. */\n\tasksTotalSize: number;\n\t/** Sum of ask-side size across all levels. */\n\tbidsTotalSize: number;\n\t/** Best bid price (highest bid), or undefined if no bids. */\n\tbestBidPrice: number | undefined;\n\t/** Best ask price (lowest ask), or undefined if no asks. */\n\tbestAskPrice: number | undefined;\n\t/** Mid price between best bid and best ask, if both exist. */\n\tmidPrice: number | undefined;\n\t/** Incremental nonce associated with this snapshot. */\n\tnonce: bigint;\n}\n\n/**\n * Incremental deltas to an orderbook snapshot.\n *\n * These are typically used over websockets for streaming updates.\n */\nexport interface PerpetualsOrderbookDeltas {\n\t/** Updated bid-side price levels. */\n\tbidsDeltas: PerpetualsOrderbookItem[];\n\t/** Updated ask-side price levels. */\n\tasksDeltas: PerpetualsOrderbookItem[];\n\t/** Delta of total ask-side size. */\n\tasksTotalSizeDelta: number;\n\t/** Delta of total bid-side size. */\n\tbidsTotalSizeDelta: number;\n\t/** Nonce for ordering deltas. */\n\tnonce: bigint;\n}\n\n/**\n * Core order metadata for perpetuals orders.\n *\n * This is shared across multiple internal and external APIs.\n */\nexport interface PerpetualsOrderData {\n\t/** Unique ID of the order. */\n\torderId: PerpetualsOrderId;\n\t/** Initial order size in scaled base units. */\n\tinitialSize: bigint;\n\t/** Current size remaining in scaled base units. */\n\tcurrentSize: bigint;\n\t/** Order side (Bid or Ask). */\n\tside: PerpetualsOrderSide;\n\t/** Market this order belongs to. */\n\tmarketId: PerpetualsMarketId;\n}\n\n// reduceOnly: boolean;\n// expiryTimestamp?: bigint;\n// limitOrder?: {\n// \tprice: PerpetualsOrderPrice;\n// \torderType: PerpetualsOrderType;\n// };\n\n/**\n * Optional integrator fee configuration for an order.\n *\n * When provided, this allows an approved integrator to collect a fee on the taker\n * volume generated by this order. The integrator must have been previously approved\n * by the user via the create-integration endpoint, and the taker fee must not exceed\n * the maximum fee approved by the user.\n */\nexport interface PerpetualsBuilderCodeParamaters {\n\t/**\n\t * Sui address of the integrator who will receive the fee.\n\t *\n\t * This integrator must have been previously approved by the account owner,\n\t * and must have a vault created for the market where the order is being placed.\n\t */\n\tintegratorAddress: SuiAddress;\n\n\t/**\n\t * Taker fee (as a decimal) to be charged on this order's taker volume.\n\t *\n\t * For example, 0.0005 represents a 0.05% fee. This value must not exceed\n\t * the maximum taker fee that the user approved for this integrator.\n\t * The fee is only applied to taker volume (not maker volume).\n\t */\n\ttakerFee: Percentage;\n}\n\n/**\n * Full stop-order representation on-chain.\n *\n * Can represent:\n * - SL/TP orders (`slTp`)\n * - Standalone stops (`nonSlTp`)\n */\nexport interface PerpetualsStopOrderData {\n\t/** ID of the stop order object on-chain. */\n\tobjectId: ObjectId;\n\t/** Market the stop order is tied to. */\n\tmarketId: PerpetualsMarketId;\n\t/** Size to execute when triggered (scaled base units). */\n\tsize: bigint;\n\t/** Direction of the stop order. */\n\tside: PerpetualsOrderSide;\n\t/** Optional expiration time (ms or seconds, depending on protocol). */\n\texpiryTimestamp?: bigint;\n\t/** Optional limit order parameters when the stop triggers. */\n\tlimitOrder?: {\n\t\t/** Limit price to post or execute at, scaled bigint. */\n\t\tprice: bigint;\n\t\t/** Order type semantics. */\n\t\torderType: PerpetualsOrderType;\n\t};\n\t/** Stop loss / take profit configuration. */\n\tslTp?: {\n\t\t/** Index price at which to trigger a stop loss. */\n\t\tstopLossIndexPrice?: number;\n\t\t/** Index price at which to take profit. */\n\t\ttakeProfitIndexPrice?: number;\n\t\t/** Unique order identifier for limit order sl/tp is tied to. */\n\t\tlimitOrderId?: PerpetualsOrderId;\n\t};\n\t/** Non-SL/TP standalone stop configuration. */\n\tnonSlTp?: {\n\t\t/** Index price threshold used for triggering. */\n\t\tstopIndexPrice: number;\n\t\t/** If true, triggers when index >= threshold, otherwise index <= threshold. */\n\t\ttriggerIfGeStopIndexPrice: boolean;\n\t\t/** Whether the stop can only reduce an existing position. */\n\t\treduceOnly: boolean;\n\t};\n}\n\n/**\n * Filled order data used in execution price previews and trade details.\n */\nexport interface PerpetualsFilledOrderData {\n\t/** Filled size in base units (non-scaled). */\n\tsize: number;\n\t/** Execution price for the fill. */\n\tprice: number;\n}\n\n/**\n * High-level order info with price and size only.\n */\nexport interface PerpetualsOrderInfo {\n\t/** Order price. */\n\tprice: number;\n\t/** Order size (scaled base units). */\n\tsize: bigint;\n}\n\n/**\n * Pairing of a perpetuals account capability and its current account state.\n */\nexport interface PerpetualsAccountData {\n\t/** Account capability object. */\n\taccountCap: PerpetualsAccountCap;\n\t/** Account state object. */\n\taccount: PerpetualsAccountObject;\n}\n\n/**\n * Aggregate account-level metrics for perpetuals.\n */\nexport interface PerpetualsAccountObject {\n\t/** Numeric ID of the account. */\n\taccountId: PerpetualsAccountId;\n\t/** Total equity in USD. */\n\ttotalEquityUsd: number;\n\t/** Available collateral in collateral units. */\n\tavailableCollateral: number;\n\t/** Available collateral in USD. */\n\tavailableCollateralUsd: number;\n\t/** Sum of unrealized funding PnL across markets. */\n\ttotalUnrealizedFundingsUsd: number;\n\t/** Sum of unrealized position PnL across markets. */\n\ttotalUnrealizedPnlUsd: number;\n\t/** Per-market positions for this account. */\n\tpositions: PerpetualsPosition[];\n}\n\n/**\n * Human-facing metadata for vault discovery / browsing.\n *\n * This is intended for UI display and is not used for any on-chain risk or\n * accounting logic.\n *\n * Note: The type name contains a historical misspelling (\"Metatada\") and is\n * preserved for backward compatibility.\n */\nexport interface PerpetualsVaultMetatada {\n\t/**\n\t * A human-readable name for the `Vault`.\n\t */\n\tname: string;\n\t/**\n\t * A verbose description of the `Vault`.\n\t */\n\tdescription: string;\n\t/**\n\t * The `Vault` curator's name.\n\t */\n\tcuratorName: string | undefined;\n\t/**\n\t * A url for the `Vault`'s curator. Ideally their website.\n\t */\n\tcuratorUrl: string | undefined;\n\t/**\n\t * An image url for the `Vault`'s curator. Ideally their logo.\n\t */\n\tcuratorLogoUrl: string | undefined;\n\t/**\n\t * Extra / optional fields for future extensibility. Recommended keys include: twitter_url.\n\t */\n\textraFields: Record<string, string>;\n}\n\n/**\n * On-chain representation of a vault that manages user collateral and\n * interacts with clearing houses on their behalf.\n */\nexport interface PerpetualsVaultObject {\n\t/**\n\t * Unique identifier for distinct network identification.\n\t */\n\tobjectId: ObjectId;\n\t/**\n\t * Contract version number for controlled upgrades.\n\t */\n\tversion: bigint;\n\t/**\n\t * Curator-provided metadata used for vault discovery and display.\n\t *\n\t * This data is expected to be relatively stable and is typically set at\n\t * creation time (though it may be updatable depending on protocol rules).\n\t */\n\tmetadata: PerpetualsVaultMetatada;\n\t/**\n\t * Supply of LP coins from a `TreasuryCap` for liquidity integrity.\n\t *\n\t * This is the total minted supply of the vault's LP token. Together with\n\t * `tvlUsd` and `totalCollateral`, this is used to derive LP share price.\n\t */\n\tlpSupply: Balance;\n\t/**\n\t * Total balance of underlying Coin (`C`), deposited by users.\n\t *\n\t * \"Idle\" collateral is not currently allocated to any clearing house\n\t * position. It remains held by the vault and can be used for new allocations\n\t * or withdrawals (subject to lock/queue rules).\n\t */\n\tidleCollateral: Balance;\n\t/**\n\t * USD valuation of `idleCollateral` at query time.\n\t *\n\t * This is derived using the vault's collateral oracle price and is provided\n\t * for UI convenience.\n\t */\n\tidleCollateralUsd: number;\n\t/**\n\t * Total collateral owned by the vault in native units.\n\t *\n\t * This is the sum of:\n\t * - idle collateral held directly by the vault, and\n\t * - collateral currently allocated across clearing houses/positions.\n\t */\n\ttotalCollateral: Balance;\n\t/**\n\t * USD valuation of `totalCollateral` at query time.\n\t *\n\t * This is typically derived from `totalCollateral` and the collateral oracle\n\t * price used by the vault.\n\t */\n\ttotalCollateralUsd: number;\n\t/**\n\t * Total value locked in USD for this vault.\n\t *\n\t * Depending on protocol accounting, this may match `totalCollateralUsd`, or\n\t * may incorporate additional adjustments. It is the primary headline number\n\t * used for ranking and display.\n\t */\n\ttvlUsd: number;\n\t/**\n\t * IDs of `ClearingHouse` where `Vault` has positions.\n\t */\n\tmarketIds: PerpetualsMarketId[];\n\t/**\n\t * Vault parameters\n\t */\n\tparameters: {\n\t\t/**\n\t\t * Lock-in duration for engaged assets in milliseconds.\n\t\t */\n\t\tlockPeriodMs: bigint;\n\t\t/**\n\t\t * Fee rate for vault's owner, collected from user's profits when they withdraw\n\t\t */\n\t\tperformanceFeePercentage: number;\n\t\t/**\n\t\t * Delay period to wait for eventual force withdrawing\n\t\t *\n\t\t * Force-withdrawal is an emergency/escape hatch path; this delay gives the\n\t\t * vault time to unwind positions before executing the withdrawal.\n\t\t */\n\t\tforceWithdrawDelayMs: bigint;\n\t\t/**\n\t\t * Price feed storage id idetifying the oracle price for `C`\n\t\t */\n\t\tcollateralPriceFeedStorageId: ObjectId;\n\t\t/**\n\t\t * Source object ID for the collateral price feed storage.\n\t\t *\n\t\t * Some oracle integrations separate the \"storage object\" from the \"source\"\n\t\t * (e.g., an aggregator or publisher object). This field identifies the\n\t\t * upstream source used to populate `collateralPriceFeedStorageId`.\n\t\t */\n\t\tcollateralPriceFeedStorageSourceId: ObjectId;\n\t\t/**\n\t\t * Maximum tolerated deviation for the collateral oracle price.\n\t\t *\n\t\t * Used as a safety bound when valuing deposits/withdrawals and computing\n\t\t * USD conversions. This is typically a fixed-point or scaled bigint value,\n\t\t * consistent with the on-chain oracle representation.\n\t\t */\n\t\tcollateralPriceFeedStorageTolerance: bigint;\n\t\t/**\n\t\t * Maximum margin ratio tolerance for force-withdraw processing.\n\t\t *\n\t\t * Force-withdraw generally requires closing positions. This tolerance\n\t\t * controls how much worse (or better) the resulting margin ratio is allowed\n\t\t * to be, compared to a target/expected value, before rejecting the action.\n\t\t */\n\t\tmaxForceWithdrawMarginRatioTolerance: number;\n\t\t/**\n\t\t * Scaling factor to apply to `C` to convert a balance to ifixed.\n\t\t */\n\t\t/**\n\t\t * Used to calculate user's minimum deposit value in usd\n\t\t */\n\t\tscalingFactor: number;\n\t\t/**\n\t\t * The maximum number of distinct `ClearingHouse`.\n\t\t */\n\t\tmaxMarketsInVault: bigint;\n\t\t/**\n\t\t * The maximum number of pending orders allowed for a single position in the `Vault`.\n\t\t */\n\t\tmaxPendingOrdersPerPosition: bigint;\n\t\t/**\n\t\t * Maximum total collateral (native units) that can be deposited into the vault.\n\t\t *\n\t\t * This is a capacity/risk control parameter. Deposits that would cause the\n\t\t * vault to exceed this limit should be rejected by the protocol/backend.\n\t\t */\n\t\tmaxTotalDepositedCollateral: Balance;\n\t\t/** Minimum position margin (USD) to trigger full close during force withdraw. */\n\t\tminForceWithdrawValueUsd: number;\n\t};\n\t/** Owner address of the vault. */\n\townerAddress: SuiAddress;\n\t/** Creation timestamp of the vault. */\n\tcreationTimestamp: Timestamp | undefined;\n\t/** Underlying perpetuals account ID that the vault uses. */\n\taccountId: PerpetualsAccountId;\n\t/** Account object ID used by the vault. */\n\taccountObjectId: ObjectId;\n\t/** Collateral coin type accepted by this vault. */\n\tcollateralCoinType: CoinType;\n\t/**\n\t * LP coin type minted by this vault.\n\t *\n\t * This is the `Coin<T>` type used to represent shares in the vault. Users\n\t * receive LP coins on deposit and burn/return them on withdrawal.\n\t */\n\tlpCoinType: CoinType;\n\t/** Decimals for the LP token minted by this vault. */\n\tlpCoinDecimals: CoinDecimal;\n\t/**\n\t * Estimated monthly APR for this vault, expressed as a percentage.\n\t *\n\t * This is typically computed off-chain from historical performance and/or\n\t * accounting state. It is a display metric and should not be treated as a\n\t * guaranteed rate.\n\t */\n\tmonthlyAprPercentage: Percentage;\n\t/** The annualized percentage return from incentives (added yields) */\n\tmonthlyBoostedAprPercentage: Percentage;\n\t/** Indicates the vault is temporarily paused until the timestamp (if present). */\n\tpausedUntilTimestamp: bigint | undefined;\n\t/** Timestamp at which `pause_vault_for_force_withdraw` was last called. */\n\tlastPausedTimestamp: Timestamp;\n}\n\n/**\n * Represents a single pending vault withdrawal request.\n */\nexport interface PerpetualsVaultWithdrawRequest {\n\t/**\n\t * The address of the user that created the withdraw request\n\t */\n\tuserAddress: SuiAddress;\n\t/**\n\t * Object id of the vault associated with the withdraw request\n\t */\n\tvaultId: SuiAddress;\n\t/**\n\t * The amount of the shares requested for withdrawal.\n\t */\n\tlpAmountIn: Balance;\n\t/**\n\t * USD valuation of `lpAmountIn` at request time (or at query time, depending on backend).\n\t *\n\t * This field is provided for UI convenience and may be computed using the\n\t * vault's LP share price.\n\t */\n\tlpAmountInUsd: number;\n\t/**\n\t * Timestamp of request's creation\n\t */\n\trequestTimestamp: Timestamp;\n\t/**\n\t * The minimum amount of the collateral balance expected as output for this withdrawal\n\t *\n\t * This acts as a slippage/price-protection bound for the user.\n\t */\n\tminCollateralAmountOut: Balance;\n\t/**\n\t * USD valuation of `minCollateralAmountOut`, using the vault's collateral oracle.\n\t *\n\t * Provided for display; the on-chain constraint is enforced by\n\t * `minCollateralAmountOut` (native units).\n\t */\n\tminCollateralAmountOutUsd: number;\n}\n\n// =========================================================================\n// Events\n// =========================================================================\n\n// =========================================================================\n// Version\n// =========================================================================\n\n/**\n * Event emitted when a clearing house (market) is upgraded to a new version.\n */\nexport interface UpdatedMarketVersionEvent extends Event {\n\t/** Market identifier for which the version changed. */\n\tmarketId: PerpetualsMarketId;\n\t/** New version value. */\n\tversion: bigint;\n}\n\n/**\n * Type guard for {@link UpdatedMarketVersionEvent}.\n *\n * @param event - Generic event.\n * @returns `true` if this is an `UpdatedMarketVersionEvent`.\n */\nexport const isUpdatedMarketVersion = (\n\tevent: Event\n): event is UpdatedMarketVersionEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::updatedclearinghouseversion\");\n};\n\n// =========================================================================\n// Collateral\n// =========================================================================\n\n/**\n * Cursor-based response wrapping a list of collateral changes for an account.\n */\nexport type ApiPerpetualsAccountCollateralHistoryResponse =\n\tApiPerpetualsHistoricalDataWithCursorResponse & {\n\t\t/** Collateral changes in chronological order. */\n\t\tcollateralChanges: PerpetualsAccountCollateralChange[];\n\t};\n\n/**\n * Single collateral change record for an account.\n *\n * This may represent:\n * - Deposits / withdrawals\n * - Liquidations\n * - Funding settlements\n * - Trading fees\n */\nexport type PerpetualsAccountCollateralChange = {\n\t/** When the change occurred. */\n\ttimestamp: Timestamp;\n\t/** Sui transaction digest that produced this change. */\n\ttxDigest: TransactionDigest;\n\t/** Market ID, if applicable (can be undefined for global changes). */\n\tmarketId: PerpetualsMarketId | undefined;\n\t/** Concrete event type fully qualified (Sui struct type). */\n\teventType: AnyObjectType;\n\t/** Net change in collateral units. */\n\tcollateralChange: number;\n\t/** Net change in USD value. */\n\tcollateralChangeUsd: number;\n\t/** Optional breakdown of fees, with variant shapes based on event. */\n\tfees?:\n\t\t| {\n\t\t\t\tnetFeesUsd: number;\n\t\t\t\tliquidationFeesUsd: number;\n\t\t\t\tforceCancelFeesUsd: number;\n\t\t\t\tinsuranceFundFeesUsd: number;\n\t\t }\n\t\t| {\n\t\t\t\tnetFeesUsd: number;\n\t\t\t\tliqorFeesUsd: number;\n\t\t }\n\t\t| {\n\t\t\t\tnetFeesUsd: number;\n\t\t };\n};\n\n/**\n * Cursor-based response wrapping a list of orders for an account.\n */\nexport type ApiPerpetualsAccountOrderHistoryResponse =\n\tApiPerpetualsHistoricalDataWithCursorResponse & {\n\t\t/** Orders in chronological order. */\n\t\torders: PerpetualsAccountOrderHistoryData[];\n\t};\n\n/**\n * Historical margin data point for an account, used in margin history views.\n */\nexport interface PerpetualsAccountMarginHistoryData {\n\t/** Timestamp of this snapshot. */\n\ttimestamp: Timestamp;\n\t/** Available collateral in USD. */\n\tavailableCollateralUsd: number;\n\t/** Total equity in USD. */\n\ttotalEquityUsd: number;\n\t/** Unrealized funding PnL in USD at that time. */\n\tunrealizedFundingsUsd: number;\n\t/** Unrealized position PnL in USD at that time. */\n\tunrealizedPnlUsd: number;\n}\n\n/**\n * Individual order affecting an account.\n */\nexport type PerpetualsAccountOrderHistoryData = {\n\t/** Timestamp of the order. */\n\ttimestamp: Timestamp;\n\t/** Sui transaction digest. */\n\ttxDigest: TransactionDigest;\n\t/** Market in which this order occurred. */\n\tmarketId: PerpetualsMarketId;\n\t/** Concrete event type. */\n\teventType: AnyObjectType;\n\t/** Side of the order relative to the account (Bid/Ask). */\n\tside: PerpetualsOrderSide;\n\t/** Price for this order. */\n\tprice: number;\n\t/** Size in base units. */\n\tsize: number;\n\t/** Optional stop-loss / take-profit data. */\n\tslTp?: {\n\t\t/** Optional stop-loss trigger price based on the index price. */\n\t\tstopLossIndexPrice?: number;\n\t\t/** Optional take-profit trigger price based on the index price. */\n\t\ttakeProfitIndexPrice?: number;\n\t\t/** Unique order identifier for limit order sl/tp is tied to. */\n\t\tlimitOrderId?: PerpetualsOrderId;\n\t};\n\t/** Stop order data that is not a stop-loss / take-profit order\n\t * (e.g. generic trigger orders).\n\t */\n\tstopOrder?: {\n\t\t/** Index price at which the stop order should trigger. */\n\t\tstopIndexPrice: number;\n\t};\n};\n\n/**\n * Event emitted when collateral is deposited into an account.\n */\nexport interface DepositedCollateralEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tcollateralDelta: Balance;\n}\n\n/**\n * Event emitted when collateral is allocated from general account collateral\n * into a specific market position.\n */\nexport interface AllocatedCollateralEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\taccountId: PerpetualsAccountId;\n\tcollateralDelta: Balance;\n}\n\n/**\n * Event emitted when collateral is deallocated from a market back to\n * the account's general collateral.\n */\nexport interface DeallocatedCollateralEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\taccountId: PerpetualsAccountId;\n\tcollateralDelta: Balance;\n}\n\n/**\n * Event emitted when collateral is withdrawn from the account.\n */\nexport interface WithdrewCollateralEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tcollateralDelta: Balance;\n}\n\n/**\n * Event emitted when funding is settled for an account and market.\n */\nexport interface SettledFundingEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tcollateralDeltaUsd: number;\n\tmarketId: PerpetualsMarketId;\n\tmarketFundingRateLong: number;\n\tmarketFundingRateShort: number;\n}\n\n/**\n * Union of all event types that impact account collateral.\n */\nexport type CollateralEvent =\n\t| WithdrewCollateralEvent\n\t| DepositedCollateralEvent\n\t| SettledFundingEvent\n\t| LiquidatedEvent\n\t| FilledTakerOrderEvent\n\t| FilledMakerOrdersEvent\n\t| AllocatedCollateralEvent\n\t| DeallocatedCollateralEvent;\n// | AddedStopOrderTicketCollateralEvent\n// | RemovedStopOrderTicketCollateralEvent;\n\n// TODO: make all these checks use string value from perps api\n\n/**\n * Type guard for {@link WithdrewCollateralEvent}.\n */\nexport const isWithdrewCollateralEvent = (\n\tevent: Event\n): event is WithdrewCollateralEvent => {\n\treturn event.type.toLowerCase().includes(\"::withdrewcollateral\");\n};\n\n/**\n * Type guard for {@link DepositedCollateralEvent}.\n */\nexport const isDepositedCollateralEvent = (\n\tevent: Event\n): event is DepositedCollateralEvent => {\n\treturn event.type.toLowerCase().includes(\"::depositedcollateral\");\n};\n\n/**\n * Type guard for {@link DeallocatedCollateralEvent}.\n */\nexport const isDeallocatedCollateralEvent = (\n\tevent: Event\n): event is DeallocatedCollateralEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::deallocatedcollateral\");\n};\n\n/**\n * Type guard for {@link AllocatedCollateralEvent}.\n */\nexport const isAllocatedCollateralEvent = (\n\tevent: Event\n): event is AllocatedCollateralEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::allocatedcollateral\");\n};\n\n/**\n * Type guard for {@link SettledFundingEvent}.\n */\nexport const isSettledFundingEvent = (\n\tevent: Event\n): event is SettledFundingEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::settledfunding\");\n};\n\n// =========================================================================\n// Liquidation\n// =========================================================================\n\n/**\n * Event emitted when an account is liquidated in a given market.\n */\nexport interface LiquidatedEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tcollateralDeltaUsd: number;\n\t/** Liquidator's account ID. */\n\tliqorAccountId: PerpetualsAccountId;\n\tmarketId: PerpetualsMarketId;\n\tside: PerpetualsOrderSide;\n\t/** Amount of base asset liquidated. */\n\tbaseLiquidated: number;\n\t/** Amount of quote asset liquidated. */\n\tquoteLiquidated: number;\n\t/** Liquidated account's PnL in USD for this event. */\n\tliqeePnlUsd: number;\n\t/** Liquidation fee paid in USD. */\n\tliquidationFeesUsd: number;\n\t/** Force-cancel fees collected in USD. */\n\tforceCancelFeesUsd: number;\n\t/** Fees directed to the insurance fund in USD. */\n\tinsuranceFundFeesUsd: number;\n}\n\n/**\n * Type guard for {@link LiquidatedEvent}.\n */\nexport const isLiquidatedEvent = (event: Event): event is LiquidatedEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::liquidatedposition\");\n};\n\n// =========================================================================\n// Account\n// =========================================================================\n\n/**\n * Event emitted when a new perpetuals account is created for a user.\n */\nexport interface CreatedAccountEvent extends Event {\n\tuser: SuiAddress;\n\taccountId: PerpetualsAccountId;\n}\n\n// export interface CreatedSubAccountEvent extends Event {\n// \taccountId: PerpetualsAccountId;\n// \tsubAccountId: ObjectId;\n// }\n\n// export interface SetSubAccountUsersEvent extends Event {\n// \taccountId: PerpetualsAccountId;\n// \tsubAccountId: ObjectId;\n// }\n\n/**\n * Event emitted when an account's initial margin ratio for a position\n * is explicitly set or adjusted.\n */\nexport interface SetPositionInitialMarginRatioEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\taccountId: PerpetualsAccountId;\n\t// NOTE: should this be made into string ?\n\tinitialMarginRatio: number;\n}\n\n// =========================================================================\n// Order\n// =========================================================================\n\n/**\n * Trade data used for market-level trade history.\n */\nexport interface PerpetualsMarketOrderHistoryData {\n\t/** Timestamp of the trade. */\n\ttimestamp: Timestamp;\n\t/** Transaction digest. */\n\ttxDigest: TransactionDigest;\n\t/** Side of the trade. */\n\tside: PerpetualsOrderSide;\n\t/** Filled size in base units. */\n\tsizeFilled: number;\n\t/** Order price (limit price) used for the trade. */\n\torderPrice: number;\n}\n\n/**\n * Cursor-based wrapper for market-level order history.\n */\nexport type ApiPerpetualsMarketOrderHistoryResponse =\n\tApiPerpetualsHistoricalDataWithCursorResponse & {\n\t\t/** Orders in this page. */\n\t\torders: PerpetualsMarketOrderHistoryData[];\n\t};\n\n/**\n * Event emitted when an order is filled or dropped by the orderbook\n * (book-keeping receipt).\n */\nexport interface OrderbookFillReceiptEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\torderId: PerpetualsOrderId;\n\tsize: bigint;\n\t/** Whether the order was dropped instead of filled. */\n\tdropped: boolean;\n}\n\n/**\n * Event emitted when an order is canceled.\n */\nexport interface CanceledOrderEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tmarketId: PerpetualsMarketId;\n\tside: PerpetualsOrderSide;\n\tsize: bigint;\n\torderId: PerpetualsOrderId;\n}\n\n/**\n * Event emitted when a new order is posted to the orderbook.\n */\nexport interface PostedOrderEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tmarketId: PerpetualsMarketId;\n\torderId: PerpetualsOrderId;\n\tsize: bigint;\n\t// TODO: change to `isReduceOnly` ?\n\treduceOnly: boolean;\n\texpiryTimestamp?: bigint;\n}\n\n/**\n * Event emitted when one or more maker orders are filled against a taker.\n */\nexport interface FilledMakerOrdersEvent extends Event {\n\t/** List of per-maker fills for this aggregate event. */\n\tevents: FilledMakerOrderEventFields[];\n}\n\n/**\n * Details for a single maker order fill inside a {@link FilledMakerOrdersEvent}.\n */\nexport interface FilledMakerOrderEventFields {\n\taccountId: PerpetualsAccountId;\n\ttakerAccountId: PerpetualsAccountId;\n\tcollateralDeltaUsd: number;\n\tmarketId: PerpetualsMarketId;\n\tside: PerpetualsOrderSide;\n\tsize: bigint;\n\tsizeRemaining: bigint;\n\torderId: PerpetualsOrderId;\n\tdropped: boolean;\n\tpnlUsd: number;\n\tfeesUsd: number;\n\tcanceledSize: bigint;\n}\n\n/**\n * Event emitted when a taker order is executed.\n */\nexport interface FilledTakerOrderEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tcollateralDeltaUsd: number;\n\tmarketId: PerpetualsMarketId;\n\tside: PerpetualsOrderSide;\n\tbaseAssetDelta: number;\n\tquoteAssetDelta: number;\n\ttakerPnlUsd: number;\n\ttakerFeesUsd: number;\n}\n\n/**\n * Union of all order-related events in the protocol.\n */\nexport type PerpetualsOrderEvent =\n\t| CanceledOrderEvent\n\t| PostedOrderEvent\n\t| PostedOrderEvent\n\t| FilledMakerOrdersEvent\n\t| FilledTakerOrderEvent\n\t| LiquidatedEvent\n\t| ReducedOrderEvent;\n\n/**\n * Event emitted when an order is posted.\n *\n * NOTE: This is a second definition of `PostedOrderEvent` used in a\n * simplified context (without `reduceOnly` / `expiryTimestamp`).\n */\nexport interface PostedOrderEvent extends Event {\n\taccountId: PerpetualsAccountId;\n\tmarketId: PerpetualsMarketId;\n\torderId: PerpetualsOrderId;\n\tsize: bigint;\n\tside: PerpetualsOrderSide;\n}\n\n/**\n * Event emitted when an existing order is reduced (partial cancellation or\n * adjustment of size).\n */\nexport interface ReducedOrderEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\taccountId: PerpetualsAccountId;\n\tsizeChange: bigint;\n\torderId: PerpetualsOrderId;\n}\n\n// TODO: make all these checks use string value from perps api\n\n/**\n * Type guard for {@link CanceledOrderEvent}.\n */\nexport const isCanceledOrderEvent = (\n\tevent: Event\n): event is CanceledOrderEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::canceledorder\");\n};\n\n/**\n * Type guard for {@link PostedOrderEvent}.\n */\nexport const isPostedOrderEvent = (event: Event): event is PostedOrderEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::postedorder\");\n};\n\n/**\n * Type guard for {@link FilledMakerOrdersEvent}.\n */\nexport const isFilledMakerOrdersEvent = (\n\tevent: Event\n): event is FilledMakerOrdersEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::filledmakerorders\");\n};\n\n/**\n * Type guard for {@link FilledTakerOrderEvent}.\n */\nexport const isFilledTakerOrderEvent = (\n\tevent: Event\n): event is FilledTakerOrderEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::filledtakerorder\");\n};\n\n/**\n * Type guard for {@link ReducedOrderEvent}.\n */\nexport const isReducedOrderEvent = (\n\tevent: Event\n): event is ReducedOrderEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::reducedorder\");\n};\n\n// =========================================================================\n// Stop Orders\n// =========================================================================\n\n/**\n * Event emitted when a stop order ticket is created.\n *\n * Stop order tickets represent off-chain-executable stop orders that\n * executors can trigger.\n */\nexport interface CreatedStopOrderTicketEvent extends Event {\n\tticketId: ObjectId;\n\taccountId: PerpetualsAccountId;\n\tsubAccountId?: ObjectId;\n\texecutors: SuiAddress[];\n\tgas: Balance;\n\tstopOrderType: PerpetualsStopOrderType;\n\t/** Encrypted stop-order details (payload). */\n\tencryptedDetails: Byte[];\n}\n\n/**\n * Event emitted when a stop order ticket is executed.\n */\nexport interface ExecutedStopOrderTicketEvent extends Event {\n\tticketId: ObjectId;\n\taccountId: PerpetualsAccountId;\n\texecutor: SuiAddress;\n}\n\n/**\n * Event emitted when a stop order ticket is deleted or canceled.\n */\nexport interface DeletedStopOrderTicketEvent extends Event {\n\tticketId: ObjectId;\n\taccountId: PerpetualsAccountId;\n\tsubAccountId?: ObjectId;\n\texecutor: SuiAddress;\n}\n\n/**\n * Event emitted when the details (payload) of a stop order ticket are edited.\n */\nexport interface EditedStopOrderTicketDetailsEvent extends Event {\n\tticketId: ObjectId;\n\taccountId: PerpetualsAccountId;\n\tsubAccountId?: ObjectId;\n\tencryptedDetails: Byte[];\n\tstopOrderType: PerpetualsStopOrderType;\n}\n\n/**\n * Event emitted when the set of executors for a stop order ticket is edited.\n */\nexport interface EditedStopOrderTicketExecutorEvent extends Event {\n\tticketId: ObjectId;\n\taccountId: PerpetualsAccountId;\n\tsubAccountId?: ObjectId;\n\texecutors: SuiAddress[];\n}\n\n// export interface AddedStopOrderTicketCollateralEvent extends Event {\n// \tticketId: ObjectId;\n// \taccountId: PerpetualsAccountId;\n// \tsubAccountId?: ObjectId;\n// \tcollateralToAllocate: Balance;\n// }\n\n// export interface RemovedStopOrderTicketCollateralEvent extends Event {\n// \tticketId: ObjectId;\n// \taccountId: PerpetualsAccountId;\n// \tsubAccountId?: ObjectId;\n// \tcollateralToRemove: Balance;\n// }\n\n/**\n * Event emitted when deallocated collateral is transferred from a clearing\n * house to an account or subaccount.\n */\nexport interface TransferredDeallocatedCollateralEvent extends Event {\n\tchId: ObjectId;\n\t/** Account or SubAccount object id. */\n\tobjectId: ObjectId; // Account or SubAccount object id\n\taccountId: PerpetualsAccountId;\n\tcollateral: Balance;\n}\n\n/**\n * Event emitted when an account or subaccount receives collateral.\n */\nexport interface ReceivedCollateralEvent extends Event {\n\t/** Account or SubAccount object id. */\n\tobjectId: ObjectId; // Account or SubAccount object id\n\taccountId: PerpetualsAccountId;\n\tcollateral: Balance;\n}\n\n// =========================================================================\n// Twap\n// =========================================================================\n\n/**\n * Event emitted when premium TWAP is updated for a market.\n */\nexport interface UpdatedPremiumTwapEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\tbookPrice: number;\n\tindexPrice: number;\n\tpremiumTwap: number;\n\tpremiumTwapLastUpdateMs: number;\n}\n\n/**\n * Event emitted when spread TWAP is updated for a market.\n */\nexport interface UpdatedSpreadTwapEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\tbookPrice: number;\n\tindexPrice: number;\n\tspreadTwap: number;\n\tspreadTwapLastUpdateMs: number;\n}\n\n/**\n * Union of all TWAP-related events.\n */\nexport type PerpetualsTwapEvent =\n\t| UpdatedPremiumTwapEvent\n\t| UpdatedSpreadTwapEvent;\n\n/**\n * Type guard for {@link UpdatedPremiumTwapEvent}.\n */\nexport const isUpdatedPremiumTwapEvent = (\n\tevent: Event\n): event is UpdatedPremiumTwapEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::updatedpremiumtwap\");\n};\n\n/**\n * Type guard for {@link UpdatedSpreadTwapEvent}.\n */\nexport const isUpdatedSpreadTwapEvent = (\n\tevent: Event\n): event is UpdatedSpreadTwapEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::updatedspreadtwap\");\n};\n\n// =========================================================================\n// Funding\n// =========================================================================\n\n/**\n * Event emitted when market funding values are updated.\n */\nexport interface UpdatedFundingEvent extends Event {\n\tmarketId: PerpetualsMarketId;\n\tcumFundingRateLong: number;\n\tcumFundingRateShort: number;\n\tfundingLastUpdateMs: Timestamp;\n}\n\n/**\n * Type guard for {@link UpdatedFundingEvent}.\n */\nexport const isUpdatedFundingEvent = (\n\tevent: Event\n): event is UpdatedFundingEvent => {\n\treturn event.type.toLowerCase().endsWith(\"::updatedfunding\");\n};\n\n// =========================================================================\n// API\n// =========================================================================\n\n// =========================================================================\n// Objects\n// =========================================================================\n\n/**\n * Request body for fetching all account caps owned by a given wallet.\n */\nexport interface ApiPerpetualsOwnedAccountCapsBody {\n\twalletAddress: SuiAddress;\n\tcollateralCoinTypes?: CoinType[];\n}\n\n/**\n * Request body for fetching specific admin account caps by their account IDs.\n */\nexport interface ApiPerpetualsAdminAccountCapsBody {\n\taccountIds: PerpetualsAccountId[];\n}\n\n/**\n * Response payload for fetching positions for one or more accounts.\n *\n * The backend returns a list of {@link PerpetualsAccountObject} snapshots.\n * Each snapshot includes per-market {@link PerpetualsPosition} data.\n */\nexport interface ApiPerpetualsAccountPositionsResponse {\n\taccounts: PerpetualsAccountObject[];\n}\n\n/**\n * Request body for fetching positions for a set of accounts.\n *\n * `marketIds` can be supplied as an optimization hint to limit the markets\n * included in each account's returned `positions` array.\n */\nexport interface ApiPerpetualsAccountPositionsBody {\n\taccountIds: PerpetualsAccountId[];\n\t// TODO: remove eventually ?\n\tmarketIds?: PerpetualsMarketId[];\n}\n\n/**\n * Response payload for fetching admin account caps by explicit account IDs.\n */\nexport interface ApiPerpetualsAdminAccountCapsResponse {\n\taccountCaps: PerpetualsAccountCap[];\n}\n\n/**\n * Response payload for fetching all account caps owned by a wallet.\n *\n * This is typically used during onboarding / wallet connect to discover\n * existing accounts.\n */\nexport interface ApiPerpetualsOwnedAccountCapsResponse {\n\taccountCaps: PerpetualsAccountCap[];\n}\n\n// =========================================================================\n// Interactions\n// =========================================================================\n\n/**\n * Generic shape for Perpetuals API historical data requests that include\n * `beforeTimestampCursor` and `limit` pagination parameters.\n */\nexport interface ApiPerpetualsHistoricalDataWithCursorBody {\n\t/**\n\t * Cursor for pagination.\n\t */\n\tbeforeTimestampCursor?: Timestamp;\n\t/**\n\t * Limit for pagination.\n\t */\n\tlimit?: number;\n}\n\n/**\n * Generic shape for Perpetuals API historical data responses that include\n * `nextBeforeTimestampCursor` pagination parameter.\n */\nexport interface ApiPerpetualsHistoricalDataWithCursorResponse {\n\t/**\n\t * The next cursor position. If undefined, no more data is available.\n\t */\n\tnextBeforeTimestampCursor: Timestamp | undefined;\n}\n\n/**\n * Enumerates the timeframes available for retrieving historical account margin data,\n * such as `\"1D\"`, `\"1W\"`, `\"1M\"`, etc.\n */\nexport type PerpetualsAccountMarginHistoryTimeframeKey =\n\t| \"1D\"\n\t| \"1W\"\n\t| \"1M\"\n\t| \"ALL\";\n\n/**\n * Request payload for fetching historical margin metrics for an account.\n */\nexport interface ApiPerpetualsAccountMarginHistoryBody {\n\t/**\n\t * Account ID.\n\t */\n\taccountId: PerpetualsAccountId;\n\n\t/**\n\t * Timeframe from which to obtain historical data from.\n\t */\n\ttimeframe: PerpetualsAccountMarginHistoryTimeframeKey;\n}\n\n/**\n * Response payload for historical margin metrics.\n *\n * The returned array is ordered chronologically by `timestamp` (oldest -> newest)\n * unless the backend specifies otherwise.\n */\nexport interface ApiPerpetualsAccountMarginHistoryResponse {\n\tmarginHistoryDatas: PerpetualsAccountMarginHistoryData[];\n}\n\n/**\n * Request body for fetching account-level order history with a cursor.\n */\nexport type ApiPerpetualsMarketOrderHistoryBody =\n\tApiPerpetualsHistoricalDataWithCursorBody & {\n\t\tmarketId: PerpetualsMarketId;\n\t};\n\n/**\n * Request body for fetching account-level order history with a cursor.\n */\nexport type ApiPerpetualsAccountOrderHistoryBody =\n\tApiPerpetualsHistoricalDataWithCursorBody & {\n\t\taccountId: PerpetualsAccountId;\n\t\tauthentication?: {\n\t\t\twalletAddress: SuiAddress;\n\t\t\tbytes: string;\n\t\t\tsignature: string;\n\t\t};\n\t};\n\n/**\n * Request body for fetching account collateral history with a cursor.\n */\nexport type ApiPerpetualsAccountCollateralHistoryBody =\n\tApiPerpetualsHistoricalDataWithCursorBody & {\n\t\taccountId: PerpetualsAccountId;\n\t\tauthentication?: {\n\t\t\twalletAddress: SuiAddress;\n\t\t\tbytes: string;\n\t\t\tsignature: string;\n\t\t};\n\t};\n\n// export type ApiPerpetualsPreviewOrderBody = (\n// \t| Omit<\n// \t\t\tApiPerpetualsLimitOrderBody,\n// \t\t\t| \"collateralChange\"\n// \t\t\t| \"walletAddress\"\n// \t\t\t| \"hasPosition\"\n// \t\t\t| \"txKind\"\n// \t\t\t| \"accountId\"\n// \t\t\t| \"slTp\"\n// \t >\n// \t| Omit<\n// \t\t\tApiPerpetualsMarketOrderBody,\n// \t\t\t| \"collateralChange\"\n// \t\t\t| \"walletAddress\"\n// \t\t\t| \"hasPosition\"\n// \t\t\t| \"txKind\"\n// \t\t\t| \"accountId\"\n// \t\t\t| \"slTp\"\n// \t >\n// ) & {\n// \t// TODO: remove eventually ?\n// \taccountObjectId: ObjectId | undefined;\n// \tcollateralCoinType: CoinType;\n// \tlotSize: number;\n// \ttickSize: number;\n// \tleverage?: number;\n// \t// NOTE: do we need this ?\n// \t// isClose?: boolean;\n// };\n\n/**\n * Request body for previewing a market order placement (before sending a tx).\n *\n * This version is used by the API and includes account or vault context.\n */\nexport type ApiPerpetualsPreviewPlaceMarketOrderBody = Omit<\n\tApiPerpetualsMarketOrderBody,\n\t| \"collateralChange\"\n\t| \"walletAddress\"\n\t| \"hasPosition\"\n\t| \"cancelSlTp\"\n\t| \"txKind\"\n\t| \"accountId\"\n\t| \"slTp\"\n\t| \"slippage\"\n> & {\n\t// collateralCoinType: CoinType;\n\t/** Optional leverage override for the preview. */\n\tleverage?: number;\n\t// NOTE: do we need this ?\n\t// isClose?: boolean;\n} & (\n\t\t| {\n\t\t\t\t// TODO: remove eventually ?\n\t\t\t\taccountId: PerpetualsAccountId | undefined;\n\t\t }\n\t\t| {\n\t\t\t\t// TODO: remove eventually ?\n\t\t\t\tvaultId: ObjectId | undefined;\n\t\t }\n\t);\n\n/**\n * Request body for previewing a limit order placement (before sending a tx).\n *\n * This version is used by the API and includes account or vault context.\n */\nexport type ApiPerpetualsPreviewPlaceLimitOrderBody = Omit<\n\tApiPerpetualsLimitOrderBody,\n\t| \"collateralChange\"\n\t| \"walletAddress\"\n\t| \"hasPosition\"\n\t| \"cancelSlTp\"\n\t| \"txKind\"\n\t| \"accountId\"\n\t| \"slTp\"\n> & {\n\t// collateralCoinType: CoinType;\n\t/** Optional leverage override for the preview. */\n\tleverage?: number;\n\t// NOTE: do we need this ?\n\t// isClose?: boolean;\n} & (\n\t\t| {\n\t\t\t\t// TODO: remove eventually ?\n\t\t\t\taccountId: PerpetualsAccountId | undefined;\n\t\t }\n\t\t| {\n\t\t\t\t// TODO: remove eventually ?\n\t\t\t\tvaultId: ObjectId | undefined;\n\t\t }\n\t);\n\n/**\n * Request body for previewing cancel-order operations.\n */\nexport type ApiPerpetualsPreviewCancelOrdersBody = {\n\t// TODO: remove eventually ?\n\t// collateralCoinType: CoinType;\n\t/** Per-market mapping of order IDs to cancel. */\n\tmarketIdsToData: Record<\n\t\tPerpetualsMarketId,\n\t\t{\n\t\t\torderIds: PerpetualsOrderId[];\n\t\t}\n\t>;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n// export type ApiPerpetualsPreviewReduceOrderBody = {\n// \tmarketId: PerpetualsMarketId;\n// \tleverage?: number;\n// \torderId: PerpetualsOrderId;\n// \tsizeToSubtract: bigint;\n// \t// TODO: remove eventually ?\n// \t// collateralCoinType: CoinType;\n// } & (\n// \t| {\n// \t\t\taccountId: PerpetualsAccountId;\n// \t }\n// \t| {\n// \t\t\tvaultId: ObjectId;\n// \t }\n// );\n\n/**\n * Request body for previewing a leverage change for a given position.\n */\nexport type ApiPerpetualsPreviewSetLeverageBody = {\n\tmarketId: PerpetualsMarketId;\n\tleverage: number;\n\t// collateralCoinType: CoinType;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * Request body for previewing a collateral allocation/deallocation for a given position.\n */\nexport type ApiPerpetualsPreviewEditCollateralBody = {\n\tmarketId: PerpetualsMarketId;\n\tcollateralChange: Balance;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n// export type ApiPerpetualsPreviewReduceOrderResponse =\n// \t| {\n// \t\t\terror: string;\n// \t }\n// \t| {\n// \t\t\tpositionAfterReduceOrder: PerpetualsPosition;\n// \t\t\tcollateralChange: number;\n// \t };\n\n/**\n * Response type for a leverage preview request.\n *\n * Either returns an error, or the position and collateral after the change.\n */\nexport type ApiPerpetualsPreviewSetLeverageResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\tcollateralChange: number;\n\t };\n\n/**\n * Response type for a allocate/deallocate collateral preview request.\n *\n * Either returns an error, or the position and collateral after the change.\n */\nexport type ApiPerpetualsPreviewEditCollateralResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\tcollateralChange: number;\n\t };\n\n/**\n * Generic response type for a place-order preview (market or limit).\n */\nexport type ApiPerpetualsPreviewPlaceOrderResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\t/** Simulated position after the market order. */\n\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\t/** Absolute price slippage between reference price and execution price. */\n\t\t\tpriceSlippage: number;\n\t\t\t/** Relative price slippage expressed as a fraction\n\t\t\t * (e.g. `0.01` == 1% slippage). */\n\t\t\tpercentSlippage: number;\n\t\t\t/** Size that is expected to be filled immediately (in base units). */\n\t\t\tfilledSize: number;\n\t\t\t/** Notional value in USD of the `filledSize`. */\n\t\t\tfilledSizeUsd: number;\n\t\t\t/** Any size that remains posted as liquidity (for market orders this is\n\t\t\t * usually zero unless partially resting is supported). */\n\t\t\tpostedSize: number;\n\t\t\t/** Notional value in USD of the `postedSize`. For pure market orders this\n\t\t\t * is typically `0`. */\n\t\t\tpostedSizeUsd: number;\n\t\t\t/** Net collateral change in USD (e.g. fees, margin changes). */\n\t\t\tcollateralChange: number;\n\t\t\t/** Effective execution price for the filled portion of the order. */\n\t\t\texecutionPrice: number;\n\t\t\t/** Whether there is an existing position in this market. */\n\t\t\thasPosition: boolean;\n\t\t\t/** True is position is closed. */\n\t\t\tcancelSlTp: boolean;\n\t };\n\n/**\n * Response type for cancel-order preview.\n */\nexport type ApiPerpetualsPreviewCancelOrdersResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tmarketIdsToData: Record<\n\t\t\t\tPerpetualsMarketId,\n\t\t\t\t{\n\t\t\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\t\t\tcollateralChange: number;\n\t\t\t\t}\n\t\t\t>;\n\t };\n\n// export interface ApiPerpetualsOrderbookStateBody {\n// \torderbookPrice: number;\n// \tlotSize: number;\n// \ttickSize: number;\n// \tpriceBucketSize: number;\n// }\n\n/**\n * Request body for computing an execution price for a hypothetical trade\n * using the current orderbook state and oracle prices.\n */\nexport interface ApiPerpetualsExecutionPriceBody {\n\tside: PerpetualsOrderSide;\n\tsize: bigint;\n\t/** Lot size used to discretize the order size. */\n\tlotSize: number;\n\t/** Available collateral. */\n\tcollateral: Balance;\n\t/** Oracle ID for the base price. */\n\tbasePriceFeedId: ObjectId;\n\t/** Oracle ID for the collateral price. */\n\tcollateralPriceFeedId: ObjectId;\n\t/** Optional user-specified price constraint. */\n\tprice?: number;\n}\n\n/**\n * Response body for execution price previews.\n */\nexport interface ApiPerpetualsExecutionPriceResponse {\n\texecutionPrice: number;\n\tsizeFilled: number;\n\tsizePosted: number;\n\tfills: PerpetualsFilledOrderData[];\n}\n/**\n * Request payload for fetching historical candle (OHLCV) data for a given\n * perpetuals market.\n */\nexport interface ApiPerpetualsMarketCandleHistoryBody {\n\t/**\n\t * Identifier of the perpetuals market whose candles you want to fetch.\n\t *\n\t * Must be a valid on-chain market ID.\n\t */\n\tmarketId: PerpetualsMarketId;\n\n\t/**\n\t * Start of the time range to query, as a Unix timestamp in **milliseconds**.\n\t */\n\tfromTimestamp: Timestamp;\n\n\t/**\n\t * End of the time range to query, as a Unix timestamp in **milliseconds**.\n\t */\n\ttoTimestamp: Timestamp;\n\n\t/**\n\t * Candle interval / resolution in **milliseconds** (e.g. 60_000 for 1m,\n\t * 300_000 for 5m).\n\t */\n\tintervalMs: number;\n}\n\n/**\n * Response type for historical market candle data.\n */\nexport interface ApiPerpetualsMarketCandleHistoryResponse {\n\tcandles: PerpetualsMarketCandleDataPoint[];\n}\n\n/**\n * Request body for computing the maximum order size for an account in a\n * given market.\n */\nexport interface ApiPerpetualsMaxOrderSizeBody {\n\tmarketId: PerpetualsMarketId;\n\taccountId: PerpetualsAccountId;\n\tside: PerpetualsOrderSide;\n\tleverage?: number;\n\tprice?: number;\n\t/**\n\t * Optional integrator fee configuration for an order.\n\t *\n\t * If provided, the integrator specified in the configuration will receive a fee\n\t * on the taker volume generated by this order. The integrator must have been\n\t * previously approved by the account owner, and the fee must not exceed the\n\t * maximum fee the user approved for that integrator.\n\t */\n\tbuilderCode?: PerpetualsBuilderCodeParamaters;\n}\n\n/**\n * Request body for fetching stop-order data associated with an account or vault,\n * validated using a wallet signature.\n */\nexport type ApiPerpetualsStopOrderDatasBody = {\n\twalletAddress: SuiAddress;\n\tbytes: string;\n\tsignature: string;\n\tmarketIds?: PerpetualsMarketId[];\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * Response payload for stop-order queries.\n *\n * Stop orders are returned in their normalized on-chain shape\n * ({@link PerpetualsStopOrderData}). Clients should interpret `slTp` vs `nonSlTp`\n * to determine the stop semantics.\n */\nexport interface ApiPerpetualsStopOrderDatasResponse {\n\tstopOrderDatas: PerpetualsStopOrderData[];\n}\n\n// =========================================================================\n// Transactions\n// =========================================================================\n\n/**\n * Request body for creating a vault capability (vault cap) for a given wallet.\n */\nexport interface ApiPerpetualsCreateVaultCapBody {\n\twalletAddress: SuiAddress;\n\tlpCoinMetadata: {\n\t\t/** Name for the token */\n\t\tname: string;\n\t\t/** Symbol for the token */\n\t\tsymbol: string;\n\t\t/** Description of the token */\n\t\tdescription: string;\n\t\t/** URL for the token logo */\n\t\ticonUrl?: string;\n\t};\n}\n\n/**\n * Request body for creating a new vault with initial deposit.\n *\n * The deposit can be specified either:\n * - As a numeric `initialDepositAmount`, or\n * - As an existing `depositCoinArg` (coin object).\n */\nexport type ApiPerpetualsCreateVaultBody = {\n\twalletAddress: SuiAddress;\n\tmetadata: {\n\t\t/**\n\t\t * A human-readable name for the `Vault`.\n\t\t */\n\t\tname: string;\n\t\t/**\n\t\t * A verbose description of the `Vault`.\n\t\t */\n\t\tdescription: string;\n\t\t/**\n\t\t * The `Vault` curator's name.\n\t\t */\n\t\tcuratorName?: string;\n\t\t/**\n\t\t * A url for the `Vault`'s curator. Ideally their website.\n\t\t */\n\t\tcuratorUrl?: string;\n\t\t/**\n\t\t * An image url for the `Vault`'s curator. Ideally their logo.\n\t\t */\n\t\tcuratorLogoUrl?: string;\n\t\t/**\n\t\t * Extra / optional fields for future extensibility. Recommended keys include: twitter_url.\n\t\t */\n\t\textraFields?: Record<string, string>;\n\t};\n\tcoinMetadataId: ObjectId;\n\ttreasuryCapId: ObjectId;\n\tcollateralCoinType: CoinType;\n\tlockPeriodMs: bigint;\n\tperformanceFeePercentage: Percentage;\n\tforceWithdrawDelayMs: bigint;\n\ttxKind?: SerializedTransaction;\n\tisSponsoredTx?: boolean;\n} & (\n\t| {\n\t\t\tinitialDepositAmount: Balance;\n\t }\n\t| {\n\t\t\tinitialDepositCoinArg: TransactionObjectArgument;\n\t }\n);\n\n/**\n * Request payload for creating an integrator configuration approval transaction.\n *\n * This transaction allows a user to approve an integrator to receive fees on orders\n * placed on their behalf. The user sets a maximum taker fee that the integrator\n * can charge per order.\n */\nexport interface ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody {\n\t/**\n\t * Account ID encoded as a bigint.\n\t *\n\t * This is the perpetuals account that is granting permission to the integrator.\n\t */\n\taccountId: PerpetualsAccountId;\n\n\t/**\n\t * Sui address of the integrator being approved.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tintegratorAddress: SuiAddress;\n\n\t/**\n\t * Maximum taker fee (as a decimal) that the integrator can charge per order.\n\t *\n\t * For example, 0.001 represents a 0.1% maximum fee. The integrator can set\n\t * any fee up to this maximum when placing orders on behalf of the user.\n\t */\n\tmaxTakerFee: Percentage;\n\n\t/**\n\t * Optional existing transaction kind (base64-encoded) to extend.\n\t *\n\t * If provided, the new integrator approval will be added to this transaction.\n\t */\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request payload for creating a transaction to revoke an integrator's permissions.\n *\n * This transaction removes an integrator's approval to collect fees on orders\n * placed on behalf of the user. After revocation, the integrator will no longer\n * be able to submit orders with fees for this account.\n */\nexport interface ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody {\n\t/**\n\t * Account ID encoded as a bigint.\n\t *\n\t * This is the perpetuals account that is revoking the integrator's permission.\n\t */\n\taccountId: PerpetualsAccountId;\n\n\t/**\n\t * Sui address of the integrator whose permissions are being revoked.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tintegratorAddress: SuiAddress;\n\n\t/**\n\t * Optional existing transaction kind (base64-encoded) to extend.\n\t *\n\t * If provided, the integrator removal will be added to this transaction.\n\t */\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request payload for creating a transaction to initialize an integrator fee vault.\n *\n * Before an integrator can claim fees from a specific market, they must first create\n * a vault for that market. This is a one-time setup per integrator per market.\n */\nexport interface ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody {\n\t/**\n\t * Market (clearing house) ID where the integrator vault will be created.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tmarketId: PerpetualsMarketId;\n\n\t/**\n\t * Sui address of the integrator creating the vault.\n\t *\n\t * Must be a valid Sui object ID.\n\t * This integrator will be able to claim fees from this vault.\n\t */\n\tintegratorAddress: SuiAddress;\n\n\t/**\n\t * Optional existing transaction kind (base64-encoded) to extend.\n\t *\n\t * If provided, the vault creation will be added to this transaction.\n\t */\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request payload for creating a transaction to claim accumulated integrator fees from a vault.\n *\n * Integrators earn fees on taker volume generated by orders they submit on behalf of users.\n * These fees accumulate in a vault per market (clearing house), and can be claimed at any time\n * by the integrator.\n */\nexport interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody {\n\t/**\n\t * Market (clearing house) ID where the integrator fees were earned.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tmarketId: PerpetualsMarketId;\n\n\t/**\n\t * Sui address of the integrator claiming their fees.\n\t *\n\t * Must be a valid Sui object ID.\n\t * Only the integrator who earned the fees can claim them.\n\t */\n\tintegratorAddress: SuiAddress;\n\n\t/**\n\t * Optional recipient address for the claimed fees.\n\t *\n\t * When provided, the transaction will include an on-chain transfer of the\n\t * claimed coin to this address. When omitted, the claimed coin is exposed\n\t * as a transaction argument that can be used in subsequent commands.\n\t */\n\trecipientAddress?: SuiAddress;\n\n\t/**\n\t * Optional existing transaction kind (base64-encoded) to extend.\n\t *\n\t * If provided, the fee claim will be added to this transaction.\n\t */\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Response payload for claim integrator vault fees transaction.\n *\n * Contains the transaction kind and optionally a coin output argument when\n * no recipient address was provided.\n */\nexport interface ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse {\n\t/**\n\t * Base64-encoded Sui `TransactionKind` representing the claim (and\n\t * optional transfer) transaction.\n\t */\n\ttxKind: SerializedTransaction;\n\n\t/**\n\t * When `recipientAddress` is omitted, this contains a readable argument\n\t * pointing to the claimed coin output, so callers can wire it into\n\t * subsequent steps.\n\t */\n\tcoinOutArg?: TransactionObjectArgument;\n}\n\n/**\n * Request payload for fetching integrator configuration for a specific account and integrator.\n *\n * This endpoint checks whether an integrator has been approved by an account to collect fees,\n * and if so, returns the maximum taker fee the integrator is authorized to charge.\n */\nexport interface ApiPerpetualsBuilderCodesIntegratorConfigBody {\n\t/**\n\t * Account ID encoded as a bigint.\n\t *\n\t * This is the perpetuals account whose integrator approval is being queried.\n\t */\n\taccountId: PerpetualsAccountId;\n\n\t/**\n\t * Sui address of the integrator whose configuration is being queried.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tintegratorAddress: SuiAddress;\n}\n\n/**\n * Response payload containing integrator configuration details.\n *\n * Returns whether an integrator configuration exists and the maximum taker fee\n * if the integrator has been approved.\n */\nexport interface ApiPerpetualsBuilderCodesIntegratorConfigResponse {\n\t/**\n\t * Maximum taker fee (as a decimal) that the integrator is authorized to charge.\n\t *\n\t * For example, 0.001 represents a 0.1% maximum fee. This value is only meaningful\n\t * if `exists` is true.\n\t */\n\tmaxTakerFee: Percentage | undefined;\n\n\t/**\n\t * Whether an integrator configuration exists for this account-integrator pair.\n\t *\n\t * If false, the integrator has not been approved by the account and cannot\n\t * collect fees on orders placed on behalf of the account.\n\t */\n\texists: boolean;\n}\n\n/**\n * Individual integrator vault data for a specific market.\n *\n * Contains the market ID and the accumulated fees available to claim from that market's vault.\n */\nexport interface PerpetualsIntegratorVaultData {\n\t/**\n\t * Market (clearing house) object ID.\n\t */\n\tmarketId: PerpetualsMarketId;\n\n\t/**\n\t * The collateral coin type used by this market.\n\t */\n\tcollateralCoinType: CoinType;\n\n\t/**\n\t * Total accumulated fees in the market's collateral currency that are available to claim.\n\t *\n\t * Fees are denominated in the collateral coin type used by the market.\n\t */\n\tfees: number;\n\n\t/**\n\t * Total accumulated fees converted to USD.\n\t */\n\tfeesUsd: number;\n}\n\n/**\n * Request payload for fetching integrator vault fees across multiple markets.\n *\n * This endpoint returns the accumulated fees an integrator has earned in their vaults\n * across one or more markets (clearing houses). These fees are generated from taker\n * volume on orders the integrator submitted on behalf of users.\n */\nexport interface ApiPerpetualsBuilderCodesIntegratorVaultsBody {\n\t/**\n\t * List of market (clearing house) IDs to query for integrator vault fees.\n\t *\n\t * Each market ID must be a valid Sui object ID.\n\t */\n\tmarketIds: PerpetualsMarketId[];\n\n\t/**\n\t * Sui address of the integrator whose vault fees are being queried.\n\t *\n\t * Must be a valid Sui object ID.\n\t */\n\tintegratorAddress: SuiAddress;\n}\n\n/**\n * Response payload containing accumulated fees per market for an integrator.\n *\n * Returns a vector of integrator vault data, one entry per market queried.\n * Markets where the integrator has no vault may be omitted or have zero fees.\n */\nexport interface ApiPerpetualsBuilderCodesIntegratorVaultsResponse {\n\t/**\n\t * Vector of integrator vault data containing market IDs and their accumulated fees.\n\t *\n\t * Each entry represents a market where the integrator has a vault and potentially\n\t * claimable fees. The order matches the order of market IDs in the request.\n\t */\n\tintegratorVaults: PerpetualsIntegratorVaultData[];\n}\n\n/**\n * Request body for creating a new perpetuals account for a given wallet\n * and collateral coin type.\n */\nexport interface ApiPerpetualsCreateAccountBody {\n\twalletAddress: SuiAddress;\n\tcollateralCoinType: CoinType;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request body for depositing collateral into a perpetuals account.\n *\n * The deposit can be provided by:\n * - `depositAmount` (numeric amount), or\n * - `depositCoinArg` (Sui coin object).\n */\nexport type ApiPerpetualsDepositCollateralBody = {\n\twalletAddress: SuiAddress;\n\taccountId: PerpetualsAccountId;\n\taccountCapId?: ObjectId;\n\tcollateralCoinType: CoinType;\n\ttxKind?: SerializedTransaction;\n\tisSponsoredTx?: boolean;\n} & (\n\t| {\n\t\t\tdepositAmount: Balance;\n\t }\n\t| {\n\t\t\tdepositCoinArg: TransactionObjectArgument;\n\t }\n);\n\n/**\n * Request body for withdrawing collateral from an account.\n */\nexport type ApiPerpetualsWithdrawCollateralBody = {\n\taccountId: PerpetualsAccountId;\n\twithdrawAmount: Balance;\n\trecipientAddress?: SuiAddress;\n\ttxKind?: SerializedTransaction;\n};\n\n/**\n * Response body for withdraw-collateral transactions.\n *\n * The SDK typically uses `txKind` to reconstruct a transaction locally.\n */\nexport interface ApiPerpetualsWithdrawCollateralResponse {\n\ttxKind: SerializedTransaction;\n\tcoinOutArg: TransactionObjectArgument | undefined;\n}\n\n/**\n * Request body for transferring collateral between two perpetuals accounts.\n */\nexport interface ApiPerpetualsTransferCollateralBody {\n\twalletAddress: SuiAddress;\n\tfromAccountId: PerpetualsAccountId;\n\tfromAccountCapId?: ObjectId;\n\ttoAccountId: PerpetualsAccountId;\n\ttoAccountCapId?: ObjectId;\n\ttransferAmount: Balance;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request body for allocating collateral to a given market (account/vault).\n */\nexport type ApiPerpetualsAllocateCollateralBody = {\n\tmarketId: PerpetualsMarketId;\n\tallocateAmount: Balance;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * Request body for deallocating collateral from a given market (account/vault).\n */\nexport type ApiPerpetualsDeallocateCollateralBody = {\n\tmarketId: PerpetualsMarketId;\n\tdeallocateAmount: Balance;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * SDK-level inputs for placing one or more stop orders.\n *\n * This is a client-facing type that wraps the on-chain format.\n */\nexport interface SdkPerpetualsPlaceStopOrdersInputs {\n\t/** Stop orders to place (without objectId, which is created on-chain). */\n\tstopOrders: Omit<PerpetualsStopOrderData, \"objectId\">[];\n\t/** Optional transaction to embed the call in. */\n\ttx?: Transaction;\n\t/** Optional gas coin for sponsored or custom gas usage. */\n\tgasCoinArg?: TransactionObjectArgument;\n\t/** Whether the transaction is expected to be sponsored by the API. */\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Request body for placing stop orders via the API.\n */\nexport type ApiPerpetualsPlaceStopOrdersBody = {\n\twalletAddress: SuiAddress;\n\tstopOrders: Omit<PerpetualsStopOrderData, \"objectId\">[];\n\tgasCoinArg?: TransactionObjectArgument;\n\tisSponsoredTx?: boolean;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * SDK-level inputs for placing stop-loss / take-profit orders bound to a\n * specific market and position side.\n */\nexport type SdkPerpetualsPlaceSlTpOrdersInputs = {\n\tmarketId: PerpetualsMarketId;\n\t/** Optional target size for SL/TP orders (scaled base units). */\n\tsize?: bigint;\n\t/** Index price at which to trigger stop loss. */\n\tstopLossIndexPrice?: number;\n\t/** Index price at which to trigger take profit. */\n\ttakeProfitIndexPrice?: number;\n\t/** Unique order identifier for limit order sl/tp is tied to. */\n\tlimitOrderId?: PerpetualsOrderId;\n\t/** Optional transaction to embed in. */\n\ttx?: Transaction;\n\t/** Optional gas coin argument. */\n\tgasCoinArg?: TransactionObjectArgument;\n\t/** Whether to treat the transaction as sponsored. */\n\tisSponsoredTx?: boolean;\n};\n// & (\n// \t| {\n// \t\t\tstopLossIndexPrice: number;\n// \t\t\ttakeProfitIndexPrice: number;\n// \t }\n// \t| {\n// \t\t\tstopLossIndexPrice: number;\n// \t }\n// \t| {\n// \t\t\ttakeProfitIndexPrice: number;\n// \t }\n// );\n\n/**\n * API request body for placing SL/TP orders bound to a position.\n */\nexport type ApiPerpetualsPlaceSlTpOrdersBody = {\n\tmarketId: PerpetualsMarketId;\n\twalletAddress: SuiAddress;\n\tpositionSide: PerpetualsOrderSide;\n\tsize?: bigint;\n\tstopLossIndexPrice?: number;\n\ttakeProfitIndexPrice?: number;\n\tlimitOrderId?: PerpetualsOrderId;\n\tgasCoinArg?: TransactionObjectArgument;\n\tisSponsoredTx?: boolean;\n\tleverage?: number;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n// & (\n// \t| {\n// \t\t\tstopLossIndexPrice: number;\n// \t\t\ttakeProfitIndexPrice: number;\n// \t }\n// \t| {\n// \t\t\tstopLossIndexPrice: number;\n// \t }\n// \t| {\n// \t\t\ttakeProfitIndexPrice: number;\n// \t }\n// );\n\n/**\n * API request body for editing existing stop orders for an\n * account or vault.\n */\nexport type ApiPerpetualsEditStopOrdersBody = {\n\tstopOrders: PerpetualsStopOrderData[];\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * API request body for placing a market order in a given market.\n *\n * This form is used by the backend and includes contextual information\n * like `accountId` or `vaultId`.\n */\nexport type ApiPerpetualsMarketOrderBody = {\n\twalletAddress: SuiAddress;\n\tmarketId: PerpetualsMarketId;\n\tside: PerpetualsOrderSide;\n\t/** Order size in scaled base units. */\n\tsize: bigint;\n\t/** Change in collateral allocated to this position (collateral units). */\n\tcollateralChange: number;\n\t/** Whether the account already has a position in this market. */\n\thasPosition: boolean;\n\t/** True is position is closed. */\n\tcancelSlTp: boolean;\n\t/** If true, order can only reduce an existing position. */\n\treduceOnly: boolean;\n\t/** Allowable max slippage for trade execution. */\n\tslippage: Slippage;\n\t/** Optional leverage override. */\n\tleverage?: number;\n\t/** Optional SL/TP instructions to be placed along with the market order. */\n\tslTp?: {\n\t\tgasCoinArg?: TransactionObjectArgument;\n\t\tisSponsoredTx?: boolean;\n\t\tsize?: bigint;\n\t\tstopLossIndexPrice?: number;\n\t\ttakeProfitIndexPrice?: number;\n\t};\n\t// & (\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// );\n\n\t/**\n\t * Optional integrator fee configuration for this order.\n\t *\n\t * If provided, the integrator specified in the configuration will receive a fee\n\t * on the taker volume generated by this order. The integrator must have been\n\t * previously approved by the account owner, and the fee must not exceed the\n\t * maximum fee the user approved for that integrator.\n\t */\n\tbuilderCode?: PerpetualsBuilderCodeParamaters;\n\t/** Optional serialized transaction kind if assembled by the API. */\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * API request body for placing a limit order in a given market.\n */\nexport type ApiPerpetualsLimitOrderBody = {\n\tmarketId: PerpetualsMarketId;\n\twalletAddress: SuiAddress;\n\tside: PerpetualsOrderSide;\n\t/** Order size in scaled base units. */\n\tsize: bigint;\n\t/** Limit price in scaled fixed-point representation. */\n\tprice: bigint;\n\t/** How the order behaves on the orderbook. */\n\torderType: PerpetualsOrderType;\n\t/** Change in collateral allocated to this position. */\n\tcollateralChange: number;\n\t/** Whether the account already has a position in this market. */\n\thasPosition: boolean;\n\t/** True is position is closed. */\n\tcancelSlTp: boolean;\n\t/** If true, order can only reduce an existing position. */\n\treduceOnly: boolean;\n\t/** Optional expiration for the order. */\n\texpiryTimestamp?: bigint;\n\t/** Optional leverage override. */\n\tleverage?: number;\n\t/** Optional SL/TP instructions to be placed along with the limit order. */\n\tslTp?: {\n\t\tgasCoinArg?: TransactionObjectArgument;\n\t\tisSponsoredTx?: boolean;\n\t\tsize?: bigint;\n\t\tstopLossIndexPrice?: number;\n\t\ttakeProfitIndexPrice?: number;\n\t};\n\t// & (\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// );\n\n\t/**\n\t * Optional integrator fee configuration for this order.\n\t *\n\t * If provided, the integrator specified in the configuration will receive a fee\n\t * on the taker volume generated by this order. The integrator must have been\n\t * previously approved by the account owner, and the fee must not exceed the\n\t * maximum fee the user approved for that integrator.\n\t */\n\tbuilderCode?: PerpetualsBuilderCodeParamaters;\n\t/** Optionally pre-built transaction payload. */\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * API request body for canceling one or more orders for an\n * account or vault, per market.\n */\nexport type ApiPerpetualsCancelOrdersBody = {\n\twalletAddress: SuiAddress;\n\tmarketIdsToData: Record<\n\t\tPerpetualsMarketId,\n\t\t{\n\t\t\torderIds: PerpetualsOrderId[];\n\t\t\t/** Collateral change associated with canceling these orders. */\n\t\t\tcollateralChange: number;\n\t\t}\n\t>;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n/**\n * API request body for canceling stop orders identified by object IDs.\n */\nexport type ApiPerpetualsCancelStopOrdersBody = {\n\tstopOrderIds: ObjectId[];\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n// export type ApiPerpetualsReduceOrderBody = {\n// \tmarketId: PerpetualsMarketId;\n// \tcollateralChange: number;\n// \tleverage?: number;\n// \torderId: PerpetualsOrderId;\n// \tsizeToSubtract: bigint;\n// \ttxKind?: SerializedTransaction;\n// } & (\n// \t| {\n// \t\t\taccountId: PerpetualsAccountId;\n// \t }\n// \t| {\n// \t\t\tvaultId: ObjectId;\n// \t }\n// );\n\n/**\n * API body for setting leverage on an existing position.\n */\nexport type ApiPerpetualsSetLeverageTxBody = {\n\tmarketId: PerpetualsMarketId;\n\tcollateralChange: number;\n\tleverage: number;\n\ttxKind?: SerializedTransaction;\n} & (\n\t| {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\taccountCapId?: ObjectId;\n\t }\n\t| {\n\t\t\tvaultId: ObjectId;\n\t }\n);\n\n// export interface ApiPerpetualsReduceOrderBody {\n// \twalletAddress: SuiAddress;\n// \tpackageId: PackageId;\n// \tcollateralCoinType: CoinType;\n// \taccountCapId: ObjectId;\n// \tmarketId: PerpetualsMarketId;\n// \tmarketInitialSharedVersion: ObjectVersion;\n// \torderIds: PerpetualsOrderId[];\n// \tsizesToSubtract: bigint[];\n// \tbasePriceFeedId: ObjectId;\n// \tcollateralPriceFeedId: ObjectId;\n// \tcollateralChange: number;\n// }\n\n/**\n * 24-hour volume and price change statistics for a single market.\n */\nexport interface PerpetualsMarket24hrStats {\n\t/** The total 24h volume in USD. */\n\tvolumeUsd: number;\n\t/** The total 24h volume measured in the base asset. */\n\tvolumeBaseAssetAmount: number;\n\t/**\n\t * Absolute price change over the last 24h, denominated in the\n\t * base asset's quote units.\n\t */\n\tpriceChange: number;\n\t/** Relative price change over the last 24h (e.g. +5% => `0.05`). */\n\tpriceChangePercentage: number;\n\t/** Latest base asset price for this market. */\n\tbasePrice: number;\n\t/** Latest collateral asset price used in this market. */\n\tcollateralPrice: number;\n\t/**\n\t * Mid price derived from the current order book.\n\t *\n\t * Calculated as the average of the best bid and best ask.\n\t * `undefined` if either side of the book is empty.\n\t */\n\tmidPrice: number | undefined;\n\t/**\n\t * Mark price used for liquidations and risk calculations.\n\t *\n\t * Computed as the median of the index TWAP, the current\n\t * book-derived price, and the index price adjusted for\n\t * funding contributions.\n\t */\n\tmarkPrice: number;\n}\n\n/**\n * Response type for requesting 24h stats for multiple markets.\n */\nexport interface ApiPerpetualsMarkets24hrStatsResponse {\n\tmarketsStats: PerpetualsMarket24hrStats[];\n}\n\n/**\n * Request body for fetching all markets for a given collateral type.\n *\n * This endpoint is commonly used to populate a \"Markets\" list filtered by\n * the user's selected collateral (e.g., USDC-margined markets).\n */\nexport interface ApiPerpetualsAllMarketsBody {\n\tcollateralCoinType: CoinType;\n}\n\n/**\n * Response payload for {@link ApiPerpetualsAllMarketsBody}.\n *\n * Returns enriched market data including parameters, state, and current prices.\n */\nexport interface ApiPerpetualsAllMarketsResponse {\n\tmarkets: PerpetualsMarketData[];\n}\n\n/**\n * Request body for fetching a specific set of markets by ID.\n */\nexport interface ApiPerpetualsMarketsBody {\n\tmarketIds: PerpetualsMarketId[];\n}\n\n/**\n * Response payload for {@link ApiPerpetualsMarketsBody}.\n *\n * Each item includes the market data.\n */\nexport interface ApiPerpetualsMarketsResponse {\n\tmarketDatas: {\n\t\tmarket: PerpetualsMarketData;\n\t}[];\n}\n\n/**\n * Request body for fetching a specific set of orderbooks by market ID.\n */\nexport interface ApiPerpetualsOrderbooksBody {\n\tmarketIds: PerpetualsMarketId[];\n}\n\n/**\n * Response payload for {@link ApiPerpetualsOrderbooksBody}.\n *\n * Each item includes the current orderbook snapshot.\n */\nexport interface ApiPerpetualsOrderbooksResponse {\n\torderbooks: {\n\t\torderbook: PerpetualsOrderbook;\n\t}[];\n}\n\n/**\n * Request body for fetching vault objects.\n *\n * If `vaultIds` is omitted, the API may return all vaults (potentially paginated\n * at the transport layer).\n */\nexport interface ApiPerpetualsVaultsBody {\n\tvaultIds?: ObjectId[];\n}\n\n/**\n * Response payload for vault queries.\n */\nexport interface ApiPerpetualsVaultsResponse {\n\tvaults: PerpetualsVaultObject[];\n}\n\n/**\n * Request body for fetching current prices for a list of markets.\n *\n * This is a lightweight alternative to fetching full {@link PerpetualsMarketData}\n * when only prices are needed.\n */\nexport interface ApiPerpetualsMarketsPricesBody {\n\tmarketIds: PerpetualsMarketId[];\n}\n\n/**\n * Response payload for {@link ApiPerpetualsMarketsPricesBody}.\n *\n * Returns base (index/oracle) and collateral prices, the order book mid price,\n * and the mark price used for liquidations and risk calculations.\n */\nexport interface ApiPerpetualsMarketsPricesResponse {\n\tmarketsPrices: {\n\t\t/** Identifier of the market. */\n\t\tmarketId: PerpetualsMarketId;\n\t\t/** Latest base asset price for this market. */\n\t\tbasePrice: number;\n\t\t/** Latest collateral asset price used in this market. */\n\t\tcollateralPrice: number;\n\t\t/**\n\t\t * Mid price derived from the current order book.\n\t\t *\n\t\t * Calculated as the average of the best bid and best ask.\n\t\t * `undefined` if either side of the book is empty.\n\t\t */\n\t\tmidPrice: number | undefined;\n\t\t/**\n\t\t * Mark price used for liquidations and risk calculations.\n\t\t *\n\t\t * Computed as the median of the index TWAP, the current\n\t\t * book-derived price, and the index price adjusted for\n\t\t * funding contributions.\n\t\t */\n\t\tmarkPrice: number;\n\t}[];\n}\n\n/**\n * Request body for granting an Agent Wallet on a perpetuals account.\n *\n * This corresponds to `POST /api/perpetuals/account/transactions/grant-agent-wallet`.\n *\n * The resulting on-chain transaction must be signed by the **account admin** wallet.\n * After execution, `recipientAddress` receives assistant-level permissions for `accountId`\n * (trading actions are allowed, but **withdrawing collateral** and managing other agent wallets are not).\n */\nexport type ApiPerpetualsGrantAgentWalletTxBody = {\n\trecipientAddress: SuiAddress;\n\taccountId: PerpetualsAccountId;\n\ttxKind?: SerializedTransaction;\n};\n\n/**\n * Request body for revoking an Agent Wallet from a perpetuals account.\n *\n * This corresponds to `POST /api/perpetuals/account/transactions/revoke-agent-wallet`.\n *\n * The resulting on-chain transaction must be signed by the **account admin** wallet.\n * `accountCapId` is the object ID of the assistant capability to revoke.\n */\nexport type ApiPerpetualsRevokeAgentWalletTxBody = {\n\taccountId: PerpetualsAccountId;\n\taccountCapId: ObjectId;\n\ttxKind?: SerializedTransaction;\n};\n\nexport type ApiPerpetualsTransferCapTxBody = {\n\t/**\n\t * Recipient wallet address that should receive the capability object.\n\t *\n\t * Must be a valid Sui address string.\n\t */\n\trecipientAddress: SuiAddress;\n\n\t/**\n\t * Object ID of the capability to transfer.\n\t *\n\t * This should be the object ID of the cap being transferred (e.g., an account cap or vault cap).\n\t */\n\tcapObjectId: ObjectId;\n\n\t/**\n\t * Optional serialized (base64) Sui `TransactionKind` to extend.\n\t *\n\t * When provided, the transfer operation is appended to the existing transaction.\n\t */\n\ttxKind?: SerializedTransaction;\n};\n\n// =========================================================================\n// Vaults\n// =========================================================================\n\n/**\n * Request body for fetching LP coin prices for a set of vaults.\n *\n * LP coin price is typically expressed in USD per 1 LP token (native units adjusted\n * using `lpCoinDecimals` on the vault object).\n */\nexport interface ApiPerpetualsVaultLpCoinPricesBody {\n\tvaultIds: ObjectId[];\n}\n\n/**\n * Response payload for {@link ApiPerpetualsVaultLpCoinPricesBody}.\n *\n * The response is index-aligned with the request `vaultIds` array.\n */\nexport interface ApiPerpetualsVaultLpCoinPricesResponse {\n\tlpCoinPrices: number[];\n}\n\n/**\n * Request body for fetching a wallet's owned LP coin objects across vaults.\n */\nexport interface ApiPerpetualsVaultOwnedLpCoinsBody {\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Response payload listing owned LP coin objects (per vault).\n */\nexport interface ApiPerpetualsVaultOwnedLpCoinsResponse {\n\townedLpCoins: PerpetualsVaultLpCoin[];\n}\n\n/**\n * Request body for fetching vault capability objects owned by a wallet.\n *\n * Vault caps are typically owned by the vault creator/owner and are required\n * for privileged vault actions (processing withdrawals, updating parameters, etc.).\n */\nexport interface ApiPerpetualsOwnedVaultCapsBody {\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Response payload listing all vault caps owned by the wallet.\n */\nexport interface ApiPerpetualsOwnedVaultCapsResponse {\n\townedVaultCaps: PerpetualsVaultCap[];\n}\n\n/**\n * API body to process forced withdrawals in a vault.\n */\nexport interface ApiPerpetualsVaultProcessForceWithdrawRequestTxBody {\n\twalletAddress: SuiAddress;\n\tvaultId: ObjectId;\n\t/** Per-market sizes to close as part of force withdraw. */\n\tsizesToClose: Record<PerpetualsMarketId, Balance>;\n\trecipientAddress?: SuiAddress;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Response body for force-withdraw processing transactions.\n *\n * - `txKind` is a serialized transaction kind the client can sign/submit.\n * - `coinOutArg` (if present) is the transaction argument referencing the\n * withdrawn collateral coin output.\n */\nexport interface ApiPerpetualsVaultProcessForceWithdrawRequestTxResponse {\n\ttxKind: SerializedTransaction;\n\tcoinOutArg: TransactionObjectArgument | undefined;\n}\n\n// TODO: docs\nexport interface ApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody {\n\tvaultId: ObjectId;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body to process regular withdraw requests for a vault.\n */\nexport interface ApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody {\n\tvaultId: ObjectId;\n\tuserAddresses: SuiAddress[];\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body to update slippage parameter for pending vault withdraw\n * request for a specific vault.\n */\nexport interface ApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody {\n\tvaultId: ObjectId;\n\tminCollateralAmountOut: Balance;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body to update the force-withdrawal delay in a vault.\n */\nexport interface ApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody {\n\tvaultId: ObjectId;\n\tforceWithdrawDelayMs: bigint;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body to update the lock period on a vault.\n */\nexport interface ApiPerpetualsVaultOwnerUpdateLockPeriodTxBody {\n\tvaultId: ObjectId;\n\tlockPeriodMs: bigint;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body to update the owner's fee percentage on a vault.\n */\nexport interface ApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody {\n\tvaultId: ObjectId;\n\tperformanceFeePercentage: number;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body for the vault owner withdrawing collected fees.\n */\nexport interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody {\n\tvaultId: ObjectId;\n\twithdrawAmount: Balance;\n\trecipientAddress?: SuiAddress;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Response for owner-fee withdrawal transactions.\n */\nexport interface ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse {\n\ttxKind: SerializedTransaction;\n\tcoinOutArg: TransactionObjectArgument | undefined;\n}\n\n/**\n * Request body for fetching all withdrawal requests for specific vaults.\n */\nexport interface ApiPerpetualsVaultsWithdrawRequestsBody {\n\tvaultIds: ObjectId[];\n}\n\n/**\n * Response payload listing withdrawal requests for the requested vaults.\n *\n * Depending on backend behavior, this may include all queued requests across\n * all specified vaults.\n */\nexport interface ApiPerpetualsVaultsWithdrawRequestsResponse {\n\twithdrawRequests: PerpetualsVaultWithdrawRequest[];\n}\n\n/**\n * Request body for fetching withdrawal requests for a given wallet across\n * its vault positions.\n */\nexport interface ApiPerpetualsVaultOwnedWithdrawRequestsBody {\n\twalletAddress: SuiAddress;\n\t// vaultIds: ObjectId[] | undefined;\n}\n\n/**\n * Response payload listing withdrawal requests created by `walletAddress`.\n */\nexport interface ApiPerpetualsVaultOwnedWithdrawRequestsResponse {\n\townedWithdrawRequests: PerpetualsVaultWithdrawRequest[];\n}\n\n/**\n * API body for creating a single withdraw request from a vault.\n */\nexport interface ApiPerpetualsVaultCreateWithdrawRequestTxBody {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n\tlpWithdrawAmount: Balance;\n\tminCollateralAmountOut: Balance;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * API body for withdrawing collateral from a vault as owner.\n */\nexport interface ApiPerpetualsVaultOwnerWithdrawCollateralTxBody {\n\tvaultId: ObjectId;\n\tlpWithdrawAmount: Balance;\n\tminCollateralAmountOut: Balance;\n\trecipientAddress?: SuiAddress;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Response body for vault owner withdraw-collateral transactions.\n *\n * The SDK typically uses `txKind` to reconstruct a transaction locally.\n */\nexport interface ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse {\n\ttxKind: SerializedTransaction;\n\tcoinOutArg: TransactionObjectArgument | undefined;\n}\n\n/**\n * API body for canceling withdrawal requests across vaults for a wallet.\n */\nexport interface ApiPerpetualsVaultCancelWithdrawRequestTxBody {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n\ttxKind?: SerializedTransaction;\n}\n\n/**\n * Request body for depositing into a vault.\n *\n * Deposit can be specified as a numeric amount or as an existing coin object.\n */\nexport type ApiPerpetualsVaultDepositTxBody = {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n\tminLpAmountOut: Balance;\n\ttxKind?: SerializedTransaction;\n\tisSponsoredTx?: boolean;\n} & (\n\t| {\n\t\t\tdepositAmount: Balance;\n\t\t\tcollateralCoinType: CoinType;\n\t }\n\t| {\n\t\t\tdepositCoinArg: TransactionObjectArgument;\n\t }\n);\n\n/**\n * Request body for previewing a vault withdrawal request.\n */\nexport interface ApiPerpetualsVaultPreviewCreateWithdrawRequestBody {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n\tlpWithdrawAmount: Balance;\n}\n\n/**\n * Response body for vault withdrawal preview.\n */\nexport type ApiPerpetualsVaultPreviewCreateWithdrawRequestResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tcollateralAmountOut: Balance;\n\t\t\tcollateralPrice: number;\n\t };\n\n/**\n * Request body for previewing a vault owner collateral withdrawal.\n */\nexport interface ApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody {\n\tvaultId: ObjectId;\n\tlpWithdrawAmount: Balance;\n}\n\n/**\n * Response body for vault owner collateral withdrawal preview.\n */\nexport type ApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tcollateralAmountOut: Balance;\n\t\t\tcollateralPrice: number;\n\t };\n\n/**\n * Request body for previewing a vault deposit.\n */\nexport interface ApiPerpetualsVaultPreviewDepositBody {\n\tvaultId: ObjectId;\n\t// TODO: rename collateralDepositAmount ?\n\tdepositAmount: Balance;\n}\n\n/**\n * Response body for vault deposit preview.\n */\nexport type ApiPerpetualsVaultPreviewDepositResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tlpAmountOut: Balance;\n\t\t\tcollateralPrice: number;\n\t\t\tdepositedAmountUsd: number;\n\t };\n\n/**\n * Request body for previewing forced withdraw processing for a vault.\n */\nexport interface ApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Response body for forced withdraw processing preview.\n */\nexport type ApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tcollateralAmountOut: Balance;\n\t\t\tcollateralPrice: number;\n\t\t\t// TODO: change to arr ?\n\t\t\tsizesToClose: Record<PerpetualsMarketId, bigint>;\n\t\t\tpriceImpact: Percentage;\n\t\t\tperformanceFeesChargedUsd: number;\n\t\t\tisWithinWithdrawRequestSlippage: boolean;\n\t\t\tminCollateralAmountOut: Balance;\n\t };\n\n// TODO: docs\nexport interface ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody {\n\tvaultId: ObjectId;\n\twalletAddress: SuiAddress;\n}\n\n// TODO: docs\nexport type ApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse =\n\n\t\t| {\n\t\t\t\terror: string;\n\t\t }\n\t\t| {\n\t\t\t\tisPausable: boolean;\n\t\t\t\tminNextPauseTimestamp: bigint;\n\t\t };\n\n/**\n * Request body for previewing normal withdraw requests processing for a vault.\n */\nexport interface ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody {\n\tvaultId: ObjectId;\n\tuserAddresses: SuiAddress[];\n}\n\n/**\n * Response body for previewing normal withdraw requests processing.\n */\nexport type ApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tuserPreviews: {\n\t\t\t\tuserAddress: SuiAddress;\n\t\t\t\tcollateralAmountOut: Balance;\n\t\t\t}[];\n\t\t\tcollateralPrice: number;\n\t };\n\n/**\n * Request body for previewing maximum performance fees withdrawable from a vault.\n */\nexport interface ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody {\n\tvaultId: ObjectId;\n}\n\n/**\n * Response body for previewing vault performance fee withdrawal.\n */\nexport type ApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse =\n\t| {\n\t\t\terror: string;\n\t }\n\t| {\n\t\t\tmaxFeesToWithdraw: Balance;\n\t\t\t// maxFeesToWithdrawUsd: number;\n\t\t\tfeeCoinType: CoinType;\n\t };\n\n// =========================================================================\n// SDK\n// =========================================================================\n\n/**\n * SDK-level inputs for placing a market order from a client.\n *\n * This omits server-managed fields like `accountId`, `hasPosition`,\n * and serialized `txKind`, and exposes a client-friendly `slTp` wrapper.\n */\nexport type SdkPerpetualsPlaceMarketOrderInputs = Omit<\n\tApiPerpetualsMarketOrderBody,\n\t\"accountId\" | \"txKind\" | \"slTp\" | \"walletAddress\"\n> & {\n\ttx?: Transaction;\n\tslTp?: {\n\t\tgasCoinArg?: TransactionObjectArgument;\n\t\tisSponsoredTx?: boolean;\n\t\tsize?: bigint;\n\t\tstopLossIndexPrice?: number;\n\t\ttakeProfitIndexPrice?: number;\n\t};\n\t// & (\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// );\n};\n\n/**\n * SDK-level inputs for placing a limit order from a client.\n */\nexport type SdkPerpetualsPlaceLimitOrderInputs = Omit<\n\tApiPerpetualsLimitOrderBody,\n\t\"accountId\" | \"txKind\" | \"slTp\" | \"walletAddress\"\n> & {\n\ttx?: Transaction;\n\tslTp?: {\n\t\tgasCoinArg?: TransactionObjectArgument;\n\t\tisSponsoredTx?: boolean;\n\t\tsize?: bigint;\n\t\tstopLossIndexPrice?: number;\n\t\ttakeProfitIndexPrice?: number;\n\t};\n\t// & (\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\tstopLossIndexPrice: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\ttakeProfitIndexPrice: number;\n\t// \t }\n\t// );\n};\n\n// export type SdkPerpetualsPlaceOrderPreviewInputs = Omit<\n// \tApiPerpetualsPreviewOrderBody,\n// \t\"collateralCoinType\" | \"accountId\"\n// >;\n\n/**\n * SDK-level inputs for previewing a market order.\n */\nexport type SdkPerpetualsPlaceMarketOrderPreviewInputs = Omit<\n\tApiPerpetualsPreviewPlaceMarketOrderBody,\n\t\"collateralCoinType\" | \"accountId\"\n>;\n\n/**\n * SDK-level inputs for previewing a limit order.\n */\nexport type SdkPerpetualsPlaceLimitOrderPreviewInputs = Omit<\n\tApiPerpetualsPreviewPlaceLimitOrderBody,\n\t\"collateralCoinType\" | \"accountId\"\n>;\n\n/**\n * SDK-level inputs for previewing order cancellations.\n */\nexport type SdkPerpetualsCancelOrdersPreviewInputs = Omit<\n\tApiPerpetualsPreviewCancelOrdersBody,\n\t\"collateralCoinType\" | \"accountId\"\n>;\n\n// =========================================================================\n// Websocket\n// =========================================================================\n\n// /perpetuals/ws/updates\n\n/**\n * Action for websocket subscription messages.\n */\nexport type PerpetualsWsUpdatesSubscriptionAction = \"subscribe\" | \"unsubscribe\";\n\n/**\n * Websocket subscription payload for subscribing to a specific market's\n * updates (orderbook, prices, etc.).\n */\nexport interface PerpetualsWsUpdatesMarketSubscriptionType {\n\tmarket: {\n\t\tmarketId: PerpetualsMarketId;\n\t};\n}\n\n/**\n * Websocket subscription payload for subscribing to user/account updates,\n * optionally including stop-order data (via signature).\n */\nexport interface PerpetualsWsUpdatesUserSubscriptionType {\n\tuser: {\n\t\taccountId: PerpetualsAccountId;\n\t\twithStopOrders:\n\t\t\t| {\n\t\t\t\t\twalletAddress: SuiAddress;\n\t\t\t\t\tbytes: string;\n\t\t\t\t\tsignature: string;\n\t\t\t }\n\t\t\t| undefined;\n\t};\n}\n\n/**\n * Websocket subscription payload for market oracle price updates.\n */\nexport interface PerpetualsWsUpdatesOracleSubscriptionType {\n\toracle: {\n\t\tmarketId: PerpetualsMarketId;\n\t};\n}\n\n/**\n * Websocket subscription payload for orderbook updates.\n */\nexport interface PerpetualsWsUpdatesOrderbookSubscriptionType {\n\torderbook: {\n\t\tmarketId: PerpetualsMarketId;\n\t};\n}\n\n/**\n * Websocket subscription payload for market orders stream.\n */\nexport interface PerpetualsWsUpdatesMarketOrdersSubscriptionType {\n\tmarketOrders: {\n\t\tmarketId: PerpetualsMarketId;\n\t};\n}\n\n/**\n * Websocket subscription payload for user-specific order updates.\n */\nexport interface PerpetualsWsUpdatesUserOrdersSubscriptionType {\n\tuserOrders: {\n\t\taccountId: PerpetualsAccountId;\n\t};\n}\n\n/**\n * Websocket subscription payload for user-specific collateral changes.\n */\nexport interface PerpetualsWsUpdatesUserCollateralChangesSubscriptionType {\n\tuserCollateralChanges: {\n\t\taccountId: PerpetualsAccountId;\n\t};\n}\n\n/**\n * Websocket subscription payload for bucketed orderbook snapshots\n * (top of orderbook) for a specific market.\n */\nexport interface PerpetualsWsUpdatesTopOfOrderbookSubscriptionType {\n\ttopOfOrderbook: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tpriceBucketSize: number;\n\t\tbucketsNumber: number;\n\t};\n}\n\n/**\n * Union of all websocket subscription types for perpetuals updates.\n */\nexport type PerpetualsWsUpdatesSubscriptionType =\n\t| PerpetualsWsUpdatesMarketSubscriptionType\n\t| PerpetualsWsUpdatesUserSubscriptionType\n\t| PerpetualsWsUpdatesOracleSubscriptionType\n\t| PerpetualsWsUpdatesOrderbookSubscriptionType\n\t| PerpetualsWsUpdatesMarketOrdersSubscriptionType\n\t| PerpetualsWsUpdatesUserOrdersSubscriptionType\n\t| PerpetualsWsUpdatesUserCollateralChangesSubscriptionType\n\t| PerpetualsWsUpdatesTopOfOrderbookSubscriptionType;\n\n/**\n * Websocket payload for oracle price updates.\n */\nexport interface PerpetualsWsUpdatesOraclePayload {\n\tmarketId: PerpetualsMarketId;\n\tbasePrice: number;\n\tcollateralPrice: number;\n}\n\n/**\n * Websocket payload for market orders stream.\n */\nexport interface PerpetualsWsUpdatesMarketOrdersPayload {\n\tmarketId: PerpetualsMarketId;\n\torders: PerpetualsMarketOrderHistoryData[];\n}\n\n/**\n * Websocket payload for user-specific orders stream.\n */\nexport interface PerpetualsWsUpdatesUserOrdersPayload {\n\taccountId: PerpetualsAccountId;\n\torders: PerpetualsAccountOrderHistoryData[];\n}\n\n/**\n * Websocket payload for user-specific collateral changes.\n */\nexport interface PerpetualsWsUpdatesUserCollateralChangesPayload {\n\taccountId: PerpetualsAccountId;\n\tcollateralChanges: PerpetualsAccountCollateralChange[];\n}\n\n/**\n * Websocket payload for incremental orderbook updates.\n */\nexport interface PerpetualsWsUpdatesOrderbookPayload {\n\tmarketId: PerpetualsMarketId;\n\torderbookDeltas: PerpetualsOrderbookDeltas;\n}\n\n/**\n * A single data point in the bucketed (top of) orderbook.\n */\nexport interface PerpetualsTopOfOrderbookDataPoint {\n\tprice: number;\n\tsize: number;\n\ttotalSize: number;\n\tsizeUsd: number;\n\ttotalSizeUsd: number;\n}\n\n/**\n * Bucketed orderbook state for top-of-orderbook updates.\n */\nexport interface PerpetualsTopOfOrderbook {\n\tbids: PerpetualsTopOfOrderbookDataPoint[];\n\tasks: PerpetualsTopOfOrderbookDataPoint[];\n\tminAskPrice: number | undefined;\n\tmaxBidPrice: number | undefined;\n}\n\n/**\n * Websocket payload for bucketed orderbook (top of orderbook) updates.\n */\nexport interface PerpetualsWsUpdatesTopOfOrderbookPayload {\n\tmarketId: PerpetualsMarketId;\n\tbids: PerpetualsTopOfOrderbookDataPoint[];\n\tasks: PerpetualsTopOfOrderbookDataPoint[];\n\tminAskPrice: number | undefined;\n\tmaxBidPrice: number | undefined;\n}\n\n/**\n * Websocket payload for user account and stop-order updates.\n */\nexport interface PerpetualsWsUpdatesUserPayload {\n\taccount: PerpetualsAccountObject;\n\tstopOrders: PerpetualsStopOrderData[] | undefined;\n}\n\n/**\n * Websocket subscription message format sent by clients to manage\n * their subscriptions.\n */\nexport interface PerpetualsWsUpdatesSubscriptionMessage {\n\taction: PerpetualsWsUpdatesSubscriptionAction;\n\tsubscriptionType: PerpetualsWsUpdatesSubscriptionType;\n}\n\n/**\n * Websocket response message for `/perpetuals/ws/updates`.\n *\n * Each response includes exactly one of the following discriminated unions.\n */\nexport type PerpetualsWsUpdatesResponseMessage =\n\t| { market: PerpetualsMarketData }\n\t| { user: PerpetualsWsUpdatesUserPayload }\n\t| { oracle: PerpetualsWsUpdatesOraclePayload }\n\t| { orderbook: PerpetualsWsUpdatesOrderbookPayload }\n\t| { marketOrders: PerpetualsWsUpdatesMarketOrdersPayload }\n\t| { userOrders: PerpetualsWsUpdatesUserOrdersPayload }\n\t| {\n\t\t\tuserCollateralChanges: PerpetualsWsUpdatesUserCollateralChangesPayload;\n\t }\n\t| { topOfOrderbook: PerpetualsWsUpdatesTopOfOrderbookPayload };\n\n// /perpetuals/ws/market-candles/{market_id}/{interval_ms}\n\n/**\n * Websocket response message carrying the last candle for a given market\n * and interval.\n */\nexport interface PerpetualsWsCandleResponseMessage {\n\tmarketId: PerpetualsMarketId;\n\tlastCandle: PerpetualsMarketCandleDataPoint | undefined;\n}\n","import {\n\tPerpetualsMarketState,\n\tPerpetualsOrderbook,\n\tPerpetualsMarketParams,\n\tPerpetualsAccountObject,\n\tPerpetualsPosition,\n\tDepositedCollateralEvent,\n\tWithdrewCollateralEvent,\n\tCreatedAccountEvent,\n\tCanceledOrderEvent,\n\tPerpetualsOrderSide,\n\tFilledTakerOrderEvent,\n\tFilledMakerOrdersEvent,\n\tPerpetualsOrderInfo,\n\tSettledFundingEvent,\n\tUpdatedSpreadTwapEvent,\n\tUpdatedPremiumTwapEvent,\n\tLiquidatedEvent,\n\tPerpetualsMarketData,\n\tPostedOrderEvent,\n\tAllocatedCollateralEvent,\n\tDeallocatedCollateralEvent,\n\tPerpetualsMarketId,\n\tPerpetualsOrderIdAsString,\n\tPerpetualsAccountId,\n\tUpdatedFundingEvent,\n\tUpdatedMarketVersionEvent,\n\tReducedOrderEvent,\n\tCreatedStopOrderTicketEvent,\n\tDeletedStopOrderTicketEvent,\n\tReceivedCollateralEvent,\n\tTransferredDeallocatedCollateralEvent,\n\tEditedStopOrderTicketExecutorEvent,\n\t// AddedStopOrderTicketCollateralEvent,\n\t// RemovedStopOrderTicketCollateralEvent,\n\tEditedStopOrderTicketDetailsEvent,\n\tExecutedStopOrderTicketEvent,\n\tSetPositionInitialMarginRatioEvent,\n\t// CreatedSubAccountEvent,\n\t// SetSubAccountUsersEvent,\n} from \"../perpetualsTypes\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport { Coin, Perpetuals } from \"../..\";\nimport { CoinSymbol, CoinType } from \"../../coin/coinTypes\";\nimport { FixedUtils } from \"../../../general/utils/fixedUtils\";\nimport {\n\tCanceledOrderEventOnChain,\n\tCreatedAccountEventOnChain,\n\tDepositedCollateralEventOnChain,\n\tWithdrewCollateralEventOnChain,\n\tFilledMakerOrdersEventOnChain,\n\tFilledTakerOrderEventOnChain,\n\tLiquidatedEventOnChain,\n\tSettledFundingEventOnChain,\n\tUpdatedPremiumTwapEventOnChain,\n\tUpdatedSpreadTwapEventOnChain,\n\tPostedOrderEventOnChain,\n\tAllocatedCollateralEventOnChain,\n\tDeallocatedCollateralEventOnChain,\n\tUpdatedFundingEventOnChain,\n\tUpdatedMarketVersionEventOnChain,\n\tReducedOrderEventOnChain,\n\tCreatedStopOrderTicketEventOnChain,\n\tDeletedStopOrderTicketEventOnChain,\n\t// ReceivedCollateralEventOnChain,\n\t// TransferredDeallocatedCollateralEventOnChain,\n\tEditedStopOrderTicketExecutorEventOnChain,\n\t// AddedStopOrderTicketCollateralEventOnChain,\n\t// RemovedStopOrderTicketCollateralEventOnChain,\n\tEditedStopOrderTicketDetailsEventOnChain,\n\tExecutedStopOrderTicketEventOnChain,\n\tSetPositionInitialMarginRatioEventOnChain,\n\tCreatedSubAccountEventOnChain,\n\tSetSubAccountUsersEventOnChain,\n} from \"../perpetualsCastingTypes\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport { IFixedAsStringBytes } from \"../../../types\";\n\n// TODO: handle 0xs and leading 0s everywhere\nexport class PerpetualsApiCasting {\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Account\n\t// =========================================================================\n\n\t// public static partialPositionFromRaw = (\n\t// \tdata: any\n\t// ): Omit<PerpetualsPosition, \"collateralCoinType\" | \"marketId\"> => {\n\t// \treturn {\n\t// \t\tcollateral: BigInt(data.collateral),\n\t// \t\tbaseAssetAmount: BigInt(data.baseAssetAmount),\n\t// \t\tquoteAssetNotionalAmount: BigInt(data.quoteAssetNotionalAmount),\n\t// \t\tcumFundingRateLong: BigInt(data.cumFundingRateLong),\n\t// \t\tcumFundingRateShort: BigInt(data.cumFundingRateShort),\n\t// \t\tasksQuantity: BigInt(data.asksQuantity),\n\t// \t\tbidsQuantity: BigInt(data.bidsQuantity),\n\t// \t\tpendingOrders: BigInt(data.pendingOrders),\n\t// \t\tmakerFee: BigInt(data.makerFee),\n\t// \t\ttakerFee: BigInt(data.takerFee),\n\t// \t};\n\t// };\n\n\t// =========================================================================\n\t// Orderbook\n\t// =========================================================================\n\n\t// public static orderbookPriceFromBytes = (bytes: number[]): number => {\n\t// \tconst unwrapped = bcs.option(bcs.u256()).parse(new Uint8Array(bytes));\n\t// \treturn FixedUtils.directCast(\n\t// \t\tunwrapped != null ? BigInt(unwrapped) : BigInt(0)\n\t// \t);\n\t// };\n\n\t// public static orderInfoFromRaw = (data: any): PerpetualsOrderInfo => {\n\t// \treturn {\n\t// \t\tprice: BigInt(data.price),\n\t// \t\tsize: BigInt(data.size),\n\t// \t};\n\t// };\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Updated Version\n\t// =========================================================================\n\n\tpublic static UpdatedMarketVersionEventFromOnChain = (\n\t\teventOnChain: UpdatedMarketVersionEventOnChain\n\t): UpdatedMarketVersionEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tversion: BigInt(fields.version),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Collateral\n\t// =========================================================================\n\n\tpublic static withdrewCollateralEventFromOnChain = (\n\t\teventOnChain: WithdrewCollateralEventOnChain\n\t): WithdrewCollateralEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tcollateralDelta: BigInt(fields.collateral),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static depositedCollateralEventFromOnChain = (\n\t\teventOnChain: DepositedCollateralEventOnChain\n\t): DepositedCollateralEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tcollateralDelta: BigInt(fields.collateral),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static settledFundingEventFromOnChain = (\n\t\teventOnChain: SettledFundingEventOnChain\n\t): SettledFundingEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tcollateralDeltaUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.collateral_change_usd)\n\t\t\t),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tmarketFundingRateLong: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.mkt_funding_rate_long)\n\t\t\t),\n\t\t\tmarketFundingRateShort: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.mkt_funding_rate_short)\n\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static allocatedCollateralEventFromOnChain = (\n\t\teventOnChain: AllocatedCollateralEventOnChain\n\t): AllocatedCollateralEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tcollateralDelta: BigInt(fields.collateral),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static deallocatedCollateralEventFromOnChain = (\n\t\teventOnChain: DeallocatedCollateralEventOnChain\n\t): DeallocatedCollateralEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tcollateralDelta: BigInt(fields.collateral),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Liquidation\n\t// =========================================================================\n\n\tpublic static liquidatedEventFromOnChain = (\n\t\teventOnChain: LiquidatedEventOnChain\n\t): LiquidatedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.liqee_account_id),\n\t\t\tcollateralDeltaUsd:\n\t\t\t\tCasting.IFixed.numberFromIFixed(BigInt(fields.liqee_pnl)) -\n\t\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\t\tBigInt(fields.liquidation_fees)\n\t\t\t\t) -\n\t\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\t\tBigInt(fields.force_cancel_fees)\n\t\t\t\t) -\n\t\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\t\tBigInt(fields.insurance_fund_fees)\n\t\t\t\t),\n\t\t\tliqorAccountId: BigInt(fields.liqor_account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tbaseLiquidated: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.base_liquidated)\n\t\t\t),\n\t\t\tquoteLiquidated: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.quote_liquidated)\n\t\t\t),\n\t\t\tliqeePnlUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.liqee_pnl)\n\t\t\t),\n\t\t\tliquidationFeesUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.liquidation_fees)\n\t\t\t),\n\t\t\tforceCancelFeesUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.force_cancel_fees)\n\t\t\t),\n\t\t\tinsuranceFundFeesUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.insurance_fund_fees)\n\t\t\t),\n\t\t\tside: fields.is_liqee_long\n\t\t\t\t? PerpetualsOrderSide.Bid\n\t\t\t\t: PerpetualsOrderSide.Ask,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Account\n\t// =========================================================================\n\n\tpublic static createdAccountEventFromOnChain = (\n\t\teventOnChain: CreatedAccountEventOnChain\n\t): CreatedAccountEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tuser: Helpers.addLeadingZeroesToType(fields.user),\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// public static createdSubAccountEventFromOnChain = (\n\t// \teventOnChain: CreatedSubAccountEventOnChain\n\t// ): CreatedSubAccountEvent => {\n\t// \tconst fields = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tusers: fields.users.map((user) =>\n\t// \t\t\tHelpers.addLeadingZeroesToType(user)\n\t// \t\t),\n\t// \t\taccountId: BigInt(fields.account_id),\n\t// \t\tsubAccountId: Helpers.addLeadingZeroesToType(fields.subaccount_id),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\t// public static setSubAccountUsersEventFromOnChain = (\n\t// \teventOnChain: SetSubAccountUsersEventOnChain\n\t// ): SetSubAccountUsersEvent => {\n\t// \tconst fields = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tusers: fields.users.map((user) =>\n\t// \t\t\tHelpers.addLeadingZeroesToType(user)\n\t// \t\t),\n\t// \t\taccountId: BigInt(fields.account_id),\n\t// \t\tsubAccountId: Helpers.addLeadingZeroesToType(fields.subaccount_id),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\tpublic static SetPositionInitialMarginRatioEventFromOnChain = (\n\t\teventOnChain: SetPositionInitialMarginRatioEventOnChain\n\t): SetPositionInitialMarginRatioEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tinitialMarginRatio: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.initial_margin_ratio)\n\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Order\n\t// =========================================================================\n\n\tpublic static canceledOrderEventFromOnChain = (\n\t\teventOnChain: CanceledOrderEventOnChain\n\t): CanceledOrderEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tside: Perpetuals.orderIdToSide(BigInt(fields.order_id)),\n\t\t\tsize: BigInt(fields.size),\n\t\t\torderId: BigInt(fields.order_id),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static filledMakerOrdersEventFromOnChain = (\n\t\teventOnChain: FilledMakerOrdersEventOnChain\n\t): FilledMakerOrdersEvent => {\n\t\treturn {\n\t\t\tevents: eventOnChain.parsedJson.events.map((fields) => ({\n\t\t\t\taccountId: BigInt(fields.maker_account_id),\n\t\t\t\ttakerAccountId: BigInt(fields.taker_account_id),\n\t\t\t\tcollateralDeltaUsd:\n\t\t\t\t\tCasting.IFixed.numberFromIFixed(BigInt(fields.pnl)) -\n\t\t\t\t\tCasting.IFixed.numberFromIFixed(BigInt(fields.fees)),\n\t\t\t\tpnlUsd: Casting.IFixed.numberFromIFixed(BigInt(fields.pnl)),\n\t\t\t\tfeesUsd: Casting.IFixed.numberFromIFixed(BigInt(fields.fees)),\n\t\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\t\torderId: BigInt(fields.order_id),\n\t\t\t\tside: Perpetuals.orderIdToSide(BigInt(fields.order_id)),\n\t\t\t\tsize: BigInt(fields.filled_size),\n\t\t\t\tdropped: BigInt(fields.remaining_size) === BigInt(0),\n\t\t\t\tsizeRemaining: BigInt(fields.remaining_size),\n\t\t\t\tcanceledSize: BigInt(fields.canceled_size),\n\t\t\t})),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static filledTakerOrderEventFromOnChain = (\n\t\teventOnChain: FilledTakerOrderEventOnChain\n\t): FilledTakerOrderEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\tconst baseAssetDelta =\n\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.base_asset_delta_bid)\n\t\t\t) -\n\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.base_asset_delta_ask)\n\t\t\t);\n\t\treturn {\n\t\t\tbaseAssetDelta,\n\t\t\taccountId: BigInt(fields.taker_account_id),\n\t\t\tcollateralDeltaUsd:\n\t\t\t\tCasting.IFixed.numberFromIFixed(BigInt(fields.taker_pnl)) -\n\t\t\t\tCasting.IFixed.numberFromIFixed(BigInt(fields.taker_fees)),\n\t\t\ttakerPnlUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.taker_pnl)\n\t\t\t),\n\t\t\ttakerFeesUsd: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.taker_fees)\n\t\t\t),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tside: Perpetuals.positionSide({ baseAssetAmount: baseAssetDelta }),\n\t\t\tquoteAssetDelta:\n\t\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\t\tBigInt(fields.quote_asset_delta_bid)\n\t\t\t\t) -\n\t\t\t\tCasting.IFixed.numberFromIFixed(\n\t\t\t\t\tBigInt(fields.quote_asset_delta_ask)\n\t\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static postedOrderEventFromOnChain = (\n\t\teventOnChain: PostedOrderEventOnChain\n\t): PostedOrderEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tsize: BigInt(fields.order_size),\n\t\t\torderId: BigInt(fields.order_id),\n\t\t\tside: Perpetuals.orderIdToSide(BigInt(fields.order_id)),\n\t\t\treduceOnly: fields.reduce_only,\n\t\t\texpiryTimestamp: !fields.expiration_timestamp_ms\n\t\t\t\t? undefined\n\t\t\t\t: BigInt(fields.expiration_timestamp_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static reducedOrderEventFromOnChain = (\n\t\teventOnChain: ReducedOrderEventOnChain\n\t): ReducedOrderEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tsizeChange: BigInt(fields.size_change),\n\t\t\torderId: BigInt(fields.order_id),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Stop Orders\n\t// =========================================================================\n\n\tpublic static createdStopOrderTicketEventFromOnChain = (\n\t\teventOnChain: CreatedStopOrderTicketEventOnChain\n\t): CreatedStopOrderTicketEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tticketId: Helpers.addLeadingZeroesToType(fields.ticket_id),\n\t\t\taccountId: BigInt(fields.account_id),\n\t\t\texecutors: fields.executors.map((executor) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(executor)\n\t\t\t),\n\t\t\tgas: BigInt(fields.gas),\n\t\t\tstopOrderType: Number(fields.stop_order_type),\n\t\t\tencryptedDetails: fields.encrypted_details,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static executedStopOrderTicketEventFromOnChain = (\n\t\teventOnChain: ExecutedStopOrderTicketEventOnChain\n\t): ExecutedStopOrderTicketEvent => {\n\t\tconst f = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t\t\texecutor: Helpers.addLeadingZeroesToType(f.executor),\n\t\t\taccountId: BigInt(f.account_id),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static deletedStopOrderTicketEventFromOnChain = (\n\t\teventOnChain: DeletedStopOrderTicketEventOnChain\n\t): DeletedStopOrderTicketEvent => {\n\t\tconst f = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t\t\texecutor: Helpers.addLeadingZeroesToType(f.executor),\n\t\t\taccountId: BigInt(f.account_id),\n\t\t\tsubAccountId: f.subaccount_id\n\t\t\t\t? Helpers.addLeadingZeroesToType(f.subaccount_id)\n\t\t\t\t: undefined,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static editedStopOrderTicketDetailsEventFromOnChain = (\n\t\teventOnChain: EditedStopOrderTicketDetailsEventOnChain\n\t): EditedStopOrderTicketDetailsEvent => {\n\t\tconst f = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t\t\tstopOrderType: Number(f.stop_order_type),\n\t\t\taccountId: BigInt(f.account_id),\n\t\t\tsubAccountId: f.subaccount_id\n\t\t\t\t? Helpers.addLeadingZeroesToType(f.subaccount_id)\n\t\t\t\t: undefined,\n\t\t\tencryptedDetails: f.encrypted_details,\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static editedStopOrderTicketExecutorEventFromOnChain = (\n\t\teventOnChain: EditedStopOrderTicketExecutorEventOnChain\n\t): EditedStopOrderTicketExecutorEvent => {\n\t\tconst f = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t\t\taccountId: BigInt(f.account_id),\n\t\t\tsubAccountId: f.subaccount_id\n\t\t\t\t? Helpers.addLeadingZeroesToType(f.subaccount_id)\n\t\t\t\t: undefined,\n\t\t\texecutors: f.executors.map((executor) =>\n\t\t\t\tHelpers.addLeadingZeroesToType(executor)\n\t\t\t),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// public static addedStopOrderTicketCollateralEventFromOnChain = (\n\t// \teventOnChain: AddedStopOrderTicketCollateralEventOnChain\n\t// ): AddedStopOrderTicketCollateralEvent => {\n\t// \tconst f = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t// \t\taccountId: BigInt(f.account_id),\n\t// \t\tsubAccountId: f.subaccount_id\n\t// \t\t\t? Helpers.addLeadingZeroesToType(f.subaccount_id)\n\t// \t\t\t: undefined,\n\t// \t\tcollateralToAllocate: BigInt(f.collateral_to_allocate),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\t// public static removedStopOrderTicketCollateralEventFromOnChain = (\n\t// \teventOnChain: RemovedStopOrderTicketCollateralEventOnChain\n\t// ): RemovedStopOrderTicketCollateralEvent => {\n\t// \tconst f = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tticketId: Helpers.addLeadingZeroesToType(f.ticket_id),\n\t// \t\taccountId: BigInt(f.account_id),\n\t// \t\tsubAccountId: f.subaccount_id\n\t// \t\t\t? Helpers.addLeadingZeroesToType(f.subaccount_id)\n\t// \t\t\t: undefined,\n\t// \t\tcollateralToRemove: BigInt(f.collateral_to_remove),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\t// public static transferredDeallocatedCollateralEventFromOnChain = (\n\t// \teventOnChain: TransferredDeallocatedCollateralEventOnChain\n\t// ): TransferredDeallocatedCollateralEvent => {\n\t// \tconst f = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tchId: Helpers.addLeadingZeroesToType(f.ch_id),\n\t// \t\tobjectId: Helpers.addLeadingZeroesToType(f.obj_id),\n\t// \t\taccountId: BigInt(f.account_id),\n\t// \t\tcollateral: BigInt(f.collateral),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\t// public static receivedCollateralEventFromOnChain = (\n\t// \teventOnChain: ReceivedCollateralEventOnChain\n\t// ): ReceivedCollateralEvent => {\n\t// \tconst f = eventOnChain.parsedJson;\n\t// \treturn {\n\t// \t\tobjectId: Helpers.addLeadingZeroesToType(f.obj_id),\n\t// \t\taccountId: BigInt(f.account_id),\n\t// \t\tcollateral: BigInt(f.collateral),\n\t// \t\ttimestamp: Number(eventOnChain.timestampMs),\n\t// \t\ttxnDigest: eventOnChain.id.txDigest,\n\t// \t\ttype: eventOnChain.type,\n\t// \t};\n\t// };\n\n\t// =========================================================================\n\t// Twap\n\t// =========================================================================\n\n\tpublic static updatedPremiumTwapEventFromOnChain = (\n\t\teventOnChain: UpdatedPremiumTwapEventOnChain\n\t): UpdatedPremiumTwapEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tindexPrice: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.index_price)\n\t\t\t),\n\t\t\tbookPrice: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.book_price)\n\t\t\t),\n\t\t\tpremiumTwap: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.premium_twap)\n\t\t\t),\n\t\t\tpremiumTwapLastUpdateMs: Number(fields.premium_twap_last_upd_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static updatedSpreadTwapEventFromOnChain = (\n\t\teventOnChain: UpdatedSpreadTwapEventOnChain\n\t): UpdatedSpreadTwapEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tbookPrice: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.book_price)\n\t\t\t),\n\t\t\tindexPrice: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.index_price)\n\t\t\t),\n\t\t\tspreadTwap: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.spread_twap)\n\t\t\t),\n\t\t\tspreadTwapLastUpdateMs: Number(fields.spread_twap_last_upd_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Funding\n\t// =========================================================================\n\n\tpublic static updatedFundingEventFromOnChain = (\n\t\teventOnChain: UpdatedFundingEventOnChain\n\t): UpdatedFundingEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmarketId: Helpers.addLeadingZeroesToType(fields.ch_id),\n\t\t\tcumFundingRateLong: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.cum_funding_rate_long)\n\t\t\t),\n\t\t\tcumFundingRateShort: Casting.IFixed.numberFromIFixed(\n\t\t\t\tBigInt(fields.cum_funding_rate_short)\n\t\t\t),\n\t\t\tfundingLastUpdateMs: Number(fields.funding_last_upd_ms),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import { Balance, Helpers } from \"../../..\";\nimport {\n\tRouterCompleteTradeRoute,\n\tRouterTradeEvent,\n\tRouterTradeRoute,\n} from \"../routerTypes\";\nimport { RouterTradeEventOnChain } from \"./routerApiCastingTypes\";\n\nexport class RouterApiCasting {\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static routerTradeEventFromOnChain = (\n\t\teventOnChain: RouterTradeEventOnChain\n\t): RouterTradeEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\ttrader: fields.swapper,\n\t\t\tcoinInType: fields.type_in,\n\t\t\tcoinInAmount: BigInt(fields.amount_in),\n\t\t\tcoinOutType: fields.type_out,\n\t\t\tcoinOutAmount: BigInt(fields.amount_out),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import { Balance, DecimalsScalar, NormalizedBalance } from \"../../types\";\n\n/**\n * The `FixedUtils` class provides utilities for fixed-point arithmetic\n * with a standard 18-decimal precision, along with some convenience\n * methods for normalizing/un-normalizing amounts based on token decimals.\n */\nexport class FixedUtils {\n\t/**\n\t * Represents 1.0 in 18-decimal fixed math as a float: 1_000_000_000_000_000_000.\n\t */\n\tpublic static readonly fixedOneN: number = 1_000_000_000_000_000_000;\n\n\t/**\n\t * Represents 1.0 in 18-decimal fixed math as a bigint: 1000000000000000000n.\n\t */\n\tpublic static readonly fixedOneB: bigint = BigInt(\"1000000000000000000\");\n\n\t/**\n\t * Represents 1.0 in 9-decimal fixed math as a float: 1_000_000_000.\n\t */\n\tpublic static readonly fixedOneN9 = 1_000_000_000;\n\n\t/**\n\t * Represents 1.0 in 9-decimal fixed math as a bigint: 1000000000n.\n\t */\n\tpublic static readonly fixedOneB9 = BigInt(1_000_000_000);\n\n\t// These methods relate to direct cast/un-cast logic for on-chain usage:\n\n\t/**\n\t * Directly convert an on-chain `u64` (stored as a bigint) into a float, effectively no scaling.\n\t *\n\t * @param n - The on-chain number as a bigint.\n\t * @returns The converted number as a float.\n\t */\n\tpublic static readonly convertFromInt = (n: OnChainNumber): LocalNumber =>\n\t\tNumber(n);\n\n\t/**\n\t * Convert a floating number back to an on-chain integer (bigint),\n\t * truncating decimals.\n\t *\n\t * @param n - The local float.\n\t * @returns The truncated bigint.\n\t */\n\tpublic static readonly convertToInt = (n: LocalNumber): OnChainNumber =>\n\t\tBigInt(Math.floor(n));\n\n\t/**\n\t * Converts a fixed-18 on-chain number to a floating local number by dividing by `fixedOneN`.\n\t *\n\t * @param n - The on-chain 18-decimal fixed number (as a bigint).\n\t * @returns A float representing the unscaled value.\n\t */\n\tpublic static readonly directCast = (n: OnChainNumber): LocalNumber =>\n\t\tNumber(n) / FixedUtils.fixedOneN;\n\n\t/**\n\t * Converts a floating local number to an on-chain 18-decimal fixed bigint by multiplying by `fixedOneN`.\n\t *\n\t * @param n - The local float to be scaled.\n\t * @returns The scaled 18-decimal fixed as a bigint.\n\t */\n\tpublic static readonly directUncast = (n: LocalNumber): OnChainNumber =>\n\t\tBigInt(Math.floor(n * FixedUtils.fixedOneN));\n\n\t/**\n\t * Returns the complement of the number in `[0,1]`, i.e., `1 - n`.\n\t * If `n` is negative, it's treated as zero; if `n` > 1, also treated as zero for the complement.\n\t *\n\t * @param n - The local float in [0,1].\n\t * @returns The complement of `n` in [0,1].\n\t */\n\tpublic static readonly complement = (n: LocalNumber) =>\n\t\tMath.max(0, 1 - Math.max(0, n));\n\n\t/**\n\t * Multiplies a raw integer `amount` by a `decimalsScalar` to produce\n\t * a \"normalized\" form. E.g., if decimals = 9, we store it as 10^9 scale.\n\t *\n\t * @param decimalsScalar - The scale factor for the coin (e.g., 1e9).\n\t * @param amount - The raw integer (balance) to be scaled.\n\t * @returns The scaled (normalized) amount as a `number`.\n\t */\n\tpublic static readonly normalizeAmount = (\n\t\tdecimalsScalar: DecimalsScalar,\n\t\tamount: Balance\n\t): NormalizedBalance => amount * decimalsScalar;\n\n\t/**\n\t * Divides a normalized amount by the `decimalsScalar` to get back the\n\t * raw on-chain integer. This is typically used after floating computations.\n\t *\n\t * @param decimalsScalar - The scale factor for the coin (e.g., 1e9).\n\t * @param normalizedAmount - The scaled amount to reduce.\n\t * @returns The raw integer balance.\n\t */\n\tpublic static readonly unnormalizeAmount = (\n\t\tdecimalsScalar: DecimalsScalar,\n\t\tnormalizedAmount: NormalizedBalance\n\t): Balance => normalizedAmount / decimalsScalar;\n\n\t/**\n\t * Directly cast a `Balance` to an 18-decimal float, factoring in token decimals.\n\t *\n\t * @param decimalsScalar - The token's decimal scale factor.\n\t * @param amount - The raw integer `Balance`.\n\t * @returns A float representing the 18-decimal scale cast.\n\t */\n\tpublic static readonly castAndNormalize = (\n\t\tdecimalsScalar: DecimalsScalar,\n\t\tamount: Balance\n\t): LocalNumber =>\n\t\tFixedUtils.directCast(\n\t\t\tFixedUtils.normalizeAmount(decimalsScalar, amount)\n\t\t);\n\n\t/**\n\t * Reverse the cast of a normalized float back to a raw `Balance`,\n\t * factoring in the token decimals.\n\t *\n\t * @param decimalsScalar - The token's decimal scale factor.\n\t * @param normalizedAmount - A local float in 18-decimal domain.\n\t * @returns A raw integer `Balance`.\n\t */\n\tpublic static readonly uncastAndUnnormalize = (\n\t\tdecimalsScalar: DecimalsScalar,\n\t\tnormalizedAmount: LocalNumber\n\t): Balance =>\n\t\tFixedUtils.unnormalizeAmount(\n\t\t\tdecimalsScalar,\n\t\t\tFixedUtils.directUncast(normalizedAmount)\n\t\t);\n}\n\n// Distinguishes on-chain numeric usage in the codebase.\n\n/**\n * A numeric type used on chain, typically fixed 18 decimals or direct u64.\n */\nexport type OnChainNumber = bigint;\n/**\n * A local floating value for user calculations or UI representation.\n */\nexport type LocalNumber = number;\n/**\n * A scalar is any fixed 18-point number. They are stored on chain as a u128 and are always directly cast.\n */\nexport type OnChainScalar = OnChainNumber;\n","import type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\nimport {\n\tValidatorConfigObject,\n\tValidatorOperationCapObject,\n\tUnstakedEvent,\n\tUnstakeRequestedEvent,\n\tStakedEvent,\n\tEpochWasChangedEvent,\n\tStakedSuiVaultStateObject,\n\tObjectId,\n\tSuiAddress,\n\tAnyObjectType,\n\tIFixedAsString,\n} from \"../../../types\";\nimport {\n\tEpochWasChangedEventOnChain,\n\tStakedEventOnChain,\n\tStakedSuiVaultStateV1FieldsOnChain,\n\tUnstakeRequestedEventOnChain,\n\tUnstakedEventOnChain,\n\tValidatorOperationCapFieldsOnChain,\n} from \"./stakingApiCastingTypes\";\nimport { Helpers } from \"../../../general/utils\";\nimport { FixedUtils } from \"../../../general/utils/fixedUtils\";\n\nexport class StakingApiCasting {\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic static validatorOperationCapObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): ValidatorOperationCapObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as ValidatorOperationCapFieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tauthorizerValidatorAddress: Helpers.addLeadingZeroesToType(\n\t\t\t\tfields.authorizer_validator_address\n\t\t\t),\n\t\t};\n\t};\n\n\tpublic static stakedSuiVaultStateObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): StakedSuiVaultStateObject => {\n\t\tconst objectId = Helpers.getObjectId(data);\n\t\tconst objectType = Helpers.getObjectType(data);\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as StakedSuiVaultStateV1FieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectId,\n\t\t\tobjectType,\n\t\t\tatomicUnstakeSuiReservesTargetValue: BigInt(\n\t\t\t\tfields.protocol_config.fields\n\t\t\t\t\t.atomic_unstake_sui_reserves_target_value\n\t\t\t),\n\t\t\tatomicUnstakeSuiReserves: BigInt(\n\t\t\t\tfields.atomic_unstake_sui_reserves\n\t\t\t),\n\t\t\tminAtomicUnstakeFee: BigInt(\n\t\t\t\tfields.protocol_config.fields.atomic_unstake_protocol_fee.fields\n\t\t\t\t\t.min_fee\n\t\t\t),\n\t\t\tmaxAtomicUnstakeFee: BigInt(\n\t\t\t\tfields.protocol_config.fields.atomic_unstake_protocol_fee.fields\n\t\t\t\t\t.max_fee\n\t\t\t),\n\t\t\ttotalSuiAmount: BigInt(fields.total_sui_amount),\n\t\t\ttotalRewardsAmount: BigInt(fields.total_rewards_amount),\n\t\t\tactiveEpoch: BigInt(fields.active_epoch),\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static stakedEventFromOnChain = (\n\t\teventOnChain: StakedEventOnChain\n\t): StakedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tsuiId: Helpers.addLeadingZeroesToType(fields.sui_id),\n\t\t\tstakedSuiId: Helpers.addLeadingZeroesToType(fields.staked_sui_id),\n\t\t\tstaker: Helpers.addLeadingZeroesToType(fields.staker),\n\t\t\tvalidatorAddress: Helpers.addLeadingZeroesToType(fields.validator),\n\t\t\tepoch: BigInt(fields.epoch),\n\t\t\tsuiStakeAmount: BigInt(fields.sui_amount),\n\t\t\tvalidatorFee: FixedUtils.directCast(BigInt(fields.validator_fee)),\n\t\t\tisRestaked: fields.is_restaked,\n\t\t\treferrer: fields.referrer ? fields.referrer : undefined,\n\t\t\tafSuiId: Helpers.addLeadingZeroesToType(fields.afsui_id),\n\t\t\tafSuiAmount: BigInt(fields.afsui_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static unstakedEventFromOnChain = (\n\t\teventOnChain: UnstakedEventOnChain\n\t): UnstakedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tafSuiId: Helpers.addLeadingZeroesToType(fields.afsui_id),\n\t\t\tsuiId: Helpers.addLeadingZeroesToType(fields.sui_id),\n\t\t\trequester: Helpers.addLeadingZeroesToType(fields.requester),\n\t\t\tepoch: BigInt(fields.epoch),\n\t\t\tprovidedAfSuiAmount: BigInt(fields.provided_afsui_amount),\n\t\t\treturnedSuiAmount: BigInt(fields.returned_sui_amount),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static unstakeRequestedEventFromOnChain = (\n\t\teventOnChain: UnstakeRequestedEventOnChain\n\t): UnstakeRequestedEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tafSuiId: Helpers.addLeadingZeroesToType(fields.afsui_id),\n\t\t\tprovidedAfSuiAmount: BigInt(fields.provided_afsui_amount),\n\t\t\trequester: Helpers.addLeadingZeroesToType(fields.requester),\n\t\t\tepoch: BigInt(fields.epoch),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\nimport {\n\tMixSuiFrensEvent,\n\tStakeSuiFrenEvent,\n\tStakedSuiFrenMetadataV1Object,\n\tUnstakeSuiFrenEvent,\n\tSuiFrenAttributes,\n\tCapyLabsAppObject,\n\tSuiFrenVaultStateV1Object,\n\tSuiFrenAccessoryObject,\n\tHarvestSuiFrenFeesEvent,\n\tPartialSuiFrenObject,\n\tStakedSuiFrenPositionObject,\n} from \"../suiFrensTypes\";\nimport {\n\tMixSuiFrensEventOnChain,\n\tStakeSuiFrenEventOnChain,\n\tUnstakeSuiFrenEventOnChain,\n\tSuiFrenFieldsOnChain,\n\tSuiFrenDisplayOnChain,\n\tCapyLabsAppFieldsOnChain,\n\tSuiFrenAccessoryDisplayOnChain,\n\tSuiFrenAccessoryFieldsOnChain,\n\tStakedSuiFrenMetadataV1FieldsOnChain,\n\tSuiFrenVaultStateV1FieldsOnChain,\n\tHarvestSuiFrenFeesEventOnChain,\n\tStakedSuiFrenPositionFieldsOnChain,\n} from \"./suiFrensApiCastingTypes\";\nimport { Helpers } from \"../../../general/utils\";\nexport class SuiFrensApiCasting {\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// TODO: handle leading 0s for ALL castings\n\n\tpublic static capyLabsAppObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): CapyLabsAppObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as CapyLabsAppFieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tmixingLimit: BigInt(fields.mixing_limit),\n\t\t\tcoolDownPeriodEpochs: BigInt(fields.cool_down_period),\n\t\t\tmixingPrice: BigInt(fields.mixing_price),\n\t\t\tsuiProfits: BigInt(fields.profits),\n\t\t};\n\t};\n\n\tpublic static partialSuiFrenObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): PartialSuiFrenObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(data) as SuiFrenFieldsOnChain;\n\t\tconst display = Helpers.getObjectDisplay(data)\n\t\t\t.data as unknown as SuiFrenDisplayOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tgeneration: BigInt(fields.generation),\n\t\t\tbirthdate: Number(fields.birthdate),\n\t\t\tcohort: BigInt(fields.cohort),\n\t\t\tgenes: fields.genes.map((gene) => BigInt(gene)),\n\t\t\tattributes: {\n\t\t\t\tskin: fields.attributes[0],\n\t\t\t\tmain: fields.attributes[1],\n\t\t\t\tsecondary: fields.attributes[2],\n\t\t\t\texpression: fields.attributes[3],\n\t\t\t\tears: fields.attributes[4],\n\t\t\t} as SuiFrenAttributes,\n\t\t\tbirthLocation: fields.birth_location,\n\t\t\tdisplay: {\n\t\t\t\tlink: display.link,\n\t\t\t\timageUrl: display.image_url,\n\t\t\t\tdescription: display.description,\n\t\t\t\tprojectUrl: display.project_url,\n\t\t\t},\n\t\t};\n\t};\n\n\tpublic static partialSuiFrenObjectFromStakedSuiFrenMetadataV1ObjectSuiObjectResponse =\n\t\t(data: SuiObjectResponse): PartialSuiFrenObject => {\n\t\t\tconst fields = Helpers.getObjectFields(\n\t\t\t\tdata\n\t\t\t) as StakedSuiFrenMetadataV1FieldsOnChain;\n\t\t\tconst display = Helpers.getObjectDisplay(data)\n\t\t\t\t.data as unknown as SuiFrenDisplayOnChain;\n\n\t\t\treturn {\n\t\t\t\tobjectType: fields.suifren_type,\n\t\t\t\tobjectId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t\t\tgeneration: BigInt(fields.generation),\n\t\t\t\tbirthdate: Number(fields.birthdate),\n\t\t\t\tcohort: BigInt(fields.cohort),\n\t\t\t\tgenes: fields.genes.map((gene) => BigInt(gene)),\n\t\t\t\tattributes: {\n\t\t\t\t\tskin: fields.attributes[0],\n\t\t\t\t\tmain: fields.attributes[1],\n\t\t\t\t\tsecondary: fields.attributes[2],\n\t\t\t\t\texpression: fields.attributes[3],\n\t\t\t\t\tears: fields.attributes[4],\n\t\t\t\t} as SuiFrenAttributes,\n\t\t\t\tbirthLocation: fields.birth_location,\n\t\t\t\tdisplay: {\n\t\t\t\t\tlink: display.link,\n\t\t\t\t\timageUrl: display.image_url.replace(\"mainnet\", \"testnet\"),\n\t\t\t\t\tdescription: display.description,\n\t\t\t\t\tprojectUrl: display.project_url,\n\t\t\t\t},\n\t\t\t};\n\t\t};\n\n\tpublic static stakedSuiFrenMetadataV1ObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): StakedSuiFrenMetadataV1Object => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as StakedSuiFrenMetadataV1FieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tsuiFrenId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t\tcollectedFees: BigInt(fields.collected_fees),\n\t\t\tautoStakeFees: fields.auto_stake_fees,\n\t\t\tmixFee: BigInt(fields.mix_fee),\n\t\t\tfeeIncrementPerMix: BigInt(fields.fee_increment_per_mix),\n\t\t\tminRemainingMixesToKeep: BigInt(fields.min_remaining_mixes_to_keep),\n\t\t};\n\t};\n\n\tpublic static partialSuiFrenAndStakedSuiFrenMetadataV1ObjectFromSuiObjectResponse =\n\t\t(\n\t\t\tdata: SuiObjectResponse\n\t\t): {\n\t\t\tstakedSuiFrenMetadata: StakedSuiFrenMetadataV1Object;\n\t\t\tpartialSuiFren: PartialSuiFrenObject;\n\t\t} => {\n\t\t\treturn {\n\t\t\t\tstakedSuiFrenMetadata:\n\t\t\t\t\tthis.stakedSuiFrenMetadataV1ObjectFromSuiObjectResponse(\n\t\t\t\t\t\tdata\n\t\t\t\t\t),\n\t\t\t\tpartialSuiFren:\n\t\t\t\t\tthis.partialSuiFrenObjectFromStakedSuiFrenMetadataV1ObjectSuiObjectResponse(\n\t\t\t\t\t\tdata\n\t\t\t\t\t),\n\t\t\t};\n\t\t};\n\n\tpublic static stakedSuiFrenPositionFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): StakedSuiFrenPositionObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as StakedSuiFrenPositionFieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tsuiFrenId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t};\n\t};\n\n\tpublic static suiFrenVaultStateV1ObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): SuiFrenVaultStateV1Object => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as SuiFrenVaultStateV1FieldsOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\ttotalMixes: BigInt(fields.mixed),\n\t\t\tstakedSuiFrens: BigInt(fields.suifrens_metadata.fields.size),\n\t\t};\n\t};\n\n\tpublic static accessoryObjectFromSuiObjectResponse = (\n\t\tdata: SuiObjectResponse\n\t): SuiFrenAccessoryObject => {\n\t\tconst objectType = Helpers.getObjectType(data);\n\n\t\tconst fields = Helpers.getObjectFields(\n\t\t\tdata\n\t\t) as SuiFrenAccessoryFieldsOnChain;\n\t\tconst display = Helpers.getObjectDisplay(data)\n\t\t\t.data as unknown as SuiFrenAccessoryDisplayOnChain;\n\n\t\treturn {\n\t\t\tobjectType,\n\t\t\tobjectId: Helpers.getObjectId(data),\n\t\t\tname: fields.name,\n\t\t\ttype: fields.type,\n\t\t\timageUrl: display.image_url,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic static harvestSuiFrenFeesEventFromOnChain = (\n\t\teventOnChain: HarvestSuiFrenFeesEventOnChain\n\t): HarvestSuiFrenFeesEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tharvester: Helpers.addLeadingZeroesToType(fields.issuer),\n\t\t\tfees: BigInt(fields.fees),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static mixSuiFrensEventFromOnChain = (\n\t\teventOnChain: MixSuiFrensEventOnChain\n\t): MixSuiFrensEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tmixer: Helpers.addLeadingZeroesToType(fields.issuer),\n\t\t\tparentOneId: Helpers.addLeadingZeroesToType(fields.parent_one_id),\n\t\t\tparentTwoId: Helpers.addLeadingZeroesToType(fields.parent_two_id),\n\t\t\tchildId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t\tfee: BigInt(fields.fee),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static stakeSuiFrenEventFromOnChain = (\n\t\teventOnChain: StakeSuiFrenEventOnChain\n\t): StakeSuiFrenEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tstaker: Helpers.addLeadingZeroesToType(fields.issuer),\n\t\t\tsuiFrenId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t\t// TODO: generalize casting of event types with passing of\n\t\t\t// timestamp and txnDigest (create wrapper)\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n\n\tpublic static unstakeSuiFrenEventFromOnChain = (\n\t\teventOnChain: UnstakeSuiFrenEventOnChain\n\t): UnstakeSuiFrenEvent => {\n\t\tconst fields = eventOnChain.parsedJson;\n\t\treturn {\n\t\t\tunstaker: Helpers.addLeadingZeroesToType(fields.issuer),\n\t\t\tsuiFrenId: Helpers.addLeadingZeroesToType(fields.suifren_id),\n\t\t\tfees: BigInt(fields.fees),\n\t\t\ttimestamp: Number(eventOnChain.timestampMs),\n\t\t\ttxnDigest: eventOnChain.id.txDigest,\n\t\t\ttype: eventOnChain.type,\n\t\t};\n\t};\n}\n","import type {\n\tDisplayFieldsResponse,\n\tSuiObjectResponse,\n} from \"@mysten/sui/jsonRpc\";\nimport {\n\tKioskOwnerCapObject,\n\tNft,\n\tNftDisplay,\n\tNftDisplayOther,\n\tNftDisplaySuggested,\n\tNftInfo,\n} from \"../types\";\nimport { Helpers } from \"../utils/helpers\";\n\nexport class NftsApiCasting {\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic static nftsFromSuiObjects = (\n\t\tobjects: SuiObjectResponse[]\n\t): Nft[] => {\n\t\tconst nfts = objects.filter((object) => object.data?.display);\n\t\treturn nfts\n\t\t\t.map((nft) => NftsApiCasting.nftFromSuiObject(nft))\n\t\t\t.filter(\n\t\t\t\t(nft) =>\n\t\t\t\t\tObject.keys(nft.display.suggested).length > 0 ||\n\t\t\t\t\tObject.keys(nft.display.other).length > 0\n\t\t\t);\n\t};\n\n\tpublic static nftFromSuiObject = (object: SuiObjectResponse): Nft => {\n\t\tconst info = this.nftInfoFromSuiObject(object);\n\n\t\tconst displayFields = Helpers.getObjectDisplay(object);\n\t\tconst display = this.nftDisplayFromDisplayFields(displayFields);\n\n\t\treturn {\n\t\t\tinfo,\n\t\t\tdisplay,\n\t\t};\n\t};\n\n\tpublic static kioskOwnerCapFromSuiObject = (\n\t\tobject: SuiObjectResponse\n\t): KioskOwnerCapObject => {\n\t\tconst fields = Helpers.getObjectFields(object);\n\t\tconst objectId = Helpers.getObjectId(object);\n\t\tconst objectType = Helpers.getObjectType(object);\n\t\treturn {\n\t\t\tobjectId,\n\t\t\tobjectType,\n\t\t\tkioskObjectId: Helpers.addLeadingZeroesToType(fields.for),\n\t\t};\n\t};\n\n\tpublic static kioskOwnerCapFromPersonalKioskCapSuiObject = (\n\t\tobject: SuiObjectResponse\n\t): KioskOwnerCapObject => {\n\t\tconst fields = Helpers.getObjectFields(object);\n\t\tconst objectId = Helpers.getObjectId(object);\n\t\tconst objectType = Helpers.getObjectType(object);\n\t\treturn {\n\t\t\tobjectId,\n\t\t\tobjectType,\n\t\t\tkioskObjectId: Helpers.addLeadingZeroesToType(\n\t\t\t\tfields.cap.fields.for\n\t\t\t),\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tprivate static nftInfoFromSuiObject = (\n\t\tobject: SuiObjectResponse\n\t): NftInfo => {\n\t\tconst objectType = Helpers.getObjectType(object);\n\t\tconst objectId = Helpers.getObjectId(object);\n\n\t\tif (!objectId || !objectType)\n\t\t\tthrow new Error(\n\t\t\t\t\"unable to obtain object info from sui object response\"\n\t\t\t);\n\n\t\treturn {\n\t\t\tobjectId,\n\t\t\tobjectType,\n\t\t};\n\t};\n\n\tprivate static nftDisplayFromDisplayFields = (\n\t\tdisplayFields: DisplayFieldsResponse\n\t): NftDisplay => {\n\t\tconst fields = displayFields.data;\n\t\tif (\n\t\t\tfields === null ||\n\t\t\tfields === undefined ||\n\t\t\tdisplayFields.error !== null\n\t\t)\n\t\t\treturn {\n\t\t\t\tsuggested: {},\n\t\t\t\tother: {},\n\t\t\t};\n\n\t\tconst suggestedFields: {\n\t\t\toffChain: keyof NftDisplaySuggested;\n\t\t\tonChain: string;\n\t\t}[] = [\n\t\t\t{\n\t\t\t\tonChain: \"name\",\n\t\t\t\toffChain: \"name\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChain: \"link\",\n\t\t\t\toffChain: \"link\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChain: \"image_url\",\n\t\t\t\toffChain: \"imageUrl\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChain: \"description\",\n\t\t\t\toffChain: \"description\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChain: \"project_url\",\n\t\t\t\toffChain: \"projectUrl\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tonChain: \"creator\",\n\t\t\t\toffChain: \"creator\",\n\t\t\t},\n\t\t];\n\n\t\tlet suggested: NftDisplaySuggested = {};\n\t\tlet other: NftDisplayOther = Helpers.deepCopy(fields);\n\n\t\tfor (const field of suggestedFields) {\n\t\t\tif (!(field.onChain in other)) continue;\n\n\t\t\tsuggested[field.offChain] = other[field.onChain];\n\t\t\tdelete other[field.onChain];\n\t\t}\n\n\t\treturn {\n\t\t\tsuggested,\n\t\t\tother,\n\t\t};\n\t};\n}\n","import { Byte, IFixed } from \"../types\";\nimport { Casting } from \"./casting\";\n\n/**\n * The `IFixedUtils` class provides support for signed 18-decimal fixed math,\n * referred to as \"IFixed\" in the Aftermath codebase. An `IFixed` value\n * is a bigint that includes sign bit manipulation.\n */\nexport class IFixedUtils {\n\t/**\n\t * The representation of 1.0 in the IFixed format, i.e. 1e18.\n\t */\n\tpublic static readonly ONE: IFixed = BigInt(1_000_000_000_000_000_000);\n\n\t/**\n\t * The greatest bit in a 256-bit representation. This is used to indicate negative values in some approaches.\n\t */\n\tpublic static readonly GREATEST_BIT: IFixed = BigInt(1) << BigInt(255);\n\n\t/**\n\t * A mask that can be used to flip or remove the greatest bit in a 256-bit number.\n\t */\n\tpublic static readonly NOT_GREATEST_BIT: IFixed =\n\t\t(BigInt(1) << BigInt(255)) - BigInt(1);\n\n\t/**\n\t * Converts an IFixed bigint into a floating-point number, extracting both the integer\n\t * and decimal portions. For negative values, the sign bit is checked and value is negated.\n\t *\n\t * @param value - The IFixed value (signed 18-decimal) as a bigint.\n\t * @returns A standard JavaScript number with fractional parts intact.\n\t */\n\tpublic static numberFromIFixed = (value: IFixed): number => {\n\t\tconst absVal = this.abs(value);\n\t\tconst integerPart = Number(absVal / this.ONE);\n\t\tconst decimalPart = Number(absVal % this.ONE) / Number(this.ONE);\n\t\treturn this.sign(value) * (integerPart + decimalPart);\n\t};\n\n\t/**\n\t * Converts a floating-point number into an IFixed bigint with 18 decimals of precision.\n\t * Negative numbers have the sign bit set.\n\t *\n\t * @param value - The JavaScript number to convert.\n\t * @returns The resulting IFixed bigint in on-chain-compatible format.\n\t */\n\tpublic static iFixedFromNumber = (value: number): IFixed => {\n\t\tconst newValue = BigInt(Math.floor(Math.abs(value) * Number(this.ONE)));\n\t\tif (value < 0) return this.neg(newValue);\n\t\treturn newValue;\n\t};\n\n\t/**\n\t * Returns the absolute value of an IFixed number. If the value is negative,\n\t * it's converted to its positive counterpart by flipping bits.\n\t *\n\t * @param value - The signed IFixed number as a bigint.\n\t * @returns The absolute value in IFixed.\n\t */\n\tpublic static abs = (value: IFixed): IFixed => {\n\t\tif (value >= this.GREATEST_BIT) return this.neg(value);\n\t\treturn value;\n\t};\n\n\t/**\n\t * Determines the sign of an IFixed number.\n\t * - If >= GREATEST_BIT, it's negative (-1).\n\t * - If exactly 0, sign is 0.\n\t * - Otherwise, sign is +1.\n\t *\n\t * @param value - The IFixed number to check.\n\t * @returns `-1`, `0`, or `1` based on the sign.\n\t */\n\tpublic static sign = (value: IFixed): number => {\n\t\tif (value >= this.GREATEST_BIT) return -1;\n\t\tif (value === BigInt(0)) return 0;\n\t\treturn 1;\n\t};\n\n\t/**\n\t * Negates an IFixed number by flipping bits. This effectively does `-value` for the signed 18-dec representation.\n\t *\n\t * @param value - The IFixed number to negate.\n\t * @returns The negated IFixed number as a bigint.\n\t */\n\tpublic static neg = (value: IFixed): IFixed => {\n\t\treturn (\n\t\t\t((value ^ this.NOT_GREATEST_BIT) + BigInt(1)) ^ this.GREATEST_BIT\n\t\t);\n\t};\n\n\t/**\n\t * Constructs an IFixed number from an array of bytes in little-endian format.\n\t * The sign bit might be set if the top bit is `1`.\n\t *\n\t * @param bytes - The byte array representing the IFixed number.\n\t * @returns The IFixed bigint.\n\t */\n\tpublic static iFixedFromBytes = (bytes: Byte[]): IFixed => {\n\t\treturn Casting.bigIntFromBytes(bytes);\n\t};\n\n\t/**\n\t * Constructs an IFixed number from an array of stringified bytes,\n\t * each representing a decimal numeric value (e.g., `\"255\"`, `\"0\"`).\n\t *\n\t * @param bytes - An array of string bytes.\n\t * @returns The IFixed bigint.\n\t */\n\tpublic static iFixedFromStringBytes = (bytes: string[]): IFixed => {\n\t\treturn this.iFixedFromBytes(Casting.bytesFromStringBytes(bytes));\n\t};\n}\n","import { type BcsType, bcs } from \"@mysten/sui/bcs\";\nimport type { SuiObjectResponse } from \"@mysten/sui/jsonRpc\";\nimport { Helpers } from \"../..\";\nimport { FarmsApiCasting } from \"../../packages/farms/api/farmsApiCasting\";\nimport { FaucetApiCasting } from \"../../packages/faucet/api/faucetApiCasting\";\nimport { NftAmmApiCasting } from \"../../packages/nftAmm/api/nftAmmApiCasting\";\nimport { PerpetualsApiCasting } from \"../../packages/perpetuals/api/perpetualsApiCasting\";\nimport { PoolsApiCasting } from \"../../packages/pools/api/poolsApiCasting\";\nimport { RouterApiCasting } from \"../../packages/router/api/routerApiCasting\";\nimport { StakingApiCasting } from \"../../packages/staking/api/stakingApiCasting\";\nimport { SuiFrensApiCasting } from \"../../packages/suiFrens/api/suiFrensApiCasting\";\nimport { NftsApiCasting } from \"../nfts/nftsApiCasting\";\nimport type { Byte, Percentage, SuiAddress } from \"../types\";\nimport { FixedUtils } from \"./fixedUtils\";\nimport { IFixedUtils } from \"./iFixedUtils\";\n\n/**\n * A central utility class for casting and conversion routines across\n * different Aftermath modules. Provides both direct numeric transformations\n * (e.g., fixed-point arithmetic) and advanced BCS-based object deserialization.\n */\nexport class Casting {\n // =========================================================================\n // Api Casting\n // =========================================================================\n\n /**\n * Casting utilities for pools-related data (AMM pools, liquidity, etc.).\n */\n public static pools = PoolsApiCasting;\n /**\n * Casting utilities for SuiFrens-related data or objects.\n */\n public static suiFrens = SuiFrensApiCasting;\n /**\n * Casting utilities for faucet-related data, typically for devnet or testnet tokens.\n */\n public static faucet = FaucetApiCasting;\n /**\n * Casting utilities for staking-related data (positions, pools, etc.).\n */\n public static staking = StakingApiCasting;\n\n /**\n * Casting utilities for NFT AMM objects and events.\n */\n public static nftAmm = NftAmmApiCasting;\n /**\n * Casting utilities for router-based data, such as trade routes and DEX interactions.\n */\n public static router = RouterApiCasting;\n /**\n * Casting utilities for perpetuals/futures data.\n */\n public static perpetuals = PerpetualsApiCasting;\n /**\n * Casting utilities for farming data (yield farms, locked positions, etc.).\n */\n public static farms = FarmsApiCasting;\n /**\n * Casting utilities for NFT structures and data retrieval logic.\n */\n public static nfts = NftsApiCasting;\n\n // =========================================================================\n // Constants\n // =========================================================================\n\n /**\n * Reference to the standard fixed-point arithmetic utilities (18 decimals).\n */\n public static Fixed = FixedUtils;\n /**\n * Reference to the intermediate fixed type (signed 18 decimals).\n */\n public static IFixed = IFixedUtils;\n\n /**\n * The maximum unsigned 64-bit integer value as a bigint (0xFFFFFFFFFFFFFFFF).\n */\n public static u64MaxBigInt: bigint = BigInt(\"0xFFFFFFFFFFFFFFFF\");\n\n /**\n * The maximum signed 64-bit integer value as a bigint.\n */\n public static i64MaxBigInt: bigint = BigInt(\"9223372036854775807\");\n\n // =========================================================================\n // Functions\n // =========================================================================\n\n // =========================================================================\n // Fixed / IFixed\n // =========================================================================\n\n /**\n * Converts a floating-point number to a fixed bigint with 18 decimals.\n * For example, `1.23` => `1230000000000000000n` if we consider 18 decimals.\n *\n * @param a - The number to convert.\n * @returns A bigint representing the number in 18-decimal fixed format.\n */\n public static numberToFixedBigInt = (a: number): bigint =>\n BigInt(Math.floor(a * this.Fixed.fixedOneN));\n\n /**\n * Converts an 18-decimal fixed bigint to a floating-point number.\n * For example, `1230000000000000000n` => `1.23`.\n *\n * @param a - The fixed bigint to convert.\n * @returns A floating-point representation of the 18-decimal fixed value.\n */\n public static bigIntToFixedNumber = (a: bigint): number =>\n Number(a) / this.Fixed.fixedOneN;\n\n /**\n * Scales a bigint by a floating-point scalar. For instance, a scalar of 0.5\n * and a bigint of 100 => 50n.\n *\n * @param scalar - The floating-point multiplier (e.g., 0.5).\n * @param int - The bigint to be scaled.\n * @returns A bigint result after scaling.\n */\n public static scaleNumberByBigInt = (scalar: number, int: bigint): bigint =>\n BigInt(Math.floor(scalar * Number(int)));\n\n // =========================================================================\n // Percentage <-> Bps\n // =========================================================================\n\n /**\n * Converts a decimal percentage into basis points (bps), returned as a bigint.\n * For example, 0.05 => 500 bps.\n *\n * @param percentage - The decimal percentage to convert (e.g., 0.05 for 5%).\n * @returns A bigint representing basis points.\n */\n public static percentageToBps(percentage: Percentage): bigint {\n // Convert decimal percentage to basis points\n const bps = percentage * 10_000;\n // Convert basis points to bigint\n return BigInt(Math.round(bps));\n }\n\n /**\n * Converts a bigint basis points value back to a decimal percentage.\n * For example, 500n => 0.05 (5%).\n *\n * @param bps - The bigint basis points to convert (e.g., 500n).\n * @returns The decimal percentage (0.05).\n */\n public static bpsToPercentage(bps: bigint): Percentage {\n // Convert bigint basis points to number\n const bpsNumber = Number(bps);\n // Convert basis points to decimal percentage\n const percentage = bpsNumber / 10_000;\n return percentage;\n }\n\n // =========================================================================\n // Bytes / BCS\n // =========================================================================\n\n /**\n * Converts an array of bytes into a string by interpreting each byte as a character code.\n *\n * @param bytes - An array of bytes to convert.\n * @returns The resulting ASCII string.\n */\n public static stringFromBytes = (bytes: Byte[]) =>\n String.fromCharCode.apply(null, bytes as any);\n\n /**\n * Interprets an array of bytes as a little-endian hex string, converting\n * that string into a bigint. For example, `[0x01, 0x02]` => `0x0201` => `513n`.\n *\n * @param bytes - An array of bytes.\n * @returns The resulting bigint from the hex.\n */\n public static bigIntFromBytes = (bytes: Byte[]) =>\n BigInt(\n \"0x\" +\n bytes\n .reverse()\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\")\n );\n\n /**\n * Converts BCS-encoded address bytes into a SuiAddress (0x...) string,\n * preserving any needed leading zeroes.\n *\n * @param bytes - The address bytes in BCS-encoded form.\n * @returns A normalized Sui address string (e.g., \"0x000123...\").\n */\n public static addressFromBcsBytes = (bytes: Byte[]): SuiAddress =>\n Helpers.addLeadingZeroesToType(bcs.Address.parse(new Uint8Array(bytes)));\n\n /**\n * Converts an array of bytes directly to a Sui address string in \"0x...\" format,\n * adding any leading zeros if needed.\n *\n * @param bytes - The raw bytes for the address.\n * @returns A normalized Sui address.\n */\n public static addressFromBytes = (bytes: Byte[]): SuiAddress =>\n Helpers.addLeadingZeroesToType(\n \"0x\" +\n bytes\n .map((byte) => {\n const hex = byte.toString(16);\n return hex.length === 1 ? \"0\" + hex : hex;\n })\n .join(\"\")\n );\n\n /**\n * Converts an array of hex string bytes into a Sui address. Each element of\n * the array is a string representing a byte (e.g., `[\"255\", \"0\", ...]`).\n *\n * @param bytes - An array of stringified bytes to convert.\n * @returns A normalized Sui address.\n */\n public static addressFromStringBytes = (bytes: string[]): SuiAddress =>\n this.addressFromBytes(this.bytesFromStringBytes(bytes));\n\n /**\n * Converts an array of decimal-encoded string bytes (e.g., `[\"255\", \"0\"]`)\n * into a numeric `Byte[]` array.\n *\n * @param bytes - The string array representing decimal values.\n * @returns A numeric array of bytes.\n */\n public static bytesFromStringBytes = (bytes: string[]): Byte[] =>\n bytes.map((byte) => Number(byte));\n\n /**\n * Unwraps a deserialized \"Option\" type from the BCS, returning its contents\n * if present, or `undefined` if not.\n *\n * @param deserializedData - The BCS-deserialized structure that might contain `{ Some: value }` or `{ None: true }`.\n * @returns The unwrapped data if present, or `undefined`.\n */\n public static unwrapDeserializedOption = (\n deserializedData: any\n ): any | undefined => {\n return \"Some\" in deserializedData ? deserializedData.Some : undefined;\n };\n\n /**\n * Encodes a JavaScript string into a UTF-8 `Uint8Array`, suitable for\n * on-chain usage or hashing.\n *\n * @param str - The string to encode.\n * @returns An array of numeric bytes representing the UTF-8 encoded string.\n */\n public static u8VectorFromString = (str: string) => {\n const textEncode = new TextEncoder();\n const encodedStr = textEncode.encode(str);\n\n const uint8s: number[] = [];\n for (const uint8 of encodedStr.values()) {\n uint8s.push(uint8);\n }\n return uint8s;\n };\n\n /**\n * Normalizes a user-provided slippage tolerance from an integer percentage\n * into a decimal fraction. E.g., `1 => 0.01`.\n *\n * @param slippageTolerance - The slippage in integer percent form (e.g., 1 for 1%).\n * @returns A decimal fraction (e.g., 0.01).\n */\n public static normalizeSlippageTolerance = (slippageTolerance: number) => {\n return slippageTolerance / 100;\n };\n\n /**\n * Deserializes a `SuiObjectResponse`'s BCS bytes into an object of type `T` using\n * a specified `bcsType`. Typically used for on-chain object decoding.\n *\n * @param inputs - The inputs including `suiObjectResponse`, `bcsType`, and a `fromDeserialized` transform function.\n * @returns The transformed object of type `T` after BCS deserialization.\n * @throws If no BCS bytes are found in the object.\n */\n public static castObjectBcs = <T, U>(inputs: {\n suiObjectResponse: SuiObjectResponse;\n bcsType: BcsType<U>;\n fromDeserialized: (deserialized: U) => T;\n }): T => {\n const { suiObjectResponse, bcsType, fromDeserialized } = inputs;\n\n const deserialized = bcsType.fromBase64(\n this.bcsBytesFromSuiObjectResponse(suiObjectResponse)\n );\n\n return fromDeserialized(deserialized);\n };\n\n /**\n * Extracts base64 BCS bytes from a `SuiObjectResponse` if present. Throws an error otherwise.\n *\n * @param suiObjectResponse - The Sui object response containing `bcsBytes`.\n * @returns A base64 string representing the object's BCS data.\n * @throws If the object response does not contain `bcsBytes`.\n */\n public static bcsBytesFromSuiObjectResponse(\n suiObjectResponse: SuiObjectResponse\n ): string {\n const rawData = suiObjectResponse.data?.bcs;\n if (rawData && \"bcsBytes\" in rawData) {\n return rawData.bcsBytes;\n }\n throw new Error(\n `no bcs bytes found on object: ${suiObjectResponse.data?.objectId}`\n );\n }\n}\n","import { AftermathApi } from \"../providers/aftermathApi\";\nimport { AnyObjectType, ObjectId, PackageId, SuiAddress } from \"../../types\";\nimport { Helpers } from \"../utils/helpers\";\nimport {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport type {\n\tSuiObjectDataFilter,\n\tSuiObjectDataOptions,\n\tSuiObjectResponse,\n} from \"@mysten/sui/jsonRpc\";\nimport type { BcsType } from \"@mysten/sui/bcs\";\nimport { BcsTypeName } from \"../types/castingTypes\";\n\nexport class ObjectsApiHelpers {\n\t// =========================================================================\n\t// Private Static Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmaxObjectFetchingLimit: 50,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\tpublic fetchDoesObjectExist = async (objectId: ObjectId | PackageId) => {\n\t\tconst object = await this.Provider.provider.getObject({ id: objectId });\n\t\treturn object.error === undefined;\n\t};\n\n\tpublic fetchIsObjectOwnedByAddress = async (inputs: {\n\t\tobjectId: ObjectId;\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { objectId, walletAddress } = inputs;\n\n\t\tconst object = await this.fetchObject({ objectId });\n\n\t\tconst objectOwner = object.data?.owner;\n\t\tif (!objectOwner || typeof objectOwner !== \"object\") return false;\n\n\t\tif (\n\t\t\t\"AddressOwner\" in objectOwner &&\n\t\t\tobjectOwner.AddressOwner === walletAddress\n\t\t)\n\t\t\treturn true;\n\t\tif (\n\t\t\t\"ObjectOwner\" in objectOwner &&\n\t\t\tobjectOwner.ObjectOwner === walletAddress\n\t\t)\n\t\t\treturn true;\n\n\t\treturn false;\n\t};\n\n\tpublic fetchObjectsOfTypeOwnedByAddress = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tobjectType: AnyObjectType;\n\t\twithDisplay?: boolean;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<SuiObjectResponse[]> => {\n\t\treturn this.fetchOwnedObjects({\n\t\t\t...inputs,\n\t\t\tfilter: {\n\t\t\t\tStructType: Helpers.stripLeadingZeroesFromType(\n\t\t\t\t\tinputs.objectType\n\t\t\t\t),\n\t\t\t},\n\t\t});\n\t};\n\n\tpublic fetchOwnedObjects = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tfilter?: SuiObjectDataFilter;\n\t\twithDisplay?: boolean;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<SuiObjectResponse[]> => {\n\t\tconst { walletAddress, withDisplay, filter } = inputs;\n\n\t\tlet allObjectData: SuiObjectResponse[] = [];\n\t\tlet cursor: string | undefined = undefined;\n\t\tdo {\n\t\t\tconst paginatedObjects =\n\t\t\t\tawait this.Provider.provider.getOwnedObjects({\n\t\t\t\t\towner: walletAddress,\n\t\t\t\t\toptions: inputs.options ?? {\n\t\t\t\t\t\tshowContent: true,\n\t\t\t\t\t\tshowDisplay: withDisplay,\n\t\t\t\t\t\tshowOwner: true,\n\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t},\n\t\t\t\t\tlimit: ObjectsApiHelpers.constants.maxObjectFetchingLimit,\n\t\t\t\t\tcursor,\n\t\t\t\t\tfilter,\n\t\t\t\t});\n\n\t\t\tconst objectData = paginatedObjects.data;\n\t\t\tallObjectData = [...allObjectData, ...objectData];\n\n\t\t\tif (\n\t\t\t\tpaginatedObjects.data.length === 0 ||\n\t\t\t\t!paginatedObjects.hasNextPage ||\n\t\t\t\t!paginatedObjects.nextCursor\n\t\t\t)\n\t\t\t\treturn allObjectData;\n\n\t\t\tcursor = paginatedObjects.nextCursor;\n\t\t} while (true);\n\t};\n\n\tpublic fetchObject = async (inputs: {\n\t\tobjectId: ObjectId;\n\t\twithDisplay?: boolean;\n\t}): Promise<SuiObjectResponse> => {\n\t\tconst { objectId, withDisplay } = inputs;\n\t\treturn await this.fetchObjectGeneral({\n\t\t\tobjectId,\n\t\t\toptions: {\n\t\t\t\tshowContent: true,\n\t\t\t\tshowDisplay: withDisplay,\n\t\t\t\tshowOwner: true,\n\t\t\t\tshowType: true,\n\t\t\t},\n\t\t});\n\t};\n\n\tpublic fetchObjectGeneral = async (inputs: {\n\t\tobjectId: ObjectId;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<SuiObjectResponse> => {\n\t\tconst { objectId, options } = inputs;\n\n\t\tconst object = await this.Provider.provider.getObject({\n\t\t\tid: objectId,\n\t\t\toptions,\n\t\t});\n\t\tif (object.error !== undefined)\n\t\t\tthrow new Error(\n\t\t\t\t`an error occured fetching object: ${object.error?.code}`\n\t\t\t);\n\t\treturn object;\n\t};\n\n\tpublic fetchCastObject = async <ObjectType>(inputs: {\n\t\tobjectId: ObjectId;\n\t\tobjectFromSuiObjectResponse: (\n\t\t\tSuiObjectResponse: SuiObjectResponse\n\t\t) => ObjectType;\n\t\twithDisplay?: boolean;\n\t}): Promise<ObjectType> => {\n\t\treturn inputs.objectFromSuiObjectResponse(\n\t\t\tawait this.fetchObject(inputs)\n\t\t);\n\t};\n\n\tpublic fetchCastObjectGeneral = async <ObjectType>(inputs: {\n\t\tobjectId: ObjectId;\n\t\tobjectFromSuiObjectResponse: (\n\t\t\tSuiObjectResponse: SuiObjectResponse\n\t\t) => ObjectType;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<ObjectType> => {\n\t\tconst { objectId, objectFromSuiObjectResponse, options } = inputs;\n\t\treturn objectFromSuiObjectResponse(\n\t\t\tawait this.fetchObjectGeneral({ objectId, options })\n\t\t);\n\t};\n\n\tpublic fetchObjectBatch = async (inputs: {\n\t\tobjectIds: ObjectId[];\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<SuiObjectResponse[]> => {\n\t\tconst { objectIds, options } = inputs;\n\n\t\tlet objectIdsBatches: ObjectId[][] = [];\n\t\tlet endIndex = 0;\n\t\twhile (true) {\n\t\t\tconst newEndIndex =\n\t\t\t\tendIndex + ObjectsApiHelpers.constants.maxObjectFetchingLimit;\n\t\t\tif (newEndIndex >= objectIds.length) {\n\t\t\t\tobjectIdsBatches.push(\n\t\t\t\t\tobjectIds.slice(endIndex, objectIds.length)\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tobjectIdsBatches.push(objectIds.slice(endIndex, newEndIndex));\n\n\t\t\tendIndex = newEndIndex;\n\t\t}\n\n\t\tconst objectBatches = await Promise.all(\n\t\t\tobjectIdsBatches.map((objectIds) =>\n\t\t\t\tthis.Provider.provider.multiGetObjects({\n\t\t\t\t\tids: objectIds,\n\t\t\t\t\toptions:\n\t\t\t\t\t\toptions === undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tshowContent: true,\n\t\t\t\t\t\t\t\t\tshowOwner: true,\n\t\t\t\t\t\t\t\t\tshowType: true,\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: options,\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t\tconst objectBatch = objectBatches.reduce(\n\t\t\t(acc, objects) => [...acc, ...objects],\n\t\t\t[]\n\t\t);\n\n\t\t// const objectDataResponses = objectBatch.filter(\n\t\t// \t(data) => data.error !== undefined\n\t\t// );\n\n\t\t// REVIEW: throw error on any objects that don't exist ?\n\t\t// or don't throw any errors and return empty array ?\n\t\treturn objectBatch;\n\t};\n\n\tpublic fetchCastObjectBatch = async <ObjectType>(inputs: {\n\t\tobjectIds: ObjectId[];\n\t\tobjectFromSuiObjectResponse: (data: SuiObjectResponse) => ObjectType;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<ObjectType[]> => {\n\t\treturn (await this.fetchObjectBatch(inputs)).map(\n\t\t\t(SuiObjectResponse: SuiObjectResponse) => {\n\t\t\t\treturn inputs.objectFromSuiObjectResponse(SuiObjectResponse);\n\t\t\t}\n\t\t);\n\t};\n\n\tpublic fetchCastObjectsOwnedByAddressOfType = async <ObjectType>(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tobjectType: AnyObjectType;\n\t\tobjectFromSuiObjectResponse: (\n\t\t\tSuiObjectResponse: SuiObjectResponse\n\t\t) => ObjectType;\n\t\twithDisplay?: boolean;\n\t\toptions?: SuiObjectDataOptions;\n\t}): Promise<ObjectType[]> => {\n\t\tconst objects = (\n\t\t\tawait this.fetchObjectsOfTypeOwnedByAddress(inputs)\n\t\t).map((SuiObjectResponse: SuiObjectResponse) => {\n\t\t\treturn inputs.objectFromSuiObjectResponse(SuiObjectResponse);\n\t\t});\n\t\treturn objects;\n\t};\n\n\t// =========================================================================\n\t// BCS\n\t// =========================================================================\n\n\tpublic fetchObjectBcs = async (\n\t\tobjectId: ObjectId\n\t): Promise<SuiObjectResponse> => {\n\t\tconst objectResponse = await this.Provider.provider.getObject({\n\t\t\tid: objectId,\n\t\t\toptions: { showBcs: true },\n\t\t});\n\t\tif (objectResponse.error !== undefined)\n\t\t\tthrow new Error(\n\t\t\t\t`an error occured fetching object: ${objectResponse.error?.code}`\n\t\t\t);\n\t\treturn objectResponse;\n\t};\n\n\tpublic fetchCastObjectBcs = async <T, U>(inputs: {\n\t\tobjectId: ObjectId;\n\t\tbcsType: BcsType<U>;\n\t\tfromDeserialized: (deserialized: U) => T;\n\t}): Promise<T> => {\n\t\tconst { objectId } = inputs;\n\t\tconst suiObjectResponse = await this.Provider.Objects().fetchObjectBcs(\n\t\t\tobjectId\n\t\t);\n\t\tconst { Casting } = await import(\"../utils/casting.js\");\n\t\treturn Casting.castObjectBcs({\n\t\t\t...inputs,\n\t\t\tsuiObjectResponse: suiObjectResponse,\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic burnObjectTx = async (inputs: {\n\t\ttx: Transaction;\n\t\tobject: TransactionObjectArgument;\n\t}): Promise<TransactionObjectArgument> => {\n\t\tconst { tx, object } = inputs;\n\n\t\treturn tx.transferObjects(\n\t\t\t[object],\n\t\t\t// not using constants because of strange build bug on frontend otherwise\n\t\t\t// tx.pure(Sui.constants.addresses.zero)\n\t\t\t\"0x0\"\n\t\t);\n\t};\n\n\tpublic publicShareObjectTx = async (inputs: {\n\t\ttx: Transaction;\n\t\tobject: TransactionObjectArgument;\n\t\tobjectType: AnyObjectType;\n\t}): Promise<TransactionObjectArgument> => {\n\t\tconst { tx, object, objectType } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\t// not using constants because of strange build bug on frontend otherwise\n\t\t\t\t// Sui.constants.addresses.suiPackageId,\n\t\t\t\t\"0x2\",\n\t\t\t\t\"transfer\",\n\t\t\t\t\"public_share_object\"\n\t\t\t),\n\t\t\ttypeArguments: [objectType],\n\t\t\targuments: [object],\n\t\t});\n\t};\n}\n","import {\n\tTransaction,\n\tisTransaction,\n\ttype TransactionArgument,\n\ttype TransactionObjectArgument,\n\ttype Argument,\n} from \"@mysten/sui/transactions\";\nimport type { SuiTransactionBlockResponseQuery } from \"@mysten/sui/jsonRpc\";\nimport {\n\tBalance,\n\tCoinType,\n\tObjectId,\n\tSerializedTransaction,\n\tServiceCoinData,\n\tServiceCoinDataV2,\n\tSuiAddress,\n\tTransactionDigest,\n\tTransactionsWithCursor,\n} from \"../../types\";\nimport { AftermathApi } from \"../providers/aftermathApi\";\nimport { Helpers } from \"../utils/helpers\";\n\nexport class TransactionsApiHelpers {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\tpublic fetchTransactionsWithCursor = async (inputs: {\n\t\tquery: SuiTransactionBlockResponseQuery;\n\t\tcursor?: TransactionDigest;\n\t\tlimit?: number;\n\t}): Promise<TransactionsWithCursor> => {\n\t\tconst { query, cursor, limit } = inputs;\n\n\t\tconst transactionsWithCursor =\n\t\t\tawait this.Provider.provider.queryTransactionBlocks({\n\t\t\t\t...query,\n\t\t\t\tcursor,\n\t\t\t\tlimit,\n\t\t\t\toptions: {\n\t\t\t\t\tshowEvents: true,\n\t\t\t\t\tshowBalanceChanges: true,\n\t\t\t\t\tshowEffects: true,\n\t\t\t\t\tshowObjectChanges: true,\n\t\t\t\t\tshowInput: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\treturn {\n\t\t\ttransactions: transactionsWithCursor.data,\n\t\t\tnextCursor: transactionsWithCursor.nextCursor ?? null,\n\t\t};\n\t};\n\n\tpublic fetchSetGasBudgetForTx = async (inputs: {\n\t\ttx: Transaction;\n\t}): Promise<Transaction> => {\n\t\tconst { tx } = inputs;\n\n\t\tconst [txResponse, referenceGasPrice] = await Promise.all([\n\t\t\tthis.Provider.provider.dryRunTransactionBlock({\n\t\t\t\ttransactionBlock: await tx.build({\n\t\t\t\t\tclient: this.Provider.provider,\n\t\t\t\t}),\n\t\t\t}),\n\t\t\tthis.Provider.provider.getReferenceGasPrice(),\n\t\t]);\n\n\t\tconst gasData = txResponse.effects.gasUsed;\n\t\tconst gasUsed =\n\t\t\tBigInt(gasData.computationCost) + BigInt(gasData.storageCost);\n\n\t\t// scale up by 10% for safety margin\n\t\tconst safeGasBudget = gasUsed + gasUsed / BigInt(10);\n\n\t\ttx.setGasBudget(safeGasBudget);\n\t\ttx.setGasPrice(BigInt(referenceGasPrice));\n\t\treturn tx;\n\t};\n\n\tpublic fetchSetGasBudgetAndSerializeTx = async (inputs: {\n\t\ttx: Transaction | Promise<Transaction>;\n\t\tisSponsoredTx?: boolean;\n\t}): Promise<SerializedTransaction> => {\n\t\tconst { tx, isSponsoredTx } = inputs;\n\n\t\tif (isSponsoredTx) return (await tx).serialize();\n\n\t\treturn (\n\t\t\tawait this.fetchSetGasBudgetForTx({ tx: await tx })\n\t\t).serialize();\n\t};\n\n\tpublic fetchBase64TxKindFromTx = async (inputs: {\n\t\ttx: Transaction | undefined;\n\t}): Promise<SerializedTransaction | undefined> => {\n\t\tconst { tx } = inputs;\n\n\t\tif (!tx) return;\n\n\t\tconst txBytes = await tx.build({\n\t\t\tclient: this.Provider?.provider,\n\t\t\tonlyTransactionKind: true,\n\t\t});\n\n\t\treturn Buffer.from(txBytes).toString(\"base64\");\n\t};\n\n\t// =========================================================================\n\t// Public Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tpublic static createTxTarget = (\n\t\tpackageAddress: string,\n\t\tpackageName: string,\n\t\tfunctionName: string\n\t): `${string}::${string}::${string}` =>\n\t\t`${packageAddress}::${packageName}::${functionName}`;\n\n\tpublic static createBuildTxFunc = <Inputs>(\n\t\tfunc: (inputs: Inputs) => TransactionArgument\n\t): ((\n\t\tinputs: {\n\t\t\twalletAddress: SuiAddress;\n\t\t} & Omit<Inputs, \"tx\">\n\t) => Transaction) => {\n\t\tconst builderFunc = (\n\t\t\tsomeInputs: {\n\t\t\t\twalletAddress: SuiAddress;\n\t\t\t} & Omit<Inputs, \"tx\">\n\t\t) => {\n\t\t\tconst tx = new Transaction();\n\t\t\ttx.setSender(someInputs.walletAddress);\n\n\t\t\tfunc({\n\t\t\t\ttx,\n\t\t\t\t...someInputs,\n\t\t\t} as Inputs);\n\n\t\t\treturn tx;\n\t\t};\n\n\t\treturn builderFunc;\n\t};\n\n\tpublic static splitCoinTx(inputs: {\n\t\ttx: Transaction;\n\t\tcoinType: CoinType;\n\t\t// coinId: TransactionArgument | ObjectId;\n\t\tcoinId: ObjectId;\n\t\tamount: Balance;\n\t}) {\n\t\tconst { tx, coinType, coinId, amount } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: this.createTxTarget(\n\t\t\t\t// Sui.constants.addresses.suiPackageId,\n\t\t\t\t\"0x2\",\n\t\t\t\t\"coin\",\n\t\t\t\t\"split\"\n\t\t\t),\n\t\t\ttypeArguments: [coinType],\n\t\t\targuments: [\n\t\t\t\ttypeof coinId === \"string\" ? tx.object(coinId) : coinId, // Coin,\n\t\t\t\ttx.pure.u64(amount), // split_amount\n\t\t\t],\n\t\t});\n\t}\n\n\tpublic static serviceCoinDataFromCoinTxArg = (inputs: {\n\t\tcoinTxArg: TransactionObjectArgument | Argument | ObjectId;\n\t}): ServiceCoinData => {\n\t\tconst { coinTxArg } = inputs;\n\n\t\tif (typeof coinTxArg === \"string\")\n\t\t\treturn { Coin: Helpers.addLeadingZeroesToType(coinTxArg) };\n\n\t\tif (!(\"$kind\" in coinTxArg)) {\n\t\t\tif (typeof coinTxArg === \"function\" || \"GasCoin\" in coinTxArg)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"unable to convert gas coin arg to service coin data\"\n\t\t\t\t);\n\t\t\t// Input\n\t\t\treturn coinTxArg;\n\t\t}\n\n\t\tif (coinTxArg.$kind === \"NestedResult\")\n\t\t\treturn {\n\t\t\t\t[coinTxArg.$kind]: coinTxArg.NestedResult,\n\t\t\t};\n\n\t\tif (coinTxArg.$kind === \"Result\")\n\t\t\treturn { [coinTxArg.$kind]: coinTxArg.Result };\n\n\t\tif (coinTxArg.$kind === \"GasCoin\")\n\t\t\tthrow new Error(\n\t\t\t\t\"unable to convert gas coin arg to service coin data\"\n\t\t\t);\n\n\t\tif (coinTxArg.$kind === \"Input\") return { Input: coinTxArg.Input };\n\n\t\tthrow new Error(`unexpected coinTxArg.$kind: ${coinTxArg.$kind}`);\n\t};\n\n\tpublic static serviceCoinDataV2FromCoinTxArg = (inputs: {\n\t\tcoinTxArg: TransactionObjectArgument | Argument;\n\t}): ServiceCoinDataV2 => {\n\t\tconst { coinTxArg } = inputs;\n\n\t\tif (!(\"$kind\" in coinTxArg)) {\n\t\t\tif (\"Result\" in coinTxArg) return { Result: coinTxArg.Result };\n\n\t\t\tif (\"NestedResult\" in coinTxArg)\n\t\t\t\treturn { NestedResult: coinTxArg.NestedResult };\n\n\t\t\tif (\"GasCoin\" in coinTxArg) return \"Gas\";\n\n\t\t\tif (\"Input\" in coinTxArg) return { Input: coinTxArg.Input };\n\n\t\t\t// TODO: handle this case better\n\t\t\tthrow new Error(`coinTxArg in format ${coinTxArg} not supported`);\n\t\t}\n\n\t\tif (coinTxArg.$kind === \"NestedResult\")\n\t\t\treturn {\n\t\t\t\tNestedResult: coinTxArg.NestedResult,\n\t\t\t};\n\n\t\tif (coinTxArg.$kind === \"Result\") return { Result: coinTxArg.Result };\n\n\t\tif (coinTxArg.$kind === \"GasCoin\") return \"Gas\";\n\n\t\tif (coinTxArg.$kind === \"Input\") return { Input: coinTxArg.Input };\n\n\t\tthrow new Error(`unexpected coinTxArg.$kind: ${coinTxArg.$kind}`);\n\t};\n\n\tpublic static coinTxArgFromServiceCoinData = (inputs: {\n\t\tserviceCoinData: ServiceCoinData;\n\t}): TransactionObjectArgument => {\n\t\tconst { serviceCoinData } = inputs;\n\n\t\tconst key = Object.keys(serviceCoinData)[0];\n\n\t\t// TODO: handle all cases\n\t\tif (key === \"Coin\")\n\t\t\tthrow new Error(\n\t\t\t\t\"serviceCoinData in format { Coin: ObjectId } not supported\"\n\t\t\t);\n\n\t\t// TODO: handle this cleaner\n\t\tconst kind = key as \"Input\" | \"NestedResult\" | \"Result\";\n\n\t\tif (kind === \"NestedResult\") {\n\t\t\treturn {\n\t\t\t\tNestedResult: Object.values(serviceCoinData)[0],\n\t\t\t};\n\t\t}\n\t\tif (kind === \"Input\") {\n\t\t\treturn {\n\t\t\t\tInput: Object.values(serviceCoinData)[0],\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tResult: Object.values(serviceCoinData)[0],\n\t\t};\n\t};\n\n\tpublic static coinTxArgFromServiceCoinDataV2 = (inputs: {\n\t\tserviceCoinDataV2: ServiceCoinDataV2;\n\t}): TransactionObjectArgument => {\n\t\tconst { serviceCoinDataV2 } = inputs;\n\n\t\tif (typeof serviceCoinDataV2 === \"string\") {\n\t\t\treturn { GasCoin: true };\n\t\t}\n\n\t\tconst key = Object.keys(serviceCoinDataV2)[0];\n\t\tconst value: number | [number, number] =\n\t\t\tObject.values(serviceCoinDataV2)[0];\n\n\t\t// TODO: handle this cleaner ?\n\t\tconst kind = key as \"Input\" | \"Result\" | \"NestedResult\";\n\n\t\tif (kind === \"Result\" && typeof value === \"number\") {\n\t\t\treturn {\n\t\t\t\tResult: value,\n\t\t\t};\n\t\t}\n\t\tif (kind === \"NestedResult\" && typeof value !== \"number\") {\n\t\t\treturn {\n\t\t\t\tNestedResult: value,\n\t\t\t};\n\t\t}\n\t\tif (kind === \"Input\" && typeof value === \"number\") {\n\t\t\treturn {\n\t\t\t\tInput: value,\n\t\t\t};\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`serviceCoinDataV2 format ${JSON.stringify(\n\t\t\t\tserviceCoinDataV2\n\t\t\t)} not supported`\n\t\t);\n\t};\n\n\t// public static mergeCoinsTx(inputs: {\n\t// \ttx: Transaction;\n\t// \tcoinType: CoinType;\n\t// \tdestinationCoinId: TransactionArgument | string;\n\t// \tsources: TransactionArgument[] | ObjectId[];\n\t// }) {\n\t// \tconst { tx, coinType, destinationCoinId, sources } = inputs;\n\n\t// \t// TODO: clean this up\n\t// \tconst coinVec =\n\t// \t\ttypeof sources[0] === \"string\"\n\t// \t\t\t? tx.makeMoveVec({\n\t// \t\t\t\t\tobjects: sources.map((source) =>\n\t// \t\t\t\t\t\ttx.object(source as ObjectId)\n\t// \t\t\t\t\t),\n\t// \t\t\t\t\ttype: `Coin<${coinType}>`,\n\t// \t\t\t })\n\t// \t\t\t: sources;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: this.createTxTarget(\n\t// \t\t\tSui.constants.addresses.suiPackageId,\n\t// \t\t\t\"pay\",\n\t// \t\t\t\"join_vec\"\n\t// \t\t),\n\t// \t\ttypeArguments: [coinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof destinationCoinId === \"string\"\n\t// \t\t\t\t? tx.object(destinationCoinId)\n\t// \t\t\t\t: destinationCoinId, // Coin,\n\n\t// \t\t\t// TODO: clean this up\n\t// \t\t\t// @ts-ignore\n\t// \t\t\tcoinVec, // coins\n\t// \t\t],\n\t// \t});\n\t// }\n\n\tpublic static transferTxMetadata = (inputs: {\n\t\tinitTx: Transaction;\n\t\tnewTx: Transaction;\n\t}) => {\n\t\tconst { initTx, newTx } = inputs;\n\n\t\tconst sender = initTx.getData().sender;\n\t\tif (sender) newTx.setSender(sender);\n\n\t\tconst expiration = initTx.getData().expiration;\n\t\tif (expiration) newTx.setExpiration(expiration);\n\n\t\tconst gasData = initTx.getData().gasData;\n\n\t\tif (gasData.budget && typeof gasData.budget !== \"string\")\n\t\t\tnewTx.setGasBudget(gasData.budget);\n\n\t\tif (gasData.owner) newTx.setGasOwner(gasData.owner);\n\n\t\tif (gasData.payment) newTx.setGasPayment(gasData.payment);\n\n\t\tif (gasData.price && typeof gasData.price !== \"string\")\n\t\t\tnewTx.setGasPrice(gasData.price);\n\t};\n}\n","import {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport type {\n\tDisplayFieldsResponse,\n\tSuiMoveObject,\n\tSuiObjectResponse,\n} from \"@mysten/sui/jsonRpc\";\nimport { isValidSuiAddress } from \"@mysten/sui/utils\";\nimport { decodeSuiPrivateKey, type Keypair } from \"@mysten/sui/cryptography\";\nimport { Ed25519Keypair } from \"@mysten/sui/keypairs/ed25519\";\nimport { Secp256k1Keypair } from \"@mysten/sui/keypairs/secp256k1\";\nimport { Secp256r1Keypair } from \"@mysten/sui/keypairs/secp256r1\";\nimport {\n\tAnyObjectType,\n\tBalance,\n\tSuiNetwork,\n\tCoinsToDecimals,\n\tCoinsToPrice,\n\tObjectId,\n\tSlippage,\n\tModuleName,\n\tPackageId,\n\tMoveErrorCode,\n\tSuiAddress,\n\tCoinType,\n\tCoinGeckoChain,\n} from \"../../types\";\nimport { DynamicFieldsApiHelpers } from \"../apiHelpers/dynamicFieldsApiHelpers\";\nimport { EventsApiHelpers } from \"../apiHelpers/eventsApiHelpers\";\nimport { InspectionsApiHelpers } from \"../apiHelpers/inspectionsApiHelpers\";\nimport { ObjectsApiHelpers } from \"../apiHelpers/objectsApiHelpers\";\nimport { TransactionsApiHelpers } from \"../apiHelpers/transactionsApiHelpers\";\nimport { MoveErrors } from \"../types/moveErrorsInterface\";\n\n/**\n * A utility class containing various helper functions for general use across\n * the Aftermath TS ecosystem. This includes numeric operations, object field\n * extraction, array transformations, slippage adjustments, and Move error parsing.\n */\nexport class Helpers {\n\t// =========================================================================\n\t// Api Helpers (Static References)\n\t// =========================================================================\n\n\t/**\n\t * Static reference to the `DynamicFieldsApiHelpers`, providing utility methods\n\t * for working with dynamic fields in Sui objects.\n\t */\n\tpublic static readonly dynamicFields = DynamicFieldsApiHelpers;\n\n\t/**\n\t * Static reference to the `EventsApiHelpers`, providing methods for\n\t * querying and filtering Sui events.\n\t */\n\tpublic static readonly events = EventsApiHelpers;\n\n\t/**\n\t * Static reference to the `InspectionsApiHelpers`, used for reading\n\t * Summaries or inspection data from objects.\n\t */\n\tpublic static readonly inspections = InspectionsApiHelpers;\n\n\t/**\n\t * Static reference to the `ObjectsApiHelpers`, providing direct\n\t * retrieval or manipulation of on-chain Sui objects.\n\t */\n\tpublic static readonly objects = ObjectsApiHelpers;\n\n\t/**\n\t * Static reference to the `TransactionsApiHelpers`, enabling easier\n\t * queries for transaction data by digest or other criteria.\n\t */\n\tpublic static readonly transactions = TransactionsApiHelpers;\n\n\t// =========================================================================\n\t// Type Manipulation\n\t// =========================================================================\n\n\t/**\n\t * Removes all leading zeroes (after the '0x') from a string that represents\n\t * a Sui address or object type. For instance, \"0x0000123\" => \"0x123\".\n\t *\n\t * @param type - The hex string to process, potentially including \"::\" module syntax.\n\t * @returns The same string with unnecessary leading zeroes stripped out.\n\t */\n\tpublic static stripLeadingZeroesFromType = (\n\t\ttype: AnyObjectType\n\t): AnyObjectType => type.replaceAll(/x0+/g, \"x\");\n\n\t/**\n\t * Ensures the given Sui address or object type is zero-padded to 64 hex digits\n\t * after the \"0x\". If a \"::\" suffix is present, only the address portion is padded.\n\t *\n\t * @param type - The \"0x...\" string or extended type (0x..::module).\n\t * @returns A new string normalized to a 64-hex-digit address or object ID.\n\t * @throws If the address portion is already longer than 64 hex digits.\n\t */\n\tpublic static addLeadingZeroesToType = (\n\t\ttype: AnyObjectType\n\t): AnyObjectType => {\n\t\tconst EXPECTED_TYPE_LENGTH = 64;\n\n\t\tlet strippedType = type.replace(\"0x\", \"\");\n\t\tlet typeSuffix = \"\";\n\n\t\tif (strippedType.includes(\"::\")) {\n\t\t\tconst splitType = strippedType.replace(\"0x\", \"\").split(\"::\");\n\t\t\ttypeSuffix = splitType\n\t\t\t\t.slice(1)\n\t\t\t\t.reduce((acc, str) => acc + \"::\" + str, \"\");\n\t\t\tstrippedType = splitType[0];\n\t\t}\n\n\t\tconst typeLength = strippedType.length;\n\t\tif (typeLength > EXPECTED_TYPE_LENGTH)\n\t\t\tthrow new Error(\"invalid type length\");\n\n\t\tconst zerosNeeded = EXPECTED_TYPE_LENGTH - typeLength;\n\t\tconst zeroString = Array(zerosNeeded).fill(\"0\").join(\"\");\n\n\t\tconst newType = \"0x\" + zeroString + strippedType;\n\t\treturn newType + typeSuffix;\n\t};\n\n\t/**\n\t * Splits a non-SUI coin type string that may be prefixed by a chain ID for external usage,\n\t * returning the chain and the coin type. If no chain is recognized, defaults to `\"sui\"`.\n\t *\n\t * @param coin - The coin string, which may look like `\"bsc:0x<...>\"` or just `\"0x<...>\"`.\n\t * @returns An object with the `chain` (e.g. \"bsc\") and the `coinType`.\n\t */\n\tpublic static splitNonSuiCoinType = (\n\t\tcoin: CoinType\n\t): {\n\t\tchain: CoinGeckoChain;\n\t\tcoinType: CoinType;\n\t} => {\n\t\tconst [uncastChain, coinType] = coin.split(\":\");\n\t\tif (!uncastChain || !coinType) return { coinType: coin, chain: \"sui\" };\n\t\tconst chain = uncastChain as Exclude<CoinGeckoChain, \"sui\">;\n\t\treturn { chain, coinType };\n\t};\n\n\t// =========================================================================\n\t// Numbers\n\t// =========================================================================\n\n\t/**\n\t * Checks if a given string represents a valid number (integer or decimal).\n\t *\n\t * @param str - The string to test.\n\t * @returns `true` if it's a valid numeric string, otherwise `false`.\n\t */\n\tpublic static isNumber = (str: string): boolean => /^\\d*\\.?\\d*$/g.test(str);\n\n\t/**\n\t * Sums an array of floating-point numbers, returning the numeric total.\n\t *\n\t * @param arr - The array of numbers to sum.\n\t * @returns The total as a float.\n\t */\n\tpublic static sum = (arr: number[]) =>\n\t\tarr.reduce((prev, cur) => prev + cur, 0);\n\n\t/**\n\t * Sums an array of bigints, returning the total as a bigint.\n\t *\n\t * @param arr - The array of bigints to sum.\n\t * @returns The resulting total as a bigint.\n\t */\n\tpublic static sumBigInt = (arr: bigint[]) =>\n\t\tarr.reduce((prev, cur) => prev + cur, BigInt(0));\n\n\t/**\n\t * Determines if two numbers are close within a given tolerance factor,\n\t * i.e., `|a - b| <= tolerance * max(a, b)`.\n\t *\n\t * @param a - The first number.\n\t * @param b - The second number.\n\t * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).\n\t * @returns `true` if within tolerance, otherwise `false`.\n\t */\n\tpublic static closeEnough = (a: number, b: number, tolerance: number) =>\n\t\tMath.abs(a - b) <= tolerance * Math.max(a, b);\n\n\t/**\n\t * Determines if two bigints are close within a given tolerance factor,\n\t * by casting them to numbers internally.\n\t *\n\t * @param a - First bigint.\n\t * @param b - Second bigint.\n\t * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).\n\t * @returns `true` if within tolerance, otherwise `false`.\n\t */\n\tpublic static closeEnoughBigInt = (\n\t\ta: bigint,\n\t\tb: bigint,\n\t\ttolerance: number\n\t) => Helpers.closeEnough(Number(a), Number(b), tolerance);\n\n\t/**\n\t * Checks whether the integer divisions of `a` and `b` (by `fixedOne`) differ\n\t * by at most 1. Typically used in fixed math scenarios to see if two scaled\n\t * values are \"very close.\"\n\t *\n\t * @param a - First number (scaled).\n\t * @param b - Second number (scaled).\n\t * @param fixedOne - The scaling factor representing 1.0 in the same scale as `a` and `b`.\n\t * @returns `true` if the integer parts differ by <= 1, otherwise `false`.\n\t */\n\tpublic static veryCloseInt = (a: number, b: number, fixedOne: number) =>\n\t\tMath.abs(Math.floor(a / fixedOne) - Math.floor(b / fixedOne)) <= 1;\n\n\t/**\n\t * A small object containing \"blended\" math operations that handle\n\t * mixed numeric types (number vs. bigint). This is primarily for\n\t * internal usage in advanced math scenarios.\n\t */\n\tpublic static blendedOperations = {\n\t\t/**\n\t\t * Multiply two floating-point numbers.\n\t\t */\n\t\tmulNNN: (a: number, b: number): number => a * b,\n\t\t/**\n\t\t * Multiply a float and a bigint, returning a bigint (floor).\n\t\t */\n\t\tmulNNB: (a: number, b: number): bigint => BigInt(Math.floor(a * b)),\n\t\t/**\n\t\t * Multiply a float and a bigint, returning a float.\n\t\t */\n\t\tmulNBN: (a: number, b: bigint): number => a * Number(b),\n\t\t/**\n\t\t * Multiply a float and a bigint, returning a bigint (floor).\n\t\t */\n\t\tmulNBB: (a: number, b: bigint): bigint =>\n\t\t\tBigInt(Math.floor(a * Number(b))),\n\t\t/**\n\t\t * Multiply two bigints, returning a float.\n\t\t */\n\t\tmulBBN: (a: bigint, b: bigint): number => Number(a * b),\n\t\t/**\n\t\t * Multiply two bigints, returning a bigint.\n\t\t */\n\t\tmulBBB: (a: bigint, b: bigint): bigint => a * b,\n\t};\n\n\t/**\n\t * Returns the maximum of multiple bigints.\n\t *\n\t * @param args - The bigints to compare.\n\t * @returns The largest bigint.\n\t */\n\tpublic static maxBigInt = (...args: bigint[]) =>\n\t\targs.reduce((m, e) => (e > m ? e : m));\n\n\t/**\n\t * Returns the minimum of multiple bigints.\n\t *\n\t * @param args - The bigints to compare.\n\t * @returns The smallest bigint.\n\t */\n\tpublic static minBigInt = (...args: bigint[]) =>\n\t\targs.reduce((m, e) => (e < m ? e : m));\n\n\t/**\n\t * Returns the absolute value of a bigint.\n\t *\n\t * @param num - The input bigint.\n\t * @returns A bigint representing the absolute value of `num`.\n\t */\n\tpublic static absBigInt = (num: bigint) => (num < BigInt(0) ? -num : num);\n\n\t// =========================================================================\n\t// Display\n\t// =========================================================================\n\n\t/**\n\t * Capitalizes only the first letter of a string, making the rest lowercase.\n\t * E.g., \"HELLO\" => \"Hello\".\n\t *\n\t * @param str - The input string to transform.\n\t * @returns The resulting string with the first character in uppercase and the rest in lowercase.\n\t */\n\tpublic static capitalizeOnlyFirstLetter = (str: string) =>\n\t\tstr.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n\n\t// =========================================================================\n\t// JSON\n\t// =========================================================================\n\n\t/**\n\t * Parses a JSON string containing potential BigInt values.\n\t * By default, it only converts strings ending in 'n' (like `\"123n\"`) to BigInts.\n\t *\n\t * @param json - The JSON string to parse.\n\t * @param unsafeStringNumberConversion - If `true`, all numeric strings (e.g., \"123\") will also become BigInts.\n\t * @returns The parsed JSON object with BigInt conversions where applicable.\n\t */\n\tpublic static parseJsonWithBigint = (\n\t\tjson: string,\n\t\tunsafeStringNumberConversion = false\n\t) =>\n\t\tJSON.parse(json, (key, value) => {\n\t\t\t// convert null -> undefined everywhere\n\t\t\tif (value === null) return undefined;\n\n\t\t\t// handles bigint casting\n\t\t\tif (typeof value === \"string\" && /^-?\\d+n$/.test(value)) {\n\t\t\t\treturn BigInt(value.slice(0, -1));\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tunsafeStringNumberConversion &&\n\t\t\t\ttypeof value === \"string\" &&\n\t\t\t\tthis.isNumber(value)\n\t\t\t) {\n\t\t\t\treturn BigInt(value);\n\t\t\t}\n\t\t\treturn value;\n\t\t});\n\n\t// =========================================================================\n\t// General\n\t// =========================================================================\n\n\t/**\n\t * Creates a deep copy of the given target, handling nested arrays and objects.\n\t * Dates are cloned by their timestamp.\n\t *\n\t * @param target - The data to clone deeply.\n\t * @returns A new object/array/date structure mirroring `target`.\n\t */\n\tpublic static deepCopy = <T>(target: T): T => {\n\t\tif (target === null) {\n\t\t\treturn target;\n\t\t}\n\t\tif (target instanceof Date) {\n\t\t\treturn new Date(target.getTime()) as any;\n\t\t}\n\t\tif (Array.isArray(target)) {\n\t\t\tconst cp = [] as any[];\n\t\t\t(target as any[]).forEach((v) => {\n\t\t\t\tcp.push(v);\n\t\t\t});\n\t\t\treturn cp.map((n: any) => this.deepCopy<any>(n)) as any;\n\t\t}\n\t\tif (typeof target === \"object\") {\n\t\t\tconst cp = { ...(target as { [key: string]: any }) } as {\n\t\t\t\t[key: string]: any;\n\t\t\t};\n\t\t\tObject.keys(cp).forEach((k) => {\n\t\t\t\tcp[k] = this.deepCopy<any>(cp[k]);\n\t\t\t});\n\t\t\treturn cp as T;\n\t\t}\n\t\treturn target;\n\t};\n\n\t/**\n\t * Finds the index of the maximum value in an array. Returns -1 if the array is empty.\n\t *\n\t * @param arr - The input array.\n\t * @returns The index of the maximum value, or -1 if the array is empty.\n\t */\n\tpublic static indexOfMax = (arr: any[]) => {\n\t\tif (arr.length === 0) return -1;\n\n\t\tlet max = arr[0];\n\t\tlet maxIndex = 0;\n\n\t\tfor (let i = 1; i < arr.length; i++) {\n\t\t\tif (arr[i] > max) {\n\t\t\t\tmaxIndex = i;\n\t\t\t\tmax = arr[i];\n\t\t\t}\n\t\t}\n\n\t\treturn maxIndex;\n\t};\n\n\tprivate static uniqueObjectArray<T>(arr: T[]): T[] {\n\t\tconst seen = new Set<string>();\n\t\treturn arr.filter((obj) => {\n\t\t\tconst str = JSON.stringify(obj);\n\t\t\tif (seen.has(str)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tseen.add(str);\n\t\t\treturn true;\n\t\t});\n\t}\n\n\t/**\n\t * Returns a new array with unique elements from the input array,\n\t * preserving the order of first occurrences.\n\t *\n\t * @param arr - The original array.\n\t * @returns An array of unique items.\n\t */\n\tpublic static uniqueArray = <T>(arr: T[]): T[] =>\n\t\tarr.length <= 0\n\t\t\t? []\n\t\t\t: typeof arr[0] === \"object\"\n\t\t\t? Helpers.uniqueObjectArray(arr)\n\t\t\t: [...new Set(arr)];\n\n\t/**\n\t * Returns a Promise that resolves after a specified number of milliseconds.\n\t *\n\t * @param ms - The delay time in milliseconds.\n\t * @returns A promise that resolves after `ms` milliseconds.\n\t */\n\tpublic static sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n\t/**\n\t * Creates a unique ID-like string by combining the current timestamp and random base36 digits.\n\t *\n\t * @returns A short random string (base36) that can serve as a unique identifier.\n\t */\n\tpublic static createUid = () =>\n\t\tDate.now().toString(36) + Math.random().toString(36).substring(2);\n\n\t/**\n\t * Splits an array into two groups: those for which `func` returns `true` (or truthy),\n\t * and those for which it returns `false`. The result is returned as a tuple `[trues, falses]`.\n\t *\n\t * @param array - The array to filter.\n\t * @param func - The function used to test each element.\n\t * @returns A tuple containing two arrays: `[elements that pass, elements that fail]`.\n\t */\n\tpublic static bifilter = <ArrayType>(\n\t\tarray: ArrayType[],\n\t\tfunc: (item: ArrayType, index: number, arr: ArrayType[]) => boolean\n\t): [trues: ArrayType[], falses: ArrayType[]] => {\n\t\tconst trues: ArrayType[] = [];\n\t\tconst falses: ArrayType[] = [];\n\n\t\tfor (let index = 0; index < array.length; index++) {\n\t\t\tconst item = array[index];\n\t\t\tif (func(item, index, array)) trues[trues.length] = item;\n\t\t\telse falses[falses.length] = item;\n\t\t}\n\n\t\treturn [trues, falses];\n\t};\n\n\t/**\n\t * An async version of `bifilter`, returning a tuple of `[trues, falses]`.\n\t * Each element is tested asynchronously in parallel via `func`.\n\t *\n\t * @param array - The array to filter.\n\t * @param func - An async function returning `true` or `false`.\n\t * @returns A tuple `[trues, falses]` after asynchronous evaluation.\n\t */\n\tpublic static bifilterAsync = async <ArrayType>(\n\t\tarray: ArrayType[],\n\t\tfunc: (\n\t\t\titem: ArrayType,\n\t\t\tindex: number,\n\t\t\tarr: ArrayType[]\n\t\t) => Promise<boolean>\n\t): Promise<[trues: ArrayType[], falses: ArrayType[]]> => {\n\t\tconst predicates = await Promise.all(array.map(func));\n\t\treturn this.bifilter(array, (_, index) => predicates[index]);\n\t};\n\n\t/**\n\t * Filters the entries of an object based on a predicate function,\n\t * returning a new object with only those entries for which `predicate`\n\t * returns `true`.\n\t *\n\t * @param obj - The original object to filter.\n\t * @param predicate - A function taking `(key, value)` and returning a boolean.\n\t * @returns A new object with only the entries that pass the predicate.\n\t */\n\tpublic static filterObject = <Value>(\n\t\tobj: Record<string, Value>,\n\t\tpredicate: (key: string, value: Value) => boolean\n\t): Record<string, Value> =>\n\t\tObject.keys(obj).reduce((acc, key) => {\n\t\t\tconst val = obj[key];\n\t\t\tif (!predicate(key, val)) return acc;\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: val,\n\t\t\t};\n\t\t}, {} as Record<string, Value>);\n\n\t/**\n\t * Applies downward slippage to a bigint amount by subtracting `slippage * amount`.\n\t * For instance, for 1% slippage, we reduce the amount by 1%.\n\t *\n\t * @param amount - The original bigint amount.\n\t * @param slippage - An integer percent (e.g., 1 => 1%).\n\t * @returns The adjusted bigint after subtracting the slippage portion.\n\t */\n\tpublic static applySlippageBigInt = (\n\t\tamount: Balance,\n\t\tslippage: Slippage\n\t) => {\n\t\treturn amount - BigInt(Math.floor((slippage / 100) * Number(amount)));\n\t};\n\n\t/**\n\t * Applies downward slippage to a floating-point amount. E.g., for 1% slippage,\n\t * reduce by 1% of `amount`.\n\t *\n\t * @param amount - The original float value.\n\t * @param slippage - An integer percent (e.g., 1 => 1%).\n\t * @returns The float after applying slippage.\n\t */\n\tpublic static applySlippage = (amount: number, slippage: Slippage) => {\n\t\treturn amount - (slippage / 100) * amount;\n\t};\n\n\t/**\n\t * Combines two arrays into a single array of pairs. The result length is the\n\t * minimum of the two input arrays' lengths.\n\t *\n\t * @param firstCollection - The first array.\n\t * @param lastCollection - The second array.\n\t * @returns An array of `[firstCollection[i], lastCollection[i]]` pairs.\n\t */\n\tpublic static zip<S1, S2>(\n\t\tfirstCollection: Array<S1>,\n\t\tlastCollection: Array<S2>\n\t): Array<[S1, S2]> {\n\t\tconst length = Math.min(firstCollection.length, lastCollection.length);\n\t\tconst zipped: Array<[S1, S2]> = [];\n\t\tfor (let index = 0; index < length; index++) {\n\t\t\tzipped.push([firstCollection[index], lastCollection[index]]);\n\t\t}\n\t\treturn zipped;\n\t}\n\n\t/**\n\t * Removes circular references from an object or array, returning a JSON-safe structure.\n\t * Any cyclic references are replaced with `undefined`.\n\t *\n\t * @param obj - The object or array to remove circular references from.\n\t * @param seen - Internal usage to track references that have already been visited.\n\t * @returns A structure that can be safely JSON-stringified.\n\t */\n\tpublic static removeCircularReferences<T>(\n\t\tobj: T,\n\t\tseen: WeakSet<object> = new WeakSet()\n\t): T | undefined {\n\t\ttype AnyObject = { [key: string]: any };\n\n\t\tif (obj && typeof obj === \"object\") {\n\t\t\tif (seen.has(obj as object)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tseen.add(obj as object);\n\n\t\t\tif (Array.isArray(obj)) {\n\t\t\t\treturn obj.map((item) =>\n\t\t\t\t\tthis.removeCircularReferences(item, seen)\n\t\t\t\t) as unknown as T;\n\t\t\t} else {\n\t\t\t\tconst entries = Object.entries(obj as AnyObject).map(\n\t\t\t\t\t([key, value]) => [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tthis.removeCircularReferences(value, seen),\n\t\t\t\t\t]\n\t\t\t\t);\n\t\t\t\treturn Object.fromEntries(entries) as unknown as T;\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t}\n\n\t// =========================================================================\n\t// Type Checking\n\t// =========================================================================\n\n\t/**\n\t * Checks if an unknown value is an array of strings.\n\t *\n\t * @param value - The value to check.\n\t * @returns `true` if `value` is a string array, otherwise `false`.\n\t */\n\tpublic static isArrayOfStrings(value: unknown): value is string[] {\n\t\treturn (\n\t\t\tArray.isArray(value) &&\n\t\t\tvalue.every((item) => typeof item === \"string\")\n\t\t);\n\t}\n\n\t/**\n\t * Roughly checks if a string is a valid Sui type (e.g., \"0x2::sui::SUI\").\n\t * This is not guaranteed to be perfect, but covers common cases.\n\t *\n\t * @param str - The string to validate.\n\t * @returns `true` if it meets the minimum structure, otherwise `false`.\n\t */\n\tpublic static isValidType = (str: string): boolean => {\n\t\t// TODO: use regex\n\t\tconst trimmedStr = str.trim();\n\t\treturn (\n\t\t\ttrimmedStr.startsWith(\"0x\") &&\n\t\t\ttrimmedStr.length >= 9 &&\n\t\t\ttrimmedStr.indexOf(\"::\") >= 3 &&\n\t\t\ttrimmedStr.lastIndexOf(\"::\") >= 6 &&\n\t\t\t!trimmedStr.endsWith(\":\")\n\t\t);\n\t};\n\n\t/**\n\t * Checks if a string is a valid hex representation, optionally prefixed with \"0x\".\n\t *\n\t * @param hexString - The string to check.\n\t * @returns `true` if `hexString` is a valid hex, otherwise `false`.\n\t */\n\tpublic static isValidHex = (hexString: string): boolean => {\n\t\tconst hexPattern = /^(0x)?[0-9A-F]+$/i;\n\t\treturn hexPattern.test(hexString);\n\t};\n\n\t// =========================================================================\n\t// Sui Object Parsing\n\t// =========================================================================\n\n\t/**\n\t * Extracts the fully qualified type (e.g., \"0x2::coin::Coin<...>\") from a `SuiObjectResponse`,\n\t * normalizing it with leading zeroes if necessary.\n\t *\n\t * @param data - The object response from Sui.\n\t * @returns The normalized object type string.\n\t * @throws If the type is not found.\n\t */\n\tpublic static getObjectType(data: SuiObjectResponse): ObjectId {\n\t\tconst objectType = data.data?.type;\n\t\tif (objectType) return Helpers.addLeadingZeroesToType(objectType);\n\n\t\tthrow new Error(\"no object type found on \" + data.data?.objectId);\n\t}\n\n\t/**\n\t * Extracts the object ID from a `SuiObjectResponse`, normalizing it with leading zeroes.\n\t *\n\t * @param data - The object response from Sui.\n\t * @returns A zero-padded `ObjectId`.\n\t * @throws If the objectId is not found.\n\t */\n\tpublic static getObjectId(data: SuiObjectResponse): ObjectId {\n\t\tconst objectId = data.data?.objectId;\n\t\tif (objectId) return Helpers.addLeadingZeroesToType(objectId);\n\n\t\tthrow new Error(\"no object id found on \" + data.data?.type);\n\t}\n\n\t/**\n\t * Retrieves the fields of a Move object from a `SuiObjectResponse`.\n\t *\n\t * @param data - The Sui object response containing a Move object.\n\t * @returns A record of fields for that object.\n\t * @throws If no fields are found.\n\t */\n\tpublic static getObjectFields(\n\t\tdata: SuiObjectResponse\n\t): Record<string, any> {\n\t\ttry {\n\t\t\tconst content = data.data?.content as SuiMoveObject;\n\t\t\treturn content.fields;\n\t\t} catch (e) {\n\t\t\tthrow new Error(\"no object fields found on \" + data.data?.objectId);\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves display metadata from a Sui object response, if present.\n\t *\n\t * @param data - The Sui object response.\n\t * @returns The display fields for that object.\n\t * @throws If display fields are not found.\n\t */\n\tpublic static getObjectDisplay(\n\t\tdata: SuiObjectResponse\n\t): DisplayFieldsResponse {\n\t\tconst display = data.data?.display;\n\t\tif (display) return display;\n\t\tthrow new Error(\"no object display found on \" + data.data?.objectId);\n\t}\n\n\t// =========================================================================\n\t// Tx Command Input Construction\n\t// =========================================================================\n\n\t/**\n\t * Utility for building transaction commands with either a string-based\n\t * `ObjectId` or an existing transaction object argument. If it's a string,\n\t * it's converted via `tx.object(...)`; if already a `TransactionObjectArgument`,\n\t * it's returned as-is.\n\t *\n\t * @param tx - The current `Transaction` block to add the object to.\n\t * @param object - Either an `ObjectId` or a `TransactionObjectArgument`.\n\t * @returns A `TransactionObjectArgument` referencing the provided object.\n\t */\n\tpublic static addTxObject = (\n\t\ttx: Transaction,\n\t\tobject: ObjectId | TransactionObjectArgument\n\t): TransactionObjectArgument => {\n\t\treturn typeof object === \"string\" ? tx.object(object) : object;\n\t};\n\n\t// =========================================================================\n\t// Sui Address / Key Checking\n\t// =========================================================================\n\n\t/**\n\t * Checks if a given string is a valid Sui address by normalizing it to a\n\t * 64-hex-digit form and calling `isValidSuiAddress`.\n\t *\n\t * @param address - The Sui address to validate.\n\t * @returns `true` if valid, `false` otherwise.\n\t */\n\tpublic static isValidSuiAddress = (address: SuiAddress) =>\n\t\tisValidSuiAddress(\n\t\t\t(() => {\n\t\t\t\tif (!address.startsWith(\"0x\") || address.length < 3) return \"\";\n\t\t\t\ttry {\n\t\t\t\t\treturn Helpers.addLeadingZeroesToType(address);\n\t\t\t\t} catch (e) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t})()\n\t\t);\n\n\t// =========================================================================\n\t// Error Parsing\n\t// =========================================================================\n\n\t/**\n\t * Parses a MoveAbort error message from Sui into a possible `(errorCode, packageId, module)`,\n\t * if the message follows a known pattern. Otherwise returns undefined.\n\t *\n\t * @param inputs - The object containing the raw `errorMessage` from Sui.\n\t * @returns A partial structure of the error details or undefined.\n\t */\n\tpublic static parseMoveErrorMessage(inputs: { errorMessage: string }):\n\t\t| {\n\t\t\t\terrorCode: MoveErrorCode;\n\t\t\t\tpackageId: ObjectId;\n\t\t\t\tmodule: ModuleName;\n\t\t }\n\t\t| undefined {\n\t\tconst { errorMessage } = inputs;\n\t\tif (!errorMessage.toLowerCase().includes(\"moveabort\")) return undefined;\n\n\t\t/*\n\t\t\tMoveAbort(MoveLocation { module: ModuleId { address: 8d8946c2a433e2bf795414498d9f7b32e04aca8dbf35a20257542dc51406242b, name: Identifier(\"orderbook\") }, function: 11, instruction: 117, function_name: Some(\"fill_market_order\") }, 3005) in command 2\n\n\t\t\tMoveAbort(MoveLocation { module: ModuleId { address: 7c995f9c0c0553c0f3bfac7cf3c8b85716f0ca522305586bd0168ca20aeed277, name: Identifier(\"clearing_house\") }, function: 37, instruction: 17, function_name: Some(\"place_limit_order\") }, 1) in command 1\n\t\t*/\n\n\t\tconst moveErrorCode = (inputs: {\n\t\t\terrorMessage: string;\n\t\t}): MoveErrorCode | undefined => {\n\t\t\tconst { errorMessage } = inputs;\n\t\t\tconst startIndex = errorMessage.lastIndexOf(\",\");\n\t\t\tconst endIndex = errorMessage.lastIndexOf(\")\");\n\t\t\tif (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)\n\t\t\t\treturn undefined;\n\n\t\t\ttry {\n\t\t\t\tconst errorCode = parseInt(\n\t\t\t\t\terrorMessage.slice(startIndex + 1, endIndex)\n\t\t\t\t);\n\t\t\t\tif (Number.isNaN(errorCode)) return undefined;\n\t\t\t\treturn errorCode;\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tconst moveErrorPackageId = (inputs: {\n\t\t\terrorMessage: string;\n\t\t}): PackageId | undefined => {\n\t\t\tconst { errorMessage } = inputs;\n\n\t\t\tconst startIndex = errorMessage.toLowerCase().indexOf(\"address:\");\n\t\t\tconst endIndex = errorMessage.indexOf(\", name:\");\n\t\t\tif (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)\n\t\t\t\treturn undefined;\n\n\t\t\ttry {\n\t\t\t\tconst pkgStr = errorMessage\n\t\t\t\t\t.slice(startIndex + 8, endIndex)\n\t\t\t\t\t.trim()\n\t\t\t\t\t.replaceAll(\"0x\", \"\");\n\t\t\t\tconst packageId = Helpers.addLeadingZeroesToType(\"0x\" + pkgStr);\n\t\t\t\tif (!this.isValidHex(packageId)) return undefined;\n\t\t\t\treturn packageId;\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tconst moveErrorModule = (inputs: {\n\t\t\terrorMessage: string;\n\t\t}): ModuleName | undefined => {\n\t\t\tconst { errorMessage } = inputs;\n\n\t\t\tconst startIndex = errorMessage\n\t\t\t\t.toLowerCase()\n\t\t\t\t.indexOf('identifier(\"');\n\t\t\tconst endIndex = errorMessage.indexOf('\")');\n\t\t\tif (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)\n\t\t\t\treturn undefined;\n\n\t\t\ttry {\n\t\t\t\treturn errorMessage.slice(startIndex + 12, endIndex).trim();\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t};\n\n\t\tconst errorCode = moveErrorCode({ errorMessage });\n\t\tconst packageId = moveErrorPackageId({ errorMessage });\n\t\tconst module = moveErrorModule({ errorMessage });\n\t\tif (errorCode === undefined || !packageId || !module) return undefined;\n\n\t\treturn { errorCode, packageId, module };\n\t}\n\n\t/**\n\t * Translates a Move abort error message into a known error string if it matches\n\t * entries in a given `moveErrors` table. This is used to map on-chain error codes\n\t * to user-friendly messages.\n\t *\n\t * @param inputs - Includes the raw `errorMessage` and a `moveErrors` object keyed by package, module, and code.\n\t * @returns A structure with `errorCode`, `packageId`, `module`, and a human-readable `error` string, or `undefined`.\n\t */\n\tpublic static translateMoveErrorMessage(inputs: {\n\t\terrorMessage: string;\n\t\tmoveErrors: MoveErrors;\n\t}):\n\t\t| {\n\t\t\t\terrorCode: MoveErrorCode;\n\t\t\t\tpackageId: ObjectId;\n\t\t\t\tmodule: ModuleName;\n\t\t\t\terror: string;\n\t\t }\n\t\t| undefined {\n\t\tconst { errorMessage, moveErrors } = inputs;\n\n\t\tconst parsed = this.parseMoveErrorMessage({ errorMessage });\n\t\tif (!parsed || !(parsed.packageId in moveErrors)) return undefined;\n\n\t\tlet error: string;\n\t\tif (\n\t\t\tparsed.module in moveErrors[parsed.packageId] &&\n\t\t\tparsed.errorCode in moveErrors[parsed.packageId][parsed.module]\n\t\t) {\n\t\t\terror =\n\t\t\t\tmoveErrors[parsed.packageId][parsed.module][parsed.errorCode];\n\t\t} else if (\n\t\t\t\"ANY\" in moveErrors[parsed.packageId] &&\n\t\t\tparsed.errorCode in moveErrors[parsed.packageId][\"ANY\"]\n\t\t) {\n\t\t\terror = moveErrors[parsed.packageId][\"ANY\"][parsed.errorCode];\n\t\t} else return undefined;\n\n\t\treturn {\n\t\t\t...parsed,\n\t\t\terror,\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Keypair\n\t// =========================================================================\n\n\t/**\n\t * Constructs a `Keypair` instance from a private key string. The `privateKey`\n\t * may indicate the signing scheme (ED25519, Secp256k1, or Secp256r1) via prefix,\n\t * as recognized by `decodeSuiPrivateKey`.\n\t *\n\t * @param privateKey - The full private key string (e.g., \"0x<64_hex_chars>\").\n\t * @returns A new `Keypair` instance for signing transactions.\n\t * @throws If the schema is unsupported.\n\t */\n\tpublic static keypairFromPrivateKey = (privateKey: string): Keypair => {\n\t\tconst parsedKeypair = decodeSuiPrivateKey(privateKey);\n\t\tswitch (parsedKeypair.scheme) {\n\t\t\tcase \"ED25519\":\n\t\t\t\treturn Ed25519Keypair.fromSecretKey(parsedKeypair.secretKey);\n\t\t\tcase \"Secp256k1\":\n\t\t\t\treturn Secp256k1Keypair.fromSecretKey(parsedKeypair.secretKey);\n\t\t\tcase \"Secp256r1\":\n\t\t\t\treturn Secp256r1Keypair.fromSecretKey(parsedKeypair.secretKey);\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`unsupported scheme \\`${parsedKeypair.scheme}\\``\n\t\t\t\t);\n\t\t}\n\t};\n}\n","import { Transaction } from \"@mysten/sui/transactions\";\nimport type {\n ApiEventsBody,\n ApiIndexerEventsBody,\n CallerConfig,\n EventsWithCursor,\n IndexerEventsWithCursor,\n SerializedTransaction,\n SuiAddress,\n SuiNetwork,\n UniqueId,\n Url,\n} from \"../../types\";\nimport { Helpers } from \"./helpers\";\n\n/**\n * A JSON.stringify replacer that serializes BigInt values as strings\n * suffixed with \"n\" (e.g. `123n`), without mutating global prototypes.\n */\nfunction bigIntReplacer(_key: string, value: unknown): unknown {\n if (typeof value === \"bigint\") {\n return value.toString() + \"n\";\n }\n return value;\n}\n\ntype ResponseWithTxKind = { txKind: SerializedTransaction } & (\n | Record<string, unknown>\n | {}\n);\n\nexport class Caller {\n protected readonly apiBaseUrl?: Url;\n protected readonly apiEndpoint: Url;\n\n // =========================================================================\n // Constructor\n // =========================================================================\n\n constructor(\n public config: CallerConfig = {},\n private readonly apiUrlPrefix: Url = \"\"\n ) {\n this.apiBaseUrl =\n this.config.network === undefined\n ? undefined\n : Caller.apiBaseUrlForNetwork(this.config.network);\n\n this.apiEndpoint = this.config.network === \"INTERNAL\" ? \"af-fe\" : \"api\";\n }\n\n // =========================================================================\n // Private Methods\n // =========================================================================\n\n private static async fetchResponseToType<OutputType>(\n response: Response,\n disableBigIntJsonParsing: boolean\n ): Promise<OutputType> {\n if (!response.ok) {\n const status = response.status;\n const body = await response.text();\n throw new Error(`HTTP ${status} ${response.statusText}: ${body}`);\n }\n\n const text = await response.text();\n\n const output = disableBigIntJsonParsing\n ? JSON.parse(text, (_key, value) => (value === null ? undefined : value))\n : Helpers.parseJsonWithBigint(text);\n\n return (output ?? undefined) as OutputType;\n }\n\n // =========================================================================\n // Api Calling\n // =========================================================================\n\n private static apiBaseUrlForNetwork(network: SuiNetwork): Url {\n if (network === \"MAINNET\") {\n return \"https://aftermath.finance\";\n }\n if (network === \"TESTNET\") {\n return \"https://testnet.aftermath.finance\";\n }\n if (network === \"DEVNET\") {\n return \"https://devnet.aftermath.finance\";\n }\n if (network === \"LOCAL\") {\n return \"http://localhost:3000\";\n }\n if (network === \"INTERNAL\") {\n return \"http://\";\n }\n return network;\n }\n\n private urlForApiCall = (url: string): Url => {\n if (this.apiBaseUrl === undefined) {\n throw new Error(\"no apiBaseUrl: unable to fetch data\");\n }\n\n // TODO: handle url prefixing and api calls based on network differently\n\n // Note: this slash removal is need to avoid double slashes in the url\n const safeUrl =\n this.apiBaseUrl.slice(-1) === \"/\"\n ? this.apiBaseUrl.slice(0, -1)\n : this.apiBaseUrl;\n\n return `${safeUrl}/${this.apiEndpoint}/${\n this.apiUrlPrefix + (url === \"\" ? \"\" : \"/\")\n }${url}`;\n };\n\n // =========================================================================\n // Protected Methods\n // =========================================================================\n\n // =========================================================================\n // Api Calling\n // =========================================================================\n\n protected async fetchApi<Output, BodyType = undefined>(\n url: Url,\n body?: BodyType,\n signal?: AbortSignal,\n options?: {\n disableBigIntJsonParsing?: boolean;\n }\n ): Promise<Output> {\n const apiCallUrl = this.urlForApiCall(url);\n\n const headers = {\n \"Content-Type\": \"application/json\",\n ...(this.config.accessToken\n ? { Authorization: `Bearer ${this.config.accessToken}` }\n : {}),\n };\n\n const uncastResponse = await (body === undefined\n ? fetch(apiCallUrl, { headers, signal })\n : fetch(apiCallUrl, {\n method: \"POST\",\n body: JSON.stringify(body, bigIntReplacer),\n headers,\n signal,\n }));\n\n return Caller.fetchResponseToType<Output>(\n uncastResponse,\n !!options?.disableBigIntJsonParsing\n );\n }\n\n protected async fetchApiTransaction<BodyType = undefined>(\n url: Url,\n body?: BodyType & { walletAddress?: SuiAddress },\n signal?: AbortSignal,\n options?: {\n disableBigIntJsonParsing?: boolean;\n txKind?: boolean;\n }\n ) {\n const txKind = await this.fetchApi<SerializedTransaction, BodyType>(\n url,\n body,\n signal,\n options\n );\n const tx = options?.txKind\n ? Transaction.fromKind(txKind)\n : Transaction.from(txKind);\n // NOTE: is this needed ?\n if (body?.walletAddress) {\n tx.setSender(body.walletAddress);\n }\n return tx;\n }\n\n protected async fetchApiTxObject<\n BodyType extends object,\n OutputType extends ResponseWithTxKind,\n >(\n url: Url,\n body?: BodyType & { walletAddress?: SuiAddress },\n signal?: AbortSignal,\n options?: { disableBigIntJsonParsing?: boolean; txKind?: boolean }\n ): Promise<\n Omit<Extract<OutputType, ResponseWithTxKind>, \"txKind\"> & {\n tx: Transaction;\n }\n > {\n const response = await this.fetchApi<OutputType, BodyType>(\n url,\n body,\n signal,\n options\n );\n\n const tx = Transaction.fromKind(response.txKind);\n\n if (body?.walletAddress) {\n tx.setSender(body.walletAddress);\n }\n\n const { txKind, ...rest } = response;\n type Rest = Omit<Extract<OutputType, ResponseWithTxKind>, \"txKind\">;\n return { ...(rest as Rest), tx };\n }\n\n protected async fetchApiEvents<EventType, BodyType = ApiEventsBody>(\n url: Url,\n body: BodyType,\n signal?: AbortSignal,\n options?: {\n disableBigIntJsonParsing?: boolean;\n }\n ) {\n return this.fetchApi<EventsWithCursor<EventType>, BodyType>(\n url,\n body,\n signal,\n options\n );\n }\n\n protected async fetchApiIndexerEvents<\n EventType,\n BodyType extends ApiIndexerEventsBody,\n >(\n url: Url,\n body: BodyType,\n signal?: AbortSignal,\n options?: {\n disableBigIntJsonParsing?: boolean;\n }\n ): Promise<IndexerEventsWithCursor<EventType>> {\n const events = await this.fetchApi<EventType[], BodyType>(\n url,\n body,\n signal,\n options\n );\n // TODO: handle this logic on af-fe instead (to handle max limit case)\n return {\n events,\n nextCursor:\n events.length < (body.limit ?? 1)\n ? undefined\n : events.length + (body.cursor ?? 0),\n };\n }\n\n protected setAccessToken = (accessToken: UniqueId) => {\n this.config.accessToken = accessToken;\n };\n\n /**\n * Open a generic websocket stream.\n * - Automatically parses inbound JSON via `Helpers.parseJsonWithBigint`.\n * - Automatically enables BigInt -> \"123n\" serialization (same one-liner as `fetchApi`).\n */\n protected openWsStream<WsRequestMessage, WsResponseMessage>(args: {\n path: Url;\n onMessage: (message: WsResponseMessage) => void;\n onOpen?: (ev: Event) => void;\n onError?: (ev: Event) => void;\n onClose?: (ev: CloseEvent) => void;\n }) {\n const { path, onMessage, onOpen, onError, onClose } = args;\n\n /**\n * Build a WS URL using the same base the HTTP calls use, plus this.apiEndpoint and apiUrlPrefix.\n * Mirrors `urlForApiCall`, but swaps http(s) -> ws(s).\n */\n const buildWsUrl = (path: string): Url => {\n if (this.apiBaseUrl === undefined) {\n throw new Error(\"no apiBaseUrl: unable to open websocket\");\n }\n\n // Normalize base & path\n const baseHttp = this.apiBaseUrl.replace(/\\/+$/, \"\");\n const baseWs = baseHttp.replace(/^http(s?):\\/\\//, \"ws$1://\");\n\n // Prefix with endpoint + service prefix (same pattern as fetch)\n const prefix = `${this.apiEndpoint}/${this.apiUrlPrefix}`;\n const normalizedPrefix = prefix.replace(/\\/+$/, \"\");\n const normalizedPath = path.startsWith(\"/\") ? path.slice(1) : path;\n\n return `${baseWs}/${normalizedPrefix}${\n normalizedPath ? \"/\" + normalizedPath : \"\"\n }`;\n };\n\n const url = buildWsUrl(path);\n const ws = new WebSocket(url);\n\n ws.addEventListener(\"open\", (ev) => onOpen?.(ev));\n ws.addEventListener(\"error\", (ev) => onError?.(ev));\n ws.addEventListener(\"close\", (ev) => onClose?.(ev));\n\n ws.addEventListener(\"message\", (ev) => {\n try {\n const data = Helpers.parseJsonWithBigint(\n ev.data as string\n ) as WsResponseMessage;\n onMessage?.(data);\n } catch (error) {\n args.onError?.(\n new ErrorEvent(\"message-parse-error\", {\n error,\n message:\n error instanceof Error\n ? error.message\n : \"Failed to parse WebSocket message\",\n })\n );\n }\n });\n\n const send = (value: WsRequestMessage) => {\n if (ws.readyState !== WebSocket.OPEN) {\n throw new Error(\"WebSocket is not open\");\n }\n ws.send(JSON.stringify(value, bigIntReplacer));\n };\n\n const close = () => ws.close();\n\n return { ws, send, close };\n }\n}\n","import {\n\tCallerConfig,\n\tSignMessageCallback,\n\tSuiAddress,\n\tSuiNetwork,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiCreateAuthAccountBody,\n\tApiGetAccessTokenBody,\n\tApiGetAccessTokenResponse,\n\tRateLimit,\n} from \"./authTypes\";\nimport { Helpers } from \"../../general/utils\";\n\n/**\n * The `Auth` class manages creation and refreshing of access tokens\n * to obtain higher rate limits on the Aftermath API. It includes methods\n * to initialize authorization either by a direct callback-based approach\n * or by importing a local Sui keystore. Optionally, administrative functions\n * are provided for creating specialized auth accounts.\n *\n * @example\n * ```typescript\n * const auth = new Auth();\n * const stopAuth = await auth.init({\n * walletAddress: \"0x<address>\",\n * signMessageCallback: async ({ message }) => {\n * // sign message\n * },\n * });\n * // ... make authenticated requests ...\n * stopAuth(); // stop auto refresh\n * ```\n */\nexport class Auth extends Caller {\n\t// =========================================================================\n\t// Private Class Members\n\t// =========================================================================\n\n\t/**\n\t * Holds the timer reference for scheduled token refreshes.\n\t */\n\tprivate refreshTimer: ReturnType<typeof setTimeout> | null = null;\n\t/**\n\t * Indicates whether the user has canceled auto token refresh.\n\t */\n\tprivate isCanceled = false;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `Auth` instance for token-based rate limit increases.\n\t *\n\t * @param config - Optional caller configuration, including network and access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"auth\");\n\t}\n\n\t// =========================================================================\n\t// User-Facing\n\t// =========================================================================\n\n\t/**\n\t * Initializes the auth system by fetching an access token for the provided wallet address.\n\t * After obtaining the token, it automatically schedules periodic refresh calls until stopped.\n\t *\n\t * @param inputs - An object containing the user's `walletAddress` and a `signMessageCallback` function\n\t * for cryptographically signing messages.\n\t *\n\t * @returns A function that, when called, cancels further token refresh attempts.\n\t *\n\t * @example\n\t * ```typescript\n\t * const auth = new Auth();\n\t * const stopAuth = await auth.init({\n\t * walletAddress: \"0x<address>\",\n\t * signMessageCallback: async ({ message }) => {\n\t * // sign the message with your private key / keypair\n\t * },\n\t * });\n\t *\n\t * // ... make authorized calls ...\n\t *\n\t * stopAuth(); // Cancel further token refreshes\n\t * ```\n\t */\n\tpublic async init(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tsignMessageCallback: SignMessageCallback;\n\t}): Promise<() => void> {\n\t\tthis.isCanceled = false; // Mark as active\n\n\t\tconst startRefresh = async () => {\n\t\t\tif (this.isCanceled) return; // No-op if canceled\n\n\t\t\tconst { accessToken, expirationTimestamp } =\n\t\t\t\tawait this.getAccessToken(inputs);\n\t\t\tthis.setAccessToken(accessToken);\n\n\t\t\tif (this.isCanceled) return; // Double-check after token fetch\n\n\t\t\t// Provide a margin by refreshing before actual expiration\n\t\t\tconst TIMEOUT_REDUCTION_RATIO = 0.9;\n\t\t\tconst interval =\n\t\t\t\t(expirationTimestamp - Date.now()) * TIMEOUT_REDUCTION_RATIO;\n\n\t\t\t// Schedule next refresh\n\t\t\tthis.refreshTimer = setTimeout(startRefresh, interval);\n\t\t};\n\n\t\t// Kick off first refresh\n\t\tawait startRefresh();\n\n\t\t// Return cancellation function\n\t\treturn () => {\n\t\t\tthis.isCanceled = true;\n\t\t\tif (this.refreshTimer) {\n\t\t\t\tclearTimeout(this.refreshTimer);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Initializes the auth system by reading a local Sui keystore file (on the server side),\n\t * using the private keys matching a provided address to sign messages for token creation.\n\t * After the token is obtained, it automatically schedules periodic refresh calls until stopped.\n\t *\n\t * @param inputs - An object containing the target `walletAddress` and an optional path to the `.keystore`.\n\t * If `path` is not provided, it defaults to `~/.sui/sui_config/sui.keystore`.\n\t * @returns A function that, when called, cancels further token refresh attempts.\n\t *\n\t * @throws If this method is called in a browser environment (client-side).\n\t *\n\t * @example\n\t * ```typescript\n\t * // On server:\n\t * const stopAuth = await auth.initFromSuiKeystore({\n\t * walletAddress: \"0x<address>\",\n\t * path: \"/custom/path/to/keystore.json\",\n\t * });\n\t * // authorized calls...\n\t * stopAuth();\n\t * ```\n\t */\n\t// public async initFromSuiKeystore(inputs: {\n\t// \twalletAddress: SuiAddress;\n\t// \tpath?: string;\n\t// }): Promise<() => void> {\n\t// \tconst { walletAddress, path: pathStr } = inputs;\n\n\t// \tif (typeof window === \"undefined\") {\n\t// \t\t// Node environment, proceed with reading a keystore\n\t// \t\tconst fs = require(\"fs\");\n\t// \t\tconst path = require(\"path\");\n\t// \t\tconst os = require(\"os\");\n\n\t// \t\tconst keystorePath = pathStr\n\t// \t\t\t? path.join(pathStr)\n\t// \t\t\t: (() => {\n\t// \t\t\t\t\t// Default to ~/.sui/sui_config/sui.keystore\n\t// \t\t\t\t\tconst homeDir = os.homedir();\n\t// \t\t\t\t\tif (!homeDir) {\n\t// \t\t\t\t\t\tthrow new Error(\n\t// \t\t\t\t\t\t\t\"cannot obtain home directory path\"\n\t// \t\t\t\t\t\t);\n\t// \t\t\t\t\t}\n\t// \t\t\t\t\treturn path.join(\n\t// \t\t\t\t\t\thomeDir,\n\t// \t\t\t\t\t\t\".sui\",\n\t// \t\t\t\t\t\t\"sui_config\",\n\t// \t\t\t\t\t\t\"sui.keystore\"\n\t// \t\t\t\t\t);\n\t// \t\t\t })();\n\n\t// \t\t// Read JSON with an array of private keys\n\t// \t\tlet privateKeys: string[];\n\t// \t\ttry {\n\t// \t\t\tconst fileContent = fs.readFileSync(keystorePath, \"utf-8\");\n\t// \t\t\tprivateKeys = JSON.parse(fileContent);\n\n\t// \t\t\tif (!Array.isArray(privateKeys)) {\n\t// \t\t\t\tthrow new Error(\n\t// \t\t\t\t\t\"Invalid keystore format: Expected an array of private keys\"\n\t// \t\t\t\t);\n\t// \t\t\t}\n\t// \t\t} catch (error) {\n\t// \t\t\tthrow new Error(`Failed to read keystore file: ${error}`);\n\t// \t\t}\n\t// \t\tif (privateKeys.length <= 0) {\n\t// \t\t\tthrow new Error(`Empty keystore file`);\n\t// \t\t}\n\n\t// \t\t// Find the matching key for the requested walletAddress\n\t// \t\tconst foundKeypair = privateKeys\n\t// \t\t\t.map((privateKey) => Helpers.keypairFromPrivateKey(privateKey))\n\t// \t\t\t.find(\n\t// \t\t\t\t(keypair) =>\n\t// \t\t\t\t\tHelpers.addLeadingZeroesToType(\n\t// \t\t\t\t\t\tkeypair.toSuiAddress()\n\t// \t\t\t\t\t) === Helpers.addLeadingZeroesToType(walletAddress)\n\t// \t\t\t);\n\t// \t\tif (!foundKeypair) {\n\t// \t\t\tthrow new Error(\n\t// \t\t\t\t`No private key found in keystore file for ${walletAddress}`\n\t// \t\t\t);\n\t// \t\t}\n\n\t// \t\t// Initialize with sign callback\n\t// \t\treturn this.init({\n\t// \t\t\twalletAddress,\n\t// \t\t\tsignMessageCallback: async ({ message }) =>\n\t// \t\t\t\tfoundKeypair.signPersonalMessage(message),\n\t// \t\t});\n\t// \t}\n\n\t// \tthrow new Error(\"`initFromSuiKeystore` must be called on server-side\");\n\t// }\n\n\t// =========================================================================\n\t// Admin\n\t// =========================================================================\n\n\t/**\n\t * **Admin-only**: Creates a new auth account with specific rate limits for a given\n\t * `accountWalletAddress`. The `walletAddress` performing this action must have\n\t * admin privileges, or the call will fail. Use this to create custom sub-accounts\n\t * with limited scope or usage rates.\n\t *\n\t * @param inputs - Contains:\n\t * - `walletAddress`: The admin's wallet address\n\t * - `signMessageCallback`: The admin's signing callback\n\t * - `accountName`: A short name or identifier for the account\n\t * - `accountWalletAddress`: The Sui address representing this sub-account\n\t * - `rateLimits`: An array specifying the rate limits (method-based) for the sub-account\n\t * @returns A promise resolving to `true` if successful, otherwise throws or returns `false`.\n\t */\n\tpublic async adminCreateAuthAccount(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tsignMessageCallback: SignMessageCallback;\n\t\taccountName: string;\n\t\taccountWalletAddress: SuiAddress;\n\t\trateLimits: RateLimit[];\n\t}): Promise<boolean> {\n\t\tconst {\n\t\t\twalletAddress,\n\t\t\tsignMessageCallback,\n\t\t\taccountName,\n\t\t\taccountWalletAddress,\n\t\t\trateLimits,\n\t\t} = inputs;\n\n\t\t// Prepare the data to sign\n\t\tconst serializedJson = Auth.createSerializedJson<{\n\t\t\tsub: string;\n\t\t\twallet_address: SuiAddress;\n\t\t\trate_limits: RateLimit[];\n\t\t}>(\"AccountCreate\", {\n\t\t\tsub: accountName,\n\t\t\twallet_address:\n\t\t\t\tHelpers.addLeadingZeroesToType(accountWalletAddress),\n\t\t\trate_limits: rateLimits,\n\t\t});\n\t\tconst message = new TextEncoder().encode(serializedJson);\n\n\t\tconst { signature } = await signMessageCallback({ message });\n\n\t\treturn this.fetchApi<boolean, ApiCreateAuthAccountBody>(\n\t\t\t\"create-account\",\n\t\t\t{\n\t\t\t\tsignature,\n\t\t\t\tserializedJson,\n\t\t\t\twalletAddress: Helpers.addLeadingZeroesToType(walletAddress),\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Private\n\t// =========================================================================\n\n\t/**\n\t * Requests a new access token from the API by sending a signed message\n\t * indicating the user wants a token.\n\t *\n\t * @param inputs - Contains the user's `walletAddress` and `signMessageCallback`.\n\t * @returns A response object that includes the `accessToken` and an `expirationTimestamp`.\n\t */\n\tprivate async getAccessToken(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tsignMessageCallback: SignMessageCallback;\n\t}): Promise<ApiGetAccessTokenResponse> {\n\t\tconst { walletAddress, signMessageCallback } = inputs;\n\n\t\t// Prepare signable data\n\t\tconst serializedJson = Auth.createSerializedJson(\"GetAccessToken\", {});\n\t\tconst message = new TextEncoder().encode(serializedJson);\n\n\t\tconst { signature } = await signMessageCallback({ message });\n\n\t\treturn this.fetchApi<ApiGetAccessTokenResponse, ApiGetAccessTokenBody>(\n\t\t\t\"access-token\",\n\t\t\t{\n\t\t\t\tsignature,\n\t\t\t\tserializedJson,\n\t\t\t\twalletAddress: Helpers.addLeadingZeroesToType(walletAddress),\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Private Static\n\t// =========================================================================\n\n\t/**\n\t * Creates a JSON string with a standard format:\n\t * ```json\n\t * {\n\t * \"date\": <epoch-seconds>,\n\t * \"nonce\": <random_number>,\n\t * \"method\": <method_string>,\n\t * \"value\": <passed_value>\n\t * }\n\t * ```\n\t *\n\t * @param method - A short method name describing the action (\"GetAccessToken\", \"AccountCreate\", etc.).\n\t * @param value - The data object to embed under the `value` field.\n\t * @returns A JSON-serialized string for signing.\n\t */\n\tprivate static createSerializedJson<DataToSerialize extends Object>(\n\t\tmethod: string,\n\t\tvalue: DataToSerialize\n\t) {\n\t\tconst timestampSeconds = Math.floor(Date.now() / 1000);\n\t\tconst random = Math.floor(Math.random() * 1024 * 1024);\n\t\tconst data = {\n\t\t\tdate: timestampSeconds,\n\t\t\tnonce: random,\n\t\t\tmethod,\n\t\t\tvalue,\n\t\t};\n\t\treturn JSON.stringify(data);\n\t}\n}\n","export * from \"./auth\";\n","import {\n\tApr,\n\tBalance,\n\tCallerConfig,\n\tCoinType,\n\tCoinsToDecimals,\n\tCoinsToPrice,\n\tObjectId,\n\tSuiAddress,\n\tSuiNetwork,\n\tTimestamp,\n\tUrl,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiFarmsGrantOneTimeAdminCapBody,\n\tApiFarmsIncreaseStakingPoolRewardsEmissionsBody,\n\tApiFarmsInitializeStakingPoolRewardBody,\n\tApiFarmsTopUpStakingPoolRewardsBody,\n\tFarmOwnerOrOneTimeAdminCap,\n\tFarmsMultiplier,\n\tFarmsStakingPoolObject,\n\tFarmsStakingPoolRewardCoin,\n\tFarmsVersion,\n} from \"./farmsTypes\";\nimport { Casting, Helpers } from \"../../general/utils\";\nimport dayjs from \"dayjs\";\nimport duration from \"dayjs/plugin/duration\";\nimport { FixedUtils } from \"../../general/utils/fixedUtils\";\nimport { Coin } from \"../coin/coin\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Farms } from \"./farms\";\n\n/**\n * The `FarmsStakingPool` class represents a staking pool (also referred\n * to as a \"vault\" in some contexts). It allows reading details about\n * emission schedules, reward tokens, stake coin type, and lock durations,\n * as well as constructing transactions to stake, harvest, and mutate the\n * pool parameters if the user has the correct admin privileges.\n */\nexport class FarmsStakingPool extends Caller {\n\t/**\n\t * Creates a `FarmsStakingPool` instance based on on-chain pool data.\n\t *\n\t * @param stakingPool - The on-chain data object describing the pool.\n\t * @param config - An optional `CallerConfig` for network settings.\n\t * @param Provider - An optional `AftermathApi` for transaction building.\n\t */\n\tconstructor(\n\t\tpublic stakingPool: FarmsStakingPoolObject,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"farms\");\n\t\tthis.stakingPool = stakingPool;\n\t}\n\n\t// =========================================================================\n\t// Public\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Stats\n\t// =========================================================================\n\n\t/**\n\t * Fetches the total value locked (TVL) for this staking pool alone.\n\t *\n\t * @returns A `number` representing this pool's TVL in USD (or another currency).\n\t *\n\t * @example\n\t * ```typescript\n\t * const poolTvl = await someFarmsPool.getTVL();\n\t * console.log(poolTvl);\n\t * ```\n\t */\n\tpublic async getTVL(): Promise<number> {\n\t\treturn new Farms(this.config, this.Provider).getTVL({\n\t\t\tfarmIds: [this.stakingPool.objectId],\n\t\t});\n\t}\n\n\t/**\n\t * Fetches the total value locked (TVL) of the reward coins in this specific staking pool.\n\t *\n\t * @returns A `number` representing this pool's reward TVL.\n\t *\n\t * @example\n\t * ```typescript\n\t * const rewardTvl = await someFarmsPool.getRewardsTVL();\n\t * console.log(rewardTvl);\n\t * ```\n\t */\n\tpublic async getRewardsTVL(): Promise<number> {\n\t\treturn new Farms(this.config, this.Provider).getRewardsTVL({\n\t\t\tfarmIds: [this.stakingPool.objectId],\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the version of this staking pool (1 or 2).\n\t */\n\tpublic version = (): FarmsVersion => {\n\t\treturn this.stakingPool.version;\n\t};\n\n\t/**\n\t * Returns whether this pool uses strict lock enforcement.\n\t * Strict: positions must be unlocked before any principal can be withdrawn.\n\t */\n\tpublic isStrictLockEnforcement = (): boolean => {\n\t\treturn this.stakingPool.lockEnforcement === \"Strict\";\n\t};\n\n\t/**\n\t * Returns whether this pool uses relaxed lock enforcement.\n\t * Relaxed: positions can withdraw principal while locked, forfeiting pro-rata locked rewards.\n\t */\n\tpublic isRelaxedLockEnforcement = (): boolean => {\n\t\treturn this.stakingPool.lockEnforcement === \"Relaxed\";\n\t};\n\n\t/**\n\t * Lists all reward coin types offered by this staking pool.\n\t *\n\t * @returns An array of `CoinType` strings.\n\t */\n\tpublic rewardCoinTypes = (): CoinType[] => {\n\t\treturn this.stakingPool.rewardCoins.map((coin) => coin.coinType);\n\t};\n\n\t/**\n\t * Lists all reward coin types for which this pool currently has a non-zero actual reward balance.\n\t *\n\t * @returns An array of `CoinType` strings that have > 0 actual rewards.\n\t */\n\tpublic nonZeroRewardCoinTypes = (): CoinType[] => {\n\t\treturn this.stakingPool.rewardCoins\n\t\t\t.filter(\n\t\t\t\t(coin) =>\n\t\t\t\t\tcoin.emissionRate <= coin.actualRewards &&\n\t\t\t\t\tcoin.actualRewards > BigInt(0)\n\t\t\t)\n\t\t\t.map((coin) => coin.coinType);\n\t};\n\n\t/**\n\t * Retrieves the on-chain record for a specific reward coin type in this pool.\n\t *\n\t * @param inputs - Contains the `coinType` to look up.\n\t * @throws If the specified coinType is not found in `rewardCoins`.\n\t * @returns A `FarmsStakingPoolRewardCoin` object.\n\t */\n\tpublic rewardCoin = (inputs: { coinType: CoinType }) => {\n\t\tconst foundCoin = this.stakingPool.rewardCoins.find(\n\t\t\t(coin) => coin.coinType === inputs.coinType\n\t\t);\n\t\tif (!foundCoin) throw new Error(\"Invalid coin type\");\n\n\t\treturn foundCoin;\n\t};\n\n\t/**\n\t * Computes the maximum lock duration (in ms) that remains valid in this staking pool,\n\t * factoring in the current time and the pool's emission end.\n\t *\n\t * @returns The maximum possible lock duration in milliseconds, or 0 if the pool is effectively closed.\n\t */\n\tpublic maxLockDurationMs = (): number => {\n\t\treturn Math.max(\n\t\t\tMath.min(\n\t\t\t\tthis.stakingPool.maxLockDurationMs,\n\t\t\t\tthis.stakingPool.emissionEndTimestamp - dayjs().valueOf()\n\t\t\t),\n\t\t\t0\n\t\t);\n\t};\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculates and applies newly emitted rewards for each reward coin in this pool,\n\t * updating the `rewardsAccumulatedPerShare`. This simulates the on-chain\n\t * `emitRewards` logic.\n\t *\n\t * @example\n\t * ```typescript\n\t * someFarmsPool.emitRewards();\n\t * // The pool's rewardsAccumulatedPerShare fields are now updated.\n\t * ```\n\t */\n\tpublic emitRewards = () => {\n\t\tconst currentTimestamp = dayjs().valueOf();\n\n\t\t// If no staked amount, no distribution\n\t\tif (this.stakingPool.stakedAmount === BigInt(0)) return;\n\n\t\tconst rewardCoins = Helpers.deepCopy(this.stakingPool.rewardCoins);\n\n\t\tfor (const [rewardCoinIndex, rewardCoin] of rewardCoins.entries()) {\n\t\t\t// ib. Check that enough time has passed since the last emission.\n\t\t\tif (\n\t\t\t\tcurrentTimestamp <\n\t\t\t\trewardCoin.lastRewardTimestamp + rewardCoin.emissionSchedulesMs\n\t\t\t)\n\t\t\t\tcontinue;\n\n\t\t\t// iia. Calculate how many rewards have to be emitted.\n\t\t\tconst rewardsToEmit = this.calcRewardsToEmit({ rewardCoin });\n\t\t\tif (rewardsToEmit === BigInt(0)) continue;\n\n\t\t\t// iii. Increase the amount of rewards emitted per share.\n\t\t\tthis.increaseRewardsAccumulatedPerShare({\n\t\t\t\trewardsToEmit,\n\t\t\t\trewardCoinIndex,\n\t\t\t});\n\n\t\t\tconst numberOfEmissions =\n\t\t\t\t(currentTimestamp - rewardCoin.lastRewardTimestamp) /\n\t\t\t\trewardCoin.emissionSchedulesMs;\n\n\t\t\t// IMPORTANT: only increase by multiples of `emission_schedule_ms`.\n\t\t\t//\n\t\t\t// iv. Update reward's `last_reward_timestamp`.\n\t\t\tthis.stakingPool.rewardCoins[rewardCoinIndex].lastRewardTimestamp =\n\t\t\t\trewardCoin.lastRewardTimestamp +\n\t\t\t\tnumberOfEmissions * rewardCoin.emissionSchedulesMs;\n\t\t}\n\t};\n\n\t/**\n\t * Computes an approximate APR for a specific reward coin, based on the current\n\t * emission rate, coin price, pool TVL, and the lock multiplier range. This assumes\n\t * maximum lock multiplier for the final APR result.\n\t *\n\t * @param inputs - Includes the `coinType`, its `price` and `decimals`, plus the total `tvlUsd` in the pool.\n\t * @returns A numeric APR (0.05 = 5%).\n\t */\n\tpublic calcApr = (inputs: {\n\t\tcoinType: CoinType;\n\t\tprice: number;\n\t\tdecimals: number;\n\t\ttvlUsd: number;\n\t}): Apr => {\n\t\tconst { coinType, price, decimals, tvlUsd } = inputs;\n\t\tif (price <= 0 || tvlUsd <= 0) return 0;\n\n\t\tconst rewardCoin = this.rewardCoin({ coinType });\n\t\tconst currentTimestamp = dayjs().valueOf();\n\n\t\t// If the current emission rate is below the actual supply, or if the pool hasn't started or is ended, yield 0\n\t\tif (rewardCoin.emissionRate > rewardCoin.actualRewards) return 0;\n\t\tif (\n\t\t\trewardCoin.emissionStartTimestamp > currentTimestamp ||\n\t\t\tcurrentTimestamp > this.stakingPool.emissionEndTimestamp\n\t\t) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst emissionRateTokens = rewardCoin.emissionRate;\n\t\tconst emissionRateUsd =\n\t\t\tCoin.balanceWithDecimals(emissionRateTokens, decimals) * price;\n\n\t\tdayjs.extend(duration);\n\t\tconst oneYearMs = dayjs.duration(1, \"year\").asMilliseconds();\n\t\tconst rewardsUsdOneYear =\n\t\t\temissionRateUsd * (oneYearMs / rewardCoin.emissionSchedulesMs);\n\n\t\t// The final APR is normalized by total staked value and the maximum lock multiplier\n\t\tconst apr =\n\t\t\trewardsUsdOneYear /\n\t\t\ttvlUsd /\n\t\t\tCasting.bigIntToFixedNumber(this.stakingPool.maxLockMultiplier);\n\n\t\treturn apr < 0 ? 0 : isNaN(apr) ? 0 : apr;\n\t};\n\n\t/**\n\t * Computes the total APR contributed by all reward coin types in this pool, summing\n\t * up the individual APR for each coin type. This also assumes max lock multiplier.\n\t *\n\t * @param inputs - Contains price data (`coinsToPrice`), decimal data (`coinsToDecimals`), and the total TVL in USD.\n\t * @returns The sum of all coin APRs (0.10 = 10%).\n\t */\n\tpublic calcTotalApr = (inputs: {\n\t\tcoinsToPrice: CoinsToPrice;\n\t\tcoinsToDecimals: CoinsToDecimals;\n\t\ttvlUsd: number;\n\t}): Apr => {\n\t\tconst { coinsToPrice, coinsToDecimals, tvlUsd } = inputs;\n\n\t\tconst aprs = this.rewardCoinTypes().map((coinType) =>\n\t\t\tthis.calcApr({\n\t\t\t\tcoinType,\n\t\t\t\tprice: coinsToPrice[coinType],\n\t\t\t\tdecimals: coinsToDecimals[coinType],\n\t\t\t\ttvlUsd,\n\t\t\t})\n\t\t);\n\t\treturn Helpers.sum(aprs);\n\t};\n\n\t/**\n\t * Given a lock duration in ms, calculates the lock multiplier to be used by staked positions.\n\t * This function clamps the input duration between the pool's `minLockDurationMs` and\n\t * `maxLockDurationMs`.\n\t *\n\t * @param inputs - An object containing the `lockDurationMs` for which to calculate a multiplier.\n\t * @returns A `FarmsMultiplier` (bigint) representing the scaled factor (1.0 = 1e9 if using fixedOneB).\n\t */\n\tpublic calcMultiplier = (inputs: {\n\t\tlockDurationMs: number;\n\t}): FarmsMultiplier => {\n\t\tconst lockDurationMs =\n\t\t\tinputs.lockDurationMs > this.stakingPool.maxLockDurationMs\n\t\t\t\t? this.stakingPool.maxLockDurationMs\n\t\t\t\t: inputs.lockDurationMs < this.stakingPool.minLockDurationMs\n\t\t\t\t? this.stakingPool.minLockDurationMs\n\t\t\t\t: inputs.lockDurationMs;\n\n\t\tconst totalPossibleLockDurationMs =\n\t\t\tthis.stakingPool.maxLockDurationMs -\n\t\t\tthis.stakingPool.minLockDurationMs;\n\n\t\tconst newMultiplier =\n\t\t\t1 +\n\t\t\t((lockDurationMs - this.stakingPool.minLockDurationMs) /\n\t\t\t\t(totalPossibleLockDurationMs <= 0\n\t\t\t\t\t? 1\n\t\t\t\t\t: totalPossibleLockDurationMs)) *\n\t\t\t\t(Casting.bigIntToFixedNumber(\n\t\t\t\t\tthis.stakingPool.maxLockMultiplier\n\t\t\t\t) -\n\t\t\t\t\t1);\n\n\t\tconst multiplier = Casting.numberToFixedBigInt(newMultiplier);\n\t\treturn multiplier < FixedUtils.fixedOneB\n\t\t\t? FixedUtils.fixedOneB\n\t\t\t: Helpers.minBigInt(multiplier, this.stakingPool.maxLockMultiplier);\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to stake tokens into this pool, optionally locking them.\n\t *\n\t * @param inputs - Contains `stakeAmount`, `lockDurationMs`, `walletAddress`, and optional sponsorship.\n\t * @returns A transaction object (or bytes) that can be signed and executed to create a staked position.\n\t */\n\tpublic async getStakeTransaction(inputs: {\n\t\tstakeAmount: Balance;\n\t\tlockDurationMs: Timestamp;\n\t\twalletAddress: SuiAddress;\n\t\t// lockEnforcement?: FarmsLockEnforcement;\n\t\tisSponsoredTx?: boolean;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().fetchBuildStakeTxV1(args)\n\t\t\t: this.useProvider().fetchBuildStakeTxV2({\n\t\t\t\t\t...args,\n\t\t\t });\n\t}\n\n\t// =========================================================================\n\t// Reward Harvesting Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to harvest rewards from multiple staked positions in this pool.\n\t *\n\t * @param inputs - Contains `stakedPositionIds`, the `walletAddress`, and optionally any others.\n\t * @returns A transaction that can be signed and executed to claim rewards from multiple positions.\n\t */\n\tpublic async getHarvestRewardsTransaction(inputs: {\n\t\tstakedPositionIds: ObjectId[];\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t\trewardCoinTypes: this.nonZeroRewardCoinTypes(),\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildHarvestRewardsTxV1(args)\n\t\t\t: this.useProvider().buildHarvestRewardsTxV2(args);\n\t}\n\n\t// =========================================================================\n\t// Mutation/Creation Transactions (Owner Only)\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to increase the emission rate (or schedule) for specific reward coins.\n\t *\n\t * @param inputs - Contains the `ownerCapId` that authorizes changes, plus an array of `rewards` with new emission details.\n\t * @returns A transaction to be signed and executed by the owner cap holder.\n\t */\n\tpublic async getIncreaseRewardsEmissionsTransaction(inputs: {\n\t\townerCapId: ObjectId;\n\t\trewards: {\n\t\t\trewardCoinType: CoinType;\n\t\t\temissionScheduleMs: Timestamp;\n\t\t\temissionRate: bigint;\n\t\t}[];\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildIncreaseStakingPoolRewardsEmissionsTxV1(\n\t\t\t\t\targs\n\t\t\t )\n\t\t\t: this.useProvider().buildIncreaseStakingPoolRewardsEmissionsTxV2(\n\t\t\t\t\targs\n\t\t\t );\n\t}\n\n\t/**\n\t * Builds a transaction to update the pool's minimum stake amount, only authorized by the `ownerCapId`.\n\t *\n\t * @param inputs - Contains the new `minStakeAmount`, the `ownerCapId`, and the calling `walletAddress`.\n\t * @returns A transaction that can be signed and executed to change the minimum stake requirement.\n\t */\n\tpublic async getUpdateMinStakeAmountTransaction(inputs: {\n\t\townerCapId: ObjectId;\n\t\tminStakeAmount: bigint;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildSetStakingPoolMinStakeAmountTxV1(args)\n\t\t\t: this.useProvider().buildSetStakingPoolMinStakeAmountTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction granting a one-time admin cap to another address, allowing them to perform specific\n\t * one-time administrative actions (like initializing a reward).\n\t *\n\t * @param inputs - Body containing the `ownerCapId`, the `recipientAddress`, and the `rewardCoinType`.\n\t * @returns A transaction to be executed by the current pool owner.\n\t */\n\tpublic getGrantOneTimeAdminCapTransaction(\n\t\tinputs: ApiFarmsGrantOneTimeAdminCapBody\n\t) {\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildGrantOneTimeAdminCapTxV1(inputs)\n\t\t\t: this.useProvider().buildGrantOneTimeAdminCapTxV2(inputs);\n\t}\n\n\t// =========================================================================\n\t// Mutation Transactions (Owner/Admin Only)\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to initialize a new reward coin in this pool, specifying the amount, emission rate,\n\t * and schedule parameters. This can be done by either the `ownerCapId` or a `oneTimeAdminCapId`.\n\t *\n\t * @param inputs - Contains emission info (rate, schedule) and which cap is used (`ownerCapId` or `oneTimeAdminCapId`).\n\t * @returns A transaction object for the reward initialization.\n\t */\n\tpublic async getInitializeRewardTransaction(\n\t\tinputs: {\n\t\t\trewardAmount: Balance;\n\t\t\temissionScheduleMs: Timestamp;\n\t\t\temissionRate: bigint;\n\t\t\temissionDelayTimestampMs: Timestamp;\n\t\t\trewardCoinType: CoinType;\n\t\t\twalletAddress: SuiAddress;\n\t\t\tisSponsoredTx?: boolean;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().fetchBuildInitializeStakingPoolRewardTxV1(args)\n\t\t\t: this.useProvider().fetchBuildInitializeStakingPoolRewardTxV2(\n\t\t\t\t\targs\n\t\t\t );\n\t}\n\n\t/**\n\t * Builds a transaction to add more reward coins (top-up) to an existing reward\n\t * coin configuration, either as the owner or via a one-time admin cap.\n\t *\n\t * @param inputs - Contains an array of reward objects, each specifying amount and coin type.\n\t * @returns A transaction that can be signed and executed to increase the reward distribution pool.\n\t */\n\tpublic async getTopUpRewardsTransaction(\n\t\tinputs: {\n\t\t\trewards: {\n\t\t\t\trewardAmount: Balance;\n\t\t\t\trewardCoinType: CoinType;\n\t\t\t}[];\n\t\t\twalletAddress: SuiAddress;\n\t\t\tisSponsoredTx?: boolean;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().fetchBuildTopUpStakingPoolRewardsTxV1(args)\n\t\t\t: this.useProvider().fetchBuildTopUpStakingPoolRewardsTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction to **remove (withdraw) undistributed reward coins** from the\n\t * staking pool for **one or more reward coin types** in a single call.\n\t *\n\t * Only the **pool owner** (via `ownerCapId`) can remove rewards. One-time admin caps\n\t * are **not** permitted for removals. This operation reduces the pool’s remaining\n\t * undistributed reward balances; it does **not** affect rewards already accrued/claimed\n\t * by stakers.\n\t *\n\t * Versioning:\n\t * - V1 → calls `buildRemoveStakingPoolRewardTxV1`\n\t * - V2 → calls `buildRemoveStakingPoolRewardTxV2`\n\t *\n\t * Notes:\n\t * - The effective `stakingPoolId` and `stakeCoinType` are taken from this instance’s\n\t * `this.stakingPool` and override any values passed in `inputs`.\n\t *\n\t * @param inputs Parameters for reward removal.\n\t * @param inputs.rewards Array of removal entries. Each entry specifies:\n\t * - `rewardCoinType`: Coin type to withdraw.\n\t * - `rewardAmount`: Amount to withdraw (base units).\n\t * @param inputs.ownerCapId Object ID of the pool OwnerCap that authorizes the removal.\n\t * @param inputs.walletAddress Address that will sign/submit the transaction.\n\t * @returns A transaction object ready to sign and execute that removes the specified\n\t * undistributed rewards for each entry in `inputs.rewards`.\n\t */\n\tpublic getRemoveRewardsTransaction(inputs: {\n\t\trewards: {\n\t\t\trewardCoinType: CoinType;\n\t\t\trewardAmount: Balance;\n\t\t}[];\n\t\townerCapId: ObjectId;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakeCoinType: this.stakingPool.stakeCoinType,\n\t\t\tstakingPoolId: this.stakingPool.objectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildRemoveStakingPoolRewardTxV1(args)\n\t\t\t: this.useProvider().buildRemoveStakingPoolRewardTxV2(args);\n\t}\n\n\t// =========================================================================\n\t// Private\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Updates `rewardsAccumulatedPerShare` by distributing `rewardsToEmit` among\n\t * the total staked amount with multiplier. This mimics on-chain distribution logic.\n\t *\n\t * @param inputs - Contains the `rewardsToEmit` and which `rewardCoinIndex` to update.\n\t */\n\tprivate increaseRewardsAccumulatedPerShare(inputs: {\n\t\trewardsToEmit: Balance;\n\t\trewardCoinIndex: number;\n\t}) {\n\t\tconst { rewardsToEmit, rewardCoinIndex } = inputs;\n\t\tconst stakedWithMultiplier =\n\t\t\tthis.stakingPool.stakedAmountWithMultiplier;\n\n\t\tif (stakedWithMultiplier === BigInt(0)) return;\n\n\t\t// Distribute proportionally\n\t\tconst newRewardsAccumulatedPerShare =\n\t\t\t(rewardsToEmit * BigInt(1_000_000_000_000_000_000)) /\n\t\t\tstakedWithMultiplier;\n\n\t\tif (newRewardsAccumulatedPerShare === BigInt(0)) return;\n\n\t\tthis.stakingPool.rewardCoins[\n\t\t\trewardCoinIndex\n\t\t].rewardsAccumulatedPerShare += newRewardsAccumulatedPerShare;\n\t}\n\n\t/**\n\t * Computes how many rewards to emit based on the time since `lastRewardTimestamp` and\n\t * the pool's emission schedule, clamped by the total `rewardsRemaining`.\n\t */\n\tprivate calcRewardsToEmit(inputs: {\n\t\trewardCoin: FarmsStakingPoolRewardCoin;\n\t}): Balance {\n\t\tconst { rewardCoin } = inputs;\n\t\tconst currentTimestamp = dayjs().valueOf();\n\n\t\t// Calculate the number of rewards that have been emitted since the last time this reward was emitted.\n\t\tconst rewardsToEmit = this.calcRewardsEmittedFromTimeTmToTn({\n\t\t\ttimestampTm: rewardCoin.lastRewardTimestamp,\n\t\t\ttimestampTn: currentTimestamp,\n\t\t\trewardCoin,\n\t\t});\n\t\tconst { rewardsRemaining } = rewardCoin;\n\n\t\t// IMPORTANT: Cap the amount of rewards to emit by the amount of remaining rewards.\n\t\treturn rewardsRemaining < rewardsToEmit\n\t\t\t? rewardsRemaining\n\t\t\t: rewardsToEmit;\n\t}\n\n\t/**\n\t * Calculates how many tokens were emitted between two timestamps (Tm and Tn) for a given reward coin,\n\t * based on the discrete `emissionRate` and `emissionSchedulesMs`.\n\t *\n\t * @param inputs - Contains `timestampTm`, `timestampTn`, and the relevant `rewardCoin`.\n\t * @returns The total number of tokens emitted in that time window.\n\t */\n\tprivate calcRewardsEmittedFromTimeTmToTn(inputs: {\n\t\ttimestampTm: Timestamp;\n\t\ttimestampTn: Timestamp;\n\t\trewardCoin: FarmsStakingPoolRewardCoin;\n\t}): Balance {\n\t\tconst { timestampTm, timestampTn, rewardCoin } = inputs;\n\t\tconst numberOfEmissionsFromTimeTmToTn =\n\t\t\trewardCoin.emissionSchedulesMs === 0\n\t\t\t\t? 0\n\t\t\t\t: (timestampTn - timestampTm) / rewardCoin.emissionSchedulesMs;\n\n\t\treturn (\n\t\t\tBigInt(Math.floor(numberOfEmissionsFromTimeTmToTn)) *\n\t\t\trewardCoin.emissionRate\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Provides access to the farm-specific provider methods for building transactions.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Farms();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiFarmsDepositPrincipalBody,\n\tApiFarmsLockBody,\n\tApiFarmsRenewLockBody,\n\tApiFarmsUnlockBody,\n\tApiFarmsUnstakeBody,\n\tApiHarvestFarmsRewardsBody,\n\tApr,\n\tBalance,\n\tCallerConfig,\n\tCoinType,\n\tCoinsToBalance,\n\tFarmsStakedPositionObject,\n\tFarmsVersion,\n\tSuiAddress,\n\tSuiNetwork,\n\tTimestamp,\n\tUrl,\n} from \"../../types\";\nimport { FarmsStakingPool } from \"./farmsStakingPool\";\nimport { FixedUtils } from \"../../general/utils/fixedUtils\";\nimport { Helpers } from \"../../general/utils\";\nimport dayjs from \"dayjs\";\nimport duration from \"dayjs/plugin/duration\";\nimport { Farms } from \"./farms\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * The `FarmsStakedPosition` class represents a user's individual staked position\n * in a particular staking pool. It provides methods to query position details,\n * calculate potential rewards, lock/unlock stake, and build transactions\n * for depositing, unstaking, or harvesting rewards.\n */\nexport class FarmsStakedPosition extends Caller {\n\t/**\n\t * The timestamp (in ms) when rewards were last harvested for this position, possibly overriding the\n\t * on-chain data if provided in the constructor.\n\t */\n\tpublic readonly trueLastHarvestRewardsTimestamp: Timestamp;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a `FarmsStakedPosition` instance for a user's staked position in a farm.\n\t *\n\t * @param stakedPosition - The on-chain data object representing the user's staked position.\n\t * @param trueLastHarvestRewardsTimestamp - Optionally overrides the last harvest time from the on-chain data.\n\t * @param config - Optional configuration for the underlying `Caller`.\n\t * @param Provider - Optional `AftermathApi` instance for transaction building.\n\t */\n\tconstructor(\n\t\tpublic stakedPosition: FarmsStakedPositionObject,\n\t\ttrueLastHarvestRewardsTimestamp: Timestamp | undefined = undefined,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"farms\");\n\t\tthis.stakedPosition = stakedPosition;\n\t\tthis.trueLastHarvestRewardsTimestamp =\n\t\t\ttrueLastHarvestRewardsTimestamp ??\n\t\t\tstakedPosition.lastHarvestRewardsTimestamp;\n\t}\n\n\t// =========================================================================\n\t// Public\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\t/**\n\t * Returns the version of the farm system that this position belongs to (1 or 2).\n\t */\n\tpublic version = (): FarmsVersion => {\n\t\treturn this.stakedPosition.version;\n\t};\n\n\t/**\n\t * Checks whether the position is still locked, based on the current time and the lock parameters.\n\t *\n\t * @param inputs - Contains a `FarmsStakingPool` instance to check for system constraints.\n\t * @returns `true` if the position is locked; otherwise, `false`.\n\t */\n\tpublic isLocked = (inputs: { stakingPool: FarmsStakingPool }): boolean => {\n\t\treturn !this.isUnlocked(inputs);\n\t};\n\n\t/**\n\t * Checks if the position is strictly locked, meaning it is currently locked and the pool uses strict lock enforcement.\n\t *\n\t * @param inputs - Contains a `FarmsStakingPool` instance to check lock state and enforcement.\n\t * @returns `true` if locked with strict enforcement; otherwise, `false`.\n\t */\n\tpublic isStrictlyLocked = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): boolean => {\n\t\tconst { stakingPool } = inputs;\n\t\treturn (\n\t\t\tthis.isLocked({ stakingPool }) &&\n\t\t\tstakingPool.isStrictLockEnforcement()\n\t\t);\n\t};\n\n\t/**\n\t * Checks if the position is relaxed locked, meaning it is currently locked and the pool uses relaxed lock enforcement.\n\t *\n\t * @param inputs - Contains a `FarmsStakingPool` instance to check lock state and enforcement.\n\t * @returns `true` if locked with relaxed enforcement; otherwise, `false`.\n\t */\n\tpublic isRelaxedLocked = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): boolean => {\n\t\tconst { stakingPool } = inputs;\n\t\treturn (\n\t\t\tthis.isLocked({ stakingPool }) &&\n\t\t\tstakingPool.isRelaxedLockEnforcement()\n\t\t);\n\t};\n\n\t/**\n\t * Checks whether the position has a non-zero lock duration.\n\t *\n\t * @returns `true` if the position was created with a lock duration > 0.\n\t */\n\tpublic isLockDuration = (): boolean => {\n\t\treturn this.stakedPosition.lockDurationMs > 0;\n\t};\n\n\t/**\n\t * Computes the timestamp (in ms) at which this position's lock will end.\n\t *\n\t * @returns The unlock timestamp (lock start + lock duration).\n\t */\n\tpublic unlockTimestamp = (): number => {\n\t\treturn (\n\t\t\tthis.stakedPosition.lockStartTimestamp +\n\t\t\tthis.stakedPosition.lockDurationMs\n\t\t);\n\t};\n\n\t/**\n\t * Computes the user's accrued rewards for each reward coin in this position,\n\t * returned as a `CoinsToBalance` object keyed by coin type.\n\t *\n\t * @param inputs - Contains a reference to the `FarmsStakingPool`.\n\t * @returns A mapping from `coinType` to the amount of earned rewards.\n\t */\n\tpublic rewardCoinsToClaimableBalance = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): CoinsToBalance => {\n\t\treturn this.stakedPosition.rewardCoins.reduce(\n\t\t\t(acc, coin) => ({\n\t\t\t\t...acc,\n\t\t\t\t[coin.coinType]: this.rewardsEarned({\n\t\t\t\t\t...inputs,\n\t\t\t\t\tcoinType: coin.coinType,\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t{} as CoinsToBalance\n\t\t);\n\t};\n\n\t/**\n\t * Lists all reward coin types associated with this position.\n\t *\n\t * @returns An array of `CoinType` strings representing the reward coins.\n\t */\n\tpublic rewardCoinTypes = (): CoinType[] => {\n\t\treturn this.stakedPosition.rewardCoins.map((coin) => coin.coinType);\n\t};\n\n\t/**\n\t * Returns only the reward coin types that currently have a non-zero claimable balance.\n\t *\n\t * @param inputs - Contains a reference to the `FarmsStakingPool`.\n\t * @returns An array of `CoinType` strings that have pending rewards > 0.\n\t */\n\tpublic nonZeroRewardCoinTypes = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): CoinType[] => {\n\t\treturn Object.entries(this.rewardCoinsToClaimableBalance(inputs))\n\t\t\t.filter(([, val]) => val > BigInt(0))\n\t\t\t.map(([key]) => key);\n\t};\n\n\t/**\n\t * Retrieves the reward coin record for a specific coin type in this position.\n\t *\n\t * @param inputs - Must contain a `coinType` string to look up.\n\t * @throws If the coin type is not found in this position.\n\t * @returns The reward coin object from the position.\n\t */\n\tpublic rewardCoin = (inputs: { coinType: CoinType }) => {\n\t\tconst foundCoin = this.stakedPosition.rewardCoins.find(\n\t\t\t(coin) => coin.coinType === inputs.coinType\n\t\t);\n\t\tif (!foundCoin) throw new Error(\"Invalid coin type\");\n\n\t\treturn foundCoin;\n\t};\n\n\t/**\n\t * Checks if this position has any claimable rewards across all reward coin types.\n\t *\n\t * @param inputs - Contains a reference to the `FarmsStakingPool`.\n\t * @returns `true` if there are unclaimed rewards; otherwise, `false`.\n\t */\n\tpublic hasClaimableRewards = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): boolean => {\n\t\tconst { stakingPool } = inputs;\n\n\t\treturn (\n\t\t\tHelpers.sumBigInt(\n\t\t\t\tthis.rewardCoinTypes().map((coinType) =>\n\t\t\t\t\tthis.rewardsEarned({\n\t\t\t\t\t\tcoinType,\n\t\t\t\t\t\tstakingPool,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t) > BigInt(0)\n\t\t);\n\t};\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculates the current amount of earned rewards for a specific coin type,\n\t * factoring in any emission constraints and the pool's actual reward availability.\n\t *\n\t * @param inputs - Contains the `coinType` to check and a reference to the `FarmsStakingPool`.\n\t * @returns The total `BigInt` amount of rewards earned for the specified coin type.\n\t */\n\tpublic rewardsEarned = (inputs: {\n\t\tcoinType: CoinType;\n\t\tstakingPool: FarmsStakingPool;\n\t}): Balance => {\n\t\tif (inputs.stakingPool.rewardCoin(inputs).actualRewards === BigInt(0))\n\t\t\treturn BigInt(0);\n\n\t\t// this.updatePosition(inputs);\n\n\t\tconst rewardCoin = this.rewardCoin(inputs);\n\t\tconst totalRewards =\n\t\t\trewardCoin.multiplierRewardsAccumulated +\n\t\t\trewardCoin.baseRewardsAccumulated;\n\n\t\t// If below the minimum threshold to claim, show 0. If the total rewards\n\t\t// exceed what's actually in the pool, we clamp it to 0 or a logic fallback.\n\t\tif (totalRewards < Farms.constants.minRewardsToClaim) {\n\t\t\treturn BigInt(0);\n\t\t}\n\n\t\t// Additional clamp to handle overshoot beyond actual pool reserves\n\t\treturn totalRewards >\n\t\t\tinputs.stakingPool.rewardCoin(inputs).actualRewards\n\t\t\t? BigInt(0)\n\t\t\t: totalRewards;\n\t};\n\n\t/**\n\t * Updates the position's reward calculations based on the pool's current\n\t * emission state, effectively \"syncing\" the on-chain logic into this local\n\t * representation. Also checks if the lock duration has elapsed.\n\t *\n\t * @param inputs - Contains a reference to the `FarmsStakingPool`.\n\t * @remarks This method is typically called before computing `rewardsEarned()`.\n\t */\n\tpublic updatePosition = (inputs: { stakingPool: FarmsStakingPool }) => {\n\t\tconst stakingPool = new FarmsStakingPool(\n\t\t\tHelpers.deepCopy(inputs.stakingPool.stakingPool),\n\t\t\tthis.config\n\t\t);\n\n\t\t// If the lock multiplier is valid, proceed. If not, adjust the staked position\n\t\t// to the pool's maximum allowed lock multiplier or duration.\n\t\tif (\n\t\t\tthis.stakedPosition.lockDurationMs <=\n\t\t\t\tstakingPool.stakingPool.maxLockDurationMs &&\n\t\t\tthis.stakedPosition.lockMultiplier <=\n\t\t\t\tstakingPool.stakingPool.maxLockMultiplier\n\t\t) {\n\t\t\t// Lock multiplier is valid; do nothing special\n\t\t} else {\n\t\t\t// The position's lock duration or multiplier exceeds the pool's max allowed -> clamp\n\t\t\tstakingPool.stakingPool.stakedAmountWithMultiplier -=\n\t\t\t\tthis.stakedPosition.stakedAmountWithMultiplier;\n\n\t\t\t// ii. Update the `lock_duration` and `lock_multiplier` related fields.\n\t\t\tthis.stakedPosition.lockDurationMs =\n\t\t\t\tstakingPool.stakingPool.maxLockDurationMs;\n\t\t\tthis.stakedPosition.lockMultiplier =\n\t\t\t\tstakingPool.stakingPool.maxLockMultiplier;\n\n\t\t\tthis.stakedPosition.stakedAmountWithMultiplier =\n\t\t\t\t(this.stakedPosition.stakedAmount *\n\t\t\t\t\t(this.stakedPosition.lockMultiplier -\n\t\t\t\t\t\tFixedUtils.fixedOneB)) /\n\t\t\t\tFixedUtils.fixedOneB;\n\n\t\t\tthis.stakedPosition.rewardCoins = [\n\t\t\t\t...this.stakedPosition.rewardCoins.map((rewardCoin) => {\n\t\t\t\t\tconst currentDebtPerShare = stakingPool.rewardCoin({\n\t\t\t\t\t\tcoinType: rewardCoin.coinType,\n\t\t\t\t\t}).rewardsAccumulatedPerShare;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rewardCoin,\n\t\t\t\t\t\tmultiplierRewardsDebt:\n\t\t\t\t\t\t\t(this.stakedPosition.stakedAmountWithMultiplier *\n\t\t\t\t\t\t\t\tcurrentDebtPerShare) /\n\t\t\t\t\t\t\tFixedUtils.fixedOneB,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t];\n\n\t\t\t// iii. Increase the `Vault`'s `total_staked_amount_with_multiplier` to account for the\n\t\t\t// positions new lock multiplier.\n\t\t\tstakingPool.stakingPool.stakedAmountWithMultiplier +=\n\t\t\t\tthis.stakedPosition.stakedAmountWithMultiplier;\n\t\t}\n\n\t\tconst currentTimestamp = dayjs().valueOf();\n\t\t// Accumulate any newly emitted rewards in the pool’s state\n\t\tstakingPool.emitRewards();\n\n\t\t// Update position’s base + multiplier rewards using the updated pool info\n\t\tfor (const [\n\t\t\trewardCoinIndex,\n\t\t\trewardCoin,\n\t\t] of stakingPool.stakingPool.rewardCoins.entries()) {\n\t\t\t//******************************************************************************************//\n\t\t\t// debt (i.e. total_rewards_from_time_t0_to_th-1) //\n\t\t\t// .--- pending_rewards_at_time_th_minus_1 ---| //\n\t\t\t// |------------------------------------------+-------------------------------------------| //\n\t\t\t// t0 th-1 now //\n\t\t\t// '----------------------------- total_rewards_from_time_t0 -----------------------------' //\n\t\t\t//******************************************************************************************//\n\n\t\t\t// NOTE: new reward types might have been added to the vault since this position last called\n\t\t\t// `update_ pending_rewards`, so we need to be cautious when borrowing from `rewards_debt`\n\t\t\t// and `rewards_accumulated`.\n\t\t\t//\n\t\t\tif (rewardCoinIndex >= this.stakedPosition.rewardCoins.length) {\n\t\t\t\tthis.stakedPosition.rewardCoins.push({\n\t\t\t\t\tcoinType: rewardCoin.coinType,\n\t\t\t\t\tbaseRewardsAccumulated: BigInt(0),\n\t\t\t\t\tbaseRewardsDebt: BigInt(0),\n\t\t\t\t\tmultiplierRewardsAccumulated: BigInt(0),\n\t\t\t\t\tmultiplierRewardsDebt: BigInt(0),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst stakedPositionRewardCoin =\n\t\t\t\tthis.stakedPosition.rewardCoins[rewardCoinIndex];\n\n\t\t\tconst [\n\t\t\t\ttotalBaseRewardsFromTimeT0,\n\t\t\t\ttotalMultiplierRewardsFromTimeT0,\n\t\t\t] = this.calcTotalRewardsFromTimeT0({\n\t\t\t\trewardsAccumulatedPerShare:\n\t\t\t\t\trewardCoin.rewardsAccumulatedPerShare,\n\t\t\t\tmultiplierRewardsDebt:\n\t\t\t\t\tstakedPositionRewardCoin.multiplierRewardsDebt,\n\t\t\t\temissionEndTimestamp:\n\t\t\t\t\tstakingPool.stakingPool.emissionEndTimestamp,\n\t\t\t});\n\n\t\t\t// Add newly accrued rewards since the last update\n\t\t\tthis.stakedPosition.rewardCoins[\n\t\t\t\trewardCoinIndex\n\t\t\t].baseRewardsAccumulated =\n\t\t\t\ttotalBaseRewardsFromTimeT0 -\n\t\t\t\tstakedPositionRewardCoin.baseRewardsDebt +\n\t\t\t\tstakedPositionRewardCoin.baseRewardsAccumulated;\n\n\t\t\tthis.stakedPosition.rewardCoins[\n\t\t\t\trewardCoinIndex\n\t\t\t].multiplierRewardsAccumulated =\n\t\t\t\ttotalMultiplierRewardsFromTimeT0 -\n\t\t\t\tstakedPositionRewardCoin.multiplierRewardsDebt +\n\t\t\t\tstakedPositionRewardCoin.multiplierRewardsAccumulated;\n\n\t\t\t// Update debts to the new total from time t0\n\t\t\tthis.stakedPosition.rewardCoins[rewardCoinIndex].baseRewardsDebt =\n\t\t\t\ttotalBaseRewardsFromTimeT0;\n\n\t\t\tthis.stakedPosition.rewardCoins[\n\t\t\t\trewardCoinIndex\n\t\t\t].multiplierRewardsDebt = totalMultiplierRewardsFromTimeT0;\n\t\t}\n\n\t\t// Check if this position’s lock has expired\n\t\t// if (this.unlockTimestamp() < currentTimestamp) {\n\t\t// \tthis.unlock();\n\t\t// }\n\n\t\tthis.stakedPosition.lastHarvestRewardsTimestamp = currentTimestamp;\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to deposit additional principal into this staked position.\n\t *\n\t * @param inputs - Contains `depositAmount`, the `walletAddress` performing the deposit, and optional sponsorship.\n\t * @returns A transaction object (or bytes) that can be signed and executed to increase stake.\n\t */\n\tpublic async getDepositPrincipalTransaction(inputs: {\n\t\tdepositAmount: Balance;\n\t\twalletAddress: SuiAddress;\n\t\tisSponsoredTx?: boolean;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().fetchBuildDepositPrincipalTxV1(args)\n\t\t\t: this.useProvider().fetchBuildDepositPrincipalTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction to unstake this entire position, optionally claiming SUI as afSUI.\n\t *\n\t * @param inputs - Contains `walletAddress`, the `FarmsStakingPool` reference, and optional `claimSuiAsAfSui`.\n\t * @returns A transaction that can be signed and executed to fully withdraw principal and possibly rewards.\n\t */\n\tpublic async getUnstakeTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tstakingPool: FarmsStakingPool;\n\t\tclaimSuiAsAfSui?: boolean;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t\twithdrawAmount: this.stakedPosition.stakedAmount,\n\t\t\trewardCoinTypes: this.nonZeroRewardCoinTypes(inputs),\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildUnstakeTxV1(args)\n\t\t\t: this.useProvider().buildUnstakeTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction to withdraw a partial amount of principal from this staked position.\n\t * Unlike `getUnstakeTransaction`, this does NOT destroy the position.\n\t *\n\t * @param inputs - Contains `walletAddress`, `withdrawAmount`, and the `FarmsStakingPool` reference.\n\t * @returns A transaction that can be signed and executed to withdraw principal without destroying the position.\n\t */\n\tpublic async getWithdrawPrincipalTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\twithdrawAmount: Balance;\n\t\tstakingPool: FarmsStakingPool;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildWithdrawPrincipalTxV1(args)\n\t\t\t: this.useProvider().buildWithdrawPrincipalTxV2(args);\n\t}\n\n\t// =========================================================================\n\t// Locking Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to lock this position for a specified duration, increasing its lock multiplier (if any).\n\t *\n\t * @param inputs - Contains the `lockDurationMs` and the `walletAddress`.\n\t * @returns A transaction that can be signed and executed to lock the position.\n\t */\n\tpublic async getLockTransaction(inputs: {\n\t\tlockDurationMs: Timestamp;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildLockTxV1(args)\n\t\t\t: this.useProvider().buildLockTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction to re-lock this position (renew lock duration) at the current multiplier.\n\t *\n\t * @param inputs - Contains the `walletAddress`.\n\t * @returns A transaction that can be signed and executed to extend or refresh the lock.\n\t */\n\tpublic async getRenewLockTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildRenewLockTxV1(args)\n\t\t\t: this.useProvider().buildRenewLockTxV2(args);\n\t}\n\n\t/**\n\t * Builds a transaction to unlock this position, removing any lock-based multiplier.\n\t *\n\t * @param inputs - Contains the `walletAddress`.\n\t * @returns A transaction that can be signed and executed to unlock the position immediately.\n\t */\n\tpublic async getUnlockTransaction(inputs: { walletAddress: SuiAddress }) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionId: this.stakedPosition.objectId,\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildUnlockTxV1(args)\n\t\t\t: this.useProvider().buildUnlockTxV2(args);\n\t}\n\n\t// =========================================================================\n\t// Reward Harvesting Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction to harvest (claim) the rewards from this position,\n\t * optionally receiving SUI as afSUI.\n\t *\n\t * @param inputs - Includes the `walletAddress`, the `FarmsStakingPool`, and optional `claimSuiAsAfSui`.\n\t * @returns A transaction that can be signed and executed to claim accrued rewards.\n\t */\n\tpublic async getHarvestRewardsTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tstakingPool: FarmsStakingPool;\n\t\tclaimSuiAsAfSui?: boolean;\n\t}) {\n\t\tconst args = {\n\t\t\t...inputs,\n\t\t\tstakedPositionIds: [this.stakedPosition.objectId],\n\t\t\tstakeCoinType: this.stakedPosition.stakeCoinType,\n\t\t\tstakingPoolId: this.stakedPosition.stakingPoolObjectId,\n\t\t\trewardCoinTypes: this.nonZeroRewardCoinTypes(inputs),\n\t\t};\n\t\treturn this.version() === 1\n\t\t\t? this.useProvider().buildHarvestRewardsTxV1(args)\n\t\t\t: this.useProvider().buildHarvestRewardsTxV2(args);\n\t}\n\n\t// =========================================================================\n\t// Private\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculates the total base + multiplier rewards from time t0 for this position,\n\t * ensuring that multiplier rewards only apply during the locked period.\n\t *\n\t * @param inputs - Contains updated `rewardsAccumulatedPerShare`, the position’s `multiplierRewardsDebt`, and the pool’s `emissionEndTimestamp`.\n\t * @returns A tuple `[baseRewards, multiplierRewards]`.\n\t */\n\tprivate calcTotalRewardsFromTimeT0(inputs: {\n\t\trewardsAccumulatedPerShare: Balance;\n\t\tmultiplierRewardsDebt: Balance;\n\t\temissionEndTimestamp: Timestamp;\n\t}): [Balance, Balance] {\n\t\tconst {\n\t\t\trewardsAccumulatedPerShare,\n\t\t\tmultiplierRewardsDebt,\n\t\t\temissionEndTimestamp,\n\t\t} = inputs;\n\n\t\tconst lastRewardTimestamp =\n\t\t\tthis.stakedPosition.lastHarvestRewardsTimestamp;\n\t\tconst lockEndTimestamp = this.unlockTimestamp();\n\n\t\tconst principalStakedAmount = this.stakedPosition.stakedAmount;\n\t\tconst baseRewards =\n\t\t\t(principalStakedAmount * rewardsAccumulatedPerShare) /\n\t\t\tFixedUtils.fixedOneB;\n\n\t\t// const totalMultiplierRewards =\n\t\t// \t(this.stakedPosition.stakedAmountWithMultiplier *\n\t\t// \t\trewardsAccumulatedPerShare) /\n\t\t// \tFixedUtils.fixedOneB;\n\n\t\tconst multiplierEndTimestamp = Math.min(\n\t\t\tlockEndTimestamp,\n\t\t\temissionEndTimestamp\n\t\t);\n\n\t\tconst multiplierRewards = (() => {\n\t\t\tif (lastRewardTimestamp <= multiplierEndTimestamp) {\n\t\t\t\treturn (\n\t\t\t\t\t(rewardsAccumulatedPerShare *\n\t\t\t\t\t\tthis.stakedPosition.stakedAmountWithMultiplier) /\n\t\t\t\t\tFixedUtils.fixedOneB\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\treturn multiplierRewardsDebt;\n\t\t\t}\n\t\t})();\n\n\t\treturn [baseRewards, multiplierRewards];\n\t}\n\n\t// /**\n\t// * Removes the lock multiplier from this position if the current time is beyond the lock duration,\n\t// * reverting `lockMultiplier` to 1.0 (fixedOneB).\n\t// */\n\t// private unlock = () => {\n\t// \t// ia. Remove position's `multiplier_staked_amount` from the pool.\n\t// \t// afterburner_vault::decrease_stake_with_multiplier(vault, self.multiplier_staked_amount);\n\t// \tthis.stakedPosition.stakedAmountWithMultiplier = BigInt(0);\n\n\t// \t// ib. Reset position's lock parameters.\n\t// \tthis.stakedPosition.lockDurationMs = 0;\n\t// \tthis.stakedPosition.lockMultiplier = FixedUtils.fixedOneB;\n\t// };\n\n\t/**\n\t * Determines if this position is unlocked based on the lock end timestamp, the emission end timestamp,\n\t * or a forced unlock condition in the pool.\n\t */\n\tprivate isUnlocked = (inputs: {\n\t\tstakingPool: FarmsStakingPool;\n\t}): boolean => {\n\t\tconst { stakingPool } = inputs;\n\t\tconst currentTime = dayjs().valueOf();\n\n\t\t// If lock has expired, the emission has ended, or the pool is forcibly unlocked, then it is unlocked\n\t\treturn (\n\t\t\tthis.unlockTimestamp() <= currentTime ||\n\t\t\tstakingPool.stakingPool.emissionEndTimestamp <= currentTime ||\n\t\t\tstakingPool.stakingPool.isUnlocked\n\t\t);\n\t};\n\n\t/**\n\t * Provides access to the `Farms` provider in the `AftermathApi`.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Farms();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import {\n\tEventsInputs,\n\tSuiNetwork,\n\tUrl,\n\tObjectId,\n\tSuiAddress,\n\tApiIndexerEventsBody,\n\tCallerConfig,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiFarmsCreateStakingPoolBody,\n\tApiFarmsCreateStakingPoolBodyV1,\n\tApiFarmsOwnedStakedPositionsBody,\n\tApiFarmsOwnedStakingPoolOneTimeAdminCapsBody,\n\tApiFarmsOwnedStakingPoolOwnerCapsBody,\n\tFarmsDepositedPrincipalEvent,\n\tFarmsHarvestedRewardsEvent,\n\tFarmsLockedEvent,\n\tFarmsStakedEvent,\n\tFarmsStakedPositionObject,\n\tFarmsStakedRelaxedEvent,\n\tFarmsStakingPoolObject,\n\tFarmsUnlockedEvent,\n\tFarmsWithdrewPrincipalEvent,\n\tFarmUserEvent,\n\tStakingPoolOneTimeAdminCapObject,\n\tStakingPoolOwnerCapObject,\n} from \"./farmsTypes\";\nimport { FarmsStakingPool } from \"./farmsStakingPool\";\nimport { FarmsStakedPosition } from \"./farmsStakedPosition\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * The `Farms` class provides high-level methods for interacting with\n * staking pools (farms) on the Sui network. It allows fetching pool\n * details, user staked positions, and building transactions for creating\n * new pools. This class also enables retrieving user interactions (events)\n * with the farming system.\n */\nexport class Farms extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Contains constants relevant to farming, including minimum rewards to claim\n\t * and maximum lock multipliers.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * The minimum number of rewards (in smallest units) that can be claimed.\n\t\t */\n\t\tminRewardsToClaim: BigInt(10),\n\t\t/**\n\t\t * The maximum lock multiplier that can be applied when locking a staked position.\n\t\t */\n\t\tmaxLockMultiplier: 2,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `Farms` instance for fetching staking pool data and building\n\t * farm-related transactions.\n\t *\n\t * @param config - Optional configuration, including network and access token.\n\t * @param Provider - An optional `AftermathApi` instance for advanced transaction building.\n\t */\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"farms\");\n\t}\n\n\t// =========================================================================\n\t// Public\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Class Objects\n\t// =========================================================================\n\n\t/**\n\t * Fetches a single staking pool by its `objectId` from the farm API/indexer.\n\t *\n\t * @param inputs - An object containing the `objectId` of the staking pool.\n\t * @returns A `FarmsStakingPool` object representing the staking pool.\n\t *\n\t * @example\n\t * ```typescript\n\t * const pool = await farms.getStakingPool({ objectId: \"0x<pool_id>\" });\n\t * console.log(pool.stakingPool);\n\t * ```\n\t */\n\tpublic async getStakingPool(inputs: {\n\t\tobjectId: ObjectId;\n\t}): Promise<FarmsStakingPool> {\n\t\tconst stakingPool = await this.fetchApi<FarmsStakingPoolObject>(\n\t\t\tinputs.objectId\n\t\t);\n\t\treturn new FarmsStakingPool(stakingPool, this.config, this.Provider);\n\t}\n\n\t/**\n\t * Fetches multiple staking pools by their `objectIds`.\n\t *\n\t * @param inputs - An object containing an array of `objectIds`.\n\t * @returns An array of `FarmsStakingPool` instances corresponding to each `objectId`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const pools = await farms.getStakingPools({\n\t * objectIds: [\"0x<id1>\", \"0x<id2>\"]\n\t * });\n\t * console.log(pools[0].stakingPool, pools[1].stakingPool);\n\t * ```\n\t */\n\tpublic async getStakingPools(inputs: {\n\t\tobjectIds: ObjectId[];\n\t}): Promise<FarmsStakingPool[]> {\n\t\tconst stakingPools = await this.fetchApi<\n\t\t\tFarmsStakingPoolObject[],\n\t\t\t{\n\t\t\t\tfarmIds: ObjectId[];\n\t\t\t}\n\t\t>(\"\", {\n\t\t\tfarmIds: inputs.objectIds,\n\t\t});\n\t\treturn stakingPools.map(\n\t\t\t(stakingPool) =>\n\t\t\t\tnew FarmsStakingPool(stakingPool, this.config, this.Provider)\n\t\t);\n\t}\n\n\t/**\n\t * Fetches all existing staking pools registered within the indexer or farm API.\n\t *\n\t * @returns An array of `FarmsStakingPool` objects.\n\t *\n\t * @example\n\t * ```typescript\n\t * const allPools = await farms.getAllStakingPools();\n\t * console.log(allPools.map(pool => pool.stakingPool));\n\t * ```\n\t */\n\tpublic async getAllStakingPools() {\n\t\tconst stakingPools: FarmsStakingPoolObject[] = await this.fetchApi(\n\t\t\t\"\",\n\t\t\t{}\n\t\t);\n\t\treturn stakingPools.map(\n\t\t\t(pool) => new FarmsStakingPool(pool, this.config, this.Provider)\n\t\t);\n\t}\n\n\t/**\n\t * Fetches all staked positions owned by a given user.\n\t *\n\t * @param inputs - An object containing the user's `walletAddress`.\n\t * @returns An array of `FarmsStakedPosition` objects representing each of the user's staked positions.\n\t *\n\t * @example\n\t * ```typescript\n\t * const positions = await farms.getOwnedStakedPositions({\n\t * walletAddress: \"0x<user_address>\"\n\t * });\n\t * console.log(positions);\n\t * ```\n\t */\n\tpublic async getOwnedStakedPositions(\n\t\tinputs: ApiFarmsOwnedStakedPositionsBody\n\t) {\n\t\tconst positions = await this.fetchApi<\n\t\t\tFarmsStakedPositionObject[],\n\t\t\tApiFarmsOwnedStakedPositionsBody\n\t\t>(\"owned-staked-positions\", inputs);\n\t\treturn positions.map(\n\t\t\t(pool) =>\n\t\t\t\tnew FarmsStakedPosition(\n\t\t\t\t\tpool,\n\t\t\t\t\tundefined,\n\t\t\t\t\tthis.config,\n\t\t\t\t\tthis.Provider\n\t\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Fetches all `StakingPoolOwnerCapObject`s that a given address owns.\n\t * These caps grant the owner the ability to modify staking pool parameters.\n\t *\n\t * @param inputs - An object containing the owner's `walletAddress`.\n\t * @returns An array of `StakingPoolOwnerCapObject`s.\n\t *\n\t * @example\n\t * ```typescript\n\t * const ownerCaps = await farms.getOwnedStakingPoolOwnerCaps({\n\t * walletAddress: \"0x<user_address>\"\n\t * });\n\t * console.log(ownerCaps);\n\t * ```\n\t */\n\tpublic async getOwnedStakingPoolOwnerCaps(\n\t\tinputs: ApiFarmsOwnedStakingPoolOwnerCapsBody\n\t): Promise<StakingPoolOwnerCapObject[]> {\n\t\treturn this.fetchApi(\"owned-staking-pool-owner-caps\", inputs);\n\t}\n\n\t/**\n\t * Fetches all `StakingPoolOneTimeAdminCapObject`s that a given address owns.\n\t * These caps grant one-time admin privileges, typically for initializing reward coins.\n\t *\n\t * @param inputs - An object containing the admin's `walletAddress`.\n\t * @returns An array of `StakingPoolOneTimeAdminCapObject`s.\n\t *\n\t * @example\n\t * ```typescript\n\t * const adminCaps = await farms.getOwnedStakingPoolOneTimeAdminCaps({\n\t * walletAddress: \"0x<user_address>\"\n\t * });\n\t * console.log(adminCaps);\n\t * ```\n\t */\n\tpublic async getOwnedStakingPoolOneTimeAdminCaps(\n\t\tinputs: ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody\n\t): Promise<StakingPoolOneTimeAdminCapObject[]> {\n\t\treturn this.fetchApi(\"owned-staking-pool-one-time-admin-caps\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Stats\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the total value locked (TVL) in the specified farm IDs or in all farms if none are specified.\n\t *\n\t * @param inputs - An optional object containing an array of `farmIds` to filter TVL by. If not provided, returns global TVL.\n\t * @returns A promise that resolves to a `number` representing the TVL in USD (or another relevant currency).\n\t *\n\t * @example\n\t * ```typescript\n\t * const tvl = await farms.getTVL();\n\t * console.log(\"All farms' TVL:\", tvl);\n\t *\n\t * const tvlForSpecificFarm = await farms.getTVL({ farmIds: [\"0x<farm_id>\"] });\n\t * console.log(\"Specific farm's TVL:\", tvlForSpecificFarm);\n\t * ```\n\t */\n\tpublic async getTVL(inputs?: { farmIds?: ObjectId[] }): Promise<number> {\n\t\treturn this.fetchApi(\"tvl\", inputs ?? {});\n\t}\n\n\t/**\n\t * Retrieves the total value locked (TVL) of reward coins across specified farm IDs or all farms if none are specified.\n\t *\n\t * @param inputs - An optional object containing an array of `farmIds`. If not provided, returns global reward TVL.\n\t * @returns A promise that resolves to a `number` representing the total rewards TVL in USD (or another relevant currency).\n\t *\n\t * @example\n\t * ```typescript\n\t * const rewardsTvl = await farms.getRewardsTVL();\n\t * console.log(\"All farms' rewards TVL:\", rewardsTvl);\n\t *\n\t * const singleFarmRewardsTvl = await farms.getRewardsTVL({ farmIds: [\"0x<farm_id>\"] });\n\t * console.log(\"Single farm's rewards TVL:\", singleFarmRewardsTvl);\n\t * ```\n\t */\n\tpublic async getRewardsTVL(inputs?: {\n\t\tfarmIds?: ObjectId[];\n\t}): Promise<number> {\n\t\treturn this.fetchApi(\"rewards-tvl\", inputs ?? {});\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * **Deprecated**: Use `getCreateStakingPoolTransactionV2()` instead.\n\t *\n\t * Builds a transaction to create a new staking pool (farming vault) on version 1 of the farm system.\n\t *\n\t * @param inputs - Contains pool creation parameters such as `minLockDurationMs`, `maxLockDurationMs`, etc.\n\t * @returns A transaction object (or bytes) that can be signed and submitted.\n\t *\n\t * @deprecated Please use `getCreateStakingPoolTransactionV2`.\n\t */\n\tpublic async getCreateStakingPoolTransactionV1(\n\t\tinputs: ApiFarmsCreateStakingPoolBodyV1\n\t) {\n\t\treturn this.useProvider().buildCreateStakingPoolTxV1(inputs);\n\t}\n\n\t/**\n\t * Builds a transaction to create a new staking pool (farming vault) on version 2 of the farm system.\n\t *\n\t * @param inputs - Contains pool creation parameters such as `minLockDurationMs`, `maxLockDurationMs`, etc.\n\t * @returns A transaction object (or bytes) that can be signed and submitted.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tx = await farms.getCreateStakingPoolTransactionV2({\n\t * minLockDurationMs: 604800000, // 1 week\n\t * maxLockDurationMs: 31536000000, // 1 year\n\t * maxLockMultiplier: BigInt(\"2000000000\"), // e.g. 2.0x\n\t * minStakeAmount: BigInt(\"1000000\"),\n\t * stakeCoinType: \"0x<coin_type>\",\n\t * walletAddress: \"0x<admin_address>\"\n\t * });\n\t * // sign and submit the transaction\n\t * ```\n\t */\n\tpublic async getCreateStakingPoolTransactionV2(\n\t\tinputs: ApiFarmsCreateStakingPoolBody\n\t) {\n\t\treturn this.useProvider().buildCreateStakingPoolTxV2(inputs);\n\t}\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t/**\n\t * Fetches user-specific farm interaction events (e.g., staked, unlocked, withdrew) with optional pagination.\n\t *\n\t * @param inputs - Includes the user's `walletAddress`, along with `cursor` and `limit` for pagination.\n\t * @returns A paginated set of events of type `FarmUserEvent`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const userEvents = await farms.getInteractionEvents({\n\t * walletAddress: \"0x<user_address>\",\n\t * cursor: 0,\n\t * limit: 10\n\t * });\n\t * console.log(userEvents);\n\t * ```\n\t */\n\tpublic async getInteractionEvents(\n\t\tinputs: ApiIndexerEventsBody & {\n\t\t\twalletAddress: SuiAddress;\n\t\t}\n\t) {\n\t\treturn this.fetchApiIndexerEvents<\n\t\t\tFarmUserEvent,\n\t\t\tApiIndexerEventsBody & {\n\t\t\t\twalletAddress: SuiAddress;\n\t\t\t}\n\t\t>(\"events-by-user\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t/**\n\t * Retrieves an instance of the `Farms` provider from the passed `AftermathApi`,\n\t * throwing an error if not available.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Farms();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./farms\";\nexport * from \"./farmsStakingPool\";\nexport * from \"./farmsStakedPosition\";\n","import {\n\tApiFaucetMintSuiFrenBody,\n\tApiFaucetRequestBody,\n\tCallerConfig,\n\tCoinType,\n\tSuiNetwork,\n\tUrl,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Transaction } from \"@mysten/sui/transactions\";\n\nexport class Faucet extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tpublic static readonly constants = {\n\t\tdefaultRequestAmountUsd: 10,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"faucet\");\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic async getSupportedCoins(): Promise<CoinType[]> {\n\t\treturn this.fetchApi(\"supported-coins\");\n\t}\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t// TODO: add mint coin event getter ?\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getRequestCoinTransaction(inputs: ApiFaucetRequestBody) {\n\t\treturn this.useProvider().buildRequestCoinTx(inputs);\n\t}\n\n\tpublic async getMintSuiFrenTransaction(inputs: ApiFaucetMintSuiFrenBody) {\n\t\treturn this.useProvider().fetchBuildMintSuiFrenTx(inputs);\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Faucet();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./faucet\";\n","import { Balance, CoinType, CoinsToBalance, PoolObject } from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport {\n\tFixedUtils,\n\tLocalNumber,\n\tOnChainScalar,\n} from \"../../../general/utils/fixedUtils\";\n\n// This file is the typescript version of on-chain calculations. See the .move file for license info.\n// These calculations are useful for estimating values on-chain but the JS number format is LESS PRECISE!\n// Do not expect these values to be identical to their on-chain counterparts.\n\n// The formula used here differs from that of Curve/Balancer. Our stables allow custom price pegs as opposed to\n// the constant 1:1 equal-weight peg. Also our pools do not have an upper coin type limit (practically).\n\n// Here is our construction:\n\n// Start with a pool with balances b1,...,bn > 0. Call the tuple B = (b1,...,bn).\n// Take weights w1,...,wn with 0 < wi < 1 and w1 + ... + wn = 1.\n// Let X stand for the tuple (x1,...,xn) in Rn.\n// For normalization we need the tuple T = (h,h,...,h) for some h > 0, solved for later.\n// The invariant is defined as the value of this h.\n// -- TODO: generalize this reference point T to lie on a chosen ray like (w1*h, w2*h, ..., wn*h).\n// -- This would allow setting the swap price to be centered at a chosen balance distribution instead\n// -- of the 1:1:...:1 diagonal balance distribution currently in use.\n\n// Define the sum function S: Rn -> R as S(X) = w1*x1 + ... + wn*xn.\n// Define the product function P: Rn -> R as P(X) = x1^w1 * ... * xn^wn.\n// Note P(T) = S(T) = h.\n\n// We want the sum to vanish on the coordinate hyperplanes too so instead use L where\n// L(X) = [2P(X) / (P(X) + P(T))] * S(X)\n// Then 0 <= L(X) < 2S(X) and L(T) = h.\n\n// The constant price surface is defined by the equation L(X) = L(B) and the product curve by\n// P(X) = P(B). Equivilantly by L(X) - L(B) = 0, P(X) - P(B) = 0.\n// Take a flatness parameter A, 0 <= A <= 1. Then (1-A) is the dual parameter:\n// 0 <= (1-A) <= 1 and A + (1-A) = 1. Take the linear combination of the defining functions\n// C(X) = A * L(X) + (1-A) * P(X). The stable curve is defined as the solution to C(X) = C(B).\n\n// Moreover we can solve for T from the equation C(T) = C(B), making all the following equal:\n// C(B) = L(T) = S(T) = P(T) = h.\n\n// The defining equation C(X) = C(B) can be rewritten in a computationally simpler form as\n// P(X) * (2A * S(X) + (1-A) * P(X)) = h * (A * P(X) + h).\n\n// To see these functions/equations in action check out https://www.desmos.com/calculator/eu5mfckuk9\n\nexport class CmmmCalculations {\n\tprivate static minWeight: LocalNumber = 0.01;\n\t// Having a minimum normalized weight imposes a limit on the maximum number of tokens;\n\t// i.e., the largest possible pool is one where all tokens have exactly the minimum weight.\n\tprivate static maxWeightedTokens: LocalNumber = 100;\n\n\t// Pool limits that arise from limitations in the fixed point power function (and the imposed 1:100 maximum weight\n\t// ratio).\n\n\t// Swap limits: amounts swapped may not be larger than this percentage of total balance.\n\tprivate static maxInRatio: LocalNumber = 0.3;\n\tprivate static maxOutRatio: LocalNumber = 0.3;\n\n\t// Invariant shrink limit: non-proportional exits cannot cause the invariant to decrease by less than this ratio.\n\tprivate static minInvariantRatio: LocalNumber = 0.7;\n\t// Invariant growth limit: non-proportional joins cannot cause the invariant to increase by more than this ratio.\n\tprivate static maxInvariantRatio: LocalNumber = 3;\n\n\tprivate static maxNewtonAttempts: LocalNumber = 255;\n\tprivate static convergenceBound: LocalNumber = 0.000_000_001;\n\tprivate static tolerance: LocalNumber = 0.000_000_000_000_1;\n\tprivate static validityTolerance: LocalNumber = 0.000_001;\n\n\t// Invariant is used to govern pool behavior. Swaps are operations which change the pool balances without changing\n\t// the invariant (ignoring fees) and investments change the invariant without changing the distribution of balances.\n\t// Invariant and pool lp are almost in 1:1 correspondence -- e.g. burning lp in a withdraw proportionally lowers the pool invariant.\n\t// The difference is as swap fees are absorbed they increase the invariant without incrasing total lp, increasing lp worth.\n\t// Every pool operation either explicitly or implicity calls this function.\n\tpublic static calcInvariant = (pool: PoolObject): number => {\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\n\t\t// The value for h which we want is the one for which the balances vector B lies on the curve through T.\n\t\t// That is, C(T) = C(B). This turns out to be a quadratic equation which can be solved with\n\t\t// h = [sqrt[P(B) * (P(B) * (A*A + 4*(1-A)) + 8*A*S(B))] - A*P(B)] / 2.\n\t\tlet sum = 0;\n\t\tlet prod = 0;\n\t\tlet balance;\n\t\tlet weight;\n\t\tfor (let coin of Object.values(pool.coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tsum += weight * balance;\n\t\t\tprod += weight * Math.log(balance);\n\t\t}\n\t\tprod = Math.exp(prod);\n\n\t\treturn this.calcInvariantQuadratic(prod, sum, flatness);\n\t};\n\n\t// The invariant for stables comes from a quadratic equation coming from the reference point T = (h,h,...,h).\n\t// h = [sqrt[p * (p * (A*A + 4*(1-A)) + 8*A*s)] - A*p] / 2.\n\tpublic static calcInvariantQuadratic = (\n\t\tprod: number,\n\t\tsum: number,\n\t\tflatness: number\n\t): number =>\n\t\t(Math.sqrt(\n\t\t\tprod *\n\t\t\t\t(prod * (flatness * flatness + (1 - flatness) * 4) +\n\t\t\t\t\tflatness * sum * 8)\n\t\t) -\n\t\t\tflatness * prod) /\n\t\t2;\n\n\t// This function is used for 1d optimization. It computes the full invariant components and their\n\t// portions which omit contribution from the balance in the `index` coordinate.\n\t// It returns (prod, sum, p0, s0, h) where:\n\t// prod = b1^w1 * ... * bn^wn\n\t// sum = w1*b1 + ... + wn*bn\n\t// p0 = b1^w1 * ... * [bi^w1] * ... * bn^wn (remove bi from prod)\n\t// s0 = w1*b1 + ... + [wi*bi] + ... + wn*bn (remove bi from sum)\n\t// h is the invariant\n\tpublic static calcInvariantComponents = (\n\t\tpool: PoolObject,\n\t\tindex: CoinType\n\t): [prod: number, sum: number, p0: number, s0: number, h: number] => {\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\t\tlet prod = 0;\n\t\tlet sum = 0;\n\t\tlet p0 = 0;\n\t\tlet s0 = 0;\n\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet p;\n\t\tlet s;\n\t\tfor (let [coinType, coin] of Object.entries(pool.coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\n\t\t\tp = weight * Math.log(balance);\n\t\t\ts = weight * balance;\n\n\t\t\tprod = prod + p;\n\t\t\tsum = sum + s;\n\n\t\t\tif (coinType != index) {\n\t\t\t\tp0 = p0 + p;\n\t\t\t\ts0 = s0 + s;\n\t\t\t}\n\t\t}\n\t\tprod = Math.exp(prod);\n\t\tp0 = Math.exp(p0);\n\n\t\treturn [\n\t\t\tprod,\n\t\t\tsum,\n\t\t\tp0,\n\t\t\ts0,\n\t\t\tCmmmCalculations.calcInvariantQuadratic(prod, sum, flatness),\n\t\t];\n\t};\n\n\t// spot price is given in units of Bin / Bout\n\tpublic static calcSpotPrice = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType\n\t): number =>\n\t\tCmmmCalculations.calcSpotPriceWithFees(\n\t\t\tpool,\n\t\t\tcoinTypeIn,\n\t\t\tcoinTypeOut,\n\t\t\ttrue\n\t\t);\n\n\t// spot price is given in units of Bin / Bout\n\tpublic static calcSpotPriceWithFees = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tignoreFees?: boolean\n\t): number => {\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet part1 = CmmmCalculations.calcSpotPriceBody(pool);\n\n\t\tlet coinIn = pool.coins[coinTypeIn];\n\t\tlet coinOut = pool.coins[coinTypeOut];\n\t\tlet balanceIn = FixedUtils.directCast(coinIn.normalizedBalance);\n\t\tlet balanceOut = FixedUtils.directCast(coinOut.normalizedBalance);\n\t\tlet weightIn = FixedUtils.directCast(coinIn.weight);\n\t\tlet weightOut = FixedUtils.directCast(coinOut.weight);\n\t\tlet swapFeeIn = ignoreFees\n\t\t\t? 0\n\t\t\t: FixedUtils.directCast(coinIn.tradeFeeIn);\n\t\tlet swapFeeOut = ignoreFees\n\t\t\t? 0\n\t\t\t: FixedUtils.directCast(coinIn.tradeFeeOut);\n\n\t\tlet sbi = weightOut * balanceIn;\n\t\t// this is the only place where fee values are used\n\t\tlet sbo =\n\t\t\t(1 -\n\t\t\t\t(ignoreFees\n\t\t\t\t\t? 0\n\t\t\t\t\t: Casting.bpsToPercentage(\n\t\t\t\t\t\t\tpool.daoFeePoolObject?.feeBps ?? BigInt(0)\n\t\t\t\t\t ))) *\n\t\t\t(1 - swapFeeIn) *\n\t\t\t(1 - swapFeeOut) *\n\t\t\tweightIn *\n\t\t\tbalanceOut;\n\n\t\treturn (\n\t\t\t(sbi * (part1 + 2 * a * balanceOut)) /\n\t\t\t(sbo * (part1 + 2 * a * balanceIn))\n\t\t);\n\t};\n\n\t// The spot price formula contains a factor of C0^2 / P(B0) + (1-A)P(B0), this returns that\n\tprivate static calcSpotPriceBody = (pool: PoolObject): number => {\n\t\t// The spot price formula comes from the partial derivatives of Cf, specifically -(dCf / dxOut) / (dCf / dxIn)\n\t\tlet a: number = FixedUtils.directCast(pool.flatness);\n\t\tlet ac: number = 1 - a;\n\n\t\tlet prod: number = 0;\n\t\tlet sum: number = 0;\n\t\tlet balance: number;\n\t\tlet weight: number;\n\n\t\t// The spot price formula requires knowing the value of the invariant. We need the prod and sum parts\n\t\t// also later on so no need to compute them twice by calling calcInvariant, just evaluate here.\n\t\tfor (let coin of Object.values(pool.coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\n\t\t\tprod += weight * Math.log(balance);\n\t\t\tsum += weight * balance;\n\t\t}\n\t\tprod = Math.exp(prod);\n\n\t\tlet invarnt = CmmmCalculations.calcInvariantQuadratic(prod, sum, a);\n\n\t\treturn (invarnt * invarnt) / prod + ac * prod;\n\t};\n\n\t// 1d optimized swap function for finding out given in. Returns the amount out.\n\tpublic static calcOutGivenIn = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tamountIn: Balance\n\t): Balance => {\n\t\tif (coinTypeIn === coinTypeOut)\n\t\t\tthrow Error(\"in and out must be different coins\");\n\t\tlet coinIn = pool.coins[coinTypeIn];\n\t\tlet coinOut = pool.coins[coinTypeOut];\n\t\tlet swapFeeIn = FixedUtils.directCast(coinIn.tradeFeeIn);\n\t\tlet swapFeeOut = FixedUtils.directCast(coinOut.tradeFeeOut);\n\t\tif (swapFeeIn >= 1 || swapFeeOut >= 1) {\n\t\t\t// this swap is disabled\n\t\t\treturn BigInt(0);\n\t\t}\n\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\t\tlet oldIn = FixedUtils.directCast(coinIn.normalizedBalance);\n\t\tlet oldOut = FixedUtils.directCast(coinOut.normalizedBalance);\n\n\t\tlet wIn = FixedUtils.directCast(coinIn.weight);\n\t\tlet wOut = FixedUtils.directCast(coinOut.weight);\n\t\tlet [prod, , p0, s0, h] = CmmmCalculations.calcInvariantComponents(\n\t\t\tpool,\n\t\t\tcoinTypeOut\n\t\t);\n\n\t\tlet feedAmountIn =\n\t\t\t(1 - swapFeeIn) *\n\t\t\tFixedUtils.castAndNormalize(coinIn.decimalsScalar, amountIn);\n\t\tlet newIn = oldIn + feedAmountIn;\n\t\tlet prodRatio = Math.pow(newIn / oldIn, wIn);\n\n\t\tlet newP0 = p0 * prodRatio;\n\t\t// the initial estimate (xi) is from if there were only the product part of the curve\n\t\tlet xi = Math.pow(prod / newP0, 1 / wOut);\n\t\tlet newS0 = s0 + wIn * feedAmountIn;\n\n\t\tlet tokenAmountOut =\n\t\t\tCmmmCalculations.getTokenBalanceGivenInvariantAndAllOtherBalances(\n\t\t\t\tflatness,\n\t\t\t\twOut,\n\t\t\t\th,\n\t\t\t\txi, // initial estimate -- default can be (P(X) / p0)^n\n\t\t\t\tnewP0, // P(B) / xi^(1/n) (everything but the missing part)\n\t\t\t\tnewS0 // S(B) - xi / n (everything but the missing part)\n\t\t\t);\n\n\t\tlet amountOut = FixedUtils.uncastAndUnnormalize(\n\t\t\tcoinOut.decimalsScalar,\n\t\t\t(oldOut - tokenAmountOut) * (1 - swapFeeOut)\n\t\t);\n\t\tif (\n\t\t\t!CmmmCalculations.checkValid1dSwap(\n\t\t\t\tpool,\n\t\t\t\tcoinTypeIn,\n\t\t\t\tcoinTypeOut,\n\t\t\t\tamountIn,\n\t\t\t\tamountOut\n\t\t\t)\n\t\t)\n\t\t\tthrow Error(\"invalid 1d swap\");\n\t\treturn amountOut;\n\t};\n\n\t// 1d optimized swap function for finding in given out. Returns the amount in.\n\tpublic static calcInGivenOut = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tamountOut: Balance\n\t): Balance => {\n\t\tif (coinTypeIn === coinTypeOut)\n\t\t\tthrow Error(\"in and out must be different coins\");\n\t\tlet coinIn = pool.coins[coinTypeIn];\n\t\tlet coinOut = pool.coins[coinTypeOut];\n\t\tlet swapFeeIn = FixedUtils.directCast(coinIn.tradeFeeIn);\n\t\tlet swapFeeOut = FixedUtils.directCast(coinOut.tradeFeeOut);\n\t\tif (swapFeeIn >= 1 || swapFeeOut >= 1) {\n\t\t\t// this swap is disabled\n\t\t\tif (amountOut === BigInt(0)) return BigInt(0);\n\t\t\tthrow Error(\"this swap is disabled\");\n\t\t}\n\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\t\tlet oldIn = FixedUtils.directCast(coinIn.normalizedBalance);\n\t\tlet oldOut = FixedUtils.directCast(coinOut.normalizedBalance);\n\n\t\tlet wOut = FixedUtils.directCast(coinOut.weight);\n\t\tlet wIn = FixedUtils.directCast(coinIn.weight);\n\t\tlet [prod, , p0, s0, h] = CmmmCalculations.calcInvariantComponents(\n\t\t\tpool,\n\t\t\tcoinTypeIn\n\t\t);\n\n\t\tlet feedAmountOut =\n\t\t\tFixedUtils.castAndNormalize(coinIn.decimalsScalar, amountOut) /\n\t\t\t(1 - swapFeeOut);\n\t\tlet newOut = oldOut - feedAmountOut;\n\t\tlet prodRatio = Math.pow(newOut / oldOut, wOut);\n\n\t\tlet newP0 = p0 * prodRatio;\n\t\t// the initial estimate (xi) is from if there were only the product part of the curve\n\t\tlet xi = Math.pow(prod / newP0, 1 / wIn);\n\t\tlet newS0 = s0 - wOut * feedAmountOut;\n\n\t\tlet tokenAmountIn =\n\t\t\tCmmmCalculations.getTokenBalanceGivenInvariantAndAllOtherBalances(\n\t\t\t\tflatness,\n\t\t\t\twIn,\n\t\t\t\th,\n\t\t\t\txi, // initial estimate -- default can be (P(X) / p0)^n\n\t\t\t\tnewP0, // P(B) / xi^(1/n) (everything but the missing part)\n\t\t\t\tnewS0 // S(B) - xi / n (everything but the missing part)\n\t\t\t);\n\n\t\tlet amountIn = FixedUtils.uncastAndUnnormalize(\n\t\t\tcoinOut.decimalsScalar,\n\t\t\t(tokenAmountIn - oldIn) / (1 - swapFeeIn)\n\t\t);\n\t\tif (\n\t\t\t!CmmmCalculations.checkValid1dSwap(\n\t\t\t\tpool,\n\t\t\t\tcoinTypeIn,\n\t\t\t\tcoinTypeOut,\n\t\t\t\tamountIn,\n\t\t\t\tamountOut\n\t\t\t)\n\t\t)\n\t\t\tthrow Error(\"invalid 1d swap\");\n\t\treturn amountIn;\n\t};\n\n\t// For computing swap amounts. Given the current balances (and any other parameters) and an amounts in vector,\n\t// and a expected amounts out vector, determine the value of t > 0 such that t*expected_amounts_out\n\t// is a valid swap from balances corresponding to adding amounts_in to the pool. The correct value of t is the one for which\n\t// calc_swap_invariant(balances, ...parameters, amounts_in, t*expected_amounts_out) === calc_invariant_full(balances, ...parameters).\n\tpublic static calcSwapFixedIn = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance,\n\t\tamountsOutDirection: CoinsToBalance\n\t): OnChainScalar => {\n\t\tlet coins = pool.coins;\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet t = 1; // assume that the expected amounts out are close to the true amounts out\n\t\t// this allows faster convergence if the caller chooses expected_amounts_out well\n\t\tlet prevT = t;\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amountIn;\n\t\tlet amountOut;\n\t\tlet feeIn;\n\t\tlet feeOut;\n\t\tlet prod;\n\t\tlet prod1;\n\t\tlet sum;\n\t\tlet sum1;\n\t\tlet part1;\n\t\tlet part2;\n\t\tlet part3;\n\t\tlet part4;\n\t\tlet skip;\n\t\tlet drainT = Number.POSITIVE_INFINITY;\n\t\tlet shifter = 1;\n\n\t\t// make sure no disabled coin type is expected\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tfeeOut = FixedUtils.complement(\n\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut)\n\t\t\t);\n\t\t\tif (amountOut > 0) {\n\t\t\t\tif (feeOut === 0) {\n\t\t\t\t\tthrow Error(\"this trade is disabled\");\n\t\t\t\t} else {\n\t\t\t\t\t// pool is drained when b + Ain * (1 - Sin) - t * Aout / (1 - Sout) = 0, or t = (b + Ain * (1 - Sin)) * (1 - So) / Aout\n\t\t\t\t\tt =\n\t\t\t\t\t\t((FixedUtils.directCast(coin.normalizedBalance) +\n\t\t\t\t\t\t\tFixedUtils.castAndNormalize(\n\t\t\t\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t\t\t\t\t) *\n\t\t\t\t\t\t\t\tFixedUtils.complement(\n\t\t\t\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t\t\t\t\t)) /\n\t\t\t\t\t\t\tamountOut) *\n\t\t\t\t\t\tfeeOut;\n\t\t\t\t\tdrainT = Math.min(drainT, t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// drain_t is the maximum t can possibly be. It will be 0 if expected amounts out is way too high.\n\t\tif (drainT === 0) return BigInt(0);\n\t\twhile (shifter >= drainT) shifter /= 2;\n\n\t\tt = 1;\n\n\t\tfor (let i = 0; i < CmmmCalculations.maxNewtonAttempts; ++i) {\n\t\t\tprod = 0;\n\t\t\tprod1 = 0;\n\t\t\tsum = 0;\n\t\t\tsum1 = 0;\n\t\t\tskip = false;\n\t\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\t\tamountIn = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tfeeIn = FixedUtils.complement(\n\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t);\n\t\t\t\tfeeOut = FixedUtils.complement(\n\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut)\n\t\t\t\t);\n\n\t\t\t\t// pseudoin\n\t\t\t\tpart1 = feeIn * amountIn;\n\t\t\t\t// pseudoout\n\t\t\t\tpart2 = (t * amountOut) / feeOut;\n\t\t\t\t// pseudobalance\n\t\t\t\tif (part2 >= balance + part1 + 1) {\n\t\t\t\t\tskip = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tpart3 = balance + part1 - part2;\n\t\t\t\t// for derivatives: weight * expected_amounts_out / fee_out\n\t\t\t\tpart4 = (weight * amountOut) / feeOut;\n\n\t\t\t\tprod += weight * Math.log(part3);\n\t\t\t\tprod1 += part4 / part3;\n\t\t\t\tsum += weight * part3;\n\t\t\t\tsum1 += part4;\n\t\t\t}\n\t\t\tprod = Math.exp(prod);\n\n\t\t\tpart1 = a * sum;\n\t\t\tpart2 = ac * prod;\n\t\t\tpart3 = part1 + part2;\n\t\t\tpart4 = a * invariant * prod1;\n\n\t\t\tt =\n\t\t\t\t(a * (sum + 2 * t * sum1) +\n\t\t\t\t\tpart3 +\n\t\t\t\t\t2 * prod1 * t * part3 -\n\t\t\t\t\t(t * part4 + invariant * (a + invariant / prod))) /\n\t\t\t\t(2 * (prod1 * part3 + a * sum1) - part4);\n\n\t\t\tif (\n\t\t\t\tHelpers.closeEnough(t, prevT, CmmmCalculations.convergenceBound)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t!CmmmCalculations.checkValidSwap(\n\t\t\t\t\t\tpool,\n\t\t\t\t\t\tamountsIn,\n\t\t\t\t\t\t1,\n\t\t\t\t\t\tamountsOutDirection,\n\t\t\t\t\t\tt\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow Error(\"invalid swap\");\n\t\t\t\treturn FixedUtils.directUncast(t);\n\t\t\t}\n\n\t\t\tprevT = t;\n\t\t}\n\t\tthrow Error(\"Newton diverged\");\n\t};\n\n\t// Swaps but fixed amounts out. Given the pool's current state and a guaranteed out vector, and a expected in vector,\n\t// scale expected_amounts_in by t > 0 so that this swap is valid and return the correct value for t\n\tpublic static calcSwapFixedOut = (\n\t\tpool: PoolObject,\n\t\tamountsInDirection: CoinsToBalance,\n\t\tamountsOut: CoinsToBalance\n\t): OnChainScalar => {\n\t\tlet coins = pool.coins;\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet t = 1; // assume that the expected amounts out are close to the true amounts out\n\t\t// this allows faster convergence if the caller chooses expected_amounts_out well\n\t\tlet prevT = 0;\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amountIn;\n\t\tlet amountOut;\n\t\tlet feeIn;\n\t\tlet feeOut;\n\t\tlet prod;\n\t\tlet prod1;\n\t\tlet sum;\n\t\tlet sum1;\n\t\tlet part1;\n\t\tlet part2;\n\t\tlet part3;\n\t\tlet part4;\n\n\t\t// make sure no disabled coin type is expected\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tif (\n\t\t\t\tcoin.tradeFeeOut >= FixedUtils.fixedOneB &&\n\t\t\t\t(amountsOut[coinType] || BigInt(0)) > BigInt(0)\n\t\t\t)\n\t\t\t\tthrow Error(\"this trade is disabled\");\n\t\t}\n\n\t\tfor (let i = 0; i < CmmmCalculations.maxNewtonAttempts; ++i) {\n\t\t\tprod = 0;\n\t\t\tprod1 = 0;\n\t\t\tsum = 0;\n\t\t\tsum1 = 0;\n\t\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\t\tamountIn = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsInDirection[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOut[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tfeeIn = 1 - FixedUtils.directCast(coin.tradeFeeIn);\n\t\t\t\tfeeOut = 1 - FixedUtils.directCast(coin.tradeFeeOut);\n\n\t\t\t\t// pseudoin expected\n\t\t\t\tpart1 = feeIn * amountIn;\n\t\t\t\t// pseudoout\n\t\t\t\tpart2 = amountOut === 0 ? 0 : amountOut / feeOut;\n\t\t\t\t// pseudobalance\n\t\t\t\tpart3 = balance + t * part1 - part2;\n\t\t\t\t// for derivatives: weight * fee_in * expected_amounts_in\n\t\t\t\tpart4 = weight * part1;\n\n\t\t\t\tprod += weight * Math.log(part3);\n\t\t\t\tprod1 += part4 / part3;\n\t\t\t\tsum += weight * part3;\n\t\t\t\tsum1 += part4;\n\t\t\t}\n\t\t\tprod = Math.exp(prod);\n\n\t\t\tpart1 = 2 * a * sum;\n\t\t\tpart2 = ac * prod;\n\t\t\tpart3 = part1 + part2;\n\t\t\tpart4 =\n\t\t\t\t(part3 + part2) * prod1 + 2 * a * sum1 - a * invariant * prod1;\n\n\t\t\tt =\n\t\t\t\t(t * part4 + invariant * (a + invariant / prod) - part3) /\n\t\t\t\tpart4;\n\n\t\t\tif (\n\t\t\t\tHelpers.closeEnough(t, prevT, CmmmCalculations.convergenceBound)\n\t\t\t) {\n\t\t\t\tif (\n\t\t\t\t\t!CmmmCalculations.checkValidSwap(\n\t\t\t\t\t\tpool,\n\t\t\t\t\t\tamountsInDirection,\n\t\t\t\t\t\t1,\n\t\t\t\t\t\tamountsOut,\n\t\t\t\t\t\tt\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow Error(\"invalid swap\");\n\t\t\t\treturn FixedUtils.directUncast(t);\n\t\t\t}\n\n\t\t\tprevT = t;\n\t\t}\n\t\tthrow Error(\"Newton diverged\");\n\t};\n\n\t// Return the expected lp ratio for this deposit\n\tpublic static calcDepositFixedAmounts = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance\n\t): OnChainScalar => {\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet coins = pool.coins;\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amount;\n\t\tlet prod = 0;\n\t\tlet sum = 0;\n\t\tlet r = CmmmCalculations.calcDepositFixedAmountsInitialEstimate(\n\t\t\tpool,\n\t\t\tamountsIn\n\t\t);\n\t\tlet prevR = r;\n\n\t\tlet fees: Record<CoinType, number> = {};\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tfees[coinType] =\n\t\t\t\tr * (balance + amount) >= balance\n\t\t\t\t\t? 1 - FixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t\t: 1 / (1 - FixedUtils.directCast(coin.tradeFeeOut));\n\t\t}\n\n\t\tlet i = 0;\n\t\tlet prod1;\n\t\tlet sum1;\n\t\tlet fee;\n\t\tlet part1;\n\t\tlet part2;\n\t\tlet part3;\n\t\tlet part4;\n\t\twhile (i < CmmmCalculations.maxNewtonAttempts) {\n\t\t\tprod = 0;\n\t\t\tprod1 = 0;\n\t\t\tsum = 0;\n\t\t\tsum1 = 0;\n\t\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tfee = fees[coinType];\n\t\t\t\tpart1 = balance + amount;\n\t\t\t\tpart2 = fee * r * part1 + balance - fee * balance;\n\t\t\t\tpart3 = weight * fee * part1;\n\n\t\t\t\tprod += weight * Math.log(part2);\n\t\t\t\tprod1 += part3 / part2;\n\t\t\t\tsum += weight * part2;\n\t\t\t\tsum1 += part3;\n\t\t\t}\n\t\t\tprod = Math.exp(prod);\n\n\t\t\tpart3 = a * invariant * prod1;\n\t\t\tpart4 = 2 * prod1 * (a * sum + ac * prod) + 2 * a * sum1;\n\t\t\tr =\n\t\t\t\t(r * part4 +\n\t\t\t\t\tinvariant * (1 + invariant / prod) -\n\t\t\t\t\t(r * part3 + 2 * a * sum + ac * (prod + invariant))) /\n\t\t\t\t(part4 - part3);\n\n\t\t\tif (\n\t\t\t\tHelpers.closeEnough(r, prevR, CmmmCalculations.convergenceBound)\n\t\t\t) {\n\t\t\t\tlet scalar = FixedUtils.directUncast(r);\n\t\t\t\tif (\n\t\t\t\t\t!CmmmCalculations.checkValidDeposit(pool, amountsIn, scalar)\n\t\t\t\t)\n\t\t\t\t\tthrow Error(\"invalid deposit\");\n\t\t\t\treturn scalar;\n\t\t\t}\n\n\t\t\tprevR = r;\n\t\t\ti += 1;\n\t\t}\n\t\tthrow Error(\"Newton diverged\");\n\t};\n\n\tprivate static calcDepositFixedAmountsInitialEstimate = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance\n\t): LocalNumber => {\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet coins = pool.coins;\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet balance;\n\t\tlet amount;\n\t\tlet weight;\n\t\tlet r;\n\t\tlet rMin = 0;\n\t\tlet cfMin = 0;\n\t\tlet prod = 0;\n\t\tlet sum = 0;\n\t\tlet part1;\n\t\t// start cf_max as corresponding to r = 1\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\n\t\t\t// this is all in so use fees in\n\t\t\tpart1 =\n\t\t\t\tbalance + (1 - FixedUtils.directCast(coin.tradeFeeIn)) * amount;\n\t\t\tprod += weight * Math.log(part1);\n\t\t\tsum += weight * part1;\n\t\t\t// r_min portion of the loop\n\t\t\tr =\n\t\t\t\t(FixedUtils.directCast(coin.tradeFeeOut) * balance) /\n\t\t\t\t(balance + amount);\n\t\t\trMin = Math.max(r, rMin);\n\t\t}\n\t\tprod = Math.exp(prod);\n\t\tlet cfMax = (2 * a * prod * sum) / (prod + invariant) + ac * prod;\n\n\t\tlet rMax = 1;\n\t\tlet cf: number;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tr = balance / (balance + amount);\n\t\t\tif (r <= rMin) continue;\n\n\t\t\tprod = 0;\n\t\t\tsum = 0;\n\t\t\tfor (let [coinType2, coin2] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin2.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin2.weight);\n\t\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin2.decimalsScalar,\n\t\t\t\t\tamountsIn[coinType2] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tpart1 = r * (balance + amount);\n\t\t\t\tif (part1 >= balance) {\n\t\t\t\t\t// r * (B0 + Din) >= B0 so use fees in\n\t\t\t\t\tpart1 =\n\t\t\t\t\t\tbalance +\n\t\t\t\t\t\t(1 - FixedUtils.directCast(coin2.tradeFeeIn)) *\n\t\t\t\t\t\t\t(part1 - balance);\n\t\t\t\t} else {\n\t\t\t\t\t// r * (B0 + Din) < B0 so use fees out\n\t\t\t\t\tpart1 =\n\t\t\t\t\t\tbalance -\n\t\t\t\t\t\t(balance - part1) /\n\t\t\t\t\t\t\tFixedUtils.complement(\n\t\t\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut)\n\t\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprod += weight * Math.log(part1);\n\t\t\t\tsum += weight * part1;\n\t\t\t}\n\t\t\tprod = Math.exp(prod);\n\n\t\t\tcf = (2 * a * prod * sum) / (prod + invariant) + ac * prod;\n\t\t\tif (cf <= invariant) {\n\t\t\t\t// is a lower bound, check min\n\t\t\t\tif (cf >= cfMin) {\n\t\t\t\t\trMin = r;\n\t\t\t\t\tcfMin = cf;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cf >= invariant) {\n\t\t\t\t// is an upper bound, check max\n\t\t\t\tif (cf <= cfMax) {\n\t\t\t\t\trMax = r;\n\t\t\t\t\tcfMax = cf;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tr =\n\t\t\tcfMin === cfMax\n\t\t\t\t? rMin\n\t\t\t\t: (rMin * cfMax + (rMax - rMin) * invariant - rMax * cfMin) /\n\t\t\t\t (cfMax - cfMin);\n\t\treturn r;\n\t};\n\n\t// Return the expected amounts out for this withdrawal\n\tpublic static calcWithdrawFlpAmountsOut = (\n\t\tpool: PoolObject,\n\t\tamountsOutDirection: CoinsToBalance,\n\t\tlpRatio: LocalNumber\n\t): CoinsToBalance => {\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet coins = pool.coins;\n\t\tlet lpr = lpRatio;\n\t\tlet lpc = 1 - lpr;\n\t\tlet scaledInvariant = invariant * lpr;\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet i;\n\t\tlet prevR = 0;\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amountOut;\n\t\tlet fee;\n\t\tlet prod;\n\t\tlet prod1;\n\t\tlet sum;\n\t\tlet sum1;\n\t\tlet part1;\n\t\tlet part2;\n\t\tlet part3;\n\t\tlet part4;\n\t\tlet skip;\n\t\tlet shrinker = 1;\n\n\t\tlet [r, rDrain] =\n\t\t\tCmmmCalculations.calcWithdrawFlpAmountsOutInitialEstimate(\n\t\t\t\tpool,\n\t\t\t\tamountsOutDirection,\n\t\t\t\tlpRatio\n\t\t\t);\n\t\twhile (shrinker >= rDrain) shrinker /= 2;\n\n\t\tlet fees: Record<CoinType, number> = {};\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tfees[coinType] =\n\t\t\t\tbalance * lpc >= r * amountOut\n\t\t\t\t\t? 1 - FixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t\t: 1 / (1 - FixedUtils.directCast(coin.tradeFeeOut));\n\t\t}\n\n\t\ti = 0;\n\t\twhile (i < CmmmCalculations.maxNewtonAttempts) {\n\t\t\tprod = 0;\n\t\t\tprod1 = 0;\n\t\t\tsum = 0;\n\t\t\tsum1 = 0;\n\t\t\tskip = false;\n\t\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tfee = fees[coinType];\n\n\t\t\t\tpart1 = balance * (lpr + lpc * fee);\n\t\t\t\tpart2 = fee * r * amountOut;\n\t\t\t\tif (part2 + 1 >= part1) {\n\t\t\t\t\t// Overshot and drained pool. Set t to be closer to t_max and try again.\n\t\t\t\t\tskip = true;\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tpart1 -= part2;\n\t\t\t\t}\n\n\t\t\t\tpart2 = weight * fee * amountOut;\n\n\t\t\t\tprod += weight * Math.log(part1);\n\t\t\t\tprod1 += part2 / part1;\n\t\t\t\tsum += weight * part1;\n\t\t\t\tsum1 += part2;\n\t\t\t}\n\t\t\tif (skip) {\n\t\t\t\tr = rDrain - shrinker / 2 ** i;\n\t\t\t\ti += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprod = Math.exp(prod);\n\n\t\t\tpart1 = prod / scaledInvariant;\n\t\t\tpart2 = 2 * a * sum;\n\t\t\tpart3 = ac * (prod * part1 + 2 * prod + scaledInvariant) + part2;\n\t\t\tpart4 = part3 * prod1 + 2 * a * (part1 + 1) * sum1;\n\n\t\t\tr =\n\t\t\t\t(r * part4 +\n\t\t\t\t\tpart3 +\n\t\t\t\t\tpart1 * part2 -\n\t\t\t\t\tprod -\n\t\t\t\t\tscaledInvariant * (2 + scaledInvariant / prod)) /\n\t\t\t\tpart4;\n\n\t\t\tif (\n\t\t\t\tHelpers.closeEnough(r, prevR, CmmmCalculations.convergenceBound)\n\t\t\t) {\n\t\t\t\tlet returner: CoinsToBalance = {};\n\t\t\t\tfor (let coinType of Object.keys(coins)) {\n\t\t\t\t\treturner[coinType] = FixedUtils.directUncast(\n\t\t\t\t\t\tr *\n\t\t\t\t\t\t\tFixedUtils.directCast(\n\t\t\t\t\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!CmmmCalculations.checkValidWithdraw(\n\t\t\t\t\t\tpool,\n\t\t\t\t\t\treturner,\n\t\t\t\t\t\tlpRatio\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow Error(\"invalid withdraw\");\n\t\t\t\treturn returner;\n\t\t\t}\n\n\t\t\tprevR = r;\n\t\t\ti += 1;\n\t\t}\n\t\tthrow Error(\"Newton diverged\");\n\t};\n\n\tprivate static calcWithdrawFlpAmountsOutInitialEstimate = (\n\t\tpool: PoolObject,\n\t\tamountsOutDirection: CoinsToBalance,\n\t\tlpRatio: LocalNumber\n\t): [LocalNumber, LocalNumber] => {\n\t\tlet invariant = CmmmCalculations.calcInvariant(pool);\n\t\tlet coins = pool.coins;\n\t\tlet lpr = lpRatio;\n\t\tlet lpc = 1 - lpr;\n\t\tlet scaledInvariant = invariant * lpr;\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\t\tlet ac = 1 - a;\n\t\tlet keepT: boolean;\n\t\tlet tDrain;\n\t\tlet t;\n\t\tlet cf;\n\t\tlet tMin;\n\t\tlet cfMin;\n\t\tlet tMax;\n\t\tlet cfMax;\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amountOut;\n\t\tlet fee;\n\t\tlet prod;\n\t\tlet sum;\n\t\tlet part1;\n\t\tlet part2;\n\t\tlet part3;\n\n\t\t// the biggest cfMax can possibly be is f(0) which is this:\n\t\ttMax = 0;\n\t\tprod = 0;\n\t\tsum = 0;\n\t\tfor (let coin of Object.values(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tfee = FixedUtils.directCast(coin.tradeFeeIn);\n\t\t\tpart1 = balance * (1 + lpr * fee - fee);\n\t\t\tprod += weight * Math.log(part1);\n\t\t\tsum += weight * part1;\n\t\t}\n\t\tprod = Math.exp(prod);\n\t\tcfMax = (2 * a * prod * sum) / (prod + scaledInvariant) + ac * prod;\n\n\t\t// the smallest cfMin can be is 0 which occurs when the pool is drained\n\t\tcfMin = 0;\n\t\ttMin = Number.POSITIVE_INFINITY;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tif (amountOut === 0) continue;\n\t\t\tt =\n\t\t\t\t(FixedUtils.directCast(coin.normalizedBalance) *\n\t\t\t\t\tFixedUtils.complement(\n\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut) * lpRatio\n\t\t\t\t\t)) /\n\t\t\t\tamountOut;\n\t\t\tif (t < tMin) tMin = t;\n\t\t}\n\t\ttDrain = tMin;\n\n\t\t// remaining test points are the CF discontinuities: where B0 - t*D = R*B0\n\t\tfor (let [coinTypeT, coinT] of Object.entries(coins)) {\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoinT.decimalsScalar,\n\t\t\t\tamountsOutDirection[coinTypeT] || BigInt(0)\n\t\t\t);\n\t\t\tif (amountOut === 0) continue;\n\t\t\tbalance = FixedUtils.directCast(coinT.normalizedBalance);\n\t\t\tt = (balance * lpc) / amountOut;\n\t\t\tprod = 0;\n\t\t\tsum = 0;\n\t\t\tkeepT = true;\n\t\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\t\tpart1 = t * amountOut;\n\t\t\t\tif (part1 >= balance) {\n\t\t\t\t\t// this t is too large to be a bound because B0 - t*D overdraws the pool\n\t\t\t\t\tkeepT = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tpart1 = balance - part1;\n\t\t\t\tpart2 = lpr * balance;\n\t\t\t\tpart3 =\n\t\t\t\t\tpart1 >= part2\n\t\t\t\t\t\t? part2 +\n\t\t\t\t\t\t FixedUtils.complement(\n\t\t\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t\t\t ) *\n\t\t\t\t\t\t\t\t(part1 - part2)\n\t\t\t\t\t\t: part2 -\n\t\t\t\t\t\t (part2 - part1) /\n\t\t\t\t\t\t\t\tFixedUtils.complement(\n\t\t\t\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut)\n\t\t\t\t\t\t\t\t);\n\t\t\t\tprod += weight * Math.log(part3);\n\t\t\t\tsum += weight * part3;\n\t\t\t}\n\t\t\tif (keepT) {\n\t\t\t\tprod = Math.exp(prod);\n\t\t\t\tcf =\n\t\t\t\t\t(2 * a * prod * sum) / (prod + scaledInvariant) + ac * prod;\n\t\t\t\tif (cf >= scaledInvariant) {\n\t\t\t\t\t// upper bound, check against cfMax\n\t\t\t\t\tif (cf <= cfMax) {\n\t\t\t\t\t\ttMax = t;\n\t\t\t\t\t\tcfMax = cf;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (cf <= scaledInvariant) {\n\t\t\t\t\t// lower bound, check against cfMin\n\t\t\t\t\tif (cf >= cfMin) {\n\t\t\t\t\t\ttMin = t;\n\t\t\t\t\t\tcfMin = cf;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// initial estimate is the linear interpolation between discontinuity bounds\n\t\tt =\n\t\t\tcfMax === cfMin\n\t\t\t\t? tMin\n\t\t\t\t: (tMin * cfMax +\n\t\t\t\t\t\ttMax * scaledInvariant -\n\t\t\t\t\t\ttMax * cfMin -\n\t\t\t\t\t\ttMin * scaledInvariant) /\n\t\t\t\t (cfMax - cfMin);\n\n\t\treturn [t, tDrain];\n\t};\n\n\t// Dusty direct all-coin deposit, returns the number s >= 0 so that amounts_in = s*B0 + dust.\n\t// When performing an all-coin deposit, call this function to get t then split amounts_in into s*B0 + dust.\n\t// At least one coordinate of dust will be 0. Send the s*B0 balances into the pool and mint s*total_lp.\n\t// The caller keeps the dust.\n\tpublic static calcAllCoinDeposit = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance\n\t): CoinsToBalance => {\n\t\tlet coins = pool.coins;\n\n\t\tlet balance;\n\t\tlet amountIn;\n\n\t\tlet s;\n\t\tlet sMin = Number.POSITIVE_INFINITY;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamountIn = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\n\t\t\ts = amountIn / balance;\n\n\t\t\tif (s < sMin) sMin = s;\n\t\t}\n\n\t\tlet returner: CoinsToBalance = {};\n\t\tfor (let coinType of Object.keys(coins))\n\t\t\treturner[coinType] = Helpers.blendedOperations.mulNBB(\n\t\t\t\tsMin,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\treturn returner;\n\t};\n\n\t// Dusty direct all-coin withdraw, returns the number s >= 0 so that amounts_out + dust = s*B0.\n\t// The normal all-coin withdraw (take this exact amount of lp and give however much balances out)\n\t// should be done directly without this function -- just burn the lp and give the user\n\t// lp/total_lp * balance_i in each coordinate. This function is for finding how much lp it takes to\n\t// ensure that at least amounts_out comes out.\n\tpublic static calcAllCoinWithdraw = (\n\t\tpool: PoolObject,\n\t\tamountsOut: CoinsToBalance\n\t): CoinsToBalance => {\n\t\tlet coins = pool.coins;\n\n\t\tlet balance;\n\t\tlet amountOut;\n\n\t\tlet s;\n\t\tlet sMax = 0;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOut[coinType] || BigInt(0)\n\t\t\t);\n\n\t\t\ts = amountOut / balance;\n\n\t\t\tif (s > sMax) sMax = s;\n\t\t}\n\n\t\tlet returner: CoinsToBalance = {};\n\t\tfor (let coinType of Object.keys(coins))\n\t\t\treturner[coinType] = Helpers.blendedOperations.mulNBB(\n\t\t\t\tsMax,\n\t\t\t\tamountsOut[coinType] || BigInt(0)\n\t\t\t);\n\t\treturn returner;\n\t};\n\n\t// This function calculates the balance of a given token (index) given all the other balances (combined in p0, s0)\n\t// and the invariant along with an initial estimate. It is useful for 1d optimization.\n\tprivate static getTokenBalanceGivenInvariantAndAllOtherBalances = (\n\t\tflatness: number,\n\t\tw: number,\n\t\th: number,\n\t\txi: number, // initial estimate -- default can be (P(X) / p0)^n\n\t\tp0: number, // P(B) / xi^(1/n) (everything but the missing part)\n\t\ts0: number // S(B) - xi / n (everything but the missing part)\n\t): number => {\n\t\tif (isNaN(xi)) throw new Error(\"initial estimate is not a number\");\n\n\t\t// Standard Newton method used here\n\n\t\t// ---------------- setting constants ----------------\n\n\t\t// c1 = 2*A*w*w\n\t\t// c2 = 2*(1-A)*w*p0\n\t\t// c3 = A*(2*w*s0+t)\n\t\t// c4 = t*t/p0\n\t\t// c5 = (1-A)*p0\n\t\t// c6 = A*(2*s0+w*t)\n\t\t// c7 = 2*A*w*(w+1)\n\t\t// c8 = 2*(1-A)*p0\n\t\t// c9 = 2*A*w*s0\n\t\t// c10= A*w*t\n\n\t\tlet ac = 1 - flatness;\n\t\tlet aw = flatness * w;\n\t\tlet acw = ac * w;\n\t\tlet as0 = flatness * s0;\n\t\tlet ah = flatness * h;\n\n\t\tlet c1 = 2 * aw * w;\n\t\tlet c2 = 2 * acw * p0;\n\t\tlet c3 = 2 * w * as0 + ah;\n\t\tlet c4 = (h * h) / p0;\n\t\tlet c5 = ac * p0;\n\t\tlet c6 = 2 * as0 + w * ah;\n\t\tlet c7 = 2 * aw * (w + 1);\n\t\tlet c8 = 2 * acw * p0;\n\t\tlet c9 = 2 * aw * s0;\n\t\tlet c10 = aw * h;\n\n\t\t// ---------------- iterating ----------------\n\n\t\t//x = (\n\t\t// x * (\n\t\t// (\n\t\t// x^w * (\n\t\t// c1 * x + c2 * x^w + c3\n\t\t// ) + c4\n\t\t// ) - x^w * (\n\t\t// c5 * x^w + c6\n\t\t// )\n\t\t// )\n\t\t//) / (\n\t\t// x^w * (\n\t\t// (\n\t\t// c7 * x + c8 * x^w + c9\n\t\t// ) - c10\n\t\t// )\n\t\t//)\n\n\t\tlet x = xi;\n\t\tlet xw; // x^w\n\n\t\tlet topPos;\n\t\tlet topNeg;\n\t\tlet bottomPos;\n\t\t//let bottomNeg;\n\n\t\tlet prevX = x;\n\n\t\tlet i = 0;\n\t\twhile (i < CmmmCalculations.maxNewtonAttempts) {\n\t\t\txw = Math.pow(x, w);\n\n\t\t\ttopPos = x * (xw * (c1 * x + c2 * xw + c3) + c4);\n\t\t\ttopNeg = x * (xw * (c5 * xw + c6));\n\t\t\tbottomPos = c7 * x + c8 * xw + c9;\n\t\t\t//bottomNeg = c10;\n\n\t\t\t// If x jumps too much (bad initial estimate) then g(x) might overshoot into a negative number.\n\t\t\t// This only happens if x is supposed to be small. In this case, replace x with a small number and try again.\n\t\t\t// Once x is close enough to the true value g(x) won't overshoot anymore and this test will be skipped from then on.\n\t\t\tif (topPos < topNeg || bottomPos < c10) {\n\t\t\t\tx = 1 / 2 ** i;\n\t\t\t\ti = i + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tx = (topPos - topNeg) / (xw * (bottomPos - c10));\n\n\t\t\t// using relative error here (easier to pass) because js numbers are less precise\n\t\t\tif (\n\t\t\t\tHelpers.closeEnough(x, prevX, CmmmCalculations.convergenceBound)\n\t\t\t) {\n\t\t\t\treturn x;\n\t\t\t}\n\n\t\t\tprevX = x;\n\t\t\ti = i + 1;\n\t\t}\n\t\tthrow Error(\"Newton diverged\");\n\t};\n\n\t// Compute the invariant before swap and pseudoinvariant (invariant considering fees)\n\t// after the swap and see if they are the same up to a tolerance.\n\t// It also checks that this balance does not drain the pool i.e. the final balance is at least 1.\n\t// The scalars are here to avoid unnecessary vector creation. In most calls one scalar will be 10^18 (1).\n\tpublic static checkValidSwap = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance,\n\t\tamountsInScalar: LocalNumber,\n\t\tamountsOut: CoinsToBalance,\n\t\tamountsOutScalar: LocalNumber\n\t): boolean => {\n\t\tlet coins = pool.coins;\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\n\t\t// balance = balances[i]\n\t\tlet balance;\n\t\t// pseudobalance = balance + feedAmountIn - feedAmountOut\n\t\tlet pseudobalance;\n\t\t// postbalance = balance + amountIn - amountOut\n\t\tlet postbalance;\n\t\tlet weight;\n\t\tlet amountIn;\n\t\tlet amountOut;\n\t\tlet feedAmountIn;\n\t\tlet feedAmountOut;\n\n\t\tlet preprod = 0;\n\t\tlet presum = 0;\n\t\tlet pseudoprod = 0;\n\t\tlet pseudosum = 0;\n\t\tlet postprod = 0;\n\t\tlet postsum = 0;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamountIn =\n\t\t\t\tFixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t\t) * amountsInScalar;\n\t\t\tamountOut =\n\t\t\t\tFixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOut[coinType] || BigInt(0)\n\t\t\t\t) * amountsOutScalar;\n\t\t\tif (amountIn > 0 && amountOut > 0) return false;\n\t\t\tfeedAmountIn =\n\t\t\t\tamountIn * (1 - FixedUtils.directCast(coin.tradeFeeIn));\n\t\t\tfeedAmountOut =\n\t\t\t\tamountOut === 0\n\t\t\t\t\t? 0\n\t\t\t\t\t: amountOut / (1 - FixedUtils.directCast(coin.tradeFeeOut));\n\n\t\t\tpostbalance = balance + amountIn;\n\t\t\tif (amountOut > postbalance + 1) return false;\n\t\t\tpostbalance -= -amountOut;\n\t\t\tpseudobalance = balance + feedAmountIn;\n\t\t\tif (feedAmountOut > pseudobalance + 1) return false;\n\t\t\tpseudobalance -= -feedAmountOut;\n\n\t\t\tpreprod += weight * Math.log(balance);\n\t\t\tpresum += weight * balance;\n\t\t\tpostprod += weight * Math.log(postbalance);\n\t\t\tpostsum += weight * postbalance;\n\t\t\tpseudoprod += weight * Math.log(pseudobalance);\n\t\t\tpseudosum += weight * pseudobalance;\n\t\t}\n\t\tpreprod = Math.exp(preprod);\n\t\tpostprod = Math.exp(postprod);\n\t\tpseudoprod = Math.exp(pseudoprod);\n\n\t\tlet preinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpreprod,\n\t\t\tpresum,\n\t\t\tflatness\n\t\t);\n\t\tlet postinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpostprod,\n\t\t\tpostsum,\n\t\t\tflatness\n\t\t);\n\t\tlet pseudoinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpseudoprod,\n\t\t\tpseudosum,\n\t\t\tflatness\n\t\t);\n\n\t\treturn (\n\t\t\tpostinvariant * (1 + CmmmCalculations.tolerance) >= preinvariant &&\n\t\t\t(Helpers.veryCloseInt(\n\t\t\t\tpreinvariant,\n\t\t\t\tpseudoinvariant,\n\t\t\t\tFixedUtils.fixedOneN\n\t\t\t) ||\n\t\t\t\tHelpers.closeEnough(\n\t\t\t\t\tpreinvariant,\n\t\t\t\t\tpseudoinvariant,\n\t\t\t\t\tCmmmCalculations.validityTolerance\n\t\t\t\t))\n\t\t);\n\t};\n\n\t// Compute the invariant before swap and pseudoinvariant (invariant considering fees)\n\t// after the swap and see if they are the same up to a tolerance.\n\t// It also checks that this balance does not drain the pool i.e. the final balance is at least 1.\n\tpublic static checkValid1dSwap = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tamountInB: Balance,\n\t\tamountOutB: Balance\n\t): boolean => {\n\t\tif (coinTypeIn === coinTypeOut) return false;\n\t\tlet coins = pool.coins;\n\t\tlet coinIn = coins[coinTypeIn];\n\t\tlet coinOut = coins[coinTypeOut];\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\n\t\t// balance = balances[i]\n\t\tlet balance;\n\t\t// pseudobalance = balance + feed amount in - feed amount out\n\t\tlet pseudobalance;\n\t\t// postbalance = balance + amount in - amount out\n\t\tlet postbalance;\n\t\tlet weight;\n\t\tlet amountIn = FixedUtils.castAndNormalize(\n\t\t\tcoinIn.decimalsScalar,\n\t\t\tamountInB\n\t\t);\n\t\tlet amountOut = FixedUtils.castAndNormalize(\n\t\t\tcoinOut.decimalsScalar,\n\t\t\tamountOutB\n\t\t);\n\t\tlet feedAmountIn =\n\t\t\tamountIn * (1 - FixedUtils.directCast(coinIn.tradeFeeIn));\n\t\tlet feedAmountOut =\n\t\t\tamountOut === 0\n\t\t\t\t? 0\n\t\t\t\t: amountOut / (1 - FixedUtils.directCast(coinOut.tradeFeeOut));\n\n\t\tlet preprod = 0;\n\t\tlet presum = 0;\n\t\tlet pseudoprod = 0;\n\t\tlet pseudosum = 0;\n\t\tlet postprod = 0;\n\t\tlet postsum = 0;\n\t\tlet p;\n\t\tlet s;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\n\t\t\tp = weight * Math.log(balance);\n\t\t\ts = weight * balance;\n\n\t\t\tpreprod += p;\n\t\t\tpresum += s;\n\n\t\t\tif (coinType === coinTypeIn) {\n\t\t\t\tpseudobalance = balance + feedAmountIn;\n\t\t\t\tpostbalance = balance + amountIn;\n\n\t\t\t\tpseudoprod += weight * Math.log(pseudobalance);\n\t\t\t\tpseudosum += weight * pseudobalance;\n\t\t\t\tpostprod += weight * Math.log(postbalance);\n\t\t\t\tpostsum += weight * postbalance;\n\t\t\t} else {\n\t\t\t\tif (coinType === coinTypeOut) {\n\t\t\t\t\tif (feedAmountOut > balance + 1 || amountOut > balance + 1)\n\t\t\t\t\t\treturn false;\n\t\t\t\t\tpseudobalance = balance - feedAmountOut;\n\t\t\t\t\tpostbalance = balance - amountOut;\n\n\t\t\t\t\tpseudoprod += weight * Math.log(pseudobalance);\n\t\t\t\t\tpseudosum += weight * pseudobalance;\n\t\t\t\t\tpostprod += weight * Math.log(postbalance);\n\t\t\t\t\tpostsum += weight * postbalance;\n\t\t\t\t} else {\n\t\t\t\t\tpseudoprod += p;\n\t\t\t\t\tpseudosum += s;\n\t\t\t\t\tpostprod += p;\n\t\t\t\t\tpostsum += s;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpreprod = Math.exp(preprod);\n\t\tpostprod = Math.exp(postprod);\n\t\tpseudoprod = Math.exp(pseudoprod);\n\n\t\tlet preinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpreprod,\n\t\t\tpresum,\n\t\t\tflatness\n\t\t);\n\t\tlet postinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpostprod,\n\t\t\tpostsum,\n\t\t\tflatness\n\t\t);\n\t\tlet pseudoinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpseudoprod,\n\t\t\tpseudosum,\n\t\t\tflatness\n\t\t);\n\n\t\treturn (\n\t\t\tpostinvariant * (1 + CmmmCalculations.tolerance) >= preinvariant &&\n\t\t\t(Helpers.veryCloseInt(\n\t\t\t\tpreinvariant,\n\t\t\t\tpseudoinvariant,\n\t\t\t\tFixedUtils.fixedOneN\n\t\t\t) ||\n\t\t\t\tHelpers.closeEnough(\n\t\t\t\t\tpreinvariant,\n\t\t\t\t\tpseudoinvariant,\n\t\t\t\t\tCmmmCalculations.validityTolerance\n\t\t\t\t))\n\t\t);\n\t};\n\n\t// A fixed amount investment is a swap followed by an all coin investment. This function checks that the\n\t// intermediate swap is allowed and corresponds to the claimed lp ratio.\n\tpublic static checkValidDeposit = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance,\n\t\tlpRatioRaw: OnChainScalar\n\t): boolean => {\n\t\t// The supposed swap is from B0 to R*(B0 + Din)\n\t\t// This test is check_valid_swap for those data\n\n\t\tlet coins = pool.coins;\n\t\tlet lpRatio = FixedUtils.directCast(lpRatioRaw);\n\t\tif (lpRatio > 1) return false;\n\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\n\t\t// balance = balances[i]\n\t\tlet balance;\n\t\tlet weight;\n\t\t// amount = amountsIn[i]\n\t\tlet amount;\n\t\t// postbalance = lpRatio * (balance + amount)\n\t\tlet postbalance;\n\t\t// pseudobalance = fee(postbalance - balance) + balance\n\t\tlet pseudobalance;\n\t\t// diff = postbalance - balance\n\t\tlet diff;\n\t\t// pseudodiff = fee(diff)\n\t\tlet pseudodiff;\n\n\t\tlet preprod = 0;\n\t\tlet presum = 0;\n\t\tlet pseudoprod = 0;\n\t\tlet pseudosum = 0;\n\t\tlet postprod = 0;\n\t\tlet postsum = 0;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tpostbalance = lpRatio * (balance + amount);\n\n\t\t\tif (postbalance >= balance) {\n\t\t\t\t// use fee in\n\t\t\t\tdiff = postbalance - balance;\n\t\t\t\tpseudodiff =\n\t\t\t\t\tdiff * (1 - FixedUtils.directCast(coin.tradeFeeIn));\n\t\t\t\tpseudobalance = balance + pseudodiff;\n\t\t\t} else {\n\t\t\t\t// use fee out\n\t\t\t\tdiff = balance - postbalance;\n\t\t\t\tpseudodiff =\n\t\t\t\t\tdiff === 0\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: diff / (1 - FixedUtils.directCast(coin.tradeFeeOut));\n\t\t\t\tif (pseudodiff >= balance + 1) return false;\n\t\t\t\tpseudobalance = balance - pseudodiff;\n\t\t\t}\n\n\t\t\tpreprod += weight * Math.log(balance);\n\t\t\tpresum += weight * balance;\n\t\t\tpostprod += weight * Math.log(postbalance);\n\t\t\tpostsum += weight * postbalance;\n\t\t\tpseudoprod += weight * Math.log(pseudobalance);\n\t\t\tpseudosum += weight * pseudobalance;\n\t\t}\n\t\tpreprod = Math.exp(preprod);\n\t\tpostprod = Math.exp(postprod);\n\t\tpseudoprod = Math.exp(pseudoprod);\n\n\t\tlet preinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpreprod,\n\t\t\tpresum,\n\t\t\tflatness\n\t\t);\n\t\tlet postinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpostprod,\n\t\t\tpostsum,\n\t\t\tflatness\n\t\t);\n\t\tlet pseudoinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpseudoprod,\n\t\t\tpseudosum,\n\t\t\tflatness\n\t\t);\n\n\t\treturn (\n\t\t\tpostinvariant * (1 + CmmmCalculations.tolerance) >= preinvariant &&\n\t\t\t(Helpers.veryCloseInt(\n\t\t\t\tpreinvariant,\n\t\t\t\tpseudoinvariant,\n\t\t\t\tFixedUtils.fixedOneN\n\t\t\t) ||\n\t\t\t\tHelpers.closeEnough(\n\t\t\t\t\tpreinvariant,\n\t\t\t\t\tpseudoinvariant,\n\t\t\t\t\tCmmmCalculations.validityTolerance\n\t\t\t\t))\n\t\t);\n\t};\n\n\t// A fixed lp withdraw is an all coin withdraw followed by a swap.\n\t// This function checks that the swap is valid.\n\tpublic static checkValidWithdraw = (\n\t\tpool: PoolObject,\n\t\tamountsOutSrc: CoinsToBalance,\n\t\tlpRatio: LocalNumber\n\t): boolean => {\n\t\t// Check that the swap from R*B0 to B0 - Dout is valid\n\n\t\tlet coins = pool.coins;\n\t\tif (lpRatio > 1) return false;\n\n\t\tlet flatness = FixedUtils.directCast(pool.flatness);\n\n\t\t// balance = balances[i]\n\t\tlet balance;\n\t\tlet weight;\n\t\t// amount is scaled amounts out at i\n\t\tlet amount;\n\t\t// scaledBalance = lpRatio * balance\n\t\tlet scaledBalance;\n\t\t// postbalance = balance - amount\n\t\tlet postbalance;\n\t\t// pseudobalance is postbalance but considering fees\n\t\tlet pseudobalance;\n\t\tlet diff;\n\t\tlet pseudodiff;\n\n\t\tlet preprod = 0;\n\t\tlet presum = 0;\n\t\tlet pseudoprod = 0;\n\t\tlet pseudosum = 0;\n\t\tlet postprod = 0;\n\t\tlet postsum = 0;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tscaledBalance = lpRatio * balance;\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamount = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOutSrc[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tif (amount > scaledBalance + 1) return false;\n\t\t\tpostbalance = balance - amount;\n\n\t\t\tif (postbalance >= scaledBalance) {\n\t\t\t\t// use fee in\n\t\t\t\tdiff = postbalance - scaledBalance;\n\t\t\t\tpseudodiff =\n\t\t\t\t\tdiff *\n\t\t\t\t\tFixedUtils.complement(\n\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeIn)\n\t\t\t\t\t);\n\t\t\t\tpseudobalance = scaledBalance + pseudodiff;\n\t\t\t} else {\n\t\t\t\t// use fee out\n\t\t\t\tdiff = scaledBalance - postbalance;\n\t\t\t\tpseudodiff =\n\t\t\t\t\tdiff === 0\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: diff /\n\t\t\t\t\t\t FixedUtils.complement(\n\t\t\t\t\t\t\t\tFixedUtils.directCast(coin.tradeFeeOut)\n\t\t\t\t\t\t );\n\t\t\t\tif (pseudodiff > scaledBalance + 1) return false;\n\t\t\t\tpseudobalance = scaledBalance - pseudodiff;\n\t\t\t}\n\n\t\t\tpreprod += weight * Math.log(scaledBalance);\n\t\t\tpresum += weight * scaledBalance;\n\t\t\tpostprod += weight * Math.log(postbalance);\n\t\t\tpostsum += weight * postbalance;\n\t\t\tpseudoprod += weight * Math.log(pseudobalance);\n\t\t\tpseudosum += weight * pseudobalance;\n\t\t}\n\t\tpreprod = Math.exp(preprod);\n\t\tpostprod = Math.exp(postprod);\n\t\tpseudoprod = Math.exp(pseudoprod);\n\n\t\tlet preinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpreprod,\n\t\t\tpresum,\n\t\t\tflatness\n\t\t);\n\t\tlet postinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpostprod,\n\t\t\tpostsum,\n\t\t\tflatness\n\t\t);\n\t\tlet pseudoinvariant = CmmmCalculations.calcInvariantQuadratic(\n\t\t\tpseudoprod,\n\t\t\tpseudosum,\n\t\t\tflatness\n\t\t);\n\n\t\treturn (\n\t\t\tpostinvariant * (1 + CmmmCalculations.tolerance) >= preinvariant &&\n\t\t\t(Helpers.veryCloseInt(\n\t\t\t\tpreinvariant,\n\t\t\t\tpseudoinvariant,\n\t\t\t\tFixedUtils.fixedOneN\n\t\t\t) ||\n\t\t\t\tHelpers.closeEnough(\n\t\t\t\t\tpreinvariant,\n\t\t\t\t\tpseudoinvariant,\n\t\t\t\t\tCmmmCalculations.validityTolerance\n\t\t\t\t))\n\t\t);\n\t};\n\n\t// get an estimate for outGivenIn based on the spot price\n\tpublic static getEstimateOutGivenIn = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tamountIn: Balance\n\t): Balance =>\n\t\tHelpers.blendedOperations.mulNBB(\n\t\t\tCmmmCalculations.calcSpotPriceWithFees(\n\t\t\t\tpool,\n\t\t\t\tcoinTypeIn,\n\t\t\t\tcoinTypeOut\n\t\t\t),\n\t\t\tamountIn\n\t\t);\n\n\t// get an estimate for inGivenOut based on the spot price\n\tpublic static getEstimateInGivenOut = (\n\t\tpool: PoolObject,\n\t\tcoinTypeIn: CoinType,\n\t\tcoinTypeOut: CoinType,\n\t\tamountOut: Balance\n\t): Balance =>\n\t\tHelpers.blendedOperations.mulNBB(\n\t\t\t1 /\n\t\t\t\tCmmmCalculations.calcSpotPriceWithFees(\n\t\t\t\t\tpool,\n\t\t\t\t\tcoinTypeIn,\n\t\t\t\t\tcoinTypeOut\n\t\t\t\t),\n\t\t\tamountOut\n\t\t);\n\n\t// get an estimate for swapFixedIn using the spot prices\n\t// returns t > 0 such that t*amountsOutDirection agrees with amountsIn wrt spot prices\n\tpublic static getEstimateSwapFixedIn = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance,\n\t\tamountsOutDirection: CoinsToBalance\n\t): LocalNumber => {\n\t\t// find t such that Ain + t*Aout lies in the tangent plane to the swap surface at balances in the given directions\n\n\t\t// the gradient of the invariant function with fees is (with spot body E)\n\t\t// Win * (1 - Sin) * (E + 2*A * Bin) / Bin or\n\t\t// Wout * (E + 2*A * Bout) / (1-Sout) * Bout\n\t\t// depending on whether the balance is coming in or going out\n\n\t\tlet coins = pool.coins;\n\t\tlet spotBody = CmmmCalculations.calcSpotPriceBody(pool);\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\n\t\tlet balance;\n\t\tlet grad;\n\t\tlet amountIn;\n\t\tlet amountOut;\n\t\tlet inDotGrad = 0;\n\t\tlet outDotGrad = 0;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamountIn = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tgrad =\n\t\t\t\tamountIn === 0\n\t\t\t\t\t? (FixedUtils.directCast(coin.weight) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t (balance * (1 - FixedUtils.directCast(coin.tradeFeeOut)))\n\t\t\t\t\t: (FixedUtils.directCast(coin.weight) *\n\t\t\t\t\t\t\t(1 - FixedUtils.directCast(coin.tradeFeeIn)) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t balance;\n\t\t\tinDotGrad += amountIn * grad;\n\t\t\toutDotGrad += amountOut * grad;\n\t\t}\n\n\t\treturn inDotGrad / outDotGrad;\n\t};\n\n\t// get an estimate for swapFixedOut using the spot prices\n\t// returns t > 0 such that t*amountsInDirection agrees with amountsOut wrt spot prices\n\tpublic static getEstimateSwapFixedOut = (\n\t\tpool: PoolObject,\n\t\tamountsInDirection: CoinsToBalance,\n\t\tamountsOut: CoinsToBalance\n\t): LocalNumber => {\n\t\t// find t such that Ain + t*Aout lies in the tangent plane to the swap surface at balances in the given directions\n\n\t\t// the gradient of the invariant function with fees is (with spot body E)\n\t\t// Win * (1 - Sin) * (E + 2*A * Bin) / Bin or\n\t\t// Wout * (E + 2*A * Bout) / (1-Sout) * Bout\n\t\t// depending on whether the balance is coming in or going out\n\n\t\tlet coins = pool.coins;\n\t\tlet spotBody = CmmmCalculations.calcSpotPriceBody(pool);\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\n\t\tlet balance;\n\t\tlet grad;\n\t\tlet amountIn;\n\t\tlet amountOut;\n\t\tlet inDotGrad = 0;\n\t\tlet outDotGrad = 0;\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tamountIn = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsInDirection[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tamountOut = FixedUtils.castAndNormalize(\n\t\t\t\tcoin.decimalsScalar,\n\t\t\t\tamountsOut[coinType] || BigInt(0)\n\t\t\t);\n\t\t\tgrad =\n\t\t\t\tamountIn === 0\n\t\t\t\t\t? (FixedUtils.directCast(coin.weight) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t (balance * (1 - FixedUtils.directCast(coin.tradeFeeOut)))\n\t\t\t\t\t: (FixedUtils.directCast(coin.weight) *\n\t\t\t\t\t\t\t(1 - FixedUtils.directCast(coin.tradeFeeIn)) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t balance;\n\t\t\tinDotGrad += amountIn * grad;\n\t\t\toutDotGrad += amountOut * grad;\n\t\t}\n\n\t\treturn outDotGrad / inDotGrad;\n\t};\n\n\t// Calculate an estimate for lpRatio using the spot price (linear estiamtion)\n\t// This estimation will be very good for small values in amountsIn\n\tpublic static getEstimateDepositFixedAmounts = (\n\t\tpool: PoolObject,\n\t\tamountsIn: CoinsToBalance\n\t): LocalNumber => {\n\t\t// Initial estimate comes from testing the discontinuities and doing a linear\n\t\t// approximation off the two closest test points. We use it to get the correct fees.\n\t\tlet r0 = CmmmCalculations.calcDepositFixedAmountsInitialEstimate(\n\t\t\tpool,\n\t\t\tamountsIn\n\t\t);\n\n\t\t// Now r0 is on the correct side of B0 as the final t*(B0+Din). This tells us which fees apply.\n\t\t// All we have to do is find the value of r for which r*(B0+Din) lies on the feed tangent plane at B0.\n\n\t\t// the gradient of the invariant function with fees is (with spot body E)\n\t\t// Win * (1 - Sin) * (E + 2*A * Bin) / Bin or\n\t\t// Wout * (E + 2*A * Bout) / (1-Sout) * Bout\n\t\t// depending on whether the balance is coming in or going out\n\n\t\tlet coins = pool.coins;\n\t\tlet spotBody = CmmmCalculations.calcSpotPriceBody(pool);\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\n\t\t// dot(B0, g)\n\t\tlet d1 = 0;\n\t\t// dot(B0 + Din, g)\n\t\tlet d2 = 0;\n\n\t\tlet balance;\n\t\tlet weight;\n\t\tlet amount;\n\t\tlet grad;\n\t\tlet scaledAmount;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamount =\n\t\t\t\tbalance +\n\t\t\t\tFixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsIn[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\tscaledAmount = amount * r0;\n\n\t\t\tgrad =\n\t\t\t\tscaledAmount < balance\n\t\t\t\t\t? // use amount out\n\t\t\t\t\t (weight * (spotBody + 2 * a * balance)) /\n\t\t\t\t\t (balance * (1 - FixedUtils.directCast(coin.tradeFeeOut)))\n\t\t\t\t\t: // use amount in\n\t\t\t\t\t (weight *\n\t\t\t\t\t\t\t(1 - FixedUtils.directCast(coin.tradeFeeIn)) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t balance;\n\n\t\t\td1 += balance * grad;\n\t\t\td2 += amount * grad;\n\t\t}\n\n\t\treturn d1 / d2;\n\t};\n\n\t// Calculate an estimate for amountsOut using the spot price (linear estiamtion)\n\t// This estimation will be very good for lpRatios close to 1\n\t// Since we still need the out vector for its direction we return t s.t. t*amountsOutDirection is the estimate.\n\tpublic static getEstimateWithdrawFlpAmountsOut = (\n\t\tpool: PoolObject,\n\t\tamountsOutDirection: CoinsToBalance,\n\t\tlpRatio: LocalNumber\n\t): LocalNumber => {\n\t\t// Initial estimate comes from testing the discontinuities and doing a linear\n\t\t// approximation off the two closest test points. We use it to get the correct fees.\n\t\tlet [r0, _rDrain] =\n\t\t\tCmmmCalculations.calcWithdrawFlpAmountsOutInitialEstimate(\n\t\t\t\tpool,\n\t\t\t\tamountsOutDirection,\n\t\t\t\tlpRatio\n\t\t\t);\n\n\t\t// Now r0 is on the correct side of R*B0 as the final B0-t*Deout. This tells us which fees apply.\n\t\t// All we have to do is find the value of t for which B0-t*Deout lies on the feed tangent plane at R*B0.\n\n\t\t// the gradient of the invariant function with fees is (with spot body E)\n\t\t// Win * (1 - Sin) * (E + 2*A * Bin) / Bin or\n\t\t// Wout * (E + 2*A * Bout) / (1-Sout) * Bout\n\t\t// depending on whether the balance is coming in or going out\n\n\t\tlet coins = pool.coins;\n\t\t// Swap center is R*B0, not B0. Luckily the spot body formula is homogeneous.\n\t\tlet spotBody = CmmmCalculations.calcSpotPriceBody(pool) * lpRatio;\n\t\tlet a = FixedUtils.directCast(pool.flatness);\n\n\t\t// dot(B0, g)\n\t\tlet d1 = 0;\n\t\t// dot(Deout, g)\n\t\tlet d2 = 0;\n\n\t\tlet balance;\n\t\tlet scaledAmount;\n\t\tlet weight;\n\t\tlet amount;\n\t\tlet grad;\n\n\t\tfor (let [coinType, coin] of Object.entries(coins)) {\n\t\t\tbalance = FixedUtils.directCast(coin.normalizedBalance);\n\t\t\tweight = FixedUtils.directCast(coin.weight);\n\t\t\tamount =\n\t\t\t\tbalance +\n\t\t\t\tFixedUtils.castAndNormalize(\n\t\t\t\t\tcoin.decimalsScalar,\n\t\t\t\t\tamountsOutDirection[coinType] || BigInt(0)\n\t\t\t\t);\n\t\t\tscaledAmount = amount * r0;\n\n\t\t\tgrad =\n\t\t\t\tscaledAmount < balance\n\t\t\t\t\t? // use amount out\n\t\t\t\t\t (weight * (spotBody + 2 * a * balance)) /\n\t\t\t\t\t (balance * (1 - FixedUtils.directCast(coin.tradeFeeOut)))\n\t\t\t\t\t: // use amount in\n\t\t\t\t\t (weight *\n\t\t\t\t\t\t\t(1 - FixedUtils.directCast(coin.tradeFeeIn)) *\n\t\t\t\t\t\t\t(spotBody + 2 * a * balance)) /\n\t\t\t\t\t balance;\n\n\t\t\td1 += balance * grad;\n\t\t\td2 += amount * grad;\n\t\t}\n\n\t\treturn ((1 - lpRatio) * d1) / d2;\n\t};\n}\n","import {\n\tApiPoolDepositBody,\n\tApiPoolTradeBody,\n\tApiPoolWithdrawBody,\n\tBalance,\n\tCoinType,\n\tCoinsToBalance,\n\tPoolDataPoint,\n\tPoolGraphDataTimeframeKey,\n\tPoolObject,\n\tPoolStats,\n\tSuiNetwork,\n\tPoolDepositEvent,\n\tPoolWithdrawEvent,\n\tPoolTradeEvent,\n\tUrl,\n\tApiPoolAllCoinWithdrawBody,\n\tApiIndexerEventsBody,\n\tIndexerEventsWithCursor,\n\tPercentage,\n\tSuiAddress,\n\tObjectId,\n\tPoolCoin,\n\tCallerConfig,\n} from \"../../types\";\nimport { CmmmCalculations } from \"./utils/cmmmCalculations\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { Pools } from \".\";\nimport { Casting, Helpers } from \"../../general/utils\";\nimport { Transaction } from \"@mysten/sui/transactions\";\nimport { Coin } from \"..\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * The `Pool` class encapsulates all the functionality needed to interact\n * with a specific AMM pool on the Aftermath platform. It allows you to\n * calculate trade amounts, deposit/withdraw amounts, fetch transactions,\n * and retrieve on-chain statistics and event data.\n *\n * @example\n * ```typescript\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // initialize provider\n *\n * const pools = afSdk.Pools();\n * const pool = await pools.getPool({ objectId: \"0x...\" });\n *\n * const stats = await pool.getStats();\n * const tradeTx = await pool.getTradeTransaction({\n * walletAddress: \"0x...\",\n * coinInType: \"0x2::sui::SUI\",\n * coinInAmount: BigInt(1e9),\n * coinOutType: \"0x<yourCoin>\",\n * slippage: 0.01,\n * });\n * ```\n */\nexport class Pool extends Caller {\n\t/**\n\t * Internal margin of error used in trade calculations to prevent\n\t * exceeding maximum allowed percentages of pool balances.\n\t */\n\tprivate static readonly constants = {\n\t\tpercentageBoundsMarginOfError: 0.001, // 0.1%\n\t};\n\n\t/**\n\t * An optional cached object containing statistical data about the pool\n\t * (volume, fees, APR, etc.).\n\t */\n\tpublic stats: PoolStats | undefined;\n\n\t/**\n\t * Creates a new instance of the `Pool` class for on-chain interaction.\n\t *\n\t * @param pool - The fetched `PoolObject` from Aftermath API or on-chain query.\n\t * @param config - Optional caller configuration (e.g., network, access token).\n\t * @param Provider - An optional `AftermathApi` instance for advanced transaction usage.\n\t */\n\tconstructor(\n\t\tpublic readonly pool: PoolObject,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, `pools/${pool.objectId}`);\n\t\tthis.pool = pool;\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds or fetches a deposit transaction to add liquidity to this pool.\n\t * The resulting `Transaction` can be signed and submitted by the user.\n\t *\n\t * @param inputs - The deposit parameters including coin amounts, slippage, etc.\n\t * @returns A `Transaction` to deposit funds into the pool.\n\t *\n\t * @example\n\t * ```typescript\n\t * const depositTx = await pool.getDepositTransaction({\n\t * walletAddress: \"0x...\",\n\t * amountsIn: { \"0x<coin>\": BigInt(1000000) },\n\t * slippage: 0.01,\n\t * });\n\t * ```\n\t */\n\tpublic async getDepositTransaction(\n\t\tinputs: ApiPoolDepositBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildDepositTx({\n\t\t\t...inputs,\n\t\t\tpool: this,\n\t\t});\n\t}\n\n\t/**\n\t * Builds or fetches a withdrawal transaction to remove liquidity from this pool.\n\t *\n\t * @param inputs - The parameters specifying how much LP is burned, desired coins out, slippage, etc.\n\t * @returns A `Transaction` to withdraw funds from the pool.\n\t *\n\t * @example\n\t * ```typescript\n\t * const withdrawTx = await pool.getWithdrawTransaction({\n\t * walletAddress: \"0x...\",\n\t * amountsOutDirection: {\n\t * \"0x<coin>\": BigInt(500000),\n\t * },\n\t * lpCoinAmount: BigInt(1000000),\n\t * slippage: 0.01,\n\t * });\n\t * ```\n\t */\n\tpublic async getWithdrawTransaction(\n\t\tinputs: ApiPoolWithdrawBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildWithdrawTx({\n\t\t\t...inputs,\n\t\t\tpool: this,\n\t\t});\n\t}\n\n\t/**\n\t * Builds or fetches a transaction to withdraw all coin types from this pool,\n\t * effectively \"burning\" an LP position in exchange for multiple coin outputs.\n\t *\n\t * @param inputs - The parameters specifying how much LP to burn.\n\t * @returns A `Transaction` to withdraw all coins from the pool in proportion.\n\t *\n\t * @example\n\t * ```typescript\n\t * const allCoinWithdrawTx = await pool.getAllCoinWithdrawTransaction({\n\t * walletAddress: \"0x...\",\n\t * lpCoinAmount: BigInt(500000),\n\t * });\n\t * ```\n\t */\n\tpublic async getAllCoinWithdrawTransaction(\n\t\tinputs: ApiPoolAllCoinWithdrawBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildAllCoinWithdrawTx({\n\t\t\t...inputs,\n\t\t\tpool: this,\n\t\t});\n\t}\n\n\t/**\n\t * Builds or fetches a trade transaction to swap between two coin types in this pool.\n\t *\n\t * @param inputs - The trade parameters including coin in/out, amounts, slippage, etc.\n\t * @returns A `Transaction` that can be signed and executed for the swap.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tradeTx = await pool.getTradeTransaction({\n\t * walletAddress: \"0x...\",\n\t * coinInType: \"0x<coinA>\",\n\t * coinInAmount: BigInt(1000000),\n\t * coinOutType: \"0x<coinB>\",\n\t * slippage: 0.005,\n\t * });\n\t * ```\n\t */\n\tpublic async getTradeTransaction(\n\t\tinputs: ApiPoolTradeBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildTradeTx({\n\t\t\t...inputs,\n\t\t\tpool: this,\n\t\t});\n\t}\n\n\t/**\n\t * Builds a transaction to update the DAO fee percentage for this pool,\n\t * if it has a DAO fee configured. The user must own the appropriate\n\t * `daoFeePoolOwnerCap`.\n\t *\n\t * @param inputs - Includes user wallet, `daoFeePoolOwnerCapId`, and the new fee percentage.\n\t * @returns A `Transaction` that can be signed to update the DAO fee on chain.\n\t * @throws If this pool has no DAO fee configuration.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tx = await pool.getUpdateDaoFeeTransaction({\n\t * walletAddress: \"0x...\",\n\t * daoFeePoolOwnerCapId: \"0x<capId>\",\n\t * newFeePercentage: 0.01, // 1%\n\t * });\n\t * ```\n\t */\n\tpublic async getUpdateDaoFeeTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tdaoFeePoolOwnerCapId: ObjectId;\n\t\tnewFeePercentage: Percentage;\n\t}): Promise<Transaction> {\n\t\tconst daoFeePoolId = this.pool.daoFeePoolObject?.objectId;\n\t\tif (!daoFeePoolId) throw new Error(\"this pool has no DAO fee\");\n\n\t\treturn this.useProvider().buildDaoFeePoolUpdateFeeBpsTx({\n\t\t\t...inputs,\n\t\t\tdaoFeePoolId,\n\t\t\tlpCoinType: this.pool.lpCoinType,\n\t\t\tnewFeeBps: Casting.percentageToBps(inputs.newFeePercentage),\n\t\t});\n\t}\n\n\t/**\n\t * Builds a transaction to update the DAO fee recipient for this pool,\n\t * if it has a DAO fee configured. The user must own the appropriate\n\t * `daoFeePoolOwnerCap`.\n\t *\n\t * @param inputs - Includes user wallet, `daoFeePoolOwnerCapId`, and the new fee recipient.\n\t * @returns A `Transaction` that can be signed to update the DAO fee recipient on chain.\n\t * @throws If this pool has no DAO fee configuration.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tx = await pool.getUpdateDaoFeeRecipientTransaction({\n\t * walletAddress: \"0x...\",\n\t * daoFeePoolOwnerCapId: \"0x<capId>\",\n\t * newFeeRecipient: \"0x<recipient>\",\n\t * });\n\t * ```\n\t */\n\tpublic async getUpdateDaoFeeRecipientTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tdaoFeePoolOwnerCapId: ObjectId;\n\t\tnewFeeRecipient: SuiAddress;\n\t}): Promise<Transaction> {\n\t\tconst daoFeePoolId = this.pool.daoFeePoolObject?.objectId;\n\t\tif (!daoFeePoolId) throw new Error(\"this pool has no DAO fee\");\n\n\t\treturn this.useProvider().buildDaoFeePoolUpdateFeeRecipientTx({\n\t\t\t...inputs,\n\t\t\tdaoFeePoolId,\n\t\t\tlpCoinType: this.pool.lpCoinType,\n\t\t\tnewFeeRecipient: Helpers.addLeadingZeroesToType(\n\t\t\t\tinputs.newFeeRecipient\n\t\t\t),\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Fetches comprehensive pool statistics (volume, TVL, fees, APR, etc.) from the Aftermath API.\n\t * Also caches the result in `this.stats`.\n\t *\n\t * @returns A promise resolving to `PoolStats` object.\n\t *\n\t * @example\n\t * ```typescript\n\t * const stats = await pool.getStats();\n\t * console.log(stats.volume, stats.fees, stats.apr);\n\t * ```\n\t */\n\tpublic async getStats(): Promise<PoolStats> {\n\t\tconst stats = await this.fetchApi<PoolStats>(\"stats\");\n\t\tthis.setStats(stats);\n\t\treturn stats;\n\t}\n\n\t/**\n\t * Caches the provided stats object into `this.stats`.\n\t *\n\t * @param stats - The `PoolStats` object to store.\n\t */\n\tpublic setStats(stats: PoolStats): void {\n\t\tthis.stats = stats;\n\t}\n\n\t/**\n\t * Fetches an array of volume data points for a specified timeframe.\n\t * This is often used for charting or historical references.\n\t *\n\t * @param inputs - Contains a `timeframe` key, such as `\"1D\"` or `\"1W\"`.\n\t * @returns A promise resolving to an array of `PoolDataPoint`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const volumeData = await pool.getVolumeData({ timeframe: \"1D\" });\n\t * console.log(volumeData); // e.g. [{ time: 1686000000, value: 123.45 }, ...]\n\t * ```\n\t */\n\tpublic async getVolumeData(inputs: {\n\t\ttimeframe: PoolGraphDataTimeframeKey;\n\t}): Promise<PoolDataPoint[]> {\n\t\treturn this.fetchApi(`volume/${inputs.timeframe}`);\n\t}\n\n\t/**\n\t * Fetches an array of fee data points for a specified timeframe.\n\t *\n\t * @param inputs - Contains a `timeframe` key, e.g., `\"1D\"` or `\"1W\"`.\n\t * @returns A promise resolving to an array of `PoolDataPoint`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const feeData = await pool.getFeeData({ timeframe: \"1D\" });\n\t * console.log(feeData);\n\t * ```\n\t */\n\tpublic async getFeeData(inputs: {\n\t\ttimeframe: PoolGraphDataTimeframeKey;\n\t}): Promise<PoolDataPoint[]> {\n\t\treturn this.fetchApi(`fees/${inputs.timeframe}`);\n\t}\n\n\t/**\n\t * Retrieves the 24-hour volume for this specific pool.\n\t *\n\t * @returns A promise resolving to a number (volume in 24h).\n\t *\n\t * @example\n\t * ```typescript\n\t * const vol24h = await pool.getVolume24hrs();\n\t * console.log(\"Pool 24h Volume:\", vol24h);\n\t * ```\n\t */\n\tpublic getVolume24hrs = async (): Promise<number> => {\n\t\treturn this.fetchApi(\"volume-24hrs\");\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t/**\n\t * Fetches user interaction events (deposit/withdraw) with this pool, optionally paginated.\n\t *\n\t * @param inputs - Includes user `walletAddress` and optional pagination fields.\n\t * @returns A promise that resolves to `PoolDepositEvent | PoolWithdrawEvent` objects with a cursor if more exist.\n\t *\n\t * @example\n\t * ```typescript\n\t * const events = await pool.getInteractionEvents({ walletAddress: \"0x...\", limit: 10 });\n\t * console.log(events.events, events.nextCursor);\n\t * ```\n\t */\n\tpublic async getInteractionEvents(\n\t\tinputs: ApiIndexerEventsBody & {\n\t\t\twalletAddress: SuiAddress;\n\t\t}\n\t) {\n\t\treturn this.fetchApiIndexerEvents<\n\t\t\tPoolDepositEvent | PoolWithdrawEvent,\n\t\t\tApiIndexerEventsBody\n\t\t>(\"interaction-events-by-user\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculates the instantaneous spot price for swapping from `coinInType`\n\t * to `coinOutType` within this pool. Optionally includes fees in the price.\n\t *\n\t * @param inputs - Object specifying input coin, output coin, and a boolean for `withFees`.\n\t * @returns The numerical spot price (float).\n\t *\n\t * @example\n\t * ```typescript\n\t * const price = pool.getSpotPrice({\n\t * coinInType: \"0x<coinA>\",\n\t * coinOutType: \"0x<coinB>\",\n\t * withFees: true,\n\t * });\n\t * console.log(\"Spot Price:\", price);\n\t * ```\n\t */\n\tpublic getSpotPrice = (inputs: {\n\t\tcoinInType: CoinType;\n\t\tcoinOutType: CoinType;\n\t\twithFees?: boolean;\n\t}) => {\n\t\tconst spotPriceWithDecimals = CmmmCalculations.calcSpotPriceWithFees(\n\t\t\tHelpers.deepCopy(this.pool),\n\t\t\tinputs.coinInType,\n\t\t\tinputs.coinOutType,\n\t\t\t!inputs.withFees\n\t\t);\n\n\t\t// Adjust for decimals difference\n\t\treturn (\n\t\t\t(spotPriceWithDecimals *\n\t\t\t\tNumber(this.pool.coins[inputs.coinOutType].decimalsScalar)) /\n\t\t\tNumber(this.pool.coins[inputs.coinInType].decimalsScalar)\n\t\t);\n\t};\n\n\t// TODO: account for referral discount for all calculations\n\n\t/**\n\t * Calculates how much output coin you would receive when trading\n\t * a given input coin and amount in this pool, factoring in protocol\n\t * and optional DAO fees.\n\t *\n\t * @param inputs - Includes `coinInType`, `coinInAmount`, and `coinOutType`.\n\t * @returns A bigint representing how many output coins you'd get.\n\t * @throws Error if the trade amount is too large relative to the pool balance.\n\t *\n\t * @example\n\t * ```typescript\n\t * const amountOut = pool.getTradeAmountOut({\n\t * coinInType: \"0x<coinA>\",\n\t * coinInAmount: BigInt(1000000),\n\t * coinOutType: \"0x<coinB>\",\n\t * });\n\t * ```\n\t */\n\tpublic getTradeAmountOut = (inputs: {\n\t\tcoinInType: CoinType;\n\t\tcoinInAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\treferral?: boolean;\n\t}): Balance => {\n\t\tconst pool = Helpers.deepCopy(this.pool);\n\t\tconst coinInPoolBalance = pool.coins[inputs.coinInType].balance;\n\t\tconst coinOutPoolBalance = pool.coins[inputs.coinOutType].balance;\n\n\t\tconst coinInAmountWithFees = this.getAmountWithDAOFee({\n\t\t\tamount: Pools.getAmountWithProtocolFees({\n\t\t\t\tamount: inputs.coinInAmount,\n\t\t\t}),\n\t\t});\n\n\t\tif (\n\t\t\tNumber(coinInAmountWithFees) / Number(coinInPoolBalance) >=\n\t\t\tPools.constants.bounds.maxTradePercentageOfPoolBalance -\n\t\t\t\tPool.constants.percentageBoundsMarginOfError\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"coinInAmountWithFees / coinInPoolBalance >= maxTradePercentageOfPoolBalance\"\n\t\t\t);\n\n\t\tconst coinOutAmount = CmmmCalculations.calcOutGivenIn(\n\t\t\tpool,\n\t\t\tinputs.coinInType,\n\t\t\tinputs.coinOutType,\n\t\t\tcoinInAmountWithFees\n\t\t);\n\n\t\tif (coinOutAmount <= 0) throw new Error(\"coinOutAmount <= 0\");\n\n\t\tif (\n\t\t\tNumber(coinOutAmount) / Number(coinOutPoolBalance) >=\n\t\t\tPools.constants.bounds.maxTradePercentageOfPoolBalance -\n\t\t\t\tPool.constants.percentageBoundsMarginOfError\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"coinOutAmount / coinOutPoolBalance >= maxTradePercentageOfPoolBalance\"\n\t\t\t);\n\n\t\treturn coinOutAmount;\n\t};\n\n\t/**\n\t * Calculates how much input coin is required to obtain a certain output coin amount\n\t * from this pool, factoring in fees.\n\t *\n\t * @param inputs - Includes `coinInType`, desired `coinOutAmount`, and `coinOutType`.\n\t * @returns A bigint representing the needed input amount.\n\t * @throws Error if the desired output is too large relative to pool balances.\n\t *\n\t * @example\n\t * ```typescript\n\t * const amountIn = pool.getTradeAmountIn({\n\t * coinInType: \"0x<coinA>\",\n\t * coinOutAmount: BigInt(1000000),\n\t * coinOutType: \"0x<coinB>\"\n\t * });\n\t * ```\n\t */\n\tpublic getTradeAmountIn = (inputs: {\n\t\tcoinInType: CoinType;\n\t\tcoinOutAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\treferral?: boolean;\n\t}): Balance => {\n\t\tconst pool = Helpers.deepCopy(this.pool);\n\t\tconst coinInPoolBalance = pool.coins[inputs.coinInType].balance;\n\t\tconst coinOutPoolBalance = pool.coins[inputs.coinOutType].balance;\n\n\t\tif (\n\t\t\tNumber(inputs.coinOutAmount) / Number(coinOutPoolBalance) >=\n\t\t\tPools.constants.bounds.maxTradePercentageOfPoolBalance -\n\t\t\t\tPool.constants.percentageBoundsMarginOfError\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"coinOutAmount / coinOutPoolBalance >= maxTradePercentageOfPoolBalance\"\n\t\t\t);\n\n\t\tconst coinInAmount = CmmmCalculations.calcInGivenOut(\n\t\t\tpool,\n\t\t\tinputs.coinInType,\n\t\t\tinputs.coinOutType,\n\t\t\tinputs.coinOutAmount\n\t\t);\n\n\t\tif (coinInAmount <= 0) throw new Error(\"coinInAmount <= 0\");\n\n\t\tif (\n\t\t\tNumber(coinInAmount) / Number(coinInPoolBalance) >=\n\t\t\tPools.constants.bounds.maxTradePercentageOfPoolBalance -\n\t\t\t\tPool.constants.percentageBoundsMarginOfError\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t\"coinInAmount / coinInPoolBalance >= maxTradePercentageOfPoolBalance\"\n\t\t\t);\n\n\t\tconst coinInAmountWithoutFees = this.getAmountWithoutDAOFee({\n\t\t\tamount: Pools.getAmountWithoutProtocolFees({\n\t\t\t\tamount: coinInAmount,\n\t\t\t}),\n\t\t});\n\n\t\treturn coinInAmountWithoutFees;\n\t};\n\n\t/**\n\t * Calculates how many LP tokens you receive for providing liquidity\n\t * in specific coin amounts. Also returns a ratio for reference.\n\t *\n\t * @param inputs - Contains the amounts in for each coin in the pool.\n\t * @returns An object with `lpAmountOut` and `lpRatio`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const depositCalc = pool.getDepositLpAmountOut({\n\t * amountsIn: { \"0x<coinA>\": BigInt(1000000), \"0x<coinB>\": BigInt(500000) },\n\t * });\n\t * console.log(depositCalc.lpAmountOut, depositCalc.lpRatio);\n\t * ```\n\t */\n\tpublic getDepositLpAmountOut = (inputs: {\n\t\tamountsIn: CoinsToBalance;\n\t\treferral?: boolean;\n\t}): {\n\t\tlpAmountOut: Balance;\n\t\tlpRatio: number;\n\t} => {\n\t\tconst calcedLpRatio = CmmmCalculations.calcDepositFixedAmounts(\n\t\t\tthis.pool,\n\t\t\tObject.entries(inputs.amountsIn).reduce(\n\t\t\t\t(acc, [coin, amount]) => ({\n\t\t\t\t\t...acc,\n\t\t\t\t\t[coin]: this.getAmountWithDAOFee({ amount }),\n\t\t\t\t}),\n\t\t\t\t{}\n\t\t\t)\n\t\t);\n\n\t\tif (calcedLpRatio >= Casting.Fixed.fixedOneB)\n\t\t\tthrow new Error(\"lpRatio >= 1\");\n\n\t\tconst lpRatio = Casting.bigIntToFixedNumber(calcedLpRatio);\n\t\tconst lpAmountOut = BigInt(\n\t\t\tMath.floor(Number(this.pool.lpCoinSupply) * (1 / lpRatio - 1))\n\t\t);\n\n\t\treturn {\n\t\t\tlpAmountOut,\n\t\t\tlpRatio,\n\t\t};\n\t};\n\n\t/**\n\t * Calculates how many coins a user will receive when withdrawing a specific ratio or LP amount.\n\t * This method is used in multi-coin withdrawals where you specify how much of each coin you want.\n\t *\n\t * @param inputs - The LP ratio and an object specifying direction amounts for each coin.\n\t * @returns A `CoinsToBalance` object with final amounts out, factoring in DAO fees.\n\t *\n\t * @example\n\t * ```typescript\n\t * const outAmounts = pool.getWithdrawAmountsOut({\n\t * lpRatio: 0.1,\n\t * amountsOutDirection: { \"0x<coinA>\": BigInt(500000) },\n\t * });\n\t * console.log(outAmounts);\n\t * ```\n\t */\n\tpublic getWithdrawAmountsOut = (inputs: {\n\t\tlpRatio: number;\n\t\tamountsOutDirection: CoinsToBalance;\n\t\treferral?: boolean;\n\t}): CoinsToBalance => {\n\t\tconst amountsOut = CmmmCalculations.calcWithdrawFlpAmountsOut(\n\t\t\tthis.pool,\n\t\t\tinputs.amountsOutDirection,\n\t\t\tinputs.lpRatio\n\t\t);\n\n\t\tfor (const coin of Object.keys(amountsOut)) {\n\t\t\tif (\n\t\t\t\t!(coin in inputs.amountsOutDirection) ||\n\t\t\t\tinputs.amountsOutDirection[coin] <= BigInt(0)\n\t\t\t)\n\t\t\t\tcontinue;\n\n\t\t\tconst amountOut = amountsOut[coin];\n\t\t\tif (amountOut <= 0) {\n\t\t\t\tthrow new Error(`amountsOut[${coin}] <= 0`);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tNumber(amountOut) / Number(this.pool.coins[coin].balance) >=\n\t\t\t\tPools.constants.bounds.maxWithdrawPercentageOfPoolBalance\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"coinOutAmount / coinOutPoolBalance >= maxWithdrawPercentageOfPoolBalance\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tamountsOut[coin] = this.getAmountWithDAOFee({ amount: amountOut });\n\t\t}\n\n\t\treturn amountsOut;\n\t};\n\n\t/**\n\t * A simplified multi-coin withdraw approach: calculates all outputs by proportion of the\n\t * user's LP share among selected coin types. Useful for approximate or \"blind\" all-coin out logic.\n\t *\n\t * @param inputs - Contains the `lpCoinAmountIn` to burn, and which coin types to receive.\n\t * @returns A record mapping coin type => final amounts out.\n\t */\n\tpublic getWithdrawAmountsOutSimple = (inputs: {\n\t\tlpCoinAmountIn: Balance;\n\t\tcoinTypesOut: CoinType[];\n\t\treferral?: boolean;\n\t}): CoinsToBalance => {\n\t\tconst { lpCoinAmountIn, coinTypesOut, referral } = inputs;\n\n\t\tconst lpCoinSupply = this.pool.lpCoinSupply;\n\n\t\tlet withdrawAmountsEstimates: CoinsToBalance = {};\n\t\tcoinTypesOut.forEach((poolCoin) => {\n\t\t\tconst poolCoinAmountInPool =\n\t\t\t\tthis.pool.coins[Helpers.addLeadingZeroesToType(poolCoin)]\n\t\t\t\t\t.balance;\n\n\t\t\tconst poolCoinAmount =\n\t\t\t\tNumber(poolCoinAmountInPool) *\n\t\t\t\t(Number(lpCoinAmountIn) / Number(lpCoinSupply));\n\n\t\t\twithdrawAmountsEstimates[Helpers.addLeadingZeroesToType(poolCoin)] =\n\t\t\t\tBigInt(Math.floor(poolCoinAmount));\n\t\t});\n\n\t\tconst lpRatio = this.getMultiCoinWithdrawLpRatio({\n\t\t\tlpCoinAmountIn,\n\t\t});\n\t\tconst amountsOut = this.getWithdrawAmountsOut({\n\t\t\tlpRatio,\n\t\t\tamountsOutDirection: withdrawAmountsEstimates,\n\t\t\treferral,\n\t\t});\n\n\t\tfor (const coin of Object.keys(amountsOut)) {\n\t\t\tif (\n\t\t\t\t!coinTypesOut\n\t\t\t\t\t.map((coinOut) => Helpers.addLeadingZeroesToType(coinOut))\n\t\t\t\t\t.includes(coin)\n\t\t\t)\n\t\t\t\tcontinue;\n\n\t\t\tconst amountOut = amountsOut[coin];\n\t\t\tif (amountOut <= BigInt(0))\n\t\t\t\tthrow new Error(`amountsOut[${coin}] <= 0 `);\n\n\t\t\tif (\n\t\t\t\tamountOut / this.pool.coins[coin].balance >=\n\t\t\t\tPools.constants.bounds.maxWithdrawPercentageOfPoolBalance\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"coinOutAmount / coinOutPoolBalance >= maxWithdrawPercentageOfPoolBalance\"\n\t\t\t\t);\n\n\t\t\tamountsOut[coin] = this.getAmountWithDAOFee({\n\t\t\t\tamount: amountOut,\n\t\t\t});\n\t\t}\n\n\t\treturn amountsOut;\n\t};\n\n\t/**\n\t * Calculates how many coins you get when withdrawing **all** coin types from the pool,\n\t * given a ratio. This is typically used for proportionate withdrawal.\n\t *\n\t * @param inputs - Includes `lpRatio`, the portion of your LP to burn (0 < ratio < 1).\n\t * @returns A record of coin type => amounts out, after factoring in any fees.\n\t *\n\t * @example\n\t * ```typescript\n\t * const allOut = pool.getAllCoinWithdrawAmountsOut({ lpRatio: 0.1 });\n\t * console.log(allOut); // amounts for each coin\n\t * ```\n\t */\n\tpublic getAllCoinWithdrawAmountsOut = (inputs: {\n\t\tlpRatio: number;\n\t\treferral?: boolean;\n\t}): CoinsToBalance => {\n\t\tif (inputs.lpRatio >= 1) throw new Error(\"lpRatio >= 1\");\n\n\t\tconst amountsOut: CoinsToBalance = Object.entries(\n\t\t\tthis.pool.coins\n\t\t).reduce((acc, [coin, info]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[coin]: this.getAmountWithDAOFee({\n\t\t\t\t\tamount: BigInt(\n\t\t\t\t\t\tMath.floor(Number(info.balance) * inputs.lpRatio)\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t};\n\t\t}, {});\n\n\t\treturn amountsOut;\n\t};\n\n\t/**\n\t * For multi-coin withdraw, calculates the ratio of how much LP you are burning\n\t * relative to the total supply. e.g. if user burns 100 of 1000 supply => ratio 0.1.\n\t *\n\t * @param inputs - Contains the `lpCoinAmountIn` to burn.\n\t * @returns A float ratio (0 < ratio < 1).\n\t */\n\tpublic getMultiCoinWithdrawLpRatio = (inputs: {\n\t\tlpCoinAmountIn: bigint;\n\t}): number =>\n\t\tNumber(this.pool.lpCoinSupply - inputs.lpCoinAmountIn) /\n\t\tNumber(this.pool.lpCoinSupply);\n\n\t/**\n\t * For an all-coin withdraw, calculates the ratio of how much LP is burned\n\t * relative to total supply. e.g. if user burns 50 of 200 supply => ratio 0.25.\n\t *\n\t * @param inputs - Contains the `lpCoinAmountIn`.\n\t * @returns A float ratio, typically 0 < ratio < 1.\n\t */\n\tpublic getAllCoinWithdrawLpRatio = (inputs: {\n\t\tlpCoinAmountIn: bigint;\n\t}): number =>\n\t\tNumber(inputs.lpCoinAmountIn) / Number(this.pool.lpCoinSupply);\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\t/**\n\t * Returns an array of coin types in ascending lexicographic order\n\t * for the coins contained in this pool.\n\t *\n\t * @returns An array of coin type strings.\n\t */\n\tpublic coins = (): CoinType[] => {\n\t\treturn Object.keys(this.pool.coins).sort((a, b) => a.localeCompare(b));\n\t};\n\n\t/**\n\t * Returns an array of `PoolCoin` objects, one for each coin in this pool,\n\t * sorted lexicographically by coin type.\n\t *\n\t * @returns An array of `PoolCoin`.\n\t */\n\tpublic poolCoins = (): PoolCoin[] => {\n\t\treturn Object.entries(this.pool.coins)\n\t\t\t.sort((a, b) => a[0].localeCompare(b[0]))\n\t\t\t.map((data) => data[1]);\n\t};\n\n\t/**\n\t * Returns an array of `[CoinType, PoolCoin]` pairs, sorted by coin type.\n\t *\n\t * @returns An array of coin-type => `PoolCoin` pairs.\n\t */\n\tpublic poolCoinEntries = (): [CoinType, PoolCoin][] => {\n\t\treturn Object.entries(this.pool.coins).sort((a, b) =>\n\t\t\ta[0].localeCompare(b[0])\n\t\t);\n\t};\n\n\t/**\n\t * Returns the current DAO fee percentage, if configured (0 < fee <= 100%).\n\t *\n\t * @returns A decimal fraction representing the fee (e.g., 0.01 = 1%) or `undefined`.\n\t */\n\tpublic daoFeePercentage = (): Percentage | undefined => {\n\t\treturn this.pool.daoFeePoolObject\n\t\t\t? Casting.bpsToPercentage(this.pool.daoFeePoolObject.feeBps)\n\t\t\t: undefined;\n\t};\n\n\t/**\n\t * Returns the Sui address that currently receives the DAO fee portion of\n\t * pool trades, or `undefined` if no DAO fee is configured.\n\t *\n\t * @returns The DAO fee recipient address.\n\t */\n\tpublic daoFeeRecipient = (): SuiAddress | undefined => {\n\t\treturn this.pool.daoFeePoolObject?.feeRecipient;\n\t};\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t/**\n\t * Applies the DAO fee (if present) to a given `amount`, effectively reducing\n\t * that amount by the fee fraction. e.g. if fee is 2%, it returns 98% of the input.\n\t *\n\t * @param inputs - Contains `amount` as a bigint.\n\t * @returns The post-fee amount as a bigint.\n\t */\n\tprivate getAmountWithDAOFee = (inputs: { amount: Balance }) => {\n\t\tconst daoFeePercentage = this.daoFeePercentage();\n\t\tif (!daoFeePercentage) return inputs.amount;\n\n\t\treturn BigInt(\n\t\t\tMath.floor(Number(inputs.amount) * (1 - daoFeePercentage))\n\t\t);\n\t};\n\n\t/**\n\t * The inverse operation of `getAmountWithDAOFee`, used in internal calculations\n\t * when we need to back out how much input was needed prior to the fee cut.\n\t *\n\t * @param inputs - Contains `amount` as a bigint.\n\t * @returns The pre-fee amount as a bigint.\n\t */\n\tprivate getAmountWithoutDAOFee = (inputs: { amount: Balance }) => {\n\t\tconst daoFeePercentage = this.daoFeePercentage();\n\t\tif (!daoFeePercentage) return inputs.amount;\n\n\t\treturn BigInt(\n\t\t\tMath.floor(Number(inputs.amount) * (1 / (1 - daoFeePercentage)))\n\t\t);\n\t};\n\n\t/**\n\t * Provides an instance of the Pools provider from `AftermathApi`.\n\t * Throws an error if not defined.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Pools();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import type { AftermathApi } from \"../../general/providers\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { FixedUtils } from \"../../general/utils/fixedUtils\";\nimport { Helpers } from \"../../general/utils/helpers\";\nimport { Coin } from \"../../packages/coin/coin\";\nimport type {\n ApiCreatePoolBody,\n ApiIndexerEventsBody,\n ApiPoolObjectIdForLpCoinTypeBody,\n ApiPoolsOwnedDaoFeePoolOwnerCapsBody,\n ApiPoolsStatsBody,\n ApiPublishLpCoinBody,\n Balance,\n CallerConfig,\n CoinType,\n ObjectId,\n PoolDepositEvent,\n PoolLpInfo,\n PoolObject,\n PoolStats,\n PoolWithdrawEvent,\n Slippage,\n SuiAddress,\n} from \"../../types\";\nimport { Pool } from \"./pool\";\n\n/**\n * The `Pools` class provides a high-level interface for interacting with\n * Aftermath Finance liquidity pools. It allows fetching individual or multiple\n * pools, managing liquidity pool tokens (LP tokens), and creating new pools\n * if you have the required privileges.\n *\n * @example\n * ```typescript\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // initialize provider\n *\n * const pools = afSdk.Pools();\n *\n * // Fetch a single pool\n * const pool = await pools.getPool({ objectId: \"0x<poolId>\" });\n *\n * // Fetch multiple pools\n * const poolArray = await pools.getPools({ objectIds: [\"0x<id1>\", \"0x<id2>\"] });\n * ```\n */\nexport class Pools extends Caller {\n // =========================================================================\n // Constants\n // =========================================================================\n\n /**\n * Static constants relevant to the pool logic, such as protocol fees,\n * referral percentages, and bounds for trading/withdrawal percentages.\n */\n public static readonly constants = {\n /**\n * Protocol fee structure: `totalProtocol` is the fraction of trades\n * that is taken as a fee, which is split among `treasury`, `insuranceFund`,\n * and `devWallet` in the given proportions.\n */\n feePercentages: {\n /**\n * The total fraction (as a decimal) of trades charged by the protocol.\n * e.g., 0.00005 => 0.005%.\n */\n totalProtocol: 0.000_05,\n /**\n * The fraction of `totalProtocol` allocated to the treasury.\n */\n treasury: 0.5,\n /**\n * The fraction of `totalProtocol` allocated to the insurance fund.\n */\n insuranceFund: 0.3,\n /**\n * The fraction of `totalProtocol` allocated to the dev wallet.\n */\n devWallet: 0.2,\n },\n /**\n * Referral fee structures, applying a discount/rebate to the user and\n * referrer, taken from the treasury portion of protocol fees.\n */\n referralPercentages: {\n /**\n * The fraction of the treasury portion that discounts the user's fee.\n */\n discount: 0.05,\n /**\n * The fraction of the treasury portion that acts as a rebate to the referrer.\n */\n rebate: 0.05,\n },\n /**\n * Various bounds used to prevent extreme trades or invalid pool configurations.\n */\n bounds: {\n /**\n * Maximum number of distinct coins allowed in a single pool.\n */\n maxCoinsInPool: 8,\n /**\n * Maximum fraction (decimal) of a pool's balance that can be traded at once.\n */\n maxTradePercentageOfPoolBalance: 0.3,\n /**\n * Maximum fraction (decimal) of a pool's balance that can be withdrawn at once.\n */\n maxWithdrawPercentageOfPoolBalance: 0.3,\n /**\n * Minimum and maximum swap fees (0.01% to 10%).\n */\n minSwapFee: 0.0001,\n maxSwapFee: 0.1,\n /**\n * Minimum and maximum coin weight for weighted pools (1% to 99%).\n */\n minWeight: 0.01,\n maxWeight: 0.99,\n /**\n * Minimum and maximum DAO fee (0% to 100%).\n */\n minDaoFee: 0,\n maxDaoFee: 1,\n },\n /**\n * Default parameter(s) used in the absence of explicit user or code settings.\n */\n defaults: {\n /**\n * Default decimals for LP coins if none are specified.\n */\n lpCoinDecimals: 9,\n },\n };\n\n // =========================================================================\n // Constructor\n // =========================================================================\n\n /**\n * Creates a new `Pools` instance for querying and managing AMM pools on Aftermath.\n *\n * @param config - Optional configuration object specifying network or access token.\n * @param Provider - An optional `AftermathApi` instance providing advanced transaction building.\n */\n constructor(\n config?: CallerConfig,\n public readonly Provider?: AftermathApi\n ) {\n super(config, \"pools\");\n }\n\n // =========================================================================\n // Class Objects\n // =========================================================================\n\n // =========================================================================\n // Pool Class\n // =========================================================================\n\n /**\n * Fetches a single pool by its on-chain `objectId` and returns a new `Pool` instance.\n *\n * @param inputs - An object containing `objectId`.\n * @returns A promise that resolves to a `Pool` instance.\n *\n * @example\n * ```typescript\n * const pool = await pools.getPool({ objectId: \"0x<poolId>\" });\n * console.log(pool.pool.lpCoinType, pool.pool.name);\n * ```\n */\n public async getPool(inputs: { objectId: ObjectId }) {\n const pool = await this.fetchApi<PoolObject>(inputs.objectId);\n return new Pool(pool, this.config, this.Provider);\n }\n\n /**\n * Fetches multiple pools by their on-chain `objectIds` and returns an array of `Pool` instances.\n *\n * @param inputs - An object containing an array of `objectIds`.\n * @returns A promise that resolves to an array of `Pool` instances.\n *\n * @example\n * ```typescript\n * const poolArray = await pools.getPools({ objectIds: [\"0x<id1>\", \"0x<id2>\"] });\n * console.log(poolArray.length);\n * ```\n */\n public async getPools(inputs: { objectIds: ObjectId[] }) {\n const pools = await this.fetchApi<\n PoolObject[],\n {\n poolIds: ObjectId[];\n }\n >(\"\", {\n poolIds: inputs.objectIds,\n });\n return pools.map((pool) => new Pool(pool, this.config, this.Provider));\n }\n\n /**\n * Retrieves all pools recognized by the Aftermath API, returning an array of `Pool` objects.\n *\n * @returns An array of `Pool` instances.\n *\n * @example\n * ```typescript\n * const allPools = await pools.getAllPools();\n * console.log(allPools.map(p => p.pool.name));\n * ```\n */\n public async getAllPools() {\n const pools: PoolObject[] = await this.fetchApi(\"\", {});\n return pools.map((pool) => new Pool(pool, this.config, this.Provider));\n }\n\n /**\n * Fetches information about all owned LP coins for a given wallet address.\n * This indicates the user's liquidity positions across multiple pools.\n *\n * @param inputs - An object containing the `walletAddress`.\n * @returns A `PoolLpInfo` object summarizing the user's LP balances.\n *\n * @example\n * ```typescript\n * const lpCoins = await pools.getOwnedLpCoins({ walletAddress: \"0x<address>\" });\n * console.log(lpCoins);\n * ```\n */\n public async getOwnedLpCoins(inputs: {\n walletAddress: SuiAddress;\n }): Promise<PoolLpInfo> {\n return this.fetchApi(\"owned-lp-coins\", inputs);\n }\n\n // =========================================================================\n // Transactions\n // =========================================================================\n\n /**\n * Constructs or fetches a transaction to publish a new LP coin package,\n * typically used by advanced users or devs establishing new liquidity pools.\n *\n * @param inputs - Includes the user `walletAddress` and the `lpCoinDecimals`.\n * @returns A transaction object (or data) that can be signed and published to Sui.\n *\n * @example\n * ```typescript\n * const publishTx = await pools.getPublishLpCoinTransaction({\n * walletAddress: \"0x<address>\",\n * lpCoinDecimals: 9\n * });\n * ```\n */\n public async getPublishLpCoinTransaction(inputs: ApiPublishLpCoinBody) {\n return this.useProvider().buildPublishLpCoinTx(inputs);\n }\n\n /**\n * Constructs a transaction to create a brand new pool on-chain, given coin types,\n * initial weights, fees, and possible DAO fee info.\n *\n * @param inputs - The body describing how to form the new pool.\n * @returns A transaction object that can be signed and executed.\n *\n * @example\n * ```typescript\n * const createPoolTx = await pools.getCreatePoolTransaction({\n * walletAddress: \"0x<address>\",\n * lpCoinType: \"0x<lpCoin>\",\n * lpCoinMetadata: {\n * name: \"MyPool LP\",\n * symbol: \"MYPLP\"\n * },\n * coinsInfo: [\n * {\n * coinType: \"0x<coinA>\",\n * weight: 0.5,\n * decimals: 9,\n * tradeFeeIn: 0.003,\n * initialDeposit: 1_000_000_000n\n * },\n * // ...\n * ],\n * poolName: \"My Weighted Pool\",\n * createPoolCapId: \"0x<capId>\",\n * respectDecimals: true,\n * });\n * ```\n */\n public async getCreatePoolTransaction(inputs: ApiCreatePoolBody) {\n return this.fetchApiTransaction(\"transactions/create-pool\", inputs);\n }\n\n // =========================================================================\n // Inspections\n // =========================================================================\n\n /**\n * Retrieves the on-chain pool object ID corresponding to a specific LP coin type.\n *\n * @param inputs - Contains the `lpCoinType` string.\n * @returns The pool object ID if it exists.\n *\n * @example\n * ```typescript\n * const poolId = await pools.getPoolObjectIdForLpCoinType({\n * lpCoinType: \"0x<lpCoinType>\"\n * });\n * console.log(poolId);\n * ```\n */\n public getPoolObjectIdForLpCoinType = (inputs: { lpCoinType: CoinType }) => {\n return this.getPoolObjectIdsForLpCoinTypes({\n lpCoinTypes: [inputs.lpCoinType],\n });\n };\n\n /**\n * Retrieves multiple pool object IDs given an array of LP coin types.\n * If a given LP coin type has no associated pool, it might return `undefined`.\n *\n * @param inputs - Contains an array of `lpCoinTypes`.\n * @returns An array of `ObjectId | undefined` of matching length.\n *\n * @example\n * ```typescript\n * const poolIds = await pools.getPoolObjectIdsForLpCoinTypes({\n * lpCoinTypes: [\"0x<lpCoinA>\", \"0x<lpCoinB>\"]\n * });\n * console.log(poolIds);\n * ```\n */\n public async getPoolObjectIdsForLpCoinTypes(\n inputs: ApiPoolObjectIdForLpCoinTypeBody\n ): Promise<(ObjectId | undefined)[]> {\n return this.fetchApi<\n (ObjectId | undefined)[],\n ApiPoolObjectIdForLpCoinTypeBody\n >(\"pool-object-ids\", inputs);\n }\n\n /**\n * Checks if a given coin type is recognized as an LP coin.\n * Internally calls `getPoolObjectIdForLpCoinType`.\n *\n * @param inputs - Contains the `lpCoinType` to check.\n * @returns `true` if the coin is an LP token, `false` otherwise.\n */\n public isLpCoinType = async (inputs: {\n lpCoinType: CoinType;\n }): Promise<boolean> => {\n const result = await this.getPoolObjectIdForLpCoinType(inputs);\n return result.some((id) => id !== undefined);\n };\n\n /**\n * Retrieves the total volume across all pools in the last 24 hours.\n *\n * @returns A promise resolving to a numeric volume (e.g., in USD).\n *\n * @example\n * ```typescript\n * const totalVol24 = await pools.getTotalVolume24hrs();\n * console.log(\"Protocol-wide 24h volume:\", totalVol24);\n * ```\n */\n public getTotalVolume24hrs = async (): Promise<number> => {\n return this.fetchApi(\"volume-24hrs\");\n };\n\n /**\n * Retrieves the total value locked (TVL) across all or specific pool IDs.\n *\n * @param inputs - Optionally provide an array of specific `poolIds`. If omitted, returns global TVL.\n * @returns A promise resolving to a numeric TVL (e.g., in USD).\n *\n * @example\n * ```typescript\n * const allTvl = await pools.getTVL();\n * const subsetTvl = await pools.getTVL({ poolIds: [\"0x<id1>\", \"0x<id2>\"] });\n * ```\n */\n public async getTVL(inputs?: { poolIds?: ObjectId[] }): Promise<number> {\n return this.fetchApi(\"tvl\", inputs ?? {});\n }\n\n /**\n * Fetches an array of `PoolStats` objects for a given set of pools,\n * including volume, fees, TVL, and other metrics.\n *\n * @param inputs - Must include an array of `poolIds`.\n * @returns An array of `PoolStats` in matching order.\n *\n * @example\n * ```typescript\n * const stats = await pools.getPoolsStats({ poolIds: [\"0x<id1>\", \"0x<id2>\"] });\n * console.log(stats[0].volume, stats[1].tvl);\n * ```\n */\n public async getPoolsStats(inputs: ApiPoolsStatsBody): Promise<PoolStats[]> {\n return this.fetchApi(\"stats\", inputs);\n }\n\n /**\n * Returns all DAO fee pool owner capabilities owned by a particular user.\n * This is used to see which pools' DAO fees the user can update.\n *\n * @param inputs - An object with user `walletAddress`.\n * @returns Data about each `DaoFeePoolOwnerCapObject` the user owns.\n *\n * @example\n * ```typescript\n * const daoCaps = await pools.getOwnedDaoFeePoolOwnerCaps({\n * walletAddress: \"0x<address>\"\n * });\n * console.log(daoCaps);\n * ```\n */\n public async getOwnedDaoFeePoolOwnerCaps(\n inputs: ApiPoolsOwnedDaoFeePoolOwnerCapsBody\n ) {\n return this.useProvider().fetchOwnedDaoFeePoolOwnerCaps(inputs);\n }\n\n // =========================================================================\n // Events\n // =========================================================================\n\n /**\n * Fetches user-specific interaction events (deposits, withdrawals) across pools,\n * optionally with pagination.\n *\n * @param inputs - An object containing `walletAddress`, plus optional pagination (`cursor`, `limit`).\n * @returns An event set with a cursor for further queries if available.\n *\n * @example\n * ```typescript\n * const userEvents = await pools.getInteractionEvents({\n * walletAddress: \"0x...\",\n * limit: 10,\n * });\n * console.log(userEvents.events, userEvents.nextCursor);\n * ```\n */\n public async getInteractionEvents(\n inputs: ApiIndexerEventsBody & {\n walletAddress: SuiAddress;\n }\n ) {\n return this.fetchApiIndexerEvents<\n PoolDepositEvent | PoolWithdrawEvent,\n ApiIndexerEventsBody & {\n walletAddress: SuiAddress;\n }\n >(\"interaction-events-by-user\", inputs);\n }\n\n // =========================================================================\n // Fees\n // =========================================================================\n\n /**\n * Returns how much coin remains **after** applying the protocol fees\n * (and referral discount if `withReferral` is `true`).\n *\n * @param inputs - The original `amount` and an optional referral flag.\n * @returns The post-fee (net) amount as a bigint.\n *\n * @example\n * ```typescript\n * const netAmount = Pools.getAmountWithProtocolFees({ amount: 1_000_000n });\n * ```\n */\n public static getAmountWithProtocolFees = (inputs: {\n amount: Balance;\n withReferral?: boolean;\n }) => {\n const referralDiscount = inputs.withReferral\n ? this.constants.feePercentages.totalProtocol *\n this.constants.feePercentages.treasury *\n this.constants.referralPercentages.discount\n : 0;\n\n return BigInt(\n Math.floor(\n Number(inputs.amount) *\n (1 - (this.constants.feePercentages.totalProtocol - referralDiscount))\n )\n );\n };\n\n /**\n * The inverse calculation: given a net amount (post-fees), figure out\n * the original gross amount. Used when we already have fees subtracted\n * but need to restore an original quantity.\n *\n * @param inputs - The net `amount` after fees, plus an optional referral flag.\n * @returns The original gross amount as a bigint.\n */\n public static getAmountWithoutProtocolFees = (inputs: {\n amount: Balance;\n withReferral?: boolean;\n }) => {\n const referralDiscount = inputs.withReferral\n ? this.constants.feePercentages.totalProtocol *\n this.constants.feePercentages.treasury *\n this.constants.referralPercentages.discount\n : 0;\n\n return BigInt(\n Math.floor(\n Number(inputs.amount) *\n (1 /\n (1 -\n (this.constants.feePercentages.totalProtocol - referralDiscount)))\n )\n );\n };\n\n /**\n * A helper to transform a user-provided slippage fraction, e.g. 0.01,\n * into a 1 - slippage format, if needed for certain math operations.\n *\n * @param slippage - The decimal fraction of slippage tolerance, e.g. 0.01 => 1%.\n * @returns A big integer representing `1 - slippage` in a fixed context.\n */\n public static normalizeInvertSlippage = (slippage: Slippage) =>\n FixedUtils.directUncast(1 - slippage);\n\n // =========================================================================\n // Display\n // =========================================================================\n\n /**\n * Produces a user-friendly string for an LP coin type, e.g. \"Sui Coin LP\"\n * by analyzing the coin type symbol. Typically used in UIs or logs.\n *\n * @param lpCoinType - The coin type for the LP token.\n * @returns A string representation for display, e.g. \"Af_lp_abc\" => \"Abc LP\".\n */\n public static displayLpCoinType = (lpCoinType: CoinType): string =>\n Coin.getCoinTypeSymbol(lpCoinType)\n .toLowerCase()\n .replace(\"af_lp_\", \"\")\n .split(\"_\")\n .map((word) => Helpers.capitalizeOnlyFirstLetter(word))\n .join(\" \") + \" LP\";\n\n // =========================================================================\n // Helpers\n // =========================================================================\n\n /**\n * A quick heuristic check to see if the given `lpCoinType` string\n * might represent an Aftermath LP token. This is not a full on-chain validation.\n *\n * @param inputs - An object containing `lpCoinType`.\n * @returns `true` if it matches a known pattern; otherwise `false`.\n */\n public static isPossibleLpCoinType = (inputs: { lpCoinType: CoinType }) => {\n const { lpCoinType } = inputs;\n return (\n lpCoinType.split(\"::\").length === 3 &&\n lpCoinType.split(\"::\")[1].includes(\"af_lp\") &&\n lpCoinType.split(\"::\")[2].includes(\"AF_LP\")\n );\n };\n\n // =========================================================================\n // Private Helpers\n // =========================================================================\n\n /**\n * Provides a typed reference to the `Pools` part of the `AftermathApi`,\n * throwing an error if not defined.\n */\n private useProvider = () => {\n const provider = this.Provider?.Pools();\n if (!provider) {\n throw new Error(\"missing AftermathApi Provider\");\n }\n return provider;\n };\n}\n","export * from \"./pool\";\nexport * from \"./pools\";\n","import {\n\tSuiNetwork,\n\tNftAmmMarketObject,\n\tApiNftAmmDepositBody,\n\tBalance,\n\tApiNftAmmWithdrawBody,\n\tApiNftAmmBuyBody,\n\tNft,\n\tDynamicFieldObjectsWithCursor,\n\tApiDynamicFieldsBody,\n\tApiNftAmmSellBody,\n\tUrl,\n\tObjectId,\n\tCallerConfig,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { Pool } from \"../pools\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Transaction } from \"@mysten/sui/transactions\";\n\nexport class NftAmmMarket extends Caller {\n\t// =========================================================================\n\t// Private Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {};\n\n\t// =========================================================================\n\t// Public Class Members\n\t// =========================================================================\n\n\tpublic pool: Pool;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tpublic readonly market: NftAmmMarketObject,\n\t\tconfig?: CallerConfig,\n\t\tprivate readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, `nft-amm/markets/${market.objectId}`);\n\t\tthis.market = market;\n\t\tthis.pool = new Pool(market.pool, config);\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic async getNfts(inputs: {\n\t\tcursor?: ObjectId;\n\t\tlimit?: number;\n\t}): Promise<DynamicFieldObjectsWithCursor<Nft>> {\n\t\tconst { cursor, limit } = inputs;\n\t\treturn this.useProvider().fetchNftsInMarketTable({\n\t\t\tmarketTableObjectId: this.market.objectId,\n\t\t\tlimit: limit ?? 25,\n\t\t\tcursor,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getBuyTransaction(\n\t\tinputs: ApiNftAmmBuyBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildBuyTx({\n\t\t\t...inputs,\n\t\t\tmarket: this,\n\t\t});\n\t}\n\n\tpublic async getSellTransaction(\n\t\tinputs: ApiNftAmmSellBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildSellTx({\n\t\t\t...inputs,\n\t\t\tmarket: this,\n\t\t});\n\t}\n\n\tpublic async getDepositTransaction(\n\t\tinputs: ApiNftAmmDepositBody\n\t): Promise<Transaction> {\n\t\tconst { nftObjectIds: nfts, ...otherInputs } = inputs;\n\t\treturn this.useProvider().fetchBuildDepositTx({\n\t\t\t...otherInputs,\n\t\t\tnfts,\n\t\t\tmarket: this,\n\t\t});\n\t}\n\n\tpublic async getWithdrawTransaction(\n\t\tinputs: ApiNftAmmWithdrawBody\n\t): Promise<Transaction> {\n\t\treturn this.useProvider().fetchBuildWithdrawTx({\n\t\t\t...inputs,\n\t\t\tmarket: this,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\tpublic getNftSpotPriceInAssetCoin = (inputs?: {\n\t\twithFees: boolean;\n\t}): Balance => {\n\t\tconst assetToFractionalizedSpotPrice =\n\t\t\tthis.getAssetCoinToFractionalizeCoinSpotPrice(inputs);\n\n\t\treturn BigInt(\n\t\t\tassetToFractionalizedSpotPrice *\n\t\t\t\tNumber(this.market.fractionalizedCoinAmount)\n\t\t);\n\t};\n\n\tpublic getFractionalizedCoinToAssetCoinSpotPrice = (inputs?: {\n\t\twithFees: boolean;\n\t}): number => {\n\t\treturn this.pool.getSpotPrice({\n\t\t\tcoinInType: this.market.fractionalizedCoinType,\n\t\t\tcoinOutType: this.market.assetCoinType,\n\t\t\twithFees: inputs?.withFees,\n\t\t});\n\t};\n\n\tpublic getAssetCoinToFractionalizeCoinSpotPrice = (inputs?: {\n\t\twithFees: boolean;\n\t}): number => {\n\t\treturn this.pool.getSpotPrice({\n\t\t\tcoinInType: this.market.assetCoinType,\n\t\t\tcoinOutType: this.market.fractionalizedCoinType,\n\t\t\twithFees: inputs?.withFees,\n\t\t});\n\t};\n\n\tpublic getBuyAssetCoinAmountIn = (inputs: {\n\t\tnftsCount: number;\n\t\treferral?: boolean;\n\t}): Balance => {\n\t\treturn this.pool.getTradeAmountIn({\n\t\t\tcoinOutAmount:\n\t\t\t\tBigInt(inputs.nftsCount) * this.market.fractionalizedCoinAmount,\n\t\t\tcoinInType: this.market.assetCoinType,\n\t\t\tcoinOutType: this.market.fractionalizedCoinType,\n\t\t\treferral: inputs.referral,\n\t\t});\n\t};\n\n\tpublic getSellAssetCoinAmountOut = (inputs: {\n\t\tnftsCount: number;\n\t\treferral?: boolean;\n\t}): Balance => {\n\t\treturn this.pool.getTradeAmountOut({\n\t\t\tcoinInAmount:\n\t\t\t\tBigInt(inputs.nftsCount) * this.market.fractionalizedCoinAmount,\n\t\t\tcoinInType: this.market.fractionalizedCoinType,\n\t\t\tcoinOutType: this.market.assetCoinType,\n\t\t\treferral: inputs.referral,\n\t\t});\n\t};\n\n\tpublic getDepositLpCoinAmountOut = (inputs: {\n\t\tassetCoinAmountIn: Balance;\n\t\treferral?: boolean;\n\t}): {\n\t\tlpAmountOut: Balance;\n\t\tlpRatio: number;\n\t} => {\n\t\treturn this.pool.getDepositLpAmountOut({\n\t\t\tamountsIn: {\n\t\t\t\t[this.market.assetCoinType]: inputs.assetCoinAmountIn,\n\t\t\t},\n\t\t\treferral: inputs.referral,\n\t\t});\n\t};\n\n\tpublic getWithdrawFractionalizedCoinAmountOut = (inputs: {\n\t\t// NOTE: do we need a better direction approximation here ?\n\t\tlpCoinAmount: Balance;\n\t\treferral?: boolean;\n\t}): Balance => {\n\t\tconst lpRatio = this.pool.getMultiCoinWithdrawLpRatio({\n\t\t\tlpCoinAmountIn: inputs.lpCoinAmount,\n\t\t});\n\n\t\tconst amountsOut = this.pool.getWithdrawAmountsOut({\n\t\t\tlpRatio,\n\t\t\tamountsOutDirection: {\n\t\t\t\t[this.market.fractionalizedCoinType]:\n\t\t\t\t\tthis.market.fractionalizedCoinAmount,\n\t\t\t},\n\t\t\treferral: inputs.referral,\n\t\t});\n\n\t\tconst fractionalizedCoinAmountOut = amountsOut[0];\n\t\treturn fractionalizedCoinAmountOut;\n\t};\n\n\tpublic getWithdrawNftsCountOut = (inputs: {\n\t\tlpCoinAmount: Balance;\n\t\treferral?: boolean;\n\t}): bigint => {\n\t\tconst fractionalizedCoinAmountOut =\n\t\t\tthis.getWithdrawFractionalizedCoinAmountOut(inputs);\n\t\tconst minNftsCountOut =\n\t\t\tfractionalizedCoinAmountOut / this.market.fractionalizedCoinAmount;\n\n\t\treturn minNftsCountOut;\n\t};\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.NftAmm();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import { AftermathApi } from \"../../general/providers\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tCallerConfig,\n\tNftAmmMarketObject,\n\tObjectId,\n\tSuiNetwork,\n\tUrl,\n} from \"../../types\";\nimport { NftAmmMarket } from \"./nftAmmMarket\";\n\nexport class NftAmm extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tpublic static readonly constants = {};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"nft-amm\");\n\t}\n\n\t// =========================================================================\n\t// Class Objects\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Market Class\n\t// =========================================================================\n\n\tpublic async getMarket(inputs: { objectId: ObjectId }) {\n\t\tconst market = await this.fetchApi<NftAmmMarketObject>(\n\t\t\t`markets/${inputs.objectId}`\n\t\t);\n\t\treturn new NftAmmMarket(market, this.config);\n\t}\n\n\tpublic async getMarkets(inputs: { objectIds: ObjectId[] }) {\n\t\tconst markets = await Promise.all(\n\t\t\tinputs.objectIds.map((objectId) => this.getMarket({ objectId }))\n\t\t);\n\t\treturn markets;\n\t}\n\n\tpublic async getAllMarkets() {\n\t\tconst markets = await this.fetchApi<NftAmmMarketObject[]>(\"markets\");\n\t\treturn markets.map((pool) => new NftAmmMarket(pool, this.config));\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// public async getNft(inputs: { objectId: ObjectId }): Promise<Nft> {\n\t// \treturn this.fetchApi(`nfts/${inputs.objectId}`);\n\t// }\n\n\t// public async getNfts(inputs: { objectIds: ObjectId[] }): Promise<Nft[]> {\n\t// \treturn Promise.all(\n\t// \t\tinputs.objectIds.map((objectId) => this.getNft({ objectId }))\n\t// \t);\n\t// }\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.NftAmm();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./nftAmm\";\n","import type { CoinDecimal } from \"../../types\";\nimport type { ObjectId, SuiAddress } from \"./generalTypes\";\n\n// =========================================================================\n// Name Only\n// =========================================================================\n\nexport type RpcEndpoint = string;\n\n// =========================================================================\n// All Addresses\n// =========================================================================\n\nexport interface ConfigAddresses {\n faucet?: FaucetAddresses;\n staking?: StakingAddresses;\n pools?: PoolsAddresses;\n daoFeePools?: DaoFeePoolsAddresses;\n suiFrens?: SuiFrensAddresses;\n nftAmm?: NftAmmAddresses;\n router?: RouterAddresses;\n referralVault?: ReferralVaultAddresses;\n perpetuals?: PerpetualsAddresses;\n perpetualsVaults?: PerpetualsVaultsAddresses;\n farms?: FarmsAddresses;\n dynamicGas?: DynamicGasAddresses;\n scallop?: ScallopAddresses;\n\n dca?: DcaAddresses;\n limitOrders?: LimitAddresses;\n sharedCustody?: SharedCustodyAddresses;\n nfts?: NftsAddresses;\n}\n\n// =========================================================================\n// Addresses By Package\n// =========================================================================\n\nexport interface FaucetAddresses {\n packages: {\n faucet: SuiAddress;\n suiFrensGenesisWrapper: SuiAddress;\n };\n objects: {\n faucet: ObjectId;\n suiFrensMint: ObjectId;\n };\n}\n\nexport interface StakingAddresses {\n packages: {\n lsd: SuiAddress;\n afsui: SuiAddress;\n events: SuiAddress;\n };\n objects: {\n stakedSuiVault: ObjectId;\n stakedSuiVaultState: ObjectId;\n safe: ObjectId;\n treasury: ObjectId;\n referralVault: ObjectId;\n validatorConfigsTable: ObjectId;\n aftermathValidator: ObjectId;\n };\n}\n\nexport interface PoolsAddresses {\n packages: {\n amm: SuiAddress;\n ammInterface: SuiAddress;\n events: SuiAddress;\n eventsV2: SuiAddress;\n };\n objects: {\n poolRegistry: ObjectId;\n protocolFeeVault: ObjectId;\n treasury: ObjectId;\n insuranceFund: ObjectId;\n lpCoinsTable: ObjectId;\n };\n other?: {\n createLpCoinPackageCompilations: Record<CoinDecimal, string>;\n };\n}\n\nexport interface DaoFeePoolsAddresses {\n packages: {\n amm: SuiAddress;\n events: SuiAddress;\n };\n objects: {\n version: ObjectId;\n };\n}\n\nexport interface SuiFrensAddresses {\n packages: {\n suiFrens: SuiAddress;\n suiFrensBullshark: SuiAddress;\n accessories: SuiAddress;\n suiFrensVault: SuiAddress;\n suiFrensVaultCapyLabsExtension: SuiAddress;\n };\n objects: {\n capyLabsApp: ObjectId;\n suiFrensVault: ObjectId;\n suiFrensVaultStateV1: ObjectId;\n suiFrensVaultStateV1MetadataTable: ObjectId;\n suiFrensVaultCapyLabsExtension: ObjectId;\n };\n}\n\nexport interface NftAmmAddresses {\n packages: {\n nftAmm: SuiAddress;\n };\n objects: {\n protocolFeeVault: ObjectId;\n treasury: ObjectId;\n insuranceFund: ObjectId;\n referralVault: ObjectId;\n };\n}\n\nexport interface RouterAddresses {\n packages: {\n utils: SuiAddress;\n };\n}\n\nexport interface ReferralVaultAddresses {\n packages: {\n referralVault: SuiAddress;\n };\n objects: {\n referralVault: ObjectId;\n };\n}\n\nexport interface PerpetualsAddresses {\n packages: {\n // perpetuals: SuiAddress;\n events: SuiAddress;\n };\n objects: {\n registry: ObjectId;\n };\n}\n\nexport interface PerpetualsVaultsAddresses {\n other: {\n createLpCoinPackageCompilation: string;\n };\n}\n\nexport interface FarmsAddresses {\n packages: {\n vaults: SuiAddress;\n vaultsInitial: SuiAddress;\n vaultsV2: SuiAddress;\n eventsV2: SuiAddress;\n };\n objects: {\n version: ObjectId;\n };\n}\n\nexport interface DynamicGasAddresses {\n sponsorAddress: SuiAddress;\n}\n\nexport interface ScallopAddresses {\n objects: {\n version: ObjectId;\n afSuiMarket: ObjectId;\n coinDecimalsRegistry: ObjectId;\n xOracle: ObjectId;\n };\n}\n\nexport interface DcaAddresses {\n packages: {\n dca: SuiAddress;\n events: SuiAddress;\n eventsV2: SuiAddress;\n };\n objects: {\n readonly config: ObjectId;\n };\n}\n\nexport interface LimitAddresses {\n packages: {\n limitOrders: SuiAddress;\n events: SuiAddress;\n };\n}\n\nexport interface SharedCustodyAddresses {\n address: ObjectId;\n publicKey: ObjectId;\n}\n\nexport interface NftsAddresses {\n packages: {\n mystenTransferPolicy: SuiAddress;\n };\n}\n","import type { Transaction } from \"@mysten/sui/transactions\";\nimport type {\n\tDynamicFieldInfo,\n\tEventId,\n\tSuiTransactionBlockResponse,\n} from \"@mysten/sui/jsonRpc\";\nimport { SuiNetwork } from \"./suiTypes\";\n\n/**\n * Represents a token or currency balance in the system, defined as a bigint.\n */\nexport type Balance = bigint;\n\n/**\n * Represents a fixed-point integer using a bigint. May be used for calculations requiring\n * precision (e.g., decimal-like math).\n */\nexport type IFixed = bigint;\nexport type SuiCheckpoint = bigint;\n\n/**\n * Represents a gas budget for transactions. Typically a raw `number`.\n */\nexport type GasBudget = number;\n\n/**\n * Represents a timestamp in milliseconds or seconds. Typically a raw `number`.\n */\nexport type Timestamp = number;\n\n/**\n * A single byte, typically expressed as a `number` from 0 to 255.\n */\nexport type Byte = number;\n\n/**\n * Defines the allowable slippage in a trading scenario, expressed as an unscaled percentage (e.g., 0.01 = 1%).\n */\nexport type Slippage = number;\n\n/**\n * Represents an unscaled percentage (e.g., 0.01 = 1%).\n */\nexport type Percentage = number;\n\n/**\n * Annual percentage rate (APR), expressed as a `number` (e.g., 0.01 = 1%).\n */\nexport type Apr = number;\n\n/**\n * Annual percentage yield (APY), expressed as a `number` (e.g., 0.01 = 1%).\n */\nexport type Apy = number;\n\n/**\n * Represents the version of an on-chain object, expressed as a `number`.\n */\nexport type ObjectVersion = number;\n\n/**\n * Represents an error code from a Move smart contract, typically a `number`.\n */\nexport type MoveErrorCode = number;\n\n/**\n * Represents a serialized transaction in a base64 or similar format.\n */\nexport type SerializedTransaction = string;\n\n/**\n * Represents raw transaction bytes in a base64 or similar format.\n */\nexport type TxBytes = string;\n\n/**\n * Represents a BigInt in string form, typically used for JSON serialization.\n */\nexport type BigIntAsString = string;\n\n/**\n * Represents a numeric value in string form, typically used for JSON serialization.\n */\nexport type NumberAsString = string;\n\n/**\n * Represents an IFixed value in string form, typically used for JSON serialization.\n */\nexport type IFixedAsString = string;\n\n/**\n * A key type used in certain contexts, typically a string (e.g., \"ed25519\", \"secp256k1\").\n */\nexport type KeyType = string;\n\n/**\n * Represents any string identifying an object type, such as \"0x2::sui::SUI\".\n */\nexport type AnyObjectType = string;\n\n/**\n * Represents the name of a Move module, e.g. \"Router\" or \"Coin\".\n */\nexport type ModuleName = string;\n\n/**\n * Represents the name of a Move function, e.g. \"swap\" or \"mint\".\n */\nexport type FunctionName = string;\n\n/**\n * Represents the ID of a published Move package on the Sui network, e.g. \"0x<package_id>\".\n */\nexport type PackageId = string;\n\n/**\n * Represents a color in a string format (e.g., \"#FFFFFF\" or \"blue\").\n */\nexport type Color = string;\n\n/**\n * Represents a URL in string format (e.g., \"https://example.com\").\n */\nexport type Url = string;\n\n/**\n * Represents a local resource URL (e.g., \"file://path/to/resource\").\n */\nexport type LocalUrl = string;\n\n/**\n * Represents a file path (e.g., \"/usr/local/bin\").\n */\nexport type FilePath = string;\n\n/**\n * Represents an on-chain object ID (e.g., \"0x<32-byte_hex>\").\n */\nexport type ObjectId = string;\n\n/**\n * Represents a Sui wallet address (e.g., \"0x<address>\").\n */\nexport type SuiAddress = string;\n\n/**\n * Represents a TransactionDigest from a Sui transaction, typically a hex-encoded string.\n */\nexport type TransactionDigest = string;\n\n/**\n * Represents a single byte in string form, usually hex-encoded (e.g., \"0xFF\").\n */\nexport type StringByte = string;\n\n/**\n * Represents an object's digest, typically a hex-encoded string.\n */\nexport type ObjectDigest = string;\n\n/**\n * Represents an IFixed type as an array of bytes.\n */\nexport type IFixedAsBytes = Byte[];\n\n/**\n * Represents an IFixed type in string form, each byte also in string form.\n */\nexport type IFixedAsStringBytes = string[];\n\n/**\n * Represents an ID as an array of bytes in string form.\n */\nexport type IdAsStringBytes = string[];\n\n/**\n * Holds information about third-party fees in transactions, including the recipient\n * and the fee percentage to be collected.\n */\nexport interface ExternalFee {\n\t/**\n\t * Address of the recipient for collected fees.\n\t */\n\trecipient: SuiAddress;\n\t/**\n\t * Percentage of the fee to be collected.\n\t * @remarks 0.54 = 54%\n\t */\n\tfeePercentage: Percentage;\n}\n\n/**\n * A function signature for signing arbitrary messages. Typically used in\n * cryptographic contexts.\n */\nexport type SignMessageCallback = (args: { message: Uint8Array }) => Promise<{\n\tsignature: string;\n}>;\n\n/**\n * Generic shape for events with optional paging cursor data.\n */\nexport interface IndexerEventsWithCursor<EventType> {\n\t/**\n\t * An array of events of type `EventType`.\n\t */\n\tevents: EventType[];\n\t/**\n\t * The next cursor position. If undefined, no more events are available.\n\t */\n\tnextCursor: number | undefined;\n}\n\n/**\n * A generic shape for events with a Sui-based cursor structure.\n */\nexport interface EventsWithCursor<EventType> {\n\t/**\n\t * An array of events of type `EventType`.\n\t */\n\tevents: EventType[];\n\t/**\n\t * The next cursor position. If null, no more events are available.\n\t */\n\tnextCursor: EventId | null;\n}\n\n/**\n * Represents a Sui event, typically including type, timestamp, and transaction digest.\n */\nexport interface Event {\n\t/**\n\t * A string identifying the Move event type.\n\t */\n\ttype: AnyObjectType;\n\t/**\n\t * Timestamp of the event, if available.\n\t */\n\ttimestamp: Timestamp | undefined;\n\t/**\n\t * The transaction digest associated with the event.\n\t */\n\ttxnDigest: TransactionDigest;\n}\n\n/**\n * Common inputs for event retrieval, including an optional cursor and limit.\n */\nexport interface EventsInputs {\n\t/**\n\t * Cursor for pagination, often an EventId or numeric index.\n\t */\n\tcursor?: EventId;\n\t/**\n\t * Limit for pagination, specifying the maximum number of events.\n\t */\n\tlimit?: number;\n}\n\n/**\n * Inputs for retrieving user events, extending from general event inputs\n * and including the user's wallet address.\n */\nexport type UserEventsInputs = EventsInputs & {\n\twalletAddress: SuiAddress;\n};\n\n/**\n * Represents a Sui object, including its ID and type.\n */\nexport interface Object {\n\t/**\n\t * The on-chain object ID.\n\t */\n\tobjectId: ObjectId;\n\t/**\n\t * The Move type of the object.\n\t */\n\tobjectType: AnyObjectType;\n}\n\n/**\n * Holds the dynamic fields and an optional next cursor for pagination.\n */\nexport interface DynamicFieldsWithCursor {\n\t/**\n\t * An array of dynamic field information objects.\n\t */\n\tdynamicFields: DynamicFieldInfo[];\n\t/**\n\t * The next cursor for pagination. If null, no more fields are available.\n\t */\n\tnextCursor: ObjectId | null;\n}\n\n/**\n * Holds the dynamic field objects and an optional next cursor for pagination.\n */\nexport interface DynamicFieldObjectsWithCursor<ObjectType> {\n\t/**\n\t * An array of objects derived from dynamic fields.\n\t */\n\tdynamicFieldObjects: ObjectType[];\n\t/**\n\t * The next cursor for pagination. If null, no more fields are available.\n\t */\n\tnextCursor: ObjectId | null;\n}\n\n/**\n * Inputs for fetching dynamic fields, including optional cursor and limit for pagination.\n */\nexport interface DynamicFieldsInputs {\n\tcursor?: ObjectId;\n\tlimit?: number;\n}\n\n/**\n * A collection of transactions with a cursor for pagination.\n */\nexport interface TransactionsWithCursor {\n\t/**\n\t * An array of Sui transactions.\n\t */\n\ttransactions: SuiTransactionBlockResponse[];\n\t/**\n\t * The next cursor for pagination. If null, no more transactions are available.\n\t */\n\tnextCursor: TransactionDigest | null;\n}\n\n/**\n * Generic shape for API data requests that include pagination parameters.\n */\nexport interface ApiDataWithCursorBody<CursorType> {\n\t/**\n\t * Cursor for pagination.\n\t */\n\tcursor?: CursorType;\n\t/**\n\t * Limit for pagination.\n\t */\n\tlimit?: number;\n}\n\n/**\n * Specifies the shape for API calls involving events.\n */\nexport type ApiEventsBody = ApiDataWithCursorBody<EventId>;\n\n/**\n * Specifies the shape for API calls involving dynamic fields.\n */\nexport type ApiDynamicFieldsBody = ApiDataWithCursorBody<ObjectId>;\n\n/**\n * Specifies the shape for API calls involving transactions.\n */\nexport type ApiTransactionsBody = ApiDataWithCursorBody<TransactionDigest>;\n\n/**\n * Body payload for indexer-based event queries, using a numeric cursor.\n */\nexport type ApiIndexerEventsBody = ApiDataWithCursorBody<number>;\n\n/**\n * Body payload for indexer-based user events, extending from `ApiIndexerEventsBody`.\n */\nexport type ApiIndexerUserEventsBody = ApiIndexerEventsBody & {\n\t/**\n\t * The wallet address of the user.\n\t */\n\twalletAddress: SuiAddress;\n};\n\n/**\n * Represents query parameters for retrieving data with skip/limit pagination in an indexer.\n */\nexport interface IndexerDataWithCursorQueryParams {\n\tskip: number;\n\tlimit: number;\n}\n\n/**\n * Configuration for constructing a `Caller`. Includes network specification\n * and optional access token for authentication.\n */\nexport interface CallerConfig {\n\t/**\n\t * The target Sui network (e.g., \"MAINNET\", \"TESTNET\").\n\t */\n\tnetwork?: SuiNetwork;\n\t/**\n\t * Access token used for authenticated requests, if required.\n\t */\n\taccessToken?: string;\n}\n\nexport interface ApiTransactionResponse {\n\ttxKind: SerializedTransaction;\n}\n\nexport interface SdkTransactionResponse {\n\ttx: Transaction;\n}\n","// =========================================================================\n// Network\n// =========================================================================\n\nexport type SuiNetwork =\n\t| \"DEVNET\"\n\t| \"TESTNET\"\n\t| \"LOCAL\"\n\t| \"MAINNET\"\n\t| \"INTERNAL\"\n\t| (string & {});\n","import { AnyObjectType, Object, ObjectId, Url } from \"../types/generalTypes\";\n\n// =========================================================================\n// Objects\n// =========================================================================\n\nexport interface KioskOwnerCapObject extends Object {\n\tkioskObjectId: ObjectId;\n}\n\nexport interface KioskObject extends Object {\n\tkioskOwnerCapId: ObjectId;\n\tnfts: Nft[];\n\tisPersonal: boolean;\n}\n\n// =========================================================================\n// Object Display\n// =========================================================================\n\nexport interface Nft {\n\tinfo: NftInfo;\n\tdisplay: NftDisplay;\n}\n\nexport interface NftInfo {\n\tobjectId: ObjectId;\n\t// version: string;\n\t// digest: TransactionDigest;\n\tobjectType: AnyObjectType;\n}\n\nexport interface NftDisplay {\n\tsuggested: NftDisplaySuggested;\n\tother: NftDisplayOther;\n}\n\nexport interface NftDisplaySuggested {\n\tname?: string;\n\tlink?: Url;\n\timageUrl?: Url;\n\tdescription?: string;\n\tprojectUrl?: Url;\n\tcreator?: string;\n}\n\nexport type NftDisplayOther = Record<string, string>;\n","import { CoinType } from \"../../types\";\nimport { SerializedTransaction, SuiAddress } from \"../types\";\n\n/**\n * Represents the body payload sent to the dynamic gas service,\n * which includes the serialized transaction and any user-provided\n * gas configuration (e.g., coin type).\n */\nexport interface ApiDynamicGasBody {\n\t/**\n\t * The serialized transaction block in base64 or similar format.\n\t */\n\tserializedTx: SerializedTransaction;\n\t/**\n\t * The address of the user for whom the dynamic gas is being set.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The coin type to be used for gas payment (e.g., \"0x2::sui::SUI\").\n\t */\n\tgasCoinType: CoinType;\n}\n\n/**\n * Represents the response from the dynamic gas service, typically returning\n * updated transaction bytes and possibly a sponsored signature if the\n * transaction gas is being partially or fully sponsored.\n */\nexport interface ApiDynamicGasResponse {\n\t/**\n\t * The modified transaction bytes that incorporate a gas coin or sponsor information.\n\t */\n\ttxBytes: SerializedTransaction;\n\t/**\n\t * A signature used to sponsor or verify the updated transaction, if applicable.\n\t */\n\tsponsoredSignature: string;\n}\n","import { CoinSymbol, CoinType } from \"../../types\";\n\n// =========================================================================\n// Coin Gecko\n// =========================================================================\n\n// NOTE: these are taken from wormhole chain naming scheme\nexport type CoinGeckoChain = Lowercase<\n\t| \"Ethereum\"\n\t| \"Arbitrum\"\n\t| \"Bsc\"\n\t| \"Solana\"\n\t| \"Sui\"\n\t| \"Polygon\"\n\t| \"Avalanche\"\n\t| \"Optimism\"\n\t| \"Base\"\n\n\t// | \"Oasis\"\n\t// | \"Terra\"\n\t// | \"Algorand\"\n\t// | \"Aurora\"\n\t// | \"Fantom\"\n\t// | \"Karura\"\n\t// | \"Acala\"\n\t// | \"Klaytn\"\n\t// | \"Celo\"\n\t// | \"Near\"\n\t// | \"Moonbeam\"\n\t// | \"Neon\"\n\t// | \"Terra2\"\n\t// | \"Injective\"\n\t// | \"Osmosis\"\n\t// | \"Aptos\"\n\t// | \"Gnosis\"\n\t// | \"Pythnet\"\n\t// | \"Xpla\"\n\t// | \"Btc\"\n\t// | \"Sei\"\n\t// | \"Rootstock\"\n\t// | \"Scroll\"\n\t// | \"Mantle\"\n\t// | \"Blast\"\n\t// | \"Xlayer\"\n\t// | \"Linea\"\n\t// | \"Berachain\"\n\t// | \"Seievm\"\n\t// | \"Wormchain\"\n\t// | \"Cosmoshub\"\n\t// | \"Evmos\"\n\t// | \"Kujira\"\n\t// | \"Neutron\"\n\t// | \"Celestia\"\n\t// | \"Stargaze\"\n\t// | \"Seda\"\n\t// | \"Dymension\"\n\t// | \"Provenance\"\n\t// | \"Sepolia\"\n\t// | \"ArbitrumSepolia\"\n\t// | \"BaseSepolia\"\n\t// | \"OptimismSepolia\"\n\t// | \"Holesky\"\n\t// | \"PolygonSepolia\"\n>;\n\n// =========================================================================\n// Name Only\n// =========================================================================\n\nexport type CoinGeckoCoinApiId = string;\n\n// =========================================================================\n// Data\n// =========================================================================\n\nexport interface CoinGeckoCoinData {\n\tchain: CoinGeckoChain | \"\";\n\tapiId: CoinGeckoCoinApiId;\n\tname: string;\n\tsymbol: CoinSymbol;\n\tcoinType: CoinType;\n}\n\nexport interface CoinGeckoCoinSymbolData {\n\tapiId: CoinGeckoCoinApiId;\n\tname: string;\n\tsymbol: CoinSymbol;\n}\n","export * from \"./configTypes\";\nexport * from \"./generalTypes\";\nexport * from \"./suiTypes\";\nexport * from \"../nfts/nftsTypes\";\nexport * from \"../dynamicGas/dynamicGasTypes\";\nexport * from \"../prices/coinGeckoTypes\";\n","import { SuiAddress, Timestamp } from \"../../types\";\n\n/**\n * Interface specifying allowable rate limits for an auth account.\n * The `p` field indicates the path or endpoint (e.g., \"/pools\"),\n * while `m` indicates the method-based limits (GET or POST, or both).\n */\nexport interface RateLimit {\n\t/**\n\t * The path or endpoint to be rate-limited, e.g. \"/pools\" or \"/router/trade\".\n\t */\n\tp: string;\n\t/**\n\t * The method-based limit specification.\n\t * For example:\n\t * ```\n\t * { GET: { l: 100 } }\n\t * { POST: { l: 50 } }\n\t * { GET: { l: 100 }, POST: { l: 100 } }\n\t * ```\n\t */\n\tm:\n\t\t| { GET: { l: number } }\n\t\t| { POST: { l: number } }\n\t\t| { GET: { l: number }; POST: { l: number } };\n}\n\n// =========================================================================\n// Bodies\n// =========================================================================\n\n/**\n * The request body for creating a new auth account, typically\n * reserved for admin usage. The admin signs a JSON containing\n * an \"AccountCreate\" `method` plus desired sub-account data.\n */\nexport interface ApiCreateAuthAccountBody {\n\t/**\n\t * The admin's Sui address, zero-padded if necessary.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The signature of the serialized JSON data, from the admin's private key.\n\t */\n\tsignature: string;\n\t/**\n\t * The JSON string that was signed, containing the method and sub-account details.\n\t */\n\tserializedJson: string;\n}\n\n/**\n * The request body for obtaining or refreshing an access token. The user signs\n * a \"GetAccessToken\" method message plus any relevant fields.\n */\nexport interface ApiGetAccessTokenBody {\n\t/**\n\t * The user's Sui address, zero-padded if needed.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The signature over the JSON-serialized request data (nonce, date, etc.).\n\t */\n\tsignature: string;\n\t/**\n\t * The actual JSON string that was signed, e.g.:\n\t * ```\n\t * {\n\t * \"date\": 1234567890,\n\t * \"nonce\": 512,\n\t * \"method\": \"GetAccessToken\",\n\t * \"value\": {}\n\t * }\n\t * ```\n\t */\n\tserializedJson: string;\n}\n\n// =========================================================================\n// Responses\n// =========================================================================\n\n/**\n * The response returned when a user obtains or refreshes an access token,\n * containing the token string, the HTTP header name (usually \"Authorization\"),\n * and the token's expiration timestamp in milliseconds.\n */\nexport interface ApiGetAccessTokenResponse {\n\t/**\n\t * The newly issued access token to be used in `Authorization` headers.\n\t */\n\taccessToken: string;\n\t/**\n\t * The header key that should contain `accessToken` (e.g., \"Authorization\").\n\t */\n\theader: string;\n\t/**\n\t * The UNIX timestamp (milliseconds) after which the token is invalid.\n\t */\n\texpirationTimestamp: Timestamp;\n}\n","import type { CoinMetadata } from \"@mysten/sui/jsonRpc\";\nimport {\n\tBalance,\n\tObjectId,\n\tPercentage,\n} from \"../../general/types/generalTypes\";\nimport { CoinGeckoCoinApiId } from \"../../types\";\n\n/**\n * Represents the decimal precision of a coin (e.g., 9 or 18).\n */\nexport type CoinDecimal = number;\n\n/**\n * A string that uniquely identifies a coin type in the Sui network\n * (e.g., \"0x2::sui::SUI\").\n */\nexport type CoinType = string;\n\n/**\n * Represents a short symbol or ticker for a coin (e.g., \"SUI\", \"BTC\").\n */\nexport type CoinSymbol = string;\n\n/**\n * Represents a coin with an amount in integer or floating form, typically used\n * to specify a user’s holding or a transaction amount.\n */\nexport interface CoinWithAmount {\n\t/**\n\t * The coin type, e.g. \"0x2::sui::SUI\".\n\t */\n\tcoin: CoinType;\n\t/**\n\t * The amount of the coin, typically expressed as an integer number of smallest units.\n\t */\n\tamount: number;\n}\n\n/**\n * Represents a coin with an amount that can be `undefined`, typically for optional or\n * deferred usage scenarios.\n */\nexport interface CoinWithAmountOrUndefined {\n\t/**\n\t * The coin type, e.g. \"0x2::sui::SUI\".\n\t */\n\tcoin: CoinType;\n\t/**\n\t * The amount of the coin, which can be `undefined`.\n\t */\n\tamount: number | undefined;\n}\n\n/**\n * Represents an amount in both coin denomination and USD value for reference.\n */\nexport interface AmountInCoinAndUsd {\n\t/**\n\t * The amount of the coin in smallest units.\n\t */\n\tamount: number;\n\t/**\n\t * The USD equivalent of that coin amount.\n\t */\n\tamountUsd: number;\n}\n\n/**\n * Maps a coin type to a numerical balance. Typically used to store multiple\n * coin balances under their respective coin types.\n */\nexport type CoinsToBalance = Record<CoinType, Balance>;\n\n/**\n * Maps a coin type to a numerical balance, which may be `undefined`.\n */\nexport type CoinsToBalanceOrUndefined = Record<CoinType, Balance | undefined>;\n\n/**\n * Maps a coin type to its price, typically as a number in USD or another fiat currency.\n */\nexport type CoinsToPrice = Record<CoinType, number>;\n\n/**\n * Maps a coin type to its on-chain decimal precision.\n */\nexport type CoinsToDecimals = Record<CoinType, CoinDecimal>;\n\n/**\n * Maps a coin type to price information, typically containing a price and a 24-hour change.\n */\nexport type CoinsToPriceInfo = Record<CoinType, CoinPriceInfo>;\n\n/**\n * Maps a coin symbol (e.g., \"SUI\") to its price information, typically containing a price and a 24-hour change.\n */\nexport type CoinSymbolsToPriceInfo = Record<CoinSymbol, CoinPriceInfo>;\n\n/**\n * Maps a coin symbol (e.g., \"SUI\") to an array of possible coin types (e.g., \"0x2::sui::SUI\").\n */\nexport type CoinSymbolToCoinTypes = Record<CoinSymbol, CoinType[]>;\n\n/**\n * Represents pricing information for a coin, including current price and 24-hour percentage change.\n */\nexport interface CoinPriceInfo {\n\t/**\n\t * The current price in USD or another currency.\n\t */\n\tprice: number;\n\t/**\n\t * The 24-hour percentage change of the coin price.\n\t * @remarks 0.54 = 54%\n\t */\n\tpriceChange24HoursPercentage: Percentage;\n}\n\n/**\n * Extends the Sui `CoinMetadata` with optional properties relevant to external data\n * sources (e.g., CoinGecko).\n */\nexport type CoinMetadaWithInfo = CoinMetadata & {\n\t/**\n\t * Indicates whether this coin's metadata was generated automatically.\n\t */\n\tisGenerated?: boolean;\n\t/**\n\t * The associated CoinGecko API ID, if available.\n\t */\n\tcoingeckoId?: CoinGeckoCoinApiId;\n};\n\n/**\n * Represents a coin reference in the Move environment, using either an on-chain ObjectId\n * or an input index or result index from a transaction.\n */\nexport type ServiceCoinData =\n\t| { Coin: ObjectId }\n\t| { Input: number }\n\t| { Result: number }\n\t| { NestedResult: [number, number] };\n\n/**\n * **Legacy type** representing a coin reference in the Move environment, using\n * older transaction output indexing structures.\n */\nexport type ServiceCoinDataV2 =\n\t| \"Gas\"\n\t| { Input: number }\n\t| { Result: number }\n\t| { NestedResult: [number, number] };\n","import { ObjectId, SuiAddress } from \"../../types\";\nimport {\n\tBalance,\n\tEvent,\n\tObject,\n\tTimestamp,\n} from \"../../general/types/generalTypes\";\nimport { CoinType } from \"../coin/coinTypes\";\n\n// =========================================================================\n// Name Only\n// =========================================================================\n\n/**\n * A multiplier type (in fixed-point bigint) used to scale a staked amount based on lock duration.\n * Typically, 1.0 is represented as 1e9 (i.e., `FixedUtils.fixedOneB`).\n */\nexport type FarmsMultiplier = bigint;\n\n/**\n * Enumerates the supported farm system versions.\n */\nexport type FarmsVersion = 1 | 2;\n\n// =========================================================================\n// Helpers\n// =========================================================================\n\n/**\n * A union type indicating whether an action is authorized by the `ownerCapId`\n * or by a `oneTimeAdminCapId`.\n */\nexport type FarmOwnerOrOneTimeAdminCap =\n\t| { ownerCapId: ObjectId }\n\t| { oneTimeAdminCapId: ObjectId };\n\n// =========================================================================\n// Objects\n// =========================================================================\n\n// =========================================================================\n// Staking Pool\n// =========================================================================\n\n/**\n * Indicates how strictly the lock duration is enforced in the vault.\n * - **Strict**: The position cannot be unlocked before the lock period ends.\n * - **Relaxed**: The position can be unlocked early, but may have penalized rewards.\n */\nexport type FarmsLockEnforcement = \"Strict\" | \"Relaxed\";\n\n/**\n * Describes a single reward coin's parameters and state within a staking pool.\n */\nexport interface FarmsStakingPoolRewardCoin {\n\t/**\n\t * The coin type of this reward (e.g., \"0x2::sui::SUI\").\n\t */\n\tcoinType: CoinType;\n\t/**\n\t * The total number of reward tokens allocated for this pool (in smallest units).\n\t */\n\trewards: Balance;\n\t/**\n\t * Represents how many rewards are allocated per share in the pool. The share\n\t * is typically the \"stakedAmountWithMultiplier\".\n\t */\n\trewardsAccumulatedPerShare: Balance;\n\t/**\n\t * The emission rate per emission schedule for this reward coin. For example, if\n\t * `emissionSchedulesMs` is 1 hour, then this emissionRate is distributed each hour.\n\t */\n\temissionRate: Balance;\n\t/**\n\t * The interval (in ms) at which the emissionRate is released.\n\t */\n\temissionSchedulesMs: Timestamp;\n\t/**\n\t * The timestamp (ms) when emission for this reward coin starts.\n\t */\n\temissionStartTimestamp: Timestamp;\n\t/**\n\t * The last timestamp (ms) at which rewards were emitted for this reward coin.\n\t */\n\tlastRewardTimestamp: Timestamp;\n\t/**\n\t * The total number of rewards still available. If we have distributed\n\t * part of `rewards`, the remainder is `rewardsRemaining`.\n\t */\n\trewardsRemaining: Balance;\n\t/**\n\t * The actual number of reward tokens in the pool's on-chain object. This can differ\n\t * from `rewards` for internal or reserved logic.\n\t */\n\tactualRewards: Balance;\n}\n\n/**\n * Represents the core object for a staking pool (a \"vault\"). It includes\n * information about staking amounts, locking constraints, reward coins,\n * and emission parameters.\n */\nexport interface FarmsStakingPoolObject extends Object {\n\t/**\n\t * The coin type that users stake into this pool.\n\t */\n\tstakeCoinType: CoinType;\n\t/**\n\t * The total amount of staked tokens (principal) in this pool, in smallest units.\n\t */\n\tstakedAmount: Balance;\n\t/**\n\t * The total staked amount multiplied by users' lock multipliers. Used for reward calculations.\n\t */\n\tstakedAmountWithMultiplier: Balance;\n\t/**\n\t * The minimum time (ms) that a position can be locked for a valid multiplier.\n\t */\n\tminLockDurationMs: Timestamp;\n\t/**\n\t * The maximum time (ms) that a position can be locked. The position's lock multiplier is derived from\n\t * minLockDurationMs to maxLockDurationMs.\n\t */\n\tmaxLockDurationMs: Timestamp;\n\t/**\n\t * The maximum lock multiplier in fixed-point representation (1.0 = 1e9).\n\t */\n\tmaxLockMultiplier: FarmsMultiplier;\n\t/**\n\t * An array of reward coins that this pool distributes.\n\t */\n\trewardCoins: FarmsStakingPoolRewardCoin[];\n\t/**\n\t * The timestamp (ms) after which no further emissions occur.\n\t */\n\temissionEndTimestamp: Timestamp;\n\t/**\n\t * The minimum stake required to open a position in this pool.\n\t */\n\tminStakeAmount: Balance;\n\t/**\n\t * Whether the pool is forcibly unlocked. If `true`, positions might be able to exit early.\n\t */\n\tisUnlocked: boolean;\n\t/**\n\t * The lock enforcement policy for this pool.\n\t * - \"Strict\": positions must be unlocked before any principal can be withdrawn\n\t * - \"Relaxed\": positions can withdraw principal while locked, forfeiting pro-rata locked rewards\n\t */\n\tlockEnforcement: FarmsLockEnforcement;\n\t/**\n\t * Indicates whether this is version 1 or version 2 of the farm system.\n\t */\n\tversion: FarmsVersion;\n}\n\n/**\n * Represents the owner's capability to manage a specific staking pool. Typically\n * allows updating emission rates, reward coins, or other parameters.\n */\nexport interface StakingPoolOwnerCapObject extends Object {\n\t/**\n\t * The staking pool (vault) ID associated with this owner cap.\n\t */\n\tstakingPoolId: ObjectId;\n}\n\n/**\n * Represents a one-time admin capability object for a specific staking pool. Allows\n * the holder to initialize a new reward coin once.\n */\nexport interface StakingPoolOneTimeAdminCapObject extends Object {\n\t/**\n\t * The staking pool (vault) ID associated with this admin cap.\n\t */\n\tstakingPoolId: ObjectId;\n}\n\n// =========================================================================\n// Staked Position\n// =========================================================================\n\n/**\n * Represents the rewards accumulated and owed to a staked position for a specific coin type.\n */\nexport interface FarmsStakedPositionRewardCoin {\n\t/**\n\t * The coin type of the reward.\n\t */\n\tcoinType: CoinType;\n\t/**\n\t * The base (non-multiplied) rewards accrued since the position was opened or last updated.\n\t */\n\tbaseRewardsAccumulated: Balance;\n\t/**\n\t * The base rewards debt, representing the total base rewards from time t0 to the last update checkpoint.\n\t */\n\tbaseRewardsDebt: Balance;\n\t/**\n\t * The multiplier-based rewards accrued, factoring in the lock multiplier, since the position was opened or last updated.\n\t */\n\tmultiplierRewardsAccumulated: Balance;\n\t/**\n\t * The multiplier-based rewards debt, from time t0 to the last update checkpoint.\n\t */\n\tmultiplierRewardsDebt: Balance;\n}\n\n/**\n * Represents a user's staked position in a specific staking pool, including\n * the lock parameters, staked amounts, and accumulated rewards.\n */\nexport interface FarmsStakedPositionObject extends Object {\n\t/**\n\t * The on-chain object ID of the pool in which this position is staked.\n\t */\n\tstakingPoolObjectId: ObjectId;\n\t/**\n\t * The coin type that was staked into this position (matching the pool's stakeCoinType).\n\t */\n\tstakeCoinType: CoinType;\n\t/**\n\t * The amount of principal staked in smallest units.\n\t */\n\tstakedAmount: Balance;\n\t/**\n\t * The principal multiplied by the lock multiplier.\n\t */\n\tstakedAmountWithMultiplier: Balance;\n\t/**\n\t * The timestamp (ms) when this position’s lock started.\n\t */\n\tlockStartTimestamp: Timestamp;\n\t/**\n\t * The duration (ms) for which this position is locked.\n\t */\n\tlockDurationMs: Timestamp;\n\t/**\n\t * The current lock multiplier in fixed-point representation.\n\t */\n\tlockMultiplier: FarmsMultiplier;\n\t/**\n\t * An array of reward coins that track base + multiplier rewards for this position.\n\t */\n\trewardCoins: FarmsStakedPositionRewardCoin[];\n\t/**\n\t * The last time (ms) that rewards were updated or harvested for this position.\n\t */\n\tlastHarvestRewardsTimestamp: Timestamp;\n\t/**\n\t * The farm system version of this staked position (1 or 2).\n\t */\n\tversion: FarmsVersion;\n}\n\n/**\n * A partial staked position structure sometimes used internally, excluding\n * certain fields like `coinType`.\n */\nexport type PartialFarmsStakedPositionObject = Omit<\n\tFarmsStakedPositionObject,\n\t\"rewardCoins\"\n> & {\n\trewardCoins: Omit<FarmsStakedPositionRewardCoin, \"coinType\">[];\n};\n\n// =========================================================================\n// Events\n// =========================================================================\n\n/**\n * A union type representing any possible event from a farm (vault) system.\n */\nexport type FarmEvent =\n\t| FarmsAddedRewardEvent\n\t| FarmsCreatedVaultEvent\n\t| FarmsDepositedPrincipalEvent\n\t| FarmsDestroyedStakedPositionEvent\n\t| FarmsHarvestedRewardsEvent\n\t| FarmsIncreasedEmissionsEvent\n\t| FarmsInitializedRewardEvent\n\t| FarmsJoinedEvent\n\t| FarmsLockedEvent\n\t| FarmsSplitEvent\n\t| FarmsStakedEvent\n\t| FarmsStakedRelaxedEvent\n\t| FarmsUnlockedEvent\n\t| FarmsWithdrewPrincipalEvent;\n\n/**\n * A union type for events that specifically involve user interactions with a farm,\n * such as depositing principal, harvesting, or unlocking.\n */\nexport type FarmUserEvent =\n\t| FarmsDepositedPrincipalEvent\n\t| FarmsHarvestedRewardsEvent\n\t| FarmsLockedEvent\n\t| FarmsStakedEvent\n\t| FarmsUnlockedEvent\n\t| FarmsWithdrewPrincipalEvent;\n// | FarmsDestroyedStakedPositionEvent\n// | FarmsJoinedEvent\n// | FarmsSplitEvent\n// | FarmsStakedRelaxedEvent\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsDepositedPrincipalEvent`.\n */\nexport const isFarmsDepositedPrincipalEvent = (\n\tevent: FarmUserEvent\n): event is FarmsDepositedPrincipalEvent => {\n\treturn event.type.toLowerCase().includes(\"::depositedprincipalevent\");\n};\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsHarvestedRewardsEvent`.\n */\nexport const isFarmsHarvestedRewardsEvent = (\n\tevent: FarmUserEvent\n): event is FarmsHarvestedRewardsEvent => {\n\treturn event.type.toLowerCase().includes(\"::harvestedrewardsevent\");\n};\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsLockedEvent`.\n */\nexport const isFarmsLockedEvent = (\n\tevent: FarmUserEvent\n): event is FarmsLockedEvent => {\n\treturn event.type.toLowerCase().includes(\"::lockedevent\");\n};\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsStakedEvent`.\n */\nexport const isFarmsStakedEvent = (\n\tevent: FarmUserEvent\n): event is FarmsStakedEvent => {\n\treturn event.type.toLowerCase().includes(\"::stakedevent\");\n};\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsUnlockedEvent`.\n */\nexport const isFarmsUnlockedEvent = (\n\tevent: FarmUserEvent\n): event is FarmsUnlockedEvent => {\n\treturn event.type.toLowerCase().includes(\"::unlockedevent\");\n};\n\n/**\n * Type guard to determine if a `FarmUserEvent` is a `FarmsWithdrewPrincipalEvent`.\n */\nexport const isFarmsWithdrewPrincipalEvent = (\n\tevent: FarmUserEvent\n): event is FarmsWithdrewPrincipalEvent => {\n\treturn event.type.toLowerCase().includes(\"::withdrewprincipalevent\");\n};\n\n/**\n * Fired when additional reward tokens are added to a vault after creation.\n */\nexport interface FarmsAddedRewardEvent extends Event {\n\tvaultId: ObjectId;\n\trewardType: CoinType;\n\trewardAmount: Balance;\n}\n\n/**\n * Fired when a new vault (staking pool) is created.\n */\nexport interface FarmsCreatedVaultEvent extends Event {\n\tvaultId: ObjectId;\n\tstakeType: CoinType;\n\tminLockDurationMs: Timestamp;\n\tmaxLockDurationMs: Timestamp;\n\tmaxLockMultiplier: FarmsMultiplier;\n\tminStakeAmount: Balance;\n}\n\n/**\n * Fired when principal is deposited into a staked position in the vault.\n */\nexport interface FarmsDepositedPrincipalEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tamount: Balance;\n\tstakeType: CoinType;\n}\n\n/**\n * Fired when a staked position object is destroyed.\n */\nexport interface FarmsDestroyedStakedPositionEvent extends Event {\n\tstakedPositionId: ObjectId;\n}\n\n/**\n * Fired when a user harvests their rewards from one or more staked positions.\n */\nexport interface FarmsHarvestedRewardsEvent extends Event {\n\tvaultId: ObjectId;\n\trewardTypes: CoinType[];\n\trewardAmounts: Balance[];\n}\n\n/**\n * Fired when emissions (or the emission schedule) are increased for a specific reward coin.\n */\nexport interface FarmsIncreasedEmissionsEvent extends Event {\n\tvaultId: ObjectId;\n\trewardType: CoinType;\n\temissionScheduleMs: Timestamp;\n\temissionRate: Balance;\n}\n\n/**\n * Fired when a new reward coin is initialized in the vault.\n */\nexport interface FarmsInitializedRewardEvent extends Event {\n\tvaultId: ObjectId;\n\trewardType: CoinType;\n\trewardAmount: Balance;\n\temissionRate: Balance;\n\temissionStartMs: Timestamp;\n}\n\n/**\n * Fired when two staked positions are combined (joined) into one.\n */\nexport interface FarmsJoinedEvent extends Event {\n\tstakedPositionId: ObjectId;\n\totherStakedPositionId: ObjectId;\n}\n\n/**\n * Fired when a position is locked, specifying the lock duration and multiplier.\n */\nexport interface FarmsLockedEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tstakedType: CoinType;\n\tstakedAmount: Balance;\n\tlockStartTimestampMs: Timestamp;\n\tlockDurationMs: Timestamp;\n\tlockMultiplier: FarmsMultiplier;\n}\n\n/**\n * Fired when a staked position is split into two separate positions.\n */\nexport interface FarmsSplitEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tsplitStakedPositionId: ObjectId;\n}\n\n/**\n * Fired when a user stakes a new position in the vault (version 1 only).\n */\nexport interface FarmsStakedEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tstakedType: CoinType;\n\tstakedAmount: Balance;\n\tmultipliedStakedAmount: Balance;\n\tlockStartTimestampMs: Timestamp;\n\tlockDurationMs: Timestamp;\n\tlockMultiplier: FarmsMultiplier;\n}\n\n/**\n * Fired when a user stakes a new position in the vault under \"relaxed\" locking (version 2).\n */\nexport interface FarmsStakedRelaxedEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tstakedType: CoinType;\n\tstakedAmount: Balance;\n\tlockStartTimestampMs: Timestamp;\n\tlockEndTimestampMs: Timestamp;\n}\n\n/**\n * Fired when a position is unlocked.\n */\nexport interface FarmsUnlockedEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tstakedType: CoinType;\n\tstakedAmount: Balance;\n}\n\n/**\n * Fired when principal is withdrawn from a staked position.\n */\nexport interface FarmsWithdrewPrincipalEvent extends Event {\n\tstakedPositionId: ObjectId;\n\tvaultId: ObjectId;\n\tamount: Balance;\n\tstakeType: CoinType;\n}\n\n// =========================================================================\n// API\n// =========================================================================\n\n// =========================================================================\n// Staked Positions API\n// =========================================================================\n\n/**\n * Request body for fetching all staked positions owned by a given user.\n */\nexport interface ApiFarmsOwnedStakedPositionsBody {\n\t/**\n\t * The user's wallet address whose positions are being queried.\n\t */\n\twalletAddress: SuiAddress;\n}\n\n// =========================================================================\n// Staking API\n// =========================================================================\n\n/**\n * Request body for staking tokens in a pool (version 2).\n */\nexport interface ApiFarmsStakeBody {\n\tstakingPoolId: ObjectId;\n\tlockDurationMs: Timestamp;\n\tstakeCoinType: CoinType;\n\tstakeAmount: Balance;\n\twalletAddress: SuiAddress;\n\t// lockEnforcement: FarmsLockEnforcement;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * **Deprecated**: Use `ApiFarmsStakeBody` instead.\n */\nexport interface ApiFarmsStakeBodyV1 {\n\tstakingPoolId: ObjectId;\n\tlockDurationMs: Timestamp;\n\tstakeCoinType: CoinType;\n\tstakeAmount: Balance;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Request body for depositing additional principal into an existing staked position.\n */\nexport interface ApiFarmsDepositPrincipalBody {\n\tstakedPositionId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\tdepositAmount: Balance;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Request body for fully or partially unstaking a position.\n */\nexport interface ApiFarmsUnstakeBody {\n\tstakedPositionId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\trewardCoinTypes: CoinType[];\n\twithdrawAmount: Balance;\n\twalletAddress: SuiAddress;\n\tclaimSuiAsAfSui?: boolean;\n}\n\n// =========================================================================\n// Locking API\n// =========================================================================\n\n/**\n * Request body for locking a staked position to gain a multiplier (version 2).\n */\nexport interface ApiFarmsLockBody {\n\tstakedPositionId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tlockDurationMs: Timestamp;\n\tstakeCoinType: CoinType;\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Request body for renewing an existing lock on a staked position.\n */\nexport interface ApiFarmsRenewLockBody {\n\tstakedPositionId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Request body for unlocking a staked position prior to or at lock expiry.\n */\nexport interface ApiFarmsUnlockBody {\n\tstakedPositionId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\twalletAddress: SuiAddress;\n}\n\n// =========================================================================\n// Harvest Rewards API\n// =========================================================================\n\n/**\n * Request body for harvesting rewards from one or more staked positions.\n */\nexport interface ApiHarvestFarmsRewardsBody {\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\tstakedPositionIds: ObjectId[];\n\trewardCoinTypes: CoinType[];\n\twalletAddress: SuiAddress;\n\tclaimSuiAsAfSui?: boolean;\n}\n\n// =========================================================================\n// Staking Pool API\n// =========================================================================\n\n// =========================================================================\n// Staking Pool Creation API\n// =========================================================================\n\n/**\n * Request body for creating a new staking pool (version 2).\n */\nexport interface ApiFarmsCreateStakingPoolBody {\n\t// lockEnforcements: FarmsLockEnforcement[];\n\tminLockDurationMs: Timestamp;\n\tmaxLockDurationMs: Timestamp;\n\tmaxLockMultiplier: FarmsMultiplier;\n\tminStakeAmount: Balance;\n\tstakeCoinType: CoinType;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * **Deprecated**: Use `ApiFarmsCreateStakingPoolBody` instead.\n */\nexport interface ApiFarmsCreateStakingPoolBodyV1 {\n\t// lockEnforcement: FarmsLockEnforcement;\n\tminLockDurationMs: Timestamp;\n\tmaxLockDurationMs: Timestamp;\n\tmaxLockMultiplier: FarmsMultiplier;\n\tminStakeAmount: Balance;\n\tstakeCoinType: CoinType;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n// =========================================================================\n// Staking Pool Mutation API\n// =========================================================================\n\n/**\n * Request body for initializing a new reward in a staking pool, requiring either `ownerCapId` or `oneTimeAdminCapId`.\n */\nexport type ApiFarmsInitializeStakingPoolRewardBody = {\n\tstakingPoolId: ObjectId;\n\trewardAmount: Balance;\n\temissionScheduleMs: Timestamp;\n\temissionRate: bigint;\n\temissionDelayTimestampMs: Timestamp;\n\tstakeCoinType: CoinType;\n\trewardCoinType: CoinType;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n} & FarmOwnerOrOneTimeAdminCap;\n\n/**\n * Request body for topping up multiple reward coins in a staking pool, requiring either `ownerCapId` or `oneTimeAdminCapId`.\n */\nexport type ApiFarmsTopUpStakingPoolRewardsBody = {\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\trewards: {\n\t\trewardCoinType: CoinType;\n\t\trewardAmount: Balance;\n\t}[];\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n} & FarmOwnerOrOneTimeAdminCap;\n\n/**\n * Request body for increasing the emissions for specified reward coins in a pool (owner only).\n */\nexport type ApiFarmsIncreaseStakingPoolRewardsEmissionsBody = {\n\townerCapId: ObjectId;\n\tstakingPoolId: ObjectId;\n\tstakeCoinType: CoinType;\n\trewards: {\n\t\trewardCoinType: CoinType;\n\t\temissionScheduleMs: Timestamp;\n\t\temissionRate: bigint;\n\t}[];\n\twalletAddress: SuiAddress;\n};\n\n/**\n * Request body for fetching staking pool owner caps owned by a user.\n */\nexport interface ApiFarmsOwnedStakingPoolOwnerCapsBody {\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Request body for fetching staking pool one-time admin caps owned by a user.\n */\nexport interface ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody {\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Request body for granting a one-time admin cap of a particular reward coin to another user.\n */\nexport type ApiFarmsGrantOneTimeAdminCapBody = {\n\townerCapId: ObjectId;\n\trecipientAddress: SuiAddress;\n\trewardCoinType: CoinType;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n};\n","import {\n\tAnyObjectType,\n\tBalance,\n\tEvent,\n\tSuiAddress,\n} from \"../../general/types/generalTypes\";\nimport { CoinType } from \"../coin/coinTypes\";\n\n// =========================================================================\n// Events\n// =========================================================================\n\nexport interface FaucetMintCoinEvent extends Event {\n\tminter: SuiAddress;\n\tcoinType: CoinType;\n\tamount: Balance;\n}\n\nexport interface FaucetAddCoinEvent extends Event {\n\tcoinType: CoinType;\n}\n\n// =========================================================================\n// API\n// =========================================================================\n\nexport interface ApiFaucetRequestBody {\n\tcoinType: CoinType;\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiFaucetMintSuiFrenBody {\n\tmintFee: Balance;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n}\n","import {\n\tAnyObjectType,\n\tBalance,\n\tCoinType,\n\tObject,\n\tPoolObject,\n\tSlippage,\n\tUrl,\n\tObjectId,\n\tSuiAddress,\n} from \"../../types\";\n\n// =========================================================================\n// Objects\n// =========================================================================\n\nexport interface NftAmmMarketObject extends Object {\n\tnftsTable: {\n\t\tobjectId: ObjectId;\n\t\tsize: bigint;\n\t};\n\tpool: PoolObject;\n\tfractionalizedSupply: Balance;\n\tfractionalizedCoinAmount: Balance;\n\tfractionalizedCoinType: CoinType;\n\tassetCoinType: CoinType;\n\tlpCoinType: CoinType;\n\tnftType: AnyObjectType;\n}\n\n// =========================================================================\n// Generic Types\n// =========================================================================\n\nexport type NftAmmInterfaceGenericTypes = [\n\tlpCoinType: CoinType,\n\tfractionalizedCoinType: CoinType,\n\tassetCoinType: CoinType,\n\tnftType: AnyObjectType\n];\n\n// =========================================================================\n// API\n// =========================================================================\n\nexport interface ApiNftAmmBuyBody {\n\tmarketObjectId: ObjectId;\n\twalletAddress: SuiAddress;\n\tnftObjectIds: ObjectId[];\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n}\n\nexport interface ApiNftAmmSellBody {\n\tmarketObjectId: ObjectId;\n\twalletAddress: SuiAddress;\n\tnftObjectIds: ObjectId[];\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n}\n\nexport interface ApiNftAmmDepositBody {\n\twalletAddress: SuiAddress;\n\tmarketObjectId: ObjectId;\n\tassetCoinAmountIn: Balance;\n\tnftObjectIds: ObjectId[];\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n}\n\nexport interface ApiNftAmmWithdrawBody {\n\twalletAddress: SuiAddress;\n\tmarketObjectId: ObjectId;\n\tlpCoinAmount: Balance;\n\tnftObjectIds: ObjectId[];\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n}\n","import {\n\tBalance,\n\tEvent,\n\tObject,\n\tObjectId,\n\tPercentage,\n\tSlippage,\n\tSuiAddress,\n\tTimestamp,\n\tUrl,\n} from \"../../general/types/generalTypes\";\nimport { ManipulateType } from \"dayjs\";\nimport { CoinDecimal, CoinsToBalance, CoinType } from \"../coin/coinTypes\";\nimport { UniqueId } from \"../router/routerTypes\";\n\n/**\n * Name or label used to identify a pool. e.g., \"My Stable Pool\" or \"SUI-COIN LP\".\n */\nexport type PoolName = string;\n\n/**\n * Represents a coin's weight in a weighted pool, stored as a bigint for\n * 1e9 or 1e18 style scaling.\n */\nexport type PoolWeight = bigint;\n\n/**\n * Represents the trade fee for a coin in the pool, stored as a bigint\n * in a scaled format (e.g. 1 = 1e9).\n */\nexport type PoolTradeFee = bigint;\n\n/**\n * Represents the deposit fee for a coin in the pool, stored as a bigint\n * in a scaled format.\n */\nexport type PoolDepositFee = bigint;\n\n/**\n * Represents the withdrawal fee for a coin in the pool, stored as a bigint\n * in a scaled format.\n */\nexport type PoolWithdrawFee = bigint;\n\n/**\n * Represents \"flatness\" in a pool, used for certain advanced pool calculations\n * or invariants. Often 0 or 1, depending on stable vs. uncorrelated logic.\n */\nexport type PoolFlatness = bigint;\n\n/**\n * Represents a normalized balance in the pool, often used for\n * internal calculations to standardize coin decimals.\n */\nexport type NormalizedBalance = bigint;\n\n/**\n * A big integer scalar used for decimals conversion (1e9 or 1e18, etc.).\n */\nexport type DecimalsScalar = bigint;\n\n/**\n * A record mapping `CoinType` => a `PoolCoin` structure, describing\n * each coin's weight, balance, fees, and decimal scaling within a pool.\n */\nexport type PoolCoins = Record<CoinType, PoolCoin>;\n\n/**\n * Details about a coin in the pool, including the on-chain balance,\n * trade fees (in/out), deposit/withdraw fees, and decimal scaling factors.\n */\nexport interface PoolCoin {\n\t/**\n\t * The coin's weight in the pool (e.g., for a weight-based AMM).\n\t */\n\tweight: PoolWeight;\n\t/**\n\t * The on-chain balance of this coin in the pool.\n\t */\n\tbalance: Balance;\n\t/**\n\t * The inbound trade fee (scaled) for this coin.\n\t */\n\ttradeFeeIn: PoolTradeFee;\n\t/**\n\t * The outbound trade fee (scaled) for this coin.\n\t */\n\ttradeFeeOut: PoolTradeFee;\n\t/**\n\t * The deposit fee (scaled) for adding this coin into the pool.\n\t */\n\tdepositFee: PoolDepositFee;\n\t/**\n\t * The withdrawal fee (scaled) for removing this coin from the pool.\n\t */\n\twithdrawFee: PoolWithdrawFee;\n\t/**\n\t * A scaling factor (like 1e9 or 1e18) used to unify coin decimals\n\t * for internal math.\n\t */\n\tdecimalsScalar: DecimalsScalar;\n\t/**\n\t * The \"normalized\" balance, factoring in `decimalsScalar`.\n\t */\n\tnormalizedBalance: NormalizedBalance;\n\t/**\n\t * The displayed decimals for user-facing reference (e.g., 6, 9, 18).\n\t */\n\tdecimals?: CoinDecimal;\n}\n\n/**\n * The primary pool object structure stored on-chain.\n * `lpCoinType` is the minted LP token, `coins` is a record of coin data.\n */\nexport interface PoolObject extends Object {\n\t/**\n\t * The human-readable name of the pool (e.g., \"My Weighted Pool\").\n\t */\n\tname: PoolName;\n\t/**\n\t * The address of the pool's creator.\n\t */\n\tcreator: SuiAddress;\n\t/**\n\t * The LP coin type for this pool, e.g., \"0x<...>::af_lp::AF_LP_xyz\".\n\t */\n\tlpCoinType: CoinType;\n\t/**\n\t * The total supply of LP tokens currently minted.\n\t */\n\tlpCoinSupply: Balance;\n\t/**\n\t * The amount of LP tokens that are illiquid (locked for some reason).\n\t */\n\tilliquidLpCoinSupply: Balance;\n\t/**\n\t * A \"flatness\" parameter used for stable vs. uncorrelated logic. 0 or 1 typically.\n\t */\n\tflatness: PoolFlatness;\n\t/**\n\t * A record of coin data for each coin type in the pool.\n\t */\n\tcoins: PoolCoins;\n\t/**\n\t * The decimals used by the LP coin.\n\t */\n\tlpCoinDecimals: CoinDecimal;\n\t/**\n\t * An optional DAO fee object, if the pool is configured to support a fee for a DAO or treasury.\n\t */\n\tdaoFeePoolObject?: DaoFeePoolObject;\n}\n\n/**\n * Minimal information about a user's LP coin in a specific pool,\n * including the pool ID and balance of that LP coin type.\n */\nexport interface PoolLpInfo {\n\tlpCoinType: CoinType;\n\tpoolId: ObjectId;\n\tbalance: Balance;\n}\n\n/**\n * An on-chain object representing DAO fee configuration for a pool:\n * it stores the fee basis points and the fee recipient address.\n */\nexport interface DaoFeePoolObject extends Object {\n\t/**\n\t * The fee in basis points, e.g., 100 => 1%.\n\t */\n\tfeeBps: bigint;\n\t/**\n\t * The Sui address receiving the fee portion from trades or other actions.\n\t */\n\tfeeRecipient: SuiAddress;\n}\n\n/**\n * A capability object indicating ownership of a `DaoFeePoolObject`.\n * Whomever holds this can update the fee parameters or recipient.\n */\nexport interface DaoFeePoolOwnerCapObject extends Object {\n\t/**\n\t * The `DaoFeePoolObject` ID this cap is associated with.\n\t */\n\tdaoFeePoolId: ObjectId;\n}\n\n// =========================================================================\n// Events\n// =========================================================================\n\n/**\n * Represents a trade event within a pool, indicating coins in/out,\n * final amounts, etc.\n */\nexport interface PoolTradeEvent extends Event {\n\tpoolId: ObjectId;\n\ttrader: SuiAddress;\n\t/**\n\t * The array of coin types that were spent in the trade.\n\t */\n\ttypesIn: CoinType[];\n\t/**\n\t * The amounts of each coin type that were spent.\n\t */\n\tamountsIn: Balance[];\n\t/**\n\t * The coin types that were received.\n\t */\n\ttypesOut: CoinType[];\n\t/**\n\t * The amounts of each output coin.\n\t */\n\tamountsOut: Balance[];\n}\n\n/**\n * Represents a deposit event where a user adds liquidity to a pool,\n * receiving minted LP tokens in return.\n */\nexport interface PoolDepositEvent extends Event {\n\tpoolId: ObjectId;\n\t/**\n\t * The address that deposited into the pool.\n\t */\n\tdepositor: SuiAddress;\n\t/**\n\t * The coin types that were deposited.\n\t */\n\ttypes: CoinType[];\n\t/**\n\t * The amounts for each deposited coin type.\n\t */\n\tdeposits: Balance[];\n\t/**\n\t * The amount of LP minted for the depositor.\n\t */\n\tlpMinted: Balance;\n}\n\n/**\n * Represents a withdrawal event where a user removes liquidity from a pool,\n * burning LP tokens and receiving coin amounts in return.\n */\nexport interface PoolWithdrawEvent extends Event {\n\tpoolId: ObjectId;\n\t/**\n\t * The user who withdrew from the pool.\n\t */\n\twithdrawer: SuiAddress;\n\t/**\n\t * The coin types that were returned upon withdrawal.\n\t */\n\ttypes: CoinType[];\n\t/**\n\t * The amounts for each returned coin type.\n\t */\n\twithdrawn: Balance[];\n\t/**\n\t * The amount of LP burned in exchange for these outputs.\n\t */\n\tlpBurned: Balance;\n}\n\n/**\n * Fired when a new DAO fee pool is created for a specific internal pool.\n */\nexport interface CreatedDaoFeePoolEvent extends Event {\n\tdaoFeePoolId: ObjectId;\n\tinnerPoolId: ObjectId;\n\tfeeBps: bigint;\n\tfeeRecipient: SuiAddress;\n}\n\n/**\n * Fired when the fee basis points in a `DaoFeePoolObject` are updated.\n */\nexport interface UpdatedFeeBpsEvent extends Event {\n\tdaoFeePoolId: ObjectId;\n\toldFeeBps: bigint;\n\tnewFeeBps: bigint;\n}\n\n/**\n * Fired when the fee recipient address in a `DaoFeePoolObject` changes.\n */\nexport interface UpdatedFeeRecipientEvent extends Event {\n\tdaoFeePoolId: ObjectId;\n\toldFeeAddress: SuiAddress;\n\tnewFeeAddress: SuiAddress;\n}\n\n// =========================================================================\n// Stats\n// =========================================================================\n\n/**\n * Basic statistical data about a pool, including volume, TVL, supply per LPS,\n * fees, and APR.\n */\nexport interface PoolStats {\n\t/**\n\t * The 24-hour volume or some aggregated volume metric for the pool.\n\t */\n\tvolume: number;\n\t/**\n\t * The total value locked in the pool, often in USD or stablecoin value.\n\t */\n\ttvl: number;\n\t/**\n\t * A representation of the distribution of supply among liquidity providers,\n\t * e.g., how many tokens each user holds. May be used for advanced UI.\n\t */\n\tsupplyPerLps: number[];\n\t/**\n\t * The price of 1 LP token in reference to a stable baseline (USD).\n\t */\n\tlpPrice: number;\n\t/**\n\t * The total fees generated by the pool in a given period (often 24h or 7d).\n\t */\n\tfees: number;\n\t/**\n\t * The approximate annual percentage rate (yield) derived from fees, volume, or\n\t * other data. This can be used to estimate LP profits or compare pools.\n\t */\n\tapr: number;\n}\n\n/**\n * Represents a data point for pool analytics, including a Unix timestamp (in ms)\n * and a numeric value (e.g., volume or fee data).\n */\nexport interface PoolDataPoint {\n\ttime: Timestamp;\n\tvalue: number;\n}\n\n/**\n * Supported timeframes for graphing or fetching historical data:\n * 1 day, 1 week, 1 month, 3 months, 6 months, or 1 year.\n */\nexport type PoolGraphDataTimeframeKey = \"1D\" | \"1W\" | \"1M\" | \"3M\" | \"6M\" | \"1Y\";\n\n/**\n * An optional object or approach to define timeframe windows, using\n * dayjs manipulation. Not always used directly.\n */\nexport interface PoolGraphDataTimeframe {\n\ttime: Timestamp;\n\ttimeUnit: ManipulateType;\n}\n\n// =========================================================================\n// Pool Creation\n// =========================================================================\n\n/**\n * An object describing how each coin in a newly created pool is configured,\n * including initial deposit, weight, and fees.\n */\nexport interface PoolCreationCoinInfo {\n\tcoinType: CoinType;\n\tweight: PoolWeight;\n\tdecimals?: CoinDecimal;\n\ttradeFeeIn: PoolTradeFee;\n\ttradeFeeOut: PoolTradeFee;\n\tdepositFee: PoolDepositFee;\n\twithdrawFee: PoolWithdrawFee;\n\tinitialDeposit: Balance;\n}\n\n/**\n * Metadata for the newly published LP coin, specifying name, symbol, and optional icon URL.\n */\nexport interface PoolCreationLpCoinMetadata {\n\tname: string;\n\tsymbol: string;\n\ticonUrl?: Url;\n}\n\n// =========================================================================\n// CoinGecko Integration\n// =========================================================================\n\n/**\n * A data structure used for integration with CoinGecko, representing\n * an aggregated ticker ID, base/target coins, price, volumes, and liquidity.\n */\nexport interface CoinGeckoTickerData {\n\tticker_id: UniqueId;\n\tbase_currency: CoinType;\n\ttarget_currency: CoinType;\n\tpool_id: ObjectId;\n\tlast_price: number;\n\tbase_volume: number;\n\ttarget_volume: number;\n\tliquidity_in_usd: number;\n}\n\n/**\n * Represents a historical trade record for integration with CoinGecko,\n * storing a trade ID, price, volumes, timestamp, and buy/sell type.\n */\nexport interface CoinGeckoHistoricalTradeData {\n\ttrade_id: UniqueId;\n\tprice: number;\n\tbase_volume: number;\n\ttarget_volume: number;\n\ttrade_timestamp: Timestamp;\n\ttype: \"buy\" | \"sell\";\n}\n\n// =========================================================================\n// API\n// =========================================================================\n\n/**\n * Request body for a user trade, specifying which coin to send in and how much,\n * which coin to receive, plus slippage and optional referral info.\n */\nexport interface ApiPoolTradeBody {\n\twalletAddress: SuiAddress;\n\tcoinInType: CoinType;\n\tcoinInAmount: Balance;\n\tcoinOutType: CoinType;\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Request body for depositing liquidity into a pool, specifying the amounts in,\n * slippage, and optional referral or sponsorship data.\n */\nexport interface ApiPoolDepositBody {\n\twalletAddress: SuiAddress;\n\tamountsIn: CoinsToBalance;\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Request body for withdrawing specific amounts from the pool, specifying\n * which coins to remove, how much LP is burned, slippage, etc.\n */\nexport interface ApiPoolWithdrawBody {\n\twalletAddress: SuiAddress;\n\tamountsOutDirection: CoinsToBalance;\n\tlpCoinAmount: Balance;\n\tslippage: Slippage;\n\treferrer?: SuiAddress;\n}\n\n/**\n * Request body for withdrawing all coin types from a pool using a single\n * ratio or entire LP amount, simplifying the multi-coin approach.\n */\nexport interface ApiPoolAllCoinWithdrawBody {\n\twalletAddress: SuiAddress;\n\tlpCoinAmount: Balance;\n\treferrer?: SuiAddress;\n}\n\n/**\n * Request body for publishing a new LP coin on-chain,\n * typically specifying the coin's decimals.\n */\nexport interface ApiPublishLpCoinBody {\n\twalletAddress: SuiAddress;\n\tlpCoinDecimals: number;\n}\n\n/**\n * Request body for creating a new pool, specifying coin information,\n * the LP coin metadata, and optional DAO fee info.\n */\nexport interface ApiCreatePoolBody {\n\twalletAddress: SuiAddress;\n\tlpCoinType: CoinType;\n\tlpCoinMetadata: PoolCreationLpCoinMetadata;\n\tcoinsInfo: {\n\t\tcoinType: CoinType;\n\t\tweight: Percentage;\n\t\tdecimals?: number;\n\t\ttradeFeeIn: Percentage;\n\t\tinitialDeposit: Balance;\n\t}[];\n\tpoolName: PoolName;\n\tpoolFlatness: 0 | 1;\n\tcreatePoolCapId: ObjectId;\n\trespectDecimals: boolean;\n\tforceLpDecimals?: CoinDecimal;\n\tisSponsoredTx?: boolean;\n\tburnLpCoin?: boolean;\n\tdaoFeeInfo?: {\n\t\tfeePercentage: Percentage;\n\t\tfeeRecipient: SuiAddress;\n\t};\n}\n\n/**\n * For retrieving the spot price of a pool, specifying coin in/out.\n * Not always used directly, but present in certain route building contexts.\n */\nexport interface ApiPoolSpotPriceBody {\n\tcoinInType: CoinType;\n\tcoinOutType: CoinType;\n}\n\n/**\n * Request body for obtaining a pool object ID from an LP coin type.\n * Useful to confirm if a coin is indeed an LP token and which pool it references.\n */\nexport interface ApiPoolObjectIdForLpCoinTypeBody {\n\tlpCoinTypes: CoinType[];\n}\n\n/**\n * Request body for fetching statistics about one or more pools.\n */\nexport interface ApiPoolsStatsBody {\n\tpoolIds: ObjectId[];\n}\n\n/**\n * Request body for listing the owned DAO fee pool owner caps,\n * letting a user see if they can update fees/recipients in certain pools.\n */\nexport interface ApiPoolsOwnedDaoFeePoolOwnerCapsBody {\n\twalletAddress: SuiAddress;\n}\n","import { SuiAddress, Timestamp } from \"../../types\";\n\n// =========================================================================\n// Data\n// =========================================================================\n\nexport interface ReferralsRefereeInfo {\n\t/**\n\t * The wallet address of the referee\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * When the referee joined via this ref link\n\t */\n\tjoinedAt: Timestamp;\n}\n\n// =========================================================================\n// API\n// =========================================================================\n\nexport interface ApiReferralsGetRefCodeBody {\n\t/**\n\t * The wallet address to get referral code of\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The bytes of the message signed by the user's wallet. Required for authentication.\n\t */\n\tbytes: string;\n\t/**\n\t * The signature of the message signed by the user's wallet. Required for authentication.\n\t */\n\tsignature: string;\n}\n\nexport interface ApiReferralsGetRefCodeResponse {\n\t/**\n\t * The wallet address queried\n\t */\n\taddress: SuiAddress;\n\t/**\n\t * The referral code of queried wallet address\n\t */\n\trefCode: string | undefined;\n}\n\nexport interface ApiReferralsGetLinkedRefCodeBody {\n\t/**\n\t * The wallet address to get linked referral code of\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The bytes of the message signed by the user's wallet. Required for authentication.\n\t */\n\tbytes: string;\n\t/**\n\t * The signature of the message signed by the user's wallet. Required for authentication.\n\t */\n\tsignature: string;\n}\n\nexport interface ApiReferralsGetLinkedRefCodeResponse {\n\t/**\n\t * The wallet address queried\n\t */\n\taddress: SuiAddress;\n\t/**\n\t * The referral code linked to the queried wallet address\n\t */\n\tlinkedRefCode: string | undefined;\n\t/**\n\t * Timestamp when the referral link was created (None if not linked)\n\t */\n\tlinkedAt: Timestamp | undefined;\n}\n\nexport interface ApiReferralsGetRefereesBody {\n\t/**\n\t * Ref code to get referees for\n\t */\n\trefCode: string;\n\tlimit?: number;\n\toffset?: number;\n}\n\nexport interface ApiReferralsGetRefereesResponse {\n\t/**\n\t * The referral code queried\n\t */\n\trefCode: string;\n\t/**\n\t * List of referees\n\t */\n\treferees: ReferralsRefereeInfo[];\n\t/**\n\t * Total number of referees (before pagination)\n\t */\n\ttotalCount: number;\n}\n\nexport interface ApiReferralsIsRefCodeTakenBody {\n\t/**\n\t * The referral code queried if taken\n\t */\n\trefCode: string;\n}\n\nexport interface ApiReferralsIsRefCodeTakenResponse {\n\t/**\n\t * The referral code that was checked\n\t */\n\trefCode: string;\n\t/**\n\t * Whether this ref code is available for use (true = available, false = taken)\n\t */\n\tisAvailable: boolean;\n}\n\nexport interface ApiReferralsCreateReferralLinkBody {\n\t/**\n\t * The wallet address of the user creating the ref link. Required for authentication.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The bytes of the message signed by the user's wallet. Required for authentication.\n\t */\n\tbytes: string;\n\t/**\n\t * The signature of the message signed by the user's wallet. Required for authentication.\n\t */\n\tsignature: string;\n}\n\nexport interface ApiReferralsCreateReferralLinkResponse {\n\t/**\n\t * The unique referral code/ID\n\t */\n\trefCode: string;\n\t/**\n\t * The wallet address of the referrer\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * Timestamp when the ref link was created\n\t */\n\tcreatedAt: Timestamp;\n\t/**\n\t * Status of the creation\n\t */\n\tstatus: string;\n}\n\nexport interface ApiReferralsSetReferrerBody {\n\t/**\n\t * The wallet address of the referee. Required for authentication.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The bytes of the message signed by the referee's wallet. Required for authentication.\n\t */\n\tbytes: string;\n\t/**\n\t * The signature of the message signed by the referee's wallet. Required for authentication.\n\t */\n\tsignature: string;\n}\n\nexport interface ApiReferralsSetReferrerResponse {\n\t/**\n\t * The wallet address of the referee\n\t */\n\trefereeAddress: SuiAddress;\n\t/**\n\t * The referral code used\n\t */\n\trefCode: string;\n\t/**\n\t * Timestamp when the referral relationship was established\n\t */\n\tcreatedAt: Timestamp;\n\t/**\n\t * Status of the operation\n\t */\n\tstatus: string;\n}\n","import type { Transaction } from \"@mysten/sui/transactions\";\nimport type {\n\tBalance,\n\tCoinType,\n\tObjectId,\n\tSerializedTransaction,\n\tSuiAddress,\n\tTimestamp,\n\tTransactionDigest,\n} from \"../../types\";\n\n// =========================================================================\n// API - Points\n// =========================================================================\n\n/**\n * Request body for fetching a user's reward points.\n * Uses a pre-signed message (bytes + signature) for authentication.\n */\nexport interface ApiRewardsGetPointsBody {\n\t/**\n\t * The user's Sui wallet address (e.g., \"0x<address>\").\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The message bytes (base64 encoded) that the user previously signed.\n\t * Can be reused from other signed messages (e.g., Terms and Conditions).\n\t */\n\tbytes: string;\n\t/**\n\t * The signature corresponding to the signed message bytes.\n\t */\n\tsignature: string;\n}\n\n/**\n * Response containing the user's reward points.\n */\nexport interface ApiRewardsGetPointsResponse {\n\t/**\n\t * The user's total reward points.\n\t */\n\tpoints: number;\n}\n\n// =========================================================================\n// API - History\n// =========================================================================\n\n/**\n * Request body for fetching a user's rewards history.\n */\nexport interface ApiRewardsGetHistoryBody {\n\t/**\n\t * Sui wallet address to query history for.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * Optional domain filter (e.g., \"referrals\", \"perpetuals\").\n\t * If omitted, returns all domains.\n\t */\n\tdomain?: string;\n\t/**\n\t * Maximum number of entries to return. Default: 20, max: 100.\n\t */\n\tlimit?: number;\n\t/**\n\t * Cursor for fetching next page.\n\t */\n\tcursor?: number;\n}\n\n/**\n * Response containing the user's rewards history.\n */\nexport interface ApiRewardsGetHistoryResponse {\n\t/**\n\t * Array of historical reward entries.\n\t */\n\thistory: RewardsHistoryEntry[];\n\t/**\n\t * Pagination info.\n\t */\n\tpagination: RewardsPaginationInfo;\n}\n\n/**\n * A single historical reward entry.\n */\nexport interface RewardsHistoryEntry {\n\t/**\n\t * Vault ID where the deposit was made.\n\t */\n\tvaultId: ObjectId;\n\t/**\n\t * Fully-qualified Coin type (e.g., \"0x2::sui::SUI\").\n\t */\n\tcoinType: CoinType;\n\t/**\n\t * Reward amount in base units.\n\t */\n\tamount: Balance;\n\t/**\n\t * Domain identifier (e.g., \"referrals\", \"perpetuals\").\n\t */\n\tdomain: string;\n\t/**\n\t * Epoch start timestamp in milliseconds.\n\t */\n\tepochStartTimestampMs: Timestamp;\n\t/**\n\t * Epoch end timestamp in milliseconds.\n\t */\n\tepochEndTimestampMs: Timestamp;\n\t/**\n\t * Transaction digest for this deposit event, if available.\n\t */\n\ttxDigest?: TransactionDigest;\n}\n\n/**\n * Pagination information for paginated reward queries.\n */\nexport interface RewardsPaginationInfo {\n\t/**\n\t * True if more results exist beyond the returned set.\n\t */\n\thasMore: boolean;\n\t/**\n\t * Cursor for fetching the next page. Undefined if no more results.\n\t */\n\tnextCursor?: number;\n}\n\n// =========================================================================\n// API - Claimable\n// =========================================================================\n\n/**\n * Request body for fetching a user's claimable rewards.\n */\nexport interface ApiRewardsGetClaimableBody {\n\t/**\n\t * Sui wallet address to query claimable rewards for.\n\t */\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Response containing the user's claimable rewards.\n */\nexport interface ApiRewardsGetClaimableResponse {\n\t/**\n\t * Array of claimable reward entries, one per coin type.\n\t * Empty array if no rewards are claimable.\n\t */\n\trewards: RewardsClaimableReward[];\n}\n\n/**\n * A single claimable reward entry.\n */\nexport interface RewardsClaimableReward {\n\t/**\n\t * Full Sui coin type (e.g., \"0x2::sui::SUI\").\n\t */\n\tcoinType: CoinType;\n\t/**\n\t * Claimable amount in base units.\n\t */\n\tamount: Balance;\n}\n\n// =========================================================================\n// API - Claim\n// =========================================================================\n\n/**\n * Request body for claiming rewards for a user's wallet address.\n */\nexport interface ApiRewardsClaimRequestTxBody {\n\t/**\n\t * The user's Sui wallet address.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * Optional list of coin types to claim.\n\t * If omitted, claims all available rewards.\n\t */\n\tcoinTypes?: CoinType[];\n\t/**\n\t * Optional recipient address for the claimed rewards.\n\t * Defaults to walletAddress if not provided.\n\t */\n\trecipientAddress?: SuiAddress;\n\t/**\n\t * Optional serialized (base64) Sui `TransactionKind` to extend.\n\t */\n\ttxKind?: SerializedTransaction;\n}\n\nexport interface ApiRewardsClaimRequestTxResponse {\n\ttxKind: SerializedTransaction;\n}\n","import {\n\tAnyObjectType,\n\tBalance,\n\tPercentage,\n\tEvent,\n\tSlippage,\n\tApiEventsBody,\n\tObjectId,\n\tSuiAddress,\n\tTxBytes,\n\tBigIntAsString,\n\tSerializedTransaction,\n\tExternalFee,\n\tIFixedAsString,\n\tIFixed,\n\tApiIndexerEventsBody,\n} from \"../../general/types/generalTypes\";\nimport { CoinType, ServiceCoinData } from \"../coin/coinTypes\";\nimport type { TransactionObjectArgument } from \"@mysten/sui/transactions\";\n\n/**\n * A unique identifier, typically used to track items or route segments.\n */\nexport type UniqueId = string;\n\n/**\n * **Deprecated**. Please use `ExternalFee` instead.\n *\n * Fee info for third party packages wanting to fee route transactions.\n */\nexport type RouterExternalFee = ExternalFee;\n\n/**\n * All possible DEX protocols that the `Router` can use to swap coins.\n */\nexport type RouterProtocolName =\n\t| \"Aftermath\"\n\t| \"BlueMove\"\n\t| \"Cetus\"\n\t| \"DeepBook\"\n\t| \"DeepBookV3\"\n\t| \"DoubleUpPump\"\n\t| \"FlowX\"\n\t| \"FlowXClmm\"\n\t| \"FullSail\"\n\t| \"HopFun\"\n\t| \"Kriya\"\n\t| \"KriyaClmm\"\n\t| \"Magma\"\n\t| \"Metastable\"\n\t| \"Momentum\"\n\t| \"MovePump\"\n\t| \"Obric\"\n\t| \"SuiSwap\"\n\t| \"Turbos\"\n\t| \"SpringSui\"\n\t| \"Steamm\"\n\t| \"SuiAi\"\n\t// | \"AftermathLsd\"\n\t| \"Bluefin\"\n\t| \"TurbosFun\"\n\t| \"BlastFun\"\n\t| \"Bolt\";\n\n/**\n * Represents a complete trade route object. Includes all relevant information\n * for executing a trade from `coinIn` to `coinOut` through one or more protocols.\n */\nexport type RouterCompleteTradeRoute = RouterTradeInfo & {\n\t/**\n\t * An array of sub-routes, each representing a path or series of swaps.\n\t */\n\troutes: RouterTradeRoute[];\n\t/**\n\t * The total trade fee percentage across all routes.\n\t * @remarks 0.01 = 1%\n\t */\n\tnetTradeFeePercentage: Percentage;\n\t/**\n\t * Optional referrer address, if using a referral mechanism.\n\t */\n\treferrer?: SuiAddress;\n\t/**\n\t * Optional external fee information, if a third party is collecting fees.\n\t */\n\texternalFee?: ExternalFee;\n\t/**\n\t * Slippage tolerance for the trade, expressed as a decimal (0.01 = 1%).\n\t */\n\tslippage?: Slippage;\n};\n\n/**\n * **Deprecated**. Please use `RouterCompleteTradeRoute` instead.\n *\n * Represents a complete trade route object, including fee info.\n */\nexport type RouterCompleteTradeRouteWithFee = RouterCompleteTradeRoute;\n\n/**\n * Represents a sub-route of a complete trade, describing the portion\n * and the paths used. Each sub-route may involve one or more specific pools.\n */\nexport type RouterTradeRoute = RouterTradeInfo & {\n\t/**\n\t * An array of paths that this route will take to execute the trade.\n\t */\n\tpaths: RouterTradePath[];\n\t/**\n\t * The portion of the total trade allocated to this route, expressed as an IFixed value.\n\t */\n\tportion: IFixed;\n};\n\n/**\n * Represents an individual path within a route. Typically corresponds to\n * a specific DEX pool and the swap details in that pool.\n */\nexport type RouterTradePath = RouterTradeInfo & {\n\t/**\n\t * The name of the DEX protocol used for this path (e.g., \"Cetus\").\n\t */\n\tprotocolName: RouterProtocolName;\n\t/**\n\t * The pool ID (object on-chain) where the swap is performed.\n\t */\n\tpoolId: ObjectId;\n\t/**\n\t * Additional pool metadata, which can vary by DEX protocol.\n\t */\n\tpoolMetadata: any;\n};\n\n/**\n * Base interface shared by routes and paths, describing the coin in/out details and spot price.\n */\nexport interface RouterTradeInfo {\n\t/**\n\t * Input coin details, including type, amount, and any trade fee.\n\t */\n\tcoinIn: RouterTradeCoin;\n\t/**\n\t * Output coin details, including type, amount, and any trade fee.\n\t */\n\tcoinOut: RouterTradeCoin;\n\t/**\n\t * The spot price used in this route/path for calculating output from input.\n\t */\n\tspotPrice: number;\n}\n\n/**\n * Represents a coin and the associated amount and trade fee for a route or path.\n */\nexport interface RouterTradeCoin {\n\t/**\n\t * The coin type used in a route or path.\n\t */\n\ttype: CoinType;\n\t/**\n\t * The amount of the coin, typically expressed as the smallest unit (bigint).\n\t */\n\tamount: Balance;\n\t/**\n\t * The trade fee paid in this coin, expressed as a bigint.\n\t */\n\ttradeFee: Balance;\n}\n\n/**\n * Event that occurs when a user executes a trade route via the router.\n */\nexport interface RouterTradeEvent extends Event {\n\t/**\n\t * The Sui address of the trader.\n\t */\n\ttrader: SuiAddress;\n\t/**\n\t * The coin type input by the trader.\n\t */\n\tcoinInType: AnyObjectType;\n\t/**\n\t * The amount of coin input by the trader.\n\t */\n\tcoinInAmount: Balance;\n\t/**\n\t * The coin type output to the trader.\n\t */\n\tcoinOutType: AnyObjectType;\n\t/**\n\t * The amount of coin output to the trader.\n\t */\n\tcoinOutAmount: Balance;\n}\n\n/**\n * Basic body for partial router route construction, specifying coin types\n * and optional third-party fee or referral info.\n */\nexport type ApiRouterPartialCompleteTradeRouteBody = {\n\t/**\n\t * The coin type that the user wants to swap out.\n\t */\n\tcoinInType: CoinType;\n\t/**\n\t * The coin type that the user wants to receive.\n\t */\n\tcoinOutType: CoinType;\n\t/**\n\t * An optional referrer address for the route creator.\n\t */\n\treferrer?: SuiAddress;\n\t/**\n\t * Optional third-party fee details.\n\t */\n\texternalFee?: ExternalFee;\n} & (\n\t| {\n\t\t\t/**\n\t\t\t * Optionally exclude certain protocols from routing.\n\t\t\t */\n\t\t\tprotocolBlacklist?: RouterProtocolName[];\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Optionally include only certain protocols in routing.\n\t\t\t */\n\t\t\tprotocolWhitelist?: RouterProtocolName[];\n\t }\n) &\n\t(\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Optionally exclude certain pools from routing.\n\t\t\t\t */\n\t\t\t\tpoolBlacklist?: ObjectId[];\n\t\t }\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Optionally include only certain pools in routing.\n\t\t\t\t */\n\t\t\t\tpoolWhitelist?: ObjectId[];\n\t\t }\n\t);\n\n/**\n * Full body for router route construction. Either `coinInAmount` or `coinOutAmount`\n * must be specified, not both. If `coinOutAmount` is given, `slippage` is required.\n */\nexport type ApiRouterCompleteTradeRouteBody =\n\tApiRouterPartialCompleteTradeRouteBody &\n\t\t(\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * The amount of coin that the user wants to swap out.\n\t\t\t\t\t */\n\t\t\t\t\tcoinInAmount: Balance;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * The target output amount that the user wants to receive.\n\t\t\t\t\t */\n\t\t\t\t\tcoinOutAmount: Balance;\n\t\t\t\t\t/**\n\t\t\t\t\t * The user’s slippage tolerance (e.g., 0.01 = 1%).\n\t\t\t\t\t */\n\t\t\t\t\tslippage: Slippage;\n\t\t\t }\n\t\t);\n\n/**\n * Represents the information needed to create a transaction for a complete trade route.\n */\nexport interface ApiRouterTransactionForCompleteTradeRouteBody {\n\t/**\n\t * The Sui address initiating the trade.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The complete route object, typically returned by the route construction API.\n\t */\n\tcompleteRoute: RouterCompleteTradeRoute;\n\t/**\n\t * The allowable slippage tolerance for the entire route.\n\t */\n\tslippage: Slippage;\n\t/**\n\t * If `true`, indicates that the transaction fees may be sponsored by a third party.\n\t */\n\tisSponsoredTx?: boolean;\n\t/**\n\t * If specified, the traded output coins will be sent to this address.\n\t */\n\tcustomRecipient?: SuiAddress;\n}\n\n/**\n * Extended body that includes a serialized transaction for building a new\n * transaction with a trade route appended.\n */\nexport type ApiRouterAddTransactionForCompleteTradeRouteBody =\n\tApiRouterTransactionForCompleteTradeRouteBody & {\n\t\t/**\n\t\t * The already-serialized transaction to which the router instructions will be added.\n\t\t */\n\t\tserializedTx: SerializedTransaction;\n\t\t/**\n\t\t * Optional coin input ID if you are managing coin objects yourself.\n\t\t */\n\t\tcoinInId?: TransactionObjectArgument;\n\t};\n\n/**\n * The response returned after adding a trade route to an existing transaction.\n */\nexport interface ApiRouterAddTransactionForCompleteTradeRouteResponse {\n\t/**\n\t * The updated serialized transaction.\n\t */\n\ttx: SerializedTransaction;\n\t/**\n\t * A reference to the output coin after the swap. May be undefined if not applicable.\n\t */\n\tcoinOutId: TransactionObjectArgument | undefined;\n}\n\n/**\n * Body type used for retrieving router trade events for a particular user\n * from the indexer, with pagination.\n */\nexport type ApiRouterTradeEventsBody = ApiIndexerEventsBody & {\n\t/**\n\t * The wallet address whose trade events you want to retrieve.\n\t */\n\twalletAddress: SuiAddress;\n};\n\n/**\n * Represents data needed for dynamically estimating gas costs for a router trade,\n * including the coin type for gas, the coin amount out, sender address, and\n * an optional referrer or sponsor address.\n */\nexport interface ApiRouterDynamicGasBody {\n\t/**\n\t * The transaction bytes for the intended trade.\n\t */\n\ttxKindBytes: TxBytes;\n\t/**\n\t * The coin type to be used for gas (e.g., \"0x2::sui::SUI\").\n\t */\n\tgasCoinType: CoinType;\n\t/**\n\t * The coin data specifying the gas coin or a partial reference to it.\n\t */\n\tgasCoinData: ServiceCoinData;\n\t/**\n\t * The amount of coin that the user expects to receive out of the trade, in string form for BigInt.\n\t */\n\tcoinOutAmount: BigIntAsString;\n\t/**\n\t * The address of the sender who is initiating the transaction.\n\t */\n\tsenderAddress: SuiAddress;\n\t/**\n\t * The address of a sponsor for the transaction, if applicable.\n\t */\n\tsponsorAddress: SuiAddress;\n\t/**\n\t * Optional referrer address, if a referral mechanism is in place.\n\t */\n\treferrer?: SuiAddress;\n}\n","import { CoinType } from \"../..\";\nimport {\n\tApiEventsBody,\n\tBalance,\n\tEvent,\n\tObject as SuiObject,\n\tPercentage,\n\tTimestamp,\n\tObjectId,\n\tSuiAddress,\n\tTransactionDigest,\n\tExternalFee,\n} from \"../../general/types/generalTypes\";\n\n/**\n * Represents a validator's configuration object, including its Sui address,\n * operation cap ID, and fee percentage.\n */\nexport interface ValidatorConfigObject extends SuiObject {\n\t/**\n\t * The Sui address of the validator.\n\t */\n\tsuiAddress: SuiAddress;\n\t/**\n\t * The on-chain object ID referencing this validator's operation cap.\n\t */\n\toperationCapId: ObjectId;\n\t/**\n\t * The current fee percentage for this validator (0.01 = 1%).\n\t */\n\tfee: Percentage;\n}\n\n/**\n * Represents a validator's operation cap object, which authorizes changes to\n * validator settings like fees.\n */\nexport interface ValidatorOperationCapObject extends SuiObject {\n\t/**\n\t * The validator address authorized by this operation cap.\n\t */\n\tauthorizerValidatorAddress: SuiAddress;\n}\n\n/**\n * Represents the on-chain state of the stakedSui vault, which tracks liquidity\n * for atomic unstakes, total SUI amounts, rewards, and fees.\n */\nexport interface StakedSuiVaultStateObject extends SuiObject {\n\t/**\n\t * The target size for atomic unstake SUI reserves.\n\t */\n\tatomicUnstakeSuiReservesTargetValue: Balance;\n\t/**\n\t * The current size of the SUI reserves for atomic unstakes.\n\t */\n\tatomicUnstakeSuiReserves: Balance;\n\t/**\n\t * The minimum fee for atomic unstakes, expressed as a BigInt-based percentage\n\t * (e.g., 50000000n = 5% if using 1e9-based decimals).\n\t */\n\tminAtomicUnstakeFee: bigint;\n\t/**\n\t * The maximum fee for atomic unstakes.\n\t */\n\tmaxAtomicUnstakeFee: bigint;\n\t/**\n\t * The total amount of SUI rewards accumulated in the vault.\n\t */\n\ttotalRewardsAmount: Balance;\n\t/**\n\t * The total amount of SUI staked in the vault.\n\t */\n\ttotalSuiAmount: Balance;\n\t/**\n\t * The current epoch number, as a BigInt.\n\t */\n\tactiveEpoch: bigint;\n}\n\n/**\n * Represents a dynamic field holding a stake balance. Useful for tracking\n * on-chain data related to a specific stake or delegator.\n */\nexport interface StakeBalanceDynamicField {\n\t/**\n\t * The on-chain object ID of this stake balance record.\n\t */\n\tobjectId: ObjectId;\n\t/**\n\t * The amount of SUI (or afSUI) represented by this field, expressed as a bigint.\n\t */\n\tvalue: Balance;\n}\n\n/**\n * Enumerates the possible states of a delegated stake on the Sui network.\n *\n * - **Active**: The stake is actively earning rewards.\n * - **Pending**: The stake has been requested but not yet activated.\n * - **Unstaked**: The stake has been removed or the SUI is no longer earning rewards.\n */\nexport type SuiDelegatedStakeState = \"Active\" | \"Pending\" | \"Unstaked\";\n\n/**\n * Represents a delegated stake object in the Sui network. Unlike local\n * Aftermath-specific stake positions, this is a more general Sui system stake\n * that can earn protocol-level rewards.\n */\nexport interface SuiDelegatedStake {\n\t/**\n\t * The current state of the delegated stake (e.g., Active, Pending, Unstaked).\n\t */\n\tstatus: SuiDelegatedStakeState;\n\t/**\n\t * The on-chain ID representing this stake position.\n\t */\n\tstakedSuiId: ObjectId;\n\t/**\n\t * The epoch in which this stake request was made.\n\t */\n\tstakeRequestEpoch: bigint;\n\t/**\n\t * The epoch in which this stake became (or will become) active.\n\t */\n\tstakeActiveEpoch: bigint;\n\t/**\n\t * The principal amount of SUI delegated.\n\t */\n\tprincipal: Balance;\n\t/**\n\t * The estimated rewards accumulated for this stake, if available.\n\t */\n\testimatedReward?: Balance | undefined;\n\t/**\n\t * The validator to which this stake is delegated.\n\t */\n\tvalidatorAddress: SuiAddress;\n\t/**\n\t * The staking pool on-chain object that manages this stake.\n\t */\n\tstakingPool: SuiAddress;\n}\n\n/**\n * A type guard utility function to check if a position is a native Sui delegated stake\n * (`SuiDelegatedStake`) rather than an Aftermath-specific `StakingPosition`.\n *\n * @param stake - An object that could be either a `StakingPosition` or a `SuiDelegatedStake`.\n * @returns True if the object matches the shape of `SuiDelegatedStake`; otherwise, false.\n */\nexport const isSuiDelegatedStake = (\n\tstake: StakingPosition | SuiDelegatedStake\n): stake is SuiDelegatedStake => {\n\treturn (\n\t\t\"stakeRequestEpoch\" in stake &&\n\t\t\"stakeActiveEpoch\" in stake &&\n\t\t\"principal\" in stake &&\n\t\t\"stakingPool\" in stake\n\t);\n};\n\n/**\n * Represents a single entry in the historical APY data, including a Unix\n * timestamp and an APY value.\n */\nexport interface StakingApyDataPoint {\n\t/**\n\t * The Unix timestamp (in milliseconds or seconds) of the data point.\n\t */\n\ttimestamp: Timestamp;\n\t/**\n\t * The APY value recorded at that time (e.g., 0.045 = 4.5%).\n\t */\n\tapy: number;\n}\n\n/**\n * Enumerates the timeframes available for retrieving historical APY data,\n * such as `\"1W\"`, `\"1M\"`, `\"1Y\"`, etc.\n */\nexport type StakingApyTimeframeKey = \"1W\" | \"1M\" | \"3M\" | \"6M\" | \"1Y\" | \"ALL\";\n\n/* -------------------------------------------------------------------------- */\n/* EVENT INTERFACES */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Represents an event when SUI has been staked, either newly or restaked.\n */\nexport interface StakedEvent extends Event {\n\t/**\n\t * The on-chain object ID referencing the newly created staked SUI object.\n\t */\n\tstakedSuiId: ObjectId;\n\t/**\n\t * The original SUI coin ID used for staking.\n\t */\n\tsuiId: ObjectId;\n\t/**\n\t * The address of the user who performed the staking.\n\t */\n\tstaker: SuiAddress;\n\t/**\n\t * The validator address to which the user staked.\n\t */\n\tvalidatorAddress: SuiAddress;\n\t/**\n\t * The epoch in which staking took place.\n\t */\n\tepoch: bigint;\n\t/**\n\t * The amount of SUI staked.\n\t */\n\tsuiStakeAmount: Balance;\n\t/**\n\t * The validator fee percentage for this stake (0.01 = 1%).\n\t */\n\tvalidatorFee: number;\n\t/**\n\t * Indicates whether this stake is a restake of an already staked position.\n\t */\n\tisRestaked: boolean;\n\t/**\n\t * The on-chain ID of the afSUI object received in exchange for staking.\n\t */\n\tafSuiId: ObjectId;\n\t/**\n\t * The amount of afSUI received.\n\t */\n\tafSuiAmount: Balance;\n\t/**\n\t * (Optional) Referrer address for the stake.\n\t */\n\treferrer?: SuiAddress;\n}\n\n/**\n * Represents an event when a user initiates an unstake request, converting\n * afSUI back into SUI.\n */\nexport interface UnstakeRequestedEvent extends Event {\n\t/**\n\t * The afSUI ID being provided to unstake.\n\t */\n\tafSuiId: ObjectId;\n\t/**\n\t * The amount of afSUI provided by the user.\n\t */\n\tprovidedAfSuiAmount: Balance;\n\t/**\n\t * The address requesting the unstake.\n\t */\n\trequester: SuiAddress;\n\t/**\n\t * The epoch in which the unstake was requested.\n\t */\n\tepoch: bigint;\n}\n\n/**\n * Represents an event after an unstake has fully processed and SUI has\n * been returned to the user.\n */\nexport interface UnstakedEvent extends Event {\n\t/**\n\t * The afSUI ID that was burned or converted during the unstake.\n\t */\n\tafSuiId: ObjectId;\n\t/**\n\t * The amount of afSUI provided.\n\t */\n\tprovidedAfSuiAmount: Balance;\n\t/**\n\t * The resulting SUI coin ID received by the user.\n\t */\n\tsuiId: ObjectId;\n\t/**\n\t * The amount of SUI returned.\n\t */\n\treturnedSuiAmount: Balance;\n\t/**\n\t * The address that initiated the unstake.\n\t */\n\trequester: SuiAddress;\n\t/**\n\t * The epoch in which the unstake finalized.\n\t */\n\tepoch: bigint;\n}\n\n/**\n * Represents a union type covering all possible unstake events, either\n * requested or finalized.\n */\nexport type UnstakeEvent = UnstakeRequestedEvent | UnstakedEvent;\n\n/**\n * Type guard to check if an event is a `StakedEvent`.\n */\nexport const isStakeEvent = (\n\tevent: StakeEvent | UnstakeEvent\n): event is StakeEvent => {\n\treturn \"staker\" in event;\n};\n\n/**\n * Type guard to check if an event is an `UnstakeEvent`.\n */\nexport const isUnstakeEvent = (\n\tevent: StakeEvent | UnstakeEvent\n): event is UnstakeEvent => {\n\treturn !isStakeEvent(event);\n};\n\n/**\n * Represents an event that indicates the epoch has changed, generally used\n * for distributing rewards and updating positions.\n */\nexport interface EpochWasChangedEvent extends Event {\n\t/**\n\t * The new active epoch as a BigInt.\n\t */\n\tactiveEpoch: bigint;\n\t/**\n\t * The total amount of afSUI in circulation.\n\t */\n\ttotalAfSuiSupply: Balance;\n\t/**\n\t * The total amount of SUI rewards accrued in the system.\n\t */\n\ttotalSuiRewardsAmount: Balance;\n\t/**\n\t * The total amount of SUI staked in the system.\n\t */\n\ttotalSuiAmount: Balance;\n}\n\n/**\n * Union type for stake events, which can represent any variant of staking.\n */\nexport type StakeEvent = StakedEvent;\n\n/* -------------------------------------------------------------------------- */\n/* STAKING POSITIONS TYPES */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Represents a user's staking position, which could be either a `StakePosition`\n * or an `UnstakePosition`.\n */\nexport type StakingPosition = StakePosition | UnstakePosition;\n\n/**\n * Indicates a stake position, typically representing active or restaked SUI,\n * along with its associated `afSuiAmount`.\n */\nexport interface StakePosition {\n\t/**\n\t * The staked SUI object ID referencing this position.\n\t */\n\tstakedSuiId: ObjectId;\n\t/**\n\t * The original SUI coin ID.\n\t */\n\tsuiId: ObjectId;\n\t/**\n\t * The address of the staker.\n\t */\n\tstaker: SuiAddress;\n\t/**\n\t * The address of the validator to which SUI was staked.\n\t */\n\tvalidatorAddress: SuiAddress;\n\t/**\n\t * The epoch in which the stake was established.\n\t */\n\tepoch: bigint;\n\t/**\n\t * The amount of SUI staked.\n\t */\n\tsuiStakeAmount: Balance;\n\t/**\n\t * The validator fee percentage (0.01 = 1%).\n\t */\n\tvalidatorFee: number;\n\t/**\n\t * Indicates if this stake is a restake operation.\n\t */\n\tisRestaked: boolean;\n\t/**\n\t * The afSUI object ID generated from staking.\n\t */\n\tafSuiId: ObjectId;\n\t/**\n\t * The amount of afSUI issued to the user.\n\t */\n\tafSuiAmount: Balance;\n\t/**\n\t * The timestamp when the stake was recorded.\n\t */\n\ttimestamp: Timestamp | undefined;\n\t/**\n\t * The transaction digest where the stake operation occurred.\n\t */\n\ttxnDigest: TransactionDigest;\n}\n\n/**\n * Indicates a position related to an unstake operation, either requested or\n * finalized, with optional references to the returned SUI coin and amount.\n */\nexport interface UnstakePosition {\n\t/**\n\t * The state of the unstake operation: `REQUEST` (in progress) or\n\t * `SUI_MINTED` (finalized).\n\t */\n\tstate: UnstakePositionState;\n\t/**\n\t * The afSUI object ID being burned or converted.\n\t */\n\tafSuiId: ObjectId;\n\t/**\n\t * The amount of afSUI used to initiate the unstake.\n\t */\n\tprovidedAfSuiAmount: Balance;\n\t/**\n\t * The address of the requester.\n\t */\n\trequester: SuiAddress;\n\t/**\n\t * The epoch in which the unstake was requested or finalized.\n\t */\n\tepoch: bigint;\n\t/**\n\t * The SUI object ID returned to the user, if unstake has finalized.\n\t */\n\tsuiId?: ObjectId;\n\t/**\n\t * The amount of SUI returned to the user, if unstake has finalized.\n\t */\n\treturnedSuiAmount?: Balance;\n\t/**\n\t * The timestamp when the unstake request was recorded or completed.\n\t */\n\ttimestamp: Timestamp | undefined;\n\t/**\n\t * The transaction digest where the unstake operation occurred.\n\t */\n\ttxnDigest: TransactionDigest;\n}\n\n/**\n * Enumerates the possible states of an unstake operation.\n */\nexport type UnstakePositionState = \"REQUEST\" | \"SUI_MINTED\";\n\n/**\n * Type guard that checks whether a given `StakingPosition` is a stake position.\n */\nexport const isStakePosition = (\n\tposition: StakingPosition\n): position is StakePosition => {\n\treturn \"stakedSuiId\" in position;\n};\n\n/**\n * Type guard that checks whether a given `StakingPosition` is an unstake position.\n */\nexport const isUnstakePosition = (\n\tposition: StakingPosition\n): position is UnstakePosition => {\n\treturn !isStakePosition(position);\n};\n\n/* -------------------------------------------------------------------------- */\n/* API BODY INTERFACES */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Body payload for staking SUI.\n */\nexport interface ApiStakeBody {\n\t/**\n\t * The address performing the stake.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The amount of SUI to be staked.\n\t */\n\tsuiStakeAmount: Balance;\n\t/**\n\t * The validator address to stake with.\n\t */\n\tvalidatorAddress: SuiAddress;\n\t/**\n\t * Optional address indicating a referrer.\n\t */\n\treferrer?: SuiAddress;\n\t/**\n\t * Optional external fee object. Must not exceed `maxExternalFeePercentage`.\n\t */\n\texternalFee?: ExternalFee;\n\t/**\n\t * Indicates whether the transaction should be sponsored.\n\t */\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Body payload for unstaking SUI (afSUI -> SUI).\n */\nexport interface ApiUnstakeBody {\n\t/**\n\t * The address performing the unstake.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The amount of afSUI to be unstaked.\n\t */\n\tafSuiUnstakeAmount: Balance;\n\t/**\n\t * If true, the unstake is done atomically if possible, using liquidity reserves.\n\t */\n\tisAtomic: boolean;\n\t/**\n\t * Optional address indicating a referrer.\n\t */\n\treferrer?: SuiAddress;\n\t/**\n\t * Optional external fee object. Must not exceed `maxExternalFeePercentage`.\n\t */\n\texternalFee?: ExternalFee;\n\t/**\n\t * Indicates whether the transaction should be sponsored.\n\t */\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Body payload for staking stakedSUI objects (re-staking).\n */\nexport interface ApiStakeStakedSuiBody {\n\t/**\n\t * The address performing the re-stake.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * An array of stakedSui object IDs to re-stake.\n\t */\n\tstakedSuiIds: ObjectId[];\n\t/**\n\t * The validator address to stake with.\n\t */\n\tvalidatorAddress: SuiAddress;\n\t/**\n\t * Optional address indicating a referrer.\n\t */\n\treferrer?: SuiAddress;\n\t/**\n\t * Indicates whether the transaction should be sponsored.\n\t */\n\tisSponsoredTx?: boolean;\n}\n\n/**\n * Body payload for updating a validator's fee settings.\n */\nexport interface ApiUpdateValidatorFeeBody {\n\t/**\n\t * The address submitting the update transaction.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * The operation cap object ID that authorizes changes to this validator.\n\t */\n\tvalidatorOperationCapId: ObjectId;\n\t/**\n\t * The new fee percentage to be set (0.01 = 1%).\n\t */\n\tnewFeePercentage: Percentage;\n\t/**\n\t * Indicates whether the transaction should be sponsored.\n\t */\n\tisSponsoredTx?: boolean;\n}\n\n/* -------------------------------------------------------------------------- */\n/* OBJECTS API BODIES */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Body payload for retrieving staking positions, including pagination.\n */\nexport interface ApiStakingPositionsBody {\n\t/**\n\t * The address whose staking positions are being queried.\n\t */\n\twalletAddress: SuiAddress;\n\t/**\n\t * Optional cursor for pagination.\n\t */\n\tcursor?: number;\n\t/**\n\t * Optional limit on the number of positions returned.\n\t */\n\tlimit?: number;\n}\n\n/**\n * Body payload for retrieving delegated stakes, given a wallet address.\n */\nexport interface ApiDelegatedStakesBody {\n\t/**\n\t * The address whose delegated stakes are being queried.\n\t */\n\twalletAddress: SuiAddress;\n}\n\n/**\n * Body payload for retrieving validator operation caps, given a wallet address.\n */\nexport interface ApiValidatorOperationCapsBody {\n\t/**\n\t * The address whose validator operation caps are being queried.\n\t */\n\twalletAddress: SuiAddress;\n}\n\n/* -------------------------------------------------------------------------- */\n/* EVENTS API */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Body payload for retrieving staking-related events, including pagination.\n */\nexport type ApiStakingEventsBody = ApiEventsBody & {\n\t/**\n\t * The address whose events are being queried.\n\t */\n\twalletAddress: SuiAddress;\n};\n\n/* -------------------------------------------------------------------------- */\n/* ROUTER POOL TYPE */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Extends the `StakedSuiVaultStateObject` with additional fields relevant\n * to the router pool. This includes the coin type for afSUI, the configured\n * validator address, and the current exchange rate.\n */\nexport type AfSuiRouterPoolObject = StakedSuiVaultStateObject & {\n\t/**\n\t * The coin type string for afSUI (e.g., \"0x<package>::afSUI::AFSUI\").\n\t */\n\tafSuiCoinType: CoinType;\n\t/**\n\t * The official Aftermath validator address.\n\t */\n\taftermathValidatorAddress: SuiAddress;\n\t/**\n\t * The current exchange rate from afSUI to SUI.\n\t */\n\tafSuiToSuiExchangeRate: number;\n};\n","import {\n\tAnyObjectType,\n\tBalance,\n\tEvent,\n\tObject,\n\tTimestamp,\n\tUrl,\n\tObjectId,\n\tSuiAddress,\n} from \"../../general/types/generalTypes\";\n\n// =========================================================================\n// Name Only\n// =========================================================================\n\nexport type SuiFrenAccessoryType = string;\nexport type SuiFrenAccessoryName = string;\n\n// =========================================================================\n// Objects\n// =========================================================================\n\nexport interface CapyLabsAppObject extends Object {\n\tmixingLimit: bigint;\n\tcoolDownPeriodEpochs: bigint;\n\tmixingPrice: Balance;\n\tsuiProfits: Balance;\n}\n\nexport interface SuiFrenObject extends Object {\n\t// object fields\n\tgeneration: bigint;\n\tbirthdate: Timestamp;\n\tcohort: bigint;\n\tgenes: bigint[];\n\tattributes: SuiFrenAttributes;\n\tbirthLocation: string;\n\n\t// dynamic fields\n\tmixLimit?: bigint;\n\tlastEpochMixed?: bigint;\n\n\t// display fields\n\tdisplay: {\n\t\tlink: Url;\n\t\timageUrl: Url;\n\t\tdescription: string;\n\t\tprojectUrl: Url;\n\t};\n}\n\nexport type PartialSuiFrenObject = Omit<\n\tSuiFrenObject,\n\t\"mixLimit\" | \"lastEpochMixed\"\n>;\n\nexport type SuiFrenAttributes = {\n\tskin: \"stripes\" | \"cheetah\";\n\tmain: \"6FBBEE\";\n\tsecondary: \"CF9696\";\n\texpression: \"bigSmile\";\n\tears: \"ear1\";\n};\n\nexport enum SuiFrensSortOption {\n\tPriceLowToHigh = \"Price (low to high)\",\n\tPriceHighToLow = \"Price (high to low)\",\n}\n\nexport interface StakedSuiFrenInfo {\n\tsuiFren: SuiFrenObject;\n\tmetadata: StakedSuiFrenMetadataV1Object;\n\tposition?: StakedSuiFrenPositionObject;\n}\n\nexport interface StakedSuiFrenPositionObject extends Object {\n\tsuiFrenId: ObjectId;\n}\n\nexport interface StakedSuiFrenMetadataV1Object extends Object {\n\tsuiFrenId: ObjectId;\n\tcollectedFees: Balance;\n\tautoStakeFees: boolean;\n\tmixFee: Balance;\n\tfeeIncrementPerMix: Balance;\n\tminRemainingMixesToKeep: bigint;\n}\n\nexport interface SuiFrenVaultStateV1Object extends Object {\n\tstakedSuiFrens: bigint;\n\ttotalMixes: bigint;\n}\n\nexport interface SuiFrenAccessoryObject extends Object {\n\tname: SuiFrenAccessoryName;\n\ttype: SuiFrenAccessoryType;\n\timageUrl: Url;\n}\n\n// =========================================================================\n// Events\n// =========================================================================\n\nexport interface HarvestSuiFrenFeesEvent extends Event {\n\tharvester: SuiAddress;\n\tfees: bigint;\n}\n\nexport interface StakeSuiFrenEvent extends Event {\n\tstaker: SuiAddress;\n\tsuiFrenId: ObjectId;\n}\n\nexport interface UnstakeSuiFrenEvent extends Event {\n\tunstaker: SuiAddress;\n\tsuiFrenId: ObjectId;\n\tfees: Balance;\n}\n\nexport interface MixSuiFrensEvent extends Event {\n\tmixer: SuiAddress;\n\tparentOneId: ObjectId;\n\tparentTwoId: ObjectId;\n\tchildId: ObjectId;\n\tfee: Balance;\n}\n\n// =========================================================================\n// Stats\n// =========================================================================\n\nexport interface SuiFrenStats {\n\ttotalMixes: bigint;\n\tcurrentTotalStaked: bigint;\n\tmixingFees24hr: Balance;\n\tmixingVolume24hr: number;\n}\n\n// =========================================================================\n// API\n// =========================================================================\n\nexport interface ApiStakeSuiFrenBody {\n\tsuiFrenId: ObjectId;\n\tbaseFee: Balance;\n\tfeeIncrementPerMix: Balance;\n\tminRemainingMixesToKeep: bigint;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiUnstakeSuiFrenBody {\n\tstakedPositionId: ObjectId;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiMixSuiFrensBody {\n\tsuiFrenParentOne: {\n\t\tobjectId: ObjectId;\n\t\tmixFee: Balance | undefined;\n\t};\n\tsuiFrenParentTwo: {\n\t\tobjectId: ObjectId;\n\t\tmixFee: Balance | undefined;\n\t};\n\tbaseFee: Balance;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n\tisSponsoredTx?: boolean;\n}\n\nexport interface ApiHarvestSuiFrenFeesBody {\n\tstakedPositionIds: ObjectId[];\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiAddSuiFrenAccessoryBody {\n\tsuiFrenId: ObjectId;\n\taccessoryId: ObjectId;\n\tisOwned: boolean;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n}\n\nexport type ApiRemoveSuiFrenAccessoryBody = {\n\taccessoryType: SuiFrenAccessoryType;\n\tsuiFrenType: AnyObjectType;\n\twalletAddress: SuiAddress;\n} & (\n\t| {\n\t\t\tsuiFrenId: ObjectId;\n\t }\n\t| {\n\t\t\tstakedPositionId: ObjectId;\n\t }\n);\n\nexport interface ApiAccessoriesForSuiFrenBody {\n\tsuiFrenId: ObjectId;\n}\n\nexport interface ApiOwnedSuiFrenAccessoriesBody {\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiOwnedSuiFrensBody {\n\twalletAddress: SuiAddress;\n}\n\nexport interface ApiOwnedStakedSuiFrensBody {\n\twalletAddress: SuiAddress;\n}\n","// TODO: make it so that casting types are not exported ?\nexport * from \"./general/types\";\nexport * from \"./packages/auth/authTypes\";\nexport * from \"./packages/coin/coinTypes\";\nexport * from \"./packages/farms/farmsTypes\";\nexport * from \"./packages/faucet/faucetTypes\";\nexport * from \"./packages/nftAmm/nftAmmTypes\";\nexport * from \"./packages/perpetuals/perpetualsTypes\";\nexport * from \"./packages/pools/poolsTypes\";\nexport * from \"./packages/referrals/referralsTypes\";\nexport * from \"./packages/rewards/rewardsTypes\";\nexport * from \"./packages/router/routerTypes\";\nexport * from \"./packages/staking/stakingTypes\";\nexport * from \"./packages/suiFrens/suiFrensTypes\";\n","import { AftermathApi, Casting, Coin, Helpers, PerpetualsAccount } from \"../..\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { FixedUtils } from \"../../general/utils/fixedUtils\";\nimport { IFixedUtils } from \"../../general/utils/iFixedUtils\";\nimport {\n\tApiIndexerEventsBody,\n\tApiPerpetualsExecutionPriceBody,\n\tApiPerpetualsExecutionPriceResponse,\n\tCoinType,\n\tFilledMakerOrdersEvent,\n\tFilledTakerOrderEvent,\n\tObjectId,\n\tPerpetualsMarketCandleDataPoint,\n\tPerpetualsMarketId,\n\tPerpetualsMarketParams,\n\tPerpetualsMarketState,\n\tPerpetualsOrderData,\n\tPerpetualsOrderId,\n\tPerpetualsOrderPrice,\n\tPerpetualsOrderSide,\n\tPerpetualsOrderbook,\n\tPerpetualsPosition,\n\tSuiNetwork,\n\tTimestamp,\n\tUrl,\n\tPerpetualsMarketData,\n\tBalance,\n\tPerpetualsFilledOrderData,\n\tApiPerpetualsMaxOrderSizeBody,\n\tApiPerpetualsMarkets24hrStatsResponse,\n\tApiDataWithCursorBody,\n\tApiPerpetualsMarketOrderHistoryResponse,\n\tCallerConfig,\n\tPercentage,\n\tApiPerpetualsPreviewPlaceOrderResponse,\n\tPerpetualsMarket24hrStats,\n\tApiPerpetualsPreviewPlaceLimitOrderBody,\n\tSdkPerpetualsPlaceLimitOrderPreviewInputs,\n\tApiPerpetualsPreviewPlaceMarketOrderBody,\n\tSdkPerpetualsPlaceMarketOrderPreviewInputs,\n\tPerpetualsAccountId,\n\tApiPerpetualsMarketOrderHistoryBody,\n\tApiPerpetualsMarketsResponse,\n\tApiPerpetualsMarketsBody,\n\tApiPerpetualsOrderbooksResponse,\n\tApiPerpetualsOrderbooksBody,\n} from \"../../types\";\nimport { Perpetuals } from \"./perpetuals\";\nimport { PerpetualsOrderUtils } from \"./utils\";\n\n/**\n * High-level wrapper around a single perpetuals market.\n *\n * This class provides:\n *\n * - Lightweight accessors for immutable market properties:\n * - `marketId`, `indexPrice`, `collateralPrice`, `collateralCoinType`\n * - `marketParams`, `marketState`\n * - Read endpoints for:\n * - Orderbook snapshots\n * - 24h stats and order history\n * - Market prices and derived funding metrics\n * - Helpers for:\n * - Order sizing (max size, lot/tick rounding)\n * - Margin and collateral calculations\n * - Constructing an “empty” position for a market\n *\n * Typical usage:\n *\n * ```ts\n * const perps = new Perpetuals(config);\n * const { markets } = await perps.getMarkets({ marketIds: [\"0x...\"] });\n * const market = markets[0];\n *\n * const { orderbook } = await market.getOrderbook();\n * const stats = await market.get24hrStats();\n * const { basePrice, collateralPrice } = await market.getPrices();\n * ```\n */\nexport class PerpetualsMarket extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/** Unique identifier for this perpetuals market (object ID on chain). */\n\tpublic readonly marketId: PerpetualsMarketId;\n\n\t/**\n\t * Current oracle/index price for the market's underlying asset, quoted in\n\t * the index unit (typically USD).\n\t */\n\tpublic readonly indexPrice: number;\n\n\t/**\n\t * Current price of the collateral asset in USD (or the platform's base\n\t * pricing unit).\n\t */\n\tpublic readonly collateralPrice: number;\n\n\t/** Sui type of the collateral coin (e.g. `\"0x2::sui::SUI\"`). */\n\tpublic readonly collateralCoinType: CoinType;\n\n\t/** Static market configuration parameters (lot size, tick size, margins, etc.). */\n\tpublic readonly marketParams: PerpetualsMarketParams;\n\n\t/** Dynamic market state (funding rates, open interest, etc.). */\n\tpublic readonly marketState: PerpetualsMarketState;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Create a new {@link PerpetualsMarket} wrapper from raw market data.\n\t *\n\t * @param marketData - Snapshot of market configuration and state.\n\t * @param config - Optional {@link CallerConfig} (network, base URL, etc.).\n\t * @param Provider - Optional shared {@link AftermathApi} provider instance.\n\t *\n\t * @remarks\n\t * This class extends {@link Caller} with the `\"perpetuals\"` route prefix, meaning\n\t * all HTTP requests resolve under `/perpetuals/...`.\n\t */\n\tconstructor(\n\t\tpublic marketData: PerpetualsMarketData,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"perpetuals\");\n\t\tthis.marketId = marketData.objectId;\n\t\tthis.indexPrice = marketData.indexPrice;\n\t\tthis.collateralPrice = marketData.collateralPrice;\n\t\tthis.collateralCoinType = marketData.collateralCoinType;\n\t\tthis.marketParams = marketData.marketParams;\n\t\tthis.marketState = marketData.marketState;\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Fetch the 24-hour volume and price change statistics for this market.\n\t *\n\t * Under the hood, this calls {@link Perpetuals.getMarkets24hrStats} and\n\t * returns the first (and only) entry.\n\t *\n\t * @returns {@link PerpetualsMarket24hrStats}.\n\t *\n\t * @remarks\n\t * This method creates a new {@link Perpetuals} instance using `this.config`.\n\t * If you need shared Provider behavior, prefer calling `perps.getMarkets24hrStats`\n\t * directly with the same Provider you initialized.\n\t */\n\tpublic async get24hrStats(): Promise<PerpetualsMarket24hrStats> {\n\t\tconst res = await new Perpetuals(this.config).getMarkets24hrStats({\n\t\t\tmarketIds: [this.marketId],\n\t\t});\n\t\treturn res.marketsStats[0];\n\t}\n\n\t/**\n\t * Fetch the full orderbook snapshot for this market.\n\t *\n\t * @returns Object containing `orderbook`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { orderbook } = await market.getOrderbook();\n\t * console.log(orderbook.bids[0], orderbook.asks[0]);\n\t * ```\n\t */\n\t// TODO: move to `Perpetuals` class ?\n\tpublic async getOrderbook(): Promise<{\n\t\torderbook: PerpetualsOrderbook;\n\t}> {\n\t\tconst { orderbooks } = await this.fetchApi<\n\t\t\tApiPerpetualsOrderbooksResponse,\n\t\t\tApiPerpetualsOrderbooksBody\n\t\t>(\"markets/orderbooks\", {\n\t\t\tmarketIds: [this.marketId],\n\t\t});\n\t\treturn {\n\t\t\torderbook: orderbooks[0].orderbook,\n\t\t};\n\t}\n\n\t/**\n\t * Compute the maximum order size that can be placed by a given account\n\t * in this market, under optional leverage and price assumptions.\n\t *\n\t * This is a common frontend helper for:\n\t * - \"max size\" buttons\n\t * - input validation against risk limits\n\t *\n\t * **Note:** This is routed through the `account` namespace because it depends on\n\t * the account's collateral and positions.\n\t *\n\t * @param inputs.accountId - Perpetuals account ID.\n\t * @param inputs.side - Order side (Bid/Ask).\n\t * @param inputs.leverage - Optional assumed leverage.\n\t * @param inputs.price - Optional assumed price (e.g. for limit orders).\n\t *\n\t * @returns `{ maxOrderSize }` in base units (scaled integer as `bigint`).\n\t *\n\t * @example\n\t * ```ts\n\t * const { maxOrderSize } = await market.getMaxOrderSize({\n\t * accountId: 123n,\n\t * side: PerpetualsOrderSide.Bid,\n\t * leverage: 5,\n\t * });\n\t * ```\n\t */\n\t// TODO: move/add to account ?\n\tpublic getMaxOrderSize = async (\n\t\tinputs: Omit<ApiPerpetualsMaxOrderSizeBody, \"marketId\">\n\t) => {\n\t\treturn this.fetchApi<\n\t\t\t{\n\t\t\t\tmaxOrderSize: bigint;\n\t\t\t},\n\t\t\tApiPerpetualsMaxOrderSizeBody\n\t\t>(\"account/max-order-size\", {\n\t\t\t...inputs,\n\t\t\tmarketId: this.marketId,\n\t\t});\n\t};\n\n\t/**\n\t * Market-level preview of placing a market order.\n\t *\n\t * Unlike {@link PerpetualsAccount.getPlaceMarketOrderPreview}, this version:\n\t * - Calls `account/previews/place-market-order`\n\t * - Explicitly sets `accountId: undefined`, allowing a “generic” preview that\n\t * doesn’t rely on a specific account’s on-chain positions/collateral.\n\t *\n\t * @param inputs - {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.\n\t * @param abortSignal - Optional abort signal to cancel the request.\n\t *\n\t * @returns Either `{ error }` or a preview containing the simulated updated position,\n\t * slippage, filled/posted sizes, collateral change, and execution price.\n\t */\n\tpublic async getPlaceMarketOrderPreview(\n\t\tinputs: SdkPerpetualsPlaceMarketOrderPreviewInputs,\n\t\tabortSignal?: AbortSignal\n\t): Promise<ApiPerpetualsPreviewPlaceOrderResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewPlaceOrderResponse,\n\t\t\tApiPerpetualsPreviewPlaceMarketOrderBody\n\t\t>(\n\t\t\t\"account/previews/place-market-order\",\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\taccountId: undefined,\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t/**\n\t * Market-level preview of placing a limit order.\n\t *\n\t * Similar to {@link getPlaceMarketOrderPreview}, this uses:\n\t * - `account/previews/place-limit-order`\n\t * - `accountId: undefined`\n\t *\n\t * @param inputs - {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.\n\t * @param abortSignal - Optional abort signal to cancel the request.\n\t *\n\t * @returns Either `{ error }` or a preview describing the simulated post-order state.\n\t */\n\tpublic async getPlaceLimitOrderPreview(\n\t\tinputs: SdkPerpetualsPlaceLimitOrderPreviewInputs,\n\t\tabortSignal?: AbortSignal\n\t): Promise<ApiPerpetualsPreviewPlaceOrderResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewPlaceOrderResponse,\n\t\t\tApiPerpetualsPreviewPlaceLimitOrderBody\n\t\t>(\n\t\t\t\"account/previews/place-limit-order\",\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\taccountId: undefined,\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Order History\n\t// =========================================================================\n\n\t/**\n\t * Fetch paginated order history for this market.\n\t *\n\t * This is market-wide (public) history, not scoped to any account.\n\t *\n\t * @param inputs.beforeTimestampCursor - Optional pagination cursor.\n\t * @param inputs.limit - Optional page size.\n\t *\n\t * @returns {@link ApiPerpetualsMarketOrderHistoryResponse} containing:\n\t * - `orders`\n\t * - `nextBeforeTimestampCursor`\n\t */\n\tpublic async getOrderHistory(\n\t\tinputs: Omit<ApiPerpetualsMarketOrderHistoryBody, \"marketId\">\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsMarketOrderHistoryResponse,\n\t\t\tApiPerpetualsMarketOrderHistoryBody\n\t\t>(\"market/order-history\", {\n\t\t\t...inputs,\n\t\t\tmarketId: this.marketId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Prices\n\t// =========================================================================\n\n\t/**\n\t * Fetch the current prices for this market.\n\t *\n\t * Internally calls {@link Perpetuals.getPrices} and returns the first result.\n\t *\n\t * @returns `{ marketId, basePrice, collateralPrice, midPrice, markPrice }`.\n\t *\n\t * @remarks\n\t * This method instantiates a new {@link Perpetuals} client using `this.config`.\n\t * If you rely on a shared Provider, call `perps.getPrices(...)` directly instead.\n\t */\n\tpublic async getPrices(): Promise<{\n\t\tmarketId: PerpetualsMarketId;\n\t\tbasePrice: number;\n\t\tcollateralPrice: number;\n\t\tmidPrice: number | undefined;\n\t\tmarkPrice: number;\n\t}> {\n\t\treturn (\n\t\t\tawait new Perpetuals(this.config).getPrices({\n\t\t\t\tmarketIds: [this.marketId],\n\t\t\t})\n\t\t).marketsPrices[0];\n\t}\n\n\t// =========================================================================\n\t// Funding / Timing\n\t// =========================================================================\n\n\t/**\n\t * Compute the remaining time until the next funding event, in milliseconds.\n\t *\n\t * @returns `nextFundingTimeMs() - Date.now()`.\n\t *\n\t * @remarks\n\t * If the next funding timestamp does not fit safely into a JS `number`,\n\t * {@link nextFundingTimeMs} returns `Number.MAX_SAFE_INTEGER`, and the\n\t * difference may be very large.\n\t */\n\tpublic timeUntilNextFundingMs = (): Timestamp => {\n\t\treturn this.nextFundingTimeMs() - Date.now();\n\t};\n\n\t/**\n\t * Get the scheduled timestamp for the next funding event, in milliseconds.\n\t *\n\t * Safety behavior:\n\t * - If `marketData.nextFundingTimestampMs` exceeds `Number.MAX_SAFE_INTEGER`,\n\t * this returns `Number.MAX_SAFE_INTEGER`.\n\t *\n\t * @returns Next funding timestamp (ms) as a JS `number`.\n\t */\n\tpublic nextFundingTimeMs = (): Timestamp => {\n\t\treturn this.marketData.nextFundingTimestampMs >\n\t\t\tBigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? Number.MAX_SAFE_INTEGER\n\t\t\t: Number(this.marketData.nextFundingTimestampMs);\n\t};\n\n\t/**\n\t * Estimated funding rate per period for this market.\n\t *\n\t * This is read directly from `marketData.estimatedFundingRate`.\n\t *\n\t * @returns Estimated funding rate as a fraction (e.g. `0.01` = 1%).\n\t */\n\tpublic estimatedFundingRate = (): Percentage => {\n\t\treturn this.marketData.estimatedFundingRate;\n\t};\n\n\t// =========================================================================\n\t// Margin / Collateral Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculate the collateral required to support an order given leverage and prices.\n\t *\n\t * The computed collateral is based on the *remaining* unfilled size:\n\t * `remaining = initialSize - filledSize`.\n\t *\n\t * USD requirement:\n\t * ```text\n\t * remainingBase * indexPrice * initialMarginRatio\n\t * ```\n\t * where `initialMarginRatio = 1 / leverage` (or 1 if leverage is falsy).\n\t *\n\t * @param inputs.leverage - Target leverage for the order (>= 1).\n\t * @param inputs.orderData - Order data containing `initialSize` and `filledSize`.\n\t * @param inputs.indexPrice - Index/oracle price of the base asset.\n\t * @param inputs.collateralPrice - Price of the collateral asset.\n\t *\n\t * @returns Object with:\n\t * - `collateralUsd`: required collateral in USD\n\t * - `collateral`: required collateral in collateral coin units\n\t */\n\tpublic calcCollateralUsedForOrder = (inputs: {\n\t\tleverage: number;\n\t\torderData: PerpetualsOrderData;\n\t\tindexPrice: number;\n\t\tcollateralPrice: number;\n\t}): {\n\t\tcollateral: number;\n\t\tcollateralUsd: number;\n\t} => {\n\t\tconst { leverage, orderData, indexPrice, collateralPrice } = inputs;\n\n\t\tconst imr = 1 / (leverage || 1);\n\n\t\tconst collateralUsd =\n\t\t\t(Number(orderData.currentSize) / Casting.Fixed.fixedOneN9) *\n\t\t\tindexPrice *\n\t\t\timr;\n\n\t\tconst collateral = collateralUsd / collateralPrice;\n\n\t\treturn {\n\t\t\tcollateralUsd,\n\t\t\tcollateral,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// Value Conversions\n\t// =========================================================================\n\n\t/**\n\t * Get the base-asset lot size for this market as a `number`.\n\t *\n\t * Order sizes must be multiples of this lot size.\n\t *\n\t * @returns Lot size in base asset units.\n\t */\n\tpublic lotSize() {\n\t\treturn Perpetuals.lotOrTickSizeToNumber(this.marketParams.lotSize);\n\t}\n\n\t/**\n\t * Get the minimal price tick size for this market as a `number`.\n\t *\n\t * Limit prices must be multiples of this tick size.\n\t *\n\t * @returns Tick size in quote units (e.g. USD).\n\t */\n\tpublic tickSize() {\n\t\treturn Perpetuals.lotOrTickSizeToNumber(this.marketParams.tickSize);\n\t}\n\n\t/**\n\t * Get the maximum theoretical leverage for this market.\n\t *\n\t * Computed as:\n\t * ```ts\n\t * 1 / marginRatioInitial\n\t * ```\n\t *\n\t * @returns Maximum leverage.\n\t */\n\tpublic maxLeverage() {\n\t\treturn 1 / this.marketParams.marginRatioInitial;\n\t}\n\n\t/**\n\t * Get the initial margin ratio for this market.\n\t *\n\t * This is the minimum margin required when opening a position.\n\t *\n\t * @returns Initial margin ratio as a fraction (e.g. 0.05 = 20x).\n\t */\n\tpublic initialMarginRatio() {\n\t\treturn this.marketParams.marginRatioInitial;\n\t}\n\n\t/**\n\t * Get the maintenance margin ratio for this market.\n\t *\n\t * Falling below this ratio may trigger liquidation.\n\t *\n\t * @returns Maintenance margin ratio as a fraction.\n\t */\n\tpublic maintenanceMarginRatio() {\n\t\treturn this.marketParams.marginRatioMaintenance;\n\t}\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Round a price to the nearest valid tick for this market.\n\t *\n\t * Rounding mode:\n\t * - `floor: true` => round down\n\t * - `ceil: true` => round up\n\t * - neither => nearest tick (`Math.round`)\n\t *\n\t * @param inputs.price - Raw price to round.\n\t * @param inputs.floor - Force floor rounding.\n\t * @param inputs.ceil - Force ceil rounding.\n\t * @returns Price snapped to the market tick size.\n\t */\n\tpublic roundToValidPrice = (inputs: {\n\t\tprice: number;\n\t\tfloor?: boolean;\n\t\tceil?: boolean;\n\t}) => {\n\t\tconst ticks = inputs.price / this.tickSize();\n\t\treturn (\n\t\t\t(inputs.floor\n\t\t\t\t? Math.floor(ticks)\n\t\t\t\t: inputs.ceil\n\t\t\t\t? Math.ceil(ticks)\n\t\t\t\t: Math.round(ticks)) * this.tickSize()\n\t\t);\n\t};\n\n\t/**\n\t * Round a price to the nearest valid tick as a fixed-point `bigint` (1e9 precision).\n\t *\n\t * This is helpful when you need the on-chain representation directly\n\t * (e.g. order price fields stored in 9-decimal fixed).\n\t *\n\t * @param inputs.price - Raw price as a JS number.\n\t * @param inputs.floor - Force floor rounding.\n\t * @param inputs.ceil - Force ceil rounding.\n\t * @returns Tick-snapped price scaled by `1e9`.\n\t */\n\tpublic roundToValidPriceBigInt = (inputs: {\n\t\tprice: number;\n\t\tfloor?: boolean;\n\t\tceil?: boolean;\n\t}) => {\n\t\tconst scaledPrice = Number(inputs.price * Casting.Fixed.fixedOneN9);\n\t\treturn (\n\t\t\t(BigInt(\n\t\t\t\tinputs.floor\n\t\t\t\t\t? Math.floor(scaledPrice)\n\t\t\t\t\t: inputs.ceil\n\t\t\t\t\t? Math.ceil(scaledPrice)\n\t\t\t\t\t: Math.round(scaledPrice)\n\t\t\t) /\n\t\t\t\tthis.marketParams.tickSize) *\n\t\t\tthis.marketParams.tickSize\n\t\t);\n\t};\n\n\t/**\n\t * Round a base-asset size to the nearest valid lot size for this market.\n\t *\n\t * Rounding mode:\n\t * - `floor: true` => round down\n\t * - `ceil: true` => round up\n\t * - neither => nearest lot (`Math.round`)\n\t *\n\t * @param inputs.size - Raw size in base asset units.\n\t * @param inputs.floor - Force floor rounding.\n\t * @param inputs.ceil - Force ceil rounding.\n\t * @returns Size snapped to the market lot size.\n\t */\n\tpublic roundToValidSize = (inputs: {\n\t\tsize: number;\n\t\tfloor?: boolean;\n\t\tceil?: boolean;\n\t}) => {\n\t\tconst lots = inputs.size / this.lotSize();\n\t\treturn (\n\t\t\t(inputs.floor\n\t\t\t\t? Math.floor(lots)\n\t\t\t\t: inputs.ceil\n\t\t\t\t? Math.ceil(lots)\n\t\t\t\t: Math.round(lots)) * this.lotSize()\n\t\t);\n\t};\n\n\t/**\n\t * Round a base-asset size to the nearest valid lot as a fixed-point `bigint` (1e9 precision).\n\t *\n\t * @param inputs.size - Raw base size as a JS number.\n\t * @param inputs.floor - Force floor rounding.\n\t * @param inputs.ceil - Force ceil rounding.\n\t * @returns Lot-snapped size scaled by `1e9`.\n\t */\n\tpublic roundToValidSizeBigInt = (inputs: {\n\t\tsize: number;\n\t\tfloor?: boolean;\n\t\tceil?: boolean;\n\t}) => {\n\t\tconst scaledSize = Number(inputs.size * Casting.Fixed.fixedOneN9);\n\t\treturn (\n\t\t\t(BigInt(\n\t\t\t\tinputs.floor\n\t\t\t\t\t? Math.floor(scaledSize)\n\t\t\t\t\t: inputs.ceil\n\t\t\t\t\t? Math.ceil(scaledSize)\n\t\t\t\t\t: Math.round(scaledSize)\n\t\t\t) /\n\t\t\t\tthis.marketParams.lotSize) *\n\t\t\tthis.marketParams.lotSize\n\t\t);\n\t};\n\n\t/**\n\t * Construct an \"empty\" position object for this market.\n\t *\n\t * Useful when an account has no open position but downstream UI/calculations\n\t * expect a {@link PerpetualsPosition}-shaped object.\n\t *\n\t * @returns A zeroed-out {@link PerpetualsPosition} for `this.marketId`.\n\t */\n\tpublic emptyPosition = (): PerpetualsPosition => {\n\t\treturn {\n\t\t\tmarketId: this.marketId,\n\t\t\tcollateral: 0,\n\t\t\tcollateralUsd: 0,\n\t\t\tbaseAssetAmount: 0,\n\t\t\tquoteAssetNotionalAmount: 0,\n\t\t\tcumFundingRateLong: this.marketData.marketState.cumFundingRateLong,\n\t\t\tcumFundingRateShort:\n\t\t\t\tthis.marketData.marketState.cumFundingRateShort,\n\t\t\tasksQuantity: 0,\n\t\t\tbidsQuantity: 0,\n\t\t\tpendingOrders: [],\n\t\t\tmakerFee: 1, // 100% (placeholder default)\n\t\t\ttakerFee: 1, // 100% (placeholder default)\n\t\t\tleverage: 1,\n\t\t\tentryPrice: 0,\n\t\t\tfreeCollateral: 0,\n\t\t\tfreeMarginUsd: 0,\n\t\t\tliquidationPrice: 0,\n\t\t\tmarginRatio: 1,\n\t\t\tunrealizedFundingsUsd: 0,\n\t\t\tunrealizedPnlUsd: 0,\n\t\t};\n\t};\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiPerpetualsDepositCollateralBody,\n\tApiPerpetualsLimitOrderBody,\n\tApiPerpetualsMarketOrderBody,\n\tApiPerpetualsPreviewPlaceOrderResponse,\n\tApiPerpetualsWithdrawCollateralBody,\n\tBalance,\n\tPerpetualsAccountCap,\n\tPerpetualsAccountObject,\n\tPerpetualsMarketId,\n\tPerpetualsOrderId,\n\tPerpetualsPosition,\n\tSdkPerpetualsPlaceLimitOrderInputs,\n\tSdkPerpetualsPlaceMarketOrderInputs,\n\tSuiAddress,\n\tApiPerpetualsTransferCollateralBody,\n\tObjectId,\n\tApiPerpetualsCancelOrdersBody,\n\tPercentage,\n\tApiDataWithCursorBody,\n\tTimestamp,\n\tApiPerpetualsAccountCollateralHistoryResponse,\n\tApiPerpetualsAccountOrderHistoryResponse,\n\tPerpetualsAccountId,\n\tApiPerpetualsAccountCollateralHistoryBody,\n\tApiPerpetualsAccountOrderHistoryBody,\n\tApiPerpetualsPreviewCancelOrdersBody,\n\tApiPerpetualsPreviewCancelOrdersResponse,\n\t// ApiPerpetualsPreviewReduceOrderBody,\n\t// ApiPerpetualsPreviewReduceOrderResponse,\n\tApiPerpetualsAllocateCollateralBody,\n\tApiPerpetualsDeallocateCollateralBody,\n\t// ApiPerpetualsReduceOrderBody,\n\tApiPerpetualsPreviewSetLeverageBody,\n\tApiPerpetualsPreviewSetLeverageResponse,\n\tApiPerpetualsSetLeverageTxBody,\n\tCallerConfig,\n\tSdkPerpetualsCancelOrdersPreviewInputs,\n\tApiPerpetualsStopOrderDatasBody,\n\tPerpetualsStopOrderData,\n\tApiPerpetualsCancelStopOrdersBody,\n\tApiPerpetualsPlaceStopOrdersBody,\n\tSdkPerpetualsPlaceStopOrdersInputs,\n\tApiPerpetualsEditStopOrdersBody,\n\tSdkPerpetualsPlaceSlTpOrdersInputs,\n\tApiPerpetualsPlaceSlTpOrdersBody,\n\t// ApiPerpetualsAccountMarginHistoryBody,\n\tApiPerpetualsWithdrawCollateralResponse,\n\tSdkPerpetualsPlaceMarketOrderPreviewInputs,\n\tSdkPerpetualsPlaceLimitOrderPreviewInputs,\n\tApiPerpetualsPreviewPlaceMarketOrderBody,\n\tApiPerpetualsPreviewPlaceLimitOrderBody,\n\tApiTransactionResponse,\n\tApiPerpetualsPreviewEditCollateralResponse,\n\tApiPerpetualsPreviewEditCollateralBody,\n\tPerpetualsAccountMarginHistoryData,\n\tApiPerpetualsAccountMarginHistoryBody,\n\tPerpetualsVaultCap,\n\tPerpetualsPartialVaultCap,\n\tApiPerpetualsAccountMarginHistoryResponse,\n\tApiPerpetualsStopOrderDatasResponse,\n\tApiPerpetualsGrantAgentWalletTxBody,\n\tApiPerpetualsRevokeAgentWalletTxBody,\n\tPerpetualsOrderData,\n} from \"../../types\";\nimport { Casting, Helpers } from \"../../general/utils\";\nimport { Perpetuals } from \"./perpetuals\";\nimport {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * Note on “refreshing” account state:\n *\n * This class is a thin wrapper around a snapshot of {@link PerpetualsAccountObject}\n * that is typically fetched via {@link Perpetuals.getAccount}. The transaction builders\n * use the current snapshot to derive fields like `hasPosition` and to construct\n * SL/TP helpers that depend on the position side.\n *\n * If your app is long-lived, you may want to periodically re-fetch the account\n * (and recreate this wrapper) to avoid stale local position/order state. For example:\n * - After placing/canceling orders\n * - After fills/liquidations/funding settlements\n * - After switching markets or wallets\n */\n\n/**\n * High-level wrapper around a single Perpetuals account or vault account.\n *\n * This class encapsulates:\n *\n * - Transaction builders for:\n * - Collateral actions (deposit, withdraw, allocate, deallocate, transfer)\n * - Orders (market/limit, cancel, stop orders, SL/TP, set leverage)\n * - Read-only account helpers:\n * - Stop-order message signing\n * - Order & stop-order metadata\n * - Collateral & trade history\n * - Convenience helpers to:\n * - Fetch and categorize SL/TP stop orders\n * - Resolve account/vault identifiers and owner addresses\n *\n * You typically do not construct `PerpetualsAccount` directly. Instead, use\n * {@link Perpetuals.getAccount} or {@link Perpetuals.getAccounts}, which\n * fetch all required on-chain data and wrap it for you:\n *\n * ```ts\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init();\n *\n * const perps = afSdk.Perpetuals();\n * const [accountCap] = await perps.getOwnedAccountCaps({\n * walletAddress: \"0x...\",\n * });\n *\n * const account = await perps.getAccount({ accountCap });\n *\n * // Build a deposit transaction\n * const depositTx = await account.getDepositCollateralTx({\n * depositAmount: BigInt(\"1000000000\"),\n * });\n * ```\n */\nexport class PerpetualsAccount extends Caller {\n\t// =========================================================================\n\t// Private Members\n\t// =========================================================================\n\n\t/**\n\t * If this account is backed by a vault, this holds the vault object ID.\n\t * Otherwise, `undefined` for \"direct\" user accounts.\n\t *\n\t * This is used primarily to route requests to either:\n\t * - `/perpetuals/account/...` endpoints, or\n\t * - `/perpetuals/vault/...` endpoints.\n\t */\n\tprivate readonly vaultId: ObjectId | undefined;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Create a new {@link PerpetualsAccount} wrapper.\n\t *\n\t * @param account - Raw account object with positions and equity data.\n\t * @param accountCap - Account cap or partial vault cap object containing\n\t * ownership and collateral metadata.\n\t * @param config - Optional {@link CallerConfig} (network, auth, etc.).\n\t * @param Provider - Optional shared {@link AftermathApi} provider instance\n\t * used to derive serialized transaction kinds (`txKind`) from\n\t * {@link Transaction} objects.\n\t */\n\tconstructor(\n\t\tpublic readonly account: PerpetualsAccountObject,\n\t\tpublic readonly accountCap:\n\t\t\t| PerpetualsAccountCap\n\t\t\t| PerpetualsPartialVaultCap,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tconst vaultId =\n\t\t\t\"vaultId\" in accountCap ? accountCap.vaultId : undefined;\n\t\tsuper(config, \"perpetuals\");\n\t\tthis.vaultId = vaultId;\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Collateral Txs\n\t// =========================================================================\n\n\t/**\n\t * Build a `deposit-collateral` transaction for this account.\n\t *\n\t * For non-vault accounts, this endpoint constructs a transaction that:\n\t * - Optionally extends an existing {@link Transaction}, and\n\t * - Deposits collateral into the Perpetuals account.\n\t *\n\t * **Note:** Vault accounts are currently not supported and will throw.\n\t *\n\t * @param inputs.tx - Optional existing transaction to extend. If omitted,\n\t * a new {@link Transaction} is created under the hood.\n\t * @param inputs.isSponsoredTx - Optional flag indicating whether the\n\t * transaction is gas-sponsored.\n\t * @param inputs.depositAmount - Amount of collateral to deposit, if paying\n\t * directly from the wallet.\n\t * @param inputs.depositCoinArg - Transaction object argument referencing a\n\t * coin to deposit (mutually exclusive with `depositAmount`).\n\t *\n\t * @returns Transaction response containing a `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { tx } = await account.getDepositCollateralTx({\n\t * depositAmount: BigInt(\"1000000000\"),\n\t * });\n\t * ```\n\t */\n\tpublic async getDepositCollateralTx(\n\t\tinputs: {\n\t\t\ttx?: Transaction;\n\t\t\tisSponsoredTx?: boolean;\n\t\t} & (\n\t\t\t| {\n\t\t\t\t\tdepositAmount: Balance;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tdepositCoinArg: TransactionObjectArgument;\n\t\t\t }\n\t\t)\n\t) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\n\t\tif (\"vaultId\" in this.accountCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"`getDepositCollateralTx` not supported by vault accounts, please use method `getAdminDepositTx` on class `PerpetualsVault` instead\"\n\t\t\t);\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsDepositCollateralBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"account/transactions/deposit-collateral\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\tcollateralCoinType: this.accountCap.collateralCoinType,\n\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `withdraw-collateral` transaction for this account.\n\t *\n\t * For non-vault accounts, this endpoint constructs a transaction to:\n\t * - Withdraw collateral from the Perpetuals account, and\n\t * - Optionally transfer it to a `recipientAddress` (otherwise coin is left\n\t * as a transaction argument).\n\t *\n\t * **Note:** Vault accounts are currently not supported and will throw.\n\t *\n\t * @param inputs.withdrawAmount - Amount of collateral to withdraw.\n\t * @param inputs.recipientAddress - Optional address to receive the withdrawn\n\t * coins directly.\n\t * @param inputs.tx - Optional transaction to extend (defaults to new `Transaction()`).\n\t *\n\t * @returns A response containing `tx` and the `coinOutArg` where the\n\t * withdrawn coins end up if `recipientAddress` is not used.\n\t *\n\t * @example\n\t * ```ts\n\t * const { tx, coinOutArg } = await account.getWithdrawCollateralTx({\n\t * withdrawAmount: BigInt(\"1000000000\"),\n\t * });\n\t * ```\n\t */\n\tpublic async getWithdrawCollateralTx(inputs: {\n\t\twithdrawAmount: Balance;\n\t\trecipientAddress?: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { withdrawAmount, recipientAddress, tx: txFromInputs } = inputs;\n\n\t\tif (this.vaultId)\n\t\t\tthrow new Error(\n\t\t\t\t\"this method is not supported for vaults, please use method `getAdminWithdrawTx` on class `PerpetualsVault` instead\"\n\t\t\t);\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsWithdrawCollateralBody,\n\t\t\tApiPerpetualsWithdrawCollateralResponse\n\t\t>(\n\t\t\t\"account/transactions/withdraw-collateral\",\n\t\t\t{\n\t\t\t\twithdrawAmount,\n\t\t\t\trecipientAddress,\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: txFromInputs ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build an `allocate-collateral` transaction, moving collateral from this\n\t * account into a specific market (clearing house).\n\t *\n\t * Works for both account-backed and vault-backed accounts.\n\t *\n\t * @param inputs.marketId - Market to allocate collateral to.\n\t * @param inputs.allocateAmount - Amount of collateral to allocate.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing a `tx`.\n\t */\n\tpublic async getAllocateCollateralTx(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tallocateAmount: Balance;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, allocateAmount, marketId } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsAllocateCollateralBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/allocate-collateral\",\n\t\t\t{\n\t\t\t\tmarketId,\n\t\t\t\tallocateAmount,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx: tx ?? new Transaction() }\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `deallocate-collateral` transaction, moving collateral from a\n\t * specific market back to this account.\n\t *\n\t * Works for both account-backed and vault-backed accounts.\n\t *\n\t * @param inputs.marketId - Market to deallocate collateral from.\n\t * @param inputs.deallocateAmount - Amount of collateral to deallocate.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing a `tx`.\n\t */\n\tpublic async getDeallocateCollateralTx(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tdeallocateAmount: Balance;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, deallocateAmount, marketId } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsDeallocateCollateralBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/deallocate-collateral\",\n\t\t\t{\n\t\t\t\tmarketId,\n\t\t\t\tdeallocateAmount,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx: tx ?? new Transaction() }\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `transfer-collateral` transaction between two Perpetuals accounts.\n\t *\n\t * Only supported for direct accounts, **not** vault-backed accounts.\n\t *\n\t * @param inputs.transferAmount - Amount of collateral to transfer.\n\t * @param inputs.toAccountId - Destination account ID.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing a `tx`.\n\t */\n\tpublic async getTransferCollateralTx(inputs: {\n\t\ttransferAmount: Balance;\n\t\ttoAccountId: PerpetualsAccountId;\n\t\ttoAccountCapId?: ObjectId;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { transferAmount, toAccountId, toAccountCapId, tx } = inputs;\n\n\t\tif (\"vaultId\" in this.accountCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"`getTransferCollateralTx` not supported by vault accounts\"\n\t\t\t);\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsTransferCollateralBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/transfer-collateral\",\n\t\t\t{\n\t\t\t\ttransferAmount,\n\t\t\t\ttoAccountId,\n\t\t\t\ttoAccountCapId,\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\tfromAccountId: this.accountCap.accountId,\n\t\t\t\tfromAccountCapId: this.accountCap.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx: tx ?? new Transaction() }\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Order Txs\n\t// =========================================================================\n\n\t/**\n\t * Build a `place-market-order` transaction for this account.\n\t *\n\t * This is the primary entrypoint for opening/closing positions via market orders.\n\t * It automatically:\n\t * - Injects the account/vault identity into the payload.\n\t * - Derives `hasPosition` based on the current account state for the given market.\n\t * - Optionally attaches SL/TP stop orders via the `slTp` input.\n\t *\n\t * Important behavioral notes:\n\t * - `hasPosition` is derived from the local {@link PerpetualsAccountObject} snapshot.\n\t * If the snapshot is stale, consider re-fetching the account first.\n\t * - For vault-backed accounts, the API routes to `/perpetuals/vault/...` and uses\n\t * `vaultId` as the identity discriminator. For direct accounts, it uses `accountId`.\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderInputs} for details.\n\t * Notably:\n\t * - `marketId`, `side`, `size`, `collateralChange`, `reduceOnly`\n\t * - Optional `leverage`\n\t * - Optional `slTp` params\n\t * - Optional `tx` to extend\n\t *\n\t * @returns Transaction response containing `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { tx } = await account.getPlaceMarketOrderTx({\n\t * marketId: \"0x...\",\n\t * side: PerpetualsOrderSide.Bid,\n\t * size: BigInt(\"1000000000\"),\n\t * collateralChange: 10,\n\t * reduceOnly: false,\n\t * });\n\t * ```\n\t */\n\tpublic async getPlaceMarketOrderTx(\n\t\tinputs: SdkPerpetualsPlaceMarketOrderInputs\n\t) {\n\t\tconst { tx: txFromInputs, ...otherInputs } = inputs;\n\n\t\tconst tx = txFromInputs ?? new Transaction();\n\t\t// tx.setSender(this.ownerAddress());\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsMarketOrderBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/place-market-order\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t\t// hasPosition:\n\t\t\t\t// \tthis.positionForMarketId(otherInputs) !== undefined,\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `place-limit-order` transaction for this account.\n\t *\n\t * Similar to {@link getPlaceMarketOrderTx}, but uses limit order semantics:\n\t * - Requires `price` and `orderType`.\n\t * - Supports reduce-only flags, expiry, optional leverage, and SL/TP stop orders.\n\t *\n\t * Notes:\n\t * - `hasPosition` is derived from local account state; refresh the account if needed.\n\t * - This method does not validate tick/lot sizing locally; the API/on-chain\n\t * will enforce market constraints.\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderInputs}.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getPlaceLimitOrderTx(\n\t\tinputs: SdkPerpetualsPlaceLimitOrderInputs\n\t) {\n\t\tconst { tx: txFromInputs, ...otherInputs } = inputs;\n\n\t\tconst tx = txFromInputs ?? new Transaction();\n\t\t// tx.setSender(this.ownerAddress());\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsLimitOrderBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/place-limit-order\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t\t// hasPosition:\n\t\t\t\t// \tthis.positionForMarketId(otherInputs) !== undefined,\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `cancel-orders` transaction for this account.\n\t *\n\t * Each market in `marketIdsToData` supplies:\n\t * - `orderIds`: the orders to cancel in that market\n\t * - `collateralChange`: collateral adjustment to apply alongside cancellation\n\t * - `leverage`: leverage context used for estimating/validating constraints server-side\n\t *\n\t * Notes:\n\t * - Cancels are applied per market; some markets may succeed while others fail\n\t * depending on API/on-chain validation (returned as a transaction failure at execution).\n\t * - If you need to understand the effect prior to building a tx, use\n\t * {@link getCancelOrdersPreview}.\n\t *\n\t * @param inputs.tx - Optional transaction to extend.\n\t * @param inputs.marketIdsToData - Mapping from market IDs to cancel payloads.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getCancelOrdersTx(inputs: {\n\t\ttx?: Transaction;\n\t\tmarketIdsToData: Record<\n\t\t\tPerpetualsMarketId,\n\t\t\t{\n\t\t\t\torderIds: PerpetualsOrderId[];\n\t\t\t\tcollateralChange: number;\n\t\t\t}\n\t\t>;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsCancelOrdersBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/cancel-orders\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `cancel-stop-orders` transaction for this account.\n\t *\n\t * This cancels stop-order *objects/tickets* by their object IDs. These IDs are\n\t * returned by stop-order query endpoints (see {@link getStopOrderDatas}).\n\t *\n\t * @param inputs.tx - Optional transaction to extend.\n\t * @param inputs.stopOrderIds - Array of stop-order ticket IDs to cancel.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getCancelStopOrdersTx(inputs: {\n\t\ttx?: Transaction;\n\t\tstopOrderIds: ObjectId[];\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsCancelStopOrdersBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/cancel-stop-orders\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `place-stop-orders` transaction for this account.\n\t *\n\t * This allows placing one or more stop orders in a single transaction,\n\t * optionally with a dedicated gas coin and a sponsored gas flag.\n\t *\n\t * Typical usage:\n\t * - Construct stop order payload(s) client-side\n\t * - Call this method to build a transaction kind\n\t * - Sign/execute the transaction via Sui\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceStopOrdersInputs}.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getPlaceStopOrdersTx(\n\t\tinputs: SdkPerpetualsPlaceStopOrdersInputs\n\t) {\n\t\tconst {\n\t\t\ttx: txFromInputs,\n\t\t\tisSponsoredTx,\n\t\t\tstopOrders,\n\t\t\tgasCoinArg,\n\t\t} = inputs;\n\n\t\tconst tx = txFromInputs ?? new Transaction();\n\t\t// tx.setSender(this.ownerAddress());\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsPlaceStopOrdersBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/place-stop-orders\",\n\t\t\t{\n\t\t\t\tstopOrders,\n\t\t\t\tgasCoinArg,\n\t\t\t\tisSponsoredTx,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `place-sl-tp-orders` transaction for this account.\n\t *\n\t * This helper constructs SL/TP stop orders for an **existing** position\n\t * in a given market. If the account has no position for `marketId`, this\n\t * throws an error.\n\t *\n\t * Implementation details:\n\t * - Determines the current position side from the account snapshot.\n\t * - Sets `positionSide` for the API so SL/TP orders are bound to closing logic\n\t * (i.e. they should trigger on the opposite side of the open position).\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceSlTpOrdersInputs}.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getPlaceSlTpOrdersTx(\n\t\tinputs: SdkPerpetualsPlaceSlTpOrdersInputs\n\t) {\n\t\tconst {\n\t\t\ttx: txFromInputs,\n\t\t\tisSponsoredTx,\n\t\t\tmarketId,\n\t\t\t...slTpInputs\n\t\t} = inputs;\n\n\t\tconst position = this.positionForMarketId({ marketId });\n\t\tif (!position) throw new Error(\"you have no position for this market\");\n\n\t\tconst tx = txFromInputs ?? new Transaction();\n\t\t// tx.setSender(this.ownerAddress());\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsPlaceSlTpOrdersBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/place-sl-tp-orders\",\n\t\t\t{\n\t\t\t\t...slTpInputs,\n\t\t\t\tmarketId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t\tpositionSide: Perpetuals.positionSide({\n\t\t\t\t\tbaseAssetAmount: position.baseAssetAmount,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build an `edit-stop-orders` transaction for this account.\n\t *\n\t * This endpoint lets you update existing stop orders in batch.\n\t *\n\t * Notes:\n\t * - You must provide the full updated stop-order objects (including object IDs).\n\t * - This is typically used to adjust trigger prices, sizes, expiries, or the\n\t * embedded limit-order parameters.\n\t *\n\t * @param inputs.stopOrders - Full updated stop-order payloads to apply.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getEditStopOrdersTx(\n\t\tinputs: Omit<\n\t\t\tApiPerpetualsEditStopOrdersBody,\n\t\t\t\"txKind\" | \"accountObjectId\"\n\t\t> & {\n\t\t\ttx?: Transaction;\n\t\t}\n\t) {\n\t\tconst { tx: txFromInputs, stopOrders } = inputs;\n\n\t\tconst tx = txFromInputs ?? new Transaction();\n\t\t// tx.setSender(this.ownerAddress());\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsEditStopOrdersBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/edit-stop-orders\",\n\t\t\t{\n\t\t\t\tstopOrders,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// public async getReduceOrderTx(inputs: {\n\t// \ttx?: Transaction;\n\t// \tcollateralChange: number;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \torderId: PerpetualsOrderId;\n\t// \tsizeToSubtract: bigint;\n\t// \tleverage?: number;\n\t// }) {\n\t// \tconst { tx, ...otherInputs } = inputs;\n\t// \treturn this.fetchApiTxObject<\n\t// \t\tApiPerpetualsReduceOrderBody,\n\t// \t\tApiTransactionResponse\n\t// \t>(\n\t// \t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t// \t\t\t\"transactions/reduce-order\",\n\t// \t\t{\n\t// \t\t\t...otherInputs,\n\t// \t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t// \t\t\t\t{ tx }\n\t// \t\t\t),\n\t// \t\t\twalletAddress: this.ownerAddress(),\n\t// \t\t\t...(\"vaultId\" in this.accountCap\n\t// \t\t\t\t? {\n\t// \t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t// accountId: undefined,\n\t// \t\t\t\t }\n\t// \t\t\t\t: {\n\t// \t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t// vaultId: undefined,\n\t// \t\t\t\t }),\n\t// \t\t},\n\t// \t\tundefined,\n\t// \t\t{\n\t// \t\t\ttxKind: true,\n\t// \t\t}\n\t// \t);\n\t// }\n\n\t/**\n\t * Build a `set-leverage` transaction for a given market.\n\t *\n\t * This updates the effective leverage for the position (or potential position)\n\t * in `marketId`, and optionally adjusts collateral in tandem.\n\t *\n\t * Notes:\n\t * - Leverage changes may be constrained by protocol risk limits and current\n\t * position state.\n\t * - If you want to understand the effect first, use {@link getSetLeveragePreview}.\n\t *\n\t * @param inputs.tx - Optional transaction to extend.\n\t * @param inputs.leverage - Target leverage value.\n\t * @param inputs.collateralChange - Net collateral change to apply alongside\n\t * the leverage update.\n\t * @param inputs.marketId - Market whose leverage to adjust.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getSetLeverageTx(inputs: {\n\t\ttx?: Transaction;\n\t\tleverage: number;\n\t\tcollateralChange: number;\n\t\tmarketId: PerpetualsMarketId;\n\t}) {\n\t\tconst { leverage, tx, collateralChange, marketId } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsSetLeverageTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"transactions/set-leverage\",\n\t\t\t{\n\t\t\t\tleverage,\n\t\t\t\tmarketId,\n\t\t\t\tcollateralChange,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t\twalletAddress: this.ownerAddress(),\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Position Txs\n\t// =========================================================================\n\n\t// public async getClosePositionTx(inputs: {\n\t// \tsize: bigint;\n\t// \tmarket: PerpetualsMarket;\n\t// \torderDatas: PerpetualsOrderData[];\n\t// \tindexPrice: number;\n\t// \tcollateralPrice: number;\n\t// }) {\n\t// \tthrow new Error(\"TODO\");\n\t// \t// return this.getPlaceMarketOrderTx({\n\t// \t// \t...this.closePositionTxInputs(inputs),\n\t// \t// });\n\t// }\n\n\t// =========================================================================\n\t// Interactions\n\t// =========================================================================\n\n\t/**\n\t * Build a deterministic message payload to sign when querying stop orders\n\t * from the backend.\n\t *\n\t * This payload is intended to be signed off-chain and then submitted to\n\t * `getStopOrderDatas` as a proof of account ownership.\n\t *\n\t * Important:\n\t * - The returned payload is *not* a Sui transaction; it is an off-chain\n\t * “authentication” message.\n\t * - The backend expects `account_id` to be a decimal string. This code\n\t * normalizes the bigint `accountId` by stripping the trailing `n`.\n\t *\n\t * @param inputs.marketIds - Optional list of market IDs to scope the query.\n\t *\n\t * @returns An object describing the action and account/market IDs, suitable\n\t * for message signing.\n\t *\n\t * @example\n\t * ```ts\n\t * const message = account.getStopOrdersMessageToSign({ marketIds: [\"0x...\"] });\n\t * const { signature } = await wallet.signMessage({\n\t * message: new TextEncoder().encode(JSON.stringify(message)),\n\t * });\n\t * ```\n\t */\n\tpublic getStopOrdersMessageToSign(inputs?: {\n\t\tmarketIds: PerpetualsMarketId[];\n\t}): {\n\t\taction: string;\n\t\taccount_id: string;\n\t\tclearing_house_ids: string[];\n\t} {\n\t\treturn {\n\t\t\taction: \"GET_STOP_ORDERS\",\n\t\t\taccount_id: this.accountCap.accountId\n\t\t\t\t.toString()\n\t\t\t\t.replaceAll(\"n\", \"\"),\n\t\t\tclearing_house_ids: inputs?.marketIds ?? [],\n\t\t};\n\t}\n\n\t// public async getPlaceOrderPreview(\n\t// \tinputs: SdkPerpetualsPlaceOrderPreviewInputs,\n\t// \tabortSignal?: AbortSignal\n\t// ): Promise<\n\t// \t| {\n\t// \t\t\terror: string;\n\t// \t }\n\t// \t| {\n\t// \t\t\tupdatedPosition: PerpetualsPosition;\n\t// \t\t\tpriceSlippage: number;\n\t// \t\t\tpercentSlippage: Percentage;\n\t// \t\t\tfilledSize: number;\n\t// \t\t\tfilledSizeUsd: number;\n\t// \t\t\tpostedSize: number;\n\t// \t\t\tpostedSizeUsd: number;\n\t// \t\t\tcollateralChange: number;\n\t// \t\t\texecutionPrice: number;\n\t// \t }\n\t// > {\n\t// \treturn this.fetchApi<\n\t// \t\tApiPerpetualsPreviewOrderResponse,\n\t// \t\tApiPerpetualsPreviewOrderBody\n\t// \t>(\n\t// \t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\"previews/place-order\",\n\t// \t\t{\n\t// \t\t\t...inputs,\n\t// \t\t\taccountId: this.accountCap.accountId,\n\t// \t\t\tcollateralCoinType: this.accountCap.collateralCoinType,\n\t// \t\t},\n\t// \t\tabortSignal\n\t// \t);\n\t// }\n\n\t/**\n\t * Preview the effects of placing a market order (without building a tx).\n\t *\n\t * This is a read-only API call that runs the protocol’s pricing / margin /\n\t * slippage logic against the current market state and your account/vault context.\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceMarketOrderPreviewInputs}.\n\t * @param abortSignal - Optional `AbortSignal` to cancel the request.\n\t *\n\t * @returns Either an error message or a preview including:\n\t * - `updatedPosition`\n\t * - `priceSlippage`, `percentSlippage`\n\t * - `filledSize`, `filledSizeUsd`\n\t * - `postedSize`, `postedSizeUsd`\n\t * - `collateralChange`\n\t * - `executionPrice`\n\t */\n\tpublic async getPlaceMarketOrderPreview(\n\t\tinputs: SdkPerpetualsPlaceMarketOrderPreviewInputs,\n\t\tabortSignal?: AbortSignal\n\t): Promise<ApiPerpetualsPreviewPlaceOrderResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewPlaceOrderResponse,\n\t\t\tApiPerpetualsPreviewPlaceMarketOrderBody\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"previews/place-market-order\",\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t/**\n\t * Preview the effects of placing a limit order (without building a tx).\n\t *\n\t * The preview simulates:\n\t * - How much size would execute immediately vs post to the book\n\t * - Expected slippage and execution price\n\t * - Resulting position and margin impact\n\t *\n\t * @param inputs - See {@link SdkPerpetualsPlaceLimitOrderPreviewInputs}.\n\t * @param abortSignal - Optional `AbortSignal` to cancel the request.\n\t *\n\t * @returns Either an error message or a preview object similar to\n\t * {@link getPlaceMarketOrderPreview}.\n\t */\n\tpublic async getPlaceLimitOrderPreview(\n\t\tinputs: SdkPerpetualsPlaceLimitOrderPreviewInputs,\n\t\tabortSignal?: AbortSignal\n\t): Promise<ApiPerpetualsPreviewPlaceOrderResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewPlaceOrderResponse,\n\t\t\tApiPerpetualsPreviewPlaceLimitOrderBody\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"previews/place-limit-order\",\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t/**\n\t * Preview the effects of canceling orders across one or more markets.\n\t *\n\t * This is commonly used to:\n\t * - Validate that cancels are allowed under current margin constraints\n\t * - Estimate how collateral/margin would change after canceling (and applying\n\t * the associated `collateralChange` values)\n\t *\n\t * If `marketIdsToData` is empty, this returns a trivial preview with:\n\t * - `marketIdsToData: {}`\n\t *\n\t * @param inputs - See {@link SdkPerpetualsCancelOrdersPreviewInputs}.\n\t * @param abortSignal - Optional `AbortSignal` to cancel the request.\n\t *\n\t * @returns Either:\n\t * - `{ marketIdsToData }`, or\n\t * - `{ error }`.\n\t */\n\tpublic async getCancelOrdersPreview(\n\t\tinputs: SdkPerpetualsCancelOrdersPreviewInputs,\n\t\tabortSignal?: AbortSignal\n\t): Promise<ApiPerpetualsPreviewCancelOrdersResponse> {\n\t\t// NOTE: should this case return an error instead ?\n\t\tif (Object.keys(inputs.marketIdsToData).length <= 0)\n\t\t\treturn {\n\t\t\t\tmarketIdsToData: {},\n\t\t\t};\n\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewCancelOrdersResponse,\n\t\t\tApiPerpetualsPreviewCancelOrdersBody\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` + \"previews/cancel-orders\",\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t// public async getReduceOrderPreview(\n\t// \tinputs: {\n\t// \t\tmarketId: PerpetualsMarketId;\n\t// \t\torderId: PerpetualsOrderId;\n\t// \t\tsizeToSubtract: bigint;\n\t// \t\tleverage?: number;\n\t// \t},\n\t// \tabortSignal?: AbortSignal\n\t// ): Promise<\n\t// \t| {\n\t// \t\t\tpositionAfterReduceOrder: PerpetualsPosition;\n\t// \t\t\tcollateralChange: number;\n\t// \t }\n\t// \t| {\n\t// \t\t\terror: string;\n\t// \t }\n\t// > {\n\t// \treturn this.fetchApi<\n\t// \t\tApiPerpetualsPreviewReduceOrderResponse,\n\t// \t\tApiPerpetualsPreviewReduceOrderBody\n\t// \t>(\n\t// \t\t`${this.vaultId ? \"vault\" : \"account\"}/` + \"previews/reduce-order\",\n\t// \t\t{\n\t// \t\t\t...inputs,\n\t// \t\t\t...(\"vaultId\" in this.accountCap\n\t// \t\t\t\t? {\n\t// \t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t//\t\t\t\t\t\taccountId: undefined,\n\t// \t\t\t\t }\n\t// \t\t\t\t: {\n\t// \t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t//\t\t\t\t\t\tvaultId: undefined,\n\t// \t\t\t\t }),\n\t// \t\t},\n\t// \t\tabortSignal\n\t// \t);\n\t// }\n\n\t/**\n\t * Preview the effects of setting leverage for a given market.\n\t *\n\t * The preview returns:\n\t * - The position after the leverage change (`updatedPosition`)\n\t * - The collateral delta required/produced (`collateralChange`)\n\t *\n\t * @param inputs.marketId - Market whose leverage you want to adjust.\n\t * @param inputs.leverage - Target leverage value.\n\t * @param abortSignal - Optional `AbortSignal` to cancel the request.\n\t *\n\t * @returns Either:\n\t * - `{ updatedPosition, collateralChange }`, or\n\t * - `{ error }`.\n\t */\n\tpublic async getSetLeveragePreview(\n\t\tinputs: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t\tleverage: number;\n\t\t},\n\t\tabortSignal?: AbortSignal\n\t): Promise<\n\t\t| {\n\t\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\t\tcollateralChange: number;\n\t\t }\n\t\t| {\n\t\t\t\terror: string;\n\t\t }\n\t> {\n\t\tconst { marketId, leverage } = inputs;\n\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewSetLeverageResponse,\n\t\t\tApiPerpetualsPreviewSetLeverageBody\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` + \"previews/set-leverage\",\n\t\t\t{\n\t\t\t\tmarketId,\n\t\t\t\tleverage,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t/**\n\t * Preview the effects of allocating/deallocating collateral for the position in\n\t * a given market.\n\t *\n\t * Semantics:\n\t * - Positive `collateralChange` previews allocation (moving collateral into the market).\n\t * - Negative `collateralChange` previews deallocation (moving collateral out of the market).\n\t *\n\t * @param inputs.marketId - Market of whose position you want to allocate/deallocate\n\t * collateral to/from.\n\t * @param inputs.collateralChange - The target collateral change (a positive number\n\t * for allocating collateral, negative for deallocating collateral).\n\t * @param abortSignal - Optional `AbortSignal` to cancel the request.\n\t *\n\t * @returns Either:\n\t * - `{ updatedPosition, collateralChange }`, or\n\t * - `{ error }`.\n\t */\n\tpublic async getEditCollateralPreview(\n\t\tinputs: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t\tcollateralChange: Balance;\n\t\t},\n\t\tabortSignal?: AbortSignal\n\t): Promise<\n\t\t| {\n\t\t\t\tupdatedPosition: PerpetualsPosition;\n\t\t\t\tcollateralChange: number;\n\t\t }\n\t\t| {\n\t\t\t\terror: string;\n\t\t }\n\t> {\n\t\tconst { marketId, collateralChange } = inputs;\n\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsPreviewEditCollateralResponse,\n\t\t\tApiPerpetualsPreviewEditCollateralBody\n\t\t>(\n\t\t\t`${this.vaultId ? \"vault\" : \"account\"}/` +\n\t\t\t\t\"previews/edit-collateral\",\n\t\t\t{\n\t\t\t\tmarketId,\n\t\t\t\tcollateralChange,\n\t\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t\t }),\n\t\t\t},\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t// public getPlaceClosePositionOrderPreview = async (\n\t// \tinputs: {\n\t// \t\tsize: bigint;\n\t// \t\tmarketId: PerpetualsMarketId;\n\t// \t\tleverage?: number;\n\t// \t} & (\n\t// \t\t| {\n\t// \t\t\t\taccountId: PerpetualsAccountId;\n\t// \t\t }\n\t// \t\t| {\n\t// \t\t\t\tvaultId: ObjectId;\n\t// \t\t }\n\t// \t),\n\t// \tabortSignal?: AbortSignal\n\t// ): Promise<ReturnType<PerpetualsAccount[\"getPlaceMarketOrderPreview\"]>> => {\n\t// \t// TODO: make this fetch instead ?\n\t// \tconst position = this.positionForMarketId({\n\t// \t\tmarketId: inputs.marketId,\n\t// \t});\n\t// \tif (!position)\n\t// \t\tthrow new Error(\n\t// \t\t\t`Account has no position for market id: ${inputs.marketId}`\n\t// \t\t);\n\t// \treturn this.getPlaceMarketOrderPreview(\n\t// \t\t{\n\t// \t\t\t...inputs,\n\t// \t\t\treduceOnly: true,\n\t// \t\t\tside:\n\t// \t\t\t\tPerpetuals.positionSide(position) ===\n\t// \t\t\t\tPerpetualsOrderSide.Ask\n\t// \t\t\t\t\t? PerpetualsOrderSide.Bid\n\t// \t\t\t\t\t: PerpetualsOrderSide.Ask,\n\t// \t\t},\n\t// \t\tabortSignal\n\t// \t);\n\t// };\n\n\t/**\n\t * Fetch stop-order ticket data for this account, using an off-chain signed\n\t * payload.\n\t *\n\t * Typical flow:\n\t * 1) Call {@link getStopOrdersMessageToSign} to construct a deterministic payload\n\t * 2) Sign the payload with the wallet\n\t * 3) Provide the signed payload to this method to fetch stop order data\n\t *\n\t * @param inputs.bytes - Serialized message that was signed (e.g. JSON string).\n\t * @param inputs.signature - Signature over `bytes`.\n\t * @param inputs.marketIds - Optional subset of markets to filter results by.\n\t *\n\t * @returns {@link ApiPerpetualsStopOrderDatasResponse} containing `stopOrderDatas`.\n\t */\n\tpublic async getStopOrderDatas(inputs: {\n\t\tbytes: string;\n\t\tsignature: string;\n\t\tmarketIds?: PerpetualsMarketId[];\n\t}) {\n\t\tconst { bytes, signature, marketIds } = inputs;\n\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsStopOrderDatasResponse,\n\t\t\tApiPerpetualsStopOrderDatasBody\n\t\t>(`${this.vaultId ? \"vault\" : \"account\"}/` + \"stop-order-datas\", {\n\t\t\tbytes,\n\t\t\tsignature,\n\t\t\twalletAddress: this.ownerAddress(),\n\t\t\tmarketIds: marketIds ?? [],\n\t\t\t...(\"vaultId\" in this.accountCap\n\t\t\t\t? {\n\t\t\t\t\t\tvaultId: this.accountCap.vaultId,\n\t\t\t\t\t\taccountId: undefined,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\t\t\taccountCapId: this.accountCap.objectId,\n\t\t\t\t\t\tvaultId: undefined,\n\t\t\t\t }),\n\t\t});\n\t}\n\n\t/**\n\t * Fetch paginated collateral-change history for this account, including\n\t * deposits, withdrawals, funding settlements, liquidations, etc.\n\t *\n\t * Pagination:\n\t * - Use `beforeTimestampCursor` to fetch older entries.\n\t * - The API returns a `nextBeforeTimestampCursor` to continue pagination.\n\t *\n\t * @param inputs.beforeTimestampCursor - Optional cursor for pagination.\n\t * @param inputs.limit - Optional limit per page.\n\t *\n\t * @returns {@link ApiPerpetualsAccountCollateralHistoryResponse} containing\n\t * an array of changes and a `nextBeforeTimestampCursor`.\n\t */\n\tpublic async getCollateralHistory(\n\t\tinputs: Omit<ApiPerpetualsAccountCollateralHistoryBody, \"accountId\">\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsAccountCollateralHistoryResponse,\n\t\t\tApiPerpetualsAccountCollateralHistoryBody\n\t\t>(\"account/collateral-history\", {\n\t\t\t...inputs,\n\t\t\taccountId: this.accountCap.accountId,\n\t\t});\n\t}\n\n\t/**\n\t * Fetch paginated order history for this account.\n\t *\n\t * This endpoint is distinct from {@link getOrderDatas}:\n\t * - `getOrderDatas` resolves current/pending orders based on the snapshot.\n\t * - `getOrderHistory` returns historical order events (fills, cancels, etc.)\n\t * over time with cursor-based pagination.\n\t *\n\t * @param inputs.beforeTimestampCursor - Optional cursor for pagination.\n\t * @param inputs.limit - Optional limit per page.\n\t *\n\t * @returns {@link ApiPerpetualsAccountOrderHistoryResponse} containing a list of\n\t * orders and a `nextBeforeTimestampCursor`.\n\t */\n\tpublic async getOrderHistory(\n\t\tinputs: Omit<ApiPerpetualsAccountOrderHistoryBody, \"accountId\">\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsAccountOrderHistoryResponse,\n\t\t\tApiPerpetualsAccountOrderHistoryBody\n\t\t>(\"account/order-history\", {\n\t\t\t...inputs,\n\t\t\taccountId: this.accountCap.accountId,\n\t\t});\n\t}\n\n\t/**\n\t * Fetch historical margin snapshots for this account over a time range.\n\t *\n\t * This endpoint returns time-series margin data suitable for charting UI\n\t * such as equity and available collateral over time.\n\t *\n\t * Notes:\n\t * - This is an account-level view (aggregated across markets).\n\t *\n\t * @param inputs - {@link ApiPerpetualsAccountMarginHistoryBody} without `accountId`.\n\t * @returns {@link ApiPerpetualsAccountMarginHistoryResponse} containing `marginHistoryDatas`.\n\t */\n\tpublic async getMarginHistory(\n\t\tinputs: Omit<ApiPerpetualsAccountMarginHistoryBody, \"accountId\">\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsAccountMarginHistoryResponse,\n\t\t\tApiPerpetualsAccountMarginHistoryBody\n\t\t>(\"account/margin-history\", {\n\t\t\t...inputs,\n\t\t\taccountId: this.accountCap.accountId,\n\t\t});\n\t}\n\n\t// public async getOwnedWithdrawRequests() {\n\t// \treturn new Perpetuals(\n\t// \t\tthis.config,\n\t// \t\tthis.Provider\n\t// \t).getOwnedWithdrawRequests({\n\t// \t\twalletAddress: this.ownerAddress(),\n\t// \t});\n\t// }\n\n\t/**\n\t * Build a transaction that grants an Agent Wallet (assistant permissions) for this perpetuals account.\n\t *\n\t * The returned transaction must be signed and submitted by the **account admin** wallet.\n\t * After execution, `recipientAddress` can execute supported trading actions on behalf of this account.\n\t *\n\t * Agent wallets can perform all supported actions **except**:\n\t * - withdrawing collateral, and\n\t * - granting or revoking other agent wallets.\n\t *\n\t * @param inputs.recipientAddress Wallet address to receive agent permissions.\n\t * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.\n\t * @throws If this instance represents a vault account (agent wallets are account-only).\n\t */\n\tpublic async getGrantAgentWalletTx(inputs: {\n\t\trecipientAddress: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, recipientAddress } = inputs;\n\n\t\tif (\"vaultId\" in this.accountCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"`getGrantAgentWalletTx` not supported by vault accounts\"\n\t\t\t);\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsGrantAgentWalletTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"account/transactions/grant-agent-wallet\",\n\t\t\t{\n\t\t\t\trecipientAddress,\n\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a transaction that revokes an Agent Wallet (assistant capability) from this perpetuals account.\n\t *\n\t * The returned transaction must be signed and submitted by the **account admin** wallet.\n\t * After execution, the revoked wallet immediately loses its delegated permissions.\n\t *\n\t * @param inputs.accountCapId Object ID of the assistant capability to revoke.\n\t * @param inputs.tx Optional existing {@link Transaction} to append to. If omitted, a new Transaction is used.\n\t * @throws If this instance represents a vault account (agent wallets are account-only).\n\t */\n\tpublic async getRevokeAgentWalletTx(inputs: {\n\t\taccountCapId: ObjectId;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, accountCapId } = inputs;\n\n\t\tif (\"vaultId\" in this.accountCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"`getRevokeAgentWalletTx` not supported by vault accounts\"\n\t\t\t);\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsRevokeAgentWalletTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"account/transactions/revoke-agent-wallet\",\n\t\t\t{\n\t\t\t\taccountCapId,\n\t\t\t\taccountId: this.accountCap.accountId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Find the current position for a given market ID, if any.\n\t *\n\t * @param inputs.marketId - Market ID to search for.\n\t * @returns {@link PerpetualsPosition} if found, otherwise `undefined`.\n\t */\n\tpublic positionForMarketId(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t}): PerpetualsPosition | undefined {\n\t\ttry {\n\t\t\treturn this.account.positions.find(\n\t\t\t\t(pos) => pos.marketId === inputs.marketId\n\t\t\t)!;\n\t\t} catch (e) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Filter a list of stop orders to only include non-SL/TP orders.\n\t *\n\t * A stop order is considered SL/TP if it appears in the combined set of\n\t * SL/TP orders across **all** markets (see {@link slTpStopOrderDatas}).\n\t *\n\t * Note:\n\t * - This implementation uses JSON string equality to compare objects.\n\t * This is pragmatic but assumes stable field ordering and identical shapes.\n\t *\n\t * @param inputs.stopOrderDatas - Full array of stop-order ticket data.\n\t * @returns An array of non-SL/TP stop orders, or `undefined` if none exist.\n\t */\n\tpublic nonSlTpStopOrderDatas(inputs: {\n\t\tstopOrderDatas: PerpetualsStopOrderData[];\n\t}): PerpetualsStopOrderData[] | undefined {\n\t\tconst { stopOrderDatas } = inputs;\n\n\t\tconst slTpOrders = this.slTpStopOrderDatas(inputs);\n\n\t\tconst stopOrders = stopOrderDatas.filter(\n\t\t\t(stopOrder) =>\n\t\t\t\t!(slTpOrders ?? [])\n\t\t\t\t\t.map((slTpOrder) => JSON.stringify(slTpOrder))\n\t\t\t\t\t.includes(JSON.stringify(stopOrder))\n\t\t);\n\t\treturn stopOrders.length <= 0 ? undefined : stopOrders;\n\t}\n\n\t/**\n\t * Extract all SL/TP-style stop orders across **all** markets for this\n\t * account.\n\t *\n\t * SL/TP orders are stop orders which:\n\t * - Have an `slTp` payload, and\n\t * - Target the opposite side of the current position.\n\t *\n\t * This combines:\n\t * - \"Full\" SL/TP orders (size >= `i64MaxBigInt`)\n\t * - \"Partial\" SL/TP orders (size < `i64MaxBigInt`)\n\t *\n\t * The \"full vs partial\" distinction is a protocol convention: some systems\n\t * encode “close entire position” using a sentinel max size.\n\t *\n\t * @param inputs.stopOrderDatas - Full list of stop-order tickets.\n\t * @returns Array of SL/TP stop orders, or `undefined` if none exist.\n\t */\n\tpublic slTpStopOrderDatas(inputs: {\n\t\tstopOrderDatas: PerpetualsStopOrderData[];\n\t}): PerpetualsStopOrderData[] | undefined {\n\t\tconst { stopOrderDatas } = inputs;\n\n\t\tlet slTpOrders: PerpetualsStopOrderData[] = [];\n\n\t\tfor (const { marketId } of this.account.positions) {\n\t\t\tconst { fullSlTpOrder, partialSlTpOrders } =\n\t\t\t\tthis.slTpStopOrderDatasForPosition({\n\t\t\t\t\tmarketId,\n\t\t\t\t\tstopOrderDatas,\n\t\t\t\t});\n\t\t\tslTpOrders = [\n\t\t\t\t...slTpOrders,\n\t\t\t\t...(fullSlTpOrder ? [fullSlTpOrder] : []),\n\t\t\t\t...(partialSlTpOrders ?? []),\n\t\t\t];\n\t\t}\n\t\tfor (const limitOrderId of Helpers.uniqueArray(\n\t\t\tstopOrderDatas.map((stopOrder) => stopOrder.slTp?.limitOrderId)\n\t\t)) {\n\t\t\tif (limitOrderId === undefined) continue;\n\n\t\t\tconst { fullSlTpOrder, partialSlTpOrders } =\n\t\t\t\tthis.slTpStopOrderDatasForLimitOrder({\n\t\t\t\t\tlimitOrderId,\n\t\t\t\t\tstopOrderDatas,\n\t\t\t\t});\n\t\t\tslTpOrders = [\n\t\t\t\t...slTpOrders,\n\t\t\t\t...(fullSlTpOrder ? [fullSlTpOrder] : []),\n\t\t\t\t...(partialSlTpOrders ?? []),\n\t\t\t];\n\t\t}\n\t\treturn slTpOrders.length <= 0 ? undefined : slTpOrders;\n\t}\n\n\t/**\n\t * Filter stop orders for a single market to only include non-SL/TP orders.\n\t *\n\t * Uses {@link slTpStopOrderDatasForPosition} under the hood.\n\t *\n\t * @param inputs.marketId - Market ID to filter for.\n\t * @param inputs.stopOrderDatas - Full list of stop orders.\n\t * @returns Non-SL/TP stop orders for the given market, or `undefined` if none exist.\n\t */\n\tpublic nonSlTpStopOrderDatasForPosition(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tstopOrderDatas: PerpetualsStopOrderData[];\n\t}): PerpetualsStopOrderData[] | undefined {\n\t\tconst { marketId, stopOrderDatas } = inputs;\n\n\t\tconst position = this.positionForMarketId({ marketId });\n\t\tif (!position) return undefined;\n\n\t\tconst { fullSlTpOrder, partialSlTpOrders } =\n\t\t\tthis.slTpStopOrderDatasForPosition(inputs);\n\n\t\tconst stopOrders = stopOrderDatas.filter(\n\t\t\t(stopOrder) =>\n\t\t\t\t!stopOrder.limitOrder &&\n\t\t\t\t![\n\t\t\t\t\t...(fullSlTpOrder ? [fullSlTpOrder] : []),\n\t\t\t\t\t...(partialSlTpOrders ?? []),\n\t\t\t\t]\n\t\t\t\t\t.map((slTpOrder) => JSON.stringify(slTpOrder))\n\t\t\t\t\t.includes(JSON.stringify(stopOrder))\n\t\t);\n\t\treturn stopOrders.length <= 0 ? undefined : stopOrders;\n\t}\n\n\t/**\n\t * Categorize stop orders for a specific market into:\n\t * - A \"full\" SL/TP order (size >= `i64MaxBigInt`) if any.\n\t * - A set of \"partial\" SL/TP orders (size < `i64MaxBigInt`).\n\t *\n\t * SL/TP stop orders are defined as:\n\t * - Market ID matches the input market.\n\t * - `slTp` field is present.\n\t * - Order side is opposite of the position side.\n\t * - At least a `stopLossIndexPrice` or `takeProfitIndexPrice` is set.\n\t *\n\t * Notes on matching:\n\t * - The side comparison uses the current position side derived from the account snapshot.\n\t * - If `baseAssetAmount === 0` (no effective position), the method returns no SL/TP orders.\n\t *\n\t * @param inputs.marketId - Market to categorize stop orders for.\n\t * @param inputs.stopOrderDatas - Full list of stop orders.\n\t *\n\t * @returns Object containing:\n\t * - `fullSlTpOrder` (if any)\n\t * - `partialSlTpOrders` (if any, otherwise `undefined`)\n\t */\n\tpublic slTpStopOrderDatasForPosition(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tstopOrderDatas: PerpetualsStopOrderData[];\n\t}): {\n\t\tfullSlTpOrder: PerpetualsStopOrderData | undefined;\n\t\tpartialSlTpOrders: PerpetualsStopOrderData[] | undefined;\n\t} {\n\t\tconst { marketId, stopOrderDatas } = inputs;\n\n\t\tconst position = this.positionForMarketId({ marketId });\n\t\tif (!position || position.baseAssetAmount === 0) {\n\t\t\treturn {\n\t\t\t\tfullSlTpOrder: undefined,\n\t\t\t\tpartialSlTpOrders: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst side = !position ? undefined : Perpetuals.positionSide(position);\n\n\t\t/**\n\t\t * Implementation note:\n\t\t *\n\t\t * This method uses a pair of predicates that differ only by the `size` threshold\n\t\t * to split “full close” SL/TP from “partial close” SL/TP. The sentinel threshold\n\t\t * is {@link Casting.i64MaxBigInt}. Keeping the logic explicit (rather than\n\t\t * abstracting into helpers) makes it easier to reason about protocol conventions.\n\t\t */\n\t\tconst fullSlTpOrder: PerpetualsStopOrderData | undefined =\n\t\t\tstopOrderDatas.find(\n\t\t\t\t(order) =>\n\t\t\t\t\torder.marketId === marketId &&\n\t\t\t\t\torder.slTp &&\n\t\t\t\t\torder.side !== side &&\n\t\t\t\t\t(order.slTp.stopLossIndexPrice ||\n\t\t\t\t\t\torder.slTp.takeProfitIndexPrice) &&\n\t\t\t\t\torder.size >= Casting.i64MaxBigInt &&\n\t\t\t\t\t!order.limitOrder\n\t\t\t);\n\n\t\tconst partialSlTpOrders: PerpetualsStopOrderData[] =\n\t\t\tstopOrderDatas.filter(\n\t\t\t\t(order) =>\n\t\t\t\t\torder.marketId === marketId &&\n\t\t\t\t\torder.slTp &&\n\t\t\t\t\torder.side !== side &&\n\t\t\t\t\t(order.slTp.stopLossIndexPrice ||\n\t\t\t\t\t\torder.slTp.takeProfitIndexPrice) &&\n\t\t\t\t\torder.size < Casting.i64MaxBigInt &&\n\t\t\t\t\t!order.limitOrder\n\t\t\t);\n\n\t\treturn {\n\t\t\tfullSlTpOrder,\n\t\t\tpartialSlTpOrders:\n\t\t\t\tpartialSlTpOrders.length <= 0 ? undefined : partialSlTpOrders,\n\t\t};\n\t}\n\n\tpublic slTpStopOrderDatasForLimitOrder(inputs: {\n\t\tstopOrderDatas: PerpetualsStopOrderData[];\n\t\tlimitOrderId: PerpetualsOrderId;\n\t}): {\n\t\tfullSlTpOrder: PerpetualsStopOrderData | undefined;\n\t\tpartialSlTpOrders: PerpetualsStopOrderData[] | undefined;\n\t} {\n\t\tconst { stopOrderDatas, limitOrderId } = inputs;\n\n\t\t/**\n\t\t * Implementation note:\n\t\t *\n\t\t * This method uses a pair of predicates that differ only by the `size` threshold\n\t\t * to split “full close” SL/TP from “partial close” SL/TP. The sentinel threshold\n\t\t * is {@link Casting.i64MaxBigInt}. Keeping the logic explicit (rather than\n\t\t * abstracting into helpers) makes it easier to reason about protocol conventions.\n\t\t */\n\t\tconst fullSlTpOrder: PerpetualsStopOrderData | undefined =\n\t\t\tstopOrderDatas.find(\n\t\t\t\t(order) =>\n\t\t\t\t\torder.slTp &&\n\t\t\t\t\torder.slTp.limitOrderId === limitOrderId &&\n\t\t\t\t\t(order.slTp.stopLossIndexPrice ||\n\t\t\t\t\t\torder.slTp.takeProfitIndexPrice) &&\n\t\t\t\t\torder.size >= Casting.i64MaxBigInt\n\t\t\t);\n\n\t\tconst partialSlTpOrders: PerpetualsStopOrderData[] =\n\t\t\tstopOrderDatas.filter(\n\t\t\t\t(order) =>\n\t\t\t\t\torder.slTp &&\n\t\t\t\t\torder.slTp.limitOrderId === limitOrderId &&\n\t\t\t\t\t(order.slTp.stopLossIndexPrice ||\n\t\t\t\t\t\torder.slTp.takeProfitIndexPrice) &&\n\t\t\t\t\torder.size < Casting.i64MaxBigInt\n\t\t\t);\n\n\t\treturn {\n\t\t\tfullSlTpOrder,\n\t\t\tpartialSlTpOrders:\n\t\t\t\tpartialSlTpOrders.length <= 0 ? undefined : partialSlTpOrders,\n\t\t};\n\t}\n\n\tpublic orderDatas(): PerpetualsOrderData[] {\n\t\treturn this.account.positions.reduce(\n\t\t\t(acc, position) => [\n\t\t\t\t...acc,\n\t\t\t\t...position.pendingOrders.map((order) => ({\n\t\t\t\t\torderId: order.orderId,\n\t\t\t\t\tcurrentSize: order.currentSize,\n\t\t\t\t\tinitialSize: order.initialSize,\n\t\t\t\t\tside: Perpetuals.orderIdToSide(order.orderId),\n\t\t\t\t\tmarketId: position.marketId,\n\t\t\t\t})),\n\t\t\t],\n\t\t\t[] as PerpetualsOrderData[]\n\t\t);\n\t}\n\n\t/**\n\t * Convenience accessor for the account's available collateral (in coin units).\n\t *\n\t * This is the amount of collateral not currently locked/allocated across markets,\n\t * as represented by the backend response.\n\t *\n\t * @returns Available collateral as a `number`.\n\t */\n\tpublic collateral(): number {\n\t\treturn this.account.availableCollateral;\n\t}\n\n\t// public collateralDecimals(): CoinDecimal {\n\t// \treturn this.accountCap.collateralDecimals;\n\t// }\n\n\t// public collateralBalance(): Balance {\n\t// \treturn Coin.normalizeBalance(\n\t// \t\tthis.collateral(),\n\t// \t\tthis.collateralDecimals()\n\t// \t);\n\t// }\n\n\t/**\n\t * Check whether this {@link PerpetualsAccount} is vault-backed.\n\t *\n\t * @returns `true` if the underlying `accountCap` is a vault cap; otherwise `false`.\n\t */\n\tpublic isVault(): boolean {\n\t\treturn \"vaultId\" in this.accountCap;\n\t}\n\n\t/**\n\t * Resolve the owner wallet address of this account or vault.\n\t *\n\t * - For direct accounts, returns the cap's `walletAddress` field.\n\t * - For vault-backed accounts, returns the vault cap's `ownerAddress`.\n\t *\n\t * Naming note:\n\t * - Some types use `walletAddress` for direct ownership. For vault-backed accounts\n\t * the analogous field is `ownerAddress`.\n\t *\n\t * @returns Owner wallet {@link SuiAddress}.\n\t */\n\tpublic ownerAddress(): SuiAddress {\n\t\treturn \"walletAddress\" in this.accountCap\n\t\t\t? // NOTE: direct accounts expose `walletAddress`; vault accounts expose `ownerAddress`.\n\t\t\t this.accountCap.walletAddress\n\t\t\t: this.accountCap.ownerAddress;\n\t}\n\n\t/**\n\t * Get the underlying account object ID.\n\t *\n\t * This is the on-chain object that holds the account's state and positions.\n\t *\n\t * @returns {@link ObjectId} of the account object.\n\t */\n\tpublic accountObjectId(): ObjectId {\n\t\treturn this.accountCap.accountObjectId;\n\t}\n\n\t/**\n\t * Get the numeric perpetuals account ID.\n\t *\n\t * This is the protocol-level identifier (bigint-derived) used across API calls.\n\t *\n\t * @returns {@link PerpetualsAccountId} for this account.\n\t */\n\tpublic accountId(): PerpetualsAccountId {\n\t\treturn this.accountCap.accountId;\n\t}\n\n\t/**\n\t * Get the account cap object ID, if this is a direct account.\n\t *\n\t * Direct accounts are controlled via an on-chain “cap” object. Vault-backed\n\t * accounts are controlled via vault caps and do not expose a direct account-cap ID.\n\t *\n\t * @throws If called for a vault-backed account.\n\t *\n\t * @returns {@link ObjectId} of the account cap.\n\t */\n\tpublic accountCapId(): ObjectId {\n\t\tif (\"vaultId\" in this.accountCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"not account cap id present on vault owned account\"\n\t\t\t);\n\t\treturn this.accountCap.objectId;\n\t}\n\n\t// public closePositionTxInputs = (inputs: {\n\t// \tsize: bigint;\n\t// \tmarket: PerpetualsMarket;\n\t// \torderDatas: PerpetualsOrderData[];\n\t// \tindexPrice: number;\n\t// \tcollateralPrice: number;\n\t// }): SdkPerpetualsPlaceMarketOrderInputs => {\n\t// \tconst { size, market, orderDatas, collateralPrice } = inputs;\n\t//\n\t// \tconst marketId = market.marketId;\n\t// \tconst position =\n\t// \t\tthis.positionForMarketId({ marketId }) ?? market.emptyPosition();\n\t//\n\t// \t// TODO: move conversion to helper function, since used often\n\t// \tconst ordersCollateral = Helpers.sum(\n\t// \t\torderDatas\n\t// \t\t\t.filter((orderData) => orderData.marketId === market.marketId)\n\t// \t\t\t.map(\n\t// \t\t\t\t(orderData) =>\n\t// \t\t\t\t\tmarket.calcCollateralUsedForOrder({\n\t// \t\t\t\t\t\t...inputs,\n\t// \t\t\t\t\t\torderData,\n\t// \t\t\t\t\t\tleverage: position.leverage,\n\t// \t\t\t\t\t}).collateral\n\t// \t\t\t)\n\t// \t);\n\t//\n\t// \tconst fullPositionCollateralChange =\n\t// \t\tMath.max(\n\t// \t\t\tthis.calcFreeMarginUsdForPosition(inputs) / collateralPrice -\n\t// \t\t\t\tordersCollateral *\n\t// \t\t\t\t\t(1 -\n\t// \t\t\t\t\t\tPerpetualsAccount.constants\n\t// \t\t\t\t\t\t\t.closePositionMarginOfError),\n\t// \t\t\t0\n\t// \t\t) * -1;\n\t//\n\t// \t// NOTE: is this safe / correct ?\n\t// \tconst collateralChange =\n\t// \t\tNumber(fullPositionCollateralChange) *\n\t// \t\t(Number(size) /\n\t// \t\t\tCasting.Fixed.fixedOneN9 /\n\t// \t\t\tposition.baseAssetAmount);\n\t//\n\t// \tconst positionSide = Perpetuals.positionSide(position);\n\t// \treturn {\n\t// \t\tsize,\n\t// \t\tmarketId,\n\t// \t\tcollateralChange,\n\t// \t\t// leverage: position.leverage || 1,\n\t// \t\t// leverage: undefined,\n\t// \t\tside:\n\t// \t\t\tpositionSide === PerpetualsOrderSide.Bid\n\t// \t\t\t\t? PerpetualsOrderSide.Ask\n\t// \t\t\t\t: PerpetualsOrderSide.Bid,\n\t// \t\t// hasPosition: this.positionForMarketId({ marketId }) !== undefined,\n\t// \t\treduceOnly: true,\n\t// \t};\n\t// };\n}\n","import { type PerpetualsOrderId, PerpetualsOrderSide } from \"../../../types\";\nimport { Perpetuals } from \"..\";\n\nconst MASK_64 = (BigInt(1) << BigInt(64)) - BigInt(1);\nconst MASK_128 = (BigInt(1) << BigInt(128)) - BigInt(1);\nconst ASK_THRESHOLD = BigInt(1) << BigInt(127);\n\nexport class PerpetualsOrderUtils {\n // Return order_id given price, counter and side\n public static orderId = (\n price: bigint,\n counter: bigint,\n side: PerpetualsOrderSide\n ): PerpetualsOrderId => {\n if (side) {\n return this.orderIdAsk(price, counter);\n }\n return this.orderIdBid(price, counter);\n };\n\n // Return order_id for ask order, given price, counter\n // (price << 64) | counter\n private static orderIdAsk = (\n price: bigint,\n counter: bigint\n ): PerpetualsOrderId => {\n return (price << BigInt(64)) | counter;\n };\n\n // Return order_id for bid order, given price, counter and side\n // ((price ^ 0xffff_ffff_ffff_ffff) << 64) | counter\n private static orderIdBid = (\n price: bigint,\n counter: bigint\n ): PerpetualsOrderId => {\n return ((price ^ MASK_64) << BigInt(64)) | counter;\n };\n\n // Return price of given `order_id`, (works for ask or bid)\n public static price = (orderId: PerpetualsOrderId): bigint => {\n const side = Perpetuals.orderIdToSide(orderId);\n if (side === PerpetualsOrderSide.Ask) {\n return this.priceAsk(orderId);\n }\n return this.priceBid(orderId);\n };\n\n // Returns price of a given ask `order_id`.\n private static priceAsk = (orderId: PerpetualsOrderId): bigint => {\n return orderId >> BigInt(64);\n };\n\n // Returns price of a given bid `order_id`.\n private static priceBid = (orderId: PerpetualsOrderId): bigint => {\n return (orderId >> BigInt(64)) ^ MASK_64;\n };\n\n public static counter = (orderId: PerpetualsOrderId): bigint => {\n return orderId & MASK_128;\n };\n\n public static isAsk = (orderId: PerpetualsOrderId): boolean => {\n return orderId < ASK_THRESHOLD;\n };\n}\n","export * from \"./perpetualsOrderUtils\";\n","import {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody,\n\tApiPerpetualsVaultOwnerUpdateLockPeriodTxBody,\n\tApiPerpetualsVaultProcessForceWithdrawRequestTxBody,\n\tApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody,\n\tBalance,\n\tCallerConfig,\n\tPerpetualsMarketId,\n\tPerpetualsVaultObject,\n\tSuiAddress,\n\tApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody,\n\tApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse,\n\tApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody,\n\tPerpetualsVaultWithdrawRequest,\n\tApiPerpetualsVaultsWithdrawRequestsBody,\n\tApiPerpetualsVaultOwnedWithdrawRequestsBody,\n\tApiPerpetualsVaultCreateWithdrawRequestTxBody,\n\tApiPerpetualsVaultCancelWithdrawRequestTxBody,\n\tApiPerpetualsVaultDepositTxBody,\n\tApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody,\n\tApiPerpetualsVaultPreviewCreateWithdrawRequestBody,\n\tApiPerpetualsVaultPreviewCreateWithdrawRequestResponse,\n\tApiPerpetualsVaultPreviewDepositResponse,\n\tApiPerpetualsVaultPreviewDepositBody,\n\tApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse,\n\tApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody,\n\tApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse,\n\tApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody,\n\tApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse,\n\tApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody,\n\tPerpetualsVaultCap,\n\tApiTransactionResponse,\n\tObjectId,\n\tPerpetualsPartialVaultCap,\n\tApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse,\n\tApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody,\n\tApiPerpetualsVaultOwnerWithdrawCollateralTxBody,\n\tApiPerpetualsVaultsWithdrawRequestsResponse,\n\tApiPerpetualsVaultOwnerWithdrawCollateralTxResponse,\n\tApiPerpetualsVaultProcessForceWithdrawRequestTxResponse,\n\tPerpetualsAccountObject,\n\tApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody,\n\tApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse,\n\tApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody,\n} from \"../../types\";\nimport { PerpetualsAccount } from \"./perpetualsAccount\";\nimport { Perpetuals } from \"./perpetuals\";\n\n/**\n * High-level wrapper around a single Perpetuals vault.\n *\n * A vault is a managed perpetuals account that accepts user deposits (LP),\n * trades across up to a bounded set of markets, and supports withdrawals via\n * a request flow.\n *\n * This class provides:\n *\n * - Transaction builders for:\n * - User actions (deposit, create/cancel withdraw request, update slippage)\n * - Force-withdraw processing (close positions and settle a request)\n * - Owner admin actions (update params, process requests, withdraw fees/collateral)\n * - Read helpers for:\n * - Vault withdraw requests\n * - LP token pricing\n * - Accessing the vault’s underlying perpetuals account\n * - Static validation helpers for LP coin metadata (name/symbol constraints)\n * - A small calculation helper for withdraw-request slippage\n *\n * Typical usage:\n *\n * ```ts\n * const perps = afSdk.Perpetuals();\n * const { vaults } = await perps.getAllVaults();\n * const vault = vaults[0];\n *\n * const { tx } = await vault.getDepositTx({\n * walletAddress: \"0x...\",\n * depositAmount: BigInt(\"1000000000\"),\n * minLpAmountOut: 0n,\n * });\n * ```\n */\nexport class PerpetualsVault extends Caller {\n\t// =========================================================================\n\t// Public Constants\n\t// =========================================================================\n\n\t/**\n\t * Vault-level protocol limits and UI-friendly constraints.\n\t *\n\t * @remarks\n\t * These are SDK constants (not fetched from chain). They should match the\n\t * on-chain / backend limits enforced by the vault module.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * Maximum lock period in milliseconds.\n\t\t */\n\t\tmaxLockPeriodMs: 5184000000, // 2 months\n\n\t\t/**\n\t\t * Maximum period for force withdraw delay in milliseconds.\n\t\t */\n\t\tmaxForceWithdrawDelayMs: 86400000, // 1 day\n\n\t\t/**\n\t\t * Maximum vault fee (performance fee).\n\t\t */\n\t\tmaxPerformanceFeePercentage: 0.2, // 20%\n\n\t\t/**\n\t\t * Minimum USD value required for user deposits.\n\t\t */\n\t\tminDepositUsd: 1,\n\n\t\t/**\n\t\t * Minimum USD value required to be locked by vault owner during vault creation.\n\t\t */\n\t\tminOwnerLockUsd: 1,\n\n\t\t/**\n\t\t * The maximum number of distinct markets (`ClearingHouse`s) the vault can trade.\n\t\t */\n\t\tmaxMarketsInVault: 12,\n\n\t\t/**\n\t\t * The maximum number of pending orders allowed for a single position in the vault.\n\t\t */\n\t\tmaxPendingOrdersPerPosition: 70,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Create a new {@link PerpetualsVault} wrapper.\n\t *\n\t * @param vaultObject - Raw on-chain vault object snapshot.\n\t * @param config - Optional {@link CallerConfig} (network, auth, base URL).\n\t * @param Provider - Optional shared {@link AftermathApi} provider. When provided,\n\t * transaction builders will serialize {@link Transaction}s into `txKind`.\n\t */\n\tconstructor(\n\t\tpublic readonly vaultObject: PerpetualsVaultObject,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"perpetuals\");\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Withdraw Request Txs\n\t// =========================================================================\n\n\t/**\n\t * Build a `process-force-withdraw-request` transaction.\n\t *\n\t * Force-withdraw is a mechanism that closes required positions and processes\n\t * a withdraw request after a delay window (see vault params).\n\t *\n\t * @param inputs.walletAddress - User wallet that owns the withdraw request.\n\t * @param inputs.sizesToClose - Mapping of marketId -> size (base units) to close.\n\t * @param inputs.recipientAddress - Optional recipient of the withdrawn collateral.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx` (and any additional outputs\n\t * provided by the backend response type).\n\t */\n\tpublic async getProcessForceWithdrawRequestTx(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\t// TODO: change to arr ?\n\t\tsizesToClose: Record<PerpetualsMarketId, Balance>;\n\t\trecipientAddress?: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultProcessForceWithdrawRequestTxBody,\n\t\t\tApiPerpetualsVaultProcessForceWithdrawRequestTxResponse\n\t\t>(\n\t\t\t\"vault/transactions/process-force-withdraw-request\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t// TODO: docs\n\tpublic async getPauseVaultForForceWithdrawRequestTx(inputs: {\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultPauseVaultForForceWithdrawRequestTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/pause-vault-for-force-withdraw-request\",\n\t\t\t{\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build an `update-withdraw-request-slippage` transaction.\n\t *\n\t * This updates the user's minimum acceptable collateral output amount\n\t * for an existing withdraw request.\n\t *\n\t * @param inputs.minCollateralAmountOut - New minimum collateral amount out.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getUpdateWithdrawRequestSlippageTx(inputs: {\n\t\tminCollateralAmountOut: Balance;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultUpdateWithdrawRequestSlippageTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/update-withdraw-request-slippage\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Owner Settings Txs\n\t// =========================================================================\n\n\t/**\n\t * Build an owner transaction to update the vault's force withdraw delay.\n\t *\n\t * @param inputs.forceWithdrawDelayMs - New delay (ms). Should be <= {@link constants.maxForceWithdrawDelayMs}.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getOwnerUpdateForceWithdrawDelayTx(inputs: {\n\t\tforceWithdrawDelayMs: bigint;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerUpdateForceWithdrawDelayTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/update-force-withdraw-delay\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build an owner transaction to update the vault's lock period.\n\t *\n\t * @param inputs.lockPeriodMs - New lock period (ms). Should be <= {@link constants.maxLockPeriodMs}.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getOwnerUpdateLockPeriodTx(inputs: {\n\t\tlockPeriodMs: bigint;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerUpdateLockPeriodTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/update-lock-period\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build an owner transaction to update the vault performance fee.\n\t *\n\t * @param inputs.performanceFeePercentage - New fee as a fraction (e.g. `0.2` = 20%).\n\t * Should be <= {@link constants.maxPerformanceFeePercentage}.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getOwnerUpdatePerformanceFeeTx(inputs: {\n\t\tperformanceFeePercentage: number;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerUpdatePerformanceFeeTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/update-performance-fee\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Owner Interactions Txs\n\t// =========================================================================\n\n\t/**\n\t * Build an owner transaction to process one or more users' withdraw requests.\n\t *\n\t * This is the normal (non-force) processing path for withdrawals. The owner\n\t * batches users and settles their requests in a single transaction.\n\t *\n\t * @param inputs.userAddresses - Users whose requests should be processed.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getOwnerProcessWithdrawRequestsTx(inputs: {\n\t\tuserAddresses: SuiAddress[];\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerProcessWithdrawRequestsTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/process-withdraw-requests\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build an owner transaction to withdraw accrued performance fees.\n\t *\n\t * @param inputs.withdrawAmount - Amount of collateral to withdraw as fees.\n\t * @param inputs.recipientAddress - Optional recipient address for the withdrawn fees.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Response containing `tx` and any extra outputs described by\n\t * {@link ApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse}.\n\t */\n\tpublic async getOwnerWithdrawPerformanceFeesTx(inputs: {\n\t\twithdrawAmount: Balance;\n\t\trecipientAddress?: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx: txFromInputs, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxBody,\n\t\t\tApiPerpetualsVaultOwnerWithdrawPerformanceFeesTxResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/withdraw-performance-fees\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: txFromInputs ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build an owner transaction to withdraw vault collateral by redeeming LP.\n\t *\n\t * @param inputs.lpWithdrawAmount - Amount of LP to redeem.\n\t * @param inputs.minCollateralAmountOut - Minimum collateral out to protect from slippage.\n\t * @param inputs.recipientAddress - Optional recipient address for withdrawn collateral.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Response containing `tx` and any extra outputs described by\n\t * {@link ApiPerpetualsVaultOwnerWithdrawCollateralTxResponse}.\n\t */\n\tpublic async getOwnerWithdrawCollateralTx(inputs: {\n\t\tlpWithdrawAmount: Balance;\n\t\tminCollateralAmountOut: Balance;\n\t\trecipientAddress?: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultOwnerWithdrawCollateralTxBody,\n\t\t\tApiPerpetualsVaultOwnerWithdrawCollateralTxResponse\n\t\t>(\n\t\t\t\"vault/transactions/owner/withdraw-collateral\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// User Interactions Txs\n\t// =========================================================================\n\n\t/**\n\t * Build a user transaction to create a vault withdraw request.\n\t *\n\t * Withdrawals are request-based: the user specifies how much LP to redeem\n\t * and a minimum collateral output amount.\n\t *\n\t * @param inputs.walletAddress - Wallet creating the request.\n\t * @param inputs.lpWithdrawAmount - Amount of LP to withdraw.\n\t * @param inputs.minCollateralAmountOut - Minimum collateral out (slippage guard).\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getCreateWithdrawRequestTx(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tlpWithdrawAmount: Balance;\n\t\tminCollateralAmountOut: Balance;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultCreateWithdrawRequestTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/create-withdraw-request\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build a user transaction to cancel an existing vault withdraw request.\n\t *\n\t * @param inputs.walletAddress - Wallet canceling the request.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t */\n\tpublic async getCancelWithdrawRequestTx(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultCancelWithdrawRequestTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/cancel-withdraw-request\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t/**\n\t * Build a user transaction to deposit collateral into the vault in exchange for LP.\n\t *\n\t * You can specify the deposit as:\n\t * - `depositAmount` (wallet pays directly), OR\n\t * - `depositCoinArg` (use an existing transaction argument)\n\t *\n\t * @param inputs.walletAddress - Depositor wallet.\n\t * @param inputs.minLpAmountOut - Minimum LP out (slippage guard).\n\t * @param inputs.isSponsoredTx - Whether the tx is sponsored (gas paid by another party).\n\t * @param inputs.depositAmount - Amount of collateral to deposit (mutually exclusive with `depositCoinArg`).\n\t * @param inputs.depositCoinArg - Transaction argument referencing collateral coin.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { txKind } = await vault.getDepositTx({\n\t * walletAddress: \"0x...\",\n\t * depositAmount: 1_000_000_000n,\n\t * minLpAmountOut: 0n,\n\t * });\n\t * ```\n\t */\n\t// TODO: make return lp coin out ?\n\tpublic async getDepositTx(\n\t\tinputs: {\n\t\t\twalletAddress: SuiAddress;\n\t\t\tminLpAmountOut: Balance;\n\t\t\ttx?: Transaction;\n\t\t\tisSponsoredTx?: boolean;\n\t\t} & (\n\t\t\t| { depositAmount: Balance }\n\t\t\t| { depositCoinArg: TransactionObjectArgument }\n\t\t)\n\t) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\n\t\tconst depositInputs =\n\t\t\t\"depositAmount\" in otherInputs\n\t\t\t\t? {\n\t\t\t\t\t\tdepositAmount: otherInputs.depositAmount,\n\t\t\t\t\t\tcollateralCoinType: this.vaultObject.collateralCoinType,\n\t\t\t\t }\n\t\t\t\t: { depositCoinArg: otherInputs.depositCoinArg };\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsVaultDepositTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/deposit\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\t...depositInputs,\n\t\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t/**\n\t * Fetch all withdraw requests for this vault.\n\t *\n\t * @returns {@link ApiPerpetualsVaultsWithdrawRequestsResponse} containing requests\n\t * scoped to `this.vaultObject.objectId`.\n\t *\n\t * @remarks\n\t * This currently calls the `vaults/withdraw-requests` endpoint with a single vault ID.\n\t * This may be moved to {@link Perpetuals} as a shared helper.\n\t */\n\t// TODO: move to `Perpetuals` (as well) ?\n\tpublic getAllWithdrawRequests(): Promise<ApiPerpetualsVaultsWithdrawRequestsResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultsWithdrawRequestsResponse,\n\t\t\tApiPerpetualsVaultsWithdrawRequestsBody\n\t\t>(\"vaults/withdraw-requests\", {\n\t\t\tvaultIds: [this.vaultObject.objectId],\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Owner Previews\n\t// =========================================================================\n\n\t/**\n\t * Preview the results of an owner processing one or more withdraw requests.\n\t *\n\t * @param inputs.userAddresses - Users to process.\n\t * @returns Preview response with expected effects.\n\t */\n\tpublic async getPreviewOwnerProcessWithdrawRequests(inputs: {\n\t\t// NOTE: should these be `walletAddresses` instead ?\n\t\tuserAddresses: SuiAddress[];\n\t}) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsResponse,\n\t\t\tApiPerpetualsVaultPreviewOwnerProcessWithdrawRequestsBody\n\t\t>(\"vault/previews/owner/process-withdraw-requests\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t/**\n\t * Preview the amount available for the owner to withdraw as performance fees.\n\t *\n\t * @returns Preview response including withdrawable fees and related metadata.\n\t */\n\tpublic async getPreviewOwnerWithdrawPerformanceFees() {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesResponse,\n\t\t\tApiPerpetualsVaultPreviewOwnerWithdrawPerformanceFeesBody\n\t\t>(\"vault/previews/owner/withdraw-performance-fees\", {\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t/**\n\t * Preview an owner collateral withdrawal (LP redemption).\n\t *\n\t * @param inputs.lpWithdrawAmount - LP amount to redeem.\n\t * @returns Preview response including estimated collateral out.\n\t */\n\tpublic async getPreviewOwnerWithdrawCollateral(inputs: {\n\t\tlpWithdrawAmount: Balance;\n\t}) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewOwnerWithdrawCollateralResponse,\n\t\t\tApiPerpetualsVaultPreviewOwnerWithdrawCollateralBody\n\t\t>(\"vault/previews/owner/withdraw-collateral\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// User Previews\n\t// =========================================================================\n\n\t/**\n\t * Preview creating a withdraw request.\n\t *\n\t * @param inputs.walletAddress - Requesting wallet.\n\t * @param inputs.lpWithdrawAmount - LP amount to withdraw.\n\t * @returns Preview response including estimated collateral out and constraints.\n\t */\n\tpublic async getPreviewCreateWithdrawRequest(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tlpWithdrawAmount: Balance;\n\t}) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewCreateWithdrawRequestResponse,\n\t\t\tApiPerpetualsVaultPreviewCreateWithdrawRequestBody\n\t\t>(\"vault/previews/create-withdraw-request\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t/**\n\t * Preview depositing into the vault.\n\t *\n\t * @param inputs.depositAmount - Deposit amount in collateral coin units.\n\t * @returns Preview response including estimated LP out.\n\t */\n\tpublic async getPreviewDeposit(inputs: { depositAmount: Balance }) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewDepositResponse,\n\t\t\tApiPerpetualsVaultPreviewDepositBody\n\t\t>(\"vault/previews/deposit\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t/**\n\t * Preview processing a force withdraw request for a user.\n\t *\n\t * This is useful to determine what positions/sizes must be closed or what\n\t * the expected outputs are prior to building the actual transaction.\n\t *\n\t * @param inputs.walletAddress - User wallet with a pending force-withdraw.\n\t * @returns Preview response describing expected processing effects.\n\t */\n\tpublic async getPreviewProcessForceWithdrawRequest(inputs: {\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewProcessForceWithdrawRequestResponse,\n\t\t\tApiPerpetualsVaultPreviewProcessForceWithdrawRequestBody\n\t\t>(\"vault/previews/process-force-withdraw-request\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t// TODO: docs\n\tpublic async getPreviewPauseVaultForForceWithdrawRequest(inputs: {\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestResponse,\n\t\t\tApiPerpetualsVaultPreviewPauseVaultForForceWithdrawRequestBody\n\t\t>(\"vault/previews/pause-vault-for-force-withdraw-request\", {\n\t\t\t...inputs,\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Fetch the current LP coin price for this vault (in collateral units).\n\t *\n\t * Internally calls {@link Perpetuals.getLpCoinPrices} and returns the first price.\n\t *\n\t * @returns LP coin price as a `number`.\n\t */\n\tpublic async getLpCoinPrice(): Promise<number> {\n\t\treturn (\n\t\t\tawait new Perpetuals(this.config, this.Provider).getLpCoinPrices({\n\t\t\t\tvaultIds: [this.vaultObject.objectId],\n\t\t\t})\n\t\t).lpCoinPrices[0];\n\t}\n\n\t// =========================================================================\n\t// Account\n\t// =========================================================================\n\n\t/**\n\t * Build a lightweight “cap-like” object for the vault’s underlying account.\n\t *\n\t * @returns {@link PerpetualsPartialVaultCap} suitable for account fetch helpers\n\t * such as {@link Perpetuals.getAccount}.\n\t */\n\tpublic partialVaultCap(): PerpetualsPartialVaultCap {\n\t\treturn {\n\t\t\tvaultId: this.vaultObject.objectId,\n\t\t\townerAddress: this.vaultObject.ownerAddress,\n\t\t\taccountId: this.vaultObject.accountId,\n\t\t\taccountObjectId: this.vaultObject.accountObjectId,\n\t\t\tcollateralCoinType: this.vaultObject.collateralCoinType,\n\t\t};\n\t}\n\n\t/**\n\t * Fetch the underlying perpetuals account object for this vault.\n\t *\n\t * @returns `{ account }` where `account` is the on-chain {@link PerpetualsAccountObject}.\n\t */\n\tpublic async getAccountObject(): Promise<{\n\t\taccount: PerpetualsAccountObject;\n\t}> {\n\t\treturn {\n\t\t\taccount: (\n\t\t\t\tawait new Perpetuals(\n\t\t\t\t\tthis.config,\n\t\t\t\t\tthis.Provider\n\t\t\t\t).getAccountObjects({\n\t\t\t\t\taccountIds: [this.vaultObject.accountId],\n\t\t\t\t})\n\t\t\t).accounts[0],\n\t\t};\n\t}\n\n\t/**\n\t * Fetch a {@link PerpetualsAccount} wrapper for the vault’s underlying account.\n\t *\n\t * @returns `{ account }` where `account` is a high-level {@link PerpetualsAccount}.\n\t */\n\tpublic async getAccount(): Promise<{ account: PerpetualsAccount }> {\n\t\treturn new Perpetuals(this.config, this.Provider).getAccount({\n\t\t\taccountCap: this.partialVaultCap(),\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\t// TODO: docs\n\tpublic isPaused(): boolean {\n\t\treturn !!(\n\t\t\tthis.vaultObject.pausedUntilTimestamp &&\n\t\t\tthis.vaultObject.pausedUntilTimestamp > BigInt(Date.now())\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Static\n\t// =========================================================================\n\n\t/**\n\t * Checks if a string is a valid LP coin name.\n\t *\n\t * @param value - The string to check.\n\t * @returns `true` if `value` can be used as a valid LP coin name, otherwise `false`.\n\t *\n\t * @remarks\n\t * Current rule: ASCII-only. This aligns with many on-chain metadata constraints.\n\t */\n\tpublic static isValidLpCoinName = (value: string): boolean => {\n\t\treturn /^[\\x00-\\x7F]+$/.test(value);\n\t};\n\n\t/**\n\t * Checks if a string is a valid LP coin type symbol.\n\t *\n\t * @param value - The string to check.\n\t * @returns `true` if `value` can be used as a valid LP coin type symbol, otherwise `false`.\n\t *\n\t * @remarks\n\t * Current rule: uppercase A–Z plus underscore.\n\t */\n\tpublic static isValidLpCoinTypeSymbol = (value: string): boolean => {\n\t\treturn /^[A-Z_]+$/.test(value);\n\t};\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Compute the implied slippage tolerance for a withdraw request.\n\t *\n\t * Defined as:\n\t * ```text\n\t * (lpAmountInUsd - minCollateralAmountOutUsd) / lpAmountInUsd\n\t * ```\n\t *\n\t * @param inputs.withdrawRequest - Withdraw request to analyze.\n\t * @returns Slippage fraction (0..1). Returns `0` if `lpAmountInUsd` is missing/zero.\n\t */\n\tpublic static calcWithdrawRequestSlippage = (inputs: {\n\t\twithdrawRequest: PerpetualsVaultWithdrawRequest;\n\t}) => {\n\t\tconst { withdrawRequest } = inputs;\n\t\treturn withdrawRequest.lpAmountInUsd\n\t\t\t? (withdrawRequest.lpAmountInUsd -\n\t\t\t\t\twithdrawRequest.minCollateralAmountOutUsd) /\n\t\t\t\t\twithdrawRequest.lpAmountInUsd\n\t\t\t: 0;\n\t};\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiPerpetualsCreateAccountBody,\n\tSuiNetwork,\n\tUrl,\n\tPerpetualsMarketState,\n\tPerpetualsMarketData,\n\tPerpetualsAccountData,\n\tPerpetualsMarketId,\n\tApiPerpetualsOwnedAccountCapsBody,\n\tPerpetualsPosition,\n\tPerpetualsOrderSide,\n\tPerpetualsOrderbook,\n\tCoinType,\n\tPerpetualsOrderId,\n\tFilledTakerOrderEvent,\n\tTimestamp,\n\tPerpetualsMarketCandleDataPoint,\n\tApiPerpetualsMarketCandleHistoryResponse,\n\tPerpetualsAccountCap,\n\tPerpetualsAccountId,\n\tPerpetualsAccountObject,\n\tIFixed,\n\tMoveErrorCode,\n\tCallerConfig,\n\tSuiAddress,\n\tObjectId,\n\tApiPerpetualsMarkets24hrStatsResponse,\n\tApiPerpetualsAdminAccountCapsBody,\n\tPerpetualsVaultObject,\n\tPercentage,\n\tBalance,\n\tPerpetualsVaultCap,\n\tPerpetualsVaultWithdrawRequest,\n\tApiPerpetualsVaultOwnedWithdrawRequestsBody,\n\tPerpetualsOrderPrice,\n\tApiTransactionResponse,\n\tPerpetualsWsUpdatesSubscriptionMessage,\n\tPerpetualsWsUpdatesResponseMessage,\n\tPerpetualsWsCandleResponseMessage,\n\tApiPerpetualsCreateVaultBody,\n\tApiPerpetualsCreateVaultCapBody,\n\tPerpetualsVaultLpCoin,\n\tPerpetualsPartialVaultCap,\n\tPerpetualsVaultMetatada,\n\tApiPerpetualsMarketCandleHistoryBody,\n\tApiPerpetualsAdminAccountCapsResponse,\n\tApiPerpetualsOwnedAccountCapsResponse,\n\tApiPerpetualsAccountPositionsResponse,\n\tApiPerpetualsAccountPositionsBody,\n\tApiPerpetualsAllMarketsResponse,\n\tApiPerpetualsAllMarketsBody,\n\tApiPerpetualsMarketsBody,\n\tApiPerpetualsMarketsResponse,\n\tApiPerpetualsMarketsPricesResponse,\n\tApiPerpetualsMarketsPricesBody,\n\tApiPerpetualsVaultLpCoinPricesResponse,\n\tApiPerpetualsVaultLpCoinPricesBody,\n\tApiPerpetualsVaultOwnedLpCoinsResponse,\n\tApiPerpetualsVaultOwnedLpCoinsBody,\n\tApiPerpetualsOwnedVaultCapsBody,\n\tApiPerpetualsOwnedVaultCapsResponse,\n\tApiPerpetualsVaultOwnedWithdrawRequestsResponse,\n\tApiPerpetualsVaultsResponse,\n\tApiPerpetualsVaultsBody,\n\tSdkTransactionResponse,\n\tApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody,\n\tApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody,\n\tApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody,\n\tApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse,\n\tApiPerpetualsBuilderCodesIntegratorConfigBody,\n\tApiPerpetualsBuilderCodesIntegratorConfigResponse,\n\tApiPerpetualsBuilderCodesIntegratorVaultsBody,\n\tApiPerpetualsBuilderCodesIntegratorVaultsResponse,\n\tApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody,\n\tApiPerpetualsTransferCapTxBody,\n} from \"../../types\";\nimport { PerpetualsMarket } from \"./perpetualsMarket\";\nimport { PerpetualsAccount } from \"./perpetualsAccount\";\nimport { IFixedUtils } from \"../../general/utils/iFixedUtils\";\nimport { FixedUtils } from \"../../general/utils/fixedUtils\";\nimport { Casting, Helpers } from \"../../general/utils\";\nimport { PerpetualsOrderUtils } from \"./utils\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Coin } from \"../coin\";\nimport {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { PerpetualsVault } from \"./perpetualsVault\";\n\n/**\n * High-level client for interacting with Aftermath Perpetuals.\n *\n * This class exposes a typed, ergonomic interface over the Perpetuals HTTP API\n * and websocket endpoints, including:\n *\n * - Market discovery (`getAllMarkets`, `getMarkets`, `getMarket`)\n * - Vault discovery (`getAllVaults`, `getVaults`, `getVault`)\n * - Account & position data (`getAccount`, `getAccounts`, `getAccountObjects`)\n * - Ownership queries (`getOwnedAccountCaps`, `getOwnedVaultCaps`)\n * - Historical data & stats (`getMarketCandleHistory`, `getMarkets24hrStats`)\n * - Pricing helpers (`getPrices`, `getLpCoinPrices`)\n * - Transaction builders (`getCreateAccountTx`, `getCreateVaultCapTx`, `getCreateVaultTx`)\n * - Websocket feeds (`openUpdatesWebsocketStream`, `openMarketCandlesWebsocketStream`)\n *\n * Typical usage via the root SDK:\n *\n * ```ts\n * import { Aftermath } from \"@aftermath/sdk\";\n *\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init();\n *\n * const perps = afSdk.Perpetuals();\n *\n * // Fetch markets for a given collateral coin type\n * const markets = await perps.getAllMarkets({\n * collateralCoinType: \"0x2::sui::SUI\",\n * });\n *\n * // Fetch account + positions for a given account cap\n * const [accountCap] = await perps.getOwnedAccountCaps({\n * walletAddress: \"0x...\",\n * });\n *\n * const account = await perps.getAccount({ accountCap });\n *\n * // Build a create-account transaction (not signed or sent)\n * const createAccountTx = await perps.getCreateAccountTx({\n * walletAddress: \"0x...\",\n * collateralCoinType: \"0x2::sui::SUI\",\n * });\n * ```\n */\nexport class Perpetuals extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Helper namespace for order-specific utilities such as parsing order IDs,\n\t * extracting price bits, etc.\n\t *\n\t * This is a direct alias of {@link PerpetualsOrderUtils}.\n\t */\n\tpublic static readonly OrderUtils = PerpetualsOrderUtils;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new Perpetuals client.\n\t *\n\t * @param config - Optional caller configuration (network, auth token, etc.).\n\t * @param Provider - Optional shared {@link AftermathApi} provider instance. When\n\t * provided, transaction-building helpers can derive serialized `txKind`\n\t * from a {@link Transaction} object via `Provider.Transactions().fetchBase64TxKindFromTx`.\n\t *\n\t * @remarks\n\t * This class extends {@link Caller} with the `\"perpetuals\"` route prefix, meaning:\n\t * - HTTP calls resolve under `/perpetuals/...`\n\t * - Websocket calls resolve under `/perpetuals/ws/...`\n\t */\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"perpetuals\");\n\t}\n\n\t// =========================================================================\n\t// Markets\n\t// =========================================================================\n\n\t/**\n\t * Fetch all perpetual markets for a given collateral coin type.\n\t *\n\t * This method returns *wrapped* {@link PerpetualsMarket} instances, not the raw\n\t * market structs. Each instance provides additional helpers for pricing, margin,\n\t * and order parsing.\n\t *\n\t * @param inputs.collateralCoinType - Coin type used as collateral, e.g. `\"0x2::sui::SUI\"`.\n\t * @returns Object containing `markets`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { markets } = await perps.getAllMarkets({\n\t * collateralCoinType: \"0x2::sui::SUI\",\n\t * });\n\t * ```\n\t */\n\tpublic async getAllMarkets(inputs: {\n\t\tcollateralCoinType: CoinType;\n\t}): Promise<{\n\t\tmarkets: PerpetualsMarket[];\n\t}> {\n\t\tconst res = await this.fetchApi<\n\t\t\tApiPerpetualsAllMarketsResponse,\n\t\t\tApiPerpetualsAllMarketsBody\n\t\t>(\"all-markets\", inputs);\n\t\treturn {\n\t\t\tmarkets: res.markets.map(\n\t\t\t\t(marketData) =>\n\t\t\t\t\tnew PerpetualsMarket(marketData, this.config, this.Provider)\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * Fetch a single market by ID.\n\t *\n\t * Internally calls {@link getMarkets} and returns the first entry.\n\t *\n\t * @param inputs.marketId - The market (clearing house) object ID.\n\t * @returns Object containing `market`.\n\t *\n\t * @throws If the backend returns an empty list for the given `marketId`,\n\t * this will still attempt to return `markets[0]` (which would be `undefined`).\n\t * Callers may want to validate the result.\n\t *\n\t * @example\n\t * ```ts\n\t * const { market } = await perps.getMarket({ marketId: \"0x...\" });\n\t * ```\n\t */\n\tpublic async getMarket(inputs: {\n\t\tmarketId: PerpetualsMarketId;\n\t}): Promise<{ market: PerpetualsMarket }> {\n\t\tconst { markets } = await this.getMarkets({\n\t\t\tmarketIds: [inputs.marketId],\n\t\t});\n\t\treturn {\n\t\t\tmarket: markets[0],\n\t\t};\n\t}\n\n\t/**\n\t * Fetch multiple markets by ID.\n\t *\n\t * Backend note:\n\t * - The API supports returning orderbooks. This SDK currently constructs\n\t * {@link PerpetualsMarket} from the returned `marketDatas[].market`.\n\t *\n\t * @param inputs.marketIds - Array of market object IDs to fetch.\n\t * @returns Object containing `markets` in the same order as `marketIds`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { markets } = await perps.getMarkets({\n\t * marketIds: [\"0x..A\", \"0x..B\"],\n\t * });\n\t * ```\n\t */\n\tpublic async getMarkets(inputs: {\n\t\tmarketIds: PerpetualsMarketId[];\n\t}): Promise<{\n\t\tmarkets: PerpetualsMarket[];\n\t}> {\n\t\tconst res = await this.fetchApi<\n\t\t\tApiPerpetualsMarketsResponse,\n\t\t\tApiPerpetualsMarketsBody\n\t\t>(\"markets\", inputs);\n\t\treturn {\n\t\t\tmarkets: res.marketDatas.map(\n\t\t\t\t(marketData) =>\n\t\t\t\t\tnew PerpetualsMarket(\n\t\t\t\t\t\tmarketData.market,\n\t\t\t\t\t\tthis.config,\n\t\t\t\t\t\tthis.Provider\n\t\t\t\t\t)\n\t\t\t),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Vaults\n\t// =========================================================================\n\n\t/**\n\t * Fetch all vaults on the current network.\n\t *\n\t * Vaults are managed accounts that can hold positions; LPs deposit collateral\n\t * and receive an LP coin (see pricing helpers like {@link getLpCoinPrices}).\n\t *\n\t * @returns Object containing `vaults`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { vaults } = await perps.getAllVaults();\n\t * ```\n\t */\n\tpublic async getAllVaults(): Promise<{\n\t\tvaults: PerpetualsVault[];\n\t}> {\n\t\tconst res = await this.fetchApi<\n\t\t\tApiPerpetualsVaultsResponse,\n\t\t\tApiPerpetualsVaultsBody\n\t\t>(\"vaults\", {});\n\t\treturn {\n\t\t\tvaults: res.vaults.map(\n\t\t\t\t(vaultObject) =>\n\t\t\t\t\tnew PerpetualsVault(vaultObject, this.config, this.Provider)\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * Fetch a single vault by ID.\n\t *\n\t * Internally calls {@link getVaults} and returns the first entry.\n\t *\n\t * @param inputs.vaultId - Vault object ID.\n\t * @returns Object containing `vault`.\n\t */\n\tpublic async getVault(inputs: { vaultId: ObjectId }): Promise<{\n\t\tvault: PerpetualsVault;\n\t}> {\n\t\tconst { vaults } = await this.getVaults({\n\t\t\tvaultIds: [inputs.vaultId],\n\t\t});\n\t\treturn {\n\t\t\tvault: vaults[0],\n\t\t};\n\t}\n\n\t/**\n\t * Fetch multiple vaults by ID.\n\t *\n\t * @param inputs.vaultIds - Array of vault object IDs.\n\t * @returns Object containing `vaults` in the same order as `vaultIds`.\n\t */\n\tpublic async getVaults(inputs: { vaultIds: ObjectId[] }): Promise<{\n\t\tvaults: PerpetualsVault[];\n\t}> {\n\t\tconst res = await this.fetchApi<\n\t\t\tApiPerpetualsVaultsResponse,\n\t\t\tApiPerpetualsVaultsBody\n\t\t>(\"vaults\", inputs);\n\t\treturn {\n\t\t\tvaults: res.vaults.map(\n\t\t\t\t(vaultObject) =>\n\t\t\t\t\tnew PerpetualsVault(vaultObject, this.config, this.Provider)\n\t\t\t),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Accounts\n\t// =========================================================================\n\n\t/**\n\t * Convenience helper to fetch a single account (positions + account object) from an account cap.\n\t *\n\t * Internally calls {@link getAccounts} and returns the first entry.\n\t *\n\t * @param inputs.accountCap - Account cap or partial vault cap object to derive account metadata from.\n\t * @param inputs.marketIds - Optional list of markets to filter positions by.\n\t * @returns Object containing `account`.\n\t *\n\t * @example\n\t * ```ts\n\t * const [accountCap] = await perps.getOwnedAccountCaps({ walletAddress: \"0x...\" });\n\t * const { account } = await perps.getAccount({ accountCap });\n\t * ```\n\t */\n\t// TODO: merge this with `getAccountObjects` as an option ?\n\tpublic async getAccount(inputs: {\n\t\taccountCap: PerpetualsAccountCap | PerpetualsPartialVaultCap;\n\t\tmarketIds?: PerpetualsMarketId[];\n\t}): Promise<{\n\t\taccount: PerpetualsAccount;\n\t}> {\n\t\tconst { accountCap, marketIds } = inputs;\n\t\treturn {\n\t\t\taccount: (\n\t\t\t\tawait this.getAccounts({\n\t\t\t\t\taccountCaps: [accountCap],\n\t\t\t\t\tmarketIds,\n\t\t\t\t})\n\t\t\t).accounts[0],\n\t\t};\n\t}\n\n\t/**\n\t * Fetch one or more accounts (positions + account objects) from account caps.\n\t *\n\t * This composes:\n\t * 1) {@link getAccountObjects} to fetch {@link PerpetualsAccountObject}s by account ID\n\t * 2) Local pairing of returned account objects with `accountCaps`\n\t *\n\t * The returned {@link PerpetualsAccount} instances encapsulate:\n\t * - The account snapshot (positions, balances, etc.)\n\t * - The ownership/cap metadata (accountId, collateral type, vaultId, etc.)\n\t *\n\t * @param inputs.accountCaps - Array of account caps or partial vault cap objects.\n\t * @param inputs.marketIds - Optional list of market IDs to filter positions by.\n\t * @returns Object containing `accounts` in the same order as `accountCaps`.\n\t *\n\t * @remarks\n\t * If `accountCaps` is empty, this returns `{ accounts: [] }` without making an API call.\n\t */\n\tpublic async getAccounts(inputs: {\n\t\taccountCaps: (PerpetualsAccountCap | PerpetualsPartialVaultCap)[];\n\t\tmarketIds?: PerpetualsMarketId[];\n\t}): Promise<{\n\t\taccounts: PerpetualsAccount[];\n\t}> {\n\t\tconst { accountCaps, marketIds } = inputs;\n\t\tif (accountCaps.length <= 0)\n\t\t\treturn {\n\t\t\t\taccounts: [],\n\t\t\t};\n\n\t\tconst accountObjects = (\n\t\t\tawait this.getAccountObjects({\n\t\t\t\taccountIds: accountCaps.map(\n\t\t\t\t\t(accountCap) => accountCap.accountId\n\t\t\t\t),\n\t\t\t\tmarketIds,\n\t\t\t})\n\t\t).accounts;\n\n\t\treturn {\n\t\t\taccounts: accountObjects.map(\n\t\t\t\t(account, index) =>\n\t\t\t\t\tnew PerpetualsAccount(\n\t\t\t\t\t\taccount,\n\t\t\t\t\t\taccountCaps[index],\n\t\t\t\t\t\tthis.config,\n\t\t\t\t\t\tthis.Provider\n\t\t\t\t\t)\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * Fetch raw account objects (including positions) for one or more account IDs.\n\t *\n\t * This is the lower-level primitive used by {@link getAccounts}.\n\t *\n\t * @param inputs.accountIds - List of account IDs to query.\n\t * @param inputs.marketIds - Optional list of market IDs to filter positions by.\n\t *\n\t * @returns {@link ApiPerpetualsAccountPositionsResponse} containing `accounts`.\n\t *\n\t * @remarks\n\t * If `accountIds` is empty, this returns `{ accounts: [] }` without making an API call.\n\t */\n\tpublic async getAccountObjects(\n\t\tinputs: ApiPerpetualsAccountPositionsBody\n\t): Promise<ApiPerpetualsAccountPositionsResponse> {\n\t\tconst { accountIds, marketIds } = inputs;\n\t\tif (accountIds.length <= 0)\n\t\t\treturn {\n\t\t\t\taccounts: [],\n\t\t\t};\n\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsAccountPositionsResponse,\n\t\t\tApiPerpetualsAccountPositionsBody\n\t\t>(\"accounts/positions\", {\n\t\t\taccountIds,\n\t\t\tmarketIds,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Ownership Queries\n\t// =========================================================================\n\n\t/**\n\t * Fetch all account caps (perpetuals accounts) owned by a wallet, optionally\n\t * filtered by collateral coin types.\n\t *\n\t * Returned values are “caps” (ownership objects), not full account snapshots.\n\t * To fetch account positions, use {@link getAccount} or {@link getAccounts}.\n\t *\n\t * @param inputs.walletAddress - Owner wallet address.\n\t * @param inputs.collateralCoinTypes - Optional list of collateral coin types to filter by.\n\t * @returns {@link ApiPerpetualsOwnedAccountCapsResponse} containing `accounts`.\n\t *\n\t * @example\n\t * ```ts\n\t * const { accounts } = await perps.getOwnedAccountCaps({\n\t * walletAddress: \"0x...\",\n\t * collateralCoinTypes: [\"0x2::sui::SUI\"],\n\t * });\n\t * ```\n\t */\n\tpublic async getOwnedAccountCaps(\n\t\tinputs: ApiPerpetualsOwnedAccountCapsBody\n\t) {\n\t\tconst { walletAddress, collateralCoinTypes } = inputs;\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsOwnedAccountCapsResponse,\n\t\t\tApiPerpetualsOwnedAccountCapsBody\n\t\t>(\"accounts/owned\", {\n\t\t\twalletAddress,\n\t\t\tcollateralCoinTypes,\n\t\t});\n\t}\n\n\t/**\n\t * Fetch all vault caps owned by a wallet.\n\t *\n\t * Vault caps represent ownership/administrative authority over a vault.\n\t *\n\t * @param inputs.walletAddress - Owner wallet address.\n\t * @returns {@link ApiPerpetualsOwnedVaultCapsResponse} containing vault caps.\n\t */\n\tpublic async getOwnedVaultCaps(inputs: ApiPerpetualsOwnedVaultCapsBody) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsOwnedVaultCapsResponse,\n\t\t\tApiPerpetualsOwnedVaultCapsBody\n\t\t>(\"vaults/owned-vault-caps\", inputs);\n\t}\n\n\t/**\n\t * Fetch all pending vault withdrawal requests created by a given wallet.\n\t *\n\t * Withdraw requests are typically created when LPs request to exit a vault\n\t * and may be subject to lock periods / delays depending on vault configuration.\n\t *\n\t * @param inputs.walletAddress - Wallet address that created the withdraw requests.\n\t * @returns {@link ApiPerpetualsVaultOwnedWithdrawRequestsResponse} containing requests.\n\t */\n\tpublic async getOwnedVaultWithdrawRequests(\n\t\tinputs: ApiPerpetualsVaultOwnedWithdrawRequestsBody\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultOwnedWithdrawRequestsResponse,\n\t\t\tApiPerpetualsVaultOwnedWithdrawRequestsBody\n\t\t>(\"vaults/owned-withdraw-requests\", {\n\t\t\t...inputs,\n\t\t\t// vaultIds: undefined,\n\t\t});\n\t}\n\n\t/**\n\t * Fetch all Perpetuals vault LP coins owned by a wallet.\n\t *\n\t * This returns coin objects (or summaries) representing LP token holdings.\n\t * Use {@link getLpCoinPrices} to value them in collateral units.\n\t *\n\t * @param inputs - {@link ApiPerpetualsVaultOwnedLpCoinsBody}.\n\t * @returns {@link ApiPerpetualsVaultOwnedLpCoinsResponse}.\n\t */\n\tpublic async getOwnedVaultLpCoins(\n\t\tinputs: ApiPerpetualsVaultOwnedLpCoinsBody\n\t): Promise<ApiPerpetualsVaultOwnedLpCoinsResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultOwnedLpCoinsResponse,\n\t\t\tApiPerpetualsVaultOwnedLpCoinsBody\n\t\t>(\"vaults/owned-lp-coins\", inputs);\n\t}\n\n\t/**\n\t * Fetch account caps by their account IDs.\n\t *\n\t * @param inputs.accountCapIds - List of account IDs.\n\t * @returns {@link ApiPerpetualsAccountCapsResponse} containing caps.\n\t */\n\tpublic async getAdminAccountCaps(\n\t\tinputs: ApiPerpetualsAdminAccountCapsBody\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsAdminAccountCapsResponse,\n\t\t\tApiPerpetualsAdminAccountCapsBody\n\t\t>(\"accounts\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Historical Data & Stats\n\t// =========================================================================\n\n\t/**\n\t * Fetch historical OHLCV candle data for a single market.\n\t *\n\t * @param inputs.marketId - Market ID to query.\n\t * @param inputs.fromTimestamp - Start timestamp (inclusive).\n\t * @param inputs.toTimestamp - End timestamp (exclusive).\n\t * @param inputs.intervalMs - Candle interval in milliseconds.\n\t *\n\t * @returns {@link ApiPerpetualsMarketCandleHistoryResponse} containing candle points.\n\t *\n\t * @remarks\n\t * This is currently implemented on the Perpetuals root client, but it may be\n\t * relocated to {@link PerpetualsMarket} in the future.\n\t */\n\t// TODO: move to market class ?\n\tpublic getMarketCandleHistory(\n\t\tinputs: ApiPerpetualsMarketCandleHistoryBody\n\t) {\n\t\tconst { marketId, fromTimestamp, toTimestamp, intervalMs } = inputs;\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsMarketCandleHistoryResponse,\n\t\t\tApiPerpetualsMarketCandleHistoryBody\n\t\t>(\"market/candle-history\", {\n\t\t\tmarketId,\n\t\t\tfromTimestamp,\n\t\t\ttoTimestamp,\n\t\t\tintervalMs,\n\t\t});\n\t}\n\n\t/**\n\t * Fetch 24-hour volume and price change stats for multiple markets.\n\t *\n\t * Returns volume, price change, and the latest base, collateral,\n\t * mid, and mark prices for each requested market.\n\t *\n\t * @param inputs.marketIds - Market IDs to query.\n\t * @returns {@link ApiPerpetualsMarkets24hrStatsResponse}.\n\t */\n\tpublic getMarkets24hrStats(inputs: {\n\t\tmarketIds: PerpetualsMarketId[];\n\t}): Promise<ApiPerpetualsMarkets24hrStatsResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsMarkets24hrStatsResponse,\n\t\t\t{\n\t\t\t\tmarketIds: PerpetualsMarketId[];\n\t\t\t}\n\t\t>(\"markets/24hr-stats\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Prices\n\t// =========================================================================\n\n\t/**\n\t * Fetch the latest prices for one or more markets.\n\t *\n\t * Returns base, collateral, order book mid, and mark prices for each\n\t * requested market.\n\t *\n\t * @param inputs.marketIds - List of market IDs to query.\n\t * @returns {@link ApiPerpetualsMarketsPricesResponse} containing `marketsPrices`.\n\t *\n\t * @remarks\n\t * If `marketIds` is empty, returns `{ marketsPrices: [] }` without making an API call.\n\t */\n\tpublic async getPrices(inputs: {\n\t\tmarketIds: ObjectId[];\n\t}): Promise<ApiPerpetualsMarketsPricesResponse> {\n\t\tif (inputs.marketIds.length <= 0)\n\t\t\treturn {\n\t\t\t\tmarketsPrices: [],\n\t\t\t};\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsMarketsPricesResponse,\n\t\t\tApiPerpetualsMarketsPricesBody\n\t\t>(\"markets/prices\", inputs);\n\t}\n\n\t/**\n\t * Fetch LP coin prices (in collateral units) for a set of vaults.\n\t *\n\t * @param inputs.vaultIds - List of vault IDs to query.\n\t * @returns {@link ApiPerpetualsVaultLpCoinPricesResponse} containing `lpCoinPrices`.\n\t *\n\t * @remarks\n\t * If `vaultIds` is empty, returns `{ lpCoinPrices: [] }` without making an API call.\n\t */\n\tpublic async getLpCoinPrices(\n\t\tinputs: ApiPerpetualsVaultLpCoinPricesBody\n\t): Promise<ApiPerpetualsVaultLpCoinPricesResponse> {\n\t\tif (inputs.vaultIds.length <= 0)\n\t\t\treturn {\n\t\t\t\tlpCoinPrices: [],\n\t\t\t};\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsVaultLpCoinPricesResponse,\n\t\t\tApiPerpetualsVaultLpCoinPricesBody\n\t\t>(\"vaults/lp-coin-prices\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Build a `transfer-cap` transaction that transfers a Perpetuals capability object (cap)\n\t * to another wallet.\n\t *\n\t * Provide the `capObjectId` of the capability you want to transfer (e.g., an account cap\n\t * or vault cap) and the `recipientAddress` that should receive it.\n\t *\n\t * This endpoint builds a transaction only; it does not submit it on-chain.\n\t *\n\t * @param inputs.recipientAddress - Recipient wallet address that should receive the cap.\n\t * @param inputs.capObjectId - Object ID of the capability to transfer.\n\t * @param inputs.tx - Optional transaction to extend.\n\t *\n\t * @returns Transaction response containing a `tx`.\n\t */\n\tpublic async getTransferCapTx(inputs: {\n\t\trecipientAddress: SuiAddress;\n\t\tcapObjectId: ObjectId;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, recipientAddress, capObjectId } = inputs;\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsTransferCapTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"transactions/transfer-cap\",\n\t\t\t{\n\t\t\t\trecipientAddress,\n\t\t\t\tcapObjectId,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `create-account` transaction for Aftermath Perpetuals.\n\t *\n\t * @param inputs.walletAddress - Wallet address that will own the new account.\n\t * @param inputs.collateralCoinType - Collateral coin type used by the account.\n\t * @param inputs.tx - Optional {@link Transaction} to extend; if provided, the\n\t * create-account commands are appended to this transaction.\n\t *\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t */\n\tpublic async getCreateAccountTx(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcollateralCoinType: CoinType;\n\t\ttx?: Transaction;\n\t}): Promise<SdkTransactionResponse> {\n\t\tconst { walletAddress, collateralCoinType, tx } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsCreateAccountBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"transactions/create-account\",\n\t\t\t{\n\t\t\t\twalletAddress,\n\t\t\t\tcollateralCoinType,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a `create-vault-cap` transaction.\n\t *\n\t * A vault cap is an ownership/admin object for interacting with vault management\n\t * flows. This method returns a transaction kind that mints/creates that cap.\n\t *\n\t * @param inputs - {@link ApiPerpetualsCreateVaultCapBody}.\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t */\n\tpublic async getCreateVaultCapTx(inputs: ApiPerpetualsCreateVaultCapBody) {\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsCreateVaultCapBody,\n\t\t\tApiTransactionResponse\n\t\t>(\"vault/transactions/create-vault-cap\", inputs, undefined, {\n\t\t\ttxKind: true,\n\t\t});\n\t}\n\n\t/**\n\t * Build a `create-vault` transaction.\n\t *\n\t * This creates a new vault plus its on-chain metadata and initial LP supply\n\t * seeded by the initial deposit.\n\t *\n\t * Deposit input:\n\t * - Use `initialDepositAmount` to have the API select/merge coins as needed, OR\n\t * - Use `initialDepositCoinArg` if you already have a coin argument in a larger tx.\n\t *\n\t * Metadata:\n\t * - Stored on-chain (or in a referenced object) as part of vault creation.\n\t * - `extraFields` allows forward-compatible additions (e.g. social links).\n\t *\n\t * @param inputs.walletAddress - Address of vault owner/curator.\n\t * @param inputs.metadata - Vault display metadata (name, description, curator info).\n\t * @param inputs.metadata - Vault display metadata (name, description, curator info).\n\t * @param inputs.coinMetadataId - Coin metadata object id obtained from create vault cap tx\n\t * @param inputs.treasuryCapId - Treasury cap object id obtained from create vault cap tx\n\t * @param inputs.collateralCoinType - Collateral coin type for deposits.\n\t * @param inputs.lockPeriodMs - Lock-in period for deposits in milliseconds.\n\t * @param inputs.performanceFeePercentage - Fraction of profits taken as curator fee.\n\t * @param inputs.forceWithdrawDelayMs - Delay before forced withdrawals can be processed.\n\t * @param inputs.isSponsoredTx - Whether this tx is sponsored (gas paid by another party).\n\t * @param inputs.initialDepositAmount - Initial deposit amount (mutually exclusive with `initialDepositCoinArg`).\n\t * @param inputs.initialDepositCoinArg - Transaction object argument referencing the deposit coin.\n\t * @param inputs.tx - Optional {@link Transaction} to extend.\n\t *\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t */\n\tpublic async getCreateVaultTx(\n\t\tinputs: {\n\t\t\twalletAddress: SuiAddress;\n\t\t\tmetadata: {\n\t\t\t\t/** A human-readable name for the `Vault`. */\n\t\t\t\tname: string;\n\t\t\t\t/** A verbose description of the `Vault`. */\n\t\t\t\tdescription: string;\n\t\t\t\t/** The `Vault` curator's name. */\n\t\t\t\tcuratorName?: string;\n\t\t\t\t/** A url for the `Vault`'s curator. Ideally their website. */\n\t\t\t\tcuratorUrl?: string;\n\t\t\t\t/** An image url for the `Vault`'s curator. Ideally their logo. */\n\t\t\t\tcuratorLogoUrl?: string;\n\t\t\t\t/**\n\t\t\t\t * Extra / optional fields for future extensibility.\n\t\t\t\t * Recommended keys include: `twitter_url`.\n\t\t\t\t */\n\t\t\t\textraFields?: Record<string, string>;\n\t\t\t};\n\t\t\tcoinMetadataId: ObjectId;\n\t\t\ttreasuryCapId: ObjectId;\n\t\t\tcollateralCoinType: CoinType;\n\t\t\tlockPeriodMs: bigint;\n\t\t\tperformanceFeePercentage: Percentage;\n\t\t\tforceWithdrawDelayMs: bigint;\n\t\t\ttx?: Transaction;\n\t\t\tisSponsoredTx?: boolean;\n\t\t} & (\n\t\t\t| {\n\t\t\t\t\tinitialDepositAmount: Balance;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tinitialDepositCoinArg: TransactionObjectArgument;\n\t\t\t }\n\t\t)\n\t) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsCreateVaultBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"vault/transactions/create-vault\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{ tx }\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Builder Codes Transactions\n\t// =========================================================================\n\n\t/**\n\t * Build a transaction to create an integrator configuration.\n\t *\n\t * This endpoint creates a transaction that allows a user to grant permission to an\n\t * integrator to receive fees on orders placed on their behalf. The user specifies\n\t * a maximum taker fee that the integrator can charge. The integrator can then\n\t * include their address and fee (up to the maximum) when placing orders for the user.\n\t *\n\t * The resulting transaction must be signed by the account owner and executed on-chain.\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody}.\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({\n\t * accountId: 123n,\n\t * integratorAddress: \"0x...\",\n\t * maxTakerFee: 0.001, // 0.1% max fee\n\t * });\n\t * ```\n\t */\n\tpublic async getCreateBuilderCodeIntegratorConfigTx(\n\t\tinputs: ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody\n\t) {\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"builder-codes/transactions/create-integrator-config\",\n\t\t\tinputs,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a transaction to remove an integrator configuration.\n\t *\n\t * This endpoint creates a transaction that removes an integrator's approval to\n\t * collect fees on orders placed on behalf of the user. Once revoked, the integrator\n\t * will no longer be able to submit orders with integrator fees for this account.\n\t * The user can re-approve the integrator at any time by calling\n\t * {@link getCreateIntegratorConfigTx} again.\n\t *\n\t * The resulting transaction must be signed by the account owner and executed on-chain.\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody}.\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({\n\t * accountId: 123n,\n\t * integratorAddress: \"0x...\",\n\t * });\n\t * ```\n\t */\n\tpublic async getRemoveBuilderCodeIntegratorConfigTx(\n\t\tinputs: ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody\n\t) {\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"builder-codes/transactions/remove-integrator-config\",\n\t\t\tinputs,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a transaction to initialize an integrator fee vault for a specific market.\n\t *\n\t * This endpoint creates a transaction that initializes a vault where an integrator's\n\t * fees will accumulate for a specific market (clearing house). This is a one-time\n\t * setup operation that must be performed before the integrator can claim fees from\n\t * that market. Once created, the vault will automatically collect fees as the\n\t * integrator submits orders on behalf of users in that market.\n\t *\n\t * The resulting transaction must be signed by the integrator and executed on-chain.\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody}.\n\t * @returns {@link SdkTransactionResponse} with `tx`.\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({\n\t * marketId: \"0x...\",\n\t * integratorAddress: \"0x...\",\n\t * });\n\t * ```\n\t */\n\tpublic async getCreateBuilderCodeIntegratorVaultTx(\n\t\tinputs: ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody\n\t) {\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody,\n\t\t\tApiTransactionResponse\n\t\t>(\n\t\t\t\"builder-codes/transactions/create-integrator-vault\",\n\t\t\tinputs,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Build a transaction to claim accumulated integrator fees from a vault.\n\t *\n\t * This endpoint creates a transaction that allows an integrator to claim the fees\n\t * they have earned from orders placed on behalf of users. Fees accumulate in a vault\n\t * specific to each market (clearing house) and can be claimed at any moment by the\n\t * integrator. The fees are proportional to the taker volume generated by the users'\n\t * orders that the integrator submitted.\n\t *\n\t * If a `recipientAddress` is provided, the claimed fees will be automatically\n\t * transferred to that address. Otherwise, the coin output is exposed as a transaction\n\t * argument for further use in the transaction.\n\t *\n\t * The resulting transaction must be signed by the integrator and executed on-chain.\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.\n\t * @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing\n\t * `txKind` and optionally `coinOutArg`.\n\t *\n\t * @example\n\t * ```ts\n\t * // Claim with automatic transfer to recipient\n\t * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({\n\t * marketId: \"0x...\",\n\t * integratorAddress: \"0x...\",\n\t * recipientAddress: \"0x...\",\n\t * });\n\t *\n\t * // Claim with coin output for further use\n\t * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({\n\t * marketId: \"0x...\",\n\t * integratorAddress: \"0x...\",\n\t * });\n\t * // response.coinOutArg can be used in subsequent transaction commands\n\t * ```\n\t */\n\tpublic async getClaimBuilderCodeIntegratorVaultFeesTx(\n\t\tinputs: ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody\n\t) {\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody,\n\t\t\tApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse\n\t\t>(\n\t\t\t\"builder-codes/transactions/claim-integrator-vault-fees\",\n\t\t\tinputs,\n\t\t\tundefined,\n\t\t\t{\n\t\t\t\ttxKind: true,\n\t\t\t}\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Builder Codes Inspections\n\t// =========================================================================\n\n\t/**\n\t * Fetch integrator configuration for a specific account and integrator.\n\t *\n\t * This endpoint queries whether an integrator has been approved by an account to collect\n\t * fees on orders placed on behalf of the account. If approved, it returns the maximum\n\t * taker fee the integrator is authorized to charge. This information is useful for:\n\t * - Verifying integrator permissions before placing orders\n\t * - Displaying authorized integrators and their fee limits in UIs\n\t * - Validating that an integrator's requested fee doesn't exceed the approved maximum\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.\n\t * @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing\n\t * `maxTakerFee` and `exists` flag.\n\t *\n\t * @example\n\t * ```ts\n\t * const config = await perps.getBuilderCodeIntegratorConfig({\n\t * accountId: 123n,\n\t * integratorAddress: \"0x...\",\n\t * });\n\t *\n\t * if (config.exists) {\n\t * console.log(`Integrator is approved with max fee: ${config.maxTakerFee}`);\n\t * } else {\n\t * console.log(\"Integrator is not approved for this account\");\n\t * }\n\t * ```\n\t */\n\tpublic async getBuilderCodeIntegratorConfig(\n\t\tinputs: ApiPerpetualsBuilderCodesIntegratorConfigBody\n\t): Promise<ApiPerpetualsBuilderCodesIntegratorConfigResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsBuilderCodesIntegratorConfigResponse,\n\t\t\tApiPerpetualsBuilderCodesIntegratorConfigBody\n\t\t>(\"builder-codes/integrator-config\", inputs);\n\t}\n\n\t/**\n\t * Fetch accumulated integrator vault fees across multiple markets.\n\t *\n\t * This endpoint queries the total fees an integrator has earned and accumulated in their\n\t * vaults across one or more markets (clearing houses). Integrators earn fees proportional\n\t * to the taker volume generated by orders they submit on behalf of users. These fees\n\t * accumulate in per-market vaults and can be claimed at any time using\n\t * {@link getClaimIntegratorVaultFeesTx}.\n\t *\n\t * This information is useful for:\n\t * - Displaying total claimable fees to integrators in dashboards\n\t * - Monitoring fee accrual across different markets\n\t * - Determining which markets have fees ready to be claimed\n\t *\n\t * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.\n\t * @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing\n\t * a vector of market vault data with accumulated fees.\n\t *\n\t * @example\n\t * ```ts\n\t * const vaultFees = await perps.getBuilderCodeIntegratorVaults({\n\t * marketIds: [\"0x...BTCUSD\", \"0x...SUIUSD\"],\n\t * integratorAddress: \"0x...\",\n\t * });\n\t *\n\t * for (const vault of vaultFees.integratorVaults) {\n\t * console.log(`Market ${vault.marketId}: ${vault.fees} collateral units claimable`);\n\t * }\n\t *\n\t * const totalFees = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.fees, 0);\n\t * console.log(`Total claimable: ${totalFees}`);\n\t * ```\n\t */\n\tpublic async getBuilderCodeIntegratorVaults(\n\t\tinputs: ApiPerpetualsBuilderCodesIntegratorVaultsBody\n\t): Promise<ApiPerpetualsBuilderCodesIntegratorVaultsResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiPerpetualsBuilderCodesIntegratorVaultsResponse,\n\t\t\tApiPerpetualsBuilderCodesIntegratorVaultsBody\n\t\t>(\"builder-codes/integrator-vaults\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Public Static Helpers\n\t// =========================================================================\n\n\t/**\n\t * Determine the logical order side (Bid/Ask) from a signed base asset amount.\n\t *\n\t * @param inputs.baseAssetAmount - Position base size. Positive/zero => Bid (long), negative => Ask (short).\n\t * @returns {@link PerpetualsOrderSide}.\n\t */\n\tpublic static positionSide(inputs: {\n\t\tbaseAssetAmount: number;\n\t}): PerpetualsOrderSide {\n\t\tconst baseAmount = inputs.baseAssetAmount;\n\t\tconst isLong = Math.sign(baseAmount);\n\t\tconst side =\n\t\t\tisLong >= 0 ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask;\n\t\treturn side;\n\t}\n\n\t/**\n\t * Compute the effective trade price from a {@link FilledTakerOrderEvent}.\n\t *\n\t * Uses the ratio: `quoteAssetDelta / baseAssetDelta`.\n\t *\n\t * @param inputs.orderEvent - Filled taker order event.\n\t * @returns Trade price.\n\t */\n\tpublic static orderPriceFromEvent(inputs: {\n\t\torderEvent: FilledTakerOrderEvent;\n\t}): number {\n\t\tconst { orderEvent } = inputs;\n\t\treturn orderEvent.quoteAssetDelta / orderEvent.baseAssetDelta;\n\t}\n\n\t/**\n\t * Extract the floating-point price from an encoded order ID.\n\t *\n\t * Internally uses {@link PerpetualsOrderUtils.price} and converts the fixed-point\n\t * {@link PerpetualsOrderPrice} into a `number`.\n\t *\n\t * @param inputs.orderId - Encoded order ID.\n\t * @returns Price as a `number`.\n\t */\n\tpublic static orderPriceFromOrderId(inputs: {\n\t\torderId: PerpetualsOrderId;\n\t}): number {\n\t\tconst { orderId } = inputs;\n\t\tconst orderPrice = PerpetualsOrderUtils.price(orderId);\n\t\treturn this.orderPriceToPrice({ orderPrice });\n\t}\n\n\t/**\n\t * Convert a floating-point price into a fixed-point {@link PerpetualsOrderPrice}\n\t * using 9 decimal places of precision.\n\t *\n\t * @param inputs.price - Price as a float.\n\t * @returns Fixed-point order price.\n\t */\n\tpublic static priceToOrderPrice = (inputs: {\n\t\tprice: number;\n\t}): PerpetualsOrderPrice => {\n\t\tconst { price } = inputs;\n\t\treturn BigInt(Math.round(price * FixedUtils.fixedOneN9));\n\t};\n\n\t/**\n\t * Convert a fixed-point {@link PerpetualsOrderPrice} to a float price.\n\t *\n\t * @param inputs.orderPrice - Fixed-point order price.\n\t * @returns Price as a float.\n\t */\n\tpublic static orderPriceToPrice = (inputs: {\n\t\torderPrice: PerpetualsOrderPrice;\n\t}): number => {\n\t\tconst { orderPrice } = inputs;\n\t\treturn Number(orderPrice) / FixedUtils.fixedOneN9;\n\t};\n\n\t/**\n\t * Convert a fixed-point lot/tick size (9 decimals) to a `number`.\n\t *\n\t * @param lotOrTickSize - Fixed-point size as `bigint`.\n\t * @returns Floating-point size.\n\t */\n\tpublic static lotOrTickSizeToNumber(lotOrTickSize: bigint): number {\n\t\treturn Number(lotOrTickSize) / FixedUtils.fixedOneN9;\n\t}\n\n\t/**\n\t * Convert a floating-point lot/tick size to its fixed-point representation (9 decimals).\n\t *\n\t * @param lotOrTickSize - Floating-point size.\n\t * @returns Fixed-point size as `bigint`.\n\t */\n\tpublic static lotOrTickSizeToBigInt(lotOrTickSize: number): bigint {\n\t\treturn BigInt(Math.round(lotOrTickSize * FixedUtils.fixedOneN9));\n\t}\n\n\t/**\n\t * Infer the order side from an encoded order ID.\n\t *\n\t * @param orderId - Encoded order ID.\n\t * @returns {@link PerpetualsOrderSide}.\n\t */\n\tpublic static orderIdToSide = (\n\t\torderId: PerpetualsOrderId\n\t): PerpetualsOrderSide => {\n\t\treturn Perpetuals.OrderUtils.isAsk(orderId)\n\t\t\t? PerpetualsOrderSide.Ask\n\t\t\t: PerpetualsOrderSide.Bid;\n\t};\n\n\t/**\n\t * Construct a collateral-specialized Move event type string.\n\t *\n\t * Many Move events are generic over a collateral coin type. This helper appends\n\t * `<collateralCoinType>` to a base `eventType`.\n\t *\n\t * @param inputs.eventType - Base event type without type parameters.\n\t * @param inputs.collateralCoinType - Collateral coin type (e.g. `\"0x2::sui::SUI\"`).\n\t * @returns Fully-qualified event type string.\n\t */\n\tpublic static eventTypeForCollateral = (inputs: {\n\t\teventType: string;\n\t\tcollateralCoinType: CoinType;\n\t}): string => {\n\t\treturn `${inputs.eventType}<${inputs.collateralCoinType}>`;\n\t};\n\n\t// =========================================================================\n\t// Websocket\n\t// =========================================================================\n\n\t/**\n\t * Open the main updates websocket: `/perpetuals/ws/updates`.\n\t *\n\t * The stream emits {@link PerpetualsWsUpdatesResponseMessage} envelopes and supports\n\t * multiple subscription types. This method returns a small controller with\n\t * convenience subscribe/unsubscribe functions.\n\t *\n\t * Subscription types supported by the controller:\n\t * - `market`: market state updates\n\t * - `user`: user account updates (optionally including stop orders)\n\t * - `oracle`: oracle price updates\n\t * - `orderbook`: orderbook deltas\n\t * - `marketOrders`: public market trades/orders\n\t * - `userOrders`: user trade/order events\n\t * - `userCollateralChanges`: user collateral change events\n\t * - `topOfOrderbook`: bucketed orderbook snapshots (top of orderbook)\n\t *\n\t * @param args.onMessage - Handler for parsed messages from the websocket.\n\t * @param args.onOpen - Optional handler for the `open` event.\n\t * @param args.onError - Optional handler for the `error` event.\n\t * @param args.onClose - Optional handler for the `close` event.\n\t *\n\t * @returns A controller object containing:\n\t * - `ws`: underlying {@link WebSocket}\n\t * - subscribe/unsubscribe helpers for each subscription type\n\t * - `close()`: closes the websocket\n\t */\n\tpublic openUpdatesWebsocketStream(args: {\n\t\tonMessage: (env: PerpetualsWsUpdatesResponseMessage) => void;\n\t\tonOpen?: (ev: Event) => void;\n\t\tonError?: (ev: Event) => void;\n\t\tonClose?: (ev: CloseEvent) => void;\n\t}) {\n\t\tconst { onMessage, onOpen, onError, onClose } = args;\n\n\t\tconst ctl = this.openWsStream<\n\t\t\tPerpetualsWsUpdatesSubscriptionMessage,\n\t\t\tPerpetualsWsUpdatesResponseMessage\n\t\t>({\n\t\t\tpath: \"ws/updates\",\n\t\t\tonMessage,\n\t\t\tonOpen,\n\t\t\tonError,\n\t\t\tonClose,\n\t\t});\n\n\t\t/**\n\t\t * Subscription helpers\n\t\t *\n\t\t * Each helper sends a structured subscription message of the form:\n\t\t * `{ action: \"subscribe\" | \"unsubscribe\", subscriptionType: { ... } }`\n\t\t */\n\t\tconst subscribeMarket = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { market: { marketId } },\n\t\t\t});\n\n\t\tconst unsubscribeMarket = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { market: { marketId } },\n\t\t\t});\n\n\t\tconst subscribeUser = ({\n\t\t\taccountId,\n\t\t\twithStopOrders,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\twithStopOrders:\n\t\t\t\t| {\n\t\t\t\t\t\twalletAddress: SuiAddress;\n\t\t\t\t\t\tbytes: string;\n\t\t\t\t\t\tsignature: string;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { user: { accountId, withStopOrders } },\n\t\t\t});\n\n\t\tconst unsubscribeUser = ({\n\t\t\taccountId,\n\t\t\twithStopOrders,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t\twithStopOrders:\n\t\t\t\t| {\n\t\t\t\t\t\twalletAddress: SuiAddress;\n\t\t\t\t\t\tbytes: string;\n\t\t\t\t\t\tsignature: string;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { user: { accountId, withStopOrders } },\n\t\t\t});\n\n\t\tconst subscribeOracle = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { oracle: { marketId } },\n\t\t\t});\n\n\t\tconst unsubscribeOracle = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { oracle: { marketId } },\n\t\t\t});\n\n\t\tconst subscribeOrderbook = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { orderbook: { marketId } },\n\t\t\t});\n\n\t\tconst unsubscribeOrderbook = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { orderbook: { marketId } },\n\t\t\t});\n\n\t\tconst subscribeMarketOrders = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { marketOrders: { marketId } },\n\t\t\t});\n\n\t\tconst unsubscribeMarketOrders = ({\n\t\t\tmarketId,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { marketOrders: { marketId } },\n\t\t\t});\n\n\t\tconst subscribeUserOrders = ({\n\t\t\taccountId,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { userOrders: { accountId } },\n\t\t\t});\n\n\t\tconst unsubscribeUserOrders = ({\n\t\t\taccountId,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { userOrders: { accountId } },\n\t\t\t});\n\n\t\tconst subscribeUserCollateralChanges = ({\n\t\t\taccountId,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: { userCollateralChanges: { accountId } },\n\t\t\t});\n\n\t\tconst unsubscribeUserCollateralChanges = ({\n\t\t\taccountId,\n\t\t}: {\n\t\t\taccountId: PerpetualsAccountId;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: { userCollateralChanges: { accountId } },\n\t\t\t});\n\n\t\tconst subscribeTopOfOrderbook = ({\n\t\t\tmarketId,\n\t\t\tpriceBucketSize,\n\t\t\tbucketsNumber,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t\tpriceBucketSize: number;\n\t\t\tbucketsNumber: number;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"subscribe\",\n\t\t\t\tsubscriptionType: {\n\t\t\t\t\ttopOfOrderbook: {\n\t\t\t\t\t\tmarketId,\n\t\t\t\t\t\tpriceBucketSize,\n\t\t\t\t\t\tbucketsNumber,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\tconst unsubscribeTopOfOrderbook = ({\n\t\t\tmarketId,\n\t\t\tpriceBucketSize,\n\t\t\tbucketsNumber,\n\t\t}: {\n\t\t\tmarketId: PerpetualsMarketId;\n\t\t\tpriceBucketSize: number;\n\t\t\tbucketsNumber: number;\n\t\t}) =>\n\t\t\tctl.send({\n\t\t\t\taction: \"unsubscribe\",\n\t\t\t\tsubscriptionType: {\n\t\t\t\t\ttopOfOrderbook: {\n\t\t\t\t\t\tmarketId,\n\t\t\t\t\t\tpriceBucketSize,\n\t\t\t\t\t\tbucketsNumber,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\treturn {\n\t\t\tws: ctl.ws,\n\t\t\tsubscribeMarket,\n\t\t\tunsubscribeMarket,\n\t\t\tsubscribeUser,\n\t\t\tunsubscribeUser,\n\t\t\tsubscribeOracle,\n\t\t\tunsubscribeOracle,\n\t\t\tsubscribeOrderbook,\n\t\t\tunsubscribeOrderbook,\n\t\t\tsubscribeMarketOrders,\n\t\t\tunsubscribeMarketOrders,\n\t\t\tsubscribeUserOrders,\n\t\t\tunsubscribeUserOrders,\n\t\t\tsubscribeUserCollateralChanges,\n\t\t\tunsubscribeUserCollateralChanges,\n\t\t\tsubscribeTopOfOrderbook,\n\t\t\tunsubscribeTopOfOrderbook,\n\t\t\tclose: ctl.close,\n\t\t};\n\t}\n\n\t/**\n\t * Open a market-candles websocket stream for a single market/interval:\n\t * `/perpetuals/ws/market-candles/{market_id}/{interval_ms}`.\n\t *\n\t * The stream emits {@link PerpetualsWsCandleResponseMessage} messages,\n\t * typically containing the latest candle for the specified interval.\n\t *\n\t * @param args.marketId - Market ID to subscribe to.\n\t * @param args.intervalMs - Candle interval in milliseconds.\n\t * @param args.onMessage - Handler for incoming candle updates.\n\t * @param args.onOpen - Optional hook called when the websocket opens.\n\t * @param args.onError - Optional hook called on websocket error.\n\t * @param args.onClose - Optional hook called when the websocket closes.\n\t *\n\t * @returns A controller containing the raw websocket and a `close()` helper.\n\t *\n\t * @example\n\t * ```ts\n\t * const stream = perps.openMarketCandlesWebsocketStream({\n\t * marketId: \"0x...\",\n\t * intervalMs: 60_000,\n\t * onMessage: ({ lastCandle }) => console.log(lastCandle),\n\t * });\n\t * ```\n\t */\n\tpublic openMarketCandlesWebsocketStream(args: {\n\t\tmarketId: PerpetualsMarketId;\n\t\tintervalMs: number;\n\t\tonMessage: (msg: PerpetualsWsCandleResponseMessage) => void;\n\t\tonOpen?: (ev: Event) => void;\n\t\tonError?: (ev: Event) => void;\n\t\tonClose?: (ev: CloseEvent) => void;\n\t}) {\n\t\tconst { marketId, intervalMs, onMessage, onOpen, onError, onClose } =\n\t\t\targs;\n\n\t\tconst path = `ws/market-candles/${encodeURIComponent(\n\t\t\tmarketId\n\t\t)}/${intervalMs}`;\n\n\t\tconst ctl = this.openWsStream<\n\t\t\tundefined,\n\t\t\tPerpetualsWsCandleResponseMessage\n\t\t>({\n\t\t\tpath,\n\t\t\tonMessage,\n\t\t\tonOpen,\n\t\t\tonError,\n\t\t\tonClose,\n\t\t});\n\n\t\treturn {\n\t\t\tws: ctl.ws,\n\t\t\tclose: ctl.close,\n\t\t};\n\t}\n}\n","export * from \"./perpetuals\";\nexport * from \"./perpetualsAccount\";\nexport * from \"./perpetualsMarket\";\nexport * from \"./perpetualsVault\";\n","import { AftermathApi } from \"../../general/providers\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { CallerConfig, SuiAddress, SuiNetwork, Url } from \"../../types\";\n\n/**\n * The `ReferralVault` class provides functionality for querying and managing\n * referral information within the Aftermath protocol. It allows you to look\n * up the referrer for a given address.\n *\n * @deprecated Use `Referral` class instead\n */\nexport class ReferralVault extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Contains static configuration relevant to the referral system, if any.\n\t * Currently empty but can be extended for future needs.\n\t */\n\tpublic static readonly constants = {};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of `ReferralVault` to interact with referral-related\n\t * features in the Aftermath protocol.\n\t *\n\t * @deprecated Use `Referral` class instead\n\t * @param config - Optional caller configuration, including Sui network and access token.\n\t * @param Provider - An optional `AftermathApi` provider instance for referral-specific methods.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"referral-vault\");\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the referrer address for a specified referee (user).\n\t *\n\t * @deprecated Use `Referral` class instead\n\t * @param inputs - An object containing the `referee` Sui address.\n\t * @returns A promise that resolves to either the referrer's `SuiAddress` or the string `\"None\"` if no referrer exists.\n\t *\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const referralVault = afSdk.ReferralVault();\n\t *\n\t * const referrer = await referralVault.getReferrer({ referee: \"0x<user_address>\" });\n\t * console.log(\"Referrer address:\", referrer);\n\t * ```\n\t */\n\tpublic async getReferrer(inputs: {\n\t\treferee: SuiAddress;\n\t}): Promise<SuiAddress | \"None\"> {\n\t\treturn this.fetchApi(`${inputs.referee}/referrer`);\n\t}\n}\n","export * from \"./referralVault\";\n","import {\n\tApiRouterCompleteTradeRouteBody,\n\tApiRouterTransactionForCompleteTradeRouteBody,\n\tCoinType,\n\tRouterCompleteTradeRoute,\n\tSuiNetwork,\n\tApiRouterTradeEventsBody,\n\tRouterTradeEvent,\n\tBalance,\n\tApiRouterPartialCompleteTradeRouteBody,\n\tApiRouterAddTransactionForCompleteTradeRouteBody,\n\tApiRouterAddTransactionForCompleteTradeRouteResponse,\n\tModuleName,\n\tSlippage,\n\tApiIndexerEventsBody,\n\tCallerConfig,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { Transaction } from \"@mysten/sui/transactions\";\n\n/**\n * The `Router` class provides a collection of methods to interact with Aftermath's\n * smart order routing system on the Sui Network. It handles routing trades through\n * various liquidity pools to achieve the best possible execution price, retrieving\n * trade volume, managing supported coins, and more.\n *\n * @example\n * ```typescript\n * // Create provider\n * const router = (new Aftermath(\"MAINNET\")).Router();\n * // Retrieve 24h volume\n * const volume24h = await router.getVolume24hrs();\n * // Get supported coins\n * const supportedCoins = await router.getSupportedCoins();\n * ```\n */\nexport class Router extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Contains static information about the router, such as the maximum\n\t * allowable external fee percentage.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * The maximum external fee percentage that a third party can charge on router trades.\n\t\t * @remarks 0.5 = 50%\n\t\t */\n\t\tmaxExternalFeePercentage: 0.5,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `Router` instance to perform router-related calls on the\n\t * Aftermath platform.\n\t *\n\t * @param config - Optional configuration settings, including network and access token.\n\t * @returns A new `Router` instance.\n\t *\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const router = afSdk.Router();\n\t * ```\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"router\");\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the total trading volume in the last 24 hours.\n\t *\n\t * @returns A promise that resolves to a `number` representing the total volume in the last 24 hours.\n\t *\n\t * @example\n\t * ```typescript\n\t * const volume = await router.getVolume24hrs();\n\t * console.log(volume); // e.g. 1234567.89\n\t * ```\n\t */\n\tpublic getVolume24hrs = async (): Promise<number> => {\n\t\treturn this.fetchApi(\"volume-24hrs\");\n\t};\n\n\t/**\n\t * Fetches a list of all coin types that are supported for trading through the router.\n\t *\n\t * @returns A promise that resolves to an array of coin types (`CoinType[]`).\n\t *\n\t * @example\n\t * ```typescript\n\t * const supportedCoins = await router.getSupportedCoins();\n\t * console.log(supportedCoins); // [\"0x2::sui::SUI\", \"0x<...>::coin::TOKEN\", ...]\n\t * ```\n\t */\n\tpublic async getSupportedCoins() {\n\t\treturn this.fetchApi<CoinType[]>(\"supported-coins\");\n\t}\n\n\t/**\n\t * Searches the supported coins by applying a filter string.\n\t *\n\t * @param inputs - An object containing a `filter` string to match against supported coins.\n\t * @param abortSignal - An optional `AbortSignal` to cancel the request if needed.\n\t * @returns A promise that resolves to an array of coin types matching the filter.\n\t *\n\t * @example\n\t * ```typescript\n\t * const searchResult = await router.searchSupportedCoins({ filter: \"SUI\" });\n\t * console.log(searchResult); // e.g. [\"0x2::sui::SUI\"]\n\t * ```\n\t */\n\tpublic async searchSupportedCoins(\n\t\tinputs: { filter: string },\n\t\tabortSignal?: AbortSignal\n\t) {\n\t\treturn this.fetchApi<CoinType[]>(\n\t\t\t`supported-coins/${inputs.filter}`,\n\t\t\tundefined,\n\t\t\tabortSignal\n\t\t);\n\t}\n\n\t/**\n\t * Creates an optimal trade route for a given token input (`coinInType`) with a\n\t * specified input amount (`coinInAmount`). This route may consist of multiple\n\t * swaps across different DEX protocols to achieve the best price.\n\t *\n\t * @param inputs - Details required to construct the trade route, including `coinInType`, `coinOutType`, and `coinInAmount`.\n\t * @param abortSignal - An optional signal to abort the request if needed.\n\t * @returns A promise resolving to a `RouterCompleteTradeRoute` object containing the full route details.\n\t *\n\t * @example\n\t * ```typescript\n\t * const route = await router.getCompleteTradeRouteGivenAmountIn({\n\t * coinInType: \"0x2::sui::SUI\",\n\t * coinOutType: \"0x<...>::coin::TOKEN\",\n\t * coinInAmount: BigInt(10_000_000_000),\n\t * // optional fields:\n\t * referrer: \"0x<referrer_address>\",\n\t * externalFee: {\n\t * recipient: \"0x<fee_collector>\",\n\t * feePercentage: 0.01\n\t * },\n\t * protocolBlacklist: [\"Cetus\", \"BlueMove\"],\n\t * poolBlacklist: [\"0x<pool_id>\"]\n\t * });\n\t * console.log(route);\n\t * ```\n\t */\n\tpublic async getCompleteTradeRouteGivenAmountIn(\n\t\tinputs: ApiRouterPartialCompleteTradeRouteBody & {\n\t\t\t/**\n\t\t\t * Amount of coin being given away\n\t\t\t */\n\t\t\tcoinInAmount: Balance;\n\t\t},\n\t\tabortSignal?: AbortSignal\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tRouterCompleteTradeRoute,\n\t\t\tApiRouterCompleteTradeRouteBody\n\t\t>(\"trade-route\", inputs, abortSignal);\n\t}\n\n\t/**\n\t * Creates an optimal trade route for a given token output (`coinOutType`) with a\n\t * specified output amount (`coinOutAmount`). This route may consist of multiple\n\t * swaps to achieve the target output amount, factoring in slippage.\n\t *\n\t * @param inputs - Details required to construct the trade route, including `coinInType`, `coinOutType`, `coinOutAmount`, and `slippage`.\n\t * @param abortSignal - An optional signal to abort the request if needed.\n\t * @returns A promise resolving to a `RouterCompleteTradeRoute` object containing the full route details.\n\t *\n\t * @example\n\t * ```typescript\n\t * const route = await router.getCompleteTradeRouteGivenAmountOut({\n\t * coinInType: \"0x2::sui::SUI\",\n\t * coinOutType: \"0x<...>::coin::TOKEN\",\n\t * coinOutAmount: BigInt(20_000_000),\n\t * slippage: 0.01, // 1%\n\t * protocolWhitelist: [\"Aftermath\", \"Cetus\"],\n\t * poolWhitelist: [\"0x<pool_id>\"]\n\t * });\n\t * console.log(route);\n\t * ```\n\t */\n\tpublic async getCompleteTradeRouteGivenAmountOut(\n\t\tinputs: ApiRouterPartialCompleteTradeRouteBody & {\n\t\t\t/**\n\t\t\t * Amount of coin expected to receive\n\t\t\t */\n\t\t\tcoinOutAmount: Balance;\n\t\t\tslippage: Slippage;\n\t\t},\n\t\tabortSignal?: AbortSignal\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tRouterCompleteTradeRoute,\n\t\t\tApiRouterCompleteTradeRouteBody\n\t\t>(\"trade-route\", inputs, abortSignal);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Generates a transaction to execute a previously calculated complete trade route.\n\t * This transaction can then be signed and executed by the user.\n\t *\n\t * @param inputs - An object containing the wallet address, the complete trade route, slippage tolerance, and optional sponsorship settings.\n\t * @returns A promise resolving to a `Uint8Array` representing the serialized transaction.\n\t *\n\t * @example\n\t * ```typescript\n\t * const route = await router.getCompleteTradeRouteGivenAmountIn({ ... });\n\t * const transactionBytes = await router.getTransactionForCompleteTradeRoute({\n\t * walletAddress: \"0x<your_address>\",\n\t * completeRoute: route,\n\t * slippage: 0.01\n\t * });\n\t * // The returned bytes can now be signed and executed using your chosen wallet.\n\t * ```\n\t */\n\tpublic async getTransactionForCompleteTradeRoute(\n\t\tinputs: ApiRouterTransactionForCompleteTradeRouteBody\n\t) {\n\t\treturn this.fetchApiTransaction<ApiRouterTransactionForCompleteTradeRouteBody>(\n\t\t\t\"transactions/trade\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Adds a trade route to an existing transaction, allowing you to build complex\n\t * transactions containing multiple actions (swaps, transfers, etc.) in a single\n\t * atomic transaction.\n\t *\n\t * @param inputs - Includes the existing `Transaction`, a complete route, slippage, wallet address, and an optional `coinInId`.\n\t * @returns An object containing:\n\t * - `tx`: The updated `Transaction` including the route instructions\n\t * - `coinOutId`: A `TransactionObjectArgument` referencing the output coin after the swap\n\t *\n\t * @example\n\t * ```typescript\n\t * // 1) Create a route\n\t * const route = await router.getCompleteTradeRouteGivenAmountIn({ ... });\n\t *\n\t * // 2) Initialize your transaction\n\t * const tx = new Transaction();\n\t *\n\t * // 3) Add router instructions\n\t * const { tx: updatedTx, coinOutId } =\n\t * await router.addTransactionForCompleteTradeRoute({\n\t * tx,\n\t * completeRoute: route,\n\t * slippage: 0.01,\n\t * walletAddress: \"0x<your_address>\"\n\t * });\n\t *\n\t * // 4) Continue building your transaction with the resulting coinOutId, if desired\n\t * updatedTx.transferObjects([coinOutId!], \"0x<your_address>\");\n\t * ```\n\t */\n\tpublic async addTransactionForCompleteTradeRoute(\n\t\tinputs: Omit<\n\t\t\tApiRouterAddTransactionForCompleteTradeRouteBody,\n\t\t\t\"serializedTx\"\n\t\t> & {\n\t\t\ttx: Transaction;\n\t\t}\n\t) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\t\tconst { tx: newTx, coinOutId } = await this.fetchApi<\n\t\t\tApiRouterAddTransactionForCompleteTradeRouteResponse,\n\t\t\tApiRouterAddTransactionForCompleteTradeRouteBody\n\t\t>(\"transactions/add-trade\", {\n\t\t\t...otherInputs,\n\t\t\tserializedTx: tx.serialize(),\n\t\t});\n\t\treturn {\n\t\t\ttx: Transaction.from(newTx),\n\t\t\tcoinOutId,\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t/**\n\t * Retrieves trade events (interactions) for a given user based on router usage.\n\t *\n\t * @param inputs - Includes a `walletAddress`, cursor pagination, and limit.\n\t * @returns A promise resolving to the user's `RouterTradeEvent`s, potentially paginated.\n\t *\n\t * @example\n\t * ```typescript\n\t * const events = await router.getInteractionEvents({\n\t * walletAddress: \"0x<your_address>\",\n\t * cursor: 0,\n\t * limit: 10\n\t * });\n\t * console.log(events);\n\t * ```\n\t */\n\tpublic async getInteractionEvents(inputs: ApiRouterTradeEventsBody) {\n\t\treturn this.fetchApiIndexerEvents<\n\t\t\tRouterTradeEvent,\n\t\t\tApiRouterTradeEventsBody\n\t\t>(\"events-by-user\", inputs);\n\t}\n}\n","export * from \"./router\";\n","import {\n\tApiStakeBody,\n\tApiUnstakeBody,\n\tApiStakingPositionsBody,\n\tStakingPosition,\n\tBalance,\n\tValidatorConfigObject,\n\tApiStakeStakedSuiBody,\n\tApiDelegatedStakesBody,\n\tSuiDelegatedStake,\n\tApiValidatorOperationCapsBody,\n\tValidatorOperationCapObject,\n\tApiUpdateValidatorFeeBody,\n\tPercentage,\n\tStakedSuiVaultStateObject,\n\tSuiAddress,\n\tStakingApyDataPoint,\n\tStakingApyTimeframeKey,\n\tCallerConfig,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport type { SuiValidatorSummary, ValidatorsApy } from \"@mysten/sui/jsonRpc\";\nimport { Casting } from \"../../general/utils\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * The `Staking` class provides methods for interacting with Aftermath's\n * staking and unstaking systems for SUI. This includes fetching validator\n * information, creating stake and unstake transactions, and retrieving\n * relevant staking statistics such as TVL and APY.\n *\n * @example\n * ```typescript\n * // Instantiate Staking\n * const sdk = new Aftermath(\"MAINNET\");\n * await sdk.init();\n * const staking = sdk.Staking();\n *\n * // Get active validators\n * const validators = await staking.getActiveValidators();\n *\n * // Create a transaction for staking SUI\n * const stakeTx = await staking.getStakeTransaction({\n * walletAddress: \"0x...\",\n * suiStakeAmount: BigInt(\"1000000000\"),\n * validatorAddress: \"0x...\"\n * });\n * ```\n */\nexport class Staking extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Contains constants for staking, including protocol fees, default validator\n\t * fee, and staking/unstaking bounds. Also defines the maximum external fee\n\t * percentage allowed for third-party fees.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * Configuration for fees related to staking and unstaking operations.\n\t\t */\n\t\tfees: {\n\t\t\t/**\n\t\t\t * Protocol unstake fee (5%).\n\t\t\t */\n\t\t\tprotocolUnstake: 0.05,\n\t\t\t/**\n\t\t\t * Default validator fee (0%).\n\t\t\t */\n\t\t\tdefaultValidator: 0,\n\t\t\t/**\n\t\t\t * Maximum validator fee (5%).\n\t\t\t */\n\t\t\tmaxValidator: 0.05,\n\t\t},\n\t\t/**\n\t\t * Configuration for minimum stake/unstake amounts, and maximum external fee\n\t\t * percentage allowed.\n\t\t */\n\t\tbounds: {\n\t\t\t/**\n\t\t\t * Minimum SUI that can be staked. 1 SUI = 10^9 MIST.\n\t\t\t */\n\t\t\tminStake: BigInt(\"1000000000\"), // 1 SUI\n\t\t\t/**\n\t\t\t * Minimum afSUI that can be unstaked. 1 afSUI = 10^9 MIST (mirroring SUI decimals).\n\t\t\t */\n\t\t\tminUnstake: BigInt(\"1000000000\"), // 1 afSUI\n\t\t\t/**\n\t\t\t * Maximum external fee percentage that third parties can add on top\n\t\t\t * of protocol fees for staking or unstaking transactions.\n\t\t\t * @remarks 0.5 = 50%\n\t\t\t */\n\t\t\tmaxExternalFeePercentage: 0.5,\n\t\t},\n\t\t/**\n\t\t * The default validator fee (0%).\n\t\t */\n\t\tdefaultValidatorFee: 0,\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of the `Staking` class for interacting with Aftermath\n\t * staking contracts.\n\t *\n\t * @param config - Optional configuration containing the Sui network and/or access token.\n\t * @param Provider - Optional instance of `AftermathApi` for building transactions.\n\t */\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"staking\");\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t/**\n\t * Fetches the list of currently active validators on the Sui network.\n\t *\n\t * @returns A promise that resolves to an array of `SuiValidatorSummary` objects,\n\t * each describing a validator's on-chain metadata.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validators = await staking.getActiveValidators();\n\t * console.log(validators);\n\t * ```\n\t */\n\tpublic async getActiveValidators(): Promise<SuiValidatorSummary[]> {\n\t\treturn this.fetchApi(\"active-validators\");\n\t}\n\n\t/**\n\t * Fetches the current APYs for all validators, aggregated by the indexer.\n\t *\n\t * @returns A promise that resolves to a `ValidatorsApy` object, containing\n\t * APY data indexed by validator addresses.\n\t *\n\t * @example\n\t * ```typescript\n\t * const validatorApys = await staking.getValidatorApys();\n\t * console.log(validatorApys);\n\t * ```\n\t */\n\tpublic async getValidatorApys(): Promise<ValidatorsApy> {\n\t\treturn this.fetchApi(\"validator-apys\");\n\t}\n\n\t/**\n\t * Fetches the configuration details for each validator, including fees and\n\t * operation caps.\n\t *\n\t * @returns A promise that resolves to an array of `ValidatorConfigObject`s.\n\t *\n\t * @example\n\t * ```typescript\n\t * const configs = await staking.getValidatorConfigs();\n\t * console.log(configs);\n\t * ```\n\t */\n\tpublic async getValidatorConfigs(): Promise<ValidatorConfigObject[]> {\n\t\treturn this.fetchApi(\"validator-configs\");\n\t}\n\n\t/**\n\t * Retrieves a list of staking positions for the specified account.\n\t *\n\t * @param inputs - Contains the `walletAddress` to query, plus optional cursor\n\t * and limit for pagination.\n\t * @returns A promise that resolves to an array of `StakingPosition` objects\n\t * reflecting the user's active or pending stakes.\n\t *\n\t * @example\n\t * ```typescript\n\t * const positions = await staking.getStakingPositions({\n\t * walletAddress: \"0x...\",\n\t * cursor: 0,\n\t * limit: 10\n\t * });\n\t * console.log(positions);\n\t * ```\n\t */\n\tpublic async getStakingPositions(\n\t\tinputs: ApiStakingPositionsBody\n\t): Promise<StakingPosition[]> {\n\t\treturn this.fetchApi(\"staking-positions\", inputs);\n\t}\n\n\t/**\n\t * Fetches all delegated stakes for a specific wallet address. Delegated\n\t * stakes typically represent user funds staked to one or more validators.\n\t *\n\t * @param inputs - Contains the `walletAddress` for which to fetch delegated stakes.\n\t * @returns A promise resolving to an array of `SuiDelegatedStake` objects.\n\t *\n\t * @example\n\t * ```typescript\n\t * const delegatedStakes = await staking.getDelegatedStakes({\n\t * walletAddress: \"0x...\"\n\t * });\n\t * console.log(delegatedStakes);\n\t * ```\n\t */\n\tpublic async getDelegatedStakes(\n\t\tinputs: ApiDelegatedStakesBody\n\t): Promise<SuiDelegatedStake[]> {\n\t\treturn this.fetchApi(\"delegated-stakes\", inputs);\n\t}\n\n\t/**\n\t * Retrieves validator operation caps for a specified address. Operation caps\n\t * typically govern who is authorized to adjust validator fees and settings.\n\t *\n\t * @param inputs - Contains the `walletAddress` for which to fetch validator\n\t * operation caps, plus optional pagination.\n\t * @returns A promise resolving to an array of `ValidatorOperationCapObject`s.\n\t *\n\t * @example\n\t * ```typescript\n\t * const caps = await staking.getValidatorOperationCaps({\n\t * walletAddress: \"0x...\",\n\t * cursor: 0,\n\t * limit: 5\n\t * });\n\t * console.log(caps);\n\t * ```\n\t */\n\tpublic async getValidatorOperationCaps(\n\t\tinputs: ApiValidatorOperationCapsBody\n\t): Promise<ValidatorOperationCapObject[]> {\n\t\treturn this.fetchApi(\"validator-operation-caps\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds or fetches a staking transaction object, which can then be signed\n\t * and submitted to the network.\n\t *\n\t * @param inputs - Includes the `walletAddress`, the amount of SUI to stake, and\n\t * the validator address to stake with. Optionally includes a `referrer`, `externalFee`,\n\t * and a sponsored transaction flag.\n\t * @returns A promise resolving to a transaction that can be signed and executed.\n\t *\n\t * @example\n\t * ```typescript\n\t * const stakeTx = await staking.getStakeTransaction({\n\t * walletAddress: \"0x...\",\n\t * suiStakeAmount: BigInt(\"1000000000\"), // 1 SUI\n\t * validatorAddress: \"0x...\"\n\t * });\n\t * // sign and execute this transaction using your preferred Sui wallet\n\t * ```\n\t */\n\tpublic async getStakeTransaction(inputs: ApiStakeBody) {\n\t\treturn this.useProvider().fetchBuildStakeTx(inputs);\n\t}\n\n\t/**\n\t * Builds or fetches an unstaking transaction object, allowing a user to\n\t * convert their afSUI back into SUI (either atomically or via partial\n\t * liquidity).\n\t *\n\t * @param inputs - Contains the `walletAddress`, the afSUI amount to unstake,\n\t * and whether it's an atomic operation. Optionally includes a `referrer`,\n\t * `externalFee`, and a sponsored transaction flag.\n\t * @returns A promise resolving to a transaction that can be signed and executed.\n\t *\n\t * @example\n\t * ```typescript\n\t * const unstakeTx = await staking.getUnstakeTransaction({\n\t * walletAddress: \"0x...\",\n\t * afSuiUnstakeAmount: BigInt(\"1000000000\"), // 1 afSUI\n\t * isAtomic: true\n\t * });\n\t * // sign and execute this transaction to receive SUI\n\t * ```\n\t */\n\tpublic async getUnstakeTransaction(inputs: ApiUnstakeBody) {\n\t\treturn this.useProvider().fetchBuildUnstakeTx(inputs);\n\t}\n\n\t/**\n\t * Builds or fetches a transaction to stake an existing stakedSUI object\n\t * (e.g., re-staking funds that were already staked under a different\n\t * validator).\n\t *\n\t * @param inputs - Contains the `walletAddress`, an array of `stakedSuiIds`\n\t * to be re-staked, and the new `validatorAddress`. Optionally includes\n\t * a `referrer` and a sponsored transaction flag.\n\t * @returns A promise resolving to a transaction object that can be signed\n\t * and executed.\n\t *\n\t * @example\n\t * ```typescript\n\t * const stakeStakedTx = await staking.getStakeStakedSuiTransaction({\n\t * walletAddress: \"0x...\",\n\t * stakedSuiIds: [\"0x<stakedSuiId1>\", \"0x<stakedSuiId2>\"],\n\t * validatorAddress: \"0x...\"\n\t * });\n\t * // sign and execute this transaction\n\t * ```\n\t */\n\tpublic async getStakeStakedSuiTransaction(inputs: ApiStakeStakedSuiBody) {\n\t\treturn this.useProvider().fetchBuildStakeStakedSuiTx(inputs);\n\t}\n\n\t/**\n\t * Builds or fetches a transaction to update the validator fee for a\n\t * validator in which the user has operation cap privileges.\n\t *\n\t * @param inputs - Contains the `walletAddress`, `validatorOperationCapId`,\n\t * and `newFeePercentage`. Optionally includes a sponsored transaction flag.\n\t * @returns A transaction object that can be signed and executed to\n\t * update the validator's fee on-chain.\n\t *\n\t * @example\n\t * ```typescript\n\t * const updateFeeTx = await staking.getUpdateValidatorFeeTransaction({\n\t * walletAddress: \"0x...\",\n\t * validatorOperationCapId: \"0x...\",\n\t * newFeePercentage: 0.01,\n\t * isSponsoredTx: false\n\t * });\n\t * // sign and execute to update the validator fee\n\t * ```\n\t */\n\tpublic getUpdateValidatorFeeTransaction(inputs: ApiUpdateValidatorFeeBody) {\n\t\treturn this.useProvider().buildUpdateValidatorFeeTx(inputs);\n\t}\n\n\t/**\n\t * Builds a \"crank\" transaction to update the epoch for afSUI. This can\n\t * trigger certain internal processes within the Aftermath protocol,\n\t * such as distributing rewards or rebalancing.\n\t *\n\t * @param inputs - Contains the `walletAddress` to sign the transaction.\n\t * @returns A transaction object that can be signed and submitted to\n\t * trigger an epoch update.\n\t *\n\t * @example\n\t * ```typescript\n\t * const crankTx = await staking.getCrankAfSuiTransaction({\n\t * walletAddress: \"0x...\"\n\t * });\n\t * // sign and execute transaction\n\t * ```\n\t */\n\tpublic getCrankAfSuiTransaction(inputs: { walletAddress: SuiAddress }) {\n\t\treturn this.useProvider().buildEpochWasChangedTx(inputs);\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the total value locked (TVL) in SUI across the Aftermath\n\t * staking systems.\n\t *\n\t * @returns A promise that resolves to a `Balance` representing the total\n\t * staked SUI in the protocol.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tvl = await staking.getSuiTvl();\n\t * console.log(\"Total value locked in SUI:\", tvl);\n\t * ```\n\t */\n\tpublic async getSuiTvl(): Promise<Balance> {\n\t\treturn this.fetchApi(\"sui-tvl\");\n\t}\n\n\t/**\n\t * Retrieves the current exchange rate between afSUI and SUI. This rate\n\t * is used to determine how much SUI a single afSUI token is worth.\n\t *\n\t * @returns A promise that resolves to a `number` representing the\n\t * afSUI-to-SUI rate.\n\t *\n\t * @example\n\t * ```typescript\n\t * const rate = await staking.getAfSuiToSuiExchangeRate();\n\t * console.log(\"1 afSUI =\", rate, \"SUI\");\n\t * ```\n\t */\n\tpublic async getAfSuiToSuiExchangeRate(): Promise<number> {\n\t\treturn this.fetchApi(\"afsui-exchange-rate\");\n\t}\n\n\t/**\n\t * Retrieves the stakedSui vault state from the protocol, which holds\n\t * important values for calculating fees, reserves, and total active\n\t * stake.\n\t *\n\t * @returns A promise that resolves to a `StakedSuiVaultStateObject`,\n\t * containing details like atomic unstake reserves, fees, and total SUI.\n\t *\n\t * @example\n\t * ```typescript\n\t * const vaultState = await staking.getStakedSuiVaultState();\n\t * console.log(\"Vault State:\", vaultState);\n\t * ```\n\t */\n\tpublic async getStakedSuiVaultState(): Promise<StakedSuiVaultStateObject> {\n\t\treturn this.fetchApi(\"staked-sui-vault-state\");\n\t}\n\n\t/**\n\t * Retrieves the current APY (Annual Percentage Yield) for staking SUI\n\t * through Aftermath.\n\t *\n\t * @returns A promise that resolves to a `number` representing the APY.\n\t *\n\t * @example\n\t * ```typescript\n\t * const apy = await staking.getApy();\n\t * console.log(\"Current staking APY:\", apy);\n\t * ```\n\t */\n\tpublic async getApy(): Promise<number> {\n\t\treturn this.fetchApi(\"apy\");\n\t}\n\n\t/**\n\t * Retrieves historical APY data points over a specified timeframe.\n\t *\n\t * @param inputs - Contains a `timeframe` key, such as `\"1W\"`, `\"1M\"`, `\"1Y\"`, etc.\n\t * @returns A promise resolving to an array of `StakingApyDataPoint` objects,\n\t * each containing a timestamp and an APY value.\n\t *\n\t * @example\n\t * ```typescript\n\t * const historicalApy = await staking.getHistoricalApy({ timeframe: \"1M\" });\n\t * console.log(historicalApy); // e.g. [{ timestamp: 1686000000, apy: 0.045 }, ...]\n\t * ```\n\t */\n\tpublic async getHistoricalApy(inputs: {\n\t\ttimeframe: StakingApyTimeframeKey;\n\t}): Promise<StakingApyDataPoint[]> {\n\t\treturn this.fetchApi(\"historical-apy\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Public Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\t/**\n\t * Calculates the atomic unstake fee based on the current vault state. If\n\t * the `atomicUnstakeSuiReserves` remain above the target, the minimum fee\n\t * applies; otherwise, the fee adjusts proportionally up to the maximum\n\t * possible fee.\n\t *\n\t * @param inputs - Contains the `stakedSuiVaultState`, which holds data on\n\t * liquidity reserves, target values, and min/max fees.\n\t * @returns A `Percentage` representing the resulting fee (0.01 = 1%).\n\t *\n\t * @example\n\t * ```typescript\n\t * const vaultState = await staking.getStakedSuiVaultState();\n\t * const fee = Staking.calcAtomicUnstakeFee({ stakedSuiVaultState: vaultState });\n\t * console.log(\"Current atomic unstake fee:\", fee);\n\t * ```\n\t */\n\tpublic static calcAtomicUnstakeFee(inputs: {\n\t\tstakedSuiVaultState: StakedSuiVaultStateObject;\n\t}): Percentage {\n\t\tconst { stakedSuiVaultState } = inputs;\n\n\t\t// iia. Calculate the `atomic_unstake_fee`.\n\t\tif (\n\t\t\tstakedSuiVaultState.atomicUnstakeSuiReserves >=\n\t\t\tstakedSuiVaultState.atomicUnstakeSuiReservesTargetValue\n\t\t) {\n\t\t\t// Atomic unstakes that keep the `atomic_unstake_sui_reserves` larger than the desired target\n\t\t\t// value receive the minimum fee.\n\n\t\t\treturn Casting.bigIntToFixedNumber(\n\t\t\t\tstakedSuiVaultState.minAtomicUnstakeFee\n\t\t\t);\n\t\t} else {\n\t\t\t// Atomic unstakes that bring the `atomic_unstake_sui_reserves` below the desired target\n\t\t\t// incur a variable fee:\n\t\t\t// fee = max_fee - ((max_fee - min_fee) * liquidity_after / target_liquidity_value)\n\n\t\t\tconst atomicFeeDelta =\n\t\t\t\tstakedSuiVaultState.maxAtomicUnstakeFee -\n\t\t\t\tstakedSuiVaultState.minAtomicUnstakeFee;\n\n\t\t\treturn Casting.bigIntToFixedNumber(\n\t\t\t\tstakedSuiVaultState.maxAtomicUnstakeFee -\n\t\t\t\t\t(atomicFeeDelta *\n\t\t\t\t\t\tstakedSuiVaultState.atomicUnstakeSuiReserves) /\n\t\t\t\t\t\tstakedSuiVaultState.atomicUnstakeSuiReservesTargetValue\n\t\t\t);\n\t\t}\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t/**\n\t * Returns a provider instance for building transactions. Throws an error\n\t * if `Provider` is not defined.\n\t *\n\t * @returns An instance of `AftermathApi.Staking`.\n\t * @throws Will throw if the `Provider` is undefined.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Staking();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./staking\";\n","import type { SuiSystemStateSummary } from \"@mysten/sui/jsonRpc\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { CallerConfig, CoinType, SuiNetwork, Url } from \"../../types\";\nimport { AftermathApi } from \"../../general/providers\";\n\n/**\n * The `Sui` class provides utilities to fetch core Sui chain information,\n * such as the system state. It also exposes a set of constant addresses\n * related to the Sui network package IDs.\n */\nexport class Sui extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Static constants containing important addresses on the Sui network:\n\t * - `zero`: The zero address (commonly used as a null placeholder).\n\t * - `suiPackageId`: The package ID for the Sui system package.\n\t * - `suiSystemStateId`: The object ID for the Sui system state.\n\t * - `suiClockId`: The object ID for the Sui on-chain clock.\n\t */\n\tpublic static readonly constants = {\n\t\taddresses: {\n\t\t\tzero: \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n\t\t\tsuiPackageId:\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002\",\n\t\t\tsuiSystemStateId:\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000005\",\n\t\t\tsuiClockId:\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000006\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of the `Sui` class for fetching chain-level info.\n\t *\n\t * @param config - Optional configuration, including the Sui network and an access token.\n\t * @param Provider - An optional `AftermathApi` instance for advanced transaction building or data fetching.\n\t */\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"sui\");\n\t}\n\n\t// =========================================================================\n\t// Chain Info\n\t// =========================================================================\n\n\t/**\n\t * Fetches the Sui system state summary object, which contains details\n\t * about the current epoch, validator set, and other protocol-level data.\n\t *\n\t * @returns A promise that resolves to a `SuiSystemStateSummary` instance.\n\t *\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const sui = afSdk.Sui();\n\t *\n\t * const systemState = await sui.getSystemState();\n\t * console.log(systemState.epoch, systemState.validators);\n\t * ```\n\t */\n\tpublic async getSystemState(): Promise<SuiSystemStateSummary> {\n\t\treturn this.fetchApi(\"system-state\");\n\t}\n}\n","export * from \"./sui\";\n","import {\n\tApiStakeSuiFrenBody,\n\tSuiNetwork,\n\tSuiFrenObject,\n\tUrl,\n\tNft,\n\tBalance,\n\tSuiFrenAccessoryType,\n\tApiAddSuiFrenAccessoryBody,\n\tApiRemoveSuiFrenAccessoryBody,\n\tSuiFrenAccessoryObject,\n\tApiAccessoriesForSuiFrenBody,\n\tAnyObjectType,\n\tObjectId,\n\tSuiAddress,\n\tCallerConfig,\n} from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport dayjs from \"dayjs\";\nimport { Coin } from \"..\";\nimport { AftermathApi } from \"../../general/providers\";\n\nexport class SuiFren extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tpublic readonly suiFren: SuiFrenObject,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly isStaked: boolean = false,\n\t\tpublic readonly isOwned: boolean = false,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"sui-frens\");\n\t}\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\tpublic suiFrenType(): AnyObjectType {\n\t\treturn Coin.getInnerCoinType(this.suiFren.objectType);\n\t}\n\n\tpublic properties(): Record<string, string> {\n\t\treturn {\n\t\t\tSkin: this.suiFren.attributes.skin,\n\t\t\tEars: this.suiFren.attributes.ears,\n\t\t\tExpression: this.suiFren.attributes.expression,\n\t\t\t\"Main Color\": this.suiFren.attributes.main,\n\t\t\t\"Secondary Color\": this.suiFren.attributes.secondary,\n\t\t\t\"Birth Location\": this.suiFren.birthLocation,\n\t\t\tBirthday: dayjs(this.suiFren.birthdate).format(\"MMMM D, YYYY\"),\n\t\t\tCohort: this.suiFren.cohort.toString(),\n\t\t\tGeneration: this.suiFren.generation.toString(),\n\t\t\t// Genes: this.suiFren.genes.toString(),\n\t\t};\n\t}\n\n\tpublic dynamicFields(): Record<string, string> {\n\t\treturn {\n\t\t\t...(this.suiFren.mixLimit\n\t\t\t\t? {\n\t\t\t\t\t\t\"Mixes Remaining\": this.suiFren.mixLimit.toString(),\n\t\t\t\t }\n\t\t\t\t: {}),\n\t\t\t...(this.suiFren.lastEpochMixed\n\t\t\t\t? {\n\t\t\t\t\t\t\"Last Epoch Mixed\":\n\t\t\t\t\t\t\tthis.suiFren.lastEpochMixed.toString(),\n\t\t\t\t }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\tpublic displayNumber(): string {\n\t\treturn this.suiFren.objectId.slice(-5, -1).toUpperCase();\n\t}\n\n\tpublic clone(): SuiFren {\n\t\treturn new SuiFren(\n\t\t\tthis.suiFren,\n\t\t\tthis.config,\n\t\t\tthis.isStaked,\n\t\t\tthis.isOwned\n\t\t);\n\t}\n\n\t// public asNft(): Nft {\n\t// \treturn {\n\t// \t\tinfo: {\n\t// \t\t\tobjectId: this.suiFren.objectId,\n\t// \t\t\tobjectType: this.suiFren.objectType,\n\t// \t\t},\n\t// \t\tdisplay: {\n\t// \t\t\tsuggested: {\n\t// \t\t\t\tname: \"SuiFren\",\n\t// \t\t\t\t...this.suiFren.display,\n\t// \t\t\t},\n\t// \t\t\tother: {\n\t// \t\t\t\tSkin: this.suiFren.attributes.skin,\n\t// \t\t\t\tEars: this.suiFren.attributes.ears,\n\t// \t\t\t\tExpression: this.suiFren.attributes.expression,\n\t// \t\t\t\t\"Main Color\": this.suiFren.attributes.main,\n\t// \t\t\t\t\"Secondary Color\": this.suiFren.attributes.secondary,\n\t// \t\t\t\t\"Birth Location\": this.suiFren.birthLocation,\n\t// \t\t\t\tBirthday: dayjs(this.suiFren.birthdate).format(\n\t// \t\t\t\t\t\"MMMM D, YYYY\"\n\t// \t\t\t\t),\n\t// \t\t\t\tCohort: this.suiFren.cohort.toString(),\n\t// \t\t\t\tGeneration: this.suiFren.generation.toString(),\n\t// \t\t\t\t...(this.suiFren.mixLimit\n\t// \t\t\t\t\t? {\n\t// \t\t\t\t\t\t\t\"Mixes Remaining\":\n\t// \t\t\t\t\t\t\t\tthis.suiFren.mixLimit.toString(),\n\t// \t\t\t\t\t }\n\t// \t\t\t\t\t: {}),\n\t// \t\t\t\t...(this.suiFren.lastEpochMixed\n\t// \t\t\t\t\t? {\n\t// \t\t\t\t\t\t\t\"Last Epoch Mixed\":\n\t// \t\t\t\t\t\t\t\tthis.suiFren.lastEpochMixed.toString(),\n\t// \t\t\t\t\t }\n\t// \t\t\t\t\t: {}),\n\t// \t\t\t\t// Genes: this.suiFren.genes.toString(),\n\t// \t\t\t},\n\t// \t\t},\n\t// \t};\n\t// }\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic async getAccessories() {\n\t\treturn this.fetchApi<\n\t\t\tSuiFrenAccessoryObject[],\n\t\t\tApiAccessoriesForSuiFrenBody\n\t\t>(\"accessories\", {\n\t\t\tsuiFrenId: this.suiFren.objectId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getStakeTransaction(inputs: {\n\t\tbaseFee: Balance;\n\t\tfeeIncrementPerMix: Balance;\n\t\tminRemainingMixesToKeep: bigint;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tif (this.isStaked)\n\t\t\tthrow new Error(\"unable to stake already staked suiFren\");\n\n\t\treturn this.useProvider().fetchStakeTx({\n\t\t\t...inputs,\n\t\t\tsuiFrenType: this.suiFrenType(),\n\t\t\tsuiFrenId: this.suiFren.objectId,\n\t\t});\n\t}\n\n\tpublic async getAddAccessoryTransaction(inputs: {\n\t\taccessoryId: ObjectId;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\treturn this.useProvider().fetchBuildAddAccessoryTx({\n\t\t\t...inputs,\n\t\t\tisOwned: this.isOwned,\n\t\t\tsuiFrenType: this.suiFrenType(),\n\t\t\tsuiFrenId: this.suiFren.objectId,\n\t\t});\n\t}\n\n\tpublic async getRemoveAccessoryTransaction(inputs: {\n\t\taccessoryType: SuiFrenAccessoryType;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tif (!this.isOwned)\n\t\t\tthrow new Error(\n\t\t\t\t\"unable to remove accessory from suiFren that is not owned by caller\"\n\t\t\t);\n\n\t\treturn this.useProvider().fetchBuildRemoveAccessoryTx({\n\t\t\t...inputs,\n\t\t\tsuiFrenType: this.suiFrenType(),\n\t\t\tsuiFrenId: this.suiFren.objectId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.SuiFrens();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import {\n\tApiAddSuiFrenAccessoryBody,\n\tApiRemoveSuiFrenAccessoryBody,\n\tApiUnstakeSuiFrenBody,\n\tApiHarvestSuiFrenFeesBody,\n\tBalance,\n\tStakedSuiFrenInfo,\n\tSuiFrenAccessoryType,\n\tSuiNetwork,\n\tUrl,\n\tObjectId,\n\tSuiAddress,\n\tCallerConfig,\n} from \"../../types\";\nimport { SuiFren } from \"./suiFren\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { AftermathApi } from \"../../general/providers\";\n\nexport class StakedSuiFren extends Caller {\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly suiFren: SuiFren;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tpublic readonly info: StakedSuiFrenInfo,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly isOwned: boolean = false,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"sui-frens\");\n\t\tthis.suiFren = new SuiFren(info.suiFren, this.config, true, isOwned);\n\t}\n\n\t// =========================================================================\n\t// Getters\n\t// =========================================================================\n\n\tpublic mixFee(): Balance {\n\t\treturn this.info.metadata.mixFee;\n\t}\n\n\tpublic suiFrenId(): ObjectId {\n\t\treturn this.suiFren.suiFren.objectId;\n\t}\n\n\tpublic clone(): StakedSuiFren {\n\t\treturn new StakedSuiFren(\n\t\t\tthis.info,\n\t\t\tthis.config,\n\t\t\tthis.isOwned,\n\t\t\tthis.Provider\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic async getAccessories() {\n\t\treturn this.suiFren.getAccessories();\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getUnstakeTransaction(inputs: { walletAddress: SuiAddress }) {\n\t\tif (!this.info.position)\n\t\t\tthrow new Error(\"no position found on suiFren\");\n\n\t\treturn this.useProvider().fetchUnstakeTx({\n\t\t\t...inputs,\n\t\t\tsuiFrenType: this.suiFren.suiFrenType(),\n\t\t\tstakedPositionId: this.info.position.objectId,\n\t\t});\n\t}\n\n\tpublic async getHarvestFeesTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tif (!this.info.position)\n\t\t\tthrow new Error(\"no position found on suiFren\");\n\t\tif (!this.isOwned)\n\t\t\tthrow new Error(\n\t\t\t\t\"unable to remove accessory from suiFren that is not owned by caller\"\n\t\t\t);\n\n\t\treturn this.useProvider().fetchBuildHarvestFeesTx({\n\t\t\t...inputs,\n\t\t\tstakedPositionIds: [this.info.position.objectId],\n\t\t});\n\t}\n\n\tpublic async getAddAccessoryTransaction(inputs: {\n\t\taccessoryId: ObjectId;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\treturn this.suiFren.getAddAccessoryTransaction(inputs);\n\t}\n\n\tpublic async getRemoveAccessoryTransaction(inputs: {\n\t\taccessoryType: SuiFrenAccessoryType;\n\t\twalletAddress: SuiAddress;\n\t}) {\n\t\tif (!this.info.position)\n\t\t\tthrow new Error(\"no position found on suiFren\");\n\t\tif (!this.isOwned)\n\t\t\tthrow new Error(\n\t\t\t\t\"unable to remove accessory from suiFren that is not owned by caller\"\n\t\t\t);\n\n\t\treturn this.useProvider().fetchBuildRemoveAccessoryTx({\n\t\t\t...inputs,\n\t\t\tsuiFrenType: this.suiFren.suiFrenType(),\n\t\t\tstakedPositionId: this.info.position.objectId,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.SuiFrens();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import {\n\tApiMixSuiFrensBody,\n\tApiDynamicFieldsBody,\n\tMixSuiFrensEvent,\n\tSuiFrenObject,\n\tSuiFrenStats,\n\tDynamicFieldObjectsWithCursor,\n\tEventsInputs,\n\tStakeSuiFrenEvent,\n\tSuiNetwork,\n\tUnstakeSuiFrenEvent,\n\tUrl,\n\tSuiFrenAttributes,\n\tCapyLabsAppObject,\n\tStakedSuiFrenInfo,\n\tDynamicFieldsInputs,\n\tBalance,\n\tSuiFrensSortOption,\n\tSuiFrenAccessoryObject,\n\tApiOwnedSuiFrenAccessoriesBody,\n\tApiOwnedSuiFrensBody,\n\tApiOwnedStakedSuiFrensBody,\n\tApiHarvestSuiFrenFeesBody,\n\tHarvestSuiFrenFeesEvent,\n\tObjectId,\n\tCallerConfig,\n} from \"../../types\";\nimport { SuiFren } from \"./suiFren\";\nimport { StakedSuiFren } from \"./stakedSuiFren\";\nimport { Caller } from \"../../general/utils/caller\";\nimport { Coin } from \"../coin\";\nimport { Helpers } from \"../../general/utils\";\nimport { AftermathApi } from \"../../general/providers\";\n\nexport class SuiFrens extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tpublic static readonly constants = {\n\t\tmixingFeeCoinType: Coin.constants.suiCoinType,\n\t\tprotocolFees: {\n\t\t\tmint: BigInt(250_000_000), // 0.25 SUI\n\t\t\tmixOwned: BigInt(250_000_000), // 0.25 SUI\n\t\t\tminMixStaked: BigInt(250_000_000), // 0.25 SUI\n\t\t\tmixStakedPercentage: 0.1, // 10%\n\t\t},\n\t\tsuifrenFees: {\n\t\t\tmint: BigInt(8_000_000_000), // 8 SUI\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"sui-frens\");\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Calculations\n\t// =========================================================================\n\n\tpublic static calcTotalInternalMixFee(inputs: {\n\t\tmixFee1: Balance | undefined;\n\t\tmixFee2: Balance | undefined;\n\t}): Balance {\n\t\tconst { mixFee1, mixFee2 } = inputs;\n\n\t\tif (mixFee1 === undefined && mixFee2 === undefined)\n\t\t\treturn this.constants.protocolFees.mixOwned;\n\n\t\tif (mixFee1 !== undefined && mixFee2 !== undefined) {\n\t\t\treturn (\n\t\t\t\tthis.calcMixFeeForStakedSuiFren({ mixFee: mixFee1 }) +\n\t\t\t\tthis.calcMixFeeForStakedSuiFren({ mixFee: mixFee2 })\n\t\t\t);\n\t\t}\n\n\t\treturn mixFee1 !== undefined\n\t\t\t? this.calcMixFeeForStakedSuiFren({ mixFee: mixFee1 })\n\t\t\t: mixFee2 !== undefined\n\t\t\t? this.calcMixFeeForStakedSuiFren({ mixFee: mixFee2 })\n\t\t\t: (() => {\n\t\t\t\t\t// to make TS happy :)\n\t\t\t\t\tthrow new Error(\"unreachable\");\n\t\t\t })();\n\t}\n\n\tprivate static calcMixFeeForStakedSuiFren(inputs: {\n\t\tmixFee: Balance;\n\t}): Balance {\n\t\tconst { mixFee } = inputs;\n\n\t\treturn (\n\t\t\tmixFee +\n\t\t\tHelpers.maxBigInt(\n\t\t\t\tthis.constants.protocolFees.minMixStaked,\n\t\t\t\tmixFee /\n\t\t\t\t\tBigInt(\n\t\t\t\t\t\tMath.floor(\n\t\t\t\t\t\t\tthis.constants.protocolFees.mixStakedPercentage *\n\t\t\t\t\t\t\t\t100\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Class Objects\n\t// =========================================================================\n\n\tpublic async getSuiFren(inputs: { suiFrenObjectId: ObjectId }) {\n\t\tconst suiFrens = await this.getSuiFrens({\n\t\t\tsuiFrenObjectIds: [inputs.suiFrenObjectId],\n\t\t});\n\t\treturn suiFrens[0];\n\t}\n\n\tpublic async getSuiFrens(inputs: { suiFrenObjectIds: ObjectId[] }) {\n\t\tconst suiFrens = await this.fetchApi<SuiFrenObject[]>(\n\t\t\t`${JSON.stringify(inputs.suiFrenObjectIds)}`\n\t\t);\n\t\treturn suiFrens.map((suiFren) => new SuiFren(suiFren, this.config));\n\t}\n\n\tpublic async getOwnedSuiFrens(inputs: ApiOwnedSuiFrensBody) {\n\t\tconst ownedSuiFrens = await this.fetchApi<\n\t\t\tSuiFrenObject[],\n\t\t\tApiOwnedSuiFrensBody\n\t\t>(`owned-sui-frens`, inputs);\n\n\t\treturn ownedSuiFrens.map(\n\t\t\t(suiFren) => new SuiFren(suiFren, this.config, false, true)\n\t\t);\n\t}\n\n\tpublic async getOwnedStakedSuiFrens(inputs: ApiOwnedStakedSuiFrensBody) {\n\t\tconst stakesInfo = await this.fetchApi<\n\t\t\tStakedSuiFrenInfo[],\n\t\t\tApiOwnedStakedSuiFrensBody\n\t\t>(`owned-staked-sui-frens`, inputs);\n\n\t\treturn stakesInfo.map(\n\t\t\t(info) => new StakedSuiFren(info, this.config, true)\n\t\t);\n\t}\n\n\tpublic async getAllStakedSuiFrens(\n\t\tinputs: {\n\t\t\tattributes: Partial<SuiFrenAttributes>;\n\t\t\tsortBy?: SuiFrensSortOption;\n\t\t} & DynamicFieldsInputs\n\t): Promise<DynamicFieldObjectsWithCursor<StakedSuiFren>> {\n\t\tconst stakesInfoWithCursor = await this.fetchApi<\n\t\t\tDynamicFieldObjectsWithCursor<StakedSuiFrenInfo>,\n\t\t\tApiDynamicFieldsBody\n\t\t>(\n\t\t\t`filtered-staked-sui-frens/${SuiFrens.createStakedSuiFrensQueryString(\n\t\t\t\tinputs\n\t\t\t)}`,\n\t\t\tinputs\n\t\t);\n\n\t\tconst suiFrens = stakesInfoWithCursor.dynamicFieldObjects.map(\n\t\t\t(info) => new StakedSuiFren(info, this.config)\n\t\t);\n\t\treturn {\n\t\t\tdynamicFieldObjects: suiFrens,\n\t\t\tnextCursor: stakesInfoWithCursor.nextCursor,\n\t\t};\n\t}\n\n\tpublic async getStakedSuiFrens(inputs: { stakedSuiFrenIds: ObjectId[] }) {\n\t\tconst suiFrenInfos = await this.fetchApi<StakedSuiFrenInfo[]>(\n\t\t\t`staked-sui-frens/${JSON.stringify(inputs.stakedSuiFrenIds)}`\n\t\t);\n\t\treturn suiFrenInfos.map((info) => new StakedSuiFren(info, this.config));\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic async getCapyLabsApp() {\n\t\treturn this.fetchApi<CapyLabsAppObject>(`capy-labs-app`);\n\t}\n\n\tpublic async getOwnedAccessories(inputs: ApiOwnedSuiFrenAccessoriesBody) {\n\t\treturn this.fetchApi<\n\t\t\tSuiFrenAccessoryObject[],\n\t\t\tApiOwnedSuiFrenAccessoriesBody\n\t\t>(\"owned-accessories\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic async getHarvestFeesEvents(inputs: EventsInputs) {\n\t\treturn this.fetchApiEvents<HarvestSuiFrenFeesEvent>(\n\t\t\t\"events/harvest-fees\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\tpublic async getMixEvents(inputs: EventsInputs) {\n\t\treturn this.fetchApiEvents<MixSuiFrensEvent>(\"events/mix\", inputs);\n\t}\n\n\tpublic async getStakeEvents(inputs: EventsInputs) {\n\t\treturn this.fetchApiEvents<StakeSuiFrenEvent>(\"events/stake\", inputs);\n\t}\n\n\tpublic async getUnstakeEvents(inputs: EventsInputs) {\n\t\treturn this.fetchApiEvents<UnstakeSuiFrenEvent>(\n\t\t\t\"events/unstake\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getMixTransaction(inputs: ApiMixSuiFrensBody) {\n\t\treturn this.useProvider().fetchBuildMixTx(inputs);\n\t}\n\n\tpublic async getHarvestFeesTransaction(inputs: ApiHarvestSuiFrenFeesBody) {\n\t\treturn this.useProvider().fetchBuildHarvestFeesTx(inputs);\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic async getStats(): Promise<SuiFrenStats> {\n\t\treturn this.fetchApi(\"stats\");\n\t}\n\n\t// =========================================================================\n\t// Public Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tpublic static suiFren(\n\t\tsuiFren: SuiFren | StakedSuiFren | undefined\n\t): SuiFren | undefined {\n\t\treturn suiFren instanceof SuiFren ? suiFren : suiFren?.suiFren;\n\t}\n\n\tpublic static suiFrenId(\n\t\tsuiFren: SuiFren | StakedSuiFren | undefined\n\t): ObjectId | undefined {\n\t\treturn suiFren?.suiFren instanceof SuiFren\n\t\t\t? suiFren?.suiFren?.suiFren.objectId\n\t\t\t: suiFren?.suiFren?.objectId;\n\t}\n\n\tpublic static mixFee(\n\t\tsuiFren: SuiFren | StakedSuiFren | undefined\n\t): Balance | undefined {\n\t\treturn suiFren instanceof StakedSuiFren ? suiFren?.mixFee() : undefined;\n\t}\n\n\t// =========================================================================\n\t// Private Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tprivate static createStakedSuiFrensQueryString(inputs: {\n\t\tattributes: Partial<SuiFrenAttributes>;\n\t\tsortBy?: SuiFrensSortOption;\n\t}) {\n\t\tconst { attributes, sortBy } = inputs;\n\n\t\tconst startStr = sortBy ? `?sort=${sortBy}` : \"\";\n\n\t\treturn Object.keys(attributes).length === 0\n\t\t\t? startStr\n\t\t\t: (startStr === \"\" ? \"?\" : startStr) +\n\t\t\t\t\tObject.entries(attributes)\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t([key, val], i) =>\n\t\t\t\t\t\t\t\t`${\n\t\t\t\t\t\t\t\t\ti === 0 && startStr === \"\" ? \"\" : \"&\"\n\t\t\t\t\t\t\t\t}${key}=${val}`\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.reduce((acc, curr) => acc + curr, \"\");\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.SuiFrens();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","export * from \"./suiFren\";\nexport * from \"./suiFrens\";\nexport * from \"./stakedSuiFren\";\n","export * from \"./auth\";\nexport * from \"./coin\";\nexport * from \"./farms\";\nexport * from \"./faucet\";\nexport * from \"./nftAmm\";\nexport * from \"./perpetuals\";\nexport * from \"./pools\";\nexport * from \"./referralVault\";\nexport * from \"./router\";\nexport * from \"./staking\";\n\nexport * from \"./sui\";\nexport * from \"./suiFrens\";\n","import { CallerConfig, ObjectId, SuiAddress } from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiDCAsOwnedBody,\n\tApiDcaTransactionForCreateOrderBody,\n\tApiDcaTransactionForCloseOrderBody,\n\tDcaOrderObject,\n\tDcaOrdersObject,\n\tApiDcaCreateUserBody,\n} from \"./dcaTypes\";\nimport { Transaction } from \"@mysten/sui/transactions\";\n\n/**\n * The `Dca` class provides functionality for automating Dollar-Cost Averaging\n * (DCA) strategies on the Aftermath platform. It allows you to create, query,\n * and close DCA orders that execute periodic trades based on user-defined\n * parameters.\n *\n * @example\n * ```typescript\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // initialize provider\n *\n * const dca = afSdk.Dca();\n * ```\n */\nexport class Dca extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Contains static values related to DCA on the Aftermath platform, such as\n\t * default gas usage for DCA transactions.\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * The default gas budget for DCA-related transactions (50 SUI).\n\t\t */\n\t\tgasAmount: BigInt(50_000_000),\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of the `Dca` class, responsible for\n\t * managing DCA orders (querying, creating, closing).\n\t *\n\t * @param config - Optional caller configuration, such as network and access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"dca\");\n\t}\n\n\t// =========================================================================\n\t// Class Objects\n\t// =========================================================================\n\n\t/**\n\t * **Deprecated**. Fetches both active and past DCA orders for a given user in one response.\n\t * Use `getActiveDcaOrders` and `getPastDcaOrders` for a more explicit approach.\n\t *\n\t * @param inputs - Object containing the user's `walletAddress`.\n\t * @returns A `DcaOrdersObject` grouping active and past orders.\n\t *\n\t * @deprecated Please use `getActiveDcaOrders` & `getPastDcaOrders` instead.\n\t * @example\n\t * ```typescript\n\t * // Old usage:\n\t * const allOrders = await dca.getAllDcaOrders({ walletAddress: \"0x...\" });\n\t * console.log(allOrders.active, allOrders.past);\n\t * ```\n\t */\n\tpublic async getAllDcaOrders(inputs: ApiDCAsOwnedBody) {\n\t\treturn this.fetchApi<DcaOrdersObject, ApiDCAsOwnedBody>(\n\t\t\t\"orders\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Retrieves the currently active DCA orders for a specific user.\n\t *\n\t * @param inputs - An object containing the user's `walletAddress`.\n\t * @returns A promise that resolves to an array of `DcaOrderObject` for the active orders.\n\t *\n\t * @example\n\t * ```typescript\n\t * const activeOrders = await dca.getActiveDcaOrders({ walletAddress: \"0x...\" });\n\t * console.log(activeOrders); // Array of active DCA orders\n\t * ```\n\t */\n\tpublic async getActiveDcaOrders(inputs: { walletAddress: SuiAddress }) {\n\t\treturn this.fetchApi<DcaOrderObject[], ApiDCAsOwnedBody>(\n\t\t\t\"active\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Retrieves the past (completed or canceled) DCA orders for a specific user.\n\t *\n\t * @param inputs - An object containing the user's `walletAddress`.\n\t * @returns A promise that resolves to an array of `DcaOrderObject` for the past orders.\n\t *\n\t * @example\n\t * ```typescript\n\t * const pastOrders = await dca.getPastDcaOrders({ walletAddress: \"0x...\" });\n\t * console.log(pastOrders); // Array of past DCA orders\n\t * ```\n\t */\n\tpublic async getPastDcaOrders(inputs: { walletAddress: SuiAddress }) {\n\t\treturn this.fetchApi<DcaOrderObject[], ApiDCAsOwnedBody>(\n\t\t\t\"past\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Builds a transaction block on the Aftermath API to create a new DCA order.\n\t * The resulting `Transaction` can then be signed and executed by the user.\n\t *\n\t * @param inputs - The parameters describing the DCA order (coin types, amounts, frequency, etc.).\n\t * @returns A `Transaction` object that can be signed and submitted to the Sui network.\n\t *\n\t * @example\n\t * ```typescript\n\t * const createOrderTx = await dca.getCreateDcaOrderTx({\n\t * walletAddress: \"0x<user>\",\n\t * allocateCoinType: \"0x2::sui::SUI\",\n\t * allocateCoinAmount: BigInt(1_000_000_000),\n\t * buyCoinType: \"0x<coin>\",\n\t * frequencyMs: 3600000, // Every hour\n\t * tradesAmount: 5,\n\t * // ...other fields...\n\t * });\n\t * // sign & send the transaction\n\t * ```\n\t */\n\tpublic async getCreateDcaOrderTx(\n\t\tinputs: ApiDcaTransactionForCreateOrderBody\n\t): Promise<Transaction> {\n\t\treturn this.fetchApiTransaction<ApiDcaTransactionForCreateOrderBody>(\n\t\t\t\"transactions/create-order\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Closes (cancels) an existing DCA order by sending a transaction with user signature.\n\t * Typically used after generating a message to sign with `closeDcaOrdersMessageToSign`.\n\t *\n\t * @param inputs - Contains the user's `walletAddress`, plus the `bytes` and `signature` from message signing.\n\t * @returns A boolean indicating success or failure (true if canceled).\n\t *\n\t * @example\n\t * ```typescript\n\t * const success = await dca.closeDcaOrder({\n\t * walletAddress: \"0x...\",\n\t * bytes: \"0x<signed_bytes>\",\n\t * signature: \"0x<signature>\",\n\t * });\n\t * ```\n\t */\n\tpublic async closeDcaOrder(\n\t\tinputs: ApiDcaTransactionForCloseOrderBody\n\t): Promise<boolean> {\n\t\treturn this.fetchApi<boolean, ApiDcaTransactionForCloseOrderBody>(\n\t\t\t`cancel`,\n\t\t\tinputs\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Interactions\n\t// =========================================================================\n\n\t/**\n\t * Generates a JSON object representing the message to sign for canceling one or more DCA orders.\n\t * The user can sign this message (converted to bytes) locally, then submit the signature to\n\t * `closeDcaOrder`.\n\t *\n\t * @param inputs - An object containing `orderIds`, an array of order object IDs to cancel.\n\t * @returns An object with `action: \"CANCEL_DCA_ORDERS\"` and the `order_object_ids`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const msg = dca.closeDcaOrdersMessageToSign({ orderIds: [\"0x<order1>\", \"0x<order2>\"] });\n\t * console.log(msg);\n\t * // sign this as JSON or string-encode, then pass to closeDcaOrder\n\t * ```\n\t */\n\tpublic closeDcaOrdersMessageToSign(inputs: { orderIds: ObjectId[] }): {\n\t\taction: string;\n\t\torder_object_ids: string[];\n\t} {\n\t\treturn {\n\t\t\taction: \"CANCEL_DCA_ORDERS\",\n\t\t\torder_object_ids: inputs.orderIds,\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Interactions - Deprecated\n\t// =========================================================================\n\n\t/**\n\t * **Deprecated**. Generates a message object used in older flows to create\n\t * a DCA user account. Use the `userData` package for user key storage or account creation.\n\t *\n\t * @deprecated Please use method from `userData` package instead.\n\t * @returns An object with `action: \"CREATE_DCA_ACCOUNT\"`.\n\t */\n\tpublic createUserAccountMessageToSign(): {\n\t\taction: string;\n\t} {\n\t\treturn {\n\t\t\taction: \"CREATE_DCA_ACCOUNT\",\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// User Public Key\n\t// =========================================================================\n\n\t/**\n\t * **Deprecated**. Fetches the user's public key from the older DCA system.\n\t * Please use `getUserPublicKey` from the `userData` package instead.\n\t *\n\t * @deprecated Use `userData` package method instead\n\t * @param inputs - Contains the user's `walletAddress`.\n\t * @returns The public key as a string or `undefined`.\n\t */\n\tpublic async getUserPublicKey(inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<string | undefined> {\n\t\treturn this.fetchApi<\n\t\t\tstring | undefined,\n\t\t\t{\n\t\t\t\twalletAddress: SuiAddress;\n\t\t\t}\n\t\t>(`user/get`, inputs);\n\t}\n\n\t/**\n\t * **Deprecated**. Creates the user's public key in the older DCA system.\n\t * Please use `createUserPublicKey` from the `userData` package instead.\n\t *\n\t * @deprecated Use `userData` package method instead\n\t * @param inputs - Body containing the user address, bytes, and signature.\n\t * @returns `true` if the public key was successfully stored, otherwise `false`.\n\t */\n\tpublic async createUserPublicKey(\n\t\tinputs: ApiDcaCreateUserBody\n\t): Promise<boolean> {\n\t\treturn this.fetchApi<boolean, ApiDcaCreateUserBody>(\n\t\t\t`/user/add`,\n\t\t\tinputs\n\t\t);\n\t}\n}\n","import { CallerConfig, CoinType, ObjectId, SuiAddress } from \"../../types\";\nimport { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiLimitOrdersPastOrdersOwnedBody,\n\tApiLimitOrdersCreateOrderTransactionBody,\n\tApiLimitOrdersCancelOrderTransactionBody,\n\tLimitOrderObject,\n\tApiLimitOrdersActiveOrdersOwnedBody,\n} from \"./limitOrdersTypes\";\nimport { Transaction } from \"@mysten/sui/transactions\";\n\n/**\n * The `LimitOrders` class manages creation, cancellation, and querying of\n * limit orders on the Aftermath platform. Limit orders allow you to buy or\n * sell at a specified price, giving more control over your trades compared\n * to market execution.\n *\n * @example\n * ```typescript\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // initialize provider\n *\n * const limitOrders = afSdk.LimitOrders();\n * ```\n */\nexport class LimitOrders extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Static configuration constants, including a default gas amount for\n\t * limit order transactions (50 SUI).\n\t */\n\tpublic static readonly constants = {\n\t\t/**\n\t\t * The default gas budget for limit orders. This may be subject to change.\n\t\t */\n\t\tgasAmount: BigInt(50_000_000),\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `LimitOrders` instance for interacting with limit order functionality\n\t * on Aftermath.\n\t *\n\t * @param config - Optional configuration, including network and access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"limit-orders\");\n\t}\n\n\t// =========================================================================\n\t// Class Objects\n\t// =========================================================================\n\n\t/**\n\t * Fetches the list of **active** limit orders for a given user. The user must\n\t * provide a signature for identification.\n\t *\n\t * @param inputs - Contains the `walletAddress`, as well as `bytes` and `signature` if needed for auth.\n\t * @returns A promise resolving to an array of `LimitOrderObject`, representing the active orders.\n\t *\n\t * @example\n\t * ```typescript\n\t * const activeOrders = await limitOrders.getActiveLimitOrders({\n\t * walletAddress: \"0x<address>\",\n\t * bytes: \"0x<signed_bytes>\",\n\t * signature: \"0x<signature>\"\n\t * });\n\t * ```\n\t */\n\tpublic async getActiveLimitOrders(\n\t\tinputs: ApiLimitOrdersActiveOrdersOwnedBody\n\t) {\n\t\treturn this.fetchApi<\n\t\t\tLimitOrderObject[],\n\t\t\tApiLimitOrdersActiveOrdersOwnedBody\n\t\t>(\"active\", inputs);\n\t}\n\n\t/**\n\t * Fetches the list of **past** limit orders for a given user (e.g., completed, canceled, or expired).\n\t *\n\t * @param inputs - An object containing the `walletAddress`.\n\t * @returns A promise resolving to an array of `LimitOrderObject` representing past orders.\n\t *\n\t * @example\n\t * ```typescript\n\t * const pastOrders = await limitOrders.getPastLimitOrders({\n\t * walletAddress: \"0x<address>\",\n\t * });\n\t * ```\n\t */\n\tpublic async getPastLimitOrders(inputs: { walletAddress: SuiAddress }) {\n\t\treturn this.fetchApi<\n\t\t\tLimitOrderObject[],\n\t\t\tApiLimitOrdersPastOrdersOwnedBody\n\t\t>(\"past\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Constructs a limit order creation transaction on the Aftermath API, returning a `Transaction`\n\t * object that can be signed and submitted to the network.\n\t *\n\t * @param inputs - The limit order details, including coin types, amounts, expiry, etc.\n\t * @returns A promise resolving to a `Transaction` that can be locally signed and executed.\n\t *\n\t * @example\n\t * ```typescript\n\t * const tx = await limitOrders.getCreateLimitOrderTx({\n\t * walletAddress: \"0x<address>\",\n\t * allocateCoinType: \"0x<coin>\",\n\t * allocateCoinAmount: BigInt(1000),\n\t * buyCoinType: \"0x<other_coin>\",\n\t * expiryDurationMs: 3600000, // 1 hour\n\t * outputToInputExchangeRate: 0.5,\n\t * });\n\t * // sign and execute the transaction\n\t * ```\n\t */\n\tpublic async getCreateLimitOrderTx(\n\t\tinputs: ApiLimitOrdersCreateOrderTransactionBody\n\t): Promise<Transaction> {\n\t\treturn this.fetchApiTransaction<ApiLimitOrdersCreateOrderTransactionBody>(\n\t\t\t\"transactions/create-order\",\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Cancels an existing limit order by sending a request to the Aftermath API\n\t * with the user's signed cancellation message.\n\t *\n\t * @param inputs - Contains the user's `walletAddress`, plus `bytes` and `signature`.\n\t * @returns A boolean indicating whether the cancellation was successful.\n\t *\n\t * @example\n\t * ```typescript\n\t * const success = await limitOrders.cancelLimitOrder({\n\t * walletAddress: \"0x<address>\",\n\t * bytes: \"0x<signed_bytes>\",\n\t * signature: \"0x<signature>\",\n\t * });\n\t * ```\n\t */\n\tpublic async cancelLimitOrder(\n\t\tinputs: ApiLimitOrdersCancelOrderTransactionBody\n\t): Promise<boolean> {\n\t\treturn this.fetchApi<boolean, ApiLimitOrdersCancelOrderTransactionBody>(\n\t\t\t`cancel`,\n\t\t\tinputs\n\t\t);\n\t}\n\n\t// =========================================================================\n\t// Interactions\n\t// =========================================================================\n\n\t/**\n\t * Generates the JSON message needed to cancel one or more limit orders. The user\n\t * signs this message (converted to bytes), and the resulting signature is passed\n\t * to `cancelLimitOrder`.\n\t *\n\t * @param inputs - Object with `orderIds`, an array of order object IDs to cancel.\n\t * @returns A JSON structure with the action and order IDs to be canceled.\n\t *\n\t * @example\n\t * ```typescript\n\t * const msg = limitOrders.cancelLimitOrdersMessageToSign({\n\t * orderIds: [\"0x<order1>\", \"0x<order2>\"]\n\t * });\n\t * // user signs this JSON\n\t * ```\n\t */\n\tpublic cancelLimitOrdersMessageToSign(inputs: { orderIds: ObjectId[] }): {\n\t\taction: string;\n\t\torder_object_ids: string[];\n\t} {\n\t\treturn {\n\t\t\taction: \"CANCEL_LIMIT_ORDERS\",\n\t\t\torder_object_ids: inputs.orderIds,\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Configuration\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the minimum allowable order size (in USD) for limit orders on Aftermath.\n\t *\n\t * @returns A promise resolving to a `number` (USD value) or `undefined` if not configured.\n\t *\n\t * @example\n\t * ```typescript\n\t * const minSize = await limitOrders.getMinOrderSizeUsd();\n\t * console.log(\"Minimum order size in USD:\", minSize);\n\t * ```\n\t */\n\tpublic async getMinOrderSizeUsd() {\n\t\treturn this.fetchApi<number | undefined, {}>(\"min-order-size-usd\", {});\n\t}\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport { CallerConfig, SuiNetwork } from \"../../types\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { ApiMultisigUserBody } from \"./multisigTypes\";\n\n/**\n * The `Multisig` class provides methods to interact with multisig-related functionality,\n * such as retrieving a multisig address and associated public key for a user.\n */\nexport class Multisig extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of `Multisig`.\n\t *\n\t * @param config - Optional configuration for the `Caller`, including network and access token.\n\t * @param Provider - An optional instance of `AftermathApi` to build or fetch multisig data.\n\t */\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"multisig\");\n\t}\n\n\t// =========================================================================\n\t// API\n\t// =========================================================================\n\n\t/**\n\t * Retrieves a multisig address and corresponding public key for a user based on their\n\t * provided single public key.\n\t *\n\t * @param inputs - An object implementing `ApiMultisigUserBody`, containing the user's public key as a `Uint8Array`.\n\t * @returns A promise that resolves to an object containing both the multisig address and its public key.\n\t *\n\t * @example\n\t * ```typescript\n\t *\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const multisig = afSdk.Multisig();\n\t *\n\t * const data = await multisig.getMultisigForUser({\n\t * userPublicKey: myPublicKeyBytes\n\t * });\n\t * console.log(data.address, data.publicKey);\n\t * ```\n\t */\n\tpublic getMultisigForUser(inputs: ApiMultisigUserBody) {\n\t\treturn this.useProvider().getMultisigForUser(inputs);\n\t}\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t/**\n\t * Internal helper to get the configured `Multisig` provider from `AftermathApi`.\n\t * Throws an error if the provider is not available.\n\t */\n\tprivate useProvider = () => {\n\t\tconst provider = this.Provider?.Multisig();\n\t\tif (!provider) throw new Error(\"missing AftermathApi Provider\");\n\t\treturn provider;\n\t};\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport {\n\tApiReferralsCreateReferralLinkBody,\n\tApiReferralsCreateReferralLinkResponse,\n\tApiReferralsGetRefereesBody,\n\tApiReferralsGetRefereesResponse,\n\tApiReferralsGetRefCodeBody,\n\tApiReferralsGetRefCodeResponse,\n\tApiReferralsSetReferrerBody,\n\tApiReferralsSetReferrerResponse,\n\tCallerConfig,\n\tApiReferralsIsRefCodeTakenBody,\n\tApiReferralsIsRefCodeTakenResponse,\n\tApiReferralsGetLinkedRefCodeBody,\n\tApiReferralsGetLinkedRefCodeResponse,\n\tSuiAddress,\n\tTimestamp,\n} from \"../../types\";\n\nexport class Referrals extends Caller {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tpublic static readonly constants = {};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"referrals\");\n\t}\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\tpublic async getRefCode(\n\t\tinputs: ApiReferralsGetRefCodeBody\n\t): Promise<ApiReferralsGetRefCodeResponse> {\n\t\t// TODO: handle this better\n\t\tconst res: {\n\t\t\taddress: SuiAddress;\n\t\t\trefCode: string | null;\n\t\t} = await this.fetchApi(\"ref-code\", inputs);\n\t\treturn {\n\t\t\t...res,\n\t\t\trefCode: res.refCode === null ? undefined : res.refCode,\n\t\t};\n\t}\n\n\tpublic async getLinkedRefCode(\n\t\tinputs: ApiReferralsGetLinkedRefCodeBody\n\t): Promise<ApiReferralsGetLinkedRefCodeResponse> {\n\t\t// TODO: handle this better\n\t\tconst res: {\n\t\t\taddress: SuiAddress;\n\t\t\tlinkedRefCode: string | null;\n\t\t\tlinkedAt: Timestamp | null;\n\t\t} = await this.fetchApi(\"linked-ref-code\", inputs);\n\t\treturn {\n\t\t\t...res,\n\t\t\tlinkedRefCode:\n\t\t\t\tres.linkedRefCode === null ? undefined : res.linkedRefCode,\n\t\t\tlinkedAt: res.linkedAt === null ? undefined : res.linkedAt,\n\t\t};\n\t}\n\n\tpublic async getReferees(\n\t\tinputs: ApiReferralsGetRefereesBody\n\t): Promise<ApiReferralsGetRefereesResponse> {\n\t\treturn this.fetchApi(\"query\", inputs);\n\t}\n\n\tpublic async isRefCodeTaken(\n\t\tinputs: ApiReferralsIsRefCodeTakenBody\n\t): Promise<ApiReferralsIsRefCodeTakenResponse> {\n\t\treturn this.fetchApi(\"availability\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Actions\n\t// =========================================================================\n\n\tpublic async createReferralLink(\n\t\tinputs: ApiReferralsCreateReferralLinkBody\n\t): Promise<ApiReferralsCreateReferralLinkResponse> {\n\t\treturn this.fetchApi(\"create\", inputs);\n\t}\n\n\tpublic async setReferrer(\n\t\tinputs: ApiReferralsSetReferrerBody\n\t): Promise<ApiReferralsSetReferrerResponse> {\n\t\treturn this.fetchApi(\"link\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Messages to Sign\n\t// =========================================================================\n\n\t// public getRefCodeMessageToSign() {\n\t// \treturn {\n\t// \t\taction: \"GET_REF_CODE\",\n\t// \t\tdate: Date.now(),\n\t// \t};\n\t// }\n\n\t// public getLinkedRefCodeMessageToSign() {\n\t// \treturn {\n\t// \t\taction: \"GET_LINKED_REF_CODE\",\n\t// \t\tdate: Date.now(),\n\t// \t};\n\t// }\n\n\tpublic createReferralLinkMessageToSign(inputs: { refCode: string }) {\n\t\treturn {\n\t\t\taction: \"CREATE_REFERRAL\",\n\t\t\tref_code: inputs.refCode,\n\t\t\tdate: Math.round(Date.now() / 1000),\n\t\t};\n\t}\n\n\tpublic setReferrerMessageToSign(inputs: { refCode: string }) {\n\t\treturn {\n\t\t\taction: \"LINK_REFERRAL\",\n\t\t\tref_code: inputs.refCode,\n\t\t\tdate: Math.round(Date.now() / 1000),\n\t\t};\n\t}\n}\n","import { Transaction } from \"@mysten/sui/transactions\";\nimport { AftermathApi } from \"../../general/providers\";\nimport { Caller } from \"../../general/utils/caller\";\nimport type { CallerConfig, CoinType, SuiAddress } from \"../../types\";\nimport type {\n\tApiRewardsClaimRequestTxBody,\n\tApiRewardsClaimRequestTxResponse,\n\tApiRewardsGetClaimableBody,\n\tApiRewardsGetClaimableResponse,\n\tApiRewardsGetHistoryBody,\n\tApiRewardsGetHistoryResponse,\n\tApiRewardsGetPointsBody,\n\tApiRewardsGetPointsResponse,\n} from \"./rewardsTypes\";\n\nexport class Rewards extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, \"rewards\");\n\t}\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\tpublic async getPoints(\n\t\tinputs: ApiRewardsGetPointsBody\n\t): Promise<ApiRewardsGetPointsResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiRewardsGetPointsResponse,\n\t\t\tApiRewardsGetPointsBody\n\t\t>(\"points\", inputs);\n\t}\n\n\tpublic async getHistory(\n\t\tinputs: ApiRewardsGetHistoryBody\n\t): Promise<ApiRewardsGetHistoryResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiRewardsGetHistoryResponse,\n\t\t\tApiRewardsGetHistoryBody\n\t\t>(\"history\", inputs);\n\t}\n\n\tpublic async getClaimable(\n\t\tinputs: ApiRewardsGetClaimableBody\n\t): Promise<ApiRewardsGetClaimableResponse> {\n\t\treturn this.fetchApi<\n\t\t\tApiRewardsGetClaimableResponse,\n\t\t\tApiRewardsGetClaimableBody\n\t\t>(\"claimable\", inputs);\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\tpublic async getClaimTransaction(inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcoinTypes?: CoinType[];\n\t\trecipientAddress?: SuiAddress;\n\t\ttx?: Transaction;\n\t}) {\n\t\tconst { tx, ...otherInputs } = inputs;\n\n\t\treturn this.fetchApiTxObject<\n\t\t\tApiRewardsClaimRequestTxBody,\n\t\t\tApiRewardsClaimRequestTxResponse\n\t\t>(\n\t\t\t\"transactions/claim\",\n\t\t\t{\n\t\t\t\t...otherInputs,\n\t\t\t\ttxKind: await this.Provider?.Transactions().fetchBase64TxKindFromTx(\n\t\t\t\t\t{\n\t\t\t\t\t\ttx: tx ?? new Transaction(),\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\tundefined,\n\t\t\t{ txKind: true }\n\t\t);\n\t}\n}\n","import { Caller } from \"../../general/utils/caller\";\nimport { CallerConfig } from \"../../types\";\nimport {\n\tApiUserDataCreateUserBody,\n\tApiUserDataPublicKeyBody,\n} from \"./userDataTypes\";\n\n/**\n * The `UserData` class provides functionality for managing user-specific\n * information in the Aftermath system. It enables creating and retrieving\n * user public keys, as well as generating messages for signing.\n */\nexport class UserData extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new instance of the `UserData` class for interacting with user data endpoints.\n\t *\n\t * @param config - Optional configuration for the `Caller`, including network and access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"user-data\");\n\t}\n\n\t// =========================================================================\n\t// API\n\t// =========================================================================\n\n\t/**\n\t * Retrieves the stored user public key (if any) for a given wallet address.\n\t *\n\t * @param inputs - An object implementing `ApiUserDataPublicKeyBody`, containing the user's wallet address.\n\t * @returns A promise that resolves to a string representation of the user's public key, or `undefined` if none is found.\n\t *\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const userData = afSdk.UserData();\n\t *\n\t * const pubkey = await userData.getUserPublicKey({\n\t * walletAddress: \"0x<address>\"\n\t * });\n\t * console.log(pubkey); // \"0x<hex_public_key>\" or undefined\n\t * ```\n\t */\n\tpublic async getUserPublicKey(\n\t\tinputs: ApiUserDataPublicKeyBody\n\t): Promise<string | undefined> {\n\t\treturn this.fetchApi<string | undefined, ApiUserDataPublicKeyBody>(\n\t\t\t`public-key`,\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Creates (or updates) the stored public key for a user on the backend, linking\n\t * it to their wallet address.\n\t *\n\t * @param inputs - Details required to create or update the user's public key, including signature data.\n\t * @returns A promise that resolves to `true` if the public key was successfully created/updated, otherwise `false` or an error.\n\t *\n\t * @example\n\t * ```typescript\n\t * const created = await userData.createUserPublicKey({\n\t * walletAddress: \"0x<address>\",\n\t * bytes: \"0x<message_as_bytes>\",\n\t * signature: \"0x<signature>\"\n\t * });\n\t * console.log(\"Was public key created?\", created);\n\t * ```\n\t */\n\tpublic async createUserPublicKey(\n\t\tinputs: ApiUserDataCreateUserBody\n\t): Promise<boolean> {\n\t\treturn this.fetchApi<boolean, ApiUserDataCreateUserBody>(\n\t\t\t`save-public-key`,\n\t\t\tinputs\n\t\t);\n\t}\n\n\t/**\n\t * Generates a simple message object that the user should sign to prove their\n\t * intention to create or link an account in the Aftermath system.\n\t *\n\t * @returns An object with an `action` property, used as the data to sign.\n\t *\n\t * @example\n\t * ```typescript\n\t * const userData = new UserData();\n\t * const msgToSign = userData.createUserAccountMessageToSign();\n\t * console.log(msgToSign.action); // \"CREATE_USER_ACCOUNT\"\n\t * // The user can then sign msgToSign with their private key.\n\t * ```\n\t */\n\tpublic createUserAccountMessageToSign() {\n\t\treturn {\n\t\t\taction: `CREATE_USER_ACCOUNT`,\n\t\t};\n\t}\n\n\t/**\n\t * Generates a simple message object that the user should sign to confirm their agreement\n\t * with the Terms and Conditions of the service.\n\t *\n\t * @returns An object with an `action` property set to \"SIGN_TERMS_AND_CONDITIONS\".\n\t *\n\t * @example\n\t * ```typescript\n\t * const userData = new UserData();\n\t * const termsMsg = userData.createSignTermsAndConditionsMessageToSign();\n\t * console.log(termsMsg.action); // \"SIGN_TERMS_AND_CONDITIONS\"\n\t * // The user can sign this to show acceptance of the T&C.\n\t * ```\n\t */\n\tpublic createSignTermsAndConditionsMessageToSign(): {\n\t\taction: string;\n\t} {\n\t\treturn {\n\t\t\taction: `SIGN_TERMS_AND_CONDITIONS`,\n\t\t};\n\t}\n}\n","import { SuiNetwork } from \"../types/suiTypes\";\nimport { CallerConfig, SuiAddress, Url } from \"../types/generalTypes\";\nimport { CoinType } from \"../../packages/coin/coinTypes\";\nimport { Caller } from \"../utils/caller\";\nimport { Transaction } from \"@mysten/sui/transactions\";\nimport { ApiDynamicGasBody, ApiDynamicGasResponse } from \"./dynamicGasTypes\";\n\n/**\n * The `DynamicGas` class provides functionality for dynamically determining\n * or attaching a suitable gas payment object to a transaction. This allows\n * for more flexible transaction building when exact gas objects are not\n * predetermined.\n */\nexport class DynamicGas extends Caller {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates a new `DynamicGas` instance for interacting with dynamic gas endpoints.\n\t *\n\t * @param config - Optional caller config, including the Sui network and an access token.\n\t */\n\tconstructor(config?: CallerConfig) {\n\t\tsuper(config, \"dynamic-gas\");\n\t}\n\n\t// =========================================================================\n\t// Tx Setup\n\t// =========================================================================\n\n\t/**\n\t * Requests the dynamic gas service to set up a transaction with an appropriate gas coin,\n\t * or sponsor signature if needed, based on the user's wallet and coin type preference.\n\t *\n\t * @param inputs - An object containing the `Transaction` to be adjusted, the `walletAddress`, and `gasCoinType`.\n\t * @returns A promise that resolves to an `ApiDynamicGasResponse`, which includes the new transaction bytes\n\t * (`txBytes`) and possibly a `sponsoredSignature`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const dynamicGas = afSdk.DynamicGas();\n\t *\n\t * const updatedTx = await dynamicGas.getUseDynamicGasForTx({\n\t * tx: transactionBlock,\n\t * walletAddress: \"0x<user_address>\",\n\t * gasCoinType: \"0x2::sui::SUI\"\n\t * });\n\t * // updatedTx.txBytes and updatedTx.sponsoredSignature can now be used for signing/execution\n\t * ```\n\t */\n\tpublic async getUseDynamicGasForTx(inputs: {\n\t\ttx: Transaction;\n\t\twalletAddress: SuiAddress;\n\t\tgasCoinType: CoinType;\n\t}) {\n\t\tconst { tx, walletAddress, gasCoinType } = inputs;\n\t\treturn this.fetchApi<ApiDynamicGasResponse, ApiDynamicGasBody>(\"\", {\n\t\t\tserializedTx: tx.serialize(),\n\t\t\twalletAddress,\n\t\t\tgasCoinType,\n\t\t});\n\t}\n}\n","import {\n\tApiTransactionsBody,\n\tBalance,\n\tCallerConfig,\n\tSuiAddress,\n\tTransactionsWithCursor,\n} from \"../types/generalTypes\";\nimport { CoinType, CoinsToBalance } from \"../../packages/coin/coinTypes\";\nimport { Caller } from \"../utils/caller\";\nimport { AftermathApi } from \"../providers\";\n\n/**\n * The `Wallet` class allows querying a user's balances and transactions.\n * It handles fetching coin balances, transactions, and more by leveraging\n * an `AftermathApi.Wallet` provider.\n */\nexport class Wallet extends Caller {\n\t/**\n\t * Creates a new `Wallet` instance for a specific address.\n\t *\n\t * @param address - The Sui address for this wallet (e.g., \"0x<address>\").\n\t * @param config - An optional caller configuration including network and authentication.\n\t * @param Provider - An optional `AftermathApi` instance for wallet-specific methods.\n\t */\n\tconstructor(\n\t\tpublic readonly address: SuiAddress,\n\t\tconfig?: CallerConfig,\n\t\tpublic readonly Provider?: AftermathApi\n\t) {\n\t\tsuper(config, `wallet`);\n\t}\n\n\t// =========================================================================\n\t// Balances\n\t// =========================================================================\n\n\t/**\n\t * Fetches the balance for a single coin type in this wallet.\n\t *\n\t * @param inputs - An object containing the `coin` type to look up (e.g., \"0x2::sui::SUI\").\n\t * @returns A promise that resolves to the coin balance as a bigint.\n\t *\n\t * @example\n\t * ```typescript\n\t *\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const wallet = afSdk.Wallet(\"0x<address>\");\n\t *\n\t * const suiBalance = await wallet.getBalance({ coin: \"0x2::sui::SUI\" });\n\t * console.log(\"SUI Balance:\", suiBalance.toString());\n\t * ```\n\t */\n\tpublic async getBalance(inputs: { coin: CoinType }): Promise<Balance> {\n\t\treturn (await this.getBalances({ coins: [inputs.coin] }))[0];\n\t}\n\n\t/**\n\t * Fetches the balances for multiple specified coin types in this wallet.\n\t * This method currently returns an array of balances in the same order\n\t * as the requested coins.\n\t *\n\t * @param inputs - An object containing an array of `coins` (coin types).\n\t * @returns A promise resolving to an array of `Balance`s, each matching the corresponding coin in `inputs.coins`.\n\t *\n\t * @example\n\t * ```typescript\n\t * const wallet = new Wallet(\"0x<address>\");\n\t * const balances = await wallet.getBalances({ coins: [\"0x2::sui::SUI\", \"0x<...>\"] });\n\t * console.log(balances); // e.g. [1000000000n, 50000000000n]\n\t * ```\n\t */\n\tpublic async getBalances(inputs: {\n\t\tcoins: CoinType[];\n\t}): Promise<Balance[]> {\n\t\treturn this.fetchApi(`coin-balances`, {\n\t\t\t...inputs,\n\t\t\twalletAddress: this.address,\n\t\t});\n\t}\n\n\t/**\n\t * Fetches all coin balances held by this wallet address, returning a record\n\t * keyed by coin type.\n\t *\n\t * @returns A promise resolving to an object mapping coin types to balances (bigints).\n\t *\n\t * @example\n\t * ```typescript\n\t * const wallet = new Wallet(\"0x<address>\");\n\t * const allBalances = await wallet.getAllBalances();\n\t * console.log(allBalances); // { \"0x2::sui::SUI\": 1000000000n, \"0x<other_coin>\": 5000000000n, ... }\n\t * ```\n\t */\n\tpublic async getAllBalances(): Promise<CoinsToBalance> {\n\t\treturn this.fetchApi(`all-coin-balances`, {\n\t\t\twalletAddress: this.address,\n\t\t});\n\t}\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t/**\n\t * Fetches a paginated list of past transactions for this wallet address.\n\t *\n\t * @param inputs - An object implementing `ApiTransactionsBody`, which includes pagination parameters (`cursor`, `limit`) and an optional `order` or other fields.\n\t * @returns A promise that resolves to transaction details, including a cursor if more results exist.\n\t *\n\t * @example\n\t * ```typescript\n\t * const wallet = new Wallet(\"0x<address>\");\n\t * const txHistory = await wallet.getPastTransactions({ cursor: \"abc123\", limit: 10 });\n\t * console.log(txHistory.transactions, txHistory.nextCursor);\n\t * ```\n\t */\n\tpublic async getPastTransactions(\n\t\tinputs: ApiTransactionsBody\n\t): Promise<TransactionsWithCursor> {\n\t\treturn this.fetchApi(`past-transactions`, {\n\t\t\t...inputs,\n\t\t\twalletAddress: this.address,\n\t\t});\n\t}\n}\n","import {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport type { CoinStruct, PaginatedCoins } from \"@mysten/sui/jsonRpc\";\nimport { Coin } from \"../coin\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport { Balance, CoinType, ObjectId, SuiAddress } from \"../../../types\";\nimport { Helpers } from \"../../../general/utils/helpers\";\nimport { TransactionsApiHelpers } from \"../../../general/apiHelpers/transactionsApiHelpers\";\n// import { ethers, Networkish } from \"ethers\";\n\nexport class CoinApi {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\tpublic fetchCoinWithAmountTx = async (inputs: {\n\t\ttx: Transaction;\n\t\twalletAddress: SuiAddress;\n\t\tcoinType: CoinType;\n\t\tcoinAmount: Balance;\n\t\tisSponsoredTx?: boolean;\n\t}): Promise<TransactionObjectArgument> => {\n\t\tconst { tx, walletAddress, coinType, coinAmount, isSponsoredTx } =\n\t\t\tinputs;\n\n\t\ttx.setSender(walletAddress);\n\n\t\tconst coinData = await this.fetchCoinsWithAtLeastAmount(inputs);\n\t\treturn CoinApi.coinWithAmountTx({\n\t\t\ttx,\n\t\t\tcoinData,\n\t\t\tcoinAmount,\n\t\t\tcoinType,\n\t\t\tisSponsoredTx,\n\t\t});\n\t};\n\n\tpublic fetchCoinsWithAmountTx = async (inputs: {\n\t\ttx: Transaction;\n\t\twalletAddress: SuiAddress;\n\t\tcoinTypes: CoinType[];\n\t\tcoinAmounts: Balance[];\n\t\tisSponsoredTx?: boolean;\n\t}): Promise<TransactionObjectArgument[]> => {\n\t\tconst { tx, walletAddress, coinTypes, coinAmounts, isSponsoredTx } =\n\t\t\tinputs;\n\n\t\ttx.setSender(walletAddress);\n\n\t\tconst allCoinsData = await Promise.all(\n\t\t\tcoinTypes.map(async (coinType, index) =>\n\t\t\t\tthis.fetchCoinsWithAtLeastAmount({\n\t\t\t\t\t...inputs,\n\t\t\t\t\tcoinAmount: coinAmounts[index],\n\t\t\t\t\tcoinType,\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tlet coinArgs: TransactionObjectArgument[] = [];\n\t\tfor (const [index, coinData] of allCoinsData.entries()) {\n\t\t\tconst coinArg = CoinApi.coinWithAmountTx({\n\t\t\t\ttx,\n\t\t\t\tcoinData,\n\t\t\t\tcoinAmount: coinAmounts[index],\n\t\t\t\tcoinType: coinTypes[index],\n\t\t\t\tisSponsoredTx,\n\t\t\t});\n\n\t\t\tcoinArgs = [...coinArgs, coinArg];\n\t\t}\n\n\t\treturn coinArgs;\n\t};\n\n\tpublic fetchCoinsWithAtLeastAmount = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcoinType: CoinType;\n\t\tcoinAmount: Balance;\n\t}): Promise<CoinStruct[]> => {\n\t\tlet allCoinData: CoinStruct[] = [];\n\t\tlet cursor: string | undefined = undefined;\n\t\tdo {\n\t\t\tconst paginatedCoins: PaginatedCoins =\n\t\t\t\tawait this.Provider.provider.getCoins({\n\t\t\t\t\t...inputs,\n\t\t\t\t\towner: inputs.walletAddress,\n\t\t\t\t\tcursor,\n\t\t\t\t});\n\n\t\t\tconst coinData = paginatedCoins.data;\n\t\t\tallCoinData = [...allCoinData, ...coinData];\n\n\t\t\tif (\n\t\t\t\tpaginatedCoins.data.length === 0 ||\n\t\t\t\t!paginatedCoins.hasNextPage ||\n\t\t\t\t!paginatedCoins.nextCursor\n\t\t\t) {\n\t\t\t\tallCoinData.sort((b, a) =>\n\t\t\t\t\tNumber(BigInt(a.balance) - BigInt(b.balance))\n\t\t\t\t);\n\n\t\t\t\tlet coinDatas: CoinStruct[] = [];\n\t\t\t\tlet sum = BigInt(0);\n\t\t\t\tfor (const coinData of allCoinData) {\n\t\t\t\t\tcoinDatas.push(coinData);\n\t\t\t\t\tsum += BigInt(coinData.balance);\n\n\t\t\t\t\tif (sum >= inputs.coinAmount) return coinDatas;\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"wallet does not have coins of sufficient balance\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcursor = paginatedCoins.nextCursor;\n\t\t} while (true);\n\t};\n\n\t// fetchCoinsUntilAmountReachedOrEnd\n\tpublic fetchAllCoins = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcoinType: CoinType;\n\t\t// coinAmount: Balance;\n\t}): Promise<CoinStruct[]> => {\n\t\tlet allCoinData: CoinStruct[] = [];\n\t\tlet cursor: string | undefined = undefined;\n\t\tdo {\n\t\t\tconst paginatedCoins: PaginatedCoins =\n\t\t\t\tawait this.Provider.provider.getCoins({\n\t\t\t\t\t...inputs,\n\t\t\t\t\towner: inputs.walletAddress,\n\t\t\t\t\tcursor,\n\t\t\t\t});\n\n\t\t\t// const coinData = paginatedCoins.data.filter(\n\t\t\t// \t(data) => BigInt(data.balance) > BigInt(0)\n\t\t\t// );\n\t\t\tconst coinData = paginatedCoins.data;\n\t\t\tallCoinData = [...allCoinData, ...coinData];\n\n\t\t\t// const totalAmount = Helpers.sumBigInt(\n\t\t\t// \tallCoinData.map((data) => BigInt(data.balance))\n\t\t\t// );\n\t\t\t// if (totalAmount >= inputs.coinAmount) return allCoinData;\n\n\t\t\tif (\n\t\t\t\tpaginatedCoins.data.length === 0 ||\n\t\t\t\t!paginatedCoins.hasNextPage ||\n\t\t\t\t!paginatedCoins.nextCursor\n\t\t\t)\n\t\t\t\treturn allCoinData.sort((b, a) =>\n\t\t\t\t\tNumber(BigInt(b.coinObjectId) - BigInt(a.coinObjectId))\n\t\t\t\t);\n\n\t\t\tcursor = paginatedCoins.nextCursor;\n\t\t} while (true);\n\t};\n\n\t// =========================================================================\n\t// Private Static Methods\n\t// =========================================================================\n\n\tprivate static coinWithAmountTx = (inputs: {\n\t\ttx: Transaction;\n\t\tcoinData: CoinStruct[];\n\t\tcoinAmount: Balance;\n\t\tcoinType: CoinType;\n\t\tisSponsoredTx?: boolean;\n\t}): TransactionObjectArgument => {\n\t\tconst { tx, coinData, coinAmount, coinType, isSponsoredTx } = inputs;\n\n\t\tif (coinData.length <= 0)\n\t\t\tthrow new Error(\"wallet does not have coins of sufficient balance\");\n\n\t\tconst isSuiCoin = Coin.isSuiCoin(coinData[0].coinType);\n\n\t\tconst totalCoinBalance = Helpers.sumBigInt(\n\t\t\tcoinData.map((data) => BigInt(data.balance))\n\t\t);\n\t\tif (totalCoinBalance < coinAmount)\n\t\t\tthrow new Error(\"wallet does not have coins of sufficient balance\");\n\n\t\tif (!isSponsoredTx && isSuiCoin) {\n\t\t\ttx.setGasPayment(\n\t\t\t\tcoinData.map((obj) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...obj,\n\t\t\t\t\t\tobjectId: obj.coinObjectId,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t);\n\n\t\t\treturn tx.splitCoins(tx.gas, [coinAmount]);\n\t\t\t// return Helpers.transactions.splitCoinsTx({\n\t\t\t// \ttx,\n\t\t\t// \tcoinId: tx.gas,\n\t\t\t// \tamounts: [coinAmount],\n\t\t\t// \tcoinType,\n\t\t\t// });\n\t\t}\n\n\t\tconst coinObjectIds = coinData.map((data) => data.coinObjectId);\n\t\tconst mergedCoinObjectId: ObjectId = coinObjectIds[0];\n\n\t\tif (coinObjectIds.length > 1) {\n\t\t\t// TODO: fix this (v1)\n\n\t\t\tif (isSponsoredTx) {\n\t\t\t\ttx.add({\n\t\t\t\t\t$kind: \"MergeCoins\",\n\t\t\t\t\tMergeCoins: {\n\t\t\t\t\t\tdestination: tx.object(mergedCoinObjectId),\n\t\t\t\t\t\tsources: [\n\t\t\t\t\t\t\t...coinObjectIds\n\t\t\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t\t\t.map((coinId) => tx.object(coinId)),\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\ttx.mergeCoins(tx.object(mergedCoinObjectId), [\n\t\t\t\t\t...coinObjectIds\n\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t.map((coinId) => tx.object(coinId)),\n\t\t\t\t]);\n\t\t\t}\n\t\t}\n\n\t\t// return tx.add({\n\t\t// \tkind: \"SplitCoins\",\n\t\t// \tcoin: tx.object(mergedCoinObjectId),\n\t\t// \tamounts: [tx.pure(coinAmount)],\n\t\t// });\n\t\treturn isSponsoredTx\n\t\t\t? TransactionsApiHelpers.splitCoinTx({\n\t\t\t\t\ttx,\n\t\t\t\t\tcoinId: mergedCoinObjectId,\n\t\t\t\t\tamount: coinAmount,\n\t\t\t\t\tcoinType,\n\t\t\t })\n\t\t\t: tx.splitCoins(mergedCoinObjectId, [coinAmount]);\n\t};\n}\n","import { AftermathApi } from \"../../../general/providers\";\nimport {\n\tAnyObjectType,\n\tCoinType,\n\tDcaAddresses,\n\tObjectId,\n} from \"../../../types\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { Helpers } from \"../../../general/utils\";\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n} from \"@mysten/sui/transactions\";\n\nexport class DcaApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tdca: \"order\",\n\t\t\tevents: \"events\",\n\t\t\tconfig: \"config\",\n\t\t},\n\t\teventNames: {\n\t\t\tcreatedOrder: \"CreatedOrderEvent\",\n\t\t\tcreatedOrderV2: \"CreatedOrderEventV2\",\n\t\t\tclosedOrder: \"ClosedOrderEvent\",\n\t\t\texecutedTrade: \"ExecutedTradeEvent\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: DcaAddresses;\n\tpublic readonly eventTypes: {\n\t\tcreatedOrder: AnyObjectType;\n\t\tcreatedOrderV2: AnyObjectType;\n\t\tclosedOrder: AnyObjectType;\n\t\texecutedTrade: AnyObjectType;\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.dca;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\t\tthis.eventTypes = {\n\t\t\tcreatedOrder: this.createdOrderEventType(),\n\t\t\tcreatedOrderV2: this.createdOrderEventTypeV2(),\n\t\t\tclosedOrder: this.closedOrderEventType(),\n\t\t\texecutedTrade: this.executedOrderEventType(),\n\t\t};\n\t}\n\n\tpublic createCloseOrderTx = (inputs: {\n\t\ttx: Transaction;\n\t\tallocateCoinType: CoinType;\n\t\tbuyCoinType: CoinType;\n\t\torderId: ObjectId | TransactionArgument;\n\t}) => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.dca,\n\t\t\t\tDcaApi.constants.moduleNames.dca,\n\t\t\t\t\"close_order\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.allocateCoinType, inputs.buyCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof inputs.orderId === \"string\"\n\t\t\t\t\t? tx.object(inputs.orderId)\n\t\t\t\t\t: inputs.orderId,\n\t\t\t\ttx.object(this.addresses.objects.config),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tprivate createdOrderEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tDcaApi.constants.moduleNames.events,\n\t\t\tDcaApi.constants.eventNames.createdOrder\n\t\t);\n\n\tprivate createdOrderEventTypeV2 = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.eventsV2,\n\t\t\tDcaApi.constants.moduleNames.events,\n\t\t\tDcaApi.constants.eventNames.createdOrderV2\n\t\t);\n\n\tprivate closedOrderEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tDcaApi.constants.moduleNames.events,\n\t\t\tDcaApi.constants.eventNames.closedOrder\n\t\t);\n\n\tprivate executedOrderEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tDcaApi.constants.moduleNames.events,\n\t\t\tDcaApi.constants.eventNames.executedTrade\n\t\t);\n}\n","import { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tAnyObjectType,\n\tFarmsAddresses,\n\tTimestamp,\n\tCoinType,\n\tApiFarmsStakeBody,\n\tApiHarvestFarmsRewardsBody,\n\tApiFarmsDepositPrincipalBody,\n\tBalance,\n\tApiFarmsUnstakeBody,\n\tFarmsLockEnforcement,\n\tFarmsMultiplier,\n\tApiFarmsCreateStakingPoolBody,\n\tFarmsStakingPoolObject,\n\tApiFarmsTopUpStakingPoolRewardsBody,\n\tApiFarmsInitializeStakingPoolRewardBody,\n\tStakingPoolOwnerCapObject,\n\tApiFarmsOwnedStakingPoolOwnerCapsBody,\n\tApiFarmsIncreaseStakingPoolRewardsEmissionsBody,\n\tPartialFarmsStakedPositionObject,\n\tEventsInputs,\n\tFarmsStakedEvent,\n\tFarmsStakedRelaxedEvent,\n\tFarmsLockedEvent,\n\tFarmsUnlockedEvent,\n\tFarmsWithdrewPrincipalEvent,\n\tFarmsDepositedPrincipalEvent,\n\tFarmsHarvestedRewardsEvent,\n\tFarmsCreatedVaultEvent,\n\tStakingPoolOneTimeAdminCapObject,\n\tFarmOwnerOrOneTimeAdminCap,\n\tObjectId,\n\tSuiAddress,\n\tBigIntAsString,\n\tApiFarmsCreateStakingPoolBodyV1,\n\tApiFarmsStakeBodyV1,\n\tFarmsVersion,\n} from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { Sui } from \"../../sui\";\nimport {\n\tFarmsCreatedVaultEventOnChainV1,\n\tFarmsDepositedPrincipalEventOnChainV1,\n\tFarmsHarvestedRewardsEventOnChainV1,\n\tFarmsLockedEventOnChainV1,\n\tFarmsStakedEventOnChainV1,\n\tFarmsStakedRelaxedEventOnChainV1,\n\tFarmsUnlockedEventOnChainV1,\n\tFarmsWithdrewPrincipalEventOnChainV1,\n} from \"./farmsApiCastingTypes\";\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport { Coin } from \"../..\";\nimport {\n\tMoveErrors,\n\tMoveErrorsInterface,\n} from \"../../../general/types/moveErrorsInterface\";\n\nexport class FarmsApi implements MoveErrorsInterface {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tvaultV1: \"afterburner_vault\",\n\t\t\tvaultV2: \"vault\",\n\t\t\tstakedPosition: \"staked_position\",\n\t\t\tvaultRegistry: \"vault_registry\",\n\t\t\tevents: \"events\",\n\t\t\tauthority: \"authority\",\n\t\t},\n\t\teventNames: {\n\t\t\t// staking pools\n\t\t\t// creation\n\t\t\tcreatedVault: \"CreatedVaultEvent\",\n\t\t\t// mutation\n\t\t\tinitializedReward: \"InitializedRewardEvent\",\n\t\t\taddedReward: \"AddedRewardEvent\",\n\t\t\tincreasedEmissions: \"IncreasedEmissionsEvent\",\n\t\t\tupdatedEmissions: \"UpdatedEmissionsEvent\",\n\n\t\t\t// staking positions\n\t\t\t// creation\n\t\t\tstaked: \"StakedEvent\",\n\t\t\tstakedRelaxed: \"StakedEventRelaxed\",\n\t\t\t// locking\n\t\t\tlocked: \"LockedEvent\",\n\t\t\tunlocked: \"UnlockedEvent\",\n\t\t\t// mutation\n\t\t\tjoined: \"JoinedEvent\",\n\t\t\tsplit: \"SplitEvent\",\n\t\t\t// staking\n\t\t\tdepositedPrincipal: \"DepositedPrincipalEvent\",\n\t\t\twithdrewPrincipal: \"WithdrewPrincipalEvent\",\n\t\t\t// reward harvesting\n\t\t\tharvestedRewards: \"HarvestedRewardsEvent\",\n\t\t\t// destruction\n\t\t\tdestroyedStakedPosition: \"DestroyedStakedPositionEvent\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: FarmsAddresses;\n\tpublic readonly objectTypes: {\n\t\tstakedPositionV1: AnyObjectType;\n\t\tstakingPoolOwnerCapV1: AnyObjectType;\n\t\tstakingPoolOneTimeAdminCapV1: AnyObjectType;\n\t\tstakedPositionV2: AnyObjectType;\n\t\tstakingPoolOwnerCapV2: AnyObjectType;\n\t\tstakingPoolOneTimeAdminCapV2: AnyObjectType;\n\t};\n\tpublic readonly eventTypes: {\n\t\t// v1\n\t\t// staking pools\n\t\t// creation\n\t\tcreatedVaultV1: AnyObjectType;\n\t\t// mutation\n\t\tinitializedRewardV1: AnyObjectType;\n\t\taddedRewardV1: AnyObjectType;\n\t\tincreasedEmissionsV1: AnyObjectType;\n\n\t\t// staking positions\n\t\t// creation\n\t\tstakedV1: AnyObjectType;\n\t\tstakedRelaxedV1: AnyObjectType;\n\t\t// locking\n\t\tlockedV1: AnyObjectType;\n\t\tunlockedV1: AnyObjectType;\n\t\t// staking\n\t\tdepositedPrincipalV1: AnyObjectType;\n\t\twithdrewPrincipalV1: AnyObjectType;\n\t\t// reward harvesting\n\t\tharvestedRewardsV1: AnyObjectType;\n\n\t\t// v2\n\t\t// staking pools\n\t\t// creation\n\t\tcreatedVaultV2: AnyObjectType;\n\t\t// mutation\n\t\tinitializedRewardV2: AnyObjectType;\n\t\taddedRewardV2: AnyObjectType;\n\t\tupdatedEmissionsV2: AnyObjectType;\n\n\t\t// staking positions\n\t\t// creation\n\t\tstakedV2: AnyObjectType;\n\t\t// locking\n\t\tlockedV2: AnyObjectType;\n\t\tunlockedV2: AnyObjectType;\n\t\t// staking\n\t\tdepositedPrincipalV2: AnyObjectType;\n\t\twithdrewPrincipalV2: AnyObjectType;\n\t\t// reward harvesting\n\t\tharvestedRewardsV2: AnyObjectType;\n\t};\n\tpublic readonly moveErrors: MoveErrors;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Constructor for FarmsApi\n\t * @param Provider The AftermathApi provider instance\n\t * @throws Error if not all required addresses have been set in provider\n\t */\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.farms;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\t\tthis.objectTypes = {\n\t\t\tstakedPositionV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,\n\t\t\tstakingPoolOwnerCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OwnerCap`,\n\t\t\tstakingPoolOneTimeAdminCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OneTimeAdminCap`,\n\t\t\tstakedPositionV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,\n\t\t\tstakingPoolOwnerCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::AuthorityCap<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::VAULT<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::ADMIN>>`,\n\t\t\t// NOTE: will this work with `<phantom Role, phantom Reward>` ?\n\t\t\tstakingPoolOneTimeAdminCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.vaultV2}::OneTime`,\n\t\t};\n\t\tthis.eventTypes = {\n\t\t\t// v1\n\t\t\t// staking pools\n\t\t\t// creation\n\t\t\tcreatedVaultV1: this.createdVaultEventType(1),\n\t\t\t// mutation\n\t\t\tinitializedRewardV1: this.initializedRewardEventType(1),\n\t\t\taddedRewardV1: this.addedRewardEventType(1),\n\t\t\tincreasedEmissionsV1: this.increasedEmissionsEventType(),\n\n\t\t\t// staking positions\n\t\t\t// creation\n\t\t\tstakedV1: this.stakedEventType(1),\n\t\t\tstakedRelaxedV1: this.stakedRelaxedEventType(1),\n\t\t\t// locking\n\t\t\tlockedV1: this.lockedEventType(1),\n\t\t\tunlockedV1: this.unlockedEventType(1),\n\t\t\t// staking\n\t\t\tdepositedPrincipalV1: this.depositedPrincipalEventType(1),\n\t\t\twithdrewPrincipalV1: this.withdrewPrincipalEventType(1),\n\t\t\t// reward harvesting\n\t\t\tharvestedRewardsV1: this.harvestedRewardsEventType(1),\n\n\t\t\t// v2\n\t\t\t// staking pools\n\t\t\t// creation\n\t\t\tcreatedVaultV2: this.createdVaultEventType(2),\n\t\t\t// mutation\n\t\t\tinitializedRewardV2: this.initializedRewardEventType(2),\n\t\t\taddedRewardV2: this.addedRewardEventType(2),\n\t\t\tupdatedEmissionsV2: this.updatedEmissionsEventType(),\n\n\t\t\t// staking positions\n\t\t\t// creation\n\t\t\tstakedV2: this.stakedEventType(2),\n\t\t\t// locking\n\t\t\tlockedV2: this.lockedEventType(2),\n\t\t\tunlockedV2: this.unlockedEventType(2),\n\t\t\t// staking\n\t\t\tdepositedPrincipalV2: this.depositedPrincipalEventType(2),\n\t\t\twithdrewPrincipalV2: this.withdrewPrincipalEventType(2),\n\t\t\t// reward harvesting\n\t\t\tharvestedRewardsV2: this.harvestedRewardsEventType(2),\n\t\t};\n\t\tthis.moveErrors = {\n\t\t\t[this.addresses.packages.vaults]: {\n\t\t\t\t[FarmsApi.constants.moduleNames.vaultV1]: {\n\t\t\t\t\t/// A user attempts provides a `Coin` or `u64` with value zero.\n\t\t\t\t\t0: \"Zero\",\n\t\t\t\t\t/// A user provides a `StakedPosition` and a `AfterburnerVault` that don't correspond with one\n\t\t\t\t\t/// another. This can only occur if two `AfterburnerVault` with the same underlying `STAKED` generic\n\t\t\t\t\t/// are created.\n\t\t\t\t\t1: \"Invalid Afterburner Vault\",\n\t\t\t\t\t/// A user tries to create an `AfterburnerVault` where `min_lock_duration_ms` is strictly greater than\n\t\t\t\t\t/// `max_lock_duration_ms`.\n\t\t\t\t\t2: \"Invalid Min Max Lock Durations\",\n\t\t\t\t\t/// The creator of a `AfterburnerVault` tries to update the vault's emission rate or add more rewards\n\t\t\t\t\t/// without first initializing the emissions schedule.\n\t\t\t\t\t3: \"Emissions Not Initialized\",\n\t\t\t\t\t/// The creator of a `AfterburnerVault` tries to update the vault's emission schedule/rate but\n\t\t\t\t\t/// provides a schedule/rate pair that will decrease emissions for the specified reward type.\n\t\t\t\t\t4: \"Emissions Not Increasing\",\n\t\t\t\t\t5: \"Bad Type\",\n\t\t\t\t\t/// A user attempts to stake into a `AfterburnerVault` below the vault's `min_stake_amount` or\n\t\t\t\t\t/// an amount of principal that would bring their position below the vault's `min_stake_amount`.\n\t\t\t\t\t6: \"Invalid Stake Amount\",\n\t\t\t\t\t/// A user attempts to create an `AfterburnerVault` and provides a `lock_enforcement` that doesn't\n\t\t\t\t\t/// match one of `STRICT_LOCK_ENFORCEMENT` or `RELAXED_LOCK_ENFORCEMENT`.\n\t\t\t\t\t7: \"Invalid Lock Enforcement\",\n\t\t\t\t\t/// A user tries to claim zero rewards\n\t\t\t\t\t8: \"Zero Claim\",\n\t\t\t\t\t/// A user provided invalid max lock multiplier (< 1)\n\t\t\t\t\t9: \"Invalid Lock Multiplier\",\n\t\t\t\t\t10: \"Invalid Argument\",\n\t\t\t\t\t11: \"Deprecated\",\n\t\t\t\t\t12: \"Afterburner Vault Still Active\",\n\t\t\t\t},\n\t\t\t\t[FarmsApi.constants.moduleNames.stakedPosition]: {\n\t\t\t\t\t/// A user attempts provides a `Coin` or `u64` with value zero.\n\t\t\t\t\t0: \"Zero\",\n\t\t\t\t\t/// A user attempts to withdraw funds from a `StakedPosition` that is still locked.\n\t\t\t\t\t1: \"Locked\",\n\t\t\t\t\t/// A user provides a `StakedPosition` and a `AfterburnerVault` that don't correspond with one another.\n\t\t\t\t\t/// This can only occur if two `AfterburnerVault` with the same underlying `STAKED` generic are created.\n\t\t\t\t\t2: \"Invalid Afterburner Vault\",\n\t\t\t\t\t/// A user tries to lock the coins in a `AfterburnerVault` with a `lock_duration_ms` below the vault's\n\t\t\t\t\t/// `min_lock_duration_ms`.\n\t\t\t\t\t3: \"Invalid Lock Duration\",\n\t\t\t\t\t/// A user attempts to destroy a `StakedPosition` that still holds rewards that can be harvested.\n\t\t\t\t\t4: \"Harvest Rewards\",\n\t\t\t\t\t/// A user attempts to stake into a `AfterburnerVault` below the vault's `min_stake_amount` or\n\t\t\t\t\t/// an amount of principal that would bring their position below the vault's `min_stake_amount`.\n\t\t\t\t\t5: \"Invalid Stake Amount\",\n\t\t\t\t\t6: \"Invalid Withdraw Amount\",\n\t\t\t\t\t7: \"Invalid Split Amount\",\n\t\t\t\t\t8: \"Uninitialized Vault Rewards\",\n\t\t\t\t\t9: \"Not Implemented\",\n\t\t\t\t\t/// A user requested to harvest zero base rewards.\n\t\t\t\t\t10: \"Zero Rewards\",\n\t\t\t\t},\n\t\t\t},\n\t\t\t[this.addresses.packages.vaultsV2]: {\n\t\t\t\t[FarmsApi.constants.moduleNames.vaultV2]: {\n\t\t\t\t\t/// A user provides a `Coin` with value zero.\n\t\t\t\t\t0: \"Zero\",\n\t\t\t\t\t/// A user tries to create a `Vault` where `min_lock_duration_ms` is strictly greater than\n\t\t\t\t\t/// `max_lock_duration_ms`.\n\t\t\t\t\t1: \"Invalid Min Max Lock Durations\",\n\t\t\t\t\t/// A user tries to create a `Vault` and provides a `u8` that does not map to a valid lock\n\t\t\t\t\t/// enforcement policy.\n\t\t\t\t\t2: \"Invalid Lock Enforcement\",\n\t\t\t\t\t/// The creator of a `Vault` tries to update the emission schedule or add more of a specific\n\t\t\t\t\t/// reward type that has not yet been initialized into the `Vault`.\n\t\t\t\t\t3: \"Emissions Not Initialized\",\n\t\t\t\t\t/// A `Reward` `Coin` type was passed to a function and either the `Reward` type does not\n\t\t\t\t\t/// correspond to any of the `Vault`'s reward types--for the functions that act on the `Reward`\n\t\t\t\t\t/// type--or, for `initialize_reward`, the `Reward` type has already had its emissions initialized.\n\t\t\t\t\t4: \"Invalid Reward Coin Type\",\n\t\t\t\t\t/// A user attempts to withdraw an amount of principal that would bring their position below the\n\t\t\t\t\t/// `Vault`'s `min_stake_amount`.\n\t\t\t\t\t5: \"Invalid Stake Amount\",\n\t\t\t\t\t/// A user tries to claim zero rewards\n\t\t\t\t\t6: \"Zero Claim\",\n\t\t\t\t\t/// A user provided a max lock multiplier that was strictly less than the minimum lower bound.\n\t\t\t\t\t7: \"Invalid Lock Multiplier\",\n\t\t\t\t},\n\t\t\t\t[FarmsApi.constants.moduleNames.stakedPosition]: {\n\t\t\t\t\t/// A user attempts to perform a restricted action on a `StakedPosition` that is still locked. For\n\t\t\t\t\t/// example `unlock` can only be called on a `StakedPosition` that is no longer locked.\n\t\t\t\t\t0: \"Locked\",\n\t\t\t\t\t/// A user provides a `StakedPosition` and a `Vault` that don't correspond with one another.\n\t\t\t\t\t/// This can only occur if two `Vault`s with the same underlying `Stake` generic are created.\n\t\t\t\t\t1: \"Invalid Vault\",\n\t\t\t\t\t/// A user tries to stake into a `Vault` with a `lock_duration_ms` below the vault's\n\t\t\t\t\t/// `min_lock_duration_ms`.\n\t\t\t\t\t2: \"Invalid Lock Duration\",\n\t\t\t\t\t/// A user attempts to withdraw an amount of principal that would bring their position below the\n\t\t\t\t\t/// `Vault`'s `min_stake_amount`.\n\t\t\t\t\t3: \"Invalid Stake Amount\",\n\t\t\t\t\t/// A user attempts to withdraw more principal than their `StakedPosition` holds.\n\t\t\t\t\t4: \"Invalid Withdraw Amount\",\n\t\t\t\t\t/// A user attempts to split more principal than their `StakedPosition` holds.\n\t\t\t\t\t5: \"Invalid Split Amount\",\n\t\t\t\t\t/// A user attempts to stake into a `Vault` that has no rewards.\n\t\t\t\t\t6: \"Vault Is Inactive\",\n\t\t\t\t\t/// A user requested to harvest a reward type for which they've only accrued less than the minimal\n\t\t\t\t\t/// claim amount.\n\t\t\t\t\t7: \"Zero Rewards\",\n\t\t\t\t\t/// A user attempts to stake into a `Vault` with a `LockEnforcement` policy that the vault does\n\t\t\t\t\t/// not support.\n\t\t\t\t\t8: \"Invalid Lock Enforcement\",\n\t\t\t\t\t/// A user attempts to call `destroy` on a `StakedPosition` that has unharvested rewards.\n\t\t\t\t\t9: \"Position Has Unclaimed Rewards\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Pool Objects\n\t// =========================================================================\n\n\t/**\n\t * @deprecated Use the new API method in Farms class instead.\n\t * Fetches the owner caps for staking pools owned by a specific wallet address\n\t * @param inputs Object containing wallet address\n\t * @returns Array of StakingPoolOwnerCapObject\n\t */\n\tpublic fetchOwnedStakingPoolOwnerCaps = async (\n\t\tinputs: ApiFarmsOwnedStakingPoolOwnerCapsBody\n\t): Promise<StakingPoolOwnerCapObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst [capsV1, capsV2] = await Promise.all([\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakingPoolOwnerCapV1,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.stakingPoolOwnerCapObjectFromSuiObjectResponseV1,\n\t\t\t}),\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakingPoolOwnerCapV2,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.stakingPoolOwnerCapObjectFromSuiObjectResponseV2,\n\t\t\t}),\n\t\t]);\n\t\treturn [...capsV1, ...capsV2];\n\t};\n\n\t/**\n\t * @deprecated Use the new API method in Farms class instead.\n\t * Fetches the one-time admin caps for staking pools owned by a specific wallet address\n\t * @param inputs Object containing wallet address\n\t * @returns Array of StakingPoolOneTimeAdminCapObject\n\t */\n\tpublic fetchOwnedStakingPoolOneTimeAdminCaps = async (\n\t\tinputs: ApiFarmsOwnedStakingPoolOwnerCapsBody\n\t): Promise<StakingPoolOneTimeAdminCapObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst [capsV1, capsV2] = await Promise.all([\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakingPoolOneTimeAdminCapV1,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV1,\n\t\t\t}),\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakingPoolOneTimeAdminCapV2,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV2,\n\t\t\t}),\n\t\t]);\n\t\treturn [...capsV1, ...capsV2];\n\t};\n\n\t// =========================================================================\n\t// Staked Position Objects\n\t// =========================================================================\n\n\t/**\n\t * @deprecated Use `getOwnedStakedPositions` method in Farms class instead.\n\t * Fetches partial staked positions owned by a specific wallet address\n\t * @param inputs Object containing wallet address\n\t * @returns Array of PartialFarmsStakedPositionObject\n\t */\n\tpublic fetchOwnedPartialStakedPositions = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<PartialFarmsStakedPositionObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst [positionsV1, positionsV2] = await Promise.all([\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakedPositionV1,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.partialStakedPositionObjectFromSuiObjectResponseV1,\n\t\t\t}),\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakedPositionV2,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.farms\n\t\t\t\t\t\t.partialStakedPositionObjectFromSuiObjectResponseV2,\n\t\t\t}),\n\t\t]);\n\t\treturn [...positionsV1, ...positionsV2];\n\t};\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use stakeTxV2 instead\n\t * Creates a transaction to stake coins in a staking pool (original version)\n\t * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, and coin type\n\t * @returns Transaction object argument for StakedPosition\n\t */\n\tpublic stakeTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinId: ObjectId | TransactionArgument;\n\t\tlockDurationMs: Timestamp;\n\t\tstakeCoinType: CoinType;\n\t}) /* (StakedPosition) */ => {\n\t\tconst { tx, stakeCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"stake\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof stakeCoinId === \"string\"\n\t\t\t\t\t? tx.object(stakeCoinId)\n\t\t\t\t\t: stakeCoinId, // Coin\n\t\t\t\ttx.pure.u64(inputs.lockDurationMs),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to stake coins in a staking pool\n\t * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, lock enforcement, and coin type\n\t * @returns Transaction object argument for StakedPosition\n\t */\n\tpublic stakeTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinId: ObjectId | TransactionArgument;\n\t\tlockDurationMs: Timestamp;\n\t\tlockEnforcement: FarmsLockEnforcement;\n\t\tstakeCoinType: CoinType;\n\t}) /* (StakedPosition) */ => {\n\t\tconst { tx, stakeCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"stake\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof stakeCoinId === \"string\"\n\t\t\t\t\t? tx.object(stakeCoinId)\n\t\t\t\t\t: stakeCoinId, // Coin\n\t\t\t\ttx.pure.u8(inputs.lockEnforcement === \"Strict\" ? 0 : 1), // lock_enforcement\n\t\t\t\ttx.pure.u64(inputs.lockDurationMs), // lock_duration_ms\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use depositPrincipalTxV2 instead\n\t * Creates a transaction to deposit additional principal to a staked position (original version)\n\t * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type\n\t * @returns Transaction command to deposit principal\n\t */\n\tpublic depositPrincipalTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinId: ObjectId | TransactionArgument;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, stakeCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"deposit_principal\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof stakeCoinId === \"string\"\n\t\t\t\t\t? tx.object(stakeCoinId)\n\t\t\t\t\t: stakeCoinId, // Coin\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to deposit additional principal to a staked position\n\t * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type\n\t * @returns Transaction command to deposit principal\n\t */\n\tpublic depositPrincipalTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinId: ObjectId | TransactionArgument;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, stakeCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"deposit_principal\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof stakeCoinId === \"string\"\n\t\t\t\t\t? tx.object(stakeCoinId)\n\t\t\t\t\t: stakeCoinId, // Coin\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use withdrawPrincipalTxV2 instead\n\t * Creates a transaction to withdraw principal from a staked position (original version)\n\t * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type\n\t * @returns Transaction object argument for the withdrawn Coin\n\t */\n\tpublic withdrawPrincipalTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\twithdrawAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t}) /* (Coin) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"withdraw_principal\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.withdrawAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to withdraw principal from a staked position\n\t * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type\n\t * @returns Transaction object argument for the withdrawn Coin\n\t */\n\tpublic withdrawPrincipalTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\twithdrawAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t}) /* (Coin) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"withdraw_principal\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.withdrawAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use destroyStakedPositionTxV2 instead\n\t * Creates a transaction to destroy a staked position (original version)\n\t * @param inputs Destroy parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to destroy the position\n\t */\n\tpublic destroyStakedPositionTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"destroy\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to destroy a staked position\n\t * @param inputs Destroy parameters including transaction, position ID, and coin type\n\t * @returns Transaction command to destroy the position\n\t */\n\tpublic destroyStakedPositionTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"destroy\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use updatePositionTxV2 instead\n\t * Creates a transaction to update a staked position, recalculating rewards (original version)\n\t * @param inputs Update parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to update the position\n\t */\n\tpublic updatePositionTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"update_position\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to update a staked position, recalculating rewards\n\t * @param inputs Update parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to update the position\n\t */\n\tpublic updatePositionTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"update_position\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Locking Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use lockTxV2 instead\n\t * Creates a transaction to lock a staked position for a specific duration (original version)\n\t * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type\n\t * @returns Transaction command to lock the position\n\t */\n\tpublic lockTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tlockDurationMs: Timestamp;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"lock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.lockDurationMs),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to lock a staked position for a specific duration\n\t * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type\n\t * @returns Transaction command to lock the position\n\t */\n\tpublic lockTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tlockDurationMs: Timestamp;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"lock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.lockDurationMs),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use renewLockTxV2 instead\n\t * Creates a transaction to renew the lock on a staked position (original version)\n\t * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to renew the lock\n\t */\n\tpublic renewLockTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"renew_lock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to renew the lock on a staked position\n\t * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to renew the lock\n\t */\n\tpublic renewLockTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"renew_lock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use unlockTxV2 instead\n\t * Creates a transaction to unlock a staked position (original version)\n\t * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to unlock the position\n\t */\n\tpublic unlockTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"unlock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to unlock a staked position\n\t * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction command to unlock the position\n\t */\n\tpublic unlockTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"unlock\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Reward Harvesting Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use beginHarvestTxV2 instead\n\t * Creates a transaction to begin the reward harvesting process (original version)\n\t * @param inputs Begin harvest parameters including transaction, pool ID, and coin type\n\t * @returns Transaction object argument for the harvest metadata\n\t */\n\tpublic beginHarvestTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) /* (HarvestedRewardsEventMetadata) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"begin_harvest\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to begin the reward harvesting process\n\t * @param inputs Begin harvest parameters including transaction, position ID, pool ID, and coin type\n\t * @returns Transaction object argument for the harvest cap\n\t */\n\tpublic beginHarvestTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) /* (HarvestRewardsCap) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"begin_harvest_tx\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use harvestRewardsTxV2 instead\n\t * Creates a transaction to harvest rewards from a staked position (original version)\n\t * @param inputs Harvest parameters including transaction, position ID, pool ID, harvest metadata, stake coin type, and reward coin type\n\t * @returns Transaction object argument for the harvested rewards\n\t */\n\tpublic harvestRewardsTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tharvestedRewardsEventMetadataId: ObjectId | TransactionArgument;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) /* (Coin) */ => {\n\t\tconst { tx, harvestedRewardsEventMetadataId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"harvest_rewards\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttypeof harvestedRewardsEventMetadataId === \"string\"\n\t\t\t\t\t? tx.object(harvestedRewardsEventMetadataId)\n\t\t\t\t\t: harvestedRewardsEventMetadataId, // HarvestedRewardsEventMetadata\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to harvest rewards from a staked position\n\t * @param inputs Harvest parameters including transaction, harvest cap, position ID, pool ID, stake coin type, and reward coin type\n\t * @returns Transaction object argument for the harvested rewards\n\t */\n\tpublic harvestRewardsTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tharvestRewardsCap: ObjectId | TransactionArgument;\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) /* (Coin) */ => {\n\t\tconst { tx, harvestRewardsCap } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"harvest_rewards\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof harvestRewardsCap === \"string\"\n\t\t\t\t\t? tx.object(harvestRewardsCap)\n\t\t\t\t\t: harvestRewardsCap, // HarvestRewardsCap\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use endHarvestTxV2 instead\n\t * Creates a transaction to end the reward harvesting process (original version)\n\t * @param inputs End harvest parameters including transaction and harvest metadata\n\t * @returns Transaction command to end the harvest\n\t */\n\tpublic endHarvestTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tharvestedRewardsEventMetadataId: ObjectId | TransactionArgument;\n\t}) => {\n\t\tconst { tx, harvestedRewardsEventMetadataId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"end_harvest\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttypeof harvestedRewardsEventMetadataId === \"string\"\n\t\t\t\t\t? tx.object(harvestedRewardsEventMetadataId)\n\t\t\t\t\t: harvestedRewardsEventMetadataId, // HarvestedRewardsEventMetadata\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to end the reward harvesting process\n\t * @param inputs End harvest parameters including transaction and harvest cap\n\t * @returns Transaction command to end the harvest\n\t */\n\tpublic endHarvestTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tharvestRewardsCap: ObjectId | TransactionArgument;\n\t}) => {\n\t\tconst { tx, harvestRewardsCap } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.stakedPosition,\n\t\t\t\t\"end_harvest_tx\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttypeof harvestRewardsCap === \"string\"\n\t\t\t\t\t? tx.object(harvestRewardsCap)\n\t\t\t\t\t: harvestRewardsCap, // HarvestRewardsCap\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Staking Pool Creation Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use newStakingPoolTxV2 instead\n\t * Creates a transaction for the deprecated version of staking pool creation\n\t * @param inputs Pool creation parameters including transaction, lock enforcement, durations, multiplier, stake amount, and coin type\n\t * @returns Transaction objects for the vault and owner cap\n\t */\n\tpublic newStakingPoolTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tlockEnforcement: FarmsLockEnforcement;\n\t\tminLockDurationMs: Timestamp;\n\t\tmaxLockDurationMs: Timestamp;\n\t\tmaxLockMultiplier: FarmsMultiplier;\n\t\tminStakeAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t}) /* (AfterburnerVault, OwnerCap) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"new\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.pure.u64(inputs.lockEnforcement === \"Strict\" ? 0 : 1),\n\t\t\t\ttx.pure.u64(inputs.minLockDurationMs),\n\t\t\t\ttx.pure.u64(inputs.maxLockDurationMs),\n\t\t\t\ttx.pure.u64(inputs.maxLockMultiplier),\n\t\t\t\ttx.pure.u64(inputs.minStakeAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction for the current version of staking pool creation\n\t * @param inputs Pool creation parameters including transaction, lock enforcements array, durations, multiplier, stake amount, and coin type\n\t * @returns Transaction objects for the vault and authority cap\n\t */\n\tpublic newStakingPoolTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tlockEnforcements: FarmsLockEnforcement[];\n\t\tminLockDurationMs: Timestamp;\n\t\tmaxLockDurationMs: Timestamp;\n\t\tmaxLockMultiplier: FarmsMultiplier;\n\t\tminStakeAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t}) /* (AfterburnerVault, AuthorityCap) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"new\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.version),\n\t\t\t\ttx.pure.vector(\n\t\t\t\t\t\"u8\",\n\t\t\t\t\tinputs.lockEnforcements.map((lockEnforcement) =>\n\t\t\t\t\t\tlockEnforcement === \"Strict\" ? 0 : 1\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\ttx.pure.u64(inputs.minLockDurationMs),\n\t\t\t\ttx.pure.u64(inputs.maxLockDurationMs),\n\t\t\t\ttx.pure.u64(inputs.maxLockMultiplier),\n\t\t\t\ttx.pure.u64(inputs.minStakeAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use shareStakingPoolTxV2 instead\n\t * Creates a transaction to share a staking pool, making it public\n\t * @param inputs Share pool parameters including transaction, pool ID, and coin type\n\t * @returns Transaction command to share the pool\n\t */\n\tpublic shareStakingPoolTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId | TransactionArgument;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, stakingPoolId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"share_vault\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof stakingPoolId === \"string\"\n\t\t\t\t\t? tx.object(stakingPoolId)\n\t\t\t\t\t: stakingPoolId, // AfterburnerVault\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to share a staking pool, making it public\n\t * @param inputs Share pool parameters including transaction, pool ID, and coin type\n\t * @returns Transaction command to share the pool\n\t */\n\tpublic shareStakingPoolTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId | TransactionArgument;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, stakingPoolId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"share\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof stakingPoolId === \"string\"\n\t\t\t\t\t? tx.object(stakingPoolId)\n\t\t\t\t\t: stakingPoolId, // AfterburnerVault\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use transferOwnerCapTxV2 instead\n\t * Creates a transaction to transfer ownership of a staking pool\n\t * @param inputs Transfer parameters including transaction, owner cap ID, and recipient address\n\t * @returns Transaction command to transfer the owner cap\n\t */\n\tpublic transferOwnerCapTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId | TransactionArgument;\n\t\trecipientAddress: SuiAddress;\n\t}) => {\n\t\tconst { tx, ownerCapId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"transfer_owner_cap\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttypeof ownerCapId === \"string\"\n\t\t\t\t\t? tx.object(ownerCapId)\n\t\t\t\t\t: ownerCapId, // OwnerCap\n\t\t\t\ttx.pure.address(inputs.recipientAddress),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use grantOneTimeAdminCapTxV2 instead\n\t * Creates a transaction to grant a one-time admin capability for a staking pool (original version)\n\t * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type\n\t * @returns Transaction command to grant the one-time admin cap\n\t */\n\tpublic grantOneTimeAdminCapTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId | TransactionArgument;\n\t\trecipientAddress: SuiAddress;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, ownerCapId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"grant_one_time_admin_cap\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof ownerCapId === \"string\"\n\t\t\t\t\t? tx.object(ownerCapId)\n\t\t\t\t\t: ownerCapId, // OwnerCap\n\t\t\t\ttx.pure.address(inputs.recipientAddress),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to grant a one-time admin capability for a staking pool\n\t * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type\n\t * @returns Transaction command to grant the one-time admin cap\n\t */\n\tpublic grantOneTimeAdminCapTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId | TransactionArgument;\n\t\trecipientAddress: SuiAddress;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, ownerCapId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"grant_one_time_admin_cap\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof ownerCapId === \"string\"\n\t\t\t\t\t? tx.object(ownerCapId)\n\t\t\t\t\t: ownerCapId, // OwnerCap\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.pure.address(inputs.recipientAddress),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Staking Pool Mutation Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use initializeStakingPoolRewardTxV2 instead\n\t * Creates a transaction to initialize rewards for a staking pool (original version)\n\t * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type\n\t * @returns Transaction command to initialize the reward\n\t */\n\tpublic initializeStakingPoolRewardTxV1 = (\n\t\tinputs: {\n\t\t\ttx: Transaction;\n\t\t\tstakingPoolId: ObjectId;\n\t\t\trewardCoinId: ObjectId | TransactionArgument;\n\t\t\temissionScheduleMs: Timestamp;\n\t\t\temissionRate: bigint;\n\t\t\temissionDelayTimestampMs: Timestamp;\n\t\t\tstakeCoinType: CoinType;\n\t\t\trewardCoinType: CoinType;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) => {\n\t\tconst { tx, rewardCoinId } = inputs;\n\t\tconst isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);\n\t\tconst capId = FarmsApi.farmCapId(inputs);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\tisOneTimeAdminCap\n\t\t\t\t\t? \"initialize_reward_and_consume_admin_cap\"\n\t\t\t\t\t: \"initialize_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(capId), // OwnerCap / OneTimeAdminCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof rewardCoinId === \"string\"\n\t\t\t\t\t? tx.object(rewardCoinId)\n\t\t\t\t\t: rewardCoinId, // Coin\n\t\t\t\ttx.pure.u64(inputs.emissionScheduleMs),\n\t\t\t\ttx.pure.u64(inputs.emissionRate),\n\t\t\t\ttx.pure.u64(inputs.emissionDelayTimestampMs),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to initialize rewards for a staking pool\n\t * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type\n\t * @returns Transaction command to initialize the reward\n\t */\n\tpublic initializeStakingPoolRewardTxV2 = (\n\t\tinputs: {\n\t\t\ttx: Transaction;\n\t\t\tstakingPoolId: ObjectId;\n\t\t\trewardCoinId: ObjectId | TransactionArgument;\n\t\t\temissionScheduleMs: Timestamp;\n\t\t\temissionRate: bigint;\n\t\t\temissionDelayTimestampMs: Timestamp;\n\t\t\tstakeCoinType: CoinType;\n\t\t\trewardCoinType: CoinType;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) => {\n\t\tconst { tx, rewardCoinId } = inputs;\n\t\tconst isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);\n\t\tconst capId = FarmsApi.farmCapId(inputs);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\tisOneTimeAdminCap\n\t\t\t\t\t? \"initialize_reward_and_consume_admin_cap\"\n\t\t\t\t\t: \"initialize_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(capId), // OwnerCap / OneTimeAdminCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof rewardCoinId === \"string\"\n\t\t\t\t\t? tx.object(rewardCoinId)\n\t\t\t\t\t: rewardCoinId, // Coin\n\t\t\t\ttx.pure.u64(inputs.emissionScheduleMs),\n\t\t\t\ttx.pure.u64(inputs.emissionRate),\n\t\t\t\ttx.pure.u64(inputs.emissionDelayTimestampMs),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use topUpStakingPoolRewardTxV2 instead\n\t * Creates a transaction to add more rewards to a staking pool (original version)\n\t * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type\n\t * @returns Transaction command to add rewards\n\t */\n\tpublic topUpStakingPoolRewardTxV1 = (\n\t\tinputs: {\n\t\t\ttx: Transaction;\n\t\t\tstakingPoolId: ObjectId;\n\t\t\trewardCoinId: ObjectId | TransactionArgument;\n\t\t\tstakeCoinType: CoinType;\n\t\t\trewardCoinType: CoinType;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) => {\n\t\tconst { tx, rewardCoinId } = inputs;\n\t\tconst isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);\n\t\tconst capId = FarmsApi.farmCapId(inputs);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\tisOneTimeAdminCap\n\t\t\t\t\t? \"add_reward_and_consume_admin_cap\"\n\t\t\t\t\t: \"add_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(capId), // OwnerCap / OneTimeAdminCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttypeof rewardCoinId === \"string\"\n\t\t\t\t\t? tx.object(rewardCoinId)\n\t\t\t\t\t: rewardCoinId, // Coin\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to add more rewards to a staking pool\n\t * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type\n\t * @returns Transaction command to add rewards\n\t */\n\tpublic topUpStakingPoolRewardTxV2 = (\n\t\tinputs: {\n\t\t\ttx: Transaction;\n\t\t\tstakingPoolId: ObjectId;\n\t\t\trewardCoinId: ObjectId | TransactionArgument;\n\t\t\tstakeCoinType: CoinType;\n\t\t\trewardCoinType: CoinType;\n\t\t} & FarmOwnerOrOneTimeAdminCap\n\t) => {\n\t\tconst { tx, rewardCoinId } = inputs;\n\t\tconst isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);\n\t\tconst capId = FarmsApi.farmCapId(inputs);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\tisOneTimeAdminCap\n\t\t\t\t\t? \"add_reward_and_consume_admin_cap\"\n\t\t\t\t\t: \"add_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(capId), // OwnerCap / OneTimeAdminCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttypeof rewardCoinId === \"string\"\n\t\t\t\t\t? tx.object(rewardCoinId)\n\t\t\t\t\t: rewardCoinId, // Coin\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use increaseStakingPoolRewardEmissionsTxV2 instead\n\t * Creates a transaction to increase the emission rate for a staking pool reward (original version)\n\t * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type\n\t * @returns Transaction command to update emissions\n\t */\n\tpublic increaseStakingPoolRewardEmissionsTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\temissionScheduleMs: Timestamp;\n\t\temissionRate: bigint;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"update_emissions_for\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.emissionScheduleMs),\n\t\t\t\ttx.pure.u64(inputs.emissionRate),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to increase the emission rate for a staking pool reward\n\t * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type\n\t * @returns Transaction command to update emissions\n\t */\n\tpublic increaseStakingPoolRewardEmissionsTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\temissionScheduleMs: Timestamp;\n\t\temissionRate: bigint;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"update_emission_schedule\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttx.pure.u64(inputs.emissionScheduleMs),\n\t\t\t\ttx.pure.u64(inputs.emissionRate),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @deprecated use setStakingPoolMinStakeAmountTxV2 instead\n\t * Creates a transaction to set the minimum stake amount for a staking pool (original version)\n\t * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type\n\t * @returns Transaction command to set the minimum stake amount\n\t */\n\tpublic setStakingPoolMinStakeAmountTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tminStakeAmount: bigint;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"set_min_stake_amount\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.pure.u64(inputs.minStakeAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to set the minimum stake amount for a staking pool\n\t * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type\n\t * @returns Transaction command to set the minimum stake amount\n\t */\n\tpublic setStakingPoolMinStakeAmountTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tminStakeAmount: bigint;\n\t\tstakeCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"set_min_stake_amount\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.pure.u64(inputs.minStakeAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a Move call (V1) to **remove undistributed reward coins** from a staking pool.\n\t * Only callable by the pool **owner** (validated via `ownerCapId`). This does not claw back\n\t * rewards already accrued/claimed by stakers—only reduces the remaining reward balance\n\t * for the specified `rewardCoinType`.\n\t *\n\t * @param inputs Transaction assembly parameters\n\t * @param inputs.tx Transaction instance to append the command to\n\t * @param inputs.ownerCapId OwnerCap object ID authorizing the removal\n\t * @param inputs.stakingPoolId The staking pool (vault) object ID\n\t * @param inputs.rewardAmount Amount to remove (base units, encoded as u64)\n\t * @param inputs.stakeCoinType Stake coin type argument for the vault module\n\t * @param inputs.rewardCoinType Reward coin type to be removed\n\t * @returns The transaction command added to `tx`\n\t */\n\tpublic removeStakingPoolRewardTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\trewardAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"remove_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.pure.u64(inputs.rewardAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a Move call (V2) to **remove undistributed reward coins** from a staking pool.\n\t * Only callable by the pool **owner** (validated via `ownerCapId`). Includes the protocol\n\t * `version` object as required by V2 modules.\n\t *\n\t * @param inputs Transaction assembly parameters\n\t * @param inputs.tx Transaction instance to append the command to\n\t * @param inputs.ownerCapId OwnerCap object ID authorizing the removal\n\t * @param inputs.stakingPoolId The staking pool (vault) object ID\n\t * @param inputs.rewardAmount Amount to remove (base units, encoded as u64)\n\t * @param inputs.stakeCoinType Stake coin type argument for the vault module\n\t * @param inputs.rewardCoinType Reward coin type to be removed\n\t * @returns The transaction command added to `tx`\n\t */\n\tpublic removeStakingPoolRewardTxV2 = (inputs: {\n\t\ttx: Transaction;\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\trewardAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t\trewardCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaultsV2,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV2,\n\t\t\t\t\"remove_reward\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.ownerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t\ttx.object(this.addresses.objects.version), // Version\n\t\t\t\ttx.pure.u64(inputs.rewardAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Staking Pool Inspection Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * Creates a transaction to check if a staking pool is unlocked\n\t * @param inputs Check parameters including transaction, pool ID, and coin type\n\t * @returns Transaction object argument for the boolean result\n\t */\n\tpublic isVaultUnlockedTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) /* (bool) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"is_vault_unlocked\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction to get the remaining rewards for a staking pool\n\t * @param inputs Remaining rewards parameters including transaction, pool ID, and coin type\n\t * @returns Transaction object argument for the vector of remaining rewards\n\t */\n\tpublic remainingRewardsTxV1 = (inputs: {\n\t\ttx: Transaction;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t}) /* (vector<u64>) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.vaults,\n\t\t\t\tFarmsApi.constants.moduleNames.vaultV1,\n\t\t\t\t\"remaining_rewards\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.stakeCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.stakingPoolId), // AfterburnerVault\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transactions\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use fetchBuildStakeTxV2 instead\n\t * Builds a complete transaction for staking coins\n\t * @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildStakeTxV1 = async (inputs: ApiFarmsStakeBodyV1) => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst stakeCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.stakeCoinType,\n\t\t\tcoinAmount: inputs.stakeAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tconst stakedPosition = this.stakeTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tstakeCoinId,\n\t\t});\n\t\ttx.transferObjects([stakedPosition], walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for staking coins\n\t * @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildStakeTxV2 = async (inputs: ApiFarmsStakeBody) => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst stakeCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.stakeCoinType,\n\t\t\tcoinAmount: inputs.stakeAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tconst stakedPosition = this.stakeTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tstakeCoinId,\n\t\t\tlockEnforcement: \"Strict\",\n\t\t});\n\t\ttx.transferObjects([stakedPosition], walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use fetchBuildDepositPrincipalTxV2 instead\n\t * Builds a complete transaction for depositing additional principal to a staked position\n\t * @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildDepositPrincipalTxV1 = async (\n\t\tinputs: ApiFarmsDepositPrincipalBody\n\t) => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst stakeCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.stakeCoinType,\n\t\t\tcoinAmount: inputs.depositAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tthis.depositPrincipalTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tstakeCoinId,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for depositing additional principal to a staked position\n\t * @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildDepositPrincipalTxV2 = async (\n\t\tinputs: ApiFarmsDepositPrincipalBody\n\t) => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst stakeCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.stakeCoinType,\n\t\t\tcoinAmount: inputs.depositAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tthis.depositPrincipalTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tstakeCoinId,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildWithdrawPrincipalTxV2 instead\n\t * Builds a complete transaction for withdrawing principal from a staked position\n\t * @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildWithdrawPrincipalTxV1 = (inputs: {\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\twithdrawAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst withdrawnCoin = this.withdrawPrincipalTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t});\n\t\ttx.transferObjects([withdrawnCoin], walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for withdrawing principal from a staked position\n\t * @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildWithdrawPrincipalTxV2 = (inputs: {\n\t\tstakedPositionId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\twithdrawAmount: Balance;\n\t\tstakeCoinType: CoinType;\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst withdrawnCoin = this.withdrawPrincipalTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t});\n\t\ttx.transferObjects([withdrawnCoin], walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildUnstakeTxV2 instead\n\t * Builds a complete transaction for unstaking (withdrawing and destroying a position)\n\t * @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUnstakeTxV1 = (inputs: ApiFarmsUnstakeBody) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tlet tx;\n\t\tif (inputs.rewardCoinTypes.length > 0) {\n\t\t\t// harvest rewards\n\t\t\ttx = this.buildHarvestRewardsTxV1({\n\t\t\t\t...inputs,\n\t\t\t\tstakedPositionIds: [inputs.stakedPositionId],\n\t\t\t});\n\t\t} else {\n\t\t\t// no rewards to harvest\n\t\t\ttx = new Transaction();\n\t\t\ttx.setSender(walletAddress);\n\t\t}\n\n\t\t// withdraw principal\n\t\tconst withdrawnCoin = this.withdrawPrincipalTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t});\n\t\ttx.transferObjects([withdrawnCoin], walletAddress);\n\n\t\t// destroy position\n\t\tthis.destroyStakedPositionTxV1({\n\t\t\ttx,\n\t\t\tstakingPoolId: inputs.stakingPoolId,\n\t\t\tstakedPositionId: inputs.stakedPositionId,\n\t\t\tstakeCoinType: inputs.stakeCoinType,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for unstaking (withdrawing and destroying a position)\n\t * @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUnstakeTxV2 = (inputs: ApiFarmsUnstakeBody) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tlet tx;\n\t\tif (inputs.rewardCoinTypes.length > 0) {\n\t\t\t// harvest rewards\n\t\t\ttx = this.buildHarvestRewardsTxV2({\n\t\t\t\t...inputs,\n\t\t\t\tstakedPositionIds: [inputs.stakedPositionId],\n\t\t\t});\n\t\t} else {\n\t\t\t// no rewards to harvest\n\t\t\ttx = new Transaction();\n\t\t\ttx.setSender(walletAddress);\n\t\t}\n\n\t\t// withdraw principal\n\t\tconst withdrawnCoin = this.withdrawPrincipalTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t});\n\t\ttx.transferObjects([withdrawnCoin], walletAddress);\n\n\t\t// destroy position\n\t\tthis.destroyStakedPositionTxV2({\n\t\t\ttx,\n\t\t\tstakedPositionId: inputs.stakedPositionId,\n\t\t\tstakeCoinType: inputs.stakeCoinType,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildUpdatePositionTxV2 instead\n\t * Builds a transaction for updating a staked position\n\t * @param parameters for updatePositionTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUpdatePositionTxV1 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.updatePositionTxV1\n\t);\n\n\t/**\n\t * Builds a transaction for updating a staked position\n\t * @param parameters for updatePositionTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUpdatePositionTx2 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.updatePositionTxV2\n\t);\n\n\t// =========================================================================\n\t// Locking Transactions\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use buildLockTxV2 instead\n\t * Builds a transaction for locking a staked position\n\t * @param parameters for lockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildLockTxV1 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.lockTxV1\n\t);\n\n\t/**\n\t * Builds a transaction for locking a staked position\n\t * @param parameters for lockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildLockTxV2 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.lockTxV2\n\t);\n\n\t/**\n\t * @deprecated use buildRenewLockTxV2 instead\n\t * Builds a transaction for renewing the lock on a staked position\n\t * @param parameters for renewLockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildRenewLockTxV1 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.renewLockTxV1\n\t);\n\n\t/**\n\t * Builds a transaction for renewing the lock on a staked position\n\t * @param parameters for renewLockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildRenewLockTxV2 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.renewLockTxV2\n\t);\n\n\t/**\n\t * @deprecated use buildUnlockTxV2 instead\n\t * Builds a transaction for unlocking a staked position\n\t * @param parameters for unlockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUnlockTxV1 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.unlockTxV1\n\t);\n\n\t/**\n\t * Builds a transaction for unlocking a staked position\n\t * @param parameters for unlockTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildUnlockTxV2 = Helpers.transactions.createBuildTxFunc(\n\t\tthis.unlockTxV2\n\t);\n\n\t// =========================================================================\n\t// Reward Harvesting Transactions\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use buildHarvestRewardsTxV2 instead\n\t * Builds a complete transaction for harvesting rewards from staked positions\n\t * @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildHarvestRewardsTxV1 = (\n\t\tinputs: ApiHarvestFarmsRewardsBody & {\n\t\t\ttx?: Transaction;\n\t\t}\n\t): Transaction => {\n\t\tconst { walletAddress, stakedPositionIds } = inputs;\n\n\t\tconst tx = inputs.tx ?? new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst harvestRewardsCap = this.beginHarvestTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t});\n\n\t\tlet harvestedCoins: Record<CoinType, TransactionObjectArgument[]> = {};\n\n\t\tfor (const stakedPositionId of stakedPositionIds) {\n\t\t\tfor (const rewardCoinType of inputs.rewardCoinTypes) {\n\t\t\t\tconst harvestedCoin = this.harvestRewardsTxV1({\n\t\t\t\t\t...inputs,\n\t\t\t\t\ttx,\n\t\t\t\t\tstakedPositionId,\n\t\t\t\t\trewardCoinType,\n\t\t\t\t\tharvestedRewardsEventMetadataId: harvestRewardsCap,\n\t\t\t\t});\n\n\t\t\t\tif (rewardCoinType in harvestedCoins) {\n\t\t\t\t\tharvestedCoins[rewardCoinType].push(harvestedCoin);\n\t\t\t\t} else {\n\t\t\t\t\tharvestedCoins[rewardCoinType] = [harvestedCoin];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.endHarvestTxV1({\n\t\t\ttx,\n\t\t\tharvestedRewardsEventMetadataId: harvestRewardsCap,\n\t\t});\n\n\t\tfor (const [coinType, harvestedCoinIds] of Object.entries(\n\t\t\tharvestedCoins\n\t\t)) {\n\t\t\tconst coinToTransfer = harvestedCoinIds[0];\n\n\t\t\tif (harvestedCoinIds.length > 1)\n\t\t\t\ttx.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));\n\n\t\t\tif (inputs.claimSuiAsAfSui && Coin.isCoinObjectType(coinType)) {\n\t\t\t\tthis.Provider.Staking().stakeTx({\n\t\t\t\t\ttx,\n\t\t\t\t\tsuiCoin: coinToTransfer,\n\t\t\t\t\twithTransfer: true,\n\t\t\t\t\tvalidatorAddress:\n\t\t\t\t\t\tthis.Provider.Staking().addresses.objects\n\t\t\t\t\t\t\t.aftermathValidator,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\ttx.transferObjects([coinToTransfer], walletAddress);\n\t\t\t}\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for harvesting rewards from staked positions\n\t * @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildHarvestRewardsTxV2 = (\n\t\tinputs: ApiHarvestFarmsRewardsBody & {\n\t\t\ttx?: Transaction;\n\t\t}\n\t): Transaction => {\n\t\tconst { walletAddress, stakedPositionIds } = inputs;\n\n\t\tconst tx = inputs.tx ?? new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\t// For the first position, begin harvest\n\t\tconst firstPositionId = stakedPositionIds[0];\n\t\tconst harvestRewardsCap = this.beginHarvestTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tstakedPositionId: firstPositionId,\n\t\t});\n\n\t\tlet harvestedCoins: Record<CoinType, TransactionObjectArgument[]> = {};\n\n\t\tfor (const stakedPositionId of stakedPositionIds) {\n\t\t\tfor (const rewardCoinType of inputs.rewardCoinTypes) {\n\t\t\t\tconst harvestedCoin = this.harvestRewardsTxV2({\n\t\t\t\t\t...inputs,\n\t\t\t\t\ttx,\n\t\t\t\t\tstakedPositionId,\n\t\t\t\t\tharvestRewardsCap,\n\t\t\t\t\trewardCoinType,\n\t\t\t\t});\n\n\t\t\t\tif (rewardCoinType in harvestedCoins) {\n\t\t\t\t\tharvestedCoins[rewardCoinType].push(harvestedCoin);\n\t\t\t\t} else {\n\t\t\t\t\tharvestedCoins[rewardCoinType] = [harvestedCoin];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.endHarvestTxV2({ tx, harvestRewardsCap });\n\n\t\tfor (const [coinType, harvestedCoinIds] of Object.entries(\n\t\t\tharvestedCoins\n\t\t)) {\n\t\t\tconst coinToTransfer = harvestedCoinIds[0];\n\n\t\t\tif (harvestedCoinIds.length > 1)\n\t\t\t\ttx.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));\n\n\t\t\tif (inputs.claimSuiAsAfSui && Coin.isCoinObjectType(coinType)) {\n\t\t\t\tthis.Provider.Staking().stakeTx({\n\t\t\t\t\ttx,\n\t\t\t\t\tsuiCoin: coinToTransfer,\n\t\t\t\t\twithTransfer: true,\n\t\t\t\t\tvalidatorAddress:\n\t\t\t\t\t\tthis.Provider.Staking().addresses.objects\n\t\t\t\t\t\t\t.aftermathValidator,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\ttx.transferObjects([coinToTransfer], walletAddress);\n\t\t\t}\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Staking Pool Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Pool Creation Transactions\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use buildCreateStakingPoolTxV2 instead\n\t * Builds a complete transaction for creating a new staking pool\n\t * @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildCreateStakingPoolTxV1 = (\n\t\tinputs: ApiFarmsCreateStakingPoolBodyV1\n\t): Transaction => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tlockEnforcement: \"Strict\",\n\t\t});\n\t\tthis.shareStakingPoolTxV1({\n\t\t\ttx,\n\t\t\tstakingPoolId,\n\t\t\tstakeCoinType: inputs.stakeCoinType,\n\t\t});\n\t\tthis.transferOwnerCapTxV1({\n\t\t\ttx,\n\t\t\townerCapId,\n\t\t\trecipientAddress: walletAddress,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for creating a new staking pool\n\t * @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildCreateStakingPoolTxV2 = (\n\t\tinputs: ApiFarmsCreateStakingPoolBody\n\t): Transaction => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tlockEnforcements: [\"Strict\"],\n\t\t});\n\t\tthis.shareStakingPoolTxV2({\n\t\t\ttx,\n\t\t\tstakingPoolId,\n\t\t\tstakeCoinType: inputs.stakeCoinType,\n\t\t});\n\t\ttx.transferObjects([ownerCapId], walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Staking Pool Mutation Transactions\n\t// =========================================================================\n\n\t/**\n\t * @deprecated use fetchBuildInitializeStakingPoolRewardTxV2 instead\n\t * Builds a complete transaction for initializing rewards for a staking pool\n\t * @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildInitializeStakingPoolRewardTxV1 = async (\n\t\tinputs: ApiFarmsInitializeStakingPoolRewardBody\n\t): Promise<Transaction> => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst rewardCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.rewardCoinType,\n\t\t\tcoinAmount: inputs.rewardAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tthis.initializeStakingPoolRewardTxV1({ ...inputs, tx, rewardCoinId });\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for initializing rewards for a staking pool\n\t * @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildInitializeStakingPoolRewardTxV2 = async (\n\t\tinputs: ApiFarmsInitializeStakingPoolRewardBody\n\t): Promise<Transaction> => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst rewardCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: inputs.rewardCoinType,\n\t\t\tcoinAmount: inputs.rewardAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tthis.initializeStakingPoolRewardTxV2({ ...inputs, tx, rewardCoinId });\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use fetchBuildTopUpStakingPoolRewardsTxV2 instead\n\t * Builds a complete transaction for adding more rewards to a staking pool\n\t * @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildTopUpStakingPoolRewardsTxV1 = async (\n\t\tinputs: ApiFarmsTopUpStakingPoolRewardsBody\n\t): Promise<Transaction> => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tconst rewardCoinId =\n\t\t\t\tawait this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\t\t\ttx,\n\t\t\t\t\twalletAddress,\n\t\t\t\t\tcoinType: reward.rewardCoinType,\n\t\t\t\t\tcoinAmount: reward.rewardAmount,\n\t\t\t\t\tisSponsoredTx,\n\t\t\t\t});\n\n\t\t\tthis.topUpStakingPoolRewardTxV1({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t\trewardCoinId,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for adding more rewards to a staking pool\n\t * @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic fetchBuildTopUpStakingPoolRewardsTxV2 = async (\n\t\tinputs: ApiFarmsTopUpStakingPoolRewardsBody\n\t): Promise<Transaction> => {\n\t\tconst { walletAddress, isSponsoredTx } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tconst rewardCoinId =\n\t\t\t\tawait this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\t\t\ttx,\n\t\t\t\t\twalletAddress,\n\t\t\t\t\tcoinType: reward.rewardCoinType,\n\t\t\t\t\tcoinAmount: reward.rewardAmount,\n\t\t\t\t\tisSponsoredTx,\n\t\t\t\t});\n\n\t\t\tthis.topUpStakingPoolRewardTxV2({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t\trewardCoinId,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildIncreaseStakingPoolRewardsEmissionsTxV2 instead\n\t * Builds a complete transaction for increasing the emission rate of rewards for a staking pool\n\t * @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildIncreaseStakingPoolRewardsEmissionsTxV1 = (\n\t\tinputs: ApiFarmsIncreaseStakingPoolRewardsEmissionsBody\n\t) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tthis.increaseStakingPoolRewardEmissionsTxV1({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a complete transaction for increasing the emission rate of rewards for a staking pool\n\t * @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildIncreaseStakingPoolRewardsEmissionsTxV2 = (\n\t\tinputs: ApiFarmsIncreaseStakingPoolRewardsEmissionsBody\n\t) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tthis.increaseStakingPoolRewardEmissionsTxV2({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildSetStakingPoolMinStakeAmountTxV2 instead\n\t * Builds a transaction for setting the minimum stake amount for a staking pool\n\t * @param parameters for setStakingPoolMinStakeAmountTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildSetStakingPoolMinStakeAmountTxV1 =\n\t\tHelpers.transactions.createBuildTxFunc(\n\t\t\tthis.setStakingPoolMinStakeAmountTxV1\n\t\t);\n\n\t/**\n\t * Builds a transaction for setting the minimum stake amount for a staking pool\n\t * @param parameters for setStakingPoolMinStakeAmountTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildSetStakingPoolMinStakeAmountTxV2 =\n\t\tHelpers.transactions.createBuildTxFunc(\n\t\t\tthis.setStakingPoolMinStakeAmountTxV2\n\t\t);\n\n\t/**\n\t * Builds a transaction for **removing undistributed reward coins** from a staking pool (V1).\n\t * Requires the pool **OwnerCap**. The removal is specific to a `rewardCoinType`.\n\t *\n\t * @param parameters Inputs accepted by `removeStakingPoolRewardTxV1`\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildRemoveStakingPoolRewardTxV1 = (inputs: {\n\t\trewards: {\n\t\t\trewardCoinType: CoinType;\n\t\t\trewardAmount: Balance;\n\t\t}[];\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tthis.removeStakingPoolRewardTxV1({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a transaction for **removing undistributed reward coins** from a staking pool (V2).\n\t * Requires the pool **OwnerCap** and includes the on-chain **version object**.\n\t *\n\t * @param parameters Inputs accepted by `removeStakingPoolRewardTxV2`\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildRemoveStakingPoolRewardTxV2 = (inputs: {\n\t\trewards: {\n\t\t\trewardCoinType: CoinType;\n\t\t\trewardAmount: Balance;\n\t\t}[];\n\t\townerCapId: ObjectId;\n\t\tstakingPoolId: ObjectId;\n\t\tstakeCoinType: CoinType;\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tfor (const reward of inputs.rewards) {\n\t\t\tthis.removeStakingPoolRewardTxV2({\n\t\t\t\t...inputs,\n\t\t\t\t...reward,\n\t\t\t\ttx,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * @deprecated use buildGrantOneTimeAdminCapTxV2 instead\n\t * Builds a transaction for granting a one-time admin capability for a staking pool\n\t * @param parameters for grantOneTimeAdminCapTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildGrantOneTimeAdminCapTxV1 =\n\t\tHelpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV1);\n\n\t/**\n\t * Builds a transaction for granting a one-time admin capability for a staking pool\n\t * @param parameters for grantOneTimeAdminCapTx\n\t * @returns Complete transaction ready for signing and execution\n\t */\n\tpublic buildGrantOneTimeAdminCapTxV2 =\n\t\tHelpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV2);\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Vault Creation\n\t// =========================================================================\n\n\tprivate eventWrapperType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\t\"Event\"\n\t\t);\n\n\t/**\n\t * Creates the event type for vault creation events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate createdVaultEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.createdVault,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Vault Mutation\n\t// =========================================================================\n\n\t/**\n\t * Creates the event type for reward initialization events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate initializedRewardEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.initializedReward,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t/**\n\t * Creates the event type for reward addition events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate addedRewardEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.addedReward,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t/**\n\t * Creates the event type for emission increase events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate increasedEmissionsEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.vaultsInitial,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.increasedEmissions\n\t\t);\n\n\t/**\n\t * Creates the event type for emission update events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate updatedEmissionsEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.increasedEmissions,\n\t\t\tthis.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Staking Position Creation\n\t// =========================================================================\n\n\t/**\n\t * Creates the event type for strict staking events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate stakedEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.staked,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t/**\n\t * Creates the event type for relaxed staking events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate stakedRelaxedEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.stakedRelaxed,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Staking Position Locking\n\t// =========================================================================\n\n\t/**\n\t * Creates the event type for position locking events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate lockedEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.locked,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t/**\n\t * Creates the event type for position unlocking events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate unlockedEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.unlocked,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Staking Position Staking\n\t// =========================================================================\n\n\t/**\n\t * Creates the event type for principal deposit events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate depositedPrincipalEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.depositedPrincipal,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t/**\n\t * Creates the event type for principal withdrawal events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate withdrewPrincipalEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.withdrewPrincipal,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Staking Position Reward Harvesting\n\t// =========================================================================\n\n\t/**\n\t * Creates the event type for reward harvesting events\n\t * @returns Fully qualified event type string\n\t */\n\tprivate harvestedRewardsEventType = (version: FarmsVersion) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tversion === 1\n\t\t\t\t? this.addresses.packages.vaultsInitial\n\t\t\t\t: this.addresses.packages.eventsV2,\n\t\t\tFarmsApi.constants.moduleNames.events,\n\t\t\tFarmsApi.constants.eventNames.harvestedRewards,\n\t\t\tversion === 1 ? undefined : this.eventWrapperType()\n\t\t);\n\n\t// =========================================================================\n\t// Private Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t/**\n\t * Checks if the input contains a one-time admin cap ID\n\t * @param inputs FarmOwnerOrOneTimeAdminCap object\n\t * @returns True if the input contains a one-time admin cap ID\n\t */\n\tprivate static isFarmOneTimeAdminCapId = (\n\t\tinputs: FarmOwnerOrOneTimeAdminCap\n\t) => \"oneTimeAdminCapId\" in inputs;\n\n\t/**\n\t * Gets the appropriate cap ID from the input\n\t * @param inputs FarmOwnerOrOneTimeAdminCap object\n\t * @returns Either the owner cap ID or one-time admin cap ID\n\t */\n\tprivate static farmCapId = (inputs: FarmOwnerOrOneTimeAdminCap) =>\n\t\t\"ownerCapId\" in inputs ? inputs.ownerCapId : inputs.oneTimeAdminCapId;\n}\n","import { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport { Faucet } from \"../faucet\";\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n} from \"@mysten/sui/transactions\";\nimport { FaucetApiCasting } from \"./faucetApiCasting\";\nimport { CoinDecimal, CoinType } from \"../../coin/coinTypes\";\nimport {\n\tFaucetAddCoinEventOnChain,\n\tFaucetMintCoinEventOnChain,\n} from \"./faucetApiCastingTypes\";\nimport {\n\tApiFaucetMintSuiFrenBody,\n\tFaucetAddCoinEvent,\n\tFaucetMintCoinEvent,\n} from \"../faucetTypes\";\nimport {\n\tAnyObjectType,\n\tBalance,\n\tEventsInputs,\n\tFaucetAddresses,\n\tSerializedTransaction,\n\tObjectId,\n\tSuiAddress,\n} from \"../../../types\";\nimport { Coin } from \"../../coin\";\nimport { TransactionsApiHelpers } from \"../../../general/apiHelpers/transactionsApiHelpers\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { Sui } from \"../../sui\";\nimport { Helpers } from \"../../../general/utils\";\n\nexport class FaucetApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tfaucet: \"faucet\",\n\t\t\tsuiFrensGenesisWrapper: \"genesis_wrapper\",\n\t\t},\n\t\teventNames: {\n\t\t\tmintCoin: \"MintedCoin\",\n\t\t\taddCoin: \"AddedCoinEvent\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: FaucetAddresses;\n\n\tpublic readonly eventTypes: {\n\t\tmintCoin: AnyObjectType;\n\t\taddCoin: AnyObjectType;\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.faucet;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\n\t\tthis.eventTypes = {\n\t\t\tmintCoin: this.mintCoinEventType(),\n\t\t\taddCoin: this.addCoinEventType(),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic fetchSupportedCoins = async (): Promise<CoinType[]> => {\n\t\tconst addCoinEvents = await this.fetchAddCoinEvents({});\n\t\tconst coins = addCoinEvents.events.map(\n\t\t\t(event) => \"0x\" + event.coinType\n\t\t);\n\t\treturn coins;\n\t};\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t// public addCoinTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \ttreasuryCapId: ObjectId;\n\t// \ttreasuryCapType: AnyObjectType;\n\t// }) => {\n\t// \tconst { tx, treasuryCapId, treasuryCapType } = inputs;\n\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: TransactionsApiHelpers.createTxTarget(\n\t// \t\t\tthis.addresses.packages.faucet,\n\t// \t\t\tFaucetApi.constants.moduleNames.faucet,\n\t// \t\t\t\"add_coin\"\n\t// \t\t),\n\t// \t\ttypeArguments: [treasuryCapType],\n\t// \t\targuments: [\n\t// \t\t\ttx.object(this.addresses.objects.faucet),\n\t// \t\t\ttx.object(treasuryCapId),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\tpublic requestCoinTx = (inputs: {\n\t\ttx: Transaction;\n\t\tcoinType: CoinType;\n\t}) => {\n\t\tconst { tx, coinType } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: TransactionsApiHelpers.createTxTarget(\n\t\t\t\tthis.addresses.packages.faucet,\n\t\t\t\tFaucetApi.constants.moduleNames.faucet,\n\t\t\t\t\"request_default_amount\"\n\t\t\t),\n\t\t\ttypeArguments: [coinType],\n\t\t\targuments: [tx.object(this.addresses.objects.faucet)],\n\t\t});\n\t};\n\n\tpublic mintSuiFrenTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiPaymentCoinId: ObjectId | TransactionArgument;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx, suiPaymentCoinId, suiFrenType } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: TransactionsApiHelpers.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensGenesisWrapper,\n\t\t\t\tFaucetApi.constants.moduleNames.suiFrensGenesisWrapper,\n\t\t\t\t\"mint_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.suiFrensMint), // Mint\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t\ttypeof suiPaymentCoinId === \"string\"\n\t\t\t\t\t? tx.object(suiPaymentCoinId)\n\t\t\t\t\t: suiPaymentCoinId, // Coin\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\tpublic buildRequestCoinTx = Helpers.transactions.createBuildTxFunc(\n\t\tthis.requestCoinTx\n\t);\n\n\tpublic fetchBuildMintSuiFrenTx = async (\n\t\tinputs: ApiFaucetMintSuiFrenBody\n\t) => {\n\t\tconst { walletAddress, mintFee, suiFrenType } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst suiPaymentCoinId =\n\t\t\tawait this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\t\ttx,\n\t\t\t\twalletAddress,\n\t\t\t\tcoinType: Coin.constants.suiCoinType,\n\t\t\t\tcoinAmount: mintFee,\n\t\t\t});\n\n\t\tthis.mintSuiFrenTx({ tx, suiPaymentCoinId, suiFrenType });\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t// TODO: add to indexer\n\tpublic fetchMintCoinEvents = async (inputs: EventsInputs) =>\n\t\tawait this.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tFaucetMintCoinEventOnChain,\n\t\t\tFaucetMintCoinEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.mintCoin,\n\t\t\t},\n\t\t\teventFromEventOnChain:\n\t\t\t\tFaucetApiCasting.faucetMintCoinEventFromOnChain,\n\t\t});\n\n\t// TODO: add to indexer\n\tpublic fetchAddCoinEvents = async (inputs: EventsInputs) =>\n\t\tawait this.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tFaucetAddCoinEventOnChain,\n\t\t\tFaucetAddCoinEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.addCoin,\n\t\t\t},\n\t\t\teventFromEventOnChain:\n\t\t\t\tFaucetApiCasting.faucetAddCoinEventFromOnChain,\n\t\t});\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate mintCoinEventType = () => {\n\t\treturn EventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.faucet,\n\t\t\tFaucetApi.constants.moduleNames.faucet,\n\t\t\tFaucetApi.constants.eventNames.mintCoin\n\t\t);\n\t};\n\n\tprivate addCoinEventType = () => {\n\t\treturn EventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.faucet,\n\t\t\tFaucetApi.constants.moduleNames.faucet,\n\t\t\tFaucetApi.constants.eventNames.addCoin\n\t\t);\n\t};\n}\n","import { AftermathApi } from \"../../../general/providers\";\nimport { AnyObjectType, LimitAddresses } from \"../../../types\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\n\nexport class LimitOrdersApi {\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: LimitAddresses;\n\tpublic readonly eventTypes: {\n\t\tcreatedOrder: AnyObjectType;\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.limitOrders;\n\t\tif (!addresses) {\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\t\t}\n\n\t\tthis.addresses = addresses;\n\t\tthis.eventTypes = {\n\t\t\tcreatedOrder: this.createdOrderEventType(),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tprivate createdOrderEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\t\"events\",\n\t\t\t\"CreatedOrderEventV1\"\n\t\t);\n}\n","import { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport { SharedCustodyAddresses } from \"../../../types\";\nimport { Ed25519PublicKey } from \"@mysten/sui/keypairs/ed25519\";\nimport { MultiSigPublicKey } from \"@mysten/sui/multisig\";\nimport { ApiMultisigUserBody, MultisigData } from \"../multisigTypes\";\n\nexport class MultisigApi {\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly sharedCustodyAddresses: SharedCustodyAddresses;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst sharedCustodyAddresses = this.Provider.addresses.sharedCustody;\n\t\tif (!sharedCustodyAddresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.sharedCustodyAddresses = sharedCustodyAddresses;\n\t}\n\n\t// =========================================================================\n\t// Fetch\n\t// =========================================================================\n\n\tpublic getMultisigForUser(inputs: ApiMultisigUserBody): MultisigData {\n\t\tconst afPublicKeyBuffer = Buffer.from(\n\t\t\tthis.sharedCustodyAddresses.publicKey || \"\",\n\t\t\t\"base64\"\n\t\t);\n\t\t// MARK: Shifting the first byte\n\t\tconst afPublicKeyArray = new Uint8Array(afPublicKeyBuffer).subarray(1);\n\t\tconst afPK = new Ed25519PublicKey(afPublicKeyArray);\n\t\tconst userPK = new Ed25519PublicKey(inputs.userPublicKey);\n\n\t\tconst newMultiSigPublicKey = MultiSigPublicKey.fromPublicKeys({\n\t\t\tthreshold: 1,\n\t\t\tpublicKeys: [\n\t\t\t\t{ publicKey: afPK, weight: 1 },\n\t\t\t\t{ publicKey: userPK, weight: 1 },\n\t\t\t],\n\t\t});\n\n\t\treturn {\n\t\t\tpublicKey: newMultiSigPublicKey,\n\t\t\taddress: newMultiSigPublicKey.toSuiAddress(),\n\t\t};\n\t}\n}\n","import { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tNftAmmInterfaceGenericTypes,\n\tNftAmmMarketObject,\n} from \"../nftAmmTypes\";\nimport { NftAmmApiCasting } from \"./nftAmmApiCasting\";\nimport { NftAmmMarket } from \"../nftAmmMarket\";\nimport {\n\tBalance,\n\tCoinType,\n\tDynamicFieldObjectsWithCursor,\n\tNft,\n\tNftAmmAddresses,\n\tObjectId,\n\tSlippage,\n\tSuiAddress,\n} from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport { Coin } from \"../../coin/coin\";\nimport { Pools } from \"../../pools/pools\";\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\n\nexport class NftAmmApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tinterface: \"interface\",\n\t\t\tactions: \"actions\",\n\t\t\tmarket: \"market\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: NftAmmAddresses;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.nftAmm;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic fetchNftsInMarketTable = async (inputs: {\n\t\tmarketTableObjectId: ObjectId;\n\t\tcursor?: ObjectId;\n\t\tlimit?: number;\n\t}): Promise<DynamicFieldObjectsWithCursor<Nft>> => {\n\t\treturn await this.Provider.DynamicFields().fetchCastDynamicFieldsOfTypeWithCursor(\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\tparentObjectId: inputs.marketTableObjectId,\n\t\t\t\tobjectsFromObjectIds: (objectIds) =>\n\t\t\t\t\tthis.Provider.Nfts().fetchNfts({ objectIds }),\n\t\t\t}\n\t\t);\n\t};\n\n\tpublic fetchMarket = async (inputs: {\n\t\tobjectId: ObjectId;\n\t}): Promise<NftAmmMarketObject> => {\n\t\treturn this.Provider.Objects().fetchCastObject({\n\t\t\t...inputs,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tNftAmmApiCasting.marketObjectFromSuiObject,\n\t\t});\n\t};\n\n\tpublic fetchMarkets = async (inputs: {\n\t\tobjectIds: ObjectId[];\n\t}): Promise<NftAmmMarketObject[]> => {\n\t\treturn this.Provider.Objects().fetchCastObjectBatch({\n\t\t\t...inputs,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tNftAmmApiCasting.marketObjectFromSuiObject,\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\tpublic fetchBuildBuyTx = async (inputs: {\n\t\tmarket: NftAmmMarket;\n\t\twalletAddress: SuiAddress;\n\t\tnftObjectIds: ObjectId[];\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst { market } = inputs;\n\t\tconst marketObject = market.market;\n\n\t\tconst expectedAssetCoinAmountIn = market.getBuyAssetCoinAmountIn({\n\t\t\tnftsCount: inputs.nftObjectIds.length,\n\t\t\treferral: inputs.referrer !== undefined,\n\t\t});\n\n\t\tconst assetCoin = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress: inputs.walletAddress,\n\t\t\tcoinType: marketObject.assetCoinType,\n\t\t\tcoinAmount: expectedAssetCoinAmountIn,\n\t\t});\n\n\t\tthis.buyTx({\n\t\t\ttx,\n\t\t\t...inputs,\n\t\t\tmarketObjectId: marketObject.objectId,\n\t\t\tgenericTypes: NftAmmApi.genericTypesForMarket({ market }),\n\t\t\tassetCoin,\n\t\t\texpectedAssetCoinAmountIn,\n\t\t\twithTransfer: true,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\tpublic fetchBuildSellTx = async (inputs: {\n\t\tmarket: NftAmmMarket;\n\t\twalletAddress: SuiAddress;\n\t\tnftObjectIds: ObjectId[];\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst { market } = inputs;\n\t\tconst marketObject = market.market;\n\n\t\tconst expectedAssetCoinAmountOut = market.getSellAssetCoinAmountOut({\n\t\t\tnftsCount: inputs.nftObjectIds.length,\n\t\t\treferral: inputs.referrer !== undefined,\n\t\t});\n\n\t\tthis.sellTx({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tnfts: inputs.nftObjectIds,\n\t\t\tmarketObjectId: marketObject.objectId,\n\t\t\tgenericTypes: NftAmmApi.genericTypesForMarket({ market }),\n\t\t\texpectedAssetCoinAmountOut,\n\t\t\twithTransfer: true,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\tpublic fetchBuildDepositTx = async (inputs: {\n\t\tmarket: NftAmmMarket;\n\t\twalletAddress: SuiAddress;\n\t\tassetCoinAmountIn: Balance;\n\t\tnfts: (ObjectId | TransactionArgument)[];\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst { market } = inputs;\n\t\tconst marketObject = market.market;\n\n\t\tconst { lpRatio } = market.getDepositLpCoinAmountOut({\n\t\t\tassetCoinAmountIn: inputs.assetCoinAmountIn,\n\t\t\treferral: inputs.referrer !== undefined,\n\t\t});\n\n\t\t// // TODO: move this somewhere else and into its own func\n\t\tconst expectedLpRatio = Casting.numberToFixedBigInt(lpRatio);\n\n\t\tconst assetCoin = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress: inputs.walletAddress,\n\t\t\tcoinType: marketObject.assetCoinType,\n\t\t\tcoinAmount: inputs.assetCoinAmountIn,\n\t\t});\n\n\t\tthis.depositTx({\n\t\t\ttx,\n\t\t\t...inputs,\n\t\t\tmarketObjectId: marketObject.objectId,\n\t\t\tgenericTypes: NftAmmApi.genericTypesForMarket({ market }),\n\t\t\texpectedLpRatio,\n\t\t\tassetCoin,\n\t\t\twithTransfer: true,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\tpublic fetchBuildWithdrawTx = async (inputs: {\n\t\tmarket: NftAmmMarket;\n\t\twalletAddress: SuiAddress;\n\t\tlpCoinAmount: Balance;\n\t\tnftObjectIds: ObjectId[];\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst { market } = inputs;\n\t\tconst marketObject = market.market;\n\n\t\tconst fractionalizedCoinAmountOut =\n\t\t\tmarket.getWithdrawFractionalizedCoinAmountOut({\n\t\t\t\tlpCoinAmount: inputs.lpCoinAmount,\n\t\t\t\treferral: inputs.referrer !== undefined,\n\t\t\t});\n\n\t\tconst { balances: coinAmountsOut } = Coin.coinsAndBalancesOverZero({\n\t\t\t[marketObject.fractionalizedCoinType]: fractionalizedCoinAmountOut,\n\t\t});\n\t\tconst expectedAssetCoinAmountOut = coinAmountsOut[0];\n\n\t\tconst lpCoin = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress: inputs.walletAddress,\n\t\t\tcoinType: marketObject.lpCoinType,\n\t\t\tcoinAmount: inputs.lpCoinAmount,\n\t\t});\n\n\t\tthis.addWithdrawCommandToTransaction({\n\t\t\ttx,\n\t\t\t...inputs,\n\t\t\tmarketObjectId: marketObject.objectId,\n\t\t\tgenericTypes: NftAmmApi.genericTypesForMarket({ market }),\n\t\t\texpectedAssetCoinAmountOut,\n\t\t\tlpCoin,\n\t\t\twithTransfer: true,\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\tpublic buyTx = (inputs: {\n\t\ttx: Transaction;\n\t\tmarketObjectId: ObjectId;\n\t\tassetCoin: ObjectId | TransactionArgument;\n\t\tnftObjectIds: ObjectId[];\n\t\texpectedAssetCoinAmountIn: Balance;\n\t\tgenericTypes: NftAmmInterfaceGenericTypes;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, assetCoin, genericTypes, nftObjectIds } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.nftAmm,\n\t\t\t\tinputs.withTransfer\n\t\t\t\t\t? NftAmmApi.constants.moduleNames.interface\n\t\t\t\t\t: NftAmmApi.constants.moduleNames.actions,\n\t\t\t\t\"buy\"\n\t\t\t),\n\t\t\ttypeArguments: genericTypes,\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.marketObjectId),\n\t\t\t\ttx.object(this.addresses.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.objects.treasury),\n\t\t\t\ttx.object(this.addresses.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttypeof assetCoin === \"string\"\n\t\t\t\t\t? tx.object(assetCoin)\n\t\t\t\t\t: assetCoin,\n\t\t\t\ttx.makeMoveVec({\n\t\t\t\t\telements: nftObjectIds.map((id) => tx.object(id)),\n\t\t\t\t\ttype: \"ID\",\n\t\t\t\t}),\n\t\t\t\ttx.pure.u64(inputs.expectedAssetCoinAmountIn.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(inputs.slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic sellTx = (inputs: {\n\t\ttx: Transaction;\n\t\tmarketObjectId: ObjectId;\n\t\tnfts: (ObjectId | TransactionArgument)[];\n\t\texpectedAssetCoinAmountOut: Balance;\n\t\tgenericTypes: NftAmmInterfaceGenericTypes;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, genericTypes, nfts } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.nftAmm,\n\t\t\t\tinputs.withTransfer\n\t\t\t\t\t? NftAmmApi.constants.moduleNames.interface\n\t\t\t\t\t: NftAmmApi.constants.moduleNames.actions,\n\t\t\t\t\"sell\"\n\t\t\t),\n\t\t\ttypeArguments: genericTypes,\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.marketObjectId),\n\t\t\t\ttx.object(this.addresses.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.objects.treasury),\n\t\t\t\ttx.object(this.addresses.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttx.makeMoveVec({\n\t\t\t\t\telements: Helpers.isArrayOfStrings(nfts)\n\t\t\t\t\t\t? nfts.map((nft) => tx.object(nft))\n\t\t\t\t\t\t: (nfts as TransactionObjectArgument[]),\n\t\t\t\t\ttype: genericTypes[3],\n\t\t\t\t}),\n\t\t\t\ttx.pure.u64(inputs.expectedAssetCoinAmountOut.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(inputs.slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic depositTx = (inputs: {\n\t\ttx: Transaction;\n\t\tmarketObjectId: ObjectId;\n\t\tassetCoin: ObjectId | TransactionArgument;\n\t\tnfts: (ObjectId | TransactionArgument)[];\n\t\texpectedLpRatio: bigint;\n\t\tgenericTypes: NftAmmInterfaceGenericTypes;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, assetCoin, genericTypes, nfts } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.nftAmm,\n\t\t\t\tinputs.withTransfer\n\t\t\t\t\t? NftAmmApi.constants.moduleNames.interface\n\t\t\t\t\t: NftAmmApi.constants.moduleNames.actions,\n\t\t\t\t\"deposit\"\n\t\t\t),\n\t\t\ttypeArguments: genericTypes,\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.marketObjectId),\n\t\t\t\ttx.object(this.addresses.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.objects.treasury),\n\t\t\t\ttx.object(this.addresses.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttypeof assetCoin === \"string\"\n\t\t\t\t\t? tx.object(assetCoin)\n\t\t\t\t\t: assetCoin,\n\t\t\t\ttx.makeMoveVec({\n\t\t\t\t\telements: Helpers.isArrayOfStrings(nfts)\n\t\t\t\t\t\t? nfts.map((nft) => tx.object(nft))\n\t\t\t\t\t\t: (nfts as TransactionObjectArgument[]),\n\t\t\t\t\ttype: genericTypes[3],\n\t\t\t\t}),\n\t\t\t\ttx.pure.u64(inputs.expectedLpRatio.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(inputs.slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic addWithdrawCommandToTransaction = (inputs: {\n\t\ttx: Transaction;\n\t\tmarketObjectId: ObjectId;\n\t\tlpCoin: ObjectId | TransactionArgument;\n\t\tnftObjectIds: ObjectId[];\n\t\texpectedAssetCoinAmountOut: Balance;\n\t\tgenericTypes: NftAmmInterfaceGenericTypes;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, lpCoin, genericTypes, nftObjectIds } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.nftAmm,\n\t\t\t\tinputs.withTransfer\n\t\t\t\t\t? NftAmmApi.constants.moduleNames.interface\n\t\t\t\t\t: NftAmmApi.constants.moduleNames.actions,\n\t\t\t\t\"withdraw\"\n\t\t\t),\n\t\t\ttypeArguments: genericTypes,\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.marketObjectId),\n\t\t\t\ttx.object(this.addresses.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.objects.treasury),\n\t\t\t\ttx.object(this.addresses.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttypeof lpCoin === \"string\" ? tx.object(lpCoin) : lpCoin,\n\t\t\t\ttx.makeMoveVec({\n\t\t\t\t\telements: nftObjectIds.map((id) => tx.object(id)),\n\t\t\t\t\ttype: \"ID\",\n\t\t\t\t}),\n\t\t\t\ttx.pure.u64(inputs.expectedAssetCoinAmountOut.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(inputs.slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tprivate static genericTypesForMarket = (inputs: {\n\t\tmarket: NftAmmMarket;\n\t}): [\n\t\tlpCoinType: CoinType,\n\t\tfractionalizedCoinType: CoinType,\n\t\tassetCoinType: CoinType,\n\t\tnftType: CoinType\n\t] => {\n\t\tconst marketObject = inputs.market.market;\n\t\treturn [\n\t\t\tmarketObject.lpCoinType,\n\t\t\tmarketObject.fractionalizedCoinType,\n\t\t\tmarketObject.assetCoinType,\n\t\t\tmarketObject.nftType,\n\t\t];\n\t};\n}\n","import {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tCoinType,\n\tPerpetualsAddresses,\n\tObjectId,\n\tSuiAddress,\n\tAnyObjectType,\n\tIFixed,\n\tBalance,\n\tObjectVersion,\n\tPackageId,\n} from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport { Sui } from \"../../sui\";\nimport {\n\tApiPerpetualsDepositCollateralBody,\n\tApiPerpetualsCreateAccountBody,\n\tPerpetualsMarketId,\n\tPerpetualsAccountId,\n\tPerpetualsOrderId,\n\tPerpetualsOrderSide,\n\tPerpetualsOrderType,\n} from \"../perpetualsTypes\";\nimport { PerpetualsApiCasting } from \"./perpetualsApiCasting\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { TransactionsApiHelpers } from \"../../../general/apiHelpers/transactionsApiHelpers\";\nimport {\n\tMoveErrors,\n\tMoveErrorsInterface,\n} from \"../../../general/types/moveErrorsInterface\";\n\nexport class PerpetualsApi implements MoveErrorsInterface {\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tinterface: \"interface\",\n\t\t\torderbook: \"orderbook\",\n\t\t\tevents: \"events\",\n\t\t\tclearingHouse: \"clearing_house\",\n\t\t\taccount: \"account\",\n\t\t},\n\t};\n\n\tpublic readonly addresses: PerpetualsAddresses;\n\n\tpublic readonly eventTypes: {\n\t\twithdrewCollateral: AnyObjectType;\n\t\tdepositedCollateral: AnyObjectType;\n\t\tsettledFunding: AnyObjectType;\n\t\tallocatedCollateral: AnyObjectType;\n\t\tdeallocatedCollateral: AnyObjectType;\n\t\tliquidated: AnyObjectType;\n\t\tcreatedAccount: AnyObjectType;\n\t\tcanceledOrder: AnyObjectType;\n\t\tpostedOrder: AnyObjectType;\n\t\tfilledMakerOrders: AnyObjectType;\n\t\tfilledMakerOrder: AnyObjectType;\n\t\tfilledTakerOrder: AnyObjectType;\n\t\tupdatedPremiumTwap: AnyObjectType;\n\t\tupdatedSpreadTwap: AnyObjectType;\n\t\tupdatedFunding: AnyObjectType;\n\t\tupdatedMarketVersion: AnyObjectType;\n\t\tcreatedStopOrderTicket: AnyObjectType;\n\t\tdeletedStopOrderTicket: AnyObjectType;\n\t\teditedStopOrderTicketExecutor: AnyObjectType;\n\t\taddedStopOrderTicketCollateral: AnyObjectType;\n\t\tremovedStopOrderTicketCollateral: AnyObjectType;\n\t\teditedStopOrderTicketDetails: AnyObjectType;\n\t\texecutedStopOrderTicket: AnyObjectType;\n\t\tfilledTakerOrderLiquidator: AnyObjectType;\n\t\tperformedLiquidation: AnyObjectType;\n\t\treducedOrder: AnyObjectType;\n\t\tperformedAdl: AnyObjectType;\n\t};\n\tpublic readonly moveErrors: MoveErrors;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.perpetuals;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\t\tthis.eventTypes = {\n\t\t\t// Collateral\n\t\t\twithdrewCollateral: this.eventType(\"WithdrewCollateral\"),\n\t\t\tdepositedCollateral: this.eventType(\"DepositedCollateral\"),\n\t\t\tsettledFunding: this.eventType(\"SettledFunding\"),\n\t\t\tallocatedCollateral: this.eventType(\"AllocatedCollateral\"),\n\t\t\tdeallocatedCollateral: this.eventType(\"DeallocatedCollateral\"),\n\t\t\t// Liquidation\n\t\t\tliquidated: this.eventType(\"LiquidatedPosition\"),\n\t\t\tfilledTakerOrderLiquidator: this.eventType(\n\t\t\t\t\"FilledTakerOrderLiquidator\"\n\t\t\t),\n\t\t\tperformedLiquidation: this.eventType(\"PerformedLiquidation\"),\n\t\t\t// Account\n\t\t\tcreatedAccount: this.eventType(\"CreatedAccount\"),\n\t\t\t// Order\n\t\t\tcanceledOrder: this.eventType(\"CanceledOrder\"),\n\t\t\tfilledMakerOrders: this.eventType(\"FilledMakerOrders\"),\n\t\t\tfilledMakerOrder: this.eventType(\"FilledMakerOrder\"),\n\t\t\tfilledTakerOrder: this.eventType(\"FilledTakerOrder\"),\n\t\t\treducedOrder: this.eventType(\"ReducedOrder\"),\n\t\t\tpostedOrder: this.eventType(\"PostedOrder\"),\n\t\t\t// Twap\n\t\t\tupdatedPremiumTwap: this.eventType(\"UpdatedPremiumTwap\"),\n\t\t\tupdatedSpreadTwap: this.eventType(\"UpdatedSpreadTwap\"),\n\t\t\t// Funding\n\t\t\tupdatedFunding: this.eventType(\"UpdatedFunding\"),\n\t\t\t// Version\n\t\t\tupdatedMarketVersion: this.eventType(\"UpdatedClearingHouseVersion\"),\n\t\t\t// Stop Order\n\t\t\tcreatedStopOrderTicket: this.eventType(\"CreatedStopOrderTicket\"),\n\t\t\tdeletedStopOrderTicket: this.eventType(\"DeletedStopOrderTicket\"),\n\t\t\teditedStopOrderTicketExecutor: this.eventType(\n\t\t\t\t\"EditedStopOrderTicketExecutor\"\n\t\t\t),\n\t\t\taddedStopOrderTicketCollateral: this.eventType(\n\t\t\t\t\"AddedStopOrderTicketCollateral\"\n\t\t\t),\n\t\t\tremovedStopOrderTicketCollateral: this.eventType(\n\t\t\t\t\"RemovedStopOrderTicketCollateral\"\n\t\t\t),\n\t\t\teditedStopOrderTicketDetails: this.eventType(\n\t\t\t\t\"EditedStopOrderTicketDetails\"\n\t\t\t),\n\t\t\texecutedStopOrderTicket: this.eventType(\"ExecutedStopOrderTicket\"),\n\t\t\t// ADL\n\t\t\tperformedAdl: this.eventType(\"PerformedADL\"),\n\t\t};\n\t\tthis.moveErrors = {\n\t\t\t// TODO: add support for this back in some way ?\n\t\t\t// [this.addresses.packages.perpetuals]: {\n\t\t\t// \t[\"ANY\"]: {\n\t\t\t// \t\t// ClearingHouse\n\t\t\t// \t\t/// Cannot deposit/withdraw zero coins to/from the account's collateral.\n\t\t\t// \t\t0: \"Deposit Or Withdraw Amount Zero\",\n\t\t\t// \t\t/// Orderbook size or price are invalid values\n\t\t\t// \t\t1: \"Invalid Size Or Price\",\n\t\t\t// \t\t/// Index price returned from oracle is 0 or invalid value\n\t\t\t// \t\t2: \"Bad Index Price\",\n\t\t\t// \t\t/// Order value in USD is too low\n\t\t\t// \t\t4: \"Order Usd Value Too Low\",\n\t\t\t// \t\t/// Passed a vector of invalid order ids to perform force cancellation during liquidation\n\t\t\t// \t\t5: \"Invalid Force Cancel Ids\",\n\t\t\t// \t\t/// Liquidate must be the first operation of the session, if performed.\n\t\t\t// \t\t6: \"Liquidate Not First Operation\",\n\t\t\t// \t\t/// Passed a vector of invalid order ids to cancel\n\t\t\t// \t\t7: \"Invalid Cancel Order Ids\",\n\t\t\t// \t\t/// Ticket has already passed `expire_timestamp` and can only be cancelled\n\t\t\t// \t\t8: \"Stop Order Ticket Expired\",\n\t\t\t// \t\t/// Index price is not at correct value to satisfy stop order conditions\n\t\t\t// \t\t9: \"Stop Order Conditions Violated\",\n\t\t\t// \t\t/// Index price is not at correct value to satisfy stop order conditions\n\t\t\t// \t\t10: \"Wrong Order Details\",\n\t\t\t// \t\t/// Invalid base price feed storage for the clearing house\n\t\t\t// \t\t11: \"Invalid Base Price Feed Storage\",\n\t\t\t// \t\t/// Same liquidator and liqee account ids\n\t\t\t// \t\t12: \"Self Liquidation\",\n\t\t\t// \t\t/// User trying to access the subaccount is not the one specified by parent\n\t\t\t// \t\t13: \"Invalid Sub Account User\",\n\t\t\t// \t\t/// The parent `Account` trying to delete the subaccount is not the correct one.\n\t\t\t// \t\t14: \"Wrong Parent For Sub Account\",\n\t\t\t// \t\t/// Raised when trying to delete a subaccount still containing collateral.\n\t\t\t// \t\t15: \"Sub Account Contains Collateral\",\n\t\t\t// \t\t/// Raised when trying to call a function with the wrong package's version\n\t\t\t// \t\t16: \"Wrong Version\",\n\t\t\t// \t\t/// Raised when trying to have a session composed by only `start_session` and `end_session`\n\t\t\t// \t\t17: \"Empty Session\",\n\t\t\t// \t\t/// Market already registered in the registry\n\t\t\t// \t\t18: \"Market Already Registered\",\n\t\t\t// \t\t/// Collateral is not registered in the registry\n\t\t\t// \t\t19: \"Collateral Is Not Registered\",\n\t\t\t// \t\t/// Market is not registered in the registry\n\t\t\t// \t\t20: \"Market Is Not Registered\",\n\t\t\t// \t\t/// Invalid collateral price feed storage for the clearing house\n\t\t\t// \t\t21: \"Invalid Collateral Price Feed Storage\",\n\t\t\t// \t\t/// Fees accrued are negative\n\t\t\t// \t\t22: \"Negative Fees Accrued\",\n\t\t\t// \t\t/// Reduce-only conditions are not respected for stop order execution\n\t\t\t// \t\t23: \"Not Reduce Only Stop Order\",\n\t\t\t// \t\t/// Stop order gas cost provided is not enough\n\t\t\t// \t\t24: \"Not Enough Gas For Stop Order\",\n\t\t\t// \t\t/// Stop order collateral to allocate provided is not enough\n\t\t\t// \t\t25: \"Not Enough Collateral To Allocate For Stop Order\",\n\t\t\t// \t\t/// Invalid account trying to perform an action on a StopOrderTicket\n\t\t\t// \t\t26: \"Invalid Account For Stop Order\",\n\t\t\t// \t\t/// Invalid executor trying to execute the StopOrderTicket\n\t\t\t// \t\t27: \"Invalid Executor For Stop Order\",\n\t\t\t// \t\t/// Raised when the market's max open interest is surpassed as a result of the session's actions\n\t\t\t// \t\t28: \"Max Open Interest Surpassed\",\n\t\t\t// \t\t/// Raised when a position would get a base amount higher than the allowed percentage of open interest\n\t\t\t// \t\t29: \"Max Open Interest Position Percent Surpassed\",\n\t\t\t// \t\t// Market\n\t\t\t// \t\t/// While creating ordered map with invalid parameters, or changing them improperly for an existent map.\n\t\t\t// \t\t1000: \"Invalid Market Parameters\",\n\t\t\t// \t\t/// Tried to call `update_funding` before enough time has passed since the last update.\n\t\t\t// \t\t1001: \"Updating Funding Too Early\",\n\t\t\t// \t\t/// Margin-ratio update proposal already exists for market\n\t\t\t// \t\t1002: \"Proposal Already Exists\",\n\t\t\t// \t\t/// Margin-ratio update proposal cannot be committed too early\n\t\t\t// \t\t1003: \"Premature Proposal\",\n\t\t\t// \t\t/// Margin-ratio update proposal delay is outside the valid range\n\t\t\t// \t\t1004: \"Invalid Proposal Delay\",\n\t\t\t// \t\t/// Margin-ratio update proposal does not exist for market\n\t\t\t// \t\t1005: \"Proposal Does Not Exist\",\n\t\t\t// \t\t/// Exchange has no available fees to withdraw\n\t\t\t// \t\t1006: \"No Fees Accrued\",\n\t\t\t// \t\t/// Tried to withdraw more insurance funds than the allowed amount\n\t\t\t// \t\t1007: \"Insufficient Insurance Surplus\",\n\t\t\t// \t\t/// Cannot create a market for which a price feed does not exist\n\t\t\t// \t\t1008: \"No Price Feed For Market\",\n\t\t\t// \t\t/// Cannot delete a proposal that already matured. It can only be committed.\n\t\t\t// \t\t1009: \"Proposal Already Matured\",\n\t\t\t// \t\t// Position\n\t\t\t// \t\t/// Tried placing a new pending order when the position already has the maximum allowed number of pending orders.\n\t\t\t// \t\t2000: \"Max Pending Orders Exceeded\",\n\t\t\t// \t\t/// Used for checking both liqee and liqor positions during liquidation\n\t\t\t// \t\t2001: \"Position Below IMR\",\n\t\t\t// \t\t///When leaving liqee's position with a margin ratio above tolerance,\n\t\t\t// \t\t/// meaning that liqor has overbought position\n\t\t\t// \t\t2002: \"Position Above Tolerance\",\n\t\t\t// \t\t/// An operation brought an account below initial margin requirements.\n\t\t\t// \t\t2003: \"Initial Margin Requirement Violated\",\n\t\t\t// \t\t/// Position is above MMR, so can't be liquidated.\n\t\t\t// \t\t2004: \"Position Above MMR\",\n\t\t\t// \t\t/// Cannot realize bad debt via means other than calling 'liquidate'.\n\t\t\t// \t\t2005: \"Position Bad Debt\",\n\t\t\t// \t\t/// Cannot withdraw more than the account's free collateral.\n\t\t\t// \t\t2006: \"Insufficient Free Collateral\",\n\t\t\t// \t\t/// Cannot have more than 1 position in a market.\n\t\t\t// \t\t2007: \"Position Already Exists\",\n\t\t\t// \t\t/// Cannot compute deallocate amount for a target MR < IMR.\n\t\t\t// \t\t2008: \"Deallocate Target MR Too Low\",\n\t\t\t// \t\t// Orderbook & OrderedMap\n\t\t\t// \t\t/// While creating ordered map with wrong parameters.\n\t\t\t// \t\t3000: \"Invalid Map Parameters\",\n\t\t\t// \t\t/// While searching for a key, but it doesn't exist.\n\t\t\t// \t\t3001: \"Key Not Exist\",\n\t\t\t// \t\t/// While inserting already existing key.\n\t\t\t// \t\t3002: \"Key Already Exists\",\n\t\t\t// \t\t/// When attempting to destroy a non-empty map\n\t\t\t// \t\t3003: \"Destroy Not Empty\",\n\t\t\t// \t\t/// Invalid user tries to modify an order\n\t\t\t// \t\t3004: \"Invalid User For Order\",\n\t\t\t// \t\t/// Orderbook flag requirements violated\n\t\t\t// \t\t3005: \"Flag Requirements Violated\",\n\t\t\t// \t\t/// Minimum size matched not reached\n\t\t\t// \t\t3006: \"Not Enough Liquidity\",\n\t\t\t// \t\t/// When trying to change a map configuration, but the map has length less than 4\n\t\t\t// \t\t3007: \"Map Too Small\",\n\t\t\t// \t\t/// When taker matches its own order\n\t\t\t// \t\t3008: \"Self Trading\",\n\t\t\t// \t},\n\t\t\t// },\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// public fetchMarket = async (inputs: {\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tcollateralCoinType: CoinType;\n\t// }): Promise<PerpetualsMarketData> => {\n\t// \tconst { collateralCoinType } = inputs;\n\t// \treturn this.Provider.Objects().fetchCastObject({\n\t// \t\tobjectId: inputs.marketId,\n\t// \t\tobjectFromSuiObjectResponse: (data) =>\n\t// \t\t\tCasting.perpetuals.clearingHouseFromOnChain(\n\t// \t\t\t\tdata,\n\t// \t\t\t\tcollateralCoinType\n\t// \t\t\t),\n\t// \t});\n\t// };\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t// public fetchOrderbookPrice = async (inputs: {\n\t// \tcollateralCoinType: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \t// marketInitialSharedVersion: ObjectVersion;\n\t// }): Promise<number> => {\n\t// \tconst {\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t\t// marketInitialSharedVersion\n\t// \t} = inputs;\n\n\t// \tconst tx = new Transaction();\n\n\t// \tthis.getBookPriceTx({\n\t// \t\ttx,\n\t// \t\tmarketId,\n\t// \t\tcollateralCoinType,\n\t// \t\t// marketInitialSharedVersion,\n\t// \t});\n\n\t// \tconst bytes =\n\t// \t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t// \t\t\ttx,\n\t// \t\t});\n\n\t// \treturn PerpetualsApiCasting.orderbookPriceFromBytes(bytes);\n\t// };\n\n\t// public fetchAllMarketIds = async (inputs: {\n\t// \tcollateralCoinType: CoinType;\n\t// }): Promise<PerpetualsMarketId[]> => {\n\t// \tconst { collateralCoinType } = inputs;\n\t// \tconst marketIdsData = await this.Provider.indexerCaller.fetchIndexer<\n\t// \t\t{\n\t// \t\t\tmarketId: ObjectId;\n\t// \t\t}[]\n\t// \t>(\n\t// \t\t`perpetuals/markets/${Helpers.addLeadingZeroesToType(\n\t// \t\t\tcollateralCoinType\n\t// \t\t)}`\n\t// \t);\n\t// \treturn marketIdsData.map((data) =>\n\t// \t\tHelpers.addLeadingZeroesToType(data.marketId)\n\t// \t);\n\t// };\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t// public depositCollateralTx = (\n\t// \tinputs: {\n\t// \t\ttx: Transaction;\n\t// \t\tcollateralCoinType: CoinType;\n\t// \t\taccountCapId: ObjectId | TransactionArgument;\n\t// \t} & (\n\t// \t\t| {\n\t// \t\t\t\tcoinId: ObjectId | TransactionArgument;\n\t// \t\t }\n\t// \t\t| {\n\t// \t\t\t\tcoinBytes: Uint8Array;\n\t// \t\t }\n\t// \t)\n\t// ) => {\n\t// \tconst { tx, collateralCoinType, accountCapId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tthis.addresses.packages.perpetuals,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"deposit_collateral\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof accountCapId === \"string\"\n\t// \t\t\t\t? tx.object(accountCapId)\n\t// \t\t\t\t: accountCapId,\n\t// \t\t\t\"coinBytes\" in inputs\n\t// \t\t\t\t? tx.pure(inputs.coinBytes)\n\t// \t\t\t\t: typeof inputs.coinId === \"string\"\n\t// \t\t\t\t? tx.object(inputs.coinId)\n\t// \t\t\t\t: inputs.coinId,\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public allocateCollateralTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId | TransactionArgument;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \tamount: Balance;\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, accountCapId, marketId, amount } =\n\t// \t\tinputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"allocate_collateral\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttypeof accountCapId === \"string\"\n\t// \t\t\t\t? tx.object(accountCapId)\n\t// \t\t\t\t: accountCapId,\n\t// \t\t\ttx.pure.u64(amount),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public deallocateCollateralTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId;\n\t// \tbasePriceFeedId: ObjectId;\n\t// \tcollateralPriceFeedId: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \tamount: Balance;\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, accountCapId, marketId, amount } =\n\t// \t\tinputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"deallocate_collateral\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttx.object(accountCapId),\n\t// \t\t\ttx.object(inputs.basePriceFeedId),\n\t// \t\t\ttx.object(inputs.collateralPriceFeedId),\n\t// \t\t\ttx.object(Sui.constants.addresses.suiClockId),\n\t// \t\t\ttx.pure.u64(amount),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public createMarketPositionTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId | TransactionArgument;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, accountCapId, marketId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"create_market_position\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttypeof accountCapId === \"string\"\n\t// \t\t\t\t? tx.object(accountCapId)\n\t// \t\t\t\t: accountCapId,\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public shareClearingHouseTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \tmarketId: PerpetualsMarketId | TransactionArgument;\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, marketId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"share_clearing_house\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof marketId === \"string\" ? tx.object(marketId) : marketId,\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public startSessionTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId | TransactionArgument;\n\t// \tbasePriceFeedId: ObjectId;\n\t// \tcollateralPriceFeedId: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// }) /* SessionHotPotato<T> */ => {\n\t// \tconst { tx, collateralCoinType, accountCapId, marketId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"start_session\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttypeof accountCapId === \"string\"\n\t// \t\t\t\t? tx.object(accountCapId)\n\t// \t\t\t\t: accountCapId,\n\t// \t\t\ttx.object(inputs.basePriceFeedId),\n\t// \t\t\ttx.object(inputs.collateralPriceFeedId),\n\t// \t\t\ttx.object(Sui.constants.addresses.suiClockId),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public endSessionTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \tsessionPotatoId: ObjectId | TransactionArgument;\n\t// }) /* ClearingHouse<T> */ => {\n\t// \tconst { tx, collateralCoinType, sessionPotatoId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"end_session\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof sessionPotatoId === \"string\"\n\t// \t\t\t\t? tx.object(sessionPotatoId)\n\t// \t\t\t\t: sessionPotatoId,\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public placeMarketOrderTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \tsessionPotatoId: ObjectId | TransactionArgument;\n\t// \tside: PerpetualsOrderSide;\n\t// \tsize: bigint;\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, sessionPotatoId, side, size } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"place_market_order\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof sessionPotatoId === \"string\"\n\t// \t\t\t\t? tx.object(sessionPotatoId)\n\t// \t\t\t\t: sessionPotatoId,\n\t// \t\t\ttx.pure.bool(Boolean(side)),\n\t// \t\t\ttx.pure.u64(size),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public placeLimitOrderTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \tsessionPotatoId: ObjectId | TransactionArgument;\n\t// \tside: PerpetualsOrderSide;\n\t// \tsize: bigint;\n\t// \tprice: bigint;\n\t// \torderType: PerpetualsOrderType;\n\t// }) => {\n\t// \tconst {\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tsessionPotatoId,\n\t// \t\tside,\n\t// \t\tsize,\n\t// \t\tprice,\n\t// \t\torderType,\n\t// \t} = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"place_limit_order\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof sessionPotatoId === \"string\"\n\t// \t\t\t\t? tx.object(sessionPotatoId)\n\t// \t\t\t\t: sessionPotatoId,\n\t// \t\t\ttx.pure.bool(Boolean(side)),\n\t// \t\t\ttx.pure.u64(size),\n\t// \t\t\ttx.pure.u64(price),\n\t// \t\t\ttx.pure.u64(BigInt(orderType)),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public cancelOrdersTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \torderIds: PerpetualsOrderId[];\n\t// }) => {\n\t// \tconst { tx, collateralCoinType, accountCapId, marketId, orderIds } =\n\t// \t\tinputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"cancel_orders\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttx.object(accountCapId),\n\t// \t\t\ttx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public reduceOrdersTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \torderIds: PerpetualsOrderId[];\n\t// \tsizesToSubtract: bigint[];\n\t// }) => {\n\t// \tconst {\n\t// \t\ttx,\n\t// \t\tpackageId,\n\t// \t\tcollateralCoinType,\n\t// \t\taccountCapId,\n\t// \t\tmarketId,\n\t// \t\torderIds,\n\t// \t\tsizesToSubtract,\n\t// \t} = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tpackageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"reduce_orders\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: true,\n\t// \t\t\t}),\n\t// \t\t\ttx.object(accountCapId),\n\t// \t\t\ttx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),\n\t// \t\t\ttx.pure(bcs.vector(bcs.u64()).serialize(sizesToSubtract)),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public withdrawCollateralTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId | TransactionArgument;\n\t// \tamount: Balance;\n\t// }): TransactionArgument => {\n\t// \tconst { tx, collateralCoinType, accountCapId, amount } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tthis.addresses.packages.perpetuals,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"withdraw_collateral\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof accountCapId === \"string\"\n\t// \t\t\t\t? tx.object(accountCapId)\n\t// \t\t\t\t: accountCapId,\n\t// \t\t\ttx.pure.u64(amount),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public createAccountTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tcollateralCoinType: CoinType;\n\t// }) /* Account<T> */ => {\n\t// \tconst { tx, collateralCoinType } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tthis.addresses.packages.perpetuals,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.interface,\n\t// \t\t\t\"create_account\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [tx.object(this.addresses.objects.registry)],\n\t// \t});\n\t// };\n\n\t// public getHotPotatoFieldsTx = (\n\t// \tinputs: {\n\t// \t\ttx: Transaction;\n\t// \t\tcollateralCoinType: CoinType;\n\t// \t\tsessionPotatoId: ObjectId | TransactionArgument;\n\t// \t}\n\t// \t/*\n\t// \t\t(\n\t// \t\t\tlot_size,\n\t// \t\t\ttick_size,\n\t// \t\t\ttimestamp_ms,\n\t// \t\t\tcollateral_price,\n\t// \t\t\tindex_price,\n\t// \t\t\tbook_price,\n\t// \t\t\tfills,\n\t// \t\t\tpost\n\t// \t\t): (\n\t// \t\t\tu64,\n\t// \t\t\tu64,\n\t// \t\t\tu64,\n\t// \t\t\tu64,\n\t// \t\t\tu256,\n\t// \t\t\tu256,\n\t// \t\t\tu256,\n\t// \t\t\t&vector<FillReceipt>,\n\t// \t\t\t&PostReceipt\n\t// \t\t)\n\t// \t*/\n\t// ) => {\n\t// \tconst { tx, collateralCoinType, sessionPotatoId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.clearingHouse,\n\t// \t\t\t\"get_hot_potato_fields\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttypeof sessionPotatoId === \"string\"\n\t// \t\t\t\t? tx.object(sessionPotatoId)\n\t// \t\t\t\t: sessionPotatoId,\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public getPositionTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountId: PerpetualsAccountId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// }) /* Position */ => {\n\t// \tconst { tx, marketId, collateralCoinType } = inputs;\n\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.clearingHouse,\n\t// \t\t\t\"get_position\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: false,\n\t// \t\t\t}),\n\t// \t\t\ttx.pure.u64(inputs.accountId),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public getOrderbookTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tcollateralCoinType: CoinType;\n\t// \tmarketId: PerpetualsMarketId;\n\t// }) /* Orderbook */ => {\n\t// \tconst { tx, collateralCoinType } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.clearingHouse,\n\t// \t\t\t\"get_orderbook\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [tx.object(inputs.marketId)],\n\t// \t});\n\t// };\n\n\t// public getBookPriceTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \t// marketInitialSharedVersion: ObjectVersion;\n\t// \tcollateralCoinType: CoinType;\n\t// }) /* Option<u256> */ => {\n\t// \tconst { tx, marketId, collateralCoinType } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.clearingHouse,\n\t// \t\t\t\"get_book_price\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.object(marketId),\n\t// \t\t\t// tx.sharedObjectRef({\n\t// \t\t\t// \tobjectId: marketId,\n\t// \t\t\t// \tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t// \tmutable: false,\n\t// \t\t\t// }),\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public getBestPriceTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \tside: PerpetualsOrderSide;\n\t// \tcollateralCoinType: CoinType;\n\t// }) /* Option<u256> */ => {\n\t// \tconst { tx, marketId, collateralCoinType } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.clearingHouse,\n\t// \t\t\t\"get_best_price\"\n\t// \t\t),\n\t// \t\ttypeArguments: [collateralCoinType],\n\t// \t\targuments: [\n\t// \t\t\ttx.sharedObjectRef({\n\t// \t\t\t\tobjectId: marketId,\n\t// \t\t\t\tinitialSharedVersion: inputs.marketInitialSharedVersion,\n\t// \t\t\t\tmutable: false,\n\t// \t\t\t}), // ClearingHouse\n\t// \t\t\ttx.pure.bool(Boolean(inputs.side)), // side\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public inspectOrdersTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \torderbookId: ObjectId | TransactionArgument;\n\t// \tside: PerpetualsOrderSide;\n\t// \tfromPrice: number;\n\t// \ttoPrice: number;\n\t// }) /* vector<OrderInfo> */ => {\n\t// \tconst { tx, orderbookId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.orderbook,\n\t// \t\t\t\"inspect_orders\"\n\t// \t\t),\n\t// \t\ttypeArguments: [],\n\t// \t\targuments: [\n\t// \t\t\ttypeof orderbookId === \"string\"\n\t// \t\t\t\t? tx.object(orderbookId)\n\t// \t\t\t\t: orderbookId, // Orderbook\n\t// \t\t\ttx.pure.bool(Boolean(inputs.side)), // side\n\t// \t\t\ttx.pure.u64(inputs.fromPrice), // price_from\n\t// \t\t\ttx.pure.u64(inputs.toPrice), // price_to\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public getOrderSizeTx = (inputs: {\n\t// \ttx: Transaction;\n\t// \tpackageId: PackageId;\n\t// \torderbookId: ObjectId | TransactionArgument;\n\t// \torderId: PerpetualsOrderId;\n\t// }) /* u64 */ => {\n\t// \tconst { tx, orderbookId } = inputs;\n\t// \treturn tx.moveCall({\n\t// \t\ttarget: Helpers.transactions.createTxTarget(\n\t// \t\t\tinputs.packageId,\n\t// \t\t\tPerpetualsApi.constants.moduleNames.orderbook,\n\t// \t\t\t\"get_order_size\"\n\t// \t\t),\n\t// \t\ttypeArguments: [],\n\t// \t\targuments: [\n\t// \t\t\ttypeof orderbookId === \"string\"\n\t// \t\t\t\t? tx.object(orderbookId)\n\t// \t\t\t\t: orderbookId, // Orderbook\n\t// \t\t\ttx.pure.u128(inputs.orderId), // order_id\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\t// public fetchBuildDepositCollateralTx = async (\n\t// \tinputs: ApiPerpetualsDepositCollateralBody\n\t// ): Promise<Transaction> => {\n\t// \tconst tx = new Transaction();\n\t// \ttx.setSender(inputs.walletAddress);\n\n\t// \tconst { walletAddress, collateralCoinType, amount } = inputs;\n\t// \tconst coinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t// \t\ttx,\n\t// \t\twalletAddress,\n\t// \t\tcoinType: collateralCoinType,\n\t// \t\tcoinAmount: amount,\n\t// \t});\n\t// \tthis.depositCollateralTx({\n\t// \t\ttx,\n\t// \t\tcoinId,\n\t// \t\t...inputs,\n\t// \t});\n\n\t// \treturn tx;\n\t// };\n\n\t// public buildCancelOrderTx = (\n\t// \tinputs: ApiPerpetualsCancelOrderBody\n\t// ): Transaction => {\n\t// \tconst {\n\t// \t\tpackageId,\n\t// \t\torderId,\n\t// \t\tmarketId,\n\t// \t\tmarketInitialSharedVersion,\n\t// \t\tcollateralChange,\n\t// \t\tbasePriceFeedId,\n\t// \t\tcollateralPriceFeedId,\n\t// \t\t...otherInputs\n\t// \t} = inputs;\n\n\t// \treturn this.buildCancelOrdersTx({\n\t// \t\t...otherInputs,\n\t// \t\torderDatas: [\n\t// \t\t\t{\n\t// \t\t\t\tpackageId,\n\t// \t\t\t\torderId,\n\t// \t\t\t\tmarketId,\n\t// \t\t\t\tmarketInitialSharedVersion,\n\t// \t\t\t\tcollateralChange,\n\t// \t\t\t\tbasePriceFeedId,\n\t// \t\t\t\tcollateralPriceFeedId,\n\t// \t\t\t},\n\t// \t\t],\n\t// \t});\n\t// };\n\n\t// public buildCancelOrdersTx = (\n\t// \tinputs: ApiPerpetualsCancelOrdersBody\n\t// ): Transaction => {\n\t// \tconst { orderDatas, collateralCoinType, accountCapId } = inputs;\n\n\t// \tif (orderDatas.length <= 0)\n\t// \t\tthrow new Error(\"cannot have order datas of length zero\");\n\n\t// \tconst tx = new Transaction();\n\t// \ttx.setSender(inputs.walletAddress);\n\n\t// \tconst marketIdToOrderIds = orderDatas.reduce(\n\t// \t\t(acc, order) => {\n\t// \t\t\tif (order.marketId in acc) {\n\t// \t\t\t\treturn {\n\t// \t\t\t\t\t...acc,\n\t// \t\t\t\t\t[order.marketId]: [...acc[order.marketId], order],\n\t// \t\t\t\t};\n\t// \t\t\t}\n\t// \t\t\treturn {\n\t// \t\t\t\t...acc,\n\t// \t\t\t\t[order.marketId]: [order],\n\t// \t\t\t};\n\t// \t\t},\n\t// \t\t{} as Record<\n\t// \t\t\tPerpetualsMarketId,\n\t// \t\t\t{\n\t// \t\t\t\tpackageId: PackageId;\n\t// \t\t\t\torderId: PerpetualsOrderId;\n\t// \t\t\t\tmarketId: PerpetualsMarketId;\n\t// \t\t\t\tmarketInitialSharedVersion: ObjectVersion;\n\t// \t\t\t\tcollateralChange: Balance;\n\t// \t\t\t\tbasePriceFeedId: ObjectId;\n\t// \t\t\t\tcollateralPriceFeedId: ObjectId;\n\t// \t\t\t}[]\n\t// \t\t>\n\t// \t);\n\n\t// \tfor (const [marketId, orders] of Object.entries(marketIdToOrderIds)) {\n\t// \t\tif (orders.length <= 0) continue;\n\n\t// \t\tconst marketInitialSharedVersion =\n\t// \t\t\torders[0].marketInitialSharedVersion;\n\t// \t\tconst packageId = orders[0].packageId;\n\n\t// \t\tthis.cancelOrdersTx({\n\t// \t\t\ttx,\n\t// \t\t\tcollateralCoinType,\n\t// \t\t\taccountCapId,\n\t// \t\t\tmarketId,\n\t// \t\t\tmarketInitialSharedVersion,\n\t// \t\t\tpackageId,\n\t// \t\t\torderIds: orders.map((order) => order.orderId),\n\t// \t\t});\n\n\t// \t\tconst netCollateralChange = Helpers.sumBigInt(\n\t// \t\t\torders.map((order) => order.collateralChange)\n\t// \t\t);\n\t// \t\tif (netCollateralChange < BigInt(0)) {\n\t// \t\t\tthis.deallocateCollateralTx({\n\t// \t\t\t\ttx,\n\t// \t\t\t\taccountCapId,\n\t// \t\t\t\tcollateralCoinType,\n\t// \t\t\t\tmarketId,\n\t// \t\t\t\tmarketInitialSharedVersion,\n\t// \t\t\t\tpackageId,\n\t// \t\t\t\tamount: Helpers.absBigInt(netCollateralChange),\n\t// \t\t\t\tbasePriceFeedId: orders[0].basePriceFeedId,\n\t// \t\t\t\tcollateralPriceFeedId: orders[0].collateralPriceFeedId,\n\t// \t\t\t});\n\t// \t\t} else if (netCollateralChange > BigInt(0)) {\n\t// \t\t\tthis.allocateCollateralTx({\n\t// \t\t\t\ttx,\n\t// \t\t\t\taccountCapId,\n\t// \t\t\t\tcollateralCoinType,\n\t// \t\t\t\tmarketId,\n\t// \t\t\t\tmarketInitialSharedVersion,\n\t// \t\t\t\tpackageId,\n\t// \t\t\t\tamount: netCollateralChange,\n\t// \t\t\t});\n\t// \t\t} else {\n\t// \t\t\t// no collateral change\n\t// \t\t}\n\t// \t}\n\n\t// \treturn tx;\n\t// };\n\n\t// public buildTransferCollateralTx = (inputs: {\n\t// \twalletAddress: SuiAddress;\n\t// \tcollateralCoinType: CoinType;\n\t// \tfromAccountCapId: ObjectId | TransactionArgument;\n\t// \ttoAccountCapId: ObjectId | TransactionArgument;\n\t// \tamount: Balance;\n\t// }): Transaction => {\n\t// \tconst {\n\t// \t\twalletAddress,\n\t// \t\tcollateralCoinType,\n\t// \t\tfromAccountCapId,\n\t// \t\ttoAccountCapId,\n\t// \t\tamount,\n\t// \t} = inputs;\n\n\t// \tconst tx = new Transaction();\n\t// \ttx.setSender(walletAddress);\n\n\t// \tconst coinId = this.withdrawCollateralTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tamount,\n\t// \t\taccountCapId: fromAccountCapId,\n\t// \t});\n\t// \tthis.depositCollateralTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tcoinId,\n\t// \t\taccountCapId: toAccountCapId,\n\t// \t});\n\n\t// \treturn tx;\n\t// };\n\n\t// public buildAllocateCollateralTx = TransactionsApiHelpers.createBuildTxFunc(\n\t// \tthis.allocateCollateralTx\n\t// );\n\n\t// public buildDeallocateCollateralTx =\n\t// \tTransactionsApiHelpers.createBuildTxFunc(this.deallocateCollateralTx);\n\n\t// public buildReduceOrdersTx = (\n\t// \tinputs: ApiPerpetualsReduceOrdersBody\n\t// ): Transaction => {\n\t// \tconst {\n\t// \t\twalletAddress,\n\t// \t\tcollateralChange,\n\t// \t\taccountCapId,\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t\tmarketInitialSharedVersion,\n\t// \t\tpackageId,\n\t// \t\tbasePriceFeedId,\n\t// \t\tcollateralPriceFeedId,\n\t// \t\torderIds,\n\t// \t\tsizesToSubtract,\n\t// \t} = inputs;\n\n\t// \tconst tx = new Transaction();\n\t// \ttx.setSender(walletAddress);\n\n\t// \tthis.reduceOrdersTx({\n\t// \t\ttx,\n\t// \t\tpackageId,\n\t// \t\tcollateralCoinType,\n\t// \t\taccountCapId,\n\t// \t\tmarketId,\n\t// \t\tmarketInitialSharedVersion,\n\t// \t\torderIds,\n\t// \t\tsizesToSubtract,\n\t// \t});\n\n\t// \tif (collateralChange < BigInt(0)) {\n\t// \t\tthis.deallocateCollateralTx({\n\t// \t\t\ttx,\n\t// \t\t\taccountCapId,\n\t// \t\t\tcollateralCoinType,\n\t// \t\t\tmarketId,\n\t// \t\t\tmarketInitialSharedVersion,\n\t// \t\t\tpackageId,\n\t// \t\t\tbasePriceFeedId,\n\t// \t\t\tcollateralPriceFeedId,\n\t// \t\t\tamount: Helpers.absBigInt(collateralChange),\n\t// \t\t});\n\t// \t} else if (collateralChange > BigInt(0)) {\n\t// \t\tthis.allocateCollateralTx({\n\t// \t\t\ttx,\n\t// \t\t\taccountCapId,\n\t// \t\t\tcollateralCoinType,\n\t// \t\t\tmarketId,\n\t// \t\t\tmarketInitialSharedVersion,\n\t// \t\t\tpackageId,\n\t// \t\t\tamount: collateralChange,\n\t// \t\t});\n\t// \t} else {\n\t// \t\t// no collateral change\n\t// \t}\n\n\t// \treturn tx;\n\t// };\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tpublic getAccountCapType = (inputs: {\n\t\tcollateralCoinType: CoinType;\n\t}): string => {\n\t\treturn `${this.addresses.packages.events}::${PerpetualsApi.constants.moduleNames.account}::Account<${inputs.collateralCoinType}>`;\n\t};\n\n\t// =========================================================================\n\t// Private Helpers\n\t// =========================================================================\n\n\t// private fetchOrdersSizes = async (inputs: {\n\t// \torderIds: PerpetualsOrderId[];\n\t// \tcollateralCoinType: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// }): Promise<bigint[]> => {\n\t// \tconst { orderIds, marketId, collateralCoinType } = inputs;\n\t// \tif (orderIds.length <= 0) return [];\n\n\t// \tconst tx = new Transaction();\n\n\t// \tconst orderbookId = this.getOrderbookTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t});\n\n\t// \tfor (const orderId of orderIds) {\n\t// \t\tthis.getOrderSizeTx({\n\t// \t\t\ttx,\n\t// \t\t\torderId,\n\t// \t\t\torderbookId,\n\t// \t\t});\n\t// \t}\n\n\t// \tconst { allBytes } =\n\t// \t\tawait this.Provider.Inspections().fetchAllBytesFromTx({\n\t// \t\t\ttx,\n\t// \t\t});\n\n\t// \tconst sizes = allBytes\n\t// \t\t.slice(1)\n\t// \t\t.map((bytes) => Casting.bigIntFromBytes(bytes[0]));\n\t// \treturn sizes;\n\t// };\n\n\t// private fetchOrderbookOrders = async (inputs: {\n\t// \tcollateralCoinType: ObjectId;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tside: PerpetualsOrderSide;\n\t// \tfromPrice: PerpetualsOrderPrice;\n\t// \ttoPrice: PerpetualsOrderPrice;\n\t// }): Promise<PerpetualsOrderInfo[]> => {\n\t// \tconst { collateralCoinType, marketId, side, fromPrice, toPrice } =\n\t// \t\tinputs;\n\n\t// \tconst tx = new Transaction();\n\n\t// \tconst orderbookId = this.getOrderbookTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t});\n\t// \tthis.inspectOrdersTx({ tx, orderbookId, side, fromPrice, toPrice });\n\n\t// \tconst bytes =\n\t// \t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t// \t\t\ttx,\n\t// \t\t});\n\n\t// \tconst orderInfos: any[] = bcs\n\t// \t\t.vector(perpetualsRegistry.OrderInfo)\n\t// \t\t.parse(new Uint8Array(bytes));\n\n\t// \treturn orderInfos.map((orderInfo) =>\n\t// \t\tCasting.perpetuals.orderInfoFromRaw(orderInfo)\n\t// \t);\n\t// };\n\n\t// public fetchExecutionPrice = async (\n\t// \tinputs: ApiPerpetualsExecutionPriceBody & {\n\t// \t\tcollateralCoinType: CoinType;\n\t// \t\tmarketId: PerpetualsMarketId;\n\t// \t}\n\t// ): Promise<ApiPerpetualsExecutionPriceResponse> => {\n\t// \tconst {\n\t// \t\t// collateral,\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t\tside,\n\t// \t\tsize,\n\t// \t\tprice,\n\t// \t\tlotSize,\n\t// \t\tbasePriceFeedId,\n\t// \t\tcollateralPriceFeedId,\n\t// \t} = inputs;\n\t// \t// TODO: change this\n\t// \tconst collateral = BigInt(1000000000000000);\n\n\t// \t// const accountCapId = perpetualsBcsRegistry\n\t// \t// \t.ser(`Account<${collateralCoinType}>`, {\n\t// \t// \t\tid: {\n\t// \t// \t\t\tid: {\n\t// \t// \t\t\t\tbytes: \"0x0000000000000000000000000000000000000000000000000000000000000321\",\n\t// \t// \t\t\t},\n\t// \t// \t\t},\n\t// \t// \t\taccountId: 0,\n\t// \t// \t\tcollateral,\n\t// \t// \t})\n\t// \t// \t.toBytes();\n\n\t// const depositCoinBytes = perpetualsRegistry.Coin.serialize({\n\t// \tid: \"0x0000000000000000000000000000000000000000000000000000000000000123\",\n\t// \tbalance: {\n\t// \t\tvalue: BigInt(1000000000000000),\n\t// \t},\n\t// }).toBytes();\n\n\t// \tconst walletAddress = InspectionsApiHelpers.constants.devInspectSigner;\n\n\t// \tconst tx = new Transaction();\n\t// \ttx.setSender(walletAddress);\n\n\t// \tconst accountCapId = this.createAccountTx({\n\t// \t\t...inputs,\n\t// \t\ttx,\n\t// \t});\n\t// \tthis.depositCollateralTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\taccountCapId,\n\t// \t\tcoinBytes: depositCoinBytes,\n\t// \t});\n\t// \tconst { sessionPotatoId } = this.createTxAndStartSession({\n\t// \t\ttx,\n\t// \t\taccountCapId,\n\t// \t\tcollateralCoinType,\n\t// \t\tmarketId,\n\t// \t\twalletAddress,\n\t// \t\tbasePriceFeedId,\n\t// \t\tcollateralPriceFeedId,\n\t// \t\tcollateralChange: collateral,\n\t// \t\thasPosition: false,\n\t// \t});\n\t// \tthis.placeLimitOrderTx({\n\t// \t\ttx,\n\t// \t\tside,\n\t// \t\tsize,\n\t// \t\tcollateralCoinType,\n\t// \t\tsessionPotatoId,\n\t// \t\torderType: PerpetualsOrderType.Standard,\n\t// \t\tprice:\n\t// \t\t\tprice ??\n\t// \t\t\t(side === PerpetualsOrderSide.Bid\n\t// \t\t\t\t? BigInt(\"0x7FFFFFFFFFFFFFFF\") // 2^63 - 1\n\t// \t\t\t\t: BigInt(1)),\n\t// \t});\n\t// \tthis.getHotPotatoFieldsTx({\n\t// \t\ttx,\n\t// \t\tcollateralCoinType,\n\t// \t\tsessionPotatoId,\n\t// \t});\n\t// \tthis.endSessionAndTransferAccount({\n\t// \t\t...inputs,\n\t// \t\ttx,\n\t// \t\tsessionPotatoId,\n\t// \t\twalletAddress,\n\t// \t\tcollateralChange: BigInt(0),\n\t// \t});\n\n\t// \tconst { events } =\n\t// \t\tawait this.Provider.Inspections().fetchAllBytesFromTx({\n\t// \t\t\ttx,\n\t// \t\t});\n\n\t// \tconst filledTakerEvent = EventsApiHelpers.findCastEventOrUndefined({\n\t// \t\tevents,\n\t// \t\teventType: this.eventTypes.filledTakerOrder,\n\t// \t\tcastFunction: Casting.perpetuals.filledTakerOrderEventFromOnChain,\n\t// \t});\n\n\t// \tconst sizeNum = lotSize * Math.abs(Number(size));\n\n\t// \tif (!filledTakerEvent) {\n\t// \t\treturn {\n\t// \t\t\texecutionPrice: 0,\n\t// \t\t\tsizeFilled: 0,\n\t// \t\t\tsizePosted: sizeNum,\n\t// \t\t\tfills: [],\n\t// \t\t};\n\t// \t}\n\n\t// \tconst filledOrderEvents =\n\t// \t\tAftermath.helpers.events.findCastEventsOrUndefined({\n\t// \t\t\tevents,\n\t// \t\t\teventType: this.eventTypes.filledTakerOrder,\n\t// \t\t\tcastFunction:\n\t// \t\t\t\tCasting.perpetuals.filledTakerOrderEventFromOnChain,\n\t// \t\t});\n\t// \tconst fills: PerpetualsFilledOrderData[] = filledOrderEvents.map(\n\t// \t\t(event) => {\n\t// \t\t\tconst size = Math.abs(\n\t// \t\t\t\tCasting.IFixed.numberFromIFixed(event.baseAssetDelta)\n\t// \t\t\t);\n\t// \t\t\tconst sizeUsd = Math.abs(\n\t// \t\t\t\tCasting.IFixed.numberFromIFixed(event.quoteAssetDelta)\n\t// \t\t\t);\n\t// \t\t\tconst price = sizeUsd / size;\n\t// \t\t\treturn {\n\t// \t\t\t\tsize,\n\t// \t\t\t\tprice,\n\t// \t\t\t};\n\t// \t\t}\n\t// \t);\n\n\t// \tconst executionPrice = Perpetuals.calcEntryPrice(filledTakerEvent);\n\t// \tconst sizeFilled = Math.abs(\n\t// \t\tCasting.IFixed.numberFromIFixed(filledTakerEvent.baseAssetDelta)\n\t// \t);\n\t// \tconst sizePosted = sizeNum - sizeFilled;\n\n\t// \treturn {\n\t// \t\texecutionPrice,\n\t// \t\tsizeFilled,\n\t// \t\tsizePosted,\n\t// \t\tfills,\n\t// \t};\n\n\t// \t// const { fillReceipts, postReceipt } =\n\t// \t// \tawait this.fetchMarketOrderReceipts(inputs);\n\n\t// \t// const sizePosted = postReceipt !== undefined ? postReceipt.size : 0;\n\t// \t// if (fillReceipts.length <= 0)\n\t// \t// \treturn price !== undefined\n\t// \t// \t\t? // simulating limit order\n\t// \t// \t\t {\n\t// \t// \t\t\t\texecutionPrice: Perpetuals.orderPriceToPrice({\n\t// \t// \t\t\t\t\torderPrice: price,\n\t// \t// \t\t\t\t\tlotSize,\n\t// \t// \t\t\t\t\ttickSize,\n\t// \t// \t\t\t\t}),\n\t// \t// \t\t\t\tsizeFilled: 0,\n\t// \t// \t\t\t\tsizePosted: Number(sizePosted),\n\t// \t// \t\t }\n\t// \t// \t\t: // simulating market order\n\t// \t// \t\t {\n\t// \t// \t\t\t\texecutionPrice: 0,\n\t// \t// \t\t\t\tsizeFilled: 0,\n\t// \t// \t\t\t\tsizePosted: 0,\n\t// \t// \t\t };\n\n\t// \t// const sizeFilled = Helpers.sumBigInt(\n\t// \t// \tfillReceipts.map((receipt) => receipt.size)\n\t// \t// );\n\n\t// \t// const executionPrice = fillReceipts.reduce((acc, receipt) => {\n\t// \t// \tconst orderPrice = PerpetualsOrderUtils.price(\n\t// \t// \t\treceipt.orderId,\n\t// \t// \t\tinputs.side === PerpetualsOrderSide.Ask\n\t// \t// \t\t\t? PerpetualsOrderSide.Bid\n\t// \t// \t\t\t: PerpetualsOrderSide.Ask\n\t// \t// \t);\n\t// \t// \tconst orderPriceNum = Perpetuals.orderPriceToPrice({\n\t// \t// \t\torderPrice,\n\t// \t// \t\tlotSize,\n\t// \t// \t\ttickSize,\n\t// \t// \t});\n\n\t// \t// \treturn (\n\t// \t// \t\tacc +\n\t// \t// \t\torderPriceNum * (Number(receipt.size) / Number(sizeFilled))\n\t// \t// \t);\n\t// \t// }, 0);\n\n\t// \t// return {\n\t// \t// \texecutionPrice,\n\t// \t// \tsizeFilled: Number(sizeFilled),\n\t// \t// \tsizePosted: Number(sizePosted),\n\t// \t// };\n\t// };\n\n\t// private createTxAndStartSession = (inputs: {\n\t// \ttx?: Transaction;\n\t// \tcollateralCoinType: CoinType;\n\t// \taccountCapId: ObjectId | TransactionArgument;\n\t// \tmarketId: PerpetualsMarketId;\n\t// \tmarketInitialSharedVersion: ObjectVersion;\n\t// \tbasePriceFeedId: ObjectId;\n\t// \tcollateralPriceFeedId: ObjectId;\n\t// \twalletAddress: SuiAddress;\n\t// \tcollateralChange: Balance;\n\t// \thasPosition: boolean;\n\t// }) => {\n\t// \tconst { collateralChange, walletAddress, hasPosition } = inputs;\n\t// \tconst { tx: inputsTx, ...nonTxInputs } = inputs;\n\n\t// \tconst tx = inputsTx ?? new Transaction();\n\t// \ttx.setSender(walletAddress);\n\n\t// \tif (!hasPosition) {\n\t// \t\tthis.createMarketPositionTx({\n\t// \t\t\t...nonTxInputs,\n\t// \t\t\ttx,\n\t// \t\t});\n\t// \t}\n\n\t// \tif (collateralChange > BigInt(0)) {\n\t// \t\tthis.allocateCollateralTx({\n\t// \t\t\t...nonTxInputs,\n\t// \t\t\ttx,\n\t// \t\t\tamount: collateralChange,\n\t// \t\t});\n\t// \t}\n\n\t// \tconst sessionPotatoId = this.startSessionTx({\n\t// \t\t...nonTxInputs,\n\t// \t\ttx,\n\t// \t});\n\n\t// \treturn { tx, sessionPotatoId };\n\t// };\n\n\t// private endSessionAndShareMarket = (inputs: {\n\t// \ttx: Transaction;\n\t// \tcollateralCoinType: CoinType;\n\t// \tsessionPotatoId: ObjectId | TransactionArgument;\n\t// }) => {\n\t// \tconst marketId = this.endSessionTx(inputs);\n\t// \tthis.shareClearingHouseTx({\n\t// \t\t...inputs,\n\t// \t\tmarketId,\n\t// \t});\n\t// };\n\n\t// =========================================================================\n\t// Public Static Helpers\n\t// =========================================================================\n\n\t// public static bucketOrders = (inputs: {\n\t// \torders: PerpetualsOrderInfo[];\n\t// \tside: PerpetualsOrderSide;\n\t// \tlotSize: number;\n\t// \ttickSize: number;\n\t// \tpriceBucketSize: number;\n\t// \tinitialBucketedOrders?: OrderbookDataPoint[];\n\t// }): OrderbookDataPoint[] => {\n\t// \tconst {\n\t// \t\torders,\n\t// \t\tside,\n\t// \t\tlotSize,\n\t// \t\ttickSize,\n\t// \t\tpriceBucketSize,\n\t// \t\tinitialBucketedOrders,\n\t// \t} = inputs;\n\n\t// \tlet dataPoints: OrderbookDataPoint[] = initialBucketedOrders ?? [];\n\n\t// \tconst roundPrice = (price: number, bucketSize: number): number => {\n\t// \t\treturn Math.round(price / bucketSize) * bucketSize;\n\t// \t};\n\n\t// \tconst comparePrices = (\n\t// \t\tprice1: number,\n\t// \t\tprice2: number,\n\t// \t\tbucketSize: number\n\t// \t): boolean => {\n\t// \t\treturn Math.abs(price1 - price2) < bucketSize;\n\t// \t};\n\n\t// \torders.forEach((order) => {\n\t// \t\tconst actualPrice = Perpetuals.orderPriceToPrice({\n\t// \t\t\tlotSize,\n\t// \t\t\ttickSize: Math.abs(tickSize),\n\t// \t\t\torderPrice: order.price,\n\t// \t\t});\n\t// \t\tconst roundedPrice = roundPrice(actualPrice, priceBucketSize);\n\t// \t\tconst size =\n\t// \t\t\tlotSize *\n\t// \t\t\tMath.abs(Number(order.size)) *\n\t// \t\t\t(tickSize < 0 ? -1 : 1);\n\t// \t\tconst sizeUsd = size * actualPrice;\n\n\t// \t\tconst placementIndex = dataPoints.findIndex(\n\t// \t\t\t(dataPoint: OrderbookDataPoint) =>\n\t// \t\t\t\tcomparePrices(\n\t// \t\t\t\t\troundedPrice,\n\t// \t\t\t\t\tdataPoint.price,\n\t// \t\t\t\t\tpriceBucketSize\n\t// \t\t\t\t)\n\t// \t\t);\n\n\t// \t\tif (placementIndex < 0) {\n\t// \t\t\tif (size > 0) {\n\t// \t\t\t\tconst newDataPoint: OrderbookDataPoint = {\n\t// \t\t\t\t\tsize,\n\t// \t\t\t\t\tsizeUsd,\n\t// \t\t\t\t\ttotalSize: size,\n\t// \t\t\t\t\ttotalSizeUsd: sizeUsd,\n\t// \t\t\t\t\tprice: roundedPrice,\n\t// \t\t\t\t};\n\t// \t\t\t\tconst insertIndex = dataPoints.findIndex((dataPoint) =>\n\t// \t\t\t\t\tside === PerpetualsOrderSide.Ask\n\t// \t\t\t\t\t\t? roundedPrice < dataPoint.price\n\t// \t\t\t\t\t\t: roundedPrice > dataPoint.price\n\t// \t\t\t\t);\n\t// \t\t\t\tif (insertIndex < 0) {\n\t// \t\t\t\t\tdataPoints.push(newDataPoint);\n\t// \t\t\t\t} else {\n\t// \t\t\t\t\tdataPoints.splice(insertIndex, 0, newDataPoint);\n\t// \t\t\t\t}\n\t// \t\t\t}\n\t// \t\t} else {\n\t// \t\t\tdataPoints[placementIndex].size += size;\n\t// \t\t\tdataPoints[placementIndex].sizeUsd += sizeUsd;\n\t// \t\t\tdataPoints[placementIndex].totalSize += size;\n\t// \t\t\tdataPoints[placementIndex].totalSizeUsd += sizeUsd;\n\t// \t\t}\n\t// \t});\n\n\t// \tdataPoints = dataPoints.filter((data) => data.size >= lotSize);\n\n\t// \tfor (let index = 0; index < dataPoints.length; index++) {\n\t// \t\tif (index > 0) {\n\t// \t\t\tdataPoints[index].totalSize =\n\t// \t\t\t\tdataPoints[index - 1].totalSize + dataPoints[index].size;\n\t// \t\t\tdataPoints[index].totalSizeUsd =\n\t// \t\t\t\tdataPoints[index - 1].totalSizeUsd +\n\t// \t\t\t\tdataPoints[index].sizeUsd;\n\t// \t\t} else {\n\t// \t\t\tdataPoints[index].totalSize = dataPoints[index].size;\n\t// \t\t\tdataPoints[index].totalSizeUsd = dataPoints[index].sizeUsd;\n\t// \t\t}\n\t// \t}\n\n\t// \tif (side === PerpetualsOrderSide.Ask) {\n\t// \t\tdataPoints.reverse();\n\t// \t}\n\t// \treturn dataPoints;\n\t// };\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate eventType = (eventName: string) =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tPerpetualsApi.constants.moduleNames.events,\n\t\t\teventName\n\t\t);\n\n\t// =========================================================================\n\t// Object Types\n\t// =========================================================================\n\n\t// private marketObjectType = (inputs: { collateralCoinType: CoinType }) =>\n\t// \t`${\n\t// \t\tinputs.packageId\n\t// \t}::clearing_house::ClearingHouse<${Helpers.addLeadingZeroesToType(\n\t// \t\tinputs.collateralCoinType\n\t// \t)}>`;\n}\n","import {\n\tTransaction,\n\ttype TransactionObjectArgument,\n} from \"@mysten/sui/transactions\";\nimport { fromBase64, normalizeSuiObjectId } from \"@mysten/sui/utils\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tCoinDecimal,\n\tCoinType,\n\tCoinsToBalance,\n\tCoinsToDecimals,\n\tCoinsToPrice,\n} from \"../../coin/coinTypes\";\nimport {\n\tBalance,\n\tPoolDepositEvent,\n\tPoolStats,\n\tPoolTradeEvent,\n\tPoolWithdrawEvent,\n\tSlippage,\n\tPoolCreationLpCoinMetadata,\n\tPoolName,\n\tPoolDataPoint,\n\tPoolTradeFee,\n\tPoolGraphDataTimeframeKey,\n\tPercentage,\n\tAnyObjectType,\n\tReferralVaultAddresses,\n\tPoolsAddresses,\n\tPoolGraphDataTimeframe,\n\tPoolCreationCoinInfo,\n\tPoolFlatness,\n\tPoolWeight,\n\tPoolWithdrawFee,\n\tPoolDepositFee,\n\tPoolCoins,\n\tEventsInputs,\n\tUrl,\n\tApiIndexerEventsBody,\n\tObjectId,\n\tSuiAddress,\n\tApiPublishLpCoinBody,\n\tPoolLpInfo,\n\tCoinGeckoTickerData,\n\tCoinGeckoHistoricalTradeData,\n\tTimestamp,\n\tUniqueId,\n\tPoolObject,\n\tDaoFeePoolsAddresses,\n\tApiCreatePoolBody,\n\tApiPoolsOwnedDaoFeePoolOwnerCapsBody,\n\tDaoFeePoolOwnerCapObject,\n} from \"../../../types\";\nimport {\n\tDaoFeePoolFieldsOnChain,\n\tPoolDepositEventOnChain,\n\tPoolFieldsOnChain,\n\tPoolTradeEventOnChain,\n\tPoolTradeEventOnChainFields,\n\tPoolWithdrawEventOnChain,\n} from \"./poolsApiCastingTypes\";\nimport { Casting } from \"../../../general/utils/casting\";\nimport { Pool } from \"../pool\";\nimport { Pools } from \"../pools\";\nimport { Aftermath } from \"../../../general/providers\";\nimport { Helpers } from \"../../../general/utils\";\nimport { Coin } from \"../../coin\";\nimport dayjs, { ManipulateType } from \"dayjs\";\nimport { PoolsApiCasting } from \"./poolsApiCasting\";\nimport duration, { DurationUnitType } from \"dayjs/plugin/duration\";\nimport { IndexerEventOnChain } from \"../../../general/types/castingTypes\";\nimport { FixedUtils } from \"../../../general/utils/fixedUtils\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport {\n\tMoveErrors,\n\tMoveErrorsInterface,\n} from \"../../../general/types/moveErrorsInterface\";\n\n/**\n * This file contains the implementation of the PoolsApi class, which provides methods for interacting with the Aftermath protocol's pools.\n * @packageDocumentation\n */\n/**\n * Provides methods to interact with the Pools API.\n */\nexport class PoolsApi implements MoveErrorsInterface {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t/**\n\t * Constants used in the pools API.\n\t */\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tinterface: \"amm_interface\",\n\t\t\tpool: \"pool\",\n\t\t\tswap: \"swap\",\n\t\t\tdeposit: \"deposit\",\n\t\t\twithdraw: \"withdraw\",\n\t\t\tevents: \"events\",\n\t\t\tpoolRegistry: \"pool_registry\",\n\t\t\trouterWrapper: \"router\",\n\t\t\tpoolFactory: \"pool_factory\",\n\t\t\tmath: \"math\",\n\t\t\tgeometricMeanCalculations: \"geometric_mean_calculations\",\n\t\t\tstableCalculations: \"stable_calculations\",\n\t\t\tprice: \"price\",\n\t\t},\n\t\teventNames: {\n\t\t\tswap: \"SwapEvent\",\n\t\t\tdeposit: \"DepositEvent\",\n\t\t\twithdraw: \"WithdrawEvent\",\n\t\t\tswapV2: \"SwapEventV2\",\n\t\t\tdepositV2: \"DepositEventV2\",\n\t\t\twithdrawV2: \"WithdrawEventV2\",\n\t\t},\n\t\tdefaultLpCoinIconImageUrl:\n\t\t\t\"https://aftermath.finance/coins/lp/af_lp.svg\",\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\t/**\n\t * Object containing the addresses of various contracts.\n\t */\n\tpublic readonly addresses: {\n\t\tpools: PoolsAddresses;\n\t\treferralVault: ReferralVaultAddresses;\n\t\tdaoFeePools?: DaoFeePoolsAddresses;\n\t};\n\tpublic readonly objectTypes: {\n\t\tpool: AnyObjectType;\n\t\tdaoFeePool?: AnyObjectType;\n\t\tdaoFeePoolOwnerCap?: AnyObjectType;\n\t};\n\tpublic readonly eventTypes: {\n\t\ttrade: AnyObjectType;\n\t\tdeposit: AnyObjectType;\n\t\twithdraw: AnyObjectType;\n\t\ttradeV2: AnyObjectType;\n\t\tdepositV2: AnyObjectType;\n\t\twithdrawV2: AnyObjectType;\n\t};\n\tpublic readonly moveErrors: MoveErrors;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates an instance of PoolsApi.\n\t * @param {AftermathApi} Provider - An instance of AftermathApi.\n\t * @throws {Error} Throws an error if not all required addresses have been set in AfSdk\n\t */\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst pools = Provider.addresses.pools;\n\t\tconst referralVault = Provider.addresses.referralVault;\n\t\tconst daoFeePools = Provider.addresses.daoFeePools;\n\n\t\tif (!pools || !referralVault)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = {\n\t\t\tpools,\n\t\t\treferralVault,\n\t\t\tdaoFeePools,\n\t\t};\n\t\tthis.objectTypes = {\n\t\t\tpool: `${pools.packages.events}::pool::Pool`,\n\t\t\tdaoFeePool: daoFeePools\n\t\t\t\t? `${daoFeePools.packages.events}::pool::DaoFeePool`\n\t\t\t\t: undefined,\n\t\t\tdaoFeePoolOwnerCap: daoFeePools\n\t\t\t\t? `${daoFeePools.packages.events}::pool::OwnerCap`\n\t\t\t\t: undefined,\n\t\t};\n\t\tthis.eventTypes = {\n\t\t\ttrade: this.tradeEventType(),\n\t\t\tdeposit: this.depositEventType(),\n\t\t\twithdraw: this.withdrawEventType(),\n\t\t\ttradeV2: this.tradeV2EventType(),\n\t\t\tdepositV2: this.depositV2EventType(),\n\t\t\twithdrawV2: this.withdrawV2EventType(),\n\t\t};\n\t\tthis.moveErrors = {\n\t\t\t[this.addresses.pools.packages.amm]: {\n\t\t\t\t[PoolsApi.constants.moduleNames.pool]: {\n\t\t\t\t\t/// A user provides a input that should be between 0 and `FIXED_ONE` but isn't.\n\t\t\t\t\t0: \"Flatness Not Normalized\",\n\t\t\t\t\t/// A user attempts to create a Pool with a `flatness` parameter we do not support yet.\n\t\t\t\t\t1: \"Flatness Not Supported\",\n\t\t\t\t\t/// A user attempts to create a pool with weights that don't sum to `FIXED_ONE`.\n\t\t\t\t\t2: \"Weights Not Normalized\",\n\t\t\t\t\t/// A user attempts to create a Pool with an individual weight outside of the\n\t\t\t\t\t/// range [MIN_WEIGHT, MAX_WEIGHT].\n\t\t\t\t\t3: \"Invalid Weight\",\n\t\t\t\t\t/// A user attempts to create a Pool with an individual fee outside of the\n\t\t\t\t\t/// range [MIN_FEE, MAX_FEE].\n\t\t\t\t\t4: \"Invalid Fee\",\n\t\t\t\t\t/// A user provides an input vector (with length m != n) for a pool of size n.\n\t\t\t\t\t5: \"Bad Vector Length\",\n\t\t\t\t\t/// A user tries to create a Pool but provides an initial deposit that equates to less than\n\t\t\t\t\t/// `MIN_LP_SUPPLY` worth of LP Coins.\n\t\t\t\t\t6: \"Not Enough Initial Liquidity\",\n\t\t\t\t\t/// A user attempts to create a Pool with an LP `TreasuryCap` that has already minted Coins.\n\t\t\t\t\t7: \"Non Zero Total Supply\",\n\t\t\t\t\t/// A user attempts to interact with the Pool and specifies a type that isn't in the Pool.\n\t\t\t\t\t8: \"Bad Type\",\n\t\t\t\t\t/// A user attempts to create a pool with invalid decimal scalars\n\t\t\t\t\t9: \"Bad Decimals\",\n\t\t\t\t\t/// A user attempts to create a pool with type names which are not sorted\n\t\t\t\t\t10: \"Not Sorted\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.poolRegistry]: {\n\t\t\t\t\t/// A user tries to create a Pool and the generic parameters of `create_pool_n_coins` were\n\t\t\t\t\t/// provided in nonlexicographical order.\n\t\t\t\t\t60: \"Not Sorted\",\n\t\t\t\t\t/// A user tries to create a Pool with exact parameters as an already active Pool.\n\t\t\t\t\t61: \"Duplicate Pool\",\n\t\t\t\t\t/// A user tries to upgrade the `PoolRegistry` to a value\n\t\t\t\t\t62: \"Invalid Upgrade\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.deposit]: {\n\t\t\t\t\t/// A user attempts to perform a `deposit` with an older contract.\n\t\t\t\t\t20: \"Invalid Protocol Version\",\n\t\t\t\t\t/// A user attempts to perform `deposit-n-coins` on a Pool with a size `m` < `n`.\n\t\t\t\t\t21: \"Invalid Pool Size\",\n\t\t\t\t\t/// A user attempts to perform a deposit and provides a coin with a value of zero.\n\t\t\t\t\t22: \"Zero Value\",\n\t\t\t\t\t// A user calls `deposit_n_coins` or `all_coin_deposit_n_coins` and provides the same generic\n\t\t\t\t\t// at least twice.\n\t\t\t\t\t23: \"Duplicate Types\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.poolFactory]: {\n\t\t\t\t\t/// A user attempts to create a pool on an older contract.\n\t\t\t\t\t10: \"Invalid Protocol Version\",\n\t\t\t\t\t/// A user attempts to create a Pool and provides a coin with a value of zero.\n\t\t\t\t\t11: \"Zero Value\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.price]: {\n\t\t\t\t\t/// A user attempts to query spot/oracle price using an old contract.\n\t\t\t\t\t10: \"Invalid Protocol Version\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.swap]: {\n\t\t\t\t\t/// A user attempts to perform a `swap` with an older contract.\n\t\t\t\t\t40: \"Invalid Protocol Version\",\n\t\t\t\t\t/// A user attempts to perform `multi-swap-exact-in/out-n-to-m` on a Pool with a size\n\t\t\t\t\t/// `s` < `n` + `m`.\n\t\t\t\t\t41: \"Invalid Pool Size\",\n\t\t\t\t\t/// A user attempts to perform swap and providing provides a coin with a\n\t\t\t\t\t/// value of zero.\n\t\t\t\t\t42: \"Zero Value\",\n\t\t\t\t\t/// A user attempts to perform a multi-coin withdraw and provides an `amounts_out`\n\t\t\t\t\t/// vector whose length does\n\t\t\t\t\t43: \"Bad Vector Length\",\n\t\t\t\t\t/// A user attempts to swap attempts to swap `Coin<CI>` for `amount_out` of `Coin<CO>`\n\t\t\t\t\t/// but its value is insufficient.\n\t\t\t\t\t44: \"Insufficient Coin In\",\n\t\t\t\t\t// A user calls `multi_swap_exact_in_1_to_n` or `multi_swap_exact_out_1_to_n` and provides the same\n\t\t\t\t\t// generic at least twice.\n\t\t\t\t\t45: \"Duplicate Types\",\n\t\t\t\t\t/// Something went wrong with the internal calculations\n\t\t\t\t\t46: \"Internal Error\",\n\t\t\t\t\t/// An external app is trying to call authorized functions without permission.\n\t\t\t\t\t47: \"Not Authorized\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.withdraw]: {\n\t\t\t\t\t/// A user attempts to perform a `withdraw` with an older contract.\n\t\t\t\t\t30: \"Invalid Protocol Version\",\n\t\t\t\t\t/// A user attempts to perform `withdraw-n-coins` on a Pool with a size `m` < `n`.\n\t\t\t\t\t31: \"Invalid PoolSize\",\n\t\t\t\t\t/// A user attempts to perform a withdraw and provides an LP coin with a value of zero.\n\t\t\t\t\t32: \"Zero Value\",\n\t\t\t\t\t/// A user attempts to perform a multi-coin withdraw and provides an `amounts_out`\n\t\t\t\t\t/// vector whose length does\n\t\t\t\t\t33: \"Bad Vector Length\",\n\t\t\t\t\t// A user calls `withdraw_n_coins` or `all_coin_withdraw_n_coins` and provides the same generic\n\t\t\t\t\t// at least twice.\n\t\t\t\t\t34: \"Duplicate Types\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.math]: {\n\t\t\t\t\t// TODO: change error code in move\n\n\t\t\t\t\t/// A user tries to create a Pool that would result in the Pool's invariant equalling zero.\n\t\t\t\t\t// 51: \"ZeroInvariant\",\n\n\t\t\t\t\t/// A user tries to perform an action with the Pool that results in too much slippage.\n\t\t\t\t\t51: \"Slippage\",\n\t\t\t\t\t/// A user tries to perform a swap that would result in more than `MAX_SWAP_AMOUNT_IN` worth of\n\t\t\t\t\t/// one of the Pool's coins entering the Pool.\n\t\t\t\t\t52: \"Invalid Swap Amount In\",\n\t\t\t\t\t/// A user tries to perform a swap that would result in more than `MAX_SWAP_AMOUNT_OUT` worth of\n\t\t\t\t\t/// one of the Pool's coins exiting the Pool.\n\t\t\t\t\t53: \"Invalid Swap Amount Out\",\n\t\t\t\t\t/// A user tries to perform a `swap_exact_out` with a value for `amount_out` that equates to\n\t\t\t\t\t/// zero amount of `Coin<CI>`.\n\t\t\t\t\t54: \"Zero Amount In\",\n\t\t\t\t\t/// A user tries to perform a `swap_exact_in` with an amount of `Coin<CI>` that equates to\n\t\t\t\t\t/// zero amount of `Coin<CO>`.\n\t\t\t\t\t55: \"Zero Amount Out\",\n\t\t\t\t\t/// A user tries to deposit into a Pool with a deposit that is worth zero LP coins.\n\t\t\t\t\t56: \"Zero Lp Out\",\n\t\t\t\t\t/// A user tries to invest with an lp ratio of 0\n\t\t\t\t\t57: \"Zero Lp Ratio\",\n\t\t\t\t},\n\t\t\t\t[PoolsApi.constants.moduleNames.geometricMeanCalculations]: {},\n\t\t\t\t[PoolsApi.constants.moduleNames.stableCalculations]: {},\n\t\t\t},\n\t\t\t...(this.addresses.daoFeePools\n\t\t\t\t? {\n\t\t\t\t\t\t[this.addresses.daoFeePools.packages.amm]: {\n\t\t\t\t\t\t\tversion: {\n\t\t\t\t\t\t\t\t/// A user tried to interact with an old contract.\n\t\t\t\t\t\t\t\t0: \"Invalid Version\",\n\t\t\t\t\t\t\t\t/// `init_package_version` has been called outside of this packages `init` function.\n\t\t\t\t\t\t\t\t1: \"Version Object Already Created\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\tpublic fetchOwnedDaoFeePoolOwnerCaps = async (\n\t\tinputs: ApiPoolsOwnedDaoFeePoolOwnerCapsBody\n\t): Promise<DaoFeePoolOwnerCapObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tif (!this.objectTypes.daoFeePoolOwnerCap)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\treturn this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\twalletAddress,\n\t\t\tobjectType: this.objectTypes.daoFeePoolOwnerCap,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tCasting.pools.daoFeePoolOwnerCapObjectFromSuiObjectResponse,\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * Executes a trade transaction on the specified pool.\n\t * @param inputs An object containing the necessary inputs for the trade transaction.\n\t * @returns A `TransactionObjectArgument` representing the trade transaction.\n\t */\n\tpublic tradeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tpoolId: ObjectId;\n\t\tcoinInId: ObjectId | TransactionObjectArgument;\n\t\tcoinInType: CoinType;\n\t\texpectedCoinOutAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\tlpCoinType: CoinType;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}): TransactionObjectArgument => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tpoolId,\n\t\t\tcoinInId,\n\t\t\tcoinInType,\n\t\t\texpectedCoinOutAmount,\n\t\t\tcoinOutType,\n\t\t\tlpCoinType,\n\t\t\tslippage,\n\t\t\twithTransfer,\n\t\t} = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\twithTransfer\n\t\t\t\t\t? this.addresses.pools.packages.ammInterface\n\t\t\t\t\t: this.addresses.pools.packages.amm,\n\t\t\t\twithTransfer\n\t\t\t\t\t? PoolsApi.constants.moduleNames.interface\n\t\t\t\t\t: PoolsApi.constants.moduleNames.swap,\n\t\t\t\t\"swap_exact_in\"\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, coinInType, coinOutType],\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\ttypeof coinInId === \"string\" ? tx.object(coinInId) : coinInId,\n\t\t\t\ttx.pure.u64(expectedCoinOutAmount.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction object argument for depositing multiple coins into a pool.\n\t *\n\t * @param inputs - An object containing the necessary parameters for the deposit transaction.\n\t * @returns A transaction object argument representing the deposit transaction.\n\t */\n\tpublic multiCoinDepositTx = (inputs: {\n\t\ttx: Transaction;\n\t\tpoolId: ObjectId;\n\t\tcoinIds: ObjectId[] | TransactionObjectArgument[];\n\t\tcoinTypes: CoinType[];\n\t\texpectedLpRatio: bigint;\n\t\tlpCoinType: CoinType;\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}): TransactionObjectArgument => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tpoolId,\n\t\t\tcoinIds,\n\t\t\tcoinTypes,\n\t\t\texpectedLpRatio,\n\t\t\tlpCoinType,\n\t\t\tslippage,\n\t\t\twithTransfer,\n\t\t} = inputs;\n\n\t\tconst poolSize = coinTypes.length;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\twithTransfer\n\t\t\t\t\t? this.addresses.pools.packages.ammInterface\n\t\t\t\t\t: this.addresses.pools.packages.amm,\n\t\t\t\twithTransfer\n\t\t\t\t\t? PoolsApi.constants.moduleNames.interface\n\t\t\t\t\t: PoolsApi.constants.moduleNames.deposit,\n\t\t\t\t`deposit_${poolSize}_coins`\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\t...coinIds.map((coinId) =>\n\t\t\t\t\ttypeof coinId === \"string\" ? tx.object(coinId) : coinId\n\t\t\t\t),\n\t\t\t\ttx.pure.u128(expectedLpRatio.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Withdraws multiple coins from a pool.\n\t * @param inputs An object containing the necessary parameters for the transaction.\n\t * @returns A TransactionObjectArgument representing the transaction.\n\t */\n\tpublic multiCoinWithdrawTx = (inputs: {\n\t\ttx: Transaction;\n\t\tpoolId: ObjectId;\n\t\tlpCoinId: ObjectId | TransactionObjectArgument;\n\t\tlpCoinType: CoinType;\n\t\texpectedAmountsOut: Balance[];\n\t\tcoinTypes: CoinType[];\n\t\tslippage: Slippage;\n\t\twithTransfer?: boolean;\n\t}): TransactionObjectArgument => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tpoolId,\n\t\t\tlpCoinId,\n\t\t\texpectedAmountsOut,\n\t\t\tcoinTypes,\n\t\t\tlpCoinType,\n\t\t\tslippage,\n\t\t\twithTransfer,\n\t\t} = inputs;\n\n\t\tconst poolSize = coinTypes.length;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\twithTransfer\n\t\t\t\t\t? this.addresses.pools.packages.ammInterface\n\t\t\t\t\t: this.addresses.pools.packages.amm,\n\t\t\t\twithTransfer\n\t\t\t\t\t? PoolsApi.constants.moduleNames.interface\n\t\t\t\t\t: PoolsApi.constants.moduleNames.withdraw,\n\t\t\t\t`withdraw_${poolSize}_coins`\n\t\t\t),\n\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\ttypeof lpCoinId === \"string\" ? tx.object(lpCoinId) : lpCoinId,\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(\n\t\t\t\t\t\t\texpectedAmountsOut.map((amount) =>\n\t\t\t\t\t\t\t\tamount.toString()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Withdraws all coins from a liquidity pool.\n\t * @param inputs - The inputs required for the transaction.\n\t * @param inputs.tx - The transaction block.\n\t * @param inputs.poolId - The ID of the liquidity pool.\n\t * @param inputs.lpCoinId - The ID of the LP coin.\n\t * @param inputs.lpCoinType - The type of the LP coin.\n\t * @param inputs.coinTypes - An array of coin types.\n\t * @param inputs.withTransfer - Whether or not to include a transfer.\n\t * @returns An array of transaction objects.\n\t */\n\tpublic allCoinWithdrawTx = (inputs: {\n\t\ttx: Transaction;\n\t\tpoolId: ObjectId;\n\t\tlpCoinId: ObjectId | TransactionObjectArgument;\n\t\tlpCoinType: CoinType;\n\t\tcoinTypes: CoinType[];\n\t\twithTransfer?: boolean;\n\t}): TransactionObjectArgument[] => {\n\t\tconst { tx, poolId, lpCoinId, coinTypes, lpCoinType, withTransfer } =\n\t\t\tinputs;\n\n\t\tconst poolSize = coinTypes.length;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\twithTransfer\n\t\t\t\t\t? this.addresses.pools.packages.ammInterface\n\t\t\t\t\t: this.addresses.pools.packages.amm,\n\t\t\t\twithTransfer\n\t\t\t\t\t? PoolsApi.constants.moduleNames.interface\n\t\t\t\t\t: PoolsApi.constants.moduleNames.withdraw,\n\t\t\t\t`all_coin_withdraw_${poolSize}_coins`\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttx.object(poolId),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\ttypeof lpCoinId === \"string\" ? tx.object(lpCoinId) : lpCoinId,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Publishes a transaction block for creating a liquidity pool coin.\n\t * @param inputs An object containing the transaction block and the decimal value of the liquidity pool coin.\n\t * @returns A promise that resolves to the result of the transaction publishing.\n\t */\n\tpublic publishLpCoinTx = (inputs: {\n\t\ttx: Transaction;\n\t\tlpCoinDecimals: CoinDecimal;\n\t}) => {\n\t\tconst compilations =\n\t\t\tthis.addresses.pools.other?.createLpCoinPackageCompilations;\n\t\tif (!compilations)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider for lp coin publishing (requires package compilations)\"\n\t\t\t);\n\n\t\tconst { tx, lpCoinDecimals } = inputs;\n\t\tconst compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);\n\n\t\treturn tx.publish({\n\t\t\tmodules: compiledModulesAndDeps.modules.map((m: any) =>\n\t\t\t\tArray.from(fromBase64(m))\n\t\t\t),\n\t\t\tdependencies: compiledModulesAndDeps.dependencies.map(\n\t\t\t\t(addr: string) => normalizeSuiObjectId(addr)\n\t\t\t),\n\t\t});\n\t};\n\n\t// TODO: handle bounds checks here instead of just on-chain ?\n\t/**\n\t * Creates a transaction to create a new pool.\n\t * @param inputs - An object containing the necessary inputs to create the pool.\n\t * @returns A transaction block to create the pool.\n\t */\n\tpublic createPoolTx = (inputs: {\n\t\ttx: Transaction;\n\t\tlpCoinType: CoinType;\n\t\tcoinsInfo: {\n\t\t\tcoinId: ObjectId | TransactionObjectArgument;\n\t\t\tcoinType: CoinType;\n\t\t\tweight: PoolWeight;\n\t\t\tdecimals?: CoinDecimal;\n\t\t\ttradeFeeIn: PoolTradeFee;\n\t\t\ttradeFeeOut: PoolTradeFee;\n\t\t\tdepositFee: PoolDepositFee;\n\t\t\twithdrawFee: PoolWithdrawFee;\n\t\t}[];\n\t\tlpCoinMetadata: PoolCreationLpCoinMetadata;\n\t\tlpCoinIconUrl: Url;\n\t\tcreatePoolCapId: ObjectId | TransactionObjectArgument;\n\t\tpoolName: PoolName;\n\t\tpoolFlatness: PoolFlatness;\n\t\tlpCoinDescription: string;\n\t\trespectDecimals: boolean;\n\t\tforceLpDecimals?: CoinDecimal;\n\t\twithTransfer?: boolean;\n\t}): TransactionObjectArgument[] /* (Pool<L>, Coin<L>) */ => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tlpCoinType,\n\t\t\tcreatePoolCapId,\n\t\t\tcoinsInfo,\n\t\t\tlpCoinMetadata,\n\t\t\tlpCoinDescription,\n\t\t\tlpCoinIconUrl,\n\t\t\twithTransfer,\n\t\t} = inputs;\n\n\t\tconst poolSize = coinsInfo.length;\n\t\tconst coinTypes = coinsInfo.map((coin) => coin.coinType);\n\t\tconst decimals = coinsInfo.map((coin) => coin.decimals);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\twithTransfer\n\t\t\t\t\t? this.addresses.pools.packages.ammInterface\n\t\t\t\t\t: this.addresses.pools.packages.amm,\n\t\t\t\twithTransfer\n\t\t\t\t\t? PoolsApi.constants.moduleNames.interface\n\t\t\t\t\t: PoolsApi.constants.moduleNames.poolFactory,\n\t\t\t\t`create_pool_${poolSize}_coins`\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttypeof createPoolCapId === \"string\"\n\t\t\t\t\t? tx.object(createPoolCapId)\n\t\t\t\t\t: createPoolCapId,\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u8())\n\t\t\t\t\t\t.serialize(Casting.u8VectorFromString(inputs.poolName))\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u8())\n\t\t\t\t\t\t.serialize(\n\t\t\t\t\t\t\tCasting.u8VectorFromString(\n\t\t\t\t\t\t\t\tlpCoinMetadata.name.toString()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u8())\n\t\t\t\t\t\t.serialize(\n\t\t\t\t\t\t\tCasting.u8VectorFromString(\n\t\t\t\t\t\t\t\tlpCoinMetadata.symbol.toString().toUpperCase()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u8())\n\t\t\t\t\t\t.serialize(\n\t\t\t\t\t\t\tCasting.u8VectorFromString(lpCoinDescription)\n\t\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u8())\n\t\t\t\t\t\t.serialize(Casting.u8VectorFromString(lpCoinIconUrl))\n\t\t\t\t), // lp_icon_url\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(coinsInfo.map((coin) => coin.weight))\n\t\t\t\t),\n\t\t\t\ttx.pure.u64(inputs.poolFlatness),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(coinsInfo.map((coin) => coin.tradeFeeIn))\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(coinsInfo.map((coin) => coin.tradeFeeOut))\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(coinsInfo.map((coin) => coin.depositFee))\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.vector(bcs.u64())\n\t\t\t\t\t\t.serialize(coinsInfo.map((coin) => coin.withdrawFee))\n\t\t\t\t),\n\t\t\t\t...coinsInfo.map((coin) =>\n\t\t\t\t\ttypeof coin.coinId === \"string\"\n\t\t\t\t\t\t? tx.object(coin.coinId)\n\t\t\t\t\t\t: coin.coinId\n\t\t\t\t),\n\t\t\t\ttx.pure(\n\t\t\t\t\tbcs\n\t\t\t\t\t\t.option(bcs.vector(bcs.u8()))\n\t\t\t\t\t\t.serialize(\n\t\t\t\t\t\t\tdecimals.includes(undefined)\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: (decimals as number[])\n\t\t\t\t\t\t)\n\t\t\t\t), // decimals\n\t\t\t\ttx.pure.bool(inputs.respectDecimals), // respect_decimals\n\t\t\t\ttx.pure(bcs.option(bcs.u8()).serialize(inputs.forceLpDecimals)), // force_lp_decimals\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Returns the pool object ID for a given LP coin type transaction.\n\t * @param inputs - An object containing the transaction block and LP coin type.\n\t * @returns The pool object ID.\n\t */\n\tpublic poolObjectIdForLpCoinTypeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tlpCoinType: CoinType;\n\t}) => {\n\t\tconst { tx, lpCoinType } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.pools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.poolRegistry,\n\t\t\t\t\"lp_type_to_pool_id\"\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType],\n\t\t\targuments: [tx.object(this.addresses.pools.objects.poolRegistry)],\n\t\t});\n\t};\n\n\tpublic daoFeePoolNewTx = (inputs: {\n\t\ttx: Transaction;\n\t\tpoolId: ObjectId | TransactionObjectArgument;\n\t\tfeeBps: bigint;\n\t\tfeeRecipient: SuiAddress;\n\t\tlpCoinType: CoinType;\n\t}) /* (DaoFeePool, OwnerCap) */ => {\n\t\tconst { tx, poolId } = inputs;\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.pool,\n\t\t\t\t\"new\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.lpCoinType],\n\t\t\targuments: [\n\t\t\t\ttypeof poolId === \"string\" ? tx.object(poolId) : poolId, // Pool\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.pure.u16(Number(inputs.feeBps)),\n\t\t\t\ttx.pure.address(inputs.feeRecipient),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic daoFeePoolUpdateFeeBpsTx = (inputs: {\n\t\ttx: Transaction;\n\t\tdaoFeePoolOwnerCapId: ObjectId;\n\t\tdaoFeePoolId: ObjectId;\n\t\tnewFeeBps: bigint;\n\t\tlpCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.pool,\n\t\t\t\t\"update_fee_bps\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.lpCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.daoFeePoolOwnerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.daoFeePoolId), // DaoFeePool\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.pure.u16(Number(inputs.newFeeBps)),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic daoFeePoolUpdateFeeRecipientTx = (inputs: {\n\t\ttx: Transaction;\n\t\tdaoFeePoolOwnerCapId: ObjectId;\n\t\tdaoFeePoolId: ObjectId;\n\t\tnewFeeRecipient: SuiAddress;\n\t\tlpCoinType: CoinType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.pool,\n\t\t\t\t\"update_fee_recipient\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.lpCoinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.daoFeePoolOwnerCapId), // OwnerCap\n\t\t\t\ttx.object(inputs.daoFeePoolId), // DaoFeePool\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.pure.address(inputs.newFeeRecipient),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Executes a trade transaction on the specified pool.\n\t * @param inputs An object containing the necessary inputs for the trade transaction.\n\t * @returns A `TransactionObjectArgument` representing the trade transaction.\n\t */\n\tpublic daoFeePoolTradeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tdaoFeePoolId: ObjectId;\n\t\tcoinInId: ObjectId | TransactionObjectArgument;\n\t\tcoinInType: CoinType;\n\t\texpectedCoinOutAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\tlpCoinType: CoinType;\n\t\tslippage: Slippage;\n\t}): TransactionObjectArgument => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tdaoFeePoolId,\n\t\t\tcoinInId,\n\t\t\tcoinInType,\n\t\t\texpectedCoinOutAmount,\n\t\t\tcoinOutType,\n\t\t\tlpCoinType,\n\t\t\tslippage,\n\t\t} = inputs;\n\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.swap,\n\t\t\t\t\"swap_exact_in\"\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, coinInType, coinOutType],\n\t\t\targuments: [\n\t\t\t\ttx.object(daoFeePoolId),\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\ttypeof coinInId === \"string\" ? tx.object(coinInId) : coinInId,\n\t\t\t\ttx.pure.u64(expectedCoinOutAmount.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Creates a transaction object argument for depositing multiple coins into a pool.\n\t *\n\t * @param inputs - An object containing the necessary parameters for the deposit transaction.\n\t * @returns A transaction object argument representing the deposit transaction.\n\t */\n\tpublic daoFeePoolMultiCoinDepositTx = (inputs: {\n\t\ttx: Transaction;\n\t\tdaoFeePoolId: ObjectId;\n\t\tcoinIds: ObjectId[] | TransactionObjectArgument[];\n\t\tcoinTypes: CoinType[];\n\t\texpectedLpRatio: bigint;\n\t\tlpCoinType: CoinType;\n\t\tslippage: Slippage;\n\t}): TransactionObjectArgument => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tdaoFeePoolId,\n\t\t\tcoinIds,\n\t\t\tcoinTypes,\n\t\t\texpectedLpRatio,\n\t\t\tlpCoinType,\n\t\t\tslippage,\n\t\t} = inputs;\n\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\tconst poolSize = coinTypes.length;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.deposit,\n\t\t\t\t`deposit_${poolSize}_coins`\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttx.object(daoFeePoolId),\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\t...coinIds.map((coinId) =>\n\t\t\t\t\ttypeof coinId === \"string\" ? tx.object(coinId) : coinId\n\t\t\t\t),\n\t\t\t\ttx.pure.u128(expectedLpRatio.toString()),\n\t\t\t\ttx.pure.u64(Pools.normalizeInvertSlippage(slippage)),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Withdraws all coins from a liquidity pool.\n\t * @param inputs - The inputs required for the transaction.\n\t * @param inputs.tx - The transaction block.\n\t * @param inputs.poolId - The ID of the liquidity pool.\n\t * @param inputs.lpCoinId - The ID of the LP coin.\n\t * @param inputs.lpCoinType - The type of the LP coin.\n\t * @param inputs.coinTypes - An array of coin types.\n\t * @returns An array of transaction objects.\n\t */\n\tpublic daoFeePoolAllCoinWithdrawTx = (inputs: {\n\t\ttx: Transaction;\n\t\tdaoFeePoolId: ObjectId;\n\t\tlpCoinId: ObjectId | TransactionObjectArgument;\n\t\tlpCoinType: CoinType;\n\t\tcoinTypes: CoinType[];\n\t}): TransactionObjectArgument[] => {\n\t\tconst { tx, daoFeePoolId, lpCoinId, coinTypes, lpCoinType } = inputs;\n\n\t\tif (!this.addresses.daoFeePools)\n\t\t\tthrow new Error(\n\t\t\t\t\"dao fee pool addresses have not been set in provider\"\n\t\t\t);\n\n\t\tconst poolSize = coinTypes.length;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.daoFeePools.packages.amm,\n\t\t\t\tPoolsApi.constants.moduleNames.withdraw,\n\t\t\t\t`all_coin_withdraw_${poolSize}_coins`\n\t\t\t),\n\t\t\ttypeArguments: [lpCoinType, ...coinTypes],\n\t\t\targuments: [\n\t\t\t\ttx.object(daoFeePoolId),\n\t\t\t\ttx.object(this.addresses.daoFeePools.objects.version),\n\t\t\t\ttx.object(this.addresses.pools.objects.poolRegistry),\n\t\t\t\ttx.object(this.addresses.pools.objects.protocolFeeVault),\n\t\t\t\ttx.object(this.addresses.pools.objects.treasury),\n\t\t\t\ttx.object(this.addresses.pools.objects.insuranceFund),\n\t\t\t\ttx.object(this.addresses.referralVault.objects.referralVault),\n\t\t\t\ttypeof lpCoinId === \"string\" ? tx.object(lpCoinId) : lpCoinId,\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\t/**\n\t * Fetches a transaction block for trading in a pool.\n\t * @async\n\t * @param {SuiAddress} inputs.walletAddress - The wallet address of the user trading in the pool.\n\t * @param {Pool} inputs.pool - The pool to trade in.\n\t * @param {CoinType} inputs.coinInType - The coin type of the coin being traded in.\n\t * @param {Balance} inputs.coinInAmount - The amount of the coin being traded in.\n\t * @param {CoinType} inputs.coinOutType - The coin type of the coin being traded out.\n\t * @param {Slippage} inputs.slippage - The slippage of the trade.\n\t * @param {SuiAddress} [inputs.referrer] - The referrer of the trade.\n\t * @param {boolean} [inputs.isSponsoredTx] - Whether the transaction is sponsored.\n\t * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block.\n\t */\n\tpublic fetchBuildTradeTx = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tpool: Pool;\n\t\tcoinInType: CoinType;\n\t\tcoinInAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t\tisSponsoredTx?: boolean;\n\t}): Promise<Transaction> => {\n\t\tconst {\n\t\t\twalletAddress,\n\t\t\tpool,\n\t\t\tcoinInAmount,\n\t\t\tcoinInType,\n\t\t\tcoinOutType,\n\t\t\tslippage,\n\t\t\treferrer,\n\t\t\tisSponsoredTx,\n\t\t} = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst amountOut = pool.getTradeAmountOut({\n\t\t\tcoinInAmount,\n\t\t\tcoinInType,\n\t\t\tcoinOutType,\n\t\t\treferral: referrer !== undefined,\n\t\t});\n\n\t\tconst coinInId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: coinInType,\n\t\t\tcoinAmount: coinInAmount,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tif (pool.pool.daoFeePoolObject) {\n\t\t\tconst coinOutId = this.daoFeePoolTradeTx({\n\t\t\t\ttx,\n\t\t\t\tcoinInId,\n\t\t\t\tdaoFeePoolId: pool.pool.daoFeePoolObject.objectId,\n\t\t\t\texpectedCoinOutAmount: amountOut,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinInType,\n\t\t\t\tcoinOutType,\n\t\t\t\tslippage,\n\t\t\t});\n\t\t\ttx.transferObjects([coinOutId], walletAddress);\n\t\t} else {\n\t\t\tthis.tradeTx({\n\t\t\t\ttx,\n\t\t\t\tcoinInId,\n\t\t\t\tpoolId: pool.pool.objectId,\n\t\t\t\texpectedCoinOutAmount: amountOut,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinInType,\n\t\t\t\tcoinOutType,\n\t\t\t\tslippage,\n\t\t\t\twithTransfer: true,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\tpublic fetchAddTradeTx = async (inputs: {\n\t\ttx: Transaction;\n\t\tcoinInId: ObjectId | TransactionObjectArgument;\n\t\tcoinInType: CoinType;\n\t\tcoinInAmount: Balance;\n\t\tcoinOutType: CoinType;\n\t\tslippage: Slippage;\n\t\tpool: Pool;\n\t\treferrer?: SuiAddress;\n\t}): Promise<TransactionObjectArgument> /* Coin */ => {\n\t\tconst {\n\t\t\ttx,\n\t\t\tcoinInId,\n\t\t\tcoinInAmount,\n\t\t\tcoinInType,\n\t\t\tcoinOutType,\n\t\t\tslippage,\n\t\t\tpool,\n\t\t\treferrer,\n\t\t} = inputs;\n\n\t\tconst amountOut = pool.getTradeAmountOut({\n\t\t\tcoinInAmount,\n\t\t\tcoinInType,\n\t\t\tcoinOutType,\n\t\t\treferral: referrer !== undefined,\n\t\t});\n\n\t\treturn this.tradeTx({\n\t\t\ttx,\n\t\t\tcoinInId,\n\t\t\tpoolId: pool.pool.objectId,\n\t\t\texpectedCoinOutAmount: amountOut,\n\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\tcoinInType,\n\t\t\tcoinOutType,\n\t\t\tslippage,\n\t\t});\n\t};\n\n\t/**\n\t * Fetches a transaction block for depositing in a pool.\n\t * @async\n\t * @param {SuiAddress} inputs.walletAddress - The wallet address of the user depositing in the pool.\n\t * @param {Pool} inputs.pool - The pool to deposit in.\n\t * @param {CoinsToBalance} inputs.amountsIn - The amounts of coins being deposited.\n\t * @param {Slippage} inputs.slippage - The slippage of the deposit.\n\t * @param {SuiAddress} [inputs.referrer] - The referrer of the deposit.\n\t * @param {boolean} [inputs.isSponsoredTx] - Whether the transaction is sponsored.\n\t * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block.\n\t */\n\tpublic fetchBuildDepositTx = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tpool: Pool;\n\t\tamountsIn: CoinsToBalance;\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t\tisSponsoredTx?: boolean;\n\t}): Promise<Transaction> => {\n\t\tconst {\n\t\t\twalletAddress,\n\t\t\tpool,\n\t\t\tamountsIn,\n\t\t\tslippage,\n\t\t\treferrer,\n\t\t\tisSponsoredTx,\n\t\t} = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst { coins: coinTypes, balances: coinAmounts } =\n\t\t\tCoin.coinsAndBalancesOverZero(amountsIn);\n\n\t\tconst { lpRatio } = pool.getDepositLpAmountOut({\n\t\t\tamountsIn,\n\t\t\treferral: referrer !== undefined,\n\t\t});\n\n\t\t// TODO: move this somewhere else and into its own func\n\t\tconst expectedLpRatio = Casting.numberToFixedBigInt(lpRatio);\n\n\t\tconst coinIds = await this.Provider.Coin().fetchCoinsWithAmountTx({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tcoinTypes,\n\t\t\tcoinAmounts,\n\t\t\tisSponsoredTx,\n\t\t});\n\n\t\tif (pool.pool.daoFeePoolObject) {\n\t\t\tconst lpCoinId = this.daoFeePoolMultiCoinDepositTx({\n\t\t\t\ttx,\n\t\t\t\tdaoFeePoolId: pool.pool.daoFeePoolObject.objectId,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinIds,\n\t\t\t\tcoinTypes,\n\t\t\t\texpectedLpRatio,\n\t\t\t\tslippage,\n\t\t\t});\n\t\t\ttx.transferObjects([lpCoinId], walletAddress);\n\t\t} else {\n\t\t\tthis.multiCoinDepositTx({\n\t\t\t\ttx,\n\t\t\t\tpoolId: pool.pool.objectId,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinIds,\n\t\t\t\tcoinTypes,\n\t\t\t\texpectedLpRatio,\n\t\t\t\tslippage,\n\t\t\t\twithTransfer: true,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Fetches a transaction block for withdrawing from a pool.\n\t * @async\n\t * @param {SuiAddress} inputs.walletAddress - The wallet address of the user withdrawing from the pool.\n\t * @param {Pool} inputs.pool - The pool to withdraw from.\n\t * @param {CoinsToBalance} inputs.amountsOutDirection - The amounts of coins being withdrawn.\n\t * @param {Balance} inputs.lpCoinAmount - The amount of LP tokens being withdrawn.\n\t * @param {Slippage} inputs.slippage - The slippage of the withdrawal.\n\t * @param {SuiAddress} [inputs.referrer] - The referrer of the withdrawal.\n\t * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block.\n\t */\n\tpublic fetchBuildWithdrawTx = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tpool: Pool;\n\t\tamountsOutDirection: CoinsToBalance;\n\t\tlpCoinAmount: Balance;\n\t\tslippage: Slippage;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst {\n\t\t\twalletAddress,\n\t\t\tpool,\n\t\t\tamountsOutDirection,\n\t\t\tlpCoinAmount,\n\t\t\tslippage,\n\t\t\treferrer,\n\t\t} = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst lpRatio = pool.getMultiCoinWithdrawLpRatio({\n\t\t\tlpCoinAmountIn: lpCoinAmount,\n\t\t});\n\n\t\tconst amountsOut = pool.getWithdrawAmountsOut({\n\t\t\tlpRatio,\n\t\t\tamountsOutDirection,\n\t\t\treferral: referrer !== undefined,\n\t\t});\n\n\t\tconst { coins: coinTypes, balances: coinAmounts } =\n\t\t\tCoin.coinsAndBalancesOverZero(amountsOut);\n\n\t\tconst lpCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: pool.pool.lpCoinType,\n\t\t\tcoinAmount: lpCoinAmount,\n\t\t});\n\n\t\tif (pool.pool.daoFeePoolObject) {\n\t\t\t// TODO: handle dao fee pool\n\t\t\t// TODO: handle transfer\n\t\t} else {\n\t\t\tthis.multiCoinWithdrawTx({\n\t\t\t\ttx,\n\t\t\t\tpoolId: pool.pool.objectId,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\texpectedAmountsOut: coinAmounts,\n\t\t\t\tcoinTypes: coinTypes,\n\t\t\t\tlpCoinId,\n\t\t\t\tslippage,\n\t\t\t\twithTransfer: true,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Fetches a transaction block that withdraws all coins from a pool in exchange for the corresponding LP tokens.\n\t * @param inputs An object containing the wallet address, pool, LP coin amount, and optional referrer.\n\t * @returns A promise that resolves to a Transaction object.\n\t */\n\tpublic fetchBuildAllCoinWithdrawTx = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tpool: Pool;\n\t\tlpCoinAmount: Balance;\n\t\treferrer?: SuiAddress;\n\t}): Promise<Transaction> => {\n\t\tconst { walletAddress, pool, lpCoinAmount, referrer } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst lpCoinId = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress,\n\t\t\tcoinType: pool.pool.lpCoinType,\n\t\t\tcoinAmount: lpCoinAmount,\n\t\t});\n\n\t\tconst coinTypes = Object.keys(pool.pool.coins);\n\n\t\tif (pool.pool.daoFeePoolObject) {\n\t\t\tconst withdrawnCoinIds = this.daoFeePoolAllCoinWithdrawTx({\n\t\t\t\ttx,\n\t\t\t\tdaoFeePoolId: pool.pool.daoFeePoolObject.objectId,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinTypes,\n\t\t\t\tlpCoinId,\n\t\t\t});\n\t\t\ttx.transferObjects(\n\t\t\t\tcoinTypes.map((_, index) => withdrawnCoinIds[index]),\n\t\t\t\twalletAddress\n\t\t\t);\n\t\t} else {\n\t\t\tthis.allCoinWithdrawTx({\n\t\t\t\ttx,\n\t\t\t\tpoolId: pool.pool.objectId,\n\t\t\t\tlpCoinType: pool.pool.lpCoinType,\n\t\t\t\tcoinTypes,\n\t\t\t\tlpCoinId,\n\t\t\t\twithTransfer: true,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds a transaction block for publishing an LP coin.\n\t * @param inputs - The input parameters for the transaction.\n\t * @returns The built transaction block.\n\t */\n\tpublic buildPublishLpCoinTx = (\n\t\tinputs: ApiPublishLpCoinBody\n\t): Transaction => {\n\t\tconst { lpCoinDecimals } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst upgradeCap = this.publishLpCoinTx({ tx, lpCoinDecimals });\n\t\ttx.transferObjects([upgradeCap], inputs.walletAddress);\n\n\t\treturn tx;\n\t};\n\n\tpublic buildDaoFeePoolUpdateFeeBpsTx =\n\t\tHelpers.transactions.createBuildTxFunc(this.daoFeePoolUpdateFeeBpsTx);\n\n\tpublic buildDaoFeePoolUpdateFeeRecipientTx =\n\t\tHelpers.transactions.createBuildTxFunc(\n\t\t\tthis.daoFeePoolUpdateFeeRecipientTx\n\t\t);\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate tradeEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.events,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.swap\n\t\t);\n\n\tprivate depositEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.events,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.deposit\n\t\t);\n\n\tprivate withdrawEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.events,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.withdraw\n\t\t);\n\n\tprivate tradeV2EventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.eventsV2,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.swapV2\n\t\t);\n\n\tprivate depositV2EventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.eventsV2,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.depositV2\n\t\t);\n\n\tprivate withdrawV2EventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.pools.packages.eventsV2,\n\t\t\tPoolsApi.constants.moduleNames.events,\n\t\t\tPoolsApi.constants.eventNames.withdrawV2\n\t\t);\n}\n","import { Transaction } from \"@mysten/sui/transactions\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tBalance,\n\tCoinType,\n\tReferralVaultAddresses,\n\tSuiAddress,\n} from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\n\nexport class ReferralVaultApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\treferralVault: \"referral_vault\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: ReferralVaultAddresses;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.referralVault;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\tpublic updateReferrerTx = (inputs: {\n\t\ttx: Transaction;\n\t\treferrer: SuiAddress;\n\t}) => {\n\t\t// TODO: handle this case better\n\t\t// in try catch in case referrer is invalid address and throws\n\t\ttry {\n\t\t\tconst { tx, referrer } = inputs;\n\n\t\t\tconst txData = tx.getData();\n\t\t\tif (\n\t\t\t\ttxData.sender &&\n\t\t\t\tHelpers.addLeadingZeroesToType(txData.sender) ===\n\t\t\t\t\tHelpers.addLeadingZeroesToType(referrer)\n\t\t\t)\n\t\t\t\treturn;\n\n\t\t\treturn tx.moveCall({\n\t\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\t\tthis.addresses.packages.referralVault,\n\t\t\t\t\tReferralVaultApi.constants.moduleNames.referralVault,\n\t\t\t\t\t\"update_referrer_address\"\n\t\t\t\t),\n\t\t\t\ttypeArguments: [],\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\t\ttx.pure.address(referrer),\n\t\t\t\t],\n\t\t\t});\n\t\t} catch (e) {}\n\t};\n\n\tpublic withdrawRebateTx = (inputs: {\n\t\ttx: Transaction;\n\t\tcoinType: CoinType;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.referralVault,\n\t\t\t\tReferralVaultApi.constants.moduleNames.referralVault,\n\t\t\t\tinputs.withTransfer\n\t\t\t\t\t? \"withdraw_and_transfer\"\n\t\t\t\t\t: \"withdraw_rebate\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.coinType],\n\t\t\targuments: [tx.object(this.addresses.objects.referralVault)],\n\t\t});\n\t};\n\n\tpublic balanceOfRebateTx = (inputs: {\n\t\ttx: Transaction;\n\t\tcoinType: CoinType;\n\t\treferrer: SuiAddress;\n\t}) /* u64 */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.referralVault,\n\t\t\t\tReferralVaultApi.constants.moduleNames.referralVault,\n\t\t\t\t\"balance_of\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.coinType],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttx.pure.address(inputs.referrer),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic referrerForTx = (inputs: {\n\t\ttx: Transaction;\n\t\treferee: SuiAddress;\n\t}) /* Option<address> */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.referralVault,\n\t\t\t\tReferralVaultApi.constants.moduleNames.referralVault,\n\t\t\t\t\"referrer_for\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttx.pure.address(inputs.referee),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic hasReffererTx = (inputs: {\n\t\ttx: Transaction;\n\t\treferee: SuiAddress;\n\t}) /* bool */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.referralVault,\n\t\t\t\tReferralVaultApi.constants.moduleNames.referralVault,\n\t\t\t\t\"has_referrer\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.referralVault),\n\t\t\t\ttx.pure.address(inputs.referee),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic fetchBalanceOfRebate = async (inputs: {\n\t\tcoinType: CoinType;\n\t\treferrer: SuiAddress;\n\t}): Promise<Balance> => {\n\t\tconst tx = new Transaction();\n\t\tthis.balanceOfRebateTx({ ...inputs, tx });\n\t\tconst bytes =\n\t\t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\t\treturn Casting.bigIntFromBytes(bytes);\n\t};\n\n\tpublic fetchReferrer = async (inputs: {\n\t\treferee: SuiAddress;\n\t}): Promise<SuiAddress | undefined> => {\n\t\tconst tx = new Transaction();\n\t\tthis.referrerForTx({ ...inputs, tx });\n\t\tconst bytes =\n\t\t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\n\t\tconst unwrapped = bcs.option(bcs.Address).parse(new Uint8Array(bytes));\n\t\treturn unwrapped ?? undefined;\n\t};\n}\n","import { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tUserEventsInputs,\n\tRouterTradeEvent,\n\tAnyObjectType,\n\tRouterAddresses,\n} from \"../../../types\";\nimport { RouterTradeEventOnChain } from \"./routerApiCastingTypes\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { RouterApiCasting } from \"./routerApiCasting\";\nimport {\n\tMoveErrors,\n\tMoveErrorsInterface,\n} from \"../../../general/types/moveErrorsInterface\";\n\n/**\n * RouterApi class provides methods for interacting with the Aftermath Router API.\n * @class\n */\nexport class RouterApi implements MoveErrorsInterface {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tpublic static readonly constants = {\n\t\tmoduleNames: {\n\t\t\trouter: \"router\",\n\t\t\tevents: \"events\",\n\t\t\tprotocolFee: \"protocol_fee\",\n\t\t\tversion: \"version\",\n\t\t\tadmin: \"admin\",\n\t\t},\n\t\teventNames: {\n\t\t\trouterTrade: \"SwapCompletedEvent\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: RouterAddresses;\n\tpublic readonly eventTypes: {\n\t\trouterTrade: AnyObjectType;\n\t};\n\tpublic readonly moveErrors: MoveErrors;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\t/**\n\t * Creates an instance of RouterApi.\n\t * @constructor\n\t * @param {AftermathApi} Provider - The Aftermath API instance.\n\t */\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tif (!this.Provider.addresses.router)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = this.Provider.addresses.router;\n\t\tthis.eventTypes = {\n\t\t\trouterTrade: this.routerTradeEventType(),\n\t\t};\n\t\tthis.moveErrors = {\n\t\t\t[this.addresses.packages.utils]: {\n\t\t\t\t[RouterApi.constants.moduleNames.protocolFee]: {\n\t\t\t\t\t/// A non-one-time-witness type has been provided to the `ProtocolFeeConfig`'s `create` function.\n\t\t\t\t\t1: \"Protocol Fee Config Already Created\",\n\t\t\t\t\t/// Occurs when `change_fee` is called more than once during the same Epoch.\n\t\t\t\t\t2: \"Bad Epoch\",\n\t\t\t\t\t/// A user provided a new protocol fees that do not sum to one.\n\t\t\t\t\t3: \"Not Normalized\",\n\t\t\t\t},\n\t\t\t\t[RouterApi.constants.moduleNames.router]: {\n\t\t\t\t\t0: \"Not Authorized\",\n\t\t\t\t\t1: \"Invalid Coin In\",\n\t\t\t\t\t2: \"Invalid Coin Out\",\n\t\t\t\t\t4: \"Invalid Previous Swap\",\n\t\t\t\t\t5: \"Invalid Slippage\",\n\t\t\t\t\t/// A route is constructed that bypasses one of `begin_router_tx_and_pay_fees` or\n\t\t\t\t\t/// `end_router_tx_and_pay_fees`.\n\t\t\t\t\t6: \"No Fees Paid\",\n\t\t\t\t},\n\t\t\t\t[RouterApi.constants.moduleNames.version]: {\n\t\t\t\t\t/// A user tries to interact with an old contract.\n\t\t\t\t\t0: \"Invalid Version\",\n\t\t\t\t},\n\t\t\t\t[RouterApi.constants.moduleNames.admin]: {\n\t\t\t\t\t/// Admin has not authorized the calling shared object to acess a permissioned function.\n\t\t\t\t\t0: \"Not Authorized\",\n\t\t\t\t\t/// Admin has already authorized the calling shared object to acess a permissioned function.\n\t\t\t\t\t1: \"Already Authorized\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate routerTradeEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.utils,\n\t\t\tRouterApi.constants.moduleNames.events,\n\t\t\tRouterApi.constants.eventNames.routerTrade\n\t\t);\n}\n","import {\n\tTransaction,\n\ttype TransactionArgument,\n} from \"@mysten/sui/transactions\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tStakeEvent,\n\tStakingPosition,\n\tUnstakePosition,\n\tUnstakedEvent,\n\tisStakePosition,\n\tisUnstakePosition,\n\tisStakeEvent,\n\tisUnstakeEvent,\n\tApiStakeStakedSuiBody,\n\tApiUnstakeBody,\n\tApiStakeBody,\n\tApiUpdateValidatorFeeBody,\n\tUnstakeEvent,\n\tUnstakeRequestedEvent,\n} from \"../stakingTypes\";\nimport {\n\tAnyObjectType,\n\tBalance,\n\tCoinType,\n\tExternalFee,\n\tObjectId,\n\tStakingAddresses,\n\tSuiAddress,\n} from \"../../../types\";\nimport { Casting, Helpers } from \"../../../general/utils\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { Coin } from \"../../coin\";\nimport { Sui } from \"../../sui\";\nimport { Staking } from \"../..\";\nimport {\n\tMoveErrors,\n\tMoveErrorsInterface,\n} from \"../../../general/types/moveErrorsInterface\";\n\nexport class StakingApi implements MoveErrorsInterface {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tactions: \"actions\",\n\t\t\tevents: \"events\",\n\t\t\tstakedSuiVault: \"staked_sui_vault\",\n\t\t\tstakedSuiVaultState: \"staked_sui_vault_state\",\n\t\t\trouterWrapper: \"router\",\n\t\t\tsort: \"sort\",\n\t\t\treceipt: \"receipt\",\n\t\t\tcalculations: \"calculations\",\n\t\t},\n\t\teventNames: {\n\t\t\tstaked: \"StakedEvent\",\n\t\t\tunstaked: \"UnstakedEvent\",\n\t\t\tunstakeRequested: \"UnstakeRequestedEvent\",\n\t\t\tepochWasChanged: \"EpochWasChangedEvent\",\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: StakingAddresses;\n\tpublic readonly eventTypes: {\n\t\tstaked: AnyObjectType;\n\t\tunstakeRequested: AnyObjectType;\n\t\tunstaked: AnyObjectType;\n\t\tepochWasChanged: AnyObjectType;\n\t};\n\tpublic readonly coinTypes: {\n\t\tafSui: CoinType;\n\t};\n\tpublic readonly objectTypes: {\n\t\tunverifiedValidatorOperationCap: AnyObjectType;\n\t};\n\tpublic readonly moveErrors: MoveErrors;\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tif (!this.Provider.addresses.staking)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = this.Provider.addresses.staking;\n\t\tthis.eventTypes = {\n\t\t\tstaked: this.stakedEventType(),\n\t\t\tunstakeRequested: this.unstakeRequestedEventType(),\n\t\t\tunstaked: this.unstakedEventType(),\n\t\t\tepochWasChanged: this.epochWasChangedEventType(),\n\t\t};\n\t\tthis.coinTypes = {\n\t\t\tafSui: `${this.addresses.packages.afsui}::afsui::AFSUI`,\n\t\t};\n\t\tthis.objectTypes = {\n\t\t\tunverifiedValidatorOperationCap: `${this.addresses.packages.events}::validator::UnverifiedValidatorOperationCap`,\n\t\t};\n\t\tthis.moveErrors = {\n\t\t\t[this.addresses.packages.lsd]: {\n\t\t\t\t[StakingApi.constants.moduleNames.stakedSuiVault]: {\n\t\t\t\t\t/// The admin calls `migrate` on an outdated package.\n\t\t\t\t\t0: \"Version Incompatibility\",\n\t\t\t\t\t/// A user tries to interact with the `StakedSuiVault` through an outdated package.\n\t\t\t\t\t1: \"Wrong Package Version\",\n\t\t\t\t\t/// One tries to call deprecated function.\n\t\t\t\t\t2: \"Deprecated\",\n\t\t\t\t},\n\t\t\t\t[StakingApi.constants.moduleNames.sort]: {\n\t\t\t\t\t/// One provided keys and values vectors of different lengths.\n\t\t\t\t\t1: \"Different Inputs Length\",\n\t\t\t\t\t/// Error for tests.\n\t\t\t\t\t2: \"Dummy Error\",\n\t\t\t\t},\n\t\t\t\t[StakingApi.constants.moduleNames.calculations]: {\n\t\t\t\t\t/// User provided a percentage value larger than 10^18 = 1 = 100%.\n\t\t\t\t\t0: \"Invalid Percentage\",\n\t\t\t\t},\n\t\t\t\t[StakingApi.constants.moduleNames.actions]: {\n\t\t\t\t\t/// Epoch advancement has not yet been processed.\n\t\t\t\t\t0: \"Epoch Change Has Not Been Treated\",\n\t\t\t\t\t/// Epoch advancement has already been processed.\n\t\t\t\t\t1: \"Epoch Change Has Already Been Treated\",\n\t\t\t\t\t/// User tried to delegate stake to a validator that is inactive.\n\t\t\t\t\t2: \"Validator Is Not Active\",\n\t\t\t\t\t/// User tried to delegate stake with value less than the minimum staking threshold.\n\t\t\t\t\t3: \"Less Than Minimum Staking Threshold\",\n\t\t\t\t\t/// User tried to delegate stake to a validator whose history of exchange rates is too short.\n\t\t\t\t\t4: \"Insufficient Validator History\",\n\t\t\t\t\t/// User provided an empty vector as input.\n\t\t\t\t\t5: \"Empty Vector\",\n\t\t\t\t\t/// User requested to unstake more SUI than held in the `atomic_unstake_sui_reserves`.\n\t\t\t\t\t6: \"Insufficient Sui Reserves\",\n\t\t\t\t\t/// User provided afSUI coin with insufficient balance.\n\t\t\t\t\t7: \"Insufficient Balance afSUI Coin Provided\",\n\t\t\t\t},\n\t\t\t\t[StakingApi.constants.moduleNames.receipt]: {\n\t\t\t\t\t0: \"Not Enough Amount In Receipt\",\n\t\t\t\t\t1: \"Try To Burn Non Zero Receipt\",\n\t\t\t\t},\n\t\t\t\t[StakingApi.constants.moduleNames.stakedSuiVaultState]: {\n\t\t\t\t\t/// One provided value larger than 1 (100%) when opposite is supposed.\n\t\t\t\t\t1: \"Invalid Percentage\",\n\t\t\t\t\t/// One provided min atomic unstake fee value larger than max atomic unstake fee value.\n\t\t\t\t\t2: \"Invalid Atomic Unstake Fees Values\",\n\t\t\t\t\t/// A `validator` address - that isn't recognized by the afSUI framework - is provided to a function\n\t\t\t\t\t/// that requests a `ValidatorConfig`.\n\t\t\t\t\t3: \"Invalid Validator\",\n\t\t\t\t\t/// An address tries to create a `UnverifiedValidatorOperationCap` without being an active validator.\n\t\t\t\t\t4: \"Validator Is Not Active\",\n\t\t\t\t\t/// An authorized owner of an `UnverifiedValidatorOperationCap` object tries to perform a permissioned\n\t\t\t\t\t/// function for another validator.\n\t\t\t\t\t5: \"Invalid Operation Cap\",\n\t\t\t\t\t/// An authorized owner of an `UnverifiedValidatorOperationCap` object tries to set a `validator_fee`\n\t\t\t\t\t/// that is greater than the maximum allowed validator fee.\n\t\t\t\t\t6: \"Invalid Validator Fee\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transaction Commands\n\t// =========================================================================\n\n\t/**\n\t * Adds move call to tx for liquid staking of SUI for afSUI.\n\t *\n\t * @returns `Coin<AFSUI>` if `withTransfer` is `undefined` or `false`\n\t */\n\tpublic stakeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiCoin: ObjectId | TransactionArgument;\n\t\tvalidatorAddress: SuiAddress;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, suiCoin, withTransfer } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"request_stake\" + (withTransfer ? \"_and_keep\" : \"\")\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.object(Sui.constants.addresses.suiSystemStateId), // SuiSystemState\n\t\t\t\ttx.object(this.addresses.objects.referralVault), // ReferralVault\n\t\t\t\ttypeof suiCoin === \"string\" ? tx.object(suiCoin) : suiCoin,\n\t\t\t\ttx.pure.address(inputs.validatorAddress),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Adds move call to tx for liquid unstaking of afSUI for SUI that will be\n\t * processed at start of next epoch (end of current epoch).\n\t *\n\t * @returns ()\n\t */\n\tpublic unstakeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tafSuiCoin: ObjectId | TransactionArgument;\n\t}) => {\n\t\tconst { tx, afSuiCoin } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"request_unstake\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttypeof afSuiCoin === \"string\"\n\t\t\t\t\t? tx.object(afSuiCoin)\n\t\t\t\t\t: afSuiCoin,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Adds move call to tx for liquid unstaking of afSUI for SUI that will be\n\t * processed immedietly.\n\t *\n\t * @returns `Coin<SUI>` if `withTransfer` is `undefined` or `false`\n\t */\n\tpublic atomicUnstakeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tafSuiCoin: ObjectId | TransactionArgument;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, afSuiCoin, withTransfer } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"request_unstake_atomic\" + (withTransfer ? \"_and_keep\" : \"\")\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.object(this.addresses.objects.referralVault), // ReferralVault\n\t\t\t\ttx.object(this.addresses.objects.treasury), // Treasury\n\t\t\t\ttypeof afSuiCoin === \"string\"\n\t\t\t\t\t? tx.object(afSuiCoin)\n\t\t\t\t\t: afSuiCoin,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * Adds move call to tx for liquid staking of currently staked (non-liquid)\n\t * SUI objects for afSUI.\n\t *\n\t * @returns `Coin<AFSUI>` if `withTransfer` is `undefined` or `false`\n\t */\n\tpublic requestStakeStakedSuiVecTx = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedSuiIds: ObjectId[];\n\t\tvalidatorAddress: SuiAddress;\n\t\twithTransfer?: boolean;\n\t}) => {\n\t\tconst { tx, stakedSuiIds, withTransfer } = inputs;\n\n\t\tconst stakedSuiIdsVec = tx.makeMoveVec({\n\t\t\telements: stakedSuiIds.map((id) => tx.object(id)),\n\t\t});\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"request_stake_staked_sui_vec\" +\n\t\t\t\t\t(withTransfer ? \"_and_keep\" : \"\")\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.object(Sui.constants.addresses.suiSystemStateId), // SuiSystemState\n\t\t\t\ttx.object(this.addresses.objects.referralVault), // ReferralVault\n\t\t\t\tstakedSuiIdsVec,\n\t\t\t\ttx.pure.address(inputs.validatorAddress),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic epochWasChangedTx = (inputs: { tx: Transaction }) => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"epoch_was_changed\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.object(Sui.constants.addresses.suiSystemStateId), // SuiSystemState\n\t\t\t\ttx.object(this.addresses.objects.referralVault), // ReferralVault\n\t\t\t\ttx.object(this.addresses.objects.treasury), // Treasury\n\t\t\t\ttx.pure.u64(BigInt(1000)), // fields_requests_per_tx\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Inspection Transaction Commands\n\t// =========================================================================\n\n\tpublic afSuiToSuiExchangeRateTx = (inputs: {\n\t\ttx: Transaction;\n\t}) /* (u128) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"afsui_to_sui_exchange_rate\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic suiToAfSuiExchangeRateTx = (inputs: {\n\t\ttx: Transaction;\n\t}) /* (u128) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"sui_to_afsui_exchange_rate\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic totalSuiAmountTx = (inputs: { tx: Transaction }) => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: AftermathApi.helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"total_sui_amount\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [tx.object(this.addresses.objects.stakedSuiVault)],\n\t\t});\n\t};\n\n\tpublic afSuiToSuiTx = (inputs: {\n\t\ttx: Transaction;\n\t\tafSuiAmount: Balance;\n\t}) /* (u64) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"afsui_to_sui\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.pure.u64(inputs.afSuiAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic suiToAfSuiTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiAmount: Balance;\n\t}) /* (u64) */ => {\n\t\tconst { tx } = inputs;\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"sui_to_afsui\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.object(this.addresses.objects.safe), // Safe\n\t\t\t\ttx.pure.u64(inputs.suiAmount),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Validator Transaction Commands\n\t// =========================================================================\n\n\tpublic updateValidatorFeeTx = (inputs: {\n\t\ttx: Transaction;\n\t\tvalidatorOperationCapId: ObjectId;\n\t\tnewFee: bigint;\n\t}) => {\n\t\tconst { tx, validatorOperationCapId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.lsd,\n\t\t\t\tStakingApi.constants.moduleNames.stakedSuiVault,\n\t\t\t\t\"update_validator_fee\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttypeof validatorOperationCapId === \"string\"\n\t\t\t\t\t? tx.object(validatorOperationCapId)\n\t\t\t\t\t: validatorOperationCapId, // UnverifiedValidatorOperationCap\n\t\t\t\ttx.object(this.addresses.objects.stakedSuiVault), // StakedSuiVault\n\t\t\t\ttx.pure.u64(inputs.newFee),\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transaction Builders\n\t// =========================================================================\n\n\t/**\n\t * Builds complete PTB for liquid staking of SUI for afSUI.\n\t *\n\t * @returns Transaction Block ready for execution\n\t */\n\tpublic fetchBuildStakeTx = async (\n\t\tinputs: ApiStakeBody\n\t): Promise<Transaction> => {\n\t\tconst { referrer, externalFee } = inputs;\n\n\t\tif (externalFee) StakingApi.assertValidExternalFee(externalFee);\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst suiCoin = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress: inputs.walletAddress,\n\t\t\tcoinType: Coin.constants.suiCoinType,\n\t\t\tcoinAmount: inputs.suiStakeAmount,\n\t\t\tisSponsoredTx: inputs.isSponsoredTx,\n\t\t});\n\n\t\tif (externalFee) {\n\t\t\tconst feeAmount = BigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(inputs.suiStakeAmount) * externalFee.feePercentage\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst suiFeeCoin = tx.splitCoins(suiCoin, [feeAmount]);\n\t\t\ttx.transferObjects([suiFeeCoin], externalFee.recipient);\n\t\t}\n\n\t\tconst afSuiCoinId = this.stakeTx({\n\t\t\ttx,\n\t\t\t...inputs,\n\t\t\tsuiCoin,\n\t\t\t// withTransfer: true,\n\t\t});\n\t\ttx.transferObjects([afSuiCoinId], inputs.walletAddress);\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds complete PTB for liquid unstaking of afSUI for SUI.\n\t *\n\t * @returns Transaction Block ready for execution\n\t */\n\tpublic fetchBuildUnstakeTx = async (\n\t\tinputs: ApiUnstakeBody\n\t): Promise<Transaction> => {\n\t\tconst { referrer, externalFee } = inputs;\n\n\t\tif (externalFee) StakingApi.assertValidExternalFee(externalFee);\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\tconst afSuiCoin = await this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\ttx,\n\t\t\twalletAddress: inputs.walletAddress,\n\t\t\tcoinType: this.coinTypes.afSui,\n\t\t\tcoinAmount: inputs.afSuiUnstakeAmount,\n\t\t});\n\n\t\tif (externalFee) {\n\t\t\tconst feeAmount = BigInt(\n\t\t\t\tMath.floor(\n\t\t\t\t\tNumber(inputs.afSuiUnstakeAmount) *\n\t\t\t\t\t\texternalFee.feePercentage\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst afSuiFeeCoin = tx.splitCoins(afSuiCoin, [feeAmount]);\n\t\t\ttx.transferObjects([afSuiFeeCoin], externalFee.recipient);\n\t\t}\n\t\tif (inputs.isAtomic) {\n\t\t\tconst suiCoinId = this.atomicUnstakeTx({\n\t\t\t\ttx,\n\t\t\t\t...inputs,\n\t\t\t\tafSuiCoin,\n\t\t\t\t// withTransfer: true,\n\t\t\t});\n\t\t\ttx.transferObjects([suiCoinId], inputs.walletAddress);\n\t\t} else {\n\t\t\tthis.unstakeTx({\n\t\t\t\ttx,\n\t\t\t\t...inputs,\n\t\t\t\tafSuiCoin,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t/**\n\t * Builds complete PTB for liquid staking of currently staked (non-liquid)\n\t * SUI objects for afSUI.\n\t *\n\t * @returns Transaction Block ready for execution\n\t */\n\tpublic fetchBuildStakeStakedSuiTx = async (\n\t\tinputs: ApiStakeStakedSuiBody\n\t): Promise<Transaction> => {\n\t\tconst { referrer } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tif (referrer)\n\t\t\tthis.Provider.ReferralVault().updateReferrerTx({\n\t\t\t\ttx,\n\t\t\t\treferrer,\n\t\t\t});\n\n\t\t// TODO: add external fee here\n\t\tconst afSuiCoinId = this.requestStakeStakedSuiVecTx({\n\t\t\ttx,\n\t\t\t...inputs,\n\t\t\t// withTransfer: true,\n\t\t});\n\t\ttx.transferObjects([afSuiCoinId], inputs.walletAddress);\n\n\t\treturn tx;\n\t};\n\n\tpublic buildUpdateValidatorFeeTx = async (\n\t\tinputs: ApiUpdateValidatorFeeBody\n\t): Promise<Transaction> => {\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tthis.updateValidatorFeeTx({\n\t\t\t...inputs,\n\t\t\ttx,\n\t\t\tnewFee: Casting.numberToFixedBigInt(inputs.newFeePercentage),\n\t\t});\n\n\t\treturn tx;\n\t};\n\n\tpublic buildEpochWasChangedTx = Helpers.transactions.createBuildTxFunc(\n\t\tthis.epochWasChangedTx\n\t);\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate stakedEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tStakingApi.constants.moduleNames.events,\n\t\t\tStakingApi.constants.eventNames.staked\n\t\t);\n\n\tprivate unstakeRequestedEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tStakingApi.constants.moduleNames.events,\n\t\t\tStakingApi.constants.eventNames.unstakeRequested\n\t\t);\n\n\tprivate unstakedEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tStakingApi.constants.moduleNames.events,\n\t\t\tStakingApi.constants.eventNames.unstaked\n\t\t);\n\n\tprivate epochWasChangedEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.events,\n\t\t\tStakingApi.constants.moduleNames.events,\n\t\t\tStakingApi.constants.eventNames.epochWasChanged\n\t\t);\n\n\t// =========================================================================\n\t// Public Static Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Positions Updating\n\t// =========================================================================\n\n\t// NOTE: should these functions be on FE only ?\n\n\tpublic static updateStakingPositionsFromEvent = (inputs: {\n\t\tstakingPositions: StakingPosition[];\n\t\tevent: StakeEvent | UnstakeEvent;\n\t}): StakingPosition[] => {\n\t\tconst positions = inputs.stakingPositions;\n\t\tconst event = inputs.event;\n\n\t\tlet newPositions: StakingPosition[] = [];\n\n\t\t// TODO: use bifilter\n\t\tconst unstakePositions = positions.filter(isUnstakePosition);\n\t\tconst newUnstakes = isUnstakeEvent(event)\n\t\t\t? this.updateUnstakePositionsFromEvent({\n\t\t\t\t\tevent,\n\t\t\t\t\tunstakePositions,\n\t\t\t })\n\t\t\t: unstakePositions;\n\n\t\tconst stakePositions = positions.filter(isStakePosition);\n\t\tconst newStakes = isStakeEvent(event)\n\t\t\t? [...stakePositions, event]\n\t\t\t: stakePositions;\n\n\t\tnewPositions = [...newUnstakes, ...newStakes];\n\n\t\treturn newPositions.sort(\n\t\t\t(a, b) => (b.timestamp ?? 0) - (a.timestamp ?? 0)\n\t\t);\n\t};\n\n\t// =========================================================================\n\t// Private Static Methods\n\t// =========================================================================\n\n\tprivate static assertValidExternalFee = (externalFee: ExternalFee) => {\n\t\tif (\n\t\t\texternalFee.feePercentage >=\n\t\t\tStaking.constants.bounds.maxExternalFeePercentage\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\t`external fee percentage exceeds max of ${\n\t\t\t\t\tStaking.constants.bounds.maxExternalFeePercentage * 100\n\t\t\t\t}%`\n\t\t\t);\n\t\tif (externalFee.feePercentage <= 0)\n\t\t\tthrow new Error(`external fee percentage must be greater than 0`);\n\t};\n\n\t// =========================================================================\n\t// Unstake Event Processing\n\t// =========================================================================\n\n\tprivate static updateUnstakePositionsFromEvent = (inputs: {\n\t\tunstakePositions: UnstakePosition[];\n\t\tevent: UnstakeEvent;\n\t}): UnstakePosition[] => {\n\t\tconst foundPositionIndex = inputs.unstakePositions.findIndex(\n\t\t\t(pos) => pos.afSuiId === inputs.event.afSuiId\n\t\t);\n\t\tif (foundPositionIndex < 0) {\n\t\t\tif (\n\t\t\t\tinputs.event.type.includes(\n\t\t\t\t\tthis.constants.eventNames.unstakeRequested\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\t...(inputs.event as UnstakeRequestedEvent),\n\t\t\t\t\t\tstate: \"REQUEST\",\n\t\t\t\t\t},\n\t\t\t\t\t...inputs.unstakePositions,\n\t\t\t\t];\n\n\t\t\t// unstaked event\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\t...(inputs.event as UnstakedEvent),\n\t\t\t\t\tstate: \"SUI_MINTED\",\n\t\t\t\t},\n\t\t\t\t...inputs.unstakePositions,\n\t\t\t];\n\t\t}\n\n\t\tconst foundStakePosition = inputs.unstakePositions[foundPositionIndex];\n\n\t\tlet position: UnstakePosition | undefined = undefined;\n\t\tif (inputs.event.type.includes(this.constants.eventNames.unstaked))\n\t\t\tposition = {\n\t\t\t\t...(inputs.event as UnstakedEvent),\n\t\t\t\tstate: \"SUI_MINTED\",\n\t\t\t\tepoch: foundStakePosition.epoch,\n\t\t\t};\n\n\t\tif (\n\t\t\tinputs.event.type.includes(\n\t\t\t\tthis.constants.eventNames.unstakeRequested\n\t\t\t)\n\t\t)\n\t\t\tposition = {\n\t\t\t\t...(inputs.event as UnstakeRequestedEvent),\n\t\t\t\tstate: \"REQUEST\",\n\t\t\t\tepoch: foundStakePosition.epoch,\n\t\t\t};\n\n\t\tif (!position) return inputs.unstakePositions;\n\n\t\tlet newStakePositions = [...inputs.unstakePositions];\n\t\tnewStakePositions[foundPositionIndex] = position;\n\n\t\treturn newStakePositions;\n\t};\n}\n","import type { CommitteeInfo, SuiSystemStateSummary } from \"@mysten/sui/jsonRpc\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport { Helpers } from \"../../../general/utils\";\n\nexport class SuiApi {\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\t/**\n\t * @deprecated Use `getSystemState()` method instead.\n\t * This method will be removed in a future release.\n\t * @example\n\t * ```typescript\n\t * const afSdk = new Aftermath(\"MAINNET\");\n\t * await afSdk.init(); // initialize provider\n\t *\n\t * const sui = afSdk.Sui();\n\t *\n\t * const systemState = await sui.getSystemState();\n\t * console.log(systemState.epoch, systemState.validators);\n\t */\n\tpublic fetchSystemState = async (): Promise<SuiSystemStateSummary> => {\n\t\tconst systemState =\n\t\t\tawait this.Provider.provider.getLatestSuiSystemState();\n\n\t\tconst activeValidators = systemState.activeValidators.map(\n\t\t\t(validator) => ({\n\t\t\t\t...validator,\n\t\t\t\tsuiAddress: Helpers.addLeadingZeroesToType(\n\t\t\t\t\tvalidator.suiAddress\n\t\t\t\t),\n\t\t\t})\n\t\t);\n\n\t\treturn {\n\t\t\t...systemState,\n\t\t\tactiveValidators,\n\t\t} as SuiSystemStateSummary;\n\t};\n}\n","import {\n\tTransaction,\n\ttype TransactionArgument,\n} from \"@mysten/sui/transactions\";\nimport { bcs } from \"@mysten/sui/bcs\";\nimport { AftermathApi } from \"../../../general/providers/aftermathApi\";\nimport {\n\tMixSuiFrensEvent,\n\tSuiFrenObject,\n\tSuiFrenStats,\n\tSuiFrenVaultStateV1Object,\n\tStakeSuiFrenEvent,\n\tUnstakeSuiFrenEvent,\n\tSuiFrenAttributes,\n\tSuiFrensSortOption,\n\tSuiFrenAccessoryObject,\n\tStakedSuiFrenInfo,\n\tSuiFrenAccessoryType,\n\tApiMixSuiFrensBody,\n\tApiRemoveSuiFrenAccessoryBody,\n\tApiAddSuiFrenAccessoryBody,\n\tHarvestSuiFrenFeesEvent,\n\tStakedSuiFrenMetadataV1Object,\n\tPartialSuiFrenObject,\n} from \"../suiFrensTypes\";\nimport {\n\tHarvestSuiFrenFeesEventOnChain,\n\tMixSuiFrensEventOnChain,\n\tStakeSuiFrenEventOnChain,\n\tUnstakeSuiFrenEventOnChain,\n} from \"./suiFrensApiCastingTypes\";\nimport { AmountInCoinAndUsd, CoinDecimal } from \"../../coin/coinTypes\";\nimport { Coin } from \"../../coin/coin\";\nimport { Helpers } from \"../../../general/utils/helpers\";\nimport {\n\tAnyObjectType,\n\tBalance,\n\tSuiFrensAddresses,\n\tDynamicFieldObjectsWithCursor,\n\tDynamicFieldsInputs,\n\tEventsInputs,\n\tObjectId,\n\tSuiAddress,\n} from \"../../../types\";\nimport { Casting } from \"../../../general/utils\";\nimport { EventsApiHelpers } from \"../../../general/apiHelpers/eventsApiHelpers\";\nimport { Sui } from \"../../sui/sui\";\nimport { SuiFrens } from \"../suiFrens\";\n\nexport class SuiFrensApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\tprivate static readonly constants = {\n\t\tmoduleNames: {\n\t\t\tsuiFrens: {\n\t\t\t\tsuiFrens: \"suifrens\",\n\t\t\t},\n\t\t\taccessories: {\n\t\t\t\taccessories: \"accessories\",\n\t\t\t},\n\t\t\tcapyLabs: {\n\t\t\t\tcapyLabs: \"capy_labs\",\n\t\t\t},\n\t\t\tsuiFrensVault: {\n\t\t\t\tvault: \"vault\",\n\t\t\t\tvaultState: \"vault_state\",\n\t\t\t\tevents: \"events\",\n\t\t\t\tstakedPosition: \"staked_position\",\n\t\t\t},\n\t\t\tsuiFrensVaultCapyLabsExtension: {\n\t\t\t\tcapyLabs: \"capy_labs\",\n\t\t\t},\n\t\t},\n\n\t\teventNames: {\n\t\t\tsuiFrensVault: {\n\t\t\t\tmixSuiFrens: \"MixedSuiFrenEvent\",\n\t\t\t\tstakeSuiFren: \"StakedSuiFrenEvent\",\n\t\t\t\tunstakeSuiFren: \"UnstakedSuiFrenEvent\",\n\t\t\t\tharvestSuiFrenFees: \"HarvestedFeesEvent\",\n\t\t\t},\n\t\t},\n\t};\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: SuiFrensAddresses;\n\n\tpublic readonly objectTypes: {\n\t\t// suiFrens\n\t\tsuiFren: AnyObjectType;\n\t\tcapy: AnyObjectType;\n\t\tbullshark: AnyObjectType;\n\n\t\t// accessories\n\t\tsuiFrenAccessory: AnyObjectType;\n\n\t\t// staking\n\t\tstakedSuiFrenPosition: AnyObjectType;\n\t\tstakedSuiFrenMetadataV1: AnyObjectType;\n\t};\n\n\tpublic readonly eventTypes: {\n\t\tharvestSuiFrenFees: AnyObjectType;\n\t\tmixSuiFrens: AnyObjectType;\n\t\tstakeSuiFren: AnyObjectType;\n\t\tunstakeSuiFren: AnyObjectType;\n\t};\n\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tconst addresses = this.Provider.addresses.suiFrens;\n\t\tif (!addresses)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = addresses;\n\n\t\tthis.objectTypes = {\n\t\t\t// suiFrens\n\t\t\tsuiFren: `${addresses.packages.suiFrens}::${SuiFrensApi.constants.moduleNames.suiFrens.suiFrens}::SuiFren`,\n\t\t\tcapy: `${addresses.packages.suiFrens}::capy::Capy`,\n\t\t\tbullshark: `${addresses.packages.suiFrensBullshark}::bullshark::Bullshark`,\n\n\t\t\t// accessories\n\t\t\tsuiFrenAccessory: `${addresses.packages.accessories}::${SuiFrensApi.constants.moduleNames.accessories.accessories}::Accessory`,\n\n\t\t\t// staking\n\t\t\tstakedSuiFrenPosition: `${addresses.packages.suiFrensVault}::${SuiFrensApi.constants.moduleNames.suiFrensVault.stakedPosition}::StakedPosition`,\n\t\t\tstakedSuiFrenMetadataV1: `${addresses.packages.suiFrensVault}::${SuiFrensApi.constants.moduleNames.suiFrensVault.vaultState}::StakedSuiFrenMetadataV1`,\n\t\t};\n\n\t\tthis.eventTypes = {\n\t\t\tharvestSuiFrenFees: this.harvestSuiFrenFeesEventType(),\n\t\t\tmixSuiFrens: this.mixSuiFrensEventType(),\n\t\t\tstakeSuiFren: this.stakeSuiFrenEventType(),\n\t\t\tunstakeSuiFren: this.unstakeSuiFrenEventType(),\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic fetchMixingLimitsAndLastEpochMixeds = async (inputs: {\n\t\tsuiFrenIds: ObjectId[];\n\t\tsuiFrenType: AnyObjectType;\n\t}): Promise<\n\t\t{\n\t\t\tmixLimit: bigint | undefined;\n\t\t\tlastEpochMixed: bigint | undefined;\n\t\t}[]\n\t> => {\n\t\tconst tx = new Transaction();\n\t\tthis.devInspectMixLimitAndLastEpochMixedMulTx({ ...inputs, tx });\n\n\t\tconst [mixLimitBytes, lastEpochMixedBytes] =\n\t\t\tawait this.Provider.Inspections().fetchAllBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\n\t\tconst mixLimits = bcs\n\t\t\t.vector(bcs.option(bcs.u8()))\n\t\t\t.parse(new Uint8Array(mixLimitBytes));\n\n\t\tconst lastEpochMixeds: any[] = bcs\n\t\t\t.vector(bcs.option(bcs.u64()))\n\t\t\t.parse(new Uint8Array(lastEpochMixedBytes));\n\n\t\treturn mixLimits.map((mixLimit, index) => ({\n\t\t\tmixLimit:\n\t\t\t\tmixLimit === null || mixLimit === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: BigInt(mixLimit),\n\t\t\tlastEpochMixed:\n\t\t\t\tlastEpochMixeds[index] === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: BigInt(lastEpochMixeds[index]),\n\t\t}));\n\t};\n\n\tpublic fetchMixingLimit = async (inputs: {\n\t\tsuiFrenId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}): Promise<bigint | undefined> => {\n\t\t// TODO: handle bullshark types more cleanly\n\t\tif (inputs.suiFrenType === this.objectTypes.bullshark) return undefined;\n\n\t\tconst tx = new Transaction();\n\n\t\tthis.mixingLimitTx({ tx, ...inputs });\n\n\t\tconst bytes =\n\t\t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\n\t\tconst unwrapped = bcs.option(bcs.u8()).parse(new Uint8Array(bytes));\n\n\t\treturn unwrapped === null || unwrapped === undefined\n\t\t\t? undefined\n\t\t\t: BigInt(unwrapped);\n\t};\n\n\tpublic fetchLastEpochMixed = async (inputs: {\n\t\tsuiFrenId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}): Promise<bigint | undefined> => {\n\t\t// TODO: handle bullshark types more cleanly\n\t\tif (inputs.suiFrenType === this.objectTypes.bullshark) return undefined;\n\n\t\tconst tx = new Transaction();\n\n\t\tthis.lastEpochMixedTx({ tx, ...inputs });\n\n\t\tconst bytes =\n\t\t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\n\t\tconst unwrapped = bcs.option(bcs.u64()).parse(new Uint8Array(bytes));\n\n\t\treturn unwrapped === null || unwrapped === undefined\n\t\t\t? undefined\n\t\t\t: BigInt(unwrapped);\n\t};\n\n\tpublic fetchStakedSuiFrenMetadataIds = async (inputs: {\n\t\tsuiFrenIds: ObjectId[];\n\t}): Promise<ObjectId[]> => {\n\t\tconst { suiFrenIds } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\tthis.devInspectMetadataObjectIdMulTx({ tx, suiFrenIds });\n\n\t\tconst idBytes =\n\t\t\tawait this.Provider.Inspections().fetchFirstBytesFromTxOutput({\n\t\t\t\ttx,\n\t\t\t});\n\n\t\tconst stakedSuiFrenMetadataIds = bcs\n\t\t\t.vector(bcs.Address)\n\t\t\t.parse(new Uint8Array(idBytes));\n\n\t\treturn stakedSuiFrenMetadataIds;\n\t};\n\n\t// =========================================================================\n\t// Events\n\t// =========================================================================\n\n\tpublic fetchHarvestSuiFrenFeesEvents = (inputs: EventsInputs) =>\n\t\tthis.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tHarvestSuiFrenFeesEventOnChain,\n\t\t\tHarvestSuiFrenFeesEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.harvestSuiFrenFees,\n\t\t\t},\n\t\t\teventFromEventOnChain:\n\t\t\t\tCasting.suiFrens.harvestSuiFrenFeesEventFromOnChain,\n\t\t});\n\n\tpublic fetchMixSuiFrensEvents = (inputs: EventsInputs) =>\n\t\tthis.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tMixSuiFrensEventOnChain,\n\t\t\tMixSuiFrensEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.mixSuiFrens,\n\t\t\t},\n\t\t\teventFromEventOnChain: Casting.suiFrens.mixSuiFrensEventFromOnChain,\n\t\t});\n\n\tpublic fetchStakeSuiFrenEvents = (inputs: EventsInputs) =>\n\t\tthis.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tStakeSuiFrenEventOnChain,\n\t\t\tStakeSuiFrenEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.stakeSuiFren,\n\t\t\t},\n\t\t\teventFromEventOnChain:\n\t\t\t\tCasting.suiFrens.stakeSuiFrenEventFromOnChain,\n\t\t});\n\n\tpublic fetchUnstakeSuiFrenEvents = (inputs: EventsInputs) =>\n\t\tthis.Provider.Events().fetchCastEventsWithCursor<\n\t\t\tUnstakeSuiFrenEventOnChain,\n\t\t\tUnstakeSuiFrenEvent\n\t\t>({\n\t\t\t...inputs,\n\t\t\tquery: {\n\t\t\t\tMoveEventType: this.eventTypes.unstakeSuiFren,\n\t\t\t},\n\t\t\teventFromEventOnChain:\n\t\t\t\tCasting.suiFrens.unstakeSuiFrenEventFromOnChain,\n\t\t});\n\n\t// =========================================================================\n\t// Objects\n\t// =========================================================================\n\n\t// =========================================================================\n\t// CapyLabsApp Object\n\t// =========================================================================\n\n\tpublic fetchCapyLabsApp = async () => {\n\t\treturn this.Provider.Objects().fetchCastObject({\n\t\t\tobjectId: this.addresses.objects.capyLabsApp,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tCasting.suiFrens.capyLabsAppObjectFromSuiObjectResponse,\n\t\t});\n\t};\n\n\tpublic fetchSuiFrenVaultStateV1Object = async () => {\n\t\treturn this.Provider.Objects().fetchCastObject({\n\t\t\tobjectId: this.addresses.objects.suiFrensVaultStateV1,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tCasting.suiFrens.suiFrenVaultStateV1ObjectFromSuiObjectResponse,\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// SuiFren Objects\n\t// =========================================================================\n\n\tpublic fetchSuiFrens = async (inputs: {\n\t\tsuiFrenIds: ObjectId[];\n\t}): Promise<SuiFrenObject[]> => {\n\t\tconst { suiFrenIds } = inputs;\n\n\t\tconst partialSuiFrens =\n\t\t\tawait this.Provider.Objects().fetchCastObjectBatch({\n\t\t\t\tobjectIds: suiFrenIds,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.suiFrens.partialSuiFrenObjectFromSuiObjectResponse,\n\t\t\t\toptions: {\n\t\t\t\t\tshowDisplay: true,\n\t\t\t\t\tshowType: true,\n\t\t\t\t\tshowContent: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\treturn this.fetchCompletePartialSuiFrenObjects({\n\t\t\tpartialSuiFrens,\n\t\t\tisStaked: false,\n\t\t});\n\t};\n\n\tpublic fetchOwnedSuiFrens = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<SuiFrenObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst [partialSuiFrenNonBullsharks, partialSuiFrenBullsharks] =\n\t\t\tawait Promise.all([\n\t\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\t\twalletAddress,\n\t\t\t\t\tobjectType: this.objectTypes.suiFren,\n\t\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\t\tCasting.suiFrens\n\t\t\t\t\t\t\t.partialSuiFrenObjectFromSuiObjectResponse,\n\t\t\t\t\twithDisplay: true,\n\t\t\t\t}),\n\t\t\t\tthis.fetchOwnedPartialSuiFrenBullsharks(inputs),\n\t\t\t]);\n\n\t\tconst suiFrens = await this.fetchCompletePartialSuiFrenObjects({\n\t\t\tpartialSuiFrens: [\n\t\t\t\t...partialSuiFrenNonBullsharks,\n\t\t\t\t...partialSuiFrenBullsharks,\n\t\t\t],\n\t\t\tisStaked: false,\n\t\t});\n\t\treturn suiFrens;\n\t};\n\n\tpublic fetchStakedSuiFrens = async (inputs: {\n\t\tstakedSuiFrenIds: ObjectId[];\n\t}): Promise<StakedSuiFrenInfo[]> => {\n\t\tconst { stakedSuiFrenIds } = inputs;\n\n\t\tconst stakedSuiFrenData =\n\t\t\tawait this.Provider.Objects().fetchCastObjectBatch({\n\t\t\t\tobjectIds: stakedSuiFrenIds,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.suiFrens\n\t\t\t\t\t\t.partialSuiFrenAndStakedSuiFrenMetadataV1ObjectFromSuiObjectResponse,\n\t\t\t\toptions: {\n\t\t\t\t\tshowDisplay: true,\n\t\t\t\t\tshowType: true,\n\t\t\t\t\tshowContent: true,\n\t\t\t\t},\n\t\t\t});\n\t\tconst suiFrens = await this.fetchCompletePartialSuiFrenObjects({\n\t\t\tpartialSuiFrens: stakedSuiFrenData.map(\n\t\t\t\t(data) => data.partialSuiFren\n\t\t\t),\n\t\t\tisStaked: true,\n\t\t});\n\n\t\treturn suiFrens.map((suiFren, index) => ({\n\t\t\tsuiFren,\n\t\t\tmetadata: stakedSuiFrenData[index].stakedSuiFrenMetadata,\n\t\t}));\n\t};\n\n\tpublic fetchStakedSuiFrensDynamicFields = (inputs: DynamicFieldsInputs) => {\n\t\treturn this.Provider.DynamicFields().fetchCastDynamicFieldsOfTypeWithCursor(\n\t\t\t{\n\t\t\t\t...inputs,\n\t\t\t\tparentObjectId:\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultStateV1MetadataTable,\n\t\t\t\tobjectsFromObjectIds: (stakedSuiFrenIds) =>\n\t\t\t\t\tthis.fetchStakedSuiFrens({ stakedSuiFrenIds }),\n\t\t\t\tdynamicFieldType: this.objectTypes.stakedSuiFrenMetadataV1,\n\t\t\t}\n\t\t);\n\t};\n\n\t// =========================================================================\n\t// Accessories\n\t// =========================================================================\n\n\tpublic fetchAccessoriesForSuiFren = async (inputs: {\n\t\tsuiFrenId: ObjectId;\n\t}) => {\n\t\treturn await this.Provider.DynamicFields().fetchCastAllDynamicFieldsOfType(\n\t\t\t{\n\t\t\t\tparentObjectId: inputs.suiFrenId,\n\t\t\t\tobjectsFromObjectIds: (objectIds) =>\n\t\t\t\t\tthis.fetchAccessories({ objectIds }),\n\t\t\t\tdynamicFieldType: this.objectTypes.suiFrenAccessory,\n\t\t\t}\n\t\t);\n\t};\n\n\tpublic fetchOwnedAccessories = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}) => {\n\t\tconst { walletAddress } = inputs;\n\t\treturn await this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType(\n\t\t\t{\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.suiFrenAccessory,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.suiFrens.accessoryObjectFromSuiObjectResponse,\n\t\t\t\twithDisplay: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tpublic fetchAccessories = async (inputs: {\n\t\tobjectIds: ObjectId[];\n\t}): Promise<SuiFrenAccessoryObject[]> => {\n\t\tconst { objectIds } = inputs;\n\t\treturn this.Provider.Objects().fetchCastObjectBatch({\n\t\t\tobjectIds,\n\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\tCasting.suiFrens.accessoryObjectFromSuiObjectResponse,\n\t\t\toptions: {\n\t\t\t\tshowDisplay: true,\n\t\t\t\tshowType: true,\n\t\t\t\tshowContent: true,\n\t\t\t},\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Staked SuiFren Objects\n\t// =========================================================================\n\n\t// TODO: handle sorting\n\tpublic fetchStakedSuiFrensDynamicFieldsWithFilters = async (inputs: {\n\t\tattributes: Partial<SuiFrenAttributes>;\n\t\tsortBy?: SuiFrensSortOption;\n\t\tlimit?: number;\n\t\tlimitStepSize?: number;\n\t\tcursor?: ObjectId;\n\t}): Promise<DynamicFieldObjectsWithCursor<StakedSuiFrenInfo>> => {\n\t\tconst { attributes } = inputs;\n\t\tconst defaultLimit = 25;\n\t\tconst limit = inputs.limit ?? defaultLimit;\n\n\t\tconst isComplete = (data: StakedSuiFrenInfo[]) => {\n\t\t\treturn (\n\t\t\t\tthis.filterSuiFrensWithAttributes({\n\t\t\t\t\tsuiFrens: data.map((info) => info.suiFren),\n\t\t\t\t\tattributes,\n\t\t\t\t}).length >= limit\n\t\t\t);\n\t\t};\n\n\t\tconst suiFrensWithCursor =\n\t\t\tawait this.Provider.DynamicFields().fetchDynamicFieldsUntil({\n\t\t\t\t...inputs,\n\t\t\t\tfetchFunc: (data) =>\n\t\t\t\t\tthis.fetchStakedSuiFrensDynamicFields(data),\n\t\t\t\tisComplete,\n\t\t\t});\n\n\t\tconst filteredSuiFrens = this.filterSuiFrensWithAttributes({\n\t\t\tsuiFrens: suiFrensWithCursor.dynamicFieldObjects.map(\n\t\t\t\t(data) => data.suiFren\n\t\t\t),\n\t\t\tattributes,\n\t\t});\n\t\tconst dynamicFieldObjects =\n\t\t\tsuiFrensWithCursor.dynamicFieldObjects.filter((data) =>\n\t\t\t\tfilteredSuiFrens\n\t\t\t\t\t.slice(0, limit)\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(suiFren) => suiFren.objectId === data.suiFren.objectId\n\t\t\t\t\t)\n\t\t\t);\n\n\t\tconst resizedSuiFrensWithCursor = {\n\t\t\tnextCursor:\n\t\t\t\tlimit < filteredSuiFrens.length\n\t\t\t\t\t? filteredSuiFrens[limit].objectId\n\t\t\t\t\t: suiFrensWithCursor.nextCursor,\n\t\t\tdynamicFieldObjects,\n\t\t};\n\n\t\treturn resizedSuiFrensWithCursor;\n\t};\n\n\tpublic fetchOwnedStakedSuiFrens = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<StakedSuiFrenInfo[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst stakedPositions =\n\t\t\tawait this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.stakedSuiFrenPosition,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.suiFrens.stakedSuiFrenPositionFromSuiObjectResponse,\n\t\t\t});\n\n\t\tconst stakedSuiFrenIds = await this.fetchStakedSuiFrenMetadataIds({\n\t\t\tsuiFrenIds: stakedPositions.map((position) => position.suiFrenId),\n\t\t});\n\t\tconst stakedSuiFrens = await this.fetchStakedSuiFrens({\n\t\t\tstakedSuiFrenIds,\n\t\t});\n\n\t\treturn stakedSuiFrens.map((data, index) => ({\n\t\t\t...data,\n\t\t\tposition: stakedPositions[index],\n\t\t}));\n\t};\n\n\t// =========================================================================\n\t// Transaction Commands\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Inspections\n\t// =========================================================================\n\n\tpublic devInspectMetadataObjectIdMulTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenIds: ObjectId[];\n\t}) /* vector<address> */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"dev_inspect_metadata_object_id_mul\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.pure(bcs.vector(bcs.Address).serialize(inputs.suiFrenIds)), // suifren_ids\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic devInspectMixLimitAndLastEpochMixedMulTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenIds: ObjectId[];\n\t\tsuiFrenType: AnyObjectType;\n\t}) /* (vector<Option<u8>>, vector<Option<u64>>) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"dev_inspect_mixing_limit_and_last_epoch_mixed_mul\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.pure(bcs.vector(bcs.Address).serialize(inputs.suiFrenIds)), // suifren_ids\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic mixingLimitTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}) /* Option<u8> */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrens,\n\t\t\t\tSuiFrensApi.constants.moduleNames.capyLabs.capyLabs,\n\t\t\t\t\"mixing_limit\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.suiFrenId), // SuiFren\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic lastEpochMixedTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}) /* Option<u64> */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrens,\n\t\t\t\tSuiFrensApi.constants.moduleNames.capyLabs.capyLabs,\n\t\t\t\t\"last_epoch_mixed\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.suiFrenId), // SuiFren\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Mixing Transaction Commands\n\t// =========================================================================\n\n\tpublic mixAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tparentOneId: ObjectId;\n\t\tparentTwoId: ObjectId;\n\t\tsuiPaymentCoinId: ObjectId | TransactionArgument;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx, suiPaymentCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"mix_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.capyLabsApp), // CapyLabsApp\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\n\t\t\t\ttx.object(inputs.parentOneId), // SuiFren\n\t\t\t\ttx.object(inputs.parentTwoId), // SuiFren\n\t\t\t\ttypeof suiPaymentCoinId === \"string\"\n\t\t\t\t\t? tx.object(suiPaymentCoinId)\n\t\t\t\t\t: suiPaymentCoinId, // Coin\n\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic mixWithStakedAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tnonStakedParentId: ObjectId;\n\t\tstakedParentId: ObjectId;\n\t\tsuiPaymentCoinId: ObjectId | TransactionArgument;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx, suiPaymentCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"mix_with_staked_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.capyLabsApp), // CapyLabsApp\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\n\t\t\t\ttx.object(inputs.nonStakedParentId), // SuiFren\n\t\t\t\ttx.object(inputs.stakedParentId), // SuiFren\n\t\t\t\ttypeof suiPaymentCoinId === \"string\"\n\t\t\t\t\t? tx.object(suiPaymentCoinId)\n\t\t\t\t\t: suiPaymentCoinId, // Coin\n\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic mixStakedWithStakedAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tparentOneId: ObjectId;\n\t\tparentTwoId: ObjectId;\n\t\tsuiPaymentCoinId: ObjectId | TransactionArgument;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx, suiPaymentCoinId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"mix_staked_with_staked_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.capyLabsApp), // CapyLabsApp\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\n\t\t\t\ttx.object(inputs.parentOneId), // SuiFren\n\t\t\t\ttx.object(inputs.parentTwoId), // SuiFren\n\t\t\t\ttypeof suiPaymentCoinId === \"string\"\n\t\t\t\t\t? tx.object(suiPaymentCoinId)\n\t\t\t\t\t: suiPaymentCoinId, // Coin\n\n\t\t\t\ttx.object(Sui.constants.addresses.suiClockId), // Clock\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Staking Transaction Commands\n\t// =========================================================================\n\n\tpublic stakeAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\tautoStakeFees: boolean;\n\t\tbaseFee: Balance;\n\t\tfeeIncrementPerMix: Balance;\n\t\tminRemainingMixesToKeep: bigint;\n\t\tsuiFrenType: AnyObjectType;\n\t}) /* (StakedPosition) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"stake_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.capyLabsApp), // CapyLabsApp\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.object(inputs.suiFrenId), // SuiFren\n\n\t\t\t\ttx.pure.bool(inputs.autoStakeFees),\n\t\t\t\ttx.pure.u64(inputs.baseFee),\n\t\t\t\ttx.pure.u64(inputs.feeIncrementPerMix),\n\t\t\t\ttx.pure.u8(Number(inputs.minRemainingMixesToKeep)),\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic unstakeAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVaultCapyLabsExtension,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVaultCapyLabsExtension\n\t\t\t\t\t.capyLabs,\n\t\t\t\t\"unstake_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(\n\t\t\t\t\tthis.addresses.objects.suiFrensVaultCapyLabsExtension\n\t\t\t\t), // SuiFrensVaultCapyLabsExt\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Fee Harvest Transaction Commands\n\t// =========================================================================\n\n\tpublic beginHarvestTx = (inputs: {\n\t\ttx: Transaction;\n\t}) /* (HarvestedFeesEventMetadata) */ => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"begin_harvest\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [],\n\t\t});\n\t};\n\n\tpublic harvestTx = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\tharvestFeesEventMetadataId: ObjectId | TransactionArgument;\n\t}) /* (Coin) */ => {\n\t\tconst { tx, harvestFeesEventMetadataId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"harvest\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttypeof harvestFeesEventMetadataId === \"string\"\n\t\t\t\t\t? tx.object(harvestFeesEventMetadataId)\n\t\t\t\t\t: harvestFeesEventMetadataId, // HarvestedFeesEventMetadata\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic endHarvestTx = (inputs: {\n\t\ttx: Transaction;\n\t\tharvestFeesEventMetadataId: ObjectId | TransactionArgument;\n\t}) => {\n\t\tconst { tx, harvestFeesEventMetadataId } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"end_harvest\"\n\t\t\t),\n\t\t\ttypeArguments: [],\n\t\t\targuments: [\n\t\t\t\ttypeof harvestFeesEventMetadataId === \"string\"\n\t\t\t\t\t? tx.object(harvestFeesEventMetadataId)\n\t\t\t\t\t: harvestFeesEventMetadataId, // HarvestedFeesEventMetadata\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Accessory Transaction Commands\n\t// =========================================================================\n\n\tpublic addAccessoryTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\taccessoryId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"add_accessory\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.object(inputs.suiFrenId), // suifren_id\n\t\t\t\ttx.object(inputs.accessoryId), // Accessory\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic addAccessoryToOwnedSuiFrenTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\taccessoryId: ObjectId;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"add_accessory_to_owned_suifren\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.suiFrenId), // suifren_id\n\t\t\t\ttx.object(inputs.accessoryId), // Accessory\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic removeAccessoryAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tstakedPositionId: ObjectId;\n\t\taccessoryType: SuiFrenAccessoryType;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"remove_accessory_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(this.addresses.objects.suiFrensVault), // SuiFrenVault\n\t\t\t\ttx.object(inputs.stakedPositionId), // StakedPosition\n\t\t\t\ttx.object(inputs.accessoryType), // String\n\t\t\t],\n\t\t});\n\t};\n\n\tpublic removeAccessoryFromOwnedSuiFrenAndKeepTx = (inputs: {\n\t\ttx: Transaction;\n\t\tsuiFrenId: ObjectId;\n\t\taccessoryType: SuiFrenAccessoryType;\n\t\tsuiFrenType: AnyObjectType;\n\t}) => {\n\t\tconst { tx } = inputs;\n\n\t\treturn tx.moveCall({\n\t\t\ttarget: Helpers.transactions.createTxTarget(\n\t\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.vault,\n\t\t\t\t\"remove_accessory_from_owned_suifren_and_keep\"\n\t\t\t),\n\t\t\ttypeArguments: [inputs.suiFrenType],\n\t\t\targuments: [\n\t\t\t\ttx.object(inputs.suiFrenId), // SuiFren\n\t\t\t\ttx.object(inputs.accessoryType), // String\n\t\t\t],\n\t\t});\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Staking Transactions\n\t// =========================================================================\n\n\tpublic fetchStakeTx = Helpers.transactions.createBuildTxFunc(\n\t\t(inputs: {\n\t\t\ttx: Transaction;\n\t\t\tsuiFrenId: ObjectId;\n\t\t\tbaseFee: Balance;\n\t\t\tfeeIncrementPerMix: Balance;\n\t\t\tminRemainingMixesToKeep: bigint;\n\t\t\tsuiFrenType: AnyObjectType;\n\t\t}) => this.stakeAndKeepTx({ ...inputs, autoStakeFees: true })\n\t);\n\n\tpublic fetchUnstakeTx = Helpers.transactions.createBuildTxFunc(\n\t\tthis.unstakeAndKeepTx\n\t);\n\n\t// =========================================================================\n\t// Mixing Transactions\n\t// =========================================================================\n\n\tpublic fetchBuildMixTx = async (\n\t\tinputs: ApiMixSuiFrensBody\n\t): Promise<Transaction> => {\n\t\tconst {\n\t\t\twalletAddress,\n\t\t\tsuiFrenParentOne,\n\t\t\tsuiFrenParentTwo,\n\t\t\tsuiFrenType,\n\t\t\tbaseFee,\n\t\t\tisSponsoredTx,\n\t\t} = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(walletAddress);\n\n\t\tconst totalFee =\n\t\t\tbaseFee +\n\t\t\tSuiFrens.calcTotalInternalMixFee({\n\t\t\t\tmixFee1: suiFrenParentOne.mixFee,\n\t\t\t\tmixFee2: suiFrenParentTwo.mixFee,\n\t\t\t});\n\n\t\tconst suiPaymentCoinId =\n\t\t\tawait this.Provider.Coin().fetchCoinWithAmountTx({\n\t\t\t\ttx,\n\t\t\t\twalletAddress,\n\t\t\t\tcoinType: Coin.constants.suiCoinType,\n\t\t\t\tcoinAmount: totalFee,\n\t\t\t\tisSponsoredTx,\n\t\t\t});\n\n\t\tconst isParentOneStaked = suiFrenParentOne.mixFee !== undefined;\n\t\tconst isParentTwoStaked = suiFrenParentTwo.mixFee !== undefined;\n\n\t\tconst parentOneId = suiFrenParentOne.objectId;\n\t\tconst parentTwoId = suiFrenParentTwo.objectId;\n\n\t\tif (isParentOneStaked && isParentTwoStaked) {\n\t\t\t// both staked\n\t\t\tthis.mixStakedWithStakedAndKeepTx({\n\t\t\t\ttx,\n\t\t\t\tparentOneId,\n\t\t\t\tparentTwoId,\n\t\t\t\tsuiPaymentCoinId,\n\t\t\t\tsuiFrenType,\n\t\t\t});\n\t\t} else if (!isParentOneStaked && !isParentTwoStaked) {\n\t\t\t// neither staked\n\t\t\tthis.mixAndKeepTx({\n\t\t\t\ttx,\n\t\t\t\tparentOneId,\n\t\t\t\tparentTwoId,\n\t\t\t\tsuiPaymentCoinId,\n\t\t\t\tsuiFrenType,\n\t\t\t});\n\t\t} else {\n\t\t\t// only one staked\n\t\t\tconst [nonStakedParentId, stakedParentId] = isParentOneStaked\n\t\t\t\t? [parentTwoId, parentOneId]\n\t\t\t\t: [parentOneId, parentTwoId];\n\n\t\t\tthis.mixWithStakedAndKeepTx({\n\t\t\t\ttx,\n\t\t\t\tnonStakedParentId,\n\t\t\t\tstakedParentId,\n\t\t\t\tsuiPaymentCoinId,\n\t\t\t\tsuiFrenType,\n\t\t\t});\n\t\t}\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Fee Harvesting Transactions\n\t// =========================================================================\n\n\tpublic fetchBuildHarvestFeesTx = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tstakedPositionIds: ObjectId[];\n\t}): Promise<Transaction> => {\n\t\tconst { stakedPositionIds } = inputs;\n\n\t\tconst tx = new Transaction();\n\t\ttx.setSender(inputs.walletAddress);\n\n\t\tconst harvestFeesEventMetadataId = this.beginHarvestTx({ tx });\n\n\t\tlet harvestedCoins = [];\n\t\tfor (const stakedPositionId of stakedPositionIds) {\n\t\t\tconst harvestedCoin = this.harvestTx({\n\t\t\t\ttx,\n\t\t\t\tstakedPositionId,\n\t\t\t\tharvestFeesEventMetadataId,\n\t\t\t});\n\t\t\tharvestedCoins.push(harvestedCoin);\n\t\t}\n\n\t\t// TODO: move this merging & transferring behaviour to coins api helpers ?\n\t\tconst coinToTransfer = harvestedCoins[0];\n\n\t\tif (harvestedCoins.length > 1)\n\t\t\ttx.mergeCoins(coinToTransfer, harvestedCoins.slice(1));\n\n\t\ttx.transferObjects([coinToTransfer], inputs.walletAddress);\n\n\t\tthis.endHarvestTx({ tx, harvestFeesEventMetadataId });\n\n\t\treturn tx;\n\t};\n\n\t// =========================================================================\n\t// Accessory Transactions\n\t// =========================================================================\n\n\tpublic fetchBuildAddAccessoryTx = (inputs: ApiAddSuiFrenAccessoryBody) => {\n\t\tif (inputs.isOwned) {\n\t\t\treturn Helpers.transactions.createBuildTxFunc(\n\t\t\t\tthis.addAccessoryToOwnedSuiFrenTx\n\t\t\t)(inputs);\n\t\t}\n\t\treturn Helpers.transactions.createBuildTxFunc(this.addAccessoryTx)(\n\t\t\tinputs\n\t\t);\n\t};\n\n\tpublic fetchBuildRemoveAccessoryTx = (\n\t\tinputs: ApiRemoveSuiFrenAccessoryBody\n\t) => {\n\t\tif (\"suiFrenId\" in inputs) {\n\t\t\treturn Helpers.transactions.createBuildTxFunc(\n\t\t\t\tthis.removeAccessoryFromOwnedSuiFrenAndKeepTx\n\t\t\t)(inputs);\n\t\t}\n\t\treturn Helpers.transactions.createBuildTxFunc(\n\t\t\tthis.removeAccessoryAndKeepTx\n\t\t)(inputs);\n\t};\n\n\t// =========================================================================\n\t// Stats\n\t// =========================================================================\n\n\tpublic fetchSuiFrenStats = async (): Promise<SuiFrenStats> => {\n\t\tconst [suiFrenVault, mixSuiFrenEventsWithinTime] = await Promise.all([\n\t\t\tthis.fetchSuiFrenVaultStateV1Object(),\n\t\t\tthis.Provider.Events().fetchEventsWithinTime({\n\t\t\t\tfetchEventsFunc: this.fetchMixSuiFrensEvents,\n\t\t\t\ttimeUnit: \"hour\",\n\t\t\t\ttime: 24,\n\t\t\t}),\n\t\t]);\n\n\t\tconst mixingFees24hr = Helpers.sumBigInt(\n\t\t\tmixSuiFrenEventsWithinTime.map((event) => event.fee)\n\t\t);\n\n\t\treturn {\n\t\t\ttotalMixes: suiFrenVault.totalMixes,\n\t\t\tcurrentTotalStaked: suiFrenVault.stakedSuiFrens,\n\t\t\tmixingVolume24hr: mixSuiFrenEventsWithinTime.length,\n\t\t\tmixingFees24hr,\n\t\t};\n\t};\n\n\t// =========================================================================\n\t// SuiFren Attribute Filtering\n\t// =========================================================================\n\n\tpublic filterSuiFrensWithAttributes = (inputs: {\n\t\tsuiFrens: SuiFrenObject[];\n\t\tattributes: Partial<SuiFrenAttributes>;\n\t}) => {\n\t\tconst { suiFrens, attributes } = inputs;\n\n\t\tif (Object.keys(attributes).length <= 0) return suiFrens;\n\n\t\treturn suiFrens.filter((suiFren) =>\n\t\t\tObject.entries(attributes).every(([key1, val1]) =>\n\t\t\t\tObject.entries(suiFren.attributes).some(\n\t\t\t\t\t([key2, val2]) =>\n\t\t\t\t\t\tkey1.toLowerCase() === key2.toLowerCase() &&\n\t\t\t\t\t\tval1.toLowerCase() === val2.toLowerCase()\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t};\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\t// TODO: remove or update\n\n\t// public isSuiFrenObjectType = (suiObjectInfo: SuiObjectInfo): boolean =>\n\t// \tsuiObjectInfo.type === this.objectTypes.suiFren;\n\n\t// =========================================================================\n\t// Private Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Helpers\n\t// =========================================================================\n\n\tprivate fetchCompletePartialSuiFrenObjects = async (inputs: {\n\t\tpartialSuiFrens: PartialSuiFrenObject[];\n\t\tisStaked: boolean;\n\t}): Promise<SuiFrenObject[]> => {\n\t\tconst { partialSuiFrens, isStaked } = inputs;\n\n\t\tif (!isStaked) {\n\t\t\treturn Promise.all(\n\t\t\t\tpartialSuiFrens.map((partialSuiFren) =>\n\t\t\t\t\tthis.fetchNonStakedCompletePartialSuiFrenObject({\n\t\t\t\t\t\tpartialSuiFren,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\tif (partialSuiFrens.length <= 0) return [];\n\n\t\tconst [partialSuiFrenBullsharks, partialSuiFrenNonBullsharks] =\n\t\t\tHelpers.bifilter(partialSuiFrens, (partialSuiFren) =>\n\t\t\t\tpartialSuiFren.objectType.includes(this.objectTypes.bullshark)\n\t\t\t);\n\n\t\t// TODO: handle different suifren types\n\t\tconst bullsharkDynamicFields = partialSuiFrenBullsharks.map(() => ({\n\t\t\tmixLimit: undefined,\n\t\t\tlastEpochMixed: undefined,\n\t\t}));\n\t\tconst nonBullsharkDynamicFields =\n\t\t\tawait this.fetchMixingLimitsAndLastEpochMixeds({\n\t\t\t\tsuiFrenIds: partialSuiFrenNonBullsharks.map(\n\t\t\t\t\t(suiFren) => suiFren.objectId\n\t\t\t\t),\n\t\t\t\tsuiFrenType: Coin.getInnerCoinType(\n\t\t\t\t\tpartialSuiFrenNonBullsharks[0].objectType\n\t\t\t\t),\n\t\t\t});\n\n\t\tconst suiFrenBullsharks = bullsharkDynamicFields.map((data, index) => ({\n\t\t\t...partialSuiFrenBullsharks[index],\n\t\t\t...data,\n\t\t}));\n\t\tconst suiFrenNonBullsharks = nonBullsharkDynamicFields.map(\n\t\t\t(data, index) => ({\n\t\t\t\t...partialSuiFrenNonBullsharks[index],\n\t\t\t\t...data,\n\t\t\t})\n\t\t);\n\n\t\treturn [...suiFrenBullsharks, ...suiFrenNonBullsharks];\n\t};\n\n\tprivate fetchNonStakedCompletePartialSuiFrenObject = async (inputs: {\n\t\tpartialSuiFren: PartialSuiFrenObject;\n\t}): Promise<SuiFrenObject> => {\n\t\tconst { partialSuiFren } = inputs;\n\n\t\tconst suiFrenId = partialSuiFren.objectId;\n\t\t// TODO: move inner coin type func to general func in helpers\n\t\tconst suiFrenType = Coin.getInnerCoinType(partialSuiFren.objectType);\n\n\t\tconst [mixLimit, lastEpochMixed] = await Promise.all([\n\t\t\tthis.fetchMixingLimit({ suiFrenId, suiFrenType }),\n\t\t\tthis.fetchLastEpochMixed({ suiFrenId, suiFrenType }),\n\t\t]);\n\n\t\treturn {\n\t\t\t...partialSuiFren,\n\t\t\tmixLimit,\n\t\t\tlastEpochMixed,\n\t\t};\n\t};\n\n\t// TODO: refactor to use NftsApi class\n\tprivate fetchOwnedPartialSuiFrenBullsharks = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<PartialSuiFrenObject[]> => {\n\t\tconst kioskOwnerCaps =\n\t\t\tawait this.Provider.Nfts().fetchOwnedKioskOwnerCaps(inputs);\n\n\t\tconst allBullsharks = await Promise.all(\n\t\t\tkioskOwnerCaps.map((kioskOwnerCap) =>\n\t\t\t\tthis.Provider.DynamicFields().fetchCastAllDynamicFieldsOfType({\n\t\t\t\t\tparentObjectId: kioskOwnerCap.kioskObjectId,\n\t\t\t\t\tobjectsFromObjectIds: (suiFrenIds) =>\n\t\t\t\t\t\tthis.fetchSuiFrens({ suiFrenIds }),\n\t\t\t\t\tdynamicFieldType: (fieldType) =>\n\t\t\t\t\t\tfieldType.includes(this.objectTypes.suiFren) &&\n\t\t\t\t\t\tfieldType.includes(this.objectTypes.bullshark),\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst bullsharks = allBullsharks.reduce(\n\t\t\t(acc, bullsharks) => [...acc, ...bullsharks],\n\t\t\t[]\n\t\t);\n\t\treturn bullsharks;\n\t};\n\n\t// =========================================================================\n\t// Event Types\n\t// =========================================================================\n\n\tprivate harvestSuiFrenFeesEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.events,\n\t\t\tSuiFrensApi.constants.eventNames.suiFrensVault.harvestSuiFrenFees\n\t\t);\n\n\tprivate mixSuiFrensEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.events,\n\t\t\tSuiFrensApi.constants.eventNames.suiFrensVault.mixSuiFrens\n\t\t);\n\n\tprivate stakeSuiFrenEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.events,\n\t\t\tSuiFrensApi.constants.eventNames.suiFrensVault.stakeSuiFren\n\t\t);\n\n\tprivate unstakeSuiFrenEventType = () =>\n\t\tEventsApiHelpers.createEventType(\n\t\t\tthis.addresses.packages.suiFrensVault,\n\t\t\tSuiFrensApi.constants.moduleNames.suiFrensVault.events,\n\t\t\tSuiFrensApi.constants.eventNames.suiFrensVault.unstakeSuiFren\n\t\t);\n}\n","import { AftermathApi } from \"../providers/aftermathApi\";\nimport {\n\tAnyObjectType,\n\tKioskObject,\n\tKioskOwnerCapObject,\n\tNft,\n\tNftsAddresses,\n\tObjectId,\n\tSuiAddress,\n} from \"../../types\";\nimport { Casting, Helpers } from \"../utils\";\nimport { NftsApiCasting } from \"./nftsApiCasting\";\n\nexport class NftsApi {\n\t// =========================================================================\n\t// Constants\n\t// =========================================================================\n\n\t// private static readonly constants: {\n\t// \tobjectTypes: {\n\t// \t\tkiosk: \"0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Kiosk\";\n\t// \t\tkioskOwnerCap: \"0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::KioskOwnerCap\";\n\t// \t};\n\t// };\n\n\t// =========================================================================\n\t// Class Members\n\t// =========================================================================\n\n\tpublic readonly addresses: NftsAddresses;\n\tpublic readonly objectTypes: {\n\t\tpersonalKioskCap: AnyObjectType;\n\t};\n\n\tconstructor(private readonly Provider: AftermathApi) {\n\t\tif (!this.Provider.addresses.nfts)\n\t\t\tthrow new Error(\n\t\t\t\t\"not all required addresses have been set in provider\"\n\t\t\t);\n\n\t\tthis.addresses = this.Provider.addresses.nfts;\n\n\t\tthis.objectTypes = {\n\t\t\tpersonalKioskCap: `${this.addresses.packages.mystenTransferPolicy}::personal_kiosk::PersonalKioskCap`,\n\t\t};\n\t}\n\n\t// =========================================================================\n\t// Public Methods\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Nft Objects\n\t// =========================================================================\n\n\tpublic fetchOwnedNfts = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<Nft[]> => {\n\t\tconst objects = await this.Provider.Objects().fetchOwnedObjects({\n\t\t\t...inputs,\n\t\t\toptions: {\n\t\t\t\t// NOTE: do we need all of this ?\n\t\t\t\tshowContent: true,\n\t\t\t\tshowOwner: true,\n\t\t\t\tshowType: true,\n\t\t\t\tshowDisplay: true,\n\t\t\t},\n\t\t});\n\t\treturn Casting.nfts.nftsFromSuiObjects(objects);\n\t};\n\n\tpublic fetchNfts = async (inputs: {\n\t\tobjectIds: ObjectId[];\n\t}): Promise<Nft[]> => {\n\t\tconst objects = await this.Provider.Objects().fetchObjectBatch({\n\t\t\t...inputs,\n\t\t\toptions: {\n\t\t\t\t// NOTE: do we need all of this ?\n\t\t\t\tshowContent: true,\n\t\t\t\tshowOwner: true,\n\t\t\t\tshowType: true,\n\t\t\t\tshowDisplay: true,\n\t\t\t},\n\t\t});\n\t\treturn Casting.nfts.nftsFromSuiObjects(objects);\n\t};\n\n\t// =========================================================================\n\t// Kiosk Objects\n\t// =========================================================================\n\n\tpublic fetchOwnedKioskOwnerCaps = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<KioskOwnerCapObject[]> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst [kioskOwnerCaps, personalKioskOwnerCaps] = await Promise.all([\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType:\n\t\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::KioskOwnerCap\",\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.nfts.kioskOwnerCapFromSuiObject,\n\t\t\t}),\n\t\t\tthis.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({\n\t\t\t\twalletAddress,\n\t\t\t\tobjectType: this.objectTypes.personalKioskCap,\n\t\t\t\tobjectFromSuiObjectResponse:\n\t\t\t\t\tCasting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject,\n\t\t\t}),\n\t\t]);\n\t\treturn [...kioskOwnerCaps, ...personalKioskOwnerCaps];\n\t};\n\n\tpublic fetchNftsInKiosk = async (inputs: {\n\t\tkioskObjectId: ObjectId;\n\t}): Promise<Nft[]> => {\n\t\tconst { kioskObjectId } = inputs;\n\t\treturn this.Provider.DynamicFields().fetchCastAllDynamicFieldsOfType({\n\t\t\tparentObjectId: kioskObjectId,\n\t\t\tobjectsFromObjectIds: (objectIds) => this.fetchNfts({ objectIds }),\n\t\t});\n\t};\n\n\tpublic fetchKioskOwnerCaps = async (inputs: {\n\t\tkioskOwnerCapIds: ObjectId[];\n\t}): Promise<KioskOwnerCapObject[]> => {\n\t\tconst { kioskOwnerCapIds } = inputs;\n\n\t\treturn this.Provider.Objects().fetchCastObjectBatch({\n\t\t\tobjectIds: kioskOwnerCapIds,\n\t\t\tobjectFromSuiObjectResponse: (response) =>\n\t\t\t\tresponse.data?.type &&\n\t\t\t\tHelpers.addLeadingZeroesToType(response.data?.type) ===\n\t\t\t\t\tthis.objectTypes.personalKioskCap\n\t\t\t\t\t? Casting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject(\n\t\t\t\t\t\t\tresponse\n\t\t\t\t\t )\n\t\t\t\t\t: Casting.nfts.kioskOwnerCapFromSuiObject(response),\n\t\t});\n\t};\n\n\tpublic fetchKiosks = async (inputs: {\n\t\tkioskOwnerCaps: KioskOwnerCapObject[];\n\t}): Promise<KioskObject[]> => {\n\t\tconst { kioskOwnerCaps } = inputs;\n\n\t\tconst nfts = await Promise.all(\n\t\t\tkioskOwnerCaps.map((kioskOwnerCap) =>\n\t\t\t\tthis.fetchNftsInKiosk({\n\t\t\t\t\tkioskObjectId: kioskOwnerCap.kioskObjectId,\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\treturn kioskOwnerCaps.map((kioskOwnerCap, index) => ({\n\t\t\tobjectId: kioskOwnerCap.kioskObjectId,\n\t\t\tobjectType:\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Kiosk\",\n\t\t\tkioskOwnerCapId: kioskOwnerCap.objectId,\n\t\t\tnfts: nfts[index],\n\t\t\tisPersonal:\n\t\t\t\tkioskOwnerCap.objectType === this.objectTypes.personalKioskCap,\n\t\t}));\n\t};\n\n\tpublic fetchKiosksFromOwnerCaps = async (inputs: {\n\t\tkioskOwnerCapIds: ObjectId[];\n\t}): Promise<KioskObject[]> => {\n\t\tconst kioskOwnerCaps = await this.fetchKioskOwnerCaps(inputs);\n\t\treturn this.fetchKiosks({ kioskOwnerCaps });\n\t};\n\n\tpublic fetchOwnedKiosks = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<KioskObject[]> => {\n\t\tconst kioskOwnerCaps = await this.fetchOwnedKioskOwnerCaps(inputs);\n\n\t\tconst nfts = await Promise.all(\n\t\t\tkioskOwnerCaps.map((kioskOwnerCap) =>\n\t\t\t\tthis.fetchNftsInKiosk({\n\t\t\t\t\tkioskObjectId: kioskOwnerCap.kioskObjectId,\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\treturn kioskOwnerCaps.map((kioskOwnerCap, index) => ({\n\t\t\tobjectId: kioskOwnerCap.kioskObjectId,\n\t\t\tobjectType:\n\t\t\t\t\"0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Kiosk\",\n\t\t\tkioskOwnerCapId: kioskOwnerCap.objectId,\n\t\t\tnfts: nfts[index],\n\t\t\tisPersonal:\n\t\t\t\tkioskOwnerCap.objectType === this.objectTypes.personalKioskCap,\n\t\t}));\n\t};\n}\n","import { Helpers } from \"../utils/helpers\";\nimport { TransactionsApiHelpers } from \"../apiHelpers/transactionsApiHelpers\";\nimport { AftermathApi } from \"../providers/aftermathApi\";\nimport { CoinType, CoinsToBalance } from \"../../packages/coin/coinTypes\";\nimport { SuiAddress, TransactionDigest } from \"../types\";\n\nexport class WalletApi {\n\t// =========================================================================\n\t// Constructor\n\t// =========================================================================\n\n\tconstructor(private readonly Provider: AftermathApi) {}\n\n\t// =========================================================================\n\t// Fetching\n\t// =========================================================================\n\n\t// =========================================================================\n\t// Coins\n\t// =========================================================================\n\n\tpublic fetchCoinBalance = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcoin: CoinType;\n\t}) => {\n\t\tconst { walletAddress, coin } = inputs;\n\t\tconst coinBalance = await this.Provider.provider.getBalance({\n\t\t\towner: walletAddress,\n\t\t\tcoinType: Helpers.stripLeadingZeroesFromType(coin),\n\t\t});\n\t\treturn BigInt(coinBalance.totalBalance);\n\t};\n\n\t// TODO: make toBigIntSafe function ?\n\t// TODO: return prices here as well and sort ?\n\tpublic fetchAllCoinBalances = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t}): Promise<CoinsToBalance> => {\n\t\tconst { walletAddress } = inputs;\n\n\t\tconst allBalances = await this.Provider.provider.getAllBalances({\n\t\t\towner: walletAddress,\n\t\t});\n\n\t\tconst coinsToBalance: CoinsToBalance = allBalances.reduce(\n\t\t\t(acc, balance) => {\n\t\t\t\treturn {\n\t\t\t\t\t...acc,\n\t\t\t\t\t[Helpers.addLeadingZeroesToType(balance.coinType)]: BigInt(\n\t\t\t\t\t\tbalance.totalBalance\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn coinsToBalance;\n\t};\n\n\t// =========================================================================\n\t// Transactions\n\t// =========================================================================\n\n\t// TODO: make this only look at aftermath relevant addresses in to address\n\t// TODO: restrict all filtering for events, etc. similarly using updated sdk filters\n\tpublic fetchPastTransactions = async (inputs: {\n\t\twalletAddress: SuiAddress;\n\t\tcursor?: TransactionDigest;\n\t\tlimit?: number;\n\t}) => {\n\t\tconst { walletAddress, cursor, limit } = inputs;\n\n\t\tconst transactionsWithCursor =\n\t\t\tawait this.Provider.Transactions().fetchTransactionsWithCursor({\n\t\t\t\tquery: {\n\t\t\t\t\tfilter: {\n\t\t\t\t\t\tFromAddress: walletAddress,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tcursor,\n\t\t\t\tlimit,\n\t\t\t});\n\n\t\treturn transactionsWithCursor;\n\t};\n}\n","import type { SuiJsonRpcClient } from \"@mysten/sui/jsonRpc\";\nimport { CoinApi } from \"../../packages/coin/api/coinApi\";\nimport { DcaApi } from \"../../packages/dca/api/dcaApi\";\nimport { FarmsApi } from \"../../packages/farms/api/farmsApi\";\nimport { FaucetApi } from \"../../packages/faucet/api/faucetApi\";\nimport { LimitOrdersApi } from \"../../packages/limitOrders/api/limitOrdersApi\";\nimport { MultisigApi } from \"../../packages/multisig/api/multisigApi\";\nimport { NftAmmApi } from \"../../packages/nftAmm/api/nftAmmApi\";\nimport { PerpetualsApi } from \"../../packages/perpetuals/api/perpetualsApi\";\nimport { PoolsApi } from \"../../packages/pools/api/poolsApi\";\nimport { ReferralVaultApi } from \"../../packages/referralVault/api/referralVaultApi\";\nimport { RouterApi } from \"../../packages/router/api/routerApi\";\nimport { StakingApi } from \"../../packages/staking/api/stakingApi\";\nimport { SuiApi } from \"../../packages/sui/api/suiApi\";\nimport { SuiFrensApi } from \"../../packages/suiFrens/api/suiFrensApi\";\nimport type { ModuleName, MoveErrorCode, ObjectId } from \"../../types\";\nimport { DynamicFieldsApiHelpers } from \"../apiHelpers/dynamicFieldsApiHelpers\";\nimport { EventsApiHelpers } from \"../apiHelpers/eventsApiHelpers\";\nimport { InspectionsApiHelpers } from \"../apiHelpers/inspectionsApiHelpers\";\nimport { ObjectsApiHelpers } from \"../apiHelpers/objectsApiHelpers\";\nimport { TransactionsApiHelpers } from \"../apiHelpers/transactionsApiHelpers\";\n\nimport { NftsApi } from \"../nfts/nftsApi\";\nimport type { ConfigAddresses } from \"../types/configTypes\";\nimport type { MoveErrorsInterface } from \"../types/moveErrorsInterface\";\nimport { Helpers } from \"../utils\";\nimport { WalletApi } from \"../wallet/walletApi\";\n\n/**\n * The `AftermathApi` class is a low-level factory and reference point for\n * interacting directly with underlying API modules (e.g., PoolsApi, StakingApi).\n * It encapsulates a configured `SuiClient` and the known `addresses` for the\n * Aftermath protocol, allowing flexible or advanced usage scenarios.\n *\n * @example\n * ```typescript\n * import { AftermathApi } from \"aftermath-ts-sdk\";\n * import { SuiJsonRpcClient } from \"@mysten/sui/jsonRpc\";\n *\n * const addresses = { ... }; // from aftermath.getAddresses()\n * const client = new SuiJsonRpcClient({\n * url: \"https://fullnode.mainnet.sui.io\",\n * network: \"mainnet\",\n * });\n *\n * const afApi = new AftermathApi(client, addresses);\n * // access protocol APIs\n * const poolsApi = afApi.Pools();\n * ```\n */\nexport class AftermathApi {\n // =========================================================================\n // Helpers\n // =========================================================================\n\n /**\n * Static helper references for quick usage without instantiating the class.\n */\n public static helpers = {\n // =========================================================================\n // General\n // =========================================================================\n\n /** Helpers for accessing or iterating over dynamic fields in Sui objects. */\n dynamicFields: DynamicFieldsApiHelpers,\n /** Helpers for working with Sui events and pagination. */\n events: EventsApiHelpers,\n /** Helpers for reading on-chain data in an \"inspection\" manner (designed for Summaries). */\n inspections: InspectionsApiHelpers,\n /** Helpers for retrieving and parsing Sui objects by ID or type. */\n objects: ObjectsApiHelpers,\n /** Helpers for reading transaction data (by digest, query, etc.). */\n transactions: TransactionsApiHelpers,\n\n // =========================================================================\n // Utils\n // =========================================================================\n\n /** Helper for wallet-based operations, separate from the main `Wallet` classes. */\n wallet: WalletApi,\n\n // =========================================================================\n // General Packages\n // =========================================================================\n\n /** Low-level direct coin operations, separate from the higher-level `Coin` class. */\n coin: CoinApi,\n /** Low-level Sui chain data ops, separate from the higher-level `Sui` class. */\n sui: SuiApi,\n };\n\n // =========================================================================\n // Constructor\n // =========================================================================\n\n /**\n * Constructs a new instance of the `AftermathApi`, binding the given Sui client\n * to the known `addresses`.\n *\n * @param provider - A `SuiJsonRpcClient` for on-chain queries and transactions.\n * @param addresses - The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.\n */\n public constructor(\n public readonly provider: SuiJsonRpcClient,\n public readonly addresses: ConfigAddresses\n ) {}\n\n // =========================================================================\n // Class Object Creation\n // =========================================================================\n\n // =========================================================================\n // General\n // =========================================================================\n\n /**\n * Creates a new `DynamicFieldsApiHelpers` instance for complex object field queries.\n */\n public DynamicFields = () => new DynamicFieldsApiHelpers(this);\n\n /**\n * Creates a new `EventsApiHelpers` instance for querying Sui events.\n */\n public Events = () => new EventsApiHelpers(this);\n\n /**\n * Creates a new `InspectionsApiHelpers` instance for reading Summaries or inspection data.\n */\n public Inspections = () => new InspectionsApiHelpers(this);\n\n /**\n * Creates a new `ObjectsApiHelpers` instance for object retrieval/manipulation.\n */\n public Objects = () => new ObjectsApiHelpers(this);\n\n /**\n * Creates a new `TransactionsApiHelpers` instance for querying or parsing transaction data.\n */\n public Transactions = () => new TransactionsApiHelpers(this);\n\n // =========================================================================\n // Utils\n // =========================================================================\n\n /**\n * Creates a new `WalletApi` instance for direct wallet-based operations (fetching balances, etc.).\n */\n public Wallet = () => new WalletApi(this);\n\n /**\n * Creates a new `NftsApi` instance for retrieving and interacting with NFT data.\n */\n public Nfts = () => new NftsApi(this);\n\n // =========================================================================\n // General Packages\n // =========================================================================\n\n /**\n * Creates a new `CoinApi` instance for detailed coin operations.\n */\n public Coin = () => new CoinApi(this);\n\n /**\n * Creates a new `SuiApi` instance for lower-level Sui chain interactions.\n */\n public Sui = () => new SuiApi(this);\n\n // =========================================================================\n // Aftermath Packages\n // =========================================================================\n\n /**\n * Creates a new `PoolsApi` instance for pool-related interactions (AMM pools, liquidity, etc.).\n */\n public Pools = () => new PoolsApi(this);\n\n /**\n * Creates a new `FaucetApi` instance for dispensing tokens on supported dev/test networks.\n */\n public Faucet = () => new FaucetApi(this);\n\n /**\n * Creates a new `SuiFrensApi` instance for special social or token gating utilities on Sui.\n */\n public SuiFrens = () => new SuiFrensApi(this);\n\n /**\n * Creates a new `StakingApi` instance for advanced or direct staking operations on Sui.\n */\n public Staking = () => new StakingApi(this);\n\n /**\n * Creates a new `NftAmmApi` instance for NFT AMM logic (buy, sell, liquidity).\n */\n public NftAmm = () => new NftAmmApi(this);\n\n /**\n * Creates a new `ReferralVaultApi` instance for referral-based logic in Aftermath.\n */\n public ReferralVault = () => new ReferralVaultApi(this);\n\n /**\n * Creates a new `PerpetualsApi` instance for futures or perpetual derivatives on Sui.\n */\n public Perpetuals = () => new PerpetualsApi(this);\n\n /**\n * Creates a new `FarmsApi` instance for yield farming or liquidity mining interactions.\n */\n public Farms = () => new FarmsApi(this);\n\n /**\n * Creates a new `DcaApi` instance for dollar-cost averaging logic.\n */\n public Dca = () => new DcaApi(this);\n\n /**\n * Creates a new `MultisigApi` instance for multi-signature address creation and management.\n */\n public Multisig = () => new MultisigApi(this);\n\n /**\n * Creates a new `LimitOrdersApi` instance for placing limit orders on supported DEX protocols.\n */\n public LimitOrders = () => new LimitOrdersApi(this);\n\n /**\n * Creates a new `RouterApi` instance for best-price trade routing across multiple DEX liquidity sources.\n */\n public Router = () => new RouterApi(this);\n\n // =========================================================================\n // Helpers\n // =========================================================================\n\n /**\n * Attempts to decode a Move error message into a structured error code,\n * package ID, module name, and descriptive error string.\n *\n * @param inputs - An object containing the raw `errorMessage`.\n * @returns An object with `errorCode`, `packageId`, `module`, and `error` if translation is successful, or `undefined`.\n *\n * @example\n * ```typescript\n * const errorDecoded = afApi.translateMoveErrorMessage({ errorMessage: \"MoveAbort at ...\" });\n * if (errorDecoded) {\n * console.log(errorDecoded.errorCode, errorDecoded.error);\n * }\n * ```\n */\n public translateMoveErrorMessage = <T extends MoveErrorsInterface>(inputs: {\n errorMessage: string;\n }):\n | {\n errorCode: MoveErrorCode;\n packageId: ObjectId;\n module: ModuleName;\n error: string;\n }\n | undefined => {\n const { errorMessage } = inputs;\n\n // Candidate packageApis that define `moveErrors` we can search against\n const packageApis: (() => T)[] = [\n // @ts-expect-error\n this.Pools,\n // @ts-expect-error\n this.Staking,\n // @ts-expect-error\n this.Perpetuals,\n // @ts-expect-error\n this.Farms,\n // @ts-expect-error\n this.Router,\n ];\n for (const packageApi of packageApis) {\n try {\n const moveErrors = packageApi().moveErrors;\n const translation = Helpers.translateMoveErrorMessage({\n errorMessage,\n moveErrors,\n });\n if (!translation) {\n continue;\n }\n\n return translation;\n } catch (e) {\n // If any package lacks `moveErrors`, we skip it\n }\n }\n\n return undefined;\n };\n}\n","import { SuiJsonRpcClient } from \"@mysten/sui/jsonRpc\";\nimport { Auth, NftAmm, ReferralVault, Router, Sui } from \"../../packages\";\nimport { Coin } from \"../../packages/coin/coin\";\nimport { Dca } from \"../../packages/dca/dca\";\nimport { Farms } from \"../../packages/farms/farms\";\nimport { Faucet } from \"../../packages/faucet/faucet\";\nimport { LimitOrders } from \"../../packages/limitOrders/limitOrders\";\nimport { Multisig } from \"../../packages/multisig/multisig\";\nimport { Perpetuals } from \"../../packages/perpetuals\";\nimport { Pools } from \"../../packages/pools/pools\";\nimport { Referrals } from \"../../packages/referrals/referrals\";\nimport { Rewards } from \"../../packages/rewards/rewards\";\nimport { Staking } from \"../../packages/staking/staking\";\nimport { SuiFrens } from \"../../packages/suiFrens/suiFrens\";\nimport { UserData } from \"../../packages/userData/userData\";\nimport type {\n CoinType,\n ConfigAddresses,\n SuiAddress,\n SuiNetwork,\n Url,\n} from \"../../types\";\nimport { DynamicGas } from \"../dynamicGas/dynamicGas\";\nimport { Prices } from \"../prices/prices\";\nimport { Caller } from \"../utils/caller\";\nimport { Casting } from \"../utils/casting\";\nimport { Helpers } from \"../utils/helpers\";\nimport { Wallet } from \"../wallet/wallet\";\nimport { AftermathApi } from \"./aftermathApi\";\n\n/**\n * The `Aftermath` class serves as the primary entry point for interacting with\n * the Aftermath Finance protocols and utilities on the Sui blockchain.\n * It provides various sub-providers (e.g. `Router`, `Staking`, `Farms`)\n * initialized under the specified network environment (MAINNET, TESTNET, etc).\n *\n * @example\n * ```typescript\n * // Create provider\n * const aftermath = new Aftermath(\"MAINNET\");\n * // Create package provider\n * const router = aftermath.Router();\n * // Call sdk from package provider\n * const supportedCoins = await router.getSupportedCoins();\n *\n * // Or do it all in one go\n * const supportedCoins = await (new Aftermath(\"MAINNET\")).Router().getSupportedCoins();\n * ```\n */\nexport class Aftermath extends Caller {\n // =========================================================================\n // Constructor\n // =========================================================================\n\n /**\n * Creates an `Aftermath` provider instance to call the Aftermath Finance APIs\n * and interact with Sui-based protocols.\n *\n * @param network - The target Sui network (\"MAINNET\", \"TESTNET\", \"DEVNET\", or \"LOCAL\").\n * @param Provider - Optionally pass a custom `AftermathApi` instance if you already have one.\n */\n constructor(\n private readonly network?: SuiNetwork,\n private Provider?: AftermathApi\n ) {\n super({\n network,\n accessToken: undefined,\n });\n }\n\n // =========================================================================\n // Public Methods\n // =========================================================================\n\n /**\n * Initializes the Aftermath provider by fetching addresses from the backend\n * and configuring the Sui fullnode client. This method must be called before\n * performing many API operations.\n *\n * @param inputs - Optional object allowing you to override the default `fullnodeUrl`.\n * @example\n * ```typescript\n * const afSdk = new Aftermath(\"MAINNET\");\n * await afSdk.init(); // sets up internal providers\n * ```\n */\n public async init(inputs?: { fullnodeUrl: Url }) {\n const addresses = await this.getAddresses();\n\n // Determine the fullnode URL based on the chosen network or user override\n const fullnodeUrl =\n inputs?.fullnodeUrl ??\n (this.network === \"LOCAL\"\n ? \"http://127.0.0.1:9000\"\n : this.network === \"DEVNET\"\n ? \"https://fullnode.devnet.sui.io:443\"\n : this.network === \"TESTNET\"\n ? \"https://fullnode.testnet.sui.io:443\"\n : \"https://fullnode.mainnet.sui.io:443\");\n\n // Create the Sui JSON-RPC client\n const client = new SuiJsonRpcClient({\n url: fullnodeUrl,\n network: this.network?.toLowerCase() ?? \"mainnet\",\n });\n\n // Create a new AftermathApi provider\n this.Provider = new AftermathApi(client, addresses);\n }\n\n /**\n * Retrieves the Aftermath-specific on-chain addresses (object IDs, packages, etc.).\n *\n * @returns A `ConfigAddresses` object containing relevant addresses for the protocol.\n *\n * @example\n * ```typescript\n * const addresses = await aftermath.getAddresses();\n * console.log(addresses); // { routerPackageId: \"...\", someOtherPackageId: \"...\" }\n * ```\n */\n public async getAddresses() {\n return this.fetchApi<ConfigAddresses>(\"addresses\");\n }\n\n /**\n * Returns the base URL used for Aftermath API calls.\n *\n * @returns The base URL for this instance's API.\n *\n * @example\n * ```typescript\n * const apiBaseUrl = aftermath.getApiBaseUrl();\n * console.log(apiBaseUrl); // \"https://api.after...\"\n * ```\n */\n public getApiBaseUrl() {\n return this.apiBaseUrl;\n }\n\n // =========================================================================\n // Class Object Creation\n // =========================================================================\n\n // =========================================================================\n // Packages\n // =========================================================================\n\n /**\n * Returns an instance of the `Pools` class, which handles DEX pool operations\n * within the Aftermath platform (if supported).\n */\n public Pools = () => new Pools(this.config, this.Provider);\n\n /**\n * Returns an instance of the `Staking` class for Aftermath's staking and unstaking features.\n */\n public Staking = () => new Staking(this.config, this.Provider);\n\n /**\n * Returns an instance of `SuiFrens`, a specialized package for social or utility services.\n */\n public SuiFrens = () => new SuiFrens(this.config, this.Provider);\n\n /**\n * Returns an instance of `Faucet`, allowing test/dev networks to dispense tokens.\n */\n public Faucet = () => new Faucet(this.config, this.Provider);\n\n /**\n * Returns an instance of the `Router` class, which handles smart order routing\n * across multiple DEX protocols.\n */\n public Router = () => new Router(this.config);\n /**\n * Returns an instance of `NftAmm`, which supports NFT AMM (automated market maker) features.\n */\n public NftAmm = () => new NftAmm(this.config, this.Provider);\n\n /**\n * Returns an instance of `ReferralVault` for referral-based interactions in the protocol.\n * @deprecated Use `Referrals` instead\n */\n public ReferralVault = () => new ReferralVault(this.config);\n\n /**\n * Returns an instance of `Referrals` for referral-based interactions in the protocol.\n */\n public Referrals = () => new Referrals(this.config);\n\n /**\n * Returns an instance of `Perpetuals` for futures or perpetual contract interactions.\n */\n public Perpetuals = () => new Perpetuals(this.config, this.Provider);\n\n /**\n * Returns an instance of `Rewards` for querying user reward points.\n */\n public Rewards = () => new Rewards(this.config, this.Provider);\n\n /**\n * Returns an instance of `Farms` for yield farming or liquidity mining functionalities.\n */\n public Farms = () => new Farms(this.config, this.Provider);\n\n /**\n * Returns an instance of the `Dca` class, supporting dollar-cost averaging logic.\n */\n public Dca = () => new Dca(this.config);\n\n /**\n * Returns an instance of `Multisig`, enabling multi-signature address creation and management.\n */\n public Multisig = () => new Multisig(this.config, this.Provider);\n\n /**\n * Returns an instance of `LimitOrders`, supporting limit order placement on certain DEX protocols.\n */\n public LimitOrders = () => new LimitOrders(this.config);\n\n /**\n * Returns an instance of `UserData` for creating and managing user-specific data or key storage.\n */\n public UserData = () => new UserData(this.config);\n\n // =========================================================================\n // General\n // =========================================================================\n\n /**\n * Returns an instance of `Sui` for low-level Sui chain information and utilities.\n */\n public Sui = () => new Sui(this.config, this.Provider);\n\n /**\n * Returns an instance of `Prices`, which provides coin price data from external or internal feeds.\n */\n public Prices = () => new Prices(this.config);\n\n /**\n * Creates a new `Wallet` instance for a specific user address, enabling you to fetch balances,\n * transaction history, etc.\n *\n * @param address - The Sui address of the wallet (e.g., \"0x<32_byte_hex>\").\n */\n public Wallet = (address: SuiAddress) =>\n new Wallet(address, this.config, this.Provider);\n\n /**\n * Returns an instance of the `Coin` class, which handles coin metadata, decimal conversions,\n * and other coin-related utilities for a specified `CoinType`.\n *\n * @param coinType - Optionally specify a coin type for immediate usage in coin methods.\n */\n public Coin = (coinType?: CoinType) =>\n new Coin(coinType, this.config, this.Provider);\n\n /**\n * Returns an instance of `DynamicGas`, enabling dynamic assignment of gas\n * objects or sponsored transactions for user operations.\n */\n public DynamicGas = () => new DynamicGas(this.config);\n\n /**\n * Returns an instance of `Auth`, handling user authentication or token-based flows (if applicable).\n */\n public Auth = () => new Auth(this.config);\n\n // =========================================================================\n // Utils\n // =========================================================================\n\n /**\n * Exposes a set of helper functions for general-purpose usage across\n * the Aftermath ecosystem. Includes utilities for math, logging, etc.\n */\n public static helpers = Helpers;\n\n /**\n * Exposes a set of casting utilities for data type conversions (e.g., BigInt <-> fixed).\n */\n public static casting = Casting;\n}\n","export * from \"./aftermath\";\nexport * from \"./aftermathApi\";\n","export * from \"./general/providers\";\nexport * from \"./packages\";\nexport * from \"./types\";\nexport * from \"./general/utils\";\n"],"mappings":";;;;;;;;;;;AAAA,IAUa;AAVb;AAAA;AAAA;AAUO,IAAM,2BAAN,MAAM,yBAAwB;AAAA;AAAA;AAAA;AAAA,MAapC,YAA6B,UAAwB;AAAxB;AAU7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAO,yCAAyC,OAAmB,WAQT;AACzD,gBAAM,EAAE,eAAe,WAAW,IACjC,MAAM,KAAK,mCAAmC,MAAM;AAErD,gBAAM,wBAAwB,cAAc;AAAA,YAC3C,CAAC,UAAU,MAAM;AAAA,UAClB;AACA,gBAAM,sBAAsB,MAAM,OAAO;AAAA,YACxC;AAAA,UACD;AAEA,iBAAO;AAAA,YACN;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAEA,aAAO,8BAA8B,OAAO,WAMtC;AACL,cAAI,mBAAuC,CAAC;AAC5C,cAAI,SAA+B;AACnC,aAAG;AACF,kBAAM,0BACL,MAAM,KAAK,mCAAmC;AAAA,cAC7C,GAAG;AAAA,cACH;AAAA,cACA,OACC,OAAO,iBACP,yBAAwB,UAAU;AAAA,YACpC,CAAC;AACF,kBAAM,gBAAgB,wBAAwB;AAC9C,+BAAmB,CAAC,GAAG,kBAAkB,GAAG,aAAa;AAEzD,gBACC,cAAc,WAAW,KACzB,wBAAwB,eAAe;AAEvC,qBAAO;AACR,qBAAS,wBAAwB;AAAA,UAClC,SAAS;AAAA,QACV;AAEA,aAAO,kCAAkC,OAAmB,WAStD;AACL,gBAAM,gBAAgB,MAAM,KAAK,4BAA4B,MAAM;AACnE,gBAAM,wBAAwB,cAAc;AAAA,YAC3C,CAAC,UAAU,MAAM;AAAA,UAClB;AACA,gBAAM,sBAAsB,MAAM,OAAO;AAAA,YACxC;AAAA,UACD;AACA,iBAAO;AAAA,QACR;AAEA,aAAO,0BAA0B,OAAmB,WAOM;AACzD,gBAAM,EAAE,WAAW,YA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AAK,KAAK,MAAM;AAAA,MAtMxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAkBA,MAAa,KAAK,QAA+B;AAC/C,cAAM,YAAY,MAAM,KAAK,aAAa;AAG1C,cAAM,cACJ,QAAQ,gBACP,KAAK,YAAY,UACd,0BACA,KAAK,YAAY,WACf,uCACA,KAAK,YAAY,YACf,wCACA;AAGV,cAAM,SAAS,IAAI,iBAAiB;AAAA,UAClC,KAAK;AAAA,UACL,SAAS,KAAK,SAAS,YAAY,KAAK;AAAA,QAC1C,CAAC;AAGD,aAAK,WAAW,IAAIC,cAAa,QAAQ,SAAS;AAAA,MACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAaA,MAAa,eAAe;AAC1B,eAAO,KAAK,SAA0B,WAAW;AAAA,MACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAaO,gBAAgB;AACrB,eAAO,KAAK;AAAA,MACd;AAAA,IAgJF;AANE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IApOW,UAoOG,UAAU;AAKxB;AAAA;AAAA;AAAA,IAzOW,UAyOG,UAAU;AAAA;AAAA;;;AC1R1B;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;;;ACDA;AAAA;AAAA;AACA;AACA,IAAAC;AACA;AAAA;AAAA;","names":["init_coin","init_coin","init_coin","init_coin","PerpetualsOrderSide","PerpetualsOrderType","PerpetualsStopOrderType","objectIds","Casting","inputs","errorMessage","errorCode","packageId","Transaction","path","init_auth","dayjs","dayjs","init_farms","init_faucet","init_pools","init_pools","init_pools","init_nftAmm","SuiFrensSortOption","init_types","Transaction","PerpetualsAccount","init_types","init_perpetuals","init_utils","Transaction","Transaction","init_types","init_utils","PerpetualsAccount","init_perpetuals","init_referralVault","Transaction","init_router","init_staking","init_sui","dayjs","init_coin","init_suiFrens","init_auth","init_coin","init_farms","init_faucet","init_nftAmm","init_perpetuals","init_pools","init_referralVault","init_router","init_staking","init_sui","init_suiFrens","Transaction","coinData","Transaction","init_sui","Transaction","init_coin","init_sui","Transaction","Transaction","bcs","init_coin","Transaction","bcs","Transaction","init_coin","init_sui","AftermathApi","Transaction","bcs","bullsharks","AftermathApi","init_perpetuals","AftermathApi","init_types"]}
|