@sonarwatch/portfolio-plugins 0.14.13 → 0.14.15
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -5
- package/package.json +1 -1
- package/src/plugins/abex/positionsFetcher.js +1 -1
- package/src/plugins/abex/positionsFetcher.js.map +1 -1
- package/src/plugins/aftermath/helpers.d.ts +4 -0
- package/src/plugins/aftermath/helpers.js +81 -0
- package/src/plugins/aftermath/helpers.js.map +1 -0
- package/src/plugins/aftermath/poolsJob.js +1 -1
- package/src/plugins/aftermath/poolsJob.js.map +1 -1
- package/src/plugins/aftermath/stakingFetcher.js +42 -9
- package/src/plugins/aftermath/stakingFetcher.js.map +1 -1
- package/src/plugins/aftermath/types.d.ts +12 -0
- package/src/plugins/native-stake/solana/solanaValidatorsJob.js +1 -0
- package/src/plugins/native-stake/solana/solanaValidatorsJob.js.map +1 -1
- package/src/plugins/native-stake/solana/types.d.ts +2 -0
- package/src/plugins/parcl/stakingFetcher.js +9 -34
- package/src/plugins/parcl/stakingFetcher.js.map +1 -1
- package/src/plugins/parcl/types.d.ts +0 -9
- package/src/plugins/suilend/helpers.d.ts +4 -1
- package/src/plugins/suilend/helpers.js +25 -12
- package/src/plugins/suilend/helpers.js.map +1 -1
- package/src/plugins/suilend/obligationsFetcher.js +24 -5
- package/src/plugins/suilend/obligationsFetcher.js.map +1 -1
- package/src/plugins/suilend/types.d.ts +1 -1
- package/src/plugins/tradeport/bidsFetcher.d.ts +3 -0
- package/src/plugins/tradeport/bidsFetcher.js +46 -0
- package/src/plugins/tradeport/bidsFetcher.js.map +1 -0
- package/src/plugins/tradeport/bidsJob.d.ts +3 -0
- package/src/plugins/tradeport/bidsJob.js +41 -0
- package/src/plugins/tradeport/bidsJob.js.map +1 -0
- package/src/plugins/tradeport/constants.d.ts +4 -0
- package/src/plugins/tradeport/constants.js +5 -1
- package/src/plugins/tradeport/constants.js.map +1 -1
- package/src/plugins/tradeport/index.js +4 -2
- package/src/plugins/tradeport/index.js.map +1 -1
- package/src/plugins/tradeport/types.d.ts +18 -0
- package/src/utils/elementbuilder/LevPositionBuilder.js +2 -1
- package/src/utils/elementbuilder/LevPositionBuilder.js.map +1 -1
- package/src/utils/misc/getLendingMarketAprs.d.ts +18 -0
- package/src/utils/misc/getLendingMarketAprs.js +58 -0
- package/src/utils/misc/getLendingMarketAprs.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
-
## [0.14.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
## [0.14.12](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.11...plugins-0.14.12) (2024-10-22)
|
5
|
+
## [0.14.15](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.14...plugins-0.14.15) (2024-10-25)
|
10
6
|
|
11
7
|
|
12
8
|
|
9
|
+
## [0.14.14](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.13...plugins-0.14.14) (2024-10-24)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## [0.14.13](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.12...plugins-0.14.13) (2024-10-23)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [0.14.12](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.11...plugins-0.14.12) (2024-10-22)
|
18
|
+
|
19
|
+
|
20
|
+
|
13
21
|
## [0.14.11](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.10...plugins-0.14.11) (2024-10-18)
|
14
22
|
|
15
23
|
|
package/package.json
CHANGED
@@ -52,7 +52,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
element.addPosition({
|
55
|
-
address: positionInfo.
|
55
|
+
address: positionInfo.indexToken,
|
56
56
|
collateralValue: new bignumber_js_1.default(positionInfo.collateralAmount)
|
57
57
|
.multipliedBy(tokenPriceCollateral.price)
|
58
58
|
.dividedBy(Math.pow(10, tokenPriceCollateral.decimals))
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAqE;AACrE,gEAAqC;AAErC,2CAA6D;AAE7D,iDAAmD;AACnD,uCAImB;AACnB,gFAA6E;AAG7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,mBAAmB,GAAG,MAAM,IAAA,gCAAsB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAExE,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEhD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,OAAO,CAAc,8BAAkB,EAAE;QACtE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,gBAAgB,GAAG,MAAM,IAAA,6BAAmB,EAChD,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,KAAK,CACN,CAAC;IAEF,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,GAAG,EAAE,sBAAU,CAAC,CAAC;IAEvE,KAAK,MAAM,YAAY,IAAI,gBAAgB,EAAE,CAAC;QAC5C,IAAI,YAAY,CAAC,MAAM;YAAE,SAAS;QAClC,MAAM,OAAO,GAAG,eAAe,CAAC,kBAAkB,CAAC;YACjD,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACjD,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,eAAe,CAAC,EACvD,0BAAS,CAAC,GAAG,CACd,CAAC;QAEF,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QAE3E,IAAI,CAAC,oBAAoB;YAAE,SAAS;QAEpC,IAAI,QAAQ,CAAC;QACb,IAAI,QAAQ,CAAC;QAEb,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,MAAM,IAAA,sBAAY,EAChC,YAAY,EACZ,eAAe,EACf,oBAAoB,CACrB,CAAC;YAEF,IAAI,OAAO,EAAE,CAAC;gBACZ,QAAQ,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC3C,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,WAAW,CAAC;YAClB,OAAO,EAAE,YAAY,CAAC,
|
1
|
+
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAqE;AACrE,gEAAqC;AAErC,2CAA6D;AAE7D,iDAAmD;AACnD,uCAImB;AACnB,gFAA6E;AAG7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,mBAAmB,GAAG,MAAM,IAAA,gCAAsB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAExE,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEhD,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,OAAO,CAAc,8BAAkB,EAAE;QACtE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0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;YAChC,eAAe,EAAE,IAAI,sBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC;iBAC1D,YAAY,CAAC,oBAAoB,CAAC,KAAK,CAAC;iBACxC,SAAS,CAAC,SAAA,EAAE,EAAI,oBAAoB,CAAC,QAAQ,CAAA,CAAC;iBAC9C,QAAQ,EAAE;YACb,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAY,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAY,CAAC,KAAK;YAChE,SAAS,EAAE,IAAI,sBAAS,CAAC,YAAY,CAAC,YAAY,CAAC;YACnD,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
2
|
+
import { BurnerVault, StakingPosition } from './types';
|
3
|
+
import { SuiClient } from '../../utils/clients/types';
|
4
|
+
export declare const getHarvestRewards: (client: SuiClient, sender: string, stakedPosition: StakingPosition, stakeCoinType: string, vault: BurnerVault) => Promise<Map<string, BigNumber>>;
|
@@ -0,0 +1,81 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.getHarvestRewards = void 0;
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
|
+
const transactions_1 = require("@mysten/sui/transactions");
|
19
|
+
const getHarvestRewards = (client, sender, stakedPosition, stakeCoinType, vault) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
+
const rewards = new Map();
|
21
|
+
const rewardCoinTypes = vault.type_names.filter((coinType, i) => vault.rewards[i] !== '0' && i > 0);
|
22
|
+
if (rewardCoinTypes.length === 0)
|
23
|
+
return rewards;
|
24
|
+
const transactionBlock = new transactions_1.Transaction();
|
25
|
+
const harvestedRewardsEventMetadataId = transactionBlock.moveCall({
|
26
|
+
target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::begin_harvest`,
|
27
|
+
typeArguments: [stakeCoinType],
|
28
|
+
arguments: [transactionBlock.object(vault.id.id)],
|
29
|
+
});
|
30
|
+
const harvestedCoins = {};
|
31
|
+
for (const rewardCoinType of rewardCoinTypes) {
|
32
|
+
const harvestedCoin = transactionBlock.moveCall({
|
33
|
+
target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::harvest_rewards`,
|
34
|
+
typeArguments: [stakeCoinType, rewardCoinType],
|
35
|
+
arguments: [
|
36
|
+
transactionBlock.object(stakedPosition.id.id),
|
37
|
+
transactionBlock.object(vault.id.id),
|
38
|
+
harvestedRewardsEventMetadataId,
|
39
|
+
transactionBlock.object(portfolio_core_1.suiClockAddress),
|
40
|
+
],
|
41
|
+
});
|
42
|
+
if (rewardCoinType in harvestedCoins) {
|
43
|
+
harvestedCoins[rewardCoinType].push(harvestedCoin);
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
harvestedCoins[rewardCoinType] = [harvestedCoin];
|
47
|
+
}
|
48
|
+
}
|
49
|
+
transactionBlock.moveCall({
|
50
|
+
target: `0xcd41fbc59af65b7c58fd2590d5e35efbf756d50e6da2bd0413917102be6e1fdf::staked_position::end_harvest`,
|
51
|
+
typeArguments: [],
|
52
|
+
arguments: [harvestedRewardsEventMetadataId],
|
53
|
+
});
|
54
|
+
for (const [, harvestedCoinIds] of Object.entries(harvestedCoins)) {
|
55
|
+
const coinToTransfer = harvestedCoinIds[0];
|
56
|
+
if (harvestedCoinIds.length > 1)
|
57
|
+
transactionBlock.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));
|
58
|
+
transactionBlock.transferObjects([coinToTransfer], sender);
|
59
|
+
}
|
60
|
+
const dir = yield client.devInspectTransactionBlock({
|
61
|
+
sender,
|
62
|
+
transactionBlock,
|
63
|
+
});
|
64
|
+
const event = dir.events.find((e) => e.type ===
|
65
|
+
'0x4f0a1a923dd063757fd37e04a9c2cee8980008e94433c9075c390065f98e9e4b::events::HarvestedRewardsEvent');
|
66
|
+
if (!event || !event.parsedJson)
|
67
|
+
return rewards;
|
68
|
+
const parsedEvent = event;
|
69
|
+
if (!parsedEvent.parsedJson)
|
70
|
+
return rewards;
|
71
|
+
parsedEvent.parsedJson.reward_types.forEach((coinType, i) => {
|
72
|
+
if (parsedEvent.parsedJson) {
|
73
|
+
const balance = new bignumber_js_1.default(parsedEvent.parsedJson.reward_amounts[i]);
|
74
|
+
if (balance.isGreaterThan(0))
|
75
|
+
rewards.set(coinType, balance);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
return rewards;
|
79
|
+
});
|
80
|
+
exports.getHarvestRewards = getHarvestRewards;
|
81
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3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AC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;QAC1D,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YACxE,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA,CAAC;AAjFW,QAAA,iBAAiB,qBAiF5B"}
|
@@ -74,7 +74,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
74
|
return;
|
75
75
|
}
|
76
76
|
const tokenPrice = tokenPriceById.get(cAddress);
|
77
|
-
if (!
|
77
|
+
if (!poolInfo.coin_decimals)
|
78
78
|
return;
|
79
79
|
poolUnderlyingsRaw.push({
|
80
80
|
address: cAddress,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/poolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAKoC;AAGpC,iDAAmD;AACnD,2CAAuD;AAEvD,uEAAoE;AACpE,qEAAkE;AAClE,8EAG8C;AAE9C,MAAM,SAAS,GAAG,0BAAS,CAAC,GAAG,CAAC;AAEhC,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,gBAAgB,GAAG,MAAM,IAAA,mCAAgB,EAAC,MAAM,EAAE,wBAAY,CAAC,CAAC;IAEtE,MAAM,cAAc,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE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clients");
|
|
19
19
|
const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
|
20
20
|
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
21
21
|
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
22
|
+
const helpers_1 = require("./helpers");
|
23
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
22
24
|
const farmFactor = new bignumber_js_1.default(Math.pow(10, 9));
|
23
25
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
26
|
var _a;
|
@@ -41,6 +43,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
41
43
|
});
|
42
44
|
const burnerVaultsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, burnerVaults);
|
43
45
|
const burnerVaultsTypes = burnerVaultsObjects.map((vault) => { var _a; return (_a = vault.data) === null || _a === void 0 ? void 0 : _a.type; });
|
46
|
+
const tokenAddresses = [];
|
44
47
|
const lpMints = burnerVaultsTypes
|
45
48
|
.map((type) => {
|
46
49
|
var _a, _b;
|
@@ -49,10 +52,31 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
49
52
|
const lp = (_b = (_a = (0, portfolio_core_1.parseTypeString)(type).keys) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.type;
|
50
53
|
if (!lp || !lp.includes('af_lp'))
|
51
54
|
return undefined;
|
52
|
-
|
55
|
+
tokenAddresses.push((0, portfolio_core_1.formatTokenAddress)(lp, portfolio_core_1.NetworkId.sui));
|
56
|
+
return lp;
|
53
57
|
})
|
54
58
|
.flat();
|
55
|
-
|
59
|
+
burnerVaultsObjects.forEach((vault) => {
|
60
|
+
var _a, _b;
|
61
|
+
(_b = (_a = vault.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.type_names.forEach((ct) => tokenAddresses.push(ct));
|
62
|
+
});
|
63
|
+
const [tokenPriceById, rewards] = yield Promise.all([
|
64
|
+
cache.getTokenPricesAsMap(tokenAddresses, portfolio_core_1.NetworkId.sui),
|
65
|
+
Promise.all(stakedPositions.map((object, i) => {
|
66
|
+
var _a, _b, _c, _d, _e;
|
67
|
+
const lp = lpMints[i];
|
68
|
+
const burnerVault = burnerVaultsObjects.find((bv) => { var _a, _b; return (_b = (_a = bv.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.id.id; });
|
69
|
+
if (!lp)
|
70
|
+
return null;
|
71
|
+
if (!((_a = object.data) === null || _a === void 0 ? void 0 : _a.content))
|
72
|
+
return null;
|
73
|
+
if (!burnerVault || !((_c = (_b = burnerVault.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.fields))
|
74
|
+
return null;
|
75
|
+
return (0, helpers_1.getHarvestRewards)(client, owner, object.data.content.fields, lp, (_e = (_d = burnerVault.data) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e.fields);
|
76
|
+
})),
|
77
|
+
]);
|
78
|
+
if (!tokenPriceById)
|
79
|
+
return [];
|
56
80
|
const liquidities = [];
|
57
81
|
for (let i = 0; i < stakedPositions.length; i++) {
|
58
82
|
const object = stakedPositions[i];
|
@@ -61,20 +85,29 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
61
85
|
const lp = lpMints[i];
|
62
86
|
if (!lp)
|
63
87
|
continue;
|
64
|
-
const
|
65
|
-
if (!
|
88
|
+
const lpTokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(lp, portfolio_core_1.NetworkId.sui));
|
89
|
+
if (!lpTokenPrice)
|
66
90
|
continue;
|
67
91
|
const position = object.data.content.fields;
|
68
92
|
const amount = new bignumber_js_1.default(position.balance)
|
69
93
|
.dividedBy(farmFactor)
|
70
94
|
.toNumber();
|
71
|
-
const assets = (0, tokenPriceToAssetTokens_1.default)(
|
72
|
-
const
|
95
|
+
const assets = (0, tokenPriceToAssetTokens_1.default)(lpTokenPrice.address, amount, portfolio_core_1.NetworkId.sui, lpTokenPrice);
|
96
|
+
const rewardAssets = [];
|
97
|
+
const rewardsForPosition = rewards[i];
|
98
|
+
if (rewardsForPosition) {
|
99
|
+
rewardsForPosition.forEach((rewardAmount, coinType) => {
|
100
|
+
const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.sui));
|
101
|
+
if (tokenPrice)
|
102
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)((0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.sui), rewardAmount.dividedBy(Math.pow(10, tokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
103
|
+
});
|
104
|
+
}
|
105
|
+
const value = (0, portfolio_core_1.getUsdValueSum)([...assets, ...rewardAssets].map((asset) => asset.value));
|
73
106
|
liquidities.push({
|
74
107
|
assets,
|
75
|
-
assetsValue: value,
|
76
|
-
rewardAssets
|
77
|
-
rewardAssetsValue:
|
108
|
+
assetsValue: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
|
109
|
+
rewardAssets,
|
110
|
+
rewardAssetsValue: (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((asset) => asset.value)),
|
78
111
|
value,
|
79
112
|
yields: [],
|
80
113
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aftermath/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,gEAAqC;AAGrC,2CAAsD;AACtD,iDAAmD;AACnD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EAAE,CAAC;IAExC,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,EAAE,WAAW,EAAE;YACrB,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -51,3 +51,15 @@ export type PoolFactory = {
|
|
51
51
|
name: string;
|
52
52
|
value: string;
|
53
53
|
};
|
54
|
+
export type BurnerVault = {
|
55
|
+
id: ID;
|
56
|
+
emission_rates: string[];
|
57
|
+
type_names: string[];
|
58
|
+
rewards: string[];
|
59
|
+
};
|
60
|
+
export type CoinType = string;
|
61
|
+
export type HarvestedRewards = {
|
62
|
+
afterburner_vault_id: string;
|
63
|
+
reward_amounts: string[];
|
64
|
+
reward_types: string[];
|
65
|
+
};
|
@@ -34,6 +34,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
jitoApy: r.jito_apy,
|
35
35
|
stakingApy: r.staking_apy,
|
36
36
|
totalApy: r.total_apy,
|
37
|
+
commission: r.commission,
|
37
38
|
}));
|
38
39
|
yield cache.setItem(constants_1.validatorsKey, validators, {
|
39
40
|
prefix: constants_1.platformId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaValidatorsJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaValidatorsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA6C;AAG7C,4CAAyD;AACzD,2CAA0C;AAG1C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,MAAM,eAAK;SACpB,GAAG,CAAgD,uBAAW,EAAE;QAC/D,OAAO,EAAE,KAAK;KACf,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEL,IAAI,CAAC,GAAG,CAAC,IAAI;QAAE,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAEnD,MAAM,UAAU,GAAgB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,aAAa;QACtB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,QAAQ,EAAE,CAAC,CAAC,KAAK;QACjB,OAAO,EAAE,CAAC,CAAC,YAAY;QACvB,OAAO,EAAE,CAAC,CAAC,QAAQ;QACnB,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,QAAQ,EAAE,CAAC,CAAC,SAAS;
|
1
|
+
{"version":3,"file":"solanaValidatorsJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaValidatorsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA6C;AAG7C,4CAAyD;AACzD,2CAA0C;AAG1C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,MAAM,eAAK;SACpB,GAAG,CAAgD,uBAAW,EAAE;QAC/D,OAAO,EAAE,KAAK;KACf,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEL,IAAI,CAAC,GAAG,CAAC,IAAI;QAAE,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAEnD,MAAM,UAAU,GAAgB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,aAAa;QACtB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,QAAQ,EAAE,CAAC,CAAC,KAAK;QACjB,OAAO,EAAE,CAAC,CAAC,YAAY;QACvB,OAAO,EAAE,CAAC,CAAC,QAAQ;QACnB,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,QAAQ,EAAE,CAAC,CAAC,SAAS;QACrB,UAAU,EAAE,CAAC,CAAC,UAAU;KACzB,CAAC,CAAC,CAAC;IAEJ,MAAM,KAAK,CAAC,OAAO,CAAC,yBAAa,EAAE,UAAU,EAAE;QAC7C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,oBAAoB;IACrC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -7,6 +7,7 @@ export type ValidatorApiResponse = {
|
|
7
7
|
jito_apy: number;
|
8
8
|
staking_apy: number;
|
9
9
|
total_apy: number;
|
10
|
+
commission: number;
|
10
11
|
};
|
11
12
|
export type Validator = {
|
12
13
|
voter: string;
|
@@ -16,4 +17,5 @@ export type Validator = {
|
|
16
17
|
jitoApy: number;
|
17
18
|
stakingApy: number;
|
18
19
|
totalApy: number;
|
20
|
+
commission: number;
|
19
21
|
};
|
@@ -15,37 +15,11 @@ const constants_1 = require("./constants");
|
|
15
15
|
const clients_1 = require("../../utils/clients");
|
16
16
|
const solana_1 = require("../../utils/solana");
|
17
17
|
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
18
|
-
const decodePosition = (buffer) => ({
|
19
|
-
amount: Number(buffer.readBigUInt64LE(1)),
|
20
|
-
activationEpoch: Number(buffer.readBigUInt64LE(1 + 8)),
|
21
|
-
unlockingStart: Number(buffer.readBigUInt64LE(1 + 8 + 8)),
|
22
|
-
});
|
23
|
-
const decodePositionAccount = (buffer) => {
|
24
|
-
let i = 0;
|
25
|
-
buffer.slice(i, i + 8);
|
26
|
-
i += 8;
|
27
|
-
const owner = new web3_js_1.PublicKey(buffer.slice(i, i + 32)).toString();
|
28
|
-
i += 32;
|
29
|
-
const positions = [];
|
30
|
-
let position;
|
31
|
-
for (let t = 0; t < 20; t++) {
|
32
|
-
position = decodePosition(buffer.slice(i, i + 200));
|
33
|
-
if (position.amount > 0)
|
34
|
-
positions.push(position);
|
35
|
-
else
|
36
|
-
break;
|
37
|
-
i += 200;
|
38
|
-
}
|
39
|
-
return {
|
40
|
-
owner,
|
41
|
-
positions,
|
42
|
-
};
|
43
|
-
};
|
44
18
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
45
19
|
const client = (0, clients_1.getClientSolana)();
|
20
|
+
// https://github.com/pyth-network/governance/blob/f624ea17fd2e7b22c799ffc2a560257d155410a5/staking/app/StakeConnection.ts
|
46
21
|
const accs = yield (0, solana_1.getProgramAccounts)(client, constants_1.stakingProgramId, [
|
47
22
|
{
|
48
|
-
// account PositionData
|
49
23
|
memcmp: {
|
50
24
|
offset: 0,
|
51
25
|
bytes: 'FM2r3wAdZaa',
|
@@ -54,22 +28,23 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
54
28
|
{
|
55
29
|
memcmp: {
|
56
30
|
offset: 8,
|
57
|
-
bytes:
|
31
|
+
bytes: owner,
|
58
32
|
},
|
59
33
|
},
|
60
34
|
]);
|
61
35
|
if (accs.length === 0)
|
62
36
|
return [];
|
63
|
-
const
|
37
|
+
const tokenBalances = yield Promise.all(accs.map((acc) => __awaiter(void 0, void 0, void 0, function* () {
|
38
|
+
const tokenAccount = yield client.getTokenAccountBalance(web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('custody'), acc.pubkey.toBuffer()], constants_1.stakingProgramId)[0]);
|
39
|
+
return Number(tokenAccount.value.amount);
|
40
|
+
})));
|
64
41
|
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
65
42
|
const element = elementRegistry.addElementMultiple({
|
66
43
|
label: 'Staked',
|
67
44
|
});
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
amount: positionAccount.positions.reduce((sum, position) => sum + Number(position.amount), 0),
|
72
|
-
});
|
45
|
+
element.addAsset({
|
46
|
+
address: constants_1.prclMint,
|
47
|
+
amount: tokenBalances.reduce((sum, current) => sum + current, 0),
|
73
48
|
});
|
74
49
|
return elementRegistry.getElements(cache);
|
75
50
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AACvD,6CAA4C;AAE5C,2CAAqE;AAErE,iDAAsD;AACtD,+CAAwD;
|
1
|
+
{"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/parcl/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AACvD,6CAA4C;AAE5C,2CAAqE;AAErE,iDAAsD;AACtD,+CAAwD;AACxD,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,0HAA0H;IAE1H,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAkB,EAAC,MAAM,EAAE,4BAAgB,EAAE;QAC9D;YACE,MAAM,EAAE;gBACN,MAAM,EAAE,CAAC;gBACT,KAAK,EAA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7,12 +7,3 @@ export type ApiAirdropResponse = {
|
|
7
7
|
merkle_tree?: string;
|
8
8
|
error?: string;
|
9
9
|
};
|
10
|
-
export type PositionAccount = {
|
11
|
-
owner: string;
|
12
|
-
positions: Position[];
|
13
|
-
};
|
14
|
-
export type Position = {
|
15
|
-
amount: number;
|
16
|
-
activationEpoch: number;
|
17
|
-
unlockingStart: number;
|
18
|
-
};
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
2
2
|
import { BorrowLendRate } from '@sonarwatch/portfolio-core';
|
3
3
|
import { LendingMarket, PoolReward, Reserve } from './types';
|
4
|
-
export declare function
|
4
|
+
export declare function getPoolsRewardsMaps(lendingMarkets: LendingMarket[] | undefined): [PoolRewardById, PoolsRewardByManagerId];
|
5
|
+
type PoolRewardById = Map<string, PoolReward>;
|
6
|
+
type PoolsRewardByManagerId = Map<string, PoolReward[]>;
|
5
7
|
export declare function getRatesAsMap(borrowLendRates: BorrowLendRate[] | undefined): Map<string, BorrowLendRate>;
|
6
8
|
export declare function getBorrowApr(utilization: BigNumber, borrowedAmount: BigNumber, availableAmount: BigNumber, reserveFields: Reserve): number;
|
7
9
|
export declare function getDepositApr(utilization: BigNumber, borrowApr: number, reserveFields: Reserve): number;
|
10
|
+
export {};
|
@@ -3,26 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getDepositApr = exports.getBorrowApr = exports.getRatesAsMap = exports.
|
6
|
+
exports.getDepositApr = exports.getBorrowApr = exports.getRatesAsMap = exports.getPoolsRewardsMaps = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
|
-
function
|
9
|
-
const
|
8
|
+
function getPoolsRewardsMaps(lendingMarkets) {
|
9
|
+
const poolRewardById = new Map();
|
10
|
+
const poolsRewardByManagerId = new Map();
|
10
11
|
if (!lendingMarkets)
|
11
|
-
return
|
12
|
+
return [poolRewardById, poolsRewardByManagerId];
|
12
13
|
for (const lendingMarket of lendingMarkets) {
|
13
14
|
const { reserves } = lendingMarket;
|
14
15
|
for (const reserve of reserves) {
|
15
|
-
const
|
16
|
-
for (const poolReward of
|
17
|
-
if (!poolReward)
|
16
|
+
const depositdPoolsRewards = reserve.fields.deposits_pool_reward_manager.fields.pool_rewards;
|
17
|
+
for (const poolReward of depositdPoolsRewards) {
|
18
|
+
if (!poolReward || !poolReward.fields)
|
18
19
|
continue;
|
19
|
-
|
20
|
+
poolRewardById.set(poolReward.fields.id.id, poolReward.fields);
|
20
21
|
}
|
22
|
+
poolsRewardByManagerId.set(reserve.fields.deposits_pool_reward_manager.fields.id.id, depositdPoolsRewards.map((data) => (data ? data.fields : null)));
|
23
|
+
const borrowPoolsRewards = reserve.fields.borrows_pool_reward_manager.fields.pool_rewards;
|
24
|
+
for (const poolReward of borrowPoolsRewards) {
|
25
|
+
if (!poolReward || !poolReward.fields)
|
26
|
+
continue;
|
27
|
+
poolRewardById.set(poolReward.fields.id.id, poolReward.fields);
|
28
|
+
}
|
29
|
+
poolsRewardByManagerId.set(reserve.fields.borrows_pool_reward_manager.fields.id.id, borrowPoolsRewards.map((data) => (data ? data.fields : null)));
|
21
30
|
}
|
22
31
|
}
|
23
|
-
return
|
32
|
+
return [poolRewardById, poolsRewardByManagerId];
|
24
33
|
}
|
25
|
-
exports.
|
34
|
+
exports.getPoolsRewardsMaps = getPoolsRewardsMaps;
|
26
35
|
function getRatesAsMap(borrowLendRates) {
|
27
36
|
const ratesByReserveId = new Map();
|
28
37
|
if (!borrowLendRates)
|
@@ -37,9 +46,13 @@ exports.getRatesAsMap = getRatesAsMap;
|
|
37
46
|
function getBorrowApr(utilization, borrowedAmount, availableAmount, reserveFields) {
|
38
47
|
const { interest_rate_aprs: rateAprs, interest_rate_utils: rateUtils } = reserveFields.config.fields.element.fields;
|
39
48
|
if (borrowedAmount.isZero())
|
40
|
-
return (0, bignumber_js_1.default)(rateAprs[0])
|
49
|
+
return (0, bignumber_js_1.default)(rateAprs[0])
|
50
|
+
.dividedBy(Math.pow(10, 4))
|
51
|
+
.toNumber();
|
41
52
|
if (availableAmount.isZero())
|
42
|
-
return (0, bignumber_js_1.default)(rateAprs[rateAprs.length])
|
53
|
+
return (0, bignumber_js_1.default)(rateAprs[rateAprs.length])
|
54
|
+
.dividedBy(Math.pow(10, 4))
|
55
|
+
.toNumber();
|
43
56
|
for (let i = 0; i < rateUtils.length; i++) {
|
44
57
|
const currentUtil = rateUtils[i] / 100;
|
45
58
|
const nextUtil = rateUtils[i + 1] / 100;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,SAAgB,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAIrC,SAAgB,mBAAmB,CACjC,cAA2C;IAE3C,MAAM,cAAc,GAAmB,IAAI,GAAG,EAAE,CAAC;IACjD,MAAM,sBAAsB,GAA2B,IAAI,GAAG,EAAE,CAAC;IACjE,IAAI,CAAC,cAAc;QAAE,OAAO,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;IAErE,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;QACnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,oBAAoB,GACxB,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,YAAY,CAAC;YAClE,KAAK,MAAM,UAAU,IAAI,oBAAoB,EAAE,CAAC;gBAC9C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,C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AAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,CAAC,CAAA,CAAC,CAAC;QAClE,IAAI,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YACvC,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QAED,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACxD,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,CAAC;YAC9C,OAAO,gBAAgB;iBACpB,SAAS,CAAC,cAAc,CAAC;iBACzB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;iBAChC,IAAI,CAAC,UAAU,CAAC;iBAChB,QAAQ,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAtCD,oCAsCC;AAED,SAAgB,aAAa,CAC3B,WAAsB,EACtB,SAAiB,EACjB,aAAsB;IAEtB,OAAO,IAAA,sBAAS,EAAC,SAAS,CAAC;SACxB,KAAK,CACJ,CAAC;QACC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YAC/D,SAAA,EAAE,EAAI,CAAC,CAAA,CACZ;SACA,KAAK,CAAC,WAAW,CAAC;SAClB,QAAQ,EAAE,CAAC;AAChB,CAAC;AAbD,sCAaC"}
|
@@ -54,8 +54,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
54
54
|
marketsInfo.lendingMarkets.forEach((market) => {
|
55
55
|
marketsByIndex.set(market.id.id, market);
|
56
56
|
});
|
57
|
-
const poolRewardById = (0, helpers_1.
|
58
|
-
poolRewardById.forEach((pool) => mints.add(pool.coin_type.fields.name));
|
57
|
+
const [poolRewardById, poolsRewardByManagerId] = (0, helpers_1.getPoolsRewardsMaps)(lendingMarkets);
|
58
|
+
poolRewardById.forEach((pool) => pool ? mints.add(pool.coin_type.fields.name) : undefined);
|
59
59
|
const borrowedAssets = [];
|
60
60
|
const borrowedYields = [];
|
61
61
|
const suppliedAssets = [];
|
@@ -152,14 +152,33 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
152
152
|
.dividedBy(Math.pow(10, constants_2.wadsDecimal));
|
153
153
|
if (cumulativeAmount.isLessThanOrEqualTo(0))
|
154
154
|
continue;
|
155
|
-
const
|
156
|
-
if (
|
157
|
-
rewardAmountByMint.set(rewardMint,
|
155
|
+
const previousAmount = rewardAmountByMint.get(rewardMint);
|
156
|
+
if (previousAmount) {
|
157
|
+
rewardAmountByMint.set(rewardMint, previousAmount.plus(cumulativeAmount));
|
158
158
|
}
|
159
159
|
else {
|
160
160
|
rewardAmountByMint.set(rewardMint, cumulativeAmount);
|
161
161
|
}
|
162
162
|
}
|
163
|
+
if (userRewardManager.fields.rewards.length === 0) {
|
164
|
+
const poolsRewards = poolsRewardByManagerId.get(userRewardManager.fields.pool_reward_manager_id);
|
165
|
+
if (poolsRewards) {
|
166
|
+
for (const poolReward of poolsRewards) {
|
167
|
+
if (!poolReward)
|
168
|
+
continue;
|
169
|
+
const amount = new bignumber_js_1.default(poolReward.cumulative_rewards_per_share.fields.value)
|
170
|
+
.times(share)
|
171
|
+
.dividedBy(Math.pow(10, constants_2.wadsDecimal));
|
172
|
+
const previousAmount = rewardAmountByMint.get(poolReward.coin_type.fields.name);
|
173
|
+
if (previousAmount) {
|
174
|
+
rewardAmountByMint.set(poolReward.coin_type.fields.name, previousAmount.plus(amount));
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
rewardAmountByMint.set(poolReward.coin_type.fields.name, amount);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
163
182
|
}
|
164
183
|
rewardAmountByMint.forEach((amount, mint) => {
|
165
184
|
const tokenPrice = tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(mint, portfolio_core_1.NetworkId.sui));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAOlE,qEAAkE;AAClE,qGAA6E;AAC7E,
|
1
|
+
{"version":3,"file":"obligationsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/suilend/obligationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qEAAkE;AAOlE,qEAAkE;AAClE,qGAA6E;AAC7E,uCAA+D;AAC/D,iDAAgD;AAEhD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,oBAAoB,GAAG,MAAM,IAAA,iCAAe,EAChD,MAAM,EACN,KAAK,EACL;QACE,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAS,EAAE;KAC/B,CACF,CAAC;IACF,IAAI,oBAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,MAAM,kBAAkB,IAAI,oBAAoB,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,MAAA,MAAA,kBAAkB,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAAI,CAAC;QACpD,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,kCAAsB,CAAC,CAAA;YAAE,SAAS;QAExD,MAAM,YAAY,GAAG,M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
87
87
|
};
|
88
|
-
export type PoolReward = {
|
88
|
+
export type PoolReward = null | {
|
89
89
|
id: ID;
|
90
90
|
additional_fields: ParsedData<AdditionalFields>;
|
91
91
|
allocated_rewards: ParsedData<Value>;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
|
15
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
16
|
+
const bidsMemo = new MemoizedCache_1.MemoizedCache(constants_1.bidsCacheKey, {
|
17
|
+
prefix: constants_1.platformId,
|
18
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
19
|
+
});
|
20
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
21
|
+
const allBids = yield bidsMemo.getItem(cache);
|
22
|
+
if (!allBids)
|
23
|
+
return [];
|
24
|
+
const bids = allBids.filter((bid) => bid.buyer === owner);
|
25
|
+
if (!bids)
|
26
|
+
return [];
|
27
|
+
const registry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
|
28
|
+
const element = registry.addElementMultiple({
|
29
|
+
label: 'Deposit',
|
30
|
+
tags: ['Bids'],
|
31
|
+
});
|
32
|
+
bids.forEach((bid) => {
|
33
|
+
element.addAsset({
|
34
|
+
address: portfolio_core_1.suiNativeAddress,
|
35
|
+
amount: bid.wallet.fields.balance,
|
36
|
+
});
|
37
|
+
});
|
38
|
+
return registry.getElements(cache);
|
39
|
+
});
|
40
|
+
const fetcher = {
|
41
|
+
id: `${constants_1.platformId}-bids`,
|
42
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
43
|
+
executor,
|
44
|
+
};
|
45
|
+
exports.default = fetcher;
|
46
|
+
//# sourceMappingURL=bidsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bidsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/bidsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAyE;AAEzE,2CAAuD;AAEvD,kEAA+D;AAE/D,gFAA6E;AAE7E,MAAM,QAAQ,GAAG,IAAI,6BAAa,CAAQ,wBAAY,EAAE;IACtD,MAAM,EAAE,sBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;CACzB,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,GAAG,EAAE,sBAAU,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,QAAQ,CAAC,kBAAkB,CAAC;QAC1C,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,CAAC,MAAM,CAAC;KACf,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,OAAO,CAAC,QAAQ,CAAC;YACf,OAAO,EAAE,iCAAgB;YACzB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;SAClC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const clients_1 = require("../../utils/clients");
|
15
|
+
const getDynamicFieldObjects_1 = require("../../utils/sui/getDynamicFieldObjects");
|
16
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
+
const client = (0, clients_1.getClientSui)();
|
18
|
+
const objects = yield (0, getDynamicFieldObjects_1.getDynamicFieldObjects)(client, constants_1.bidsStore, {
|
19
|
+
showContent: true,
|
20
|
+
});
|
21
|
+
const bids = objects
|
22
|
+
.map((obj) => {
|
23
|
+
var _a, _b, _c, _d;
|
24
|
+
if (((_b = (_a = obj.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.type) && ((_d = (_c = obj.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.type) === constants_1.bidsType) {
|
25
|
+
return obj.data.content.fields;
|
26
|
+
}
|
27
|
+
return [];
|
28
|
+
})
|
29
|
+
.flat();
|
30
|
+
yield cache.setItem(constants_1.bidsCacheKey, bids, {
|
31
|
+
prefix: constants_1.platformId,
|
32
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
33
|
+
});
|
34
|
+
});
|
35
|
+
const job = {
|
36
|
+
id: `${constants_1.platformId}-bids`,
|
37
|
+
executor,
|
38
|
+
label: 'realtime',
|
39
|
+
};
|
40
|
+
exports.default = job;
|
41
|
+
//# sourceMappingURL=bidsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bidsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/bidsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAA4E;AAC5E,iDAAmD;AACnD,mFAAgF;AAGhF,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,IAAA,+CAAsB,EAAC,MAAM,EAAE,qBAAS,EAAE;QAC9D,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAU,OAAO;SACxB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;QACX,IAAI,CAAA,MAAA,MAAA,GAAG,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAAI,KAAI,CAAA,MAAA,MAAA,GAAG,CAAC,IAAI,0CAAE,OAAO,0CAAE,IAAI,MAAK,oBAAQ,EAAE,CAAC;YACpE,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAa,CAAC;QACxC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;SACD,IAAI,EAAE,CAAC;IAEV,MAAM,KAAK,CAAC,OAAO,CAAC,wBAAY,EAAE,IAAI,EAAE;QACtC,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,QAAQ;IACR,KAAK,EAAE,UAAU;CAClB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -2,4 +2,8 @@ import { Platform } from '@sonarwatch/portfolio-core';
|
|
2
2
|
export declare const platformId = "tradeport";
|
3
3
|
export declare const platform: Platform;
|
4
4
|
export declare const locksCacheKey = "locks";
|
5
|
+
export declare const bidsCacheKey = "bids";
|
5
6
|
export declare const lockStore = "0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946";
|
7
|
+
export declare const bidsStore = "0x1e5e7f38e3a61d1d189506d0fc6b7e47e935a292d9e1b23c0f3f1c0f94227772";
|
8
|
+
export declare const bidsType = "0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Bid";
|
9
|
+
export declare const escrowType = "0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Escrow";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.lockStore = exports.locksCacheKey = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.escrowType = exports.bidsType = exports.bidsStore = exports.lockStore = exports.bidsCacheKey = exports.locksCacheKey = exports.platform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'tradeport';
|
5
5
|
exports.platform = {
|
6
6
|
id: exports.platformId,
|
@@ -11,5 +11,9 @@ exports.platform = {
|
|
11
11
|
// defiLlamaId: 'foo-finance', // from https://defillama.com/docs/api
|
12
12
|
};
|
13
13
|
exports.locksCacheKey = `locks`;
|
14
|
+
exports.bidsCacheKey = `bids`;
|
14
15
|
exports.lockStore = '0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946';
|
16
|
+
exports.bidsStore = '0x1e5e7f38e3a61d1d189506d0fc6b7e47e935a292d9e1b23c0f3f1c0f94227772';
|
17
|
+
exports.bidsType = '0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Bid';
|
18
|
+
exports.escrowType = '0xec175e537be9e48f75fa6929291de6454d2502f1091feb22c0d26a22821bbf28::kiosk_biddings::Escrow';
|
15
19
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,WAAW,CAAC;AACzB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,kDAAkD;IACzD,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,4BAA4B;IACrC,qEAAqE;CACtE,CAAC;AACW,QAAA,aAAa,GAAG,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,WAAW,CAAC;AACzB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,kDAAkD;IACzD,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,4BAA4B;IACrC,qEAAqE;CACtE,CAAC;AACW,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,YAAY,GAAG,MAAM,CAAC;AAEtB,QAAA,SAAS,GACpB,oEAAoE,CAAC;AAC1D,QAAA,SAAS,GACpB,oEAAoE,CAAC;AAC1D,QAAA,QAAQ,GACnB,yFAAyF,CAAC;AAC/E,QAAA,UAAU,GACrB,4FAA4F,CAAC"}
|
@@ -7,7 +7,9 @@ exports.fetchers = exports.jobs = exports.platforms = void 0;
|
|
7
7
|
const constants_1 = require("./constants");
|
8
8
|
const positionsFetcher_1 = __importDefault(require("./positionsFetcher"));
|
9
9
|
const locksJob_1 = __importDefault(require("./locksJob"));
|
10
|
+
const bidsJob_1 = __importDefault(require("./bidsJob"));
|
11
|
+
const bidsFetcher_1 = __importDefault(require("./bidsFetcher"));
|
10
12
|
exports.platforms = [constants_1.platform];
|
11
|
-
exports.jobs = [locksJob_1.default];
|
12
|
-
exports.fetchers = [positionsFetcher_1.default];
|
13
|
+
exports.jobs = [locksJob_1.default, bidsJob_1.default];
|
14
|
+
exports.fetchers = [positionsFetcher_1.default, bidsFetcher_1.default];
|
13
15
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,0EAAkD;AAClD,0DAAkC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,0EAAkD;AAClD,0DAAkC;AAClC,wDAAgC;AAChC,gEAAwC;AAE3B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,kBAAQ,EAAE,iBAAO,CAAC,CAAC;AAClC,QAAA,QAAQ,GAAc,CAAC,0BAAgB,EAAE,qBAAW,CAAC,CAAC"}
|
@@ -23,3 +23,21 @@ export type LockObject = {
|
|
23
23
|
name: number[];
|
24
24
|
value: Lock;
|
25
25
|
};
|
26
|
+
export type Bid = {
|
27
|
+
beneficiary: string;
|
28
|
+
buyer: string;
|
29
|
+
commission: string;
|
30
|
+
id: ID;
|
31
|
+
nft_id: null;
|
32
|
+
nft_type: string;
|
33
|
+
price: string;
|
34
|
+
wallet: Wallet;
|
35
|
+
};
|
36
|
+
export type Wallet = {
|
37
|
+
fields: Fields;
|
38
|
+
type: string;
|
39
|
+
};
|
40
|
+
export type Fields = {
|
41
|
+
balance: string;
|
42
|
+
id: ID;
|
43
|
+
};
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.LevPositionBuilder = void 0;
|
7
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
7
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
9
|
class LevPositionBuilder {
|
9
10
|
constructor(params) {
|
@@ -32,7 +33,7 @@ class LevPositionBuilder {
|
|
32
33
|
collateralValue = new bignumber_js_1.default(this.params.collateralValue);
|
33
34
|
}
|
34
35
|
return {
|
35
|
-
address: this.params.address,
|
36
|
+
address: (0, portfolio_core_1.formatTokenAddress)(this.params.address, networkId),
|
36
37
|
side: this.params.side,
|
37
38
|
liquidationPrice: this.params.liquidationPrice || null,
|
38
39
|
collateralValue: collateralValue.toNumber(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LevPositionBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/LevPositionBuilder.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"LevPositionBuilder.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/elementbuilder/LevPositionBuilder.ts"],"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AAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,QAAQ,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,0CAAE,QAAQ,EAAE;YAC1C,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;YACjE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;SAChB,CAAC;IACnB,CAAC;CACF;AA1CD,gDA0CC"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
2
|
+
/**
|
3
|
+
* Get both Lending and Borrowing APRs of a market
|
4
|
+
*
|
5
|
+
* @param {BigNumber} borrowedAmount Borrow Amount of the market (decimals applied)
|
6
|
+
* @param {BigNumber} availableAmount Available Amount of the market (decimals applied)
|
7
|
+
* @param {number[]} interestRateAprs The differents raw level of APRs (i.e 2 = 2%, expecting 2 here)
|
8
|
+
* @param {number[]} interestRateSteps The steps of each level of APRs (i.e 80 = 80%, expecting 80 here)
|
9
|
+
* @param {number} spreadFeeBps The spread fee (fee of the protocol) (i.e 2 = 2%, expecting 2 here)
|
10
|
+
*
|
11
|
+
* @returns {Aprs} BorrowApr and DepositApr of the market in raw value (i.e 0.02 = 2%)
|
12
|
+
*/
|
13
|
+
export default function getLendingMarketAprs(borrowedAmount: BigNumber, availableAmount: BigNumber, interestRateAprs: number[], interestRateSteps: number[], spreadFeeBps: number): Aprs;
|
14
|
+
type Aprs = {
|
15
|
+
borrowApr: number;
|
16
|
+
depositApr: number;
|
17
|
+
};
|
18
|
+
export {};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
7
|
+
/**
|
8
|
+
* Get both Lending and Borrowing APRs of a market
|
9
|
+
*
|
10
|
+
* @param {BigNumber} borrowedAmount Borrow Amount of the market (decimals applied)
|
11
|
+
* @param {BigNumber} availableAmount Available Amount of the market (decimals applied)
|
12
|
+
* @param {number[]} interestRateAprs The differents raw level of APRs (i.e 2 = 2%, expecting 2 here)
|
13
|
+
* @param {number[]} interestRateSteps The steps of each level of APRs (i.e 80 = 80%, expecting 80 here)
|
14
|
+
* @param {number} spreadFeeBps The spread fee (fee of the protocol) (i.e 2 = 2%, expecting 2 here)
|
15
|
+
*
|
16
|
+
* @returns {Aprs} BorrowApr and DepositApr of the market in raw value (i.e 0.02 = 2%)
|
17
|
+
*/
|
18
|
+
function getLendingMarketAprs(borrowedAmount, availableAmount, interestRateAprs, interestRateSteps, spreadFeeBps) {
|
19
|
+
if (interestRateAprs.length !== interestRateSteps.length)
|
20
|
+
throw new Error("Interest Rate Aprs and Steps length don't match");
|
21
|
+
const utilization = borrowedAmount.dividedBy(availableAmount.plus(borrowedAmount));
|
22
|
+
let borrowApr = 0;
|
23
|
+
if (borrowedAmount.isZero())
|
24
|
+
borrowApr = (0, bignumber_js_1.default)(interestRateAprs[0]).dividedBy(100).toNumber();
|
25
|
+
if (availableAmount.isZero())
|
26
|
+
borrowApr = (0, bignumber_js_1.default)(interestRateAprs[interestRateAprs.length])
|
27
|
+
.dividedBy(100)
|
28
|
+
.toNumber();
|
29
|
+
for (let i = 0; i < interestRateSteps.length; i++) {
|
30
|
+
const currentUtil = interestRateSteps[i] / 100;
|
31
|
+
const nextUtil = interestRateSteps[i + 1] / 100;
|
32
|
+
const currentApr = new bignumber_js_1.default(interestRateAprs[i]).dividedBy(100);
|
33
|
+
const nextApr = new bignumber_js_1.default(interestRateAprs[i + 1]).dividedBy(100);
|
34
|
+
if (utilization.isEqualTo(currentUtil)) {
|
35
|
+
borrowApr = currentApr.toNumber();
|
36
|
+
}
|
37
|
+
if (utilization.isLessThan(nextUtil)) {
|
38
|
+
const utilizationDelta = utilization.minus(currentUtil);
|
39
|
+
const utilStepsDelta = nextUtil - currentUtil;
|
40
|
+
borrowApr = utilizationDelta
|
41
|
+
.dividedBy(utilStepsDelta)
|
42
|
+
.times(nextApr.minus(currentApr))
|
43
|
+
.plus(currentApr)
|
44
|
+
.toNumber();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
borrowApr = 0;
|
48
|
+
const depositApr = (0, bignumber_js_1.default)(borrowApr)
|
49
|
+
.times(1 - Number(spreadFeeBps) / 100)
|
50
|
+
.times(utilization)
|
51
|
+
.toNumber();
|
52
|
+
return {
|
53
|
+
borrowApr,
|
54
|
+
depositApr,
|
55
|
+
};
|
56
|
+
}
|
57
|
+
exports.default = getLendingMarketAprs;
|
58
|
+
//# sourceMappingURL=getLendingMarketAprs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getLendingMarketAprs.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getLendingMarketAprs.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAErC;;;;;;;;;;GAUG;AACH,SAAwB,oBAAoB,CAC1C,cAAyB,EACzB,eAA0B,EAC1B,gBAA0B,EAC1B,iBAA2B,EAC3B,YAAoB;IAEpB,IAAI,gBAAgB,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAErE,MAAM,WAAW,GAAG,cAAc,CAAC,SAAS,CAC1C,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CACrC,CAAC;IACF,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,cAAc,CAAC,MAAM,EAAE;QACzB,SAAS,GAAG,IAAA,sBAAS,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,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