@defisaver/positions-sdk 2.1.150-cirbtc-dev → 2.1.151-midnight-dev

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.
Files changed (38) hide show
  1. package/cjs/claiming/compV3.js +0 -1
  2. package/cjs/config/contracts.d.ts +4 -0
  3. package/cjs/config/contracts.js +4 -0
  4. package/cjs/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
  5. package/cjs/helpers/morphoMidnightHelpers/tenor.js +5 -1
  6. package/cjs/markets/index.d.ts +1 -1
  7. package/cjs/markets/index.js +2 -1
  8. package/cjs/markets/morphoBlue/index.js +122 -122
  9. package/cjs/markets/morphoMidnight/index.d.ts +44 -10
  10. package/cjs/markets/morphoMidnight/index.js +380 -59
  11. package/cjs/morphoMidnight/index.js +11 -1
  12. package/cjs/portfolio/index.js +3 -27
  13. package/cjs/types/morphoMidnight.d.ts +35 -4
  14. package/cjs/types/morphoMidnight.js +23 -0
  15. package/esm/claiming/compV3.js +0 -1
  16. package/esm/config/contracts.d.ts +4 -0
  17. package/esm/config/contracts.js +4 -0
  18. package/esm/helpers/morphoMidnightHelpers/tenor.d.ts +6 -2
  19. package/esm/helpers/morphoMidnightHelpers/tenor.js +6 -2
  20. package/esm/markets/index.d.ts +1 -1
  21. package/esm/markets/index.js +1 -1
  22. package/esm/markets/morphoBlue/index.js +122 -122
  23. package/esm/markets/morphoMidnight/index.d.ts +44 -10
  24. package/esm/markets/morphoMidnight/index.js +356 -58
  25. package/esm/morphoMidnight/index.js +11 -1
  26. package/esm/portfolio/index.js +4 -28
  27. package/esm/types/morphoMidnight.d.ts +35 -4
  28. package/esm/types/morphoMidnight.js +23 -0
  29. package/package.json +1 -1
  30. package/src/claiming/compV3.ts +0 -1
  31. package/src/config/contracts.ts +4 -0
  32. package/src/helpers/morphoMidnightHelpers/tenor.ts +6 -2
  33. package/src/markets/index.ts +1 -0
  34. package/src/markets/morphoBlue/index.ts +122 -122
  35. package/src/markets/morphoMidnight/index.ts +446 -60
  36. package/src/morphoMidnight/index.ts +8 -1
  37. package/src/portfolio/index.ts +3 -27
  38. package/src/types/morphoMidnight.ts +37 -3
@@ -18,7 +18,6 @@ const claiming_1 = require("../types/claiming");
18
18
  // `rewardConfig` set - such a market never accrues COMP, so there is nothing to claim.
19
19
  // Not decodable by name, since the error lives in CometRewards' ABI and we call through CompV3View.
20
20
  const NOT_SUPPORTED_ERROR_SIG = '0x9c58e3b6';
21
- // Only an actual on-chain revert counts - viem reports transport failures as ContractFunctionExecutionError too.
22
21
  const isMarketWithoutRewardsConfig = (err) => {
23
22
  var _a;
24
23
  if (!(err instanceof viem_1.BaseError))
@@ -89746,6 +89746,10 @@ export declare const MidnightView: {
89746
89746
  readonly type: "function";
89747
89747
  }];
