@mento-protocol/mento-sdk 3.2.7-beta.0 → 3.2.7
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/package.json +1 -1
- package/dist/cache/routes.d.ts +0 -13
- package/dist/cache/routes.js +0 -14649
- package/dist/cache/tokens.d.ts +0 -68
- package/dist/cache/tokens.js +0 -488
- package/dist/core/abis/activePool.d.ts +0 -2
- package/dist/core/abis/activePool.js +0 -14
- package/dist/core/abis/addressesRegistry.d.ts +0 -2
- package/dist/core/abis/addressesRegistry.js +0 -26
- package/dist/core/abis/bipoolmanager.d.ts +0 -34
- package/dist/core/abis/bipoolmanager.js +0 -72
- package/dist/core/abis/borrowerOperations.d.ts +0 -9
- package/dist/core/abis/borrowerOperations.js +0 -89
- package/dist/core/abis/breakerbox.d.ts +0 -13
- package/dist/core/abis/breakerbox.js +0 -8
- package/dist/core/abis/broker.d.ts +0 -2
- package/dist/core/abis/broker.js +0 -9
- package/dist/core/abis/erc20.d.ts +0 -9
- package/dist/core/abis/erc20.js +0 -21
- package/dist/core/abis/fpmm.d.ts +0 -270
- package/dist/core/abis/fpmm.js +0 -49
- package/dist/core/abis/fpmmFactory.d.ts +0 -85
- package/dist/core/abis/fpmmFactory.js +0 -26
- package/dist/core/abis/hintHelpers.d.ts +0 -2
- package/dist/core/abis/hintHelpers.js +0 -14
- package/dist/core/abis/index.d.ts +0 -22
- package/dist/core/abis/index.js +0 -38
- package/dist/core/abis/liquidityStrategy.d.ts +0 -132
- package/dist/core/abis/liquidityStrategy.js +0 -10
- package/dist/core/abis/multiTroveGetter.d.ts +0 -8
- package/dist/core/abis/multiTroveGetter.js +0 -15
- package/dist/core/abis/priceFeed.d.ts +0 -7
- package/dist/core/abis/priceFeed.js +0 -16
- package/dist/core/abis/pricingmodule.d.ts +0 -2
- package/dist/core/abis/pricingmodule.js +0 -6
- package/dist/core/abis/reserve.d.ts +0 -3
- package/dist/core/abis/reserve.js +0 -18
- package/dist/core/abis/router.d.ts +0 -521
- package/dist/core/abis/router.js +0 -45
- package/dist/core/abis/sortedTroves.d.ts +0 -2
- package/dist/core/abis/sortedTroves.js +0 -15
- package/dist/core/abis/systemParams.d.ts +0 -2
- package/dist/core/abis/systemParams.js +0 -14
- package/dist/core/abis/troveManager.d.ts +0 -2
- package/dist/core/abis/troveManager.js +0 -27
- package/dist/core/abis/troveNFT.d.ts +0 -2
- package/dist/core/abis/troveNFT.js +0 -9
- package/dist/core/abis/virtualPool.d.ts +0 -50
- package/dist/core/abis/virtualPool.js +0 -11
- package/dist/core/abis/virtualPoolFactory.d.ts +0 -59
- package/dist/core/abis/virtualPoolFactory.js +0 -17
- package/dist/core/constants/addresses.d.ts +0 -18
- package/dist/core/constants/addresses.js +0 -113
- package/dist/core/constants/borrowConstants.d.ts +0 -10
- package/dist/core/constants/borrowConstants.js +0 -16
- package/dist/core/constants/borrowRegistries.d.ts +0 -7
- package/dist/core/constants/borrowRegistries.js +0 -34
- package/dist/core/constants/chainId.d.ts +0 -7
- package/dist/core/constants/chainId.js +0 -11
- package/dist/core/constants/contractNames.d.ts +0 -21
- package/dist/core/constants/contractNames.js +0 -24
- package/dist/core/constants/index.d.ts +0 -6
- package/dist/core/constants/index.js +0 -22
- package/dist/core/errors/base.d.ts +0 -8
- package/dist/core/errors/base.js +0 -17
- package/dist/core/errors/index.d.ts +0 -4
- package/dist/core/errors/index.js +0 -20
- package/dist/core/errors/oracle.d.ts +0 -9
- package/dist/core/errors/oracle.js +0 -15
- package/dist/core/errors/router.d.ts +0 -14
- package/dist/core/errors/router.js +0 -24
- package/dist/core/types/borrow.d.ts +0 -87
- package/dist/core/types/borrow.js +0 -3
- package/dist/core/types/contractAddresses.d.ts +0 -42
- package/dist/core/types/contractAddresses.js +0 -3
- package/dist/core/types/index.d.ts +0 -10
- package/dist/core/types/index.js +0 -26
- package/dist/core/types/liquidity.d.ts +0 -194
- package/dist/core/types/liquidity.js +0 -3
- package/dist/core/types/pool.d.ts +0 -208
- package/dist/core/types/pool.js +0 -14
- package/dist/core/types/provider.d.ts +0 -45
- package/dist/core/types/provider.js +0 -3
- package/dist/core/types/route.d.ts +0 -62
- package/dist/core/types/route.js +0 -3
- package/dist/core/types/token.d.ts +0 -21
- package/dist/core/types/token.js +0 -3
- package/dist/core/types/tradingLimits.d.ts +0 -91
- package/dist/core/types/tradingLimits.js +0 -3
- package/dist/core/types/tradingMode.d.ts +0 -24
- package/dist/core/types/tradingMode.js +0 -31
- package/dist/core/types/transaction.d.ts +0 -45
- package/dist/core/types/transaction.js +0 -3
- package/dist/esm/cache/routes.js +0 -14644
- package/dist/esm/cache/tokens.js +0 -480
- package/dist/esm/core/abis/activePool.js +0 -10
- package/dist/esm/core/abis/addressesRegistry.js +0 -22
- package/dist/esm/core/abis/bipoolmanager.js +0 -68
- package/dist/esm/core/abis/borrowerOperations.js +0 -85
- package/dist/esm/core/abis/breakerbox.js +0 -4
- package/dist/esm/core/abis/broker.js +0 -5
- package/dist/esm/core/abis/erc20.js +0 -17
- package/dist/esm/core/abis/fpmm.js +0 -45
- package/dist/esm/core/abis/fpmmFactory.js +0 -22
- package/dist/esm/core/abis/hintHelpers.js +0 -10
- package/dist/esm/core/abis/index.js +0 -21
- package/dist/esm/core/abis/liquidityStrategy.js +0 -6
- package/dist/esm/core/abis/multiTroveGetter.js +0 -11
- package/dist/esm/core/abis/priceFeed.js +0 -12
- package/dist/esm/core/abis/pricingmodule.js +0 -2
- package/dist/esm/core/abis/reserve.js +0 -14
- package/dist/esm/core/abis/router.js +0 -41
- package/dist/esm/core/abis/sortedTroves.js +0 -11
- package/dist/esm/core/abis/systemParams.js +0 -10
- package/dist/esm/core/abis/troveManager.js +0 -23
- package/dist/esm/core/abis/troveNFT.js +0 -5
- package/dist/esm/core/abis/virtualPool.js +0 -7
- package/dist/esm/core/abis/virtualPoolFactory.js +0 -13
- package/dist/esm/core/constants/addresses.js +0 -107
- package/dist/esm/core/constants/borrowConstants.js +0 -12
- package/dist/esm/core/constants/borrowRegistries.js +0 -29
- package/dist/esm/core/constants/chainId.js +0 -7
- package/dist/esm/core/constants/contractNames.js +0 -20
- package/dist/esm/core/constants/index.js +0 -5
- package/dist/esm/core/errors/base.js +0 -12
- package/dist/esm/core/errors/index.js +0 -3
- package/dist/esm/core/errors/oracle.js +0 -10
- package/dist/esm/core/errors/router.js +0 -18
- package/dist/esm/core/types/borrow.js +0 -1
- package/dist/esm/core/types/contractAddresses.js +0 -1
- package/dist/esm/core/types/index.js +0 -9
- package/dist/esm/core/types/liquidity.js +0 -1
- package/dist/esm/core/types/pool.js +0 -10
- package/dist/esm/core/types/provider.js +0 -1
- package/dist/esm/core/types/route.js +0 -1
- package/dist/esm/core/types/token.js +0 -1
- package/dist/esm/core/types/tradingLimits.js +0 -1
- package/dist/esm/core/types/tradingMode.js +0 -26
- package/dist/esm/core/types/transaction.js +0 -1
- package/dist/esm/index.js +0 -139
- package/dist/esm/package.json +0 -1
- package/dist/esm/services/borrow/BorrowService.js +0 -455
- package/dist/esm/services/borrow/borrowHelpers.js +0 -3
- package/dist/esm/services/borrow/borrowMath.js +0 -127
- package/dist/esm/services/borrow/index.js +0 -3
- package/dist/esm/services/borrow/internal/borrowApprovalService.js +0 -48
- package/dist/esm/services/borrow/internal/borrowContextStore.js +0 -35
- package/dist/esm/services/borrow/internal/borrowErc20.js +0 -38
- package/dist/esm/services/borrow/internal/borrowHints.js +0 -27
- package/dist/esm/services/borrow/internal/borrowPositionParser.js +0 -82
- package/dist/esm/services/borrow/internal/borrowReadService.js +0 -271
- package/dist/esm/services/borrow/internal/borrowRegistryReader.js +0 -108
- package/dist/esm/services/borrow/internal/borrowTransactionService.js +0 -271
- package/dist/esm/services/borrow/internal/borrowTypes.js +0 -1
- package/dist/esm/services/borrow/internal/borrowValidation.js +0 -89
- package/dist/esm/services/index.js +0 -8
- package/dist/esm/services/liquidity/LiquidityService.js +0 -163
- package/dist/esm/services/liquidity/basicLiquidity.js +0 -162
- package/dist/esm/services/liquidity/index.js +0 -1
- package/dist/esm/services/liquidity/liquidityHelpers.js +0 -95
- package/dist/esm/services/liquidity/rebalance.js +0 -59
- package/dist/esm/services/liquidity/zapHelpers.js +0 -181
- package/dist/esm/services/liquidity/zapIn.js +0 -131
- package/dist/esm/services/liquidity/zapOut.js +0 -248
- package/dist/esm/services/pools/PoolService.js +0 -204
- package/dist/esm/services/pools/index.js +0 -1
- package/dist/esm/services/pools/poolDetails.js +0 -209
- package/dist/esm/services/pools/poolDiscovery.js +0 -112
- package/dist/esm/services/pools/rebalancePreview.js +0 -181
- package/dist/esm/services/quotes/QuoteService.js +0 -85
- package/dist/esm/services/quotes/index.js +0 -1
- package/dist/esm/services/routes/RouteService.js +0 -268
- package/dist/esm/services/routes/index.js +0 -1
- package/dist/esm/services/swap/SwapService.js +0 -247
- package/dist/esm/services/swap/index.js +0 -1
- package/dist/esm/services/tokens/index.js +0 -1
- package/dist/esm/services/tokens/tokenService.js +0 -285
- package/dist/esm/services/trading/TradingLimitsService.js +0 -154
- package/dist/esm/services/trading/TradingService.js +0 -222
- package/dist/esm/services/trading/index.js +0 -2
- package/dist/esm/utils/chainConfig.js +0 -118
- package/dist/esm/utils/costUtils.js +0 -56
- package/dist/esm/utils/deadline.js +0 -22
- package/dist/esm/utils/index.js +0 -9
- package/dist/esm/utils/multicall.js +0 -47
- package/dist/esm/utils/pathEncoder.js +0 -69
- package/dist/esm/utils/rateFeed.js +0 -23
- package/dist/esm/utils/retry.js +0 -24
- package/dist/esm/utils/routeUtils.js +0 -361
- package/dist/esm/utils/routes.js +0 -2
- package/dist/esm/utils/sortUtils.js +0 -33
- package/dist/esm/utils/tokens.js +0 -2
- package/dist/esm/utils/tradingLimits.js +0 -163
- package/dist/esm/utils/validation.js +0 -30
- package/dist/index.d.ts +0 -101
- package/dist/index.js +0 -158
- package/dist/services/borrow/BorrowService.d.ts +0 -381
- package/dist/services/borrow/BorrowService.js +0 -460
- package/dist/services/borrow/borrowHelpers.d.ts +0 -4
- package/dist/services/borrow/borrowHelpers.js +0 -13
- package/dist/services/borrow/borrowMath.d.ts +0 -21
- package/dist/services/borrow/borrowMath.js +0 -137
- package/dist/services/borrow/index.d.ts +0 -4
- package/dist/services/borrow/index.js +0 -20
- package/dist/services/borrow/internal/borrowApprovalService.d.ts +0 -14
- package/dist/services/borrow/internal/borrowApprovalService.js +0 -53
- package/dist/services/borrow/internal/borrowContextStore.d.ts +0 -11
- package/dist/services/borrow/internal/borrowContextStore.js +0 -40
- package/dist/services/borrow/internal/borrowErc20.d.ts +0 -5
- package/dist/services/borrow/internal/borrowErc20.js +0 -43
- package/dist/services/borrow/internal/borrowHints.d.ts +0 -7
- package/dist/services/borrow/internal/borrowHints.js +0 -31
- package/dist/services/borrow/internal/borrowPositionParser.d.ts +0 -4
- package/dist/services/borrow/internal/borrowPositionParser.js +0 -87
- package/dist/services/borrow/internal/borrowReadService.d.ts +0 -31
- package/dist/services/borrow/internal/borrowReadService.js +0 -276
- package/dist/services/borrow/internal/borrowRegistryReader.d.ts +0 -5
- package/dist/services/borrow/internal/borrowRegistryReader.js +0 -113
- package/dist/services/borrow/internal/borrowTransactionService.d.ts +0 -23
- package/dist/services/borrow/internal/borrowTransactionService.js +0 -276
- package/dist/services/borrow/internal/borrowTypes.d.ts +0 -15
- package/dist/services/borrow/internal/borrowTypes.js +0 -3
- package/dist/services/borrow/internal/borrowValidation.d.ts +0 -14
- package/dist/services/borrow/internal/borrowValidation.js +0 -104
- package/dist/services/index.d.ts +0 -9
- package/dist/services/index.js +0 -25
- package/dist/services/liquidity/LiquidityService.d.ts +0 -139
- package/dist/services/liquidity/LiquidityService.js +0 -168
- package/dist/services/liquidity/basicLiquidity.d.ts +0 -11
- package/dist/services/liquidity/basicLiquidity.js +0 -172
- package/dist/services/liquidity/index.d.ts +0 -2
- package/dist/services/liquidity/index.js +0 -18
- package/dist/services/liquidity/liquidityHelpers.d.ts +0 -19
- package/dist/services/liquidity/liquidityHelpers.js +0 -104
- package/dist/services/liquidity/rebalance.d.ts +0 -6
- package/dist/services/liquidity/rebalance.js +0 -64
- package/dist/services/liquidity/zapHelpers.d.ts +0 -100
- package/dist/services/liquidity/zapHelpers.js +0 -192
- package/dist/services/liquidity/zapIn.d.ts +0 -18
- package/dist/services/liquidity/zapIn.js +0 -138
- package/dist/services/liquidity/zapOut.d.ts +0 -9
- package/dist/services/liquidity/zapOut.js +0 -255
- package/dist/services/pools/PoolService.d.ts +0 -69
- package/dist/services/pools/PoolService.js +0 -209
- package/dist/services/pools/index.d.ts +0 -2
- package/dist/services/pools/index.js +0 -18
- package/dist/services/pools/poolDetails.d.ts +0 -13
- package/dist/services/pools/poolDetails.js +0 -216
- package/dist/services/pools/poolDiscovery.d.ts +0 -12
- package/dist/services/pools/poolDiscovery.js +0 -117
- package/dist/services/pools/rebalancePreview.d.ts +0 -5
- package/dist/services/pools/rebalancePreview.js +0 -186
- package/dist/services/quotes/QuoteService.d.ts +0 -51
- package/dist/services/quotes/QuoteService.js +0 -91
- package/dist/services/quotes/index.d.ts +0 -2
- package/dist/services/quotes/index.js +0 -18
- package/dist/services/routes/RouteService.d.ts +0 -117
- package/dist/services/routes/RouteService.js +0 -306
- package/dist/services/routes/index.d.ts +0 -2
- package/dist/services/routes/index.js +0 -18
- package/dist/services/swap/SwapService.d.ts +0 -198
- package/dist/services/swap/SwapService.js +0 -252
- package/dist/services/swap/index.d.ts +0 -2
- package/dist/services/swap/index.js +0 -18
- package/dist/services/tokens/index.d.ts +0 -2
- package/dist/services/tokens/index.js +0 -18
- package/dist/services/tokens/tokenService.d.ts +0 -55
- package/dist/services/tokens/tokenService.js +0 -290
- package/dist/services/trading/TradingLimitsService.d.ts +0 -38
- package/dist/services/trading/TradingLimitsService.js +0 -159
- package/dist/services/trading/TradingService.d.ts +0 -115
- package/dist/services/trading/TradingService.js +0 -227
- package/dist/services/trading/index.d.ts +0 -3
- package/dist/services/trading/index.js +0 -19
- package/dist/utils/chainConfig.d.ts +0 -16
- package/dist/utils/chainConfig.js +0 -123
- package/dist/utils/costUtils.d.ts +0 -12
- package/dist/utils/costUtils.js +0 -60
- package/dist/utils/deadline.d.ts +0 -21
- package/dist/utils/deadline.js +0 -26
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/index.js +0 -26
- package/dist/utils/multicall.d.ts +0 -30
- package/dist/utils/multicall.js +0 -52
- package/dist/utils/pathEncoder.d.ts +0 -34
- package/dist/utils/pathEncoder.js +0 -73
- package/dist/utils/rateFeed.d.ts +0 -18
- package/dist/utils/rateFeed.js +0 -27
- package/dist/utils/retry.d.ts +0 -12
- package/dist/utils/retry.js +0 -28
- package/dist/utils/routeUtils.d.ts +0 -295
- package/dist/utils/routeUtils.js +0 -371
- package/dist/utils/routes.d.ts +0 -3
- package/dist/utils/routes.js +0 -8
- package/dist/utils/sortUtils.d.ts +0 -24
- package/dist/utils/sortUtils.js +0 -39
- package/dist/utils/tokens.d.ts +0 -2
- package/dist/utils/tokens.js +0 -13
- package/dist/utils/tradingLimits.d.ts +0 -41
- package/dist/utils/tradingLimits.js +0 -171
- package/dist/utils/validation.d.ts +0 -19
- package/dist/utils/validation.js +0 -34
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveAddressesFromRegistry = resolveAddressesFromRegistry;
|
|
4
|
-
exports.readSystemParams = readSystemParams;
|
|
5
|
-
const abis_1 = require("../../../core/abis");
|
|
6
|
-
const multicall_1 = require("../../../utils/multicall");
|
|
7
|
-
const validation_1 = require("../../../utils/validation");
|
|
8
|
-
function readNoArgsContract(publicClient, address, abi, functionName) {
|
|
9
|
-
const readContract = publicClient.readContract;
|
|
10
|
-
return readContract({ address, abi, functionName, args: [] });
|
|
11
|
-
}
|
|
12
|
-
async function readNoArgsContracts(publicClient, contracts) {
|
|
13
|
-
if (contracts.length === 0) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
const results = await (0, multicall_1.multicall)(publicClient, contracts.map((contract) => ({
|
|
17
|
-
...contract,
|
|
18
|
-
abi: contract.abi,
|
|
19
|
-
args: [],
|
|
20
|
-
})), { allowFailure: false });
|
|
21
|
-
return results.map((result) => {
|
|
22
|
-
if (result.status === 'failure') {
|
|
23
|
-
throw result.error;
|
|
24
|
-
}
|
|
25
|
-
return result.result;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function requireAddress(value, fieldName) {
|
|
29
|
-
if (typeof value !== 'string') {
|
|
30
|
-
throw new Error(`${fieldName} must be a string address`);
|
|
31
|
-
}
|
|
32
|
-
(0, validation_1.validateAddress)(value, fieldName);
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
function requireBigInt(value, fieldName) {
|
|
36
|
-
if (typeof value !== 'bigint') {
|
|
37
|
-
throw new Error(`${fieldName} must be a bigint`);
|
|
38
|
-
}
|
|
39
|
-
if (value < 0n) {
|
|
40
|
-
throw new Error(`${fieldName} cannot be negative`);
|
|
41
|
-
}
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
async function resolveAddressesFromRegistry(publicClient, registryAddress) {
|
|
45
|
-
(0, validation_1.validateAddress)(registryAddress, 'registryAddress');
|
|
46
|
-
const registry = registryAddress;
|
|
47
|
-
const [borrowerOperationsRaw, troveManagerRaw, sortedTrovesRaw, activePoolRaw, defaultPoolRaw, hintHelpersRaw, multiTroveGetterRaw, collTokenRaw, debtTokenRaw, troveNFTRaw, metadataNFTRaw, stabilityPoolRaw, priceFeedRaw, collSurplusPoolRaw, interestRouterRaw, collateralRegistryRaw, gasTokenRaw, gasPoolAddressRaw, liquidityStrategyRaw,] = await readNoArgsContracts(publicClient, [
|
|
48
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'borrowerOperations' },
|
|
49
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'troveManager' },
|
|
50
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'sortedTroves' },
|
|
51
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'activePool' },
|
|
52
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'defaultPool' },
|
|
53
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'hintHelpers' },
|
|
54
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'multiTroveGetter' },
|
|
55
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'collToken' },
|
|
56
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'boldToken' },
|
|
57
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'troveNFT' },
|
|
58
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'metadataNFT' },
|
|
59
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'stabilityPool' },
|
|
60
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'priceFeed' },
|
|
61
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'collSurplusPool' },
|
|
62
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'interestRouter' },
|
|
63
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'collateralRegistry' },
|
|
64
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'gasToken' },
|
|
65
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'gasPoolAddress' },
|
|
66
|
-
{ address: registry, abi: abis_1.ADDRESSES_REGISTRY_ABI, functionName: 'liquidityStrategy' },
|
|
67
|
-
]);
|
|
68
|
-
return {
|
|
69
|
-
borrowerOperations: requireAddress(borrowerOperationsRaw, 'borrowerOperations'),
|
|
70
|
-
troveManager: requireAddress(troveManagerRaw, 'troveManager'),
|
|
71
|
-
sortedTroves: requireAddress(sortedTrovesRaw, 'sortedTroves'),
|
|
72
|
-
activePool: requireAddress(activePoolRaw, 'activePool'),
|
|
73
|
-
defaultPool: requireAddress(defaultPoolRaw, 'defaultPool'),
|
|
74
|
-
hintHelpers: requireAddress(hintHelpersRaw, 'hintHelpers'),
|
|
75
|
-
multiTroveGetter: requireAddress(multiTroveGetterRaw, 'multiTroveGetter'),
|
|
76
|
-
collToken: requireAddress(collTokenRaw, 'collToken'),
|
|
77
|
-
debtToken: requireAddress(debtTokenRaw, 'debtToken'),
|
|
78
|
-
troveNFT: requireAddress(troveNFTRaw, 'troveNFT'),
|
|
79
|
-
metadataNFT: requireAddress(metadataNFTRaw, 'metadataNFT'),
|
|
80
|
-
stabilityPool: requireAddress(stabilityPoolRaw, 'stabilityPool'),
|
|
81
|
-
priceFeed: requireAddress(priceFeedRaw, 'priceFeed'),
|
|
82
|
-
collSurplusPool: requireAddress(collSurplusPoolRaw, 'collSurplusPool'),
|
|
83
|
-
interestRouter: requireAddress(interestRouterRaw, 'interestRouter'),
|
|
84
|
-
collateralRegistry: requireAddress(collateralRegistryRaw, 'collateralRegistry'),
|
|
85
|
-
gasToken: requireAddress(gasTokenRaw, 'gasToken'),
|
|
86
|
-
gasPoolAddress: requireAddress(gasPoolAddressRaw, 'gasPoolAddress'),
|
|
87
|
-
liquidityStrategy: requireAddress(liquidityStrategyRaw, 'liquidityStrategy'),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
async function readSystemParams(publicClient, borrowerOperations) {
|
|
91
|
-
(0, validation_1.validateAddress)(borrowerOperations, 'borrowerOperations');
|
|
92
|
-
const systemParamsAddressRaw = await readNoArgsContract(publicClient, borrowerOperations, abis_1.BORROWER_OPERATIONS_ABI, 'systemParams');
|
|
93
|
-
const systemParamsAddress = requireAddress(systemParamsAddressRaw, 'systemParamsAddress');
|
|
94
|
-
const [ccrRaw, mcrRaw, scrRaw, bcrRaw, minDebtRaw, ethGasCompensationRaw, minAnnualInterestRateRaw,] = await readNoArgsContracts(publicClient, [
|
|
95
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'CCR' },
|
|
96
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'MCR' },
|
|
97
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'SCR' },
|
|
98
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'BCR' },
|
|
99
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'MIN_DEBT' },
|
|
100
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'ETH_GAS_COMPENSATION' },
|
|
101
|
-
{ address: systemParamsAddress, abi: abis_1.SYSTEM_PARAMS_ABI, functionName: 'MIN_ANNUAL_INTEREST_RATE' },
|
|
102
|
-
]);
|
|
103
|
-
return {
|
|
104
|
-
mcr: requireBigInt(mcrRaw, 'MCR'),
|
|
105
|
-
ccr: requireBigInt(ccrRaw, 'CCR'),
|
|
106
|
-
scr: requireBigInt(scrRaw, 'SCR'),
|
|
107
|
-
bcr: requireBigInt(bcrRaw, 'BCR'),
|
|
108
|
-
minDebt: requireBigInt(minDebtRaw, 'MIN_DEBT'),
|
|
109
|
-
ethGasCompensation: requireBigInt(ethGasCompensationRaw, 'ETH_GAS_COMPENSATION'),
|
|
110
|
-
minAnnualInterestRate: requireBigInt(minAnnualInterestRateRaw, 'MIN_ANNUAL_INTEREST_RATE'),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=borrowRegistryReader.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PublicClient } from 'viem';
|
|
2
|
-
import { AdjustTroveParams, CallParams, OpenTroveParams } from '../../../core/types';
|
|
3
|
-
import { DeploymentContext } from './borrowTypes';
|
|
4
|
-
export declare class BorrowTransactionService {
|
|
5
|
-
private publicClient;
|
|
6
|
-
constructor(publicClient: PublicClient);
|
|
7
|
-
buildOpenTroveTransaction(ctx: DeploymentContext, params: OpenTroveParams): Promise<CallParams>;
|
|
8
|
-
buildAdjustTroveTransaction(ctx: DeploymentContext, params: AdjustTroveParams): CallParams;
|
|
9
|
-
buildAdjustZombieTroveTransaction(ctx: DeploymentContext, params: AdjustTroveParams): Promise<CallParams>;
|
|
10
|
-
buildCloseTroveTransaction(ctx: DeploymentContext, troveId: string): CallParams;
|
|
11
|
-
buildAddCollTransaction(ctx: DeploymentContext, troveId: string, amount: bigint): CallParams;
|
|
12
|
-
buildWithdrawCollTransaction(ctx: DeploymentContext, troveId: string, amount: bigint): CallParams;
|
|
13
|
-
buildBorrowMoreTransaction(ctx: DeploymentContext, troveId: string, amount: bigint, maxFee: bigint): CallParams;
|
|
14
|
-
buildRepayDebtTransaction(ctx: DeploymentContext, troveId: string, amount: bigint): CallParams;
|
|
15
|
-
buildAdjustInterestRateTransaction(ctx: DeploymentContext, troveId: string, newRate: bigint, maxFee: bigint): Promise<CallParams>;
|
|
16
|
-
buildClaimCollateralTransaction(ctx: DeploymentContext): CallParams;
|
|
17
|
-
buildSetBatchManagerTransaction(ctx: DeploymentContext, troveId: string, manager: string, maxFee: bigint): Promise<CallParams>;
|
|
18
|
-
buildRemoveFromBatchTransaction(ctx: DeploymentContext, troveId: string, newRate: bigint, maxFee: bigint): Promise<CallParams>;
|
|
19
|
-
buildSwitchBatchManagerTransaction(ctx: DeploymentContext, troveId: string, newManager: string, maxFee: bigint): Promise<CallParams>;
|
|
20
|
-
buildSetInterestDelegateTransaction(ctx: DeploymentContext, troveId: string, delegate: string, minRate: bigint, maxRate: bigint, newRate: bigint, maxFee: bigint, minChangePeriod: bigint): Promise<CallParams>;
|
|
21
|
-
buildRemoveInterestDelegateTransaction(ctx: DeploymentContext, troveId: string): CallParams;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=borrowTransactionService.d.ts.map
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BorrowTransactionService = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const abis_1 = require("../../../core/abis");
|
|
6
|
-
const borrowHints_1 = require("./borrowHints");
|
|
7
|
-
const borrowValidation_1 = require("./borrowValidation");
|
|
8
|
-
const ZERO_VALUE_HEX = '0x0';
|
|
9
|
-
class BorrowTransactionService {
|
|
10
|
-
constructor(publicClient) {
|
|
11
|
-
this.publicClient = publicClient;
|
|
12
|
-
}
|
|
13
|
-
async buildOpenTroveTransaction(ctx, params) {
|
|
14
|
-
const owner = (0, borrowValidation_1.requireAddress)(params.owner, 'owner');
|
|
15
|
-
const ownerIndex = (0, borrowValidation_1.requireNonNegativeInteger)(params.ownerIndex, 'ownerIndex');
|
|
16
|
-
const collAmount = (0, borrowValidation_1.requirePositiveBigInt)(params.collAmount, 'collAmount');
|
|
17
|
-
const boldAmount = (0, borrowValidation_1.requirePositiveBigInt)(params.boldAmount, 'boldAmount');
|
|
18
|
-
const annualInterestRate = (0, borrowValidation_1.requireNonNegativeBigInt)(params.annualInterestRate, 'annualInterestRate');
|
|
19
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(params.maxUpfrontFee, 'maxUpfrontFee');
|
|
20
|
-
const addManager = (0, borrowValidation_1.optionalAddressOrZero)(params.addManager, 'addManager');
|
|
21
|
-
const removeManager = (0, borrowValidation_1.optionalAddressOrZero)(params.removeManager, 'removeManager');
|
|
22
|
-
const receiver = (0, borrowValidation_1.optionalAddressOrZero)(params.receiver, 'receiver');
|
|
23
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, annualInterestRate);
|
|
24
|
-
const data = params.interestBatchManager
|
|
25
|
-
? (0, viem_1.encodeFunctionData)({
|
|
26
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
27
|
-
functionName: 'openTroveAndJoinInterestBatchManager',
|
|
28
|
-
args: [
|
|
29
|
-
{
|
|
30
|
-
owner,
|
|
31
|
-
ownerIndex: BigInt(ownerIndex),
|
|
32
|
-
collAmount,
|
|
33
|
-
boldAmount,
|
|
34
|
-
upperHint: hints.upper,
|
|
35
|
-
lowerHint: hints.lower,
|
|
36
|
-
interestBatchManager: (0, borrowValidation_1.requireAddress)(params.interestBatchManager, 'interestBatchManager'),
|
|
37
|
-
maxUpfrontFee,
|
|
38
|
-
addManager,
|
|
39
|
-
removeManager,
|
|
40
|
-
receiver,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
})
|
|
44
|
-
: (0, viem_1.encodeFunctionData)({
|
|
45
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
46
|
-
functionName: 'openTrove',
|
|
47
|
-
args: [
|
|
48
|
-
owner,
|
|
49
|
-
BigInt(ownerIndex),
|
|
50
|
-
collAmount,
|
|
51
|
-
boldAmount,
|
|
52
|
-
hints.upper,
|
|
53
|
-
hints.lower,
|
|
54
|
-
annualInterestRate,
|
|
55
|
-
maxUpfrontFee,
|
|
56
|
-
addManager,
|
|
57
|
-
removeManager,
|
|
58
|
-
receiver,
|
|
59
|
-
],
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
to: ctx.addresses.borrowerOperations,
|
|
63
|
-
data,
|
|
64
|
-
value: ZERO_VALUE_HEX,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
buildAdjustTroveTransaction(ctx, params) {
|
|
68
|
-
const troveId = (0, borrowValidation_1.parseTroveId)(params.troveId);
|
|
69
|
-
const collChange = (0, borrowValidation_1.requireNonNegativeBigInt)(params.collChange, 'collChange');
|
|
70
|
-
const debtChange = (0, borrowValidation_1.requireNonNegativeBigInt)(params.debtChange, 'debtChange');
|
|
71
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(params.maxUpfrontFee, 'maxUpfrontFee');
|
|
72
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
73
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
74
|
-
functionName: 'adjustTrove',
|
|
75
|
-
args: [troveId, collChange, params.isCollIncrease, debtChange, params.isDebtIncrease, maxUpfrontFee],
|
|
76
|
-
});
|
|
77
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
78
|
-
}
|
|
79
|
-
async buildAdjustZombieTroveTransaction(ctx, params) {
|
|
80
|
-
const troveId = (0, borrowValidation_1.parseTroveId)(params.troveId);
|
|
81
|
-
const collChange = (0, borrowValidation_1.requireNonNegativeBigInt)(params.collChange, 'collChange');
|
|
82
|
-
const debtChange = (0, borrowValidation_1.requireNonNegativeBigInt)(params.debtChange, 'debtChange');
|
|
83
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(params.maxUpfrontFee, 'maxUpfrontFee');
|
|
84
|
-
const currentRate = (await this.publicClient.readContract({
|
|
85
|
-
address: ctx.addresses.troveManager,
|
|
86
|
-
abi: abis_1.TROVE_MANAGER_ABI,
|
|
87
|
-
functionName: 'getTroveAnnualInterestRate',
|
|
88
|
-
args: [troveId],
|
|
89
|
-
}));
|
|
90
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, currentRate);
|
|
91
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
92
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
93
|
-
functionName: 'adjustZombieTrove',
|
|
94
|
-
args: [
|
|
95
|
-
troveId,
|
|
96
|
-
collChange,
|
|
97
|
-
params.isCollIncrease,
|
|
98
|
-
debtChange,
|
|
99
|
-
params.isDebtIncrease,
|
|
100
|
-
hints.upper,
|
|
101
|
-
hints.lower,
|
|
102
|
-
maxUpfrontFee,
|
|
103
|
-
],
|
|
104
|
-
});
|
|
105
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
106
|
-
}
|
|
107
|
-
buildCloseTroveTransaction(ctx, troveId) {
|
|
108
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
109
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
110
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
111
|
-
functionName: 'closeTrove',
|
|
112
|
-
args: [parsedTroveId],
|
|
113
|
-
});
|
|
114
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
115
|
-
}
|
|
116
|
-
buildAddCollTransaction(ctx, troveId, amount) {
|
|
117
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
118
|
-
const collAmount = (0, borrowValidation_1.requirePositiveBigInt)(amount, 'amount');
|
|
119
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
120
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
121
|
-
functionName: 'addColl',
|
|
122
|
-
args: [parsedTroveId, collAmount],
|
|
123
|
-
});
|
|
124
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
125
|
-
}
|
|
126
|
-
buildWithdrawCollTransaction(ctx, troveId, amount) {
|
|
127
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
128
|
-
const collAmount = (0, borrowValidation_1.requirePositiveBigInt)(amount, 'amount');
|
|
129
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
130
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
131
|
-
functionName: 'withdrawColl',
|
|
132
|
-
args: [parsedTroveId, collAmount],
|
|
133
|
-
});
|
|
134
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
135
|
-
}
|
|
136
|
-
buildBorrowMoreTransaction(ctx, troveId, amount, maxFee) {
|
|
137
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
138
|
-
const borrowAmount = (0, borrowValidation_1.requirePositiveBigInt)(amount, 'amount');
|
|
139
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
140
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
141
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
142
|
-
functionName: 'withdrawBold',
|
|
143
|
-
args: [parsedTroveId, borrowAmount, maxUpfrontFee],
|
|
144
|
-
});
|
|
145
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
146
|
-
}
|
|
147
|
-
buildRepayDebtTransaction(ctx, troveId, amount) {
|
|
148
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
149
|
-
const repayAmount = (0, borrowValidation_1.requirePositiveBigInt)(amount, 'amount');
|
|
150
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
151
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
152
|
-
functionName: 'repayBold',
|
|
153
|
-
args: [parsedTroveId, repayAmount],
|
|
154
|
-
});
|
|
155
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
156
|
-
}
|
|
157
|
-
async buildAdjustInterestRateTransaction(ctx, troveId, newRate, maxFee) {
|
|
158
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
159
|
-
const newAnnualInterestRate = (0, borrowValidation_1.requireNonNegativeBigInt)(newRate, 'newRate');
|
|
160
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
161
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, newAnnualInterestRate);
|
|
162
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
163
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
164
|
-
functionName: 'adjustTroveInterestRate',
|
|
165
|
-
args: [parsedTroveId, newAnnualInterestRate, hints.upper, hints.lower, maxUpfrontFee],
|
|
166
|
-
});
|
|
167
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
168
|
-
}
|
|
169
|
-
buildClaimCollateralTransaction(ctx) {
|
|
170
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
171
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
172
|
-
functionName: 'claimCollateral',
|
|
173
|
-
args: [],
|
|
174
|
-
});
|
|
175
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
176
|
-
}
|
|
177
|
-
async buildSetBatchManagerTransaction(ctx, troveId, manager, maxFee) {
|
|
178
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
179
|
-
const newBatchManager = (0, borrowValidation_1.requireAddress)(manager, 'manager');
|
|
180
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
181
|
-
const currentRate = (await this.publicClient.readContract({
|
|
182
|
-
address: ctx.addresses.troveManager,
|
|
183
|
-
abi: abis_1.TROVE_MANAGER_ABI,
|
|
184
|
-
functionName: 'getTroveAnnualInterestRate',
|
|
185
|
-
args: [parsedTroveId],
|
|
186
|
-
}));
|
|
187
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, currentRate);
|
|
188
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
189
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
190
|
-
functionName: 'setInterestBatchManager',
|
|
191
|
-
args: [parsedTroveId, newBatchManager, hints.upper, hints.lower, maxUpfrontFee],
|
|
192
|
-
});
|
|
193
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
194
|
-
}
|
|
195
|
-
async buildRemoveFromBatchTransaction(ctx, troveId, newRate, maxFee) {
|
|
196
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
197
|
-
const newAnnualInterestRate = (0, borrowValidation_1.requireNonNegativeBigInt)(newRate, 'newRate');
|
|
198
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
199
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, newAnnualInterestRate);
|
|
200
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
201
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
202
|
-
functionName: 'removeFromBatch',
|
|
203
|
-
args: [parsedTroveId, newAnnualInterestRate, hints.upper, hints.lower, maxUpfrontFee],
|
|
204
|
-
});
|
|
205
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
206
|
-
}
|
|
207
|
-
async buildSwitchBatchManagerTransaction(ctx, troveId, newManager, maxFee) {
|
|
208
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
209
|
-
const managerAddress = (0, borrowValidation_1.requireAddress)(newManager, 'newManager');
|
|
210
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
211
|
-
const currentRate = (await this.publicClient.readContract({
|
|
212
|
-
address: ctx.addresses.troveManager,
|
|
213
|
-
abi: abis_1.TROVE_MANAGER_ABI,
|
|
214
|
-
functionName: 'getTroveAnnualInterestRate',
|
|
215
|
-
args: [parsedTroveId],
|
|
216
|
-
}));
|
|
217
|
-
const [removeHints, addHints] = await Promise.all([
|
|
218
|
-
(0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, currentRate),
|
|
219
|
-
(0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, currentRate),
|
|
220
|
-
]);
|
|
221
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
222
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
223
|
-
functionName: 'switchBatchManager',
|
|
224
|
-
args: [
|
|
225
|
-
parsedTroveId,
|
|
226
|
-
removeHints.upper,
|
|
227
|
-
removeHints.lower,
|
|
228
|
-
managerAddress,
|
|
229
|
-
addHints.upper,
|
|
230
|
-
addHints.lower,
|
|
231
|
-
maxUpfrontFee,
|
|
232
|
-
],
|
|
233
|
-
});
|
|
234
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
235
|
-
}
|
|
236
|
-
async buildSetInterestDelegateTransaction(ctx, troveId, delegate, minRate, maxRate, newRate, maxFee, minChangePeriod) {
|
|
237
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
238
|
-
const delegateAddress = (0, borrowValidation_1.requireAddress)(delegate, 'delegate');
|
|
239
|
-
const minInterestRate = (0, borrowValidation_1.requireUint128)(minRate, 'minRate');
|
|
240
|
-
const maxInterestRate = (0, borrowValidation_1.requireUint128)(maxRate, 'maxRate');
|
|
241
|
-
const newAnnualInterestRate = (0, borrowValidation_1.requireNonNegativeBigInt)(newRate, 'newRate');
|
|
242
|
-
const maxUpfrontFee = (0, borrowValidation_1.requireNonNegativeBigInt)(maxFee, 'maxFee');
|
|
243
|
-
const minRateChangePeriod = (0, borrowValidation_1.requireNonNegativeBigInt)(minChangePeriod, 'minChangePeriod');
|
|
244
|
-
if (minInterestRate > maxInterestRate) {
|
|
245
|
-
throw new Error('minRate cannot be greater than maxRate');
|
|
246
|
-
}
|
|
247
|
-
const hints = await (0, borrowHints_1.getTroveOperationHints)(this.publicClient, ctx, newAnnualInterestRate);
|
|
248
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
249
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
250
|
-
functionName: 'setInterestIndividualDelegate',
|
|
251
|
-
args: [
|
|
252
|
-
parsedTroveId,
|
|
253
|
-
delegateAddress,
|
|
254
|
-
minInterestRate,
|
|
255
|
-
maxInterestRate,
|
|
256
|
-
newAnnualInterestRate,
|
|
257
|
-
hints.upper,
|
|
258
|
-
hints.lower,
|
|
259
|
-
maxUpfrontFee,
|
|
260
|
-
minRateChangePeriod,
|
|
261
|
-
],
|
|
262
|
-
});
|
|
263
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
264
|
-
}
|
|
265
|
-
buildRemoveInterestDelegateTransaction(ctx, troveId) {
|
|
266
|
-
const parsedTroveId = (0, borrowValidation_1.parseTroveId)(troveId);
|
|
267
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
268
|
-
abi: abis_1.BORROWER_OPERATIONS_ABI,
|
|
269
|
-
functionName: 'removeInterestIndividualDelegate',
|
|
270
|
-
args: [parsedTroveId],
|
|
271
|
-
});
|
|
272
|
-
return { to: ctx.addresses.borrowerOperations, data, value: ZERO_VALUE_HEX };
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
exports.BorrowTransactionService = BorrowTransactionService;
|
|
276
|
-
//# sourceMappingURL=borrowTransactionService.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BorrowContractAddresses, SystemParams } from '../../../core/types';
|
|
2
|
-
export interface DeploymentContext {
|
|
3
|
-
addresses: BorrowContractAddresses;
|
|
4
|
-
systemParams: SystemParams;
|
|
5
|
-
}
|
|
6
|
-
export type InterestBatchManagerData = {
|
|
7
|
-
minInterestRate: bigint;
|
|
8
|
-
maxInterestRate: bigint;
|
|
9
|
-
minInterestRateChangePeriod: bigint;
|
|
10
|
-
};
|
|
11
|
-
export type DebtPerInterestRateItem = {
|
|
12
|
-
interestRate: bigint;
|
|
13
|
-
debt: bigint;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=borrowTypes.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Address } from 'viem';
|
|
2
|
-
export declare const MAX_SAFE_INTEGER_BIGINT: bigint;
|
|
3
|
-
export declare function requireDebtTokenSymbol(symbol: string): string;
|
|
4
|
-
export declare function requireAddress(address: string, fieldName: string): Address;
|
|
5
|
-
export declare function optionalAddressOrZero(value: string | undefined, fieldName: string): Address;
|
|
6
|
-
export declare function parseTroveId(troveId: string): bigint;
|
|
7
|
-
export declare function formatTroveId(troveId: bigint): string;
|
|
8
|
-
export declare function deriveTroveId(opener: string, owner: string, ownerIndex: number): bigint;
|
|
9
|
-
export declare function requireNonNegativeInteger(value: number, fieldName: string): number;
|
|
10
|
-
export declare function requireNonNegativeBigInt(value: bigint, fieldName: string): bigint;
|
|
11
|
-
export declare function requirePositiveBigInt(value: bigint, fieldName: string): bigint;
|
|
12
|
-
export declare function requireUint128(value: bigint, fieldName: string): bigint;
|
|
13
|
-
export declare function ceilSqrt(value: bigint): bigint;
|
|
14
|
-
//# sourceMappingURL=borrowValidation.d.ts.map
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_SAFE_INTEGER_BIGINT = void 0;
|
|
4
|
-
exports.requireDebtTokenSymbol = requireDebtTokenSymbol;
|
|
5
|
-
exports.requireAddress = requireAddress;
|
|
6
|
-
exports.optionalAddressOrZero = optionalAddressOrZero;
|
|
7
|
-
exports.parseTroveId = parseTroveId;
|
|
8
|
-
exports.formatTroveId = formatTroveId;
|
|
9
|
-
exports.deriveTroveId = deriveTroveId;
|
|
10
|
-
exports.requireNonNegativeInteger = requireNonNegativeInteger;
|
|
11
|
-
exports.requireNonNegativeBigInt = requireNonNegativeBigInt;
|
|
12
|
-
exports.requirePositiveBigInt = requirePositiveBigInt;
|
|
13
|
-
exports.requireUint128 = requireUint128;
|
|
14
|
-
exports.ceilSqrt = ceilSqrt;
|
|
15
|
-
const viem_1 = require("viem");
|
|
16
|
-
const validation_1 = require("../../../utils/validation");
|
|
17
|
-
const UINT128_MAX = (1n << 128n) - 1n;
|
|
18
|
-
exports.MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
19
|
-
const TROVE_ID_PARAMETERS = (0, viem_1.parseAbiParameters)('address opener, address owner, uint256 ownerIndex');
|
|
20
|
-
function requireDebtTokenSymbol(symbol) {
|
|
21
|
-
if (typeof symbol !== 'string' || symbol.trim().length === 0) {
|
|
22
|
-
throw new Error('debtTokenSymbol must be a non-empty string');
|
|
23
|
-
}
|
|
24
|
-
return symbol.trim();
|
|
25
|
-
}
|
|
26
|
-
function requireAddress(address, fieldName) {
|
|
27
|
-
(0, validation_1.validateAddress)(address, fieldName);
|
|
28
|
-
return address;
|
|
29
|
-
}
|
|
30
|
-
function optionalAddressOrZero(value, fieldName) {
|
|
31
|
-
if (!value)
|
|
32
|
-
return viem_1.zeroAddress;
|
|
33
|
-
return requireAddress(value, fieldName);
|
|
34
|
-
}
|
|
35
|
-
function parseTroveId(troveId) {
|
|
36
|
-
if (typeof troveId !== 'string' || troveId.trim().length === 0) {
|
|
37
|
-
throw new Error('troveId must be a non-empty string');
|
|
38
|
-
}
|
|
39
|
-
let parsed;
|
|
40
|
-
try {
|
|
41
|
-
parsed = BigInt(troveId);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
throw new Error(`Invalid troveId: ${troveId}`);
|
|
45
|
-
}
|
|
46
|
-
if (parsed < 0n) {
|
|
47
|
-
throw new Error('troveId cannot be negative');
|
|
48
|
-
}
|
|
49
|
-
return parsed;
|
|
50
|
-
}
|
|
51
|
-
function formatTroveId(troveId) {
|
|
52
|
-
return `0x${troveId.toString(16)}`;
|
|
53
|
-
}
|
|
54
|
-
function deriveTroveId(opener, owner, ownerIndex) {
|
|
55
|
-
const openerAddress = (0, viem_1.getAddress)(requireAddress(opener, 'opener'));
|
|
56
|
-
const ownerAddress = (0, viem_1.getAddress)(requireAddress(owner, 'owner'));
|
|
57
|
-
const validatedOwnerIndex = requireNonNegativeInteger(ownerIndex, 'ownerIndex');
|
|
58
|
-
return BigInt((0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)(TROVE_ID_PARAMETERS, [openerAddress, ownerAddress, BigInt(validatedOwnerIndex)])));
|
|
59
|
-
}
|
|
60
|
-
function requireNonNegativeInteger(value, fieldName) {
|
|
61
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
62
|
-
throw new Error(`${fieldName} must be a non-negative safe integer`);
|
|
63
|
-
}
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
function requireNonNegativeBigInt(value, fieldName) {
|
|
67
|
-
if (typeof value !== 'bigint' || value < 0n) {
|
|
68
|
-
throw new Error(`${fieldName} must be a non-negative bigint`);
|
|
69
|
-
}
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
function requirePositiveBigInt(value, fieldName) {
|
|
73
|
-
if (typeof value !== 'bigint' || value <= 0n) {
|
|
74
|
-
throw new Error(`${fieldName} must be a positive bigint`);
|
|
75
|
-
}
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
function requireUint128(value, fieldName) {
|
|
79
|
-
const parsed = requireNonNegativeBigInt(value, fieldName);
|
|
80
|
-
if (parsed > UINT128_MAX) {
|
|
81
|
-
throw new Error(`${fieldName} exceeds uint128 max value`);
|
|
82
|
-
}
|
|
83
|
-
return parsed;
|
|
84
|
-
}
|
|
85
|
-
function integerSqrt(value) {
|
|
86
|
-
if (value < 0n) {
|
|
87
|
-
throw new Error('Cannot compute square root of a negative bigint');
|
|
88
|
-
}
|
|
89
|
-
if (value < 2n) {
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
let x0 = value;
|
|
93
|
-
let x1 = (x0 + 1n) >> 1n;
|
|
94
|
-
while (x1 < x0) {
|
|
95
|
-
x0 = x1;
|
|
96
|
-
x1 = (x1 + value / x1) >> 1n;
|
|
97
|
-
}
|
|
98
|
-
return x0;
|
|
99
|
-
}
|
|
100
|
-
function ceilSqrt(value) {
|
|
101
|
-
const floor = integerSqrt(value);
|
|
102
|
-
return floor * floor === value ? floor : floor + 1n;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=borrowValidation.js.map
|
package/dist/services/index.d.ts
DELETED
package/dist/services/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./pools"), exports);
|
|
18
|
-
__exportStar(require("./routes"), exports);
|
|
19
|
-
__exportStar(require("./quotes"), exports);
|
|
20
|
-
__exportStar(require("./swap"), exports);
|
|
21
|
-
__exportStar(require("./trading"), exports);
|
|
22
|
-
__exportStar(require("./borrow"), exports);
|
|
23
|
-
__exportStar(require("./tokens"), exports);
|
|
24
|
-
__exportStar(require("./liquidity"), exports);
|
|
25
|
-
//# sourceMappingURL=index.js.map
|