@defisaver/positions-sdk 2.1.88 → 2.1.90
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/cjs/aaveV4/index.d.ts +1 -0
- package/cjs/aaveV4/index.js +11 -0
- package/cjs/compoundV3/index.js +5 -3
- package/cjs/contracts.d.ts +14 -14
- package/cjs/helpers/compoundHelpers/index.d.ts +2 -2
- package/cjs/helpers/compoundHelpers/index.js +4 -4
- package/cjs/types/compound.d.ts +1 -0
- package/esm/aaveV4/index.d.ts +1 -0
- package/esm/aaveV4/index.js +10 -0
- package/esm/compoundV3/index.js +5 -3
- package/esm/contracts.d.ts +14 -14
- package/esm/helpers/compoundHelpers/index.d.ts +2 -2
- package/esm/helpers/compoundHelpers/index.js +4 -4
- package/esm/types/compound.d.ts +1 -0
- package/package.json +1 -1
- package/src/aaveV4/index.ts +12 -0
- package/src/compoundV3/index.ts +6 -3
- package/src/helpers/compoundHelpers/index.ts +6 -4
- package/src/types/compound.ts +1 -0
package/cjs/aaveV4/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function _getAaveV4SpokeData(provider: Client, network: NetworkNu
|
|
|
5
5
|
export declare function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
6
6
|
export declare function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<AaveV4AccountData>;
|
|
7
7
|
export declare function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<any>;
|
|
8
|
+
export declare function getAaveV4UnderlyingFromReserveId(provider: EthereumProvider, network: NetworkNumber, spoke: EthAddress, reserveId: number): Promise<any>;
|
package/cjs/aaveV4/index.js
CHANGED
|
@@ -50,6 +50,7 @@ exports._getAaveV4SpokeData = _getAaveV4SpokeData;
|
|
|
50
50
|
exports.getAaveV4SpokeData = getAaveV4SpokeData;
|
|
51
51
|
exports._getAaveV4AccountData = _getAaveV4AccountData;
|
|
52
52
|
exports.getAaveV4AccountData = getAaveV4AccountData;
|
|
53
|
+
exports.getAaveV4UnderlyingFromReserveId = getAaveV4UnderlyingFromReserveId;
|
|
53
54
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
54
55
|
const tokens_1 = require("@defisaver/tokens");
|
|
55
56
|
const viem_1 = require("../services/viem");
|
|
@@ -244,3 +245,13 @@ function getAaveV4AccountData(provider_1, network_1, marketData_1, address_1) {
|
|
|
244
245
|
return _getAaveV4AccountData((0, viem_1.getViemProvider)(provider, network), network, marketData, address, blockNumber);
|
|
245
246
|
});
|
|
246
247
|
}
|
|
248
|
+
const _getAaveV4UnderlyingFromReserveId = (provider, network, spoke, reserveId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
|
+
const viewContract = (0, contracts_1.AaveV4ViewContractViem)(provider, network);
|
|
250
|
+
const reserveData = yield viewContract.read.getReserveData([spoke, BigInt(reserveId)]);
|
|
251
|
+
return reserveData.underlying;
|
|
252
|
+
});
|
|
253
|
+
function getAaveV4UnderlyingFromReserveId(provider, network, spoke, reserveId) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
return _getAaveV4UnderlyingFromReserveId((0, viem_1.getViemProvider)(provider, network), network, spoke, reserveId);
|
|
256
|
+
});
|
|
257
|
+
}
|
package/cjs/compoundV3/index.js
CHANGED
|
@@ -38,16 +38,18 @@ const getBaseAssetPriceFunction = (asset) => {
|
|
|
38
38
|
};
|
|
39
39
|
const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const contract = (0, contracts_1.CompV3ViewContractViem)(provider, network);
|
|
41
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = yield Promise.all([
|
|
41
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = yield Promise.all([
|
|
42
42
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
43
43
|
(0, priceService_1.getCompPrice)(defaultProvider),
|
|
44
44
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
45
45
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
46
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
46
47
|
]);
|
|
48
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
47
49
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
48
50
|
const colls = collInfos
|
|
49
51
|
.filter((coll) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
50
|
-
.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice));
|
|
52
|
+
.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused));
|
|
51
53
|
for (const coll of colls) {
|
|
52
54
|
if (staking_1.STAKING_ASSETS.includes(coll.symbol)) {
|
|
53
55
|
coll.supplyIncentives.push({
|
|
@@ -58,7 +60,7 @@ const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultPro
|
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
const base = (0, compoundHelpers_1.formatBaseData)(baseTokenInfo, network, baseAssetPrice);
|
|
63
|
+
const base = (0, compoundHelpers_1.formatBaseData)(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
62
64
|
const payload = {};
|
|
63
65
|
const baseObj = Object.assign(Object.assign({}, base), (yield (0, compoundHelpers_1.getIncentiveApys)(base, compPrice)));
|
|
64
66
|
const allAssets = [baseObj, ...colls];
|
package/cjs/contracts.d.ts
CHANGED
|
@@ -399981,7 +399981,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
399981
399981
|
}];
|
|
399982
399982
|
readonly stateMutability: "view";
|
|
399983
399983
|
readonly type: "function";
|
|
399984
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
399984
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
399985
399985
|
readonly inputs: readonly [{
|
|
399986
399986
|
readonly internalType: "address";
|
|
399987
399987
|
readonly name: "vat_";
|
|
@@ -400369,7 +400369,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
400369
400369
|
}];
|
|
400370
400370
|
readonly stateMutability: "view";
|
|
400371
400371
|
readonly type: "function";
|
|
400372
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
400372
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
400373
400373
|
readonly inputs: readonly [{
|
|
400374
400374
|
readonly internalType: "address";
|
|
400375
400375
|
readonly name: "vat_";
|
|
@@ -400757,7 +400757,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
400757
400757
|
}];
|
|
400758
400758
|
readonly stateMutability: "view";
|
|
400759
400759
|
readonly type: "function";
|
|
400760
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
400760
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
400761
400761
|
readonly inputs: readonly [{
|
|
400762
400762
|
readonly internalType: "address";
|
|
400763
400763
|
readonly name: "vat_";
|
|
@@ -401145,7 +401145,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
401145
401145
|
}];
|
|
401146
401146
|
readonly stateMutability: "view";
|
|
401147
401147
|
readonly type: "function";
|
|
401148
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
401148
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>]) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
401149
401149
|
rely: (args: readonly [`0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
401150
401150
|
readonly inputs: readonly [{
|
|
401151
401151
|
readonly internalType: "address";
|
|
@@ -403480,7 +403480,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
403480
403480
|
}];
|
|
403481
403481
|
readonly stateMutability: "view";
|
|
403482
403482
|
readonly type: "function";
|
|
403483
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
403483
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
403484
403484
|
readonly inputs: readonly [{
|
|
403485
403485
|
readonly internalType: "address";
|
|
403486
403486
|
readonly name: "vat_";
|
|
@@ -403868,7 +403868,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
403868
403868
|
}];
|
|
403869
403869
|
readonly stateMutability: "view";
|
|
403870
403870
|
readonly type: "function";
|
|
403871
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
403871
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
403872
403872
|
readonly inputs: readonly [{
|
|
403873
403873
|
readonly internalType: "address";
|
|
403874
403874
|
readonly name: "vat_";
|
|
@@ -404256,7 +404256,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
404256
404256
|
}];
|
|
404257
404257
|
readonly stateMutability: "view";
|
|
404258
404258
|
readonly type: "function";
|
|
404259
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
404259
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
404260
404260
|
readonly inputs: readonly [{
|
|
404261
404261
|
readonly internalType: "address";
|
|
404262
404262
|
readonly name: "vat_";
|
|
@@ -404644,7 +404644,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
404644
404644
|
}];
|
|
404645
404645
|
readonly stateMutability: "view";
|
|
404646
404646
|
readonly type: "function";
|
|
404647
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
404647
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>]) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
404648
404648
|
rely: (args: readonly [`0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
404649
404649
|
readonly inputs: readonly [{
|
|
404650
404650
|
readonly internalType: "address";
|
|
@@ -407756,7 +407756,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
407756
407756
|
}];
|
|
407757
407757
|
readonly stateMutability: "view";
|
|
407758
407758
|
readonly type: "function";
|
|
407759
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
407759
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, bigint], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
407760
407760
|
readonly inputs: readonly [{
|
|
407761
407761
|
readonly internalType: "address";
|
|
407762
407762
|
readonly name: "vat_";
|
|
@@ -408144,7 +408144,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408144
408144
|
}];
|
|
408145
408145
|
readonly stateMutability: "view";
|
|
408146
408146
|
readonly type: "function";
|
|
408147
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408147
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
408148
408148
|
readonly inputs: readonly [{
|
|
408149
408149
|
readonly internalType: "address";
|
|
408150
408150
|
readonly name: "vat_";
|
|
@@ -408532,7 +408532,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408532
408532
|
}];
|
|
408533
408533
|
readonly stateMutability: "view";
|
|
408534
408534
|
readonly type: "function";
|
|
408535
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408535
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
408536
408536
|
readonly inputs: readonly [{
|
|
408537
408537
|
readonly internalType: "address";
|
|
408538
408538
|
readonly name: "vat_";
|
|
@@ -408920,7 +408920,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408920
408920
|
}];
|
|
408921
408921
|
readonly stateMutability: "view";
|
|
408922
408922
|
readonly type: "function";
|
|
408923
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408923
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined]) => Promise<import("viem").SimulateContractReturnType<readonly [{
|
|
408924
408924
|
readonly inputs: readonly [{
|
|
408925
408925
|
readonly internalType: "address";
|
|
408926
408926
|
readonly name: "vat_";
|
|
@@ -409308,7 +409308,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
409308
409308
|
}];
|
|
409309
409309
|
readonly stateMutability: "view";
|
|
409310
409310
|
readonly type: "function";
|
|
409311
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
409311
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, import("viem").Account | undefined, chainOverride, accountOverride>>;
|
|
409312
409312
|
rely: <chainOverride extends import("viem").Chain | undefined = undefined, accountOverride extends import("viem").Account | import("viem").Address | undefined = undefined>(args: readonly [`0x${string}`], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
409313
409313
|
readonly inputs: readonly [{
|
|
409314
409314
|
readonly internalType: "address";
|
|
@@ -420044,7 +420044,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
420044
420044
|
}];
|
|
420045
420045
|
readonly stateMutability: "view";
|
|
420046
420046
|
readonly type: "function";
|
|
420047
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
420047
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, import("viem").Account | undefined, chainOverride>, "address" | "args" | "abi" | "functionName"> extends infer T ? { [K in keyof T]: T[K]; } : never>(...parameters: [args: readonly [`0x${string}`, `0x${string}`], options: options] | [args: readonly [`0x${string}`, bigint], options: options] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: options] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: options]) => Promise<import("viem").WriteContractReturnType>;
|
|
420048
420048
|
rely: <chainOverride extends import("viem").Chain | undefined, options extends import("viem").UnionOmit<import("viem").WriteContractParameters<readonly [{
|
|
420049
420049
|
readonly inputs: readonly [{
|
|
420050
420050
|
readonly internalType: "address";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
2
|
import { EthAddress, EthereumProvider, IncentiveData, NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
|
-
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
3
|
+
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData;
|
|
4
|
+
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => Promise<{
|
|
6
6
|
supplyIncentives: IncentiveData[];
|
|
7
7
|
borrowIncentives: IncentiveData[];
|
|
@@ -34,15 +34,15 @@ const staking_1 = require("../../staking");
|
|
|
34
34
|
const common_1 = require("../../types/common");
|
|
35
35
|
const contracts_1 = require("../../contracts");
|
|
36
36
|
const viem_1 = require("../../services/viem");
|
|
37
|
-
const formatMarketData = (data, network, baseAssetPrice) => {
|
|
37
|
+
const formatMarketData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
38
38
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(data.tokenAddr, network);
|
|
39
39
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
40
40
|
const price = (0, utils_1.getEthAmountForDecimals)(data.price, 8);
|
|
41
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied:
|
|
41
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyIncentives: [], borrowIncentives: [] }));
|
|
42
42
|
};
|
|
43
43
|
exports.formatMarketData = formatMarketData;
|
|
44
44
|
// TODO: maybe not hardcode decimals
|
|
45
|
-
const formatBaseData = (data, network, baseAssetPrice) => {
|
|
45
|
+
const formatBaseData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
46
46
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(data.tokenAddr, network);
|
|
47
47
|
const totalSupply = (0, utils_1.getEthAmountForDecimals)(new decimal_js_1.default(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
48
48
|
const totalBorrow = (0, utils_1.getEthAmountForDecimals)(new decimal_js_1.default(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -50,7 +50,7 @@ const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
50
50
|
.toString()), borrowRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(data.borrowRate).div(1e18).mul(constants_1.SECONDS_PER_YEAR).mul(100)
|
|
51
51
|
.toString()), utilization: (0, utils_1.getEthAmountForDecimals)(data.utilization, 16), // utilization is totalSupply/totalBorrow in 1e18, but we need % so when we mul with 100 it's 16 decimals
|
|
52
52
|
totalSupply,
|
|
53
|
-
totalBorrow, marketLiquidity: new decimal_js_1.default(totalSupply).minus(totalBorrow).toString(), symbol: (0, utils_1.wethToEth)(assetInfo.symbol), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied:
|
|
53
|
+
totalBorrow, marketLiquidity: new decimal_js_1.default(totalSupply).minus(totalBorrow).toString(), symbol: (0, utils_1.wethToEth)(assetInfo.symbol), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyCap: '0', rewardSupplySpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: (0, utils_1.getEthAmountForDecimals)(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
54
54
|
};
|
|
55
55
|
exports.formatBaseData = formatBaseData;
|
|
56
56
|
const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void 0, void 0, function* () {
|
package/cjs/types/compound.d.ts
CHANGED
package/esm/aaveV4/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function _getAaveV4SpokeData(provider: Client, network: NetworkNu
|
|
|
5
5
|
export declare function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
6
6
|
export declare function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<AaveV4AccountData>;
|
|
7
7
|
export declare function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<any>;
|
|
8
|
+
export declare function getAaveV4UnderlyingFromReserveId(provider: EthereumProvider, network: NetworkNumber, spoke: EthAddress, reserveId: number): Promise<any>;
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -201,3 +201,13 @@ export function getAaveV4AccountData(provider_1, network_1, marketData_1, addres
|
|
|
201
201
|
return _getAaveV4AccountData(getViemProvider(provider, network), network, marketData, address, blockNumber);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
+
const _getAaveV4UnderlyingFromReserveId = (provider, network, spoke, reserveId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
205
|
+
const viewContract = AaveV4ViewContractViem(provider, network);
|
|
206
|
+
const reserveData = yield viewContract.read.getReserveData([spoke, BigInt(reserveId)]);
|
|
207
|
+
return reserveData.underlying;
|
|
208
|
+
});
|
|
209
|
+
export function getAaveV4UnderlyingFromReserveId(provider, network, spoke, reserveId) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
return _getAaveV4UnderlyingFromReserveId(getViemProvider(provider, network), network, spoke, reserveId);
|
|
212
|
+
});
|
|
213
|
+
}
|
package/esm/compoundV3/index.js
CHANGED
|
@@ -32,16 +32,18 @@ const getBaseAssetPriceFunction = (asset) => {
|
|
|
32
32
|
};
|
|
33
33
|
export const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
const contract = CompV3ViewContractViem(provider, network);
|
|
35
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = yield Promise.all([
|
|
35
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = yield Promise.all([
|
|
36
36
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
37
37
|
getCompPrice(defaultProvider),
|
|
38
38
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
39
39
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
40
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
40
41
|
]);
|
|
42
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
41
43
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
42
44
|
const colls = collInfos
|
|
43
45
|
.filter((coll) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
44
|
-
.map((coll) => formatMarketData(coll, network, baseAssetPrice));
|
|
46
|
+
.map((coll) => formatMarketData(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused));
|
|
45
47
|
for (const coll of colls) {
|
|
46
48
|
if (STAKING_ASSETS.includes(coll.symbol)) {
|
|
47
49
|
coll.supplyIncentives.push({
|
|
@@ -52,7 +54,7 @@ export const _getCompoundV3MarketsData = (provider, network, selectedMarket, def
|
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice);
|
|
57
|
+
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
56
58
|
const payload = {};
|
|
57
59
|
const baseObj = Object.assign(Object.assign({}, base), (yield getIncentiveApys(base, compPrice)));
|
|
58
60
|
const allAssets = [baseObj, ...colls];
|
package/esm/contracts.d.ts
CHANGED
|
@@ -399981,7 +399981,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
399981
399981
|
}];
|
|
399982
399982
|
readonly stateMutability: "view";
|
|
399983
399983
|
readonly type: "function";
|
|
399984
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
399984
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
399985
399985
|
readonly inputs: readonly [{
|
|
399986
399986
|
readonly internalType: "address";
|
|
399987
399987
|
readonly name: "vat_";
|
|
@@ -400369,7 +400369,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
400369
400369
|
}];
|
|
400370
400370
|
readonly stateMutability: "view";
|
|
400371
400371
|
readonly type: "function";
|
|
400372
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
400372
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
400373
400373
|
readonly inputs: readonly [{
|
|
400374
400374
|
readonly internalType: "address";
|
|
400375
400375
|
readonly name: "vat_";
|
|
@@ -400757,7 +400757,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
400757
400757
|
}];
|
|
400758
400758
|
readonly stateMutability: "view";
|
|
400759
400759
|
readonly type: "function";
|
|
400760
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
400760
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
400761
400761
|
readonly inputs: readonly [{
|
|
400762
400762
|
readonly internalType: "address";
|
|
400763
400763
|
readonly name: "vat_";
|
|
@@ -401145,7 +401145,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
401145
401145
|
}];
|
|
401146
401146
|
readonly stateMutability: "view";
|
|
401147
401147
|
readonly type: "function";
|
|
401148
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
401148
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>]) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
401149
401149
|
rely: (args: readonly [`0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
401150
401150
|
readonly inputs: readonly [{
|
|
401151
401151
|
readonly internalType: "address";
|
|
@@ -403480,7 +403480,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
403480
403480
|
}];
|
|
403481
403481
|
readonly stateMutability: "view";
|
|
403482
403482
|
readonly type: "function";
|
|
403483
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
403483
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
403484
403484
|
readonly inputs: readonly [{
|
|
403485
403485
|
readonly internalType: "address";
|
|
403486
403486
|
readonly name: "vat_";
|
|
@@ -403868,7 +403868,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
403868
403868
|
}];
|
|
403869
403869
|
readonly stateMutability: "view";
|
|
403870
403870
|
readonly type: "function";
|
|
403871
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
403871
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
403872
403872
|
readonly inputs: readonly [{
|
|
403873
403873
|
readonly internalType: "address";
|
|
403874
403874
|
readonly name: "vat_";
|
|
@@ -404256,7 +404256,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
404256
404256
|
}];
|
|
404257
404257
|
readonly stateMutability: "view";
|
|
404258
404258
|
readonly type: "function";
|
|
404259
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
404259
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
404260
404260
|
readonly inputs: readonly [{
|
|
404261
404261
|
readonly internalType: "address";
|
|
404262
404262
|
readonly name: "vat_";
|
|
@@ -404644,7 +404644,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
404644
404644
|
}];
|
|
404645
404645
|
readonly stateMutability: "view";
|
|
404646
404646
|
readonly type: "function";
|
|
404647
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
404647
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined>, "address" | "args" | "abi" | "functionName">>]) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
404648
404648
|
rely: (args: readonly [`0x${string}`], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<readonly [{
|
|
404649
404649
|
readonly inputs: readonly [{
|
|
404650
404650
|
readonly internalType: "address";
|
|
@@ -407756,7 +407756,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
407756
407756
|
}];
|
|
407757
407757
|
readonly stateMutability: "view";
|
|
407758
407758
|
readonly type: "function";
|
|
407759
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
407759
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, bigint], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
407760
407760
|
readonly inputs: readonly [{
|
|
407761
407761
|
readonly internalType: "address";
|
|
407762
407762
|
readonly name: "vat_";
|
|
@@ -408144,7 +408144,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408144
408144
|
}];
|
|
408145
408145
|
readonly stateMutability: "view";
|
|
408146
408146
|
readonly type: "function";
|
|
408147
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408147
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
408148
408148
|
readonly inputs: readonly [{
|
|
408149
408149
|
readonly internalType: "address";
|
|
408150
408150
|
readonly name: "vat_";
|
|
@@ -408532,7 +408532,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408532
408532
|
}];
|
|
408533
408533
|
readonly stateMutability: "view";
|
|
408534
408534
|
readonly type: "function";
|
|
408535
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408535
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
408536
408536
|
readonly inputs: readonly [{
|
|
408537
408537
|
readonly internalType: "address";
|
|
408538
408538
|
readonly name: "vat_";
|
|
@@ -408920,7 +408920,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
408920
408920
|
}];
|
|
408921
408921
|
readonly stateMutability: "view";
|
|
408922
408922
|
readonly type: "function";
|
|
408923
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
408923
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "args" | "abi" | "functionName"> | undefined]) => Promise<import("viem").SimulateContractReturnType<readonly [{
|
|
408924
408924
|
readonly inputs: readonly [{
|
|
408925
408925
|
readonly internalType: "address";
|
|
408926
408926
|
readonly name: "vat_";
|
|
@@ -409308,7 +409308,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
409308
409308
|
}];
|
|
409309
409309
|
readonly stateMutability: "view";
|
|
409310
409310
|
readonly type: "function";
|
|
409311
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
409311
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, import("viem").Account | undefined, chainOverride, accountOverride>>;
|
|
409312
409312
|
rely: <chainOverride extends import("viem").Chain | undefined = undefined, accountOverride extends import("viem").Account | import("viem").Address | undefined = undefined>(args: readonly [`0x${string}`], options?: Omit<import("viem").SimulateContractParameters<readonly [{
|
|
409313
409313
|
readonly inputs: readonly [{
|
|
409314
409314
|
readonly internalType: "address";
|
|
@@ -420044,7 +420044,7 @@ export declare const McdDogContractViem: (client: Client, network: NetworkNumber
|
|
|
420044
420044
|
}];
|
|
420045
420045
|
readonly stateMutability: "view";
|
|
420046
420046
|
readonly type: "function";
|
|
420047
|
-
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, `0x${string}
|
|
420047
|
+
}], "file", readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`, bigint], import("viem").Chain | undefined, import("viem").Account | undefined, chainOverride>, "address" | "args" | "abi" | "functionName"> extends infer T ? { [K in keyof T]: T[K]; } : never>(...parameters: [args: readonly [`0x${string}`, `0x${string}`], options: options] | [args: readonly [`0x${string}`, bigint], options: options] | [args: readonly [`0x${string}`, `0x${string}`, `0x${string}`], options: options] | [args: readonly [`0x${string}`, `0x${string}`, bigint], options: options]) => Promise<import("viem").WriteContractReturnType>;
|
|
420048
420048
|
rely: <chainOverride extends import("viem").Chain | undefined, options extends import("viem").UnionOmit<import("viem").WriteContractParameters<readonly [{
|
|
420049
420049
|
readonly inputs: readonly [{
|
|
420050
420050
|
readonly internalType: "address";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
2
|
import { EthAddress, EthereumProvider, IncentiveData, NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
|
-
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
3
|
+
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData;
|
|
4
|
+
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => Promise<{
|
|
6
6
|
supplyIncentives: IncentiveData[];
|
|
7
7
|
borrowIncentives: IncentiveData[];
|
|
@@ -28,14 +28,14 @@ import { calculateNetApy, getStakingApy, STAKING_ASSETS } from '../../staking';
|
|
|
28
28
|
import { IncentiveKind, LeverageType, NetworkNumber, } from '../../types/common';
|
|
29
29
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
30
30
|
import { getViemProvider } from '../../services/viem';
|
|
31
|
-
export const formatMarketData = (data, network, baseAssetPrice) => {
|
|
31
|
+
export const formatMarketData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
32
32
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
33
33
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
34
34
|
const price = getEthAmountForDecimals(data.price, 8);
|
|
35
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied:
|
|
35
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyIncentives: [], borrowIncentives: [] }));
|
|
36
36
|
};
|
|
37
37
|
// TODO: maybe not hardcode decimals
|
|
38
|
-
export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
38
|
+
export const formatBaseData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
39
39
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
40
40
|
const totalSupply = getEthAmountForDecimals(new Dec(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
41
41
|
const totalBorrow = getEthAmountForDecimals(new Dec(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -43,7 +43,7 @@ export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
43
43
|
.toString()), borrowRate: aprToApy(new Dec(data.borrowRate).div(1e18).mul(SECONDS_PER_YEAR).mul(100)
|
|
44
44
|
.toString()), utilization: getEthAmountForDecimals(data.utilization, 16), // utilization is totalSupply/totalBorrow in 1e18, but we need % so when we mul with 100 it's 16 decimals
|
|
45
45
|
totalSupply,
|
|
46
|
-
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied:
|
|
46
|
+
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyCap: '0', rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: getEthAmountForDecimals(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
47
47
|
};
|
|
48
48
|
export const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
49
|
return ({
|
package/esm/types/compound.d.ts
CHANGED
package/package.json
CHANGED
package/src/aaveV4/index.ts
CHANGED
|
@@ -222,4 +222,16 @@ export async function _getAaveV4AccountData(provider: Client, network: NetworkNu
|
|
|
222
222
|
|
|
223
223
|
export async function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<any> {
|
|
224
224
|
return _getAaveV4AccountData(getViemProvider(provider, network), network, marketData, address, blockNumber);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const _getAaveV4UnderlyingFromReserveId = async (provider: Client, network: NetworkNumber, spoke: EthAddress, reserveId: number): Promise<any> => {
|
|
228
|
+
const viewContract = AaveV4ViewContractViem(provider, network);
|
|
229
|
+
|
|
230
|
+
const reserveData = await viewContract.read.getReserveData([spoke, BigInt(reserveId)]);
|
|
231
|
+
|
|
232
|
+
return reserveData.underlying;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export async function getAaveV4UnderlyingFromReserveId(provider: EthereumProvider, network: NetworkNumber, spoke: EthAddress, reserveId: number): Promise<any> {
|
|
236
|
+
return _getAaveV4UnderlyingFromReserveId(getViemProvider(provider, network), network, spoke, reserveId);
|
|
225
237
|
}
|
package/src/compoundV3/index.ts
CHANGED
|
@@ -43,18 +43,21 @@ const getBaseAssetPriceFunction = (asset: string) => {
|
|
|
43
43
|
export const _getCompoundV3MarketsData = async (provider: Client, network: NetworkNumber, selectedMarket: CompoundMarketData, defaultProvider: Client): Promise<CompoundV3MarketsData> => {
|
|
44
44
|
const contract = CompV3ViewContractViem(provider, network);
|
|
45
45
|
|
|
46
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = await Promise.all([
|
|
46
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = await Promise.all([
|
|
47
47
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
48
48
|
getCompPrice(defaultProvider),
|
|
49
49
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
50
50
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
51
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
51
52
|
]);
|
|
52
53
|
|
|
54
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
55
|
+
|
|
53
56
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
54
57
|
|
|
55
58
|
const colls = collInfos
|
|
56
59
|
.filter((coll: any) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
57
|
-
.map((coll: any) => formatMarketData(coll, network, baseAssetPrice)) as CompoundV3AssetData[];
|
|
60
|
+
.map((coll: any) => formatMarketData(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused)) as CompoundV3AssetData[];
|
|
58
61
|
|
|
59
62
|
for (const coll of colls) {
|
|
60
63
|
if (STAKING_ASSETS.includes(coll.symbol)) {
|
|
@@ -66,7 +69,7 @@ export const _getCompoundV3MarketsData = async (provider: Client, network: Netwo
|
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
|
-
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice);
|
|
72
|
+
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
70
73
|
|
|
71
74
|
const payload: CompoundV3AssetsData = {};
|
|
72
75
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
18
18
|
import { getViemProvider } from '../../services/viem';
|
|
19
19
|
|
|
20
|
-
export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPrice: string): CompoundV3AssetData => {
|
|
20
|
+
export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean): CompoundV3AssetData => {
|
|
21
21
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
22
22
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
23
23
|
const price = getEthAmountForDecimals(data.price, 8);
|
|
@@ -37,14 +37,15 @@ export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPri
|
|
|
37
37
|
supplyRate: '0',
|
|
38
38
|
borrowRate: '0',
|
|
39
39
|
canBeBorrowed: false,
|
|
40
|
-
canBeSupplied:
|
|
40
|
+
canBeSupplied: !isSupplyPaused,
|
|
41
|
+
canBeWithdrawn: !isWithdrawPaused,
|
|
41
42
|
supplyIncentives: [],
|
|
42
43
|
borrowIncentives: [],
|
|
43
44
|
});
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
// TODO: maybe not hardcode decimals
|
|
47
|
-
export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice: string): CompoundV3AssetData & BaseAdditionalAssetData => {
|
|
48
|
+
export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean): CompoundV3AssetData & BaseAdditionalAssetData => {
|
|
48
49
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
49
50
|
const totalSupply = getEthAmountForDecimals(new Dec(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
50
51
|
const totalBorrow = getEthAmountForDecimals(new Dec(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -71,7 +72,8 @@ export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice
|
|
|
71
72
|
collateralFactor: '0',
|
|
72
73
|
liquidationRatio: '0',
|
|
73
74
|
canBeBorrowed: true,
|
|
74
|
-
canBeSupplied:
|
|
75
|
+
canBeSupplied: !isSupplyPaused,
|
|
76
|
+
canBeWithdrawn: !isWithdrawPaused,
|
|
75
77
|
supplyCap: '0',
|
|
76
78
|
rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15),
|
|
77
79
|
rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15),
|
package/src/types/compound.ts
CHANGED