89748
89748
  readonly networks: {
89749
+ readonly "1": {
89750
+ readonly address: "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0";
89751
+ readonly createdBlock: 25938908;
89752
+ };
89749
89753
  readonly "8453": {
89750
89754
  readonly address: "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839";
89751
89755
  readonly createdBlock: 48932293;
@@ -1131,6 +1131,10 @@ exports.MorphoBlueView = {
1131
1131
  exports.MidnightView = {
1132
1132
  "abi": [{ "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "getMarketInfo", "outputs": [{ "components": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }, { "internalType": "uint128", "name": "totalUnits", "type": "uint128" }, { "internalType": "uint128", "name": "lossFactor", "type": "uint128" }, { "internalType": "uint128", "name": "withdrawable", "type": "uint128" }, { "internalType": "uint128", "name": "continuousFeeCredit", "type": "uint128" }, { "internalType": "uint16[7]", "name": "settlementFees", "type": "uint16[7]" }, { "internalType": "uint32", "name": "continuousFee", "type": "uint32" }, { "internalType": "uint8", "name": "tickSpacing", "type": "uint8" }, { "internalType": "uint256[]", "name": "prices", "type": "uint256[]" }], "internalType": "struct MidnightView.MarketInfo", "name": "info", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getPositionInfo", "outputs": [{ "components": [{ "internalType": "uint128", "name": "credit", "type": "uint128" }, { "internalType": "uint128", "name": "pendingFee", "type": "uint128" }, { "internalType": "uint128", "name": "debt", "type": "uint128" }, { "internalType": "uint128", "name": "collateralBitmap", "type": "uint128" }, { "internalType": "uint128[]", "name": "collateral", "type": "uint128[]" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }], "internalType": "struct MidnightView.PositionInfo", "name": "pos", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }, { "internalType": "address", "name": "_user", "type": "address" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "_market", "type": "tuple" }], "name": "toId", "outputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }], "name": "toMarket", "outputs": [{ "components": [{ "internalType": "uint256", "name": "chainId", "type": "uint256" }, { "internalType": "address", "name": "midnight", "type": "address" }, { "internalType": "address", "name": "loanToken", "type": "address" }, { "components": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "lltv", "type": "uint256" }, { "internalType": "uint256", "name": "liquidationCursor", "type": "uint256" }, { "internalType": "address", "name": "oracle", "type": "address" }], "internalType": "struct CollateralParams[]", "name": "collateralParams", "type": "tuple[]" }, { "internalType": "uint256", "name": "maturity", "type": "uint256" }, { "internalType": "uint256", "name": "rcfThreshold", "type": "uint256" }, { "internalType": "address", "name": "enterGate", "type": "address" }, { "internalType": "address", "name": "liquidatorGate", "type": "address" }], "internalType": "struct Market", "name": "market", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
1133
1133
  "networks": {
1134
+ "1": {
1135
+ "address": "0xB64FBf011343961D9AC4A04b714414E35ebE6BE0",
1136
+ "createdBlock": 25938908,
1137
+ },
1134
1138
  "8453": {
1135
1139
  "address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
1136
1140
  "createdBlock": 48932293,
@@ -41,11 +41,15 @@ interface TenorOfferFill {
41
41
  /**
42
42
  * Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
43
43
  * shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
44
+ *
45
+ * The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
46
+ * `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
47
+ * against another chain's core would address a market that does not exist.
44
48
  */
45
49
  export declare const tenorOfferToApiOffer: (offer: TenorOffer) => {
46
50
  market: {
47
51
  chain_id: string | number;
48
- midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
52
+ midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
49
53
  loan_token: string;
50
54
  collaterals: TenorOfferCollateral[];
51
55
  maturity: string | number;
@@ -73,7 +77,7 @@ export declare const tenorOfferFillToApiFill: (fill: TenorOfferFill) => {
73
77
  offer: {
74
78
  market: {
75
79
  chain_id: string | number;
76
- midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A";
80
+ midnight: "0xAdedD8ab6dE832766Fedf0FaC4992E5C4D3EA18A" | "0x471686c42792F93528B000beF54bC10E3aa2045f";
77
81
  loan_token: string;
78
82
  collaterals: TenorOfferCollateral[];
79
83
  maturity: string | number;
@@ -34,11 +34,15 @@ const tenorFillPrice = (assets, units) => (new decimal_js_1.default(units).lte(0
34
34
  /**
35
35
  * Tenor's offer JSON is flat (market fields live on the offer). Morpho's is nested, and that nested
36
36
  * shape is what the app encodes for `Midnight.take`. Map Tenor into that shape so recipes stay on one encoder.
37
+ *
38
+ * The core address is the one field Tenor's offer does not carry, so it is derived from the offer's own
39
+ * `chain_id` rather than the caller's network — an offer names the chain it was made on, and taking it
40
+ * against another chain's core would address a market that does not exist.
37
41
  */
38
42
  const tenorOfferToApiOffer = (offer) => ({
39
43
  market: {
40
44
  chain_id: offer.chain_id,
41
- midnight: morphoMidnight_1.MIDNIGHT_BASE,
45
+ midnight: (0, morphoMidnight_1.midnightCoreAddress)(Number(offer.chain_id)),
42
46
  loan_token: offer.loan_token_address,
43
47
  collaterals: offer.collaterals || [],
44
48
  maturity: offer.maturity,
@@ -3,7 +3,7 @@ export { CompoundMarkets, compoundV2CollateralAssets, v3ETHCollAssets, v3USDbCCo
3
3
  export { SparkMarkets } from './spark';
4
4
  export { CrvUsdMarkets } from './curveUsd';
5
5
  export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
6
- export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, } from './morphoMidnight';
6
+ export { MorphoMidnightMarkets, findMorphoMidnightMarket, isTenorMidnightMarket, morphoMidnightMarketCollateralParams, morphoMidnightVisibleCollaterals, } from './morphoMidnight';
7
7
  export { LlamaLendMarkets } from './llamaLend';
8
8
  export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
9
9
  export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.morphoMidnightMarketCollateralParams = exports.isTenorMidnightMarket = exports.findMorphoMidnightMarket = exports.MorphoMidnightMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
3
+ exports.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.morphoMidnightVisibleCollaterals = exports.morphoMidnightMarketCollateralParams = exports.isTenorMidnightMarket = exports.findMorphoMidnightMarket = exports.MorphoMidnightMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
4
4
  var aave_1 = require("./aave");
5
5
  Object.defineProperty(exports, "AaveMarkets", { enumerable: true, get: function () { return aave_1.AaveMarkets; } });
6
6
  Object.defineProperty(exports, "aaveV1AssetsDefaultMarket", { enumerable: true, get: function () { return aave_1.aaveV1AssetsDefaultMarket; } });
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "MorphoMidnightMarkets", { enumerable: true, get:
27
27
  Object.defineProperty(exports, "findMorphoMidnightMarket", { enumerable: true, get: function () { return morphoMidnight_1.findMorphoMidnightMarket; } });
28
28
  Object.defineProperty(exports, "isTenorMidnightMarket", { enumerable: true, get: function () { return morphoMidnight_1.isTenorMidnightMarket; } });
29
29
  Object.defineProperty(exports, "morphoMidnightMarketCollateralParams", { enumerable: true, get: function () { return morphoMidnight_1.morphoMidnightMarketCollateralParams; } });
30
+ Object.defineProperty(exports, "morphoMidnightVisibleCollaterals", { enumerable: true, get: function () { return morphoMidnight_1.morphoMidnightVisibleCollaterals; } });
30
31
  var llamaLend_1 = require("./llamaLend");
31
32
  Object.defineProperty(exports, "LlamaLendMarkets", { enumerable: true, get: function () { return llamaLend_1.LlamaLendMarkets; } });
32
33
  var liquityV2_1 = require("./liquityV2");