@sonarwatch/portfolio-plugins 0.11.173 → 0.11.174
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1411 -1407
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/Cache.d.ts +8 -0
- package/src/Cache.js +8 -0
- package/src/Cache.js.map +1 -1
- package/src/plugins/armada-staking/constants.d.ts +8 -0
- package/src/plugins/armada-staking/constants.js +37 -1
- package/src/plugins/armada-staking/constants.js.map +1 -1
- package/src/plugins/armada-staking/index.js +4 -0
- package/src/plugins/armada-staking/index.js.map +1 -1
- package/src/plugins/armada-staking/stakingFetcher.js +1 -1
- package/src/plugins/armada-staking/stakingFetcher.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/daos/filters.d.ts +4 -4
- package/src/plugins/daos/filters.js +9 -9
- package/src/plugins/daos/filters.js.map +1 -1
- package/src/plugins/daos/realmsDepositsFetcher.js +1 -1
- package/src/plugins/daos/realmsDepositsFetcher.js.map +1 -1
- package/src/plugins/daos/realmsProgramsJob.js +2 -2
- package/src/plugins/daos/realmsProgramsJob.js.map +1 -1
- package/src/plugins/mango/banksJob.js +15 -5
- package/src/plugins/mango/banksJob.js.map +1 -1
- package/src/plugins/mango/collateralFetcher.js +4 -4
- package/src/plugins/mango/collateralFetcher.js.map +1 -1
- package/src/plugins/mango/constants.d.ts +1 -1
- package/src/plugins/mango/constants.js +2 -2
- package/src/plugins/mango/constants.js.map +1 -1
- package/src/plugins/marginfi/banksJob.js +34 -9
- package/src/plugins/marginfi/banksJob.js.map +1 -1
- package/src/plugins/marginfi/constants.d.ts +1 -1
- package/src/plugins/marginfi/constants.js +2 -2
- package/src/plugins/marginfi/constants.js.map +1 -1
- package/src/plugins/marginfi/depositsFetcher.js +12 -41
- package/src/plugins/marginfi/depositsFetcher.js.map +1 -1
- package/src/plugins/marginfi/filters.js +4 -0
- package/src/plugins/marginfi/filters.js.map +1 -1
- package/src/plugins/marginfi/helpers.d.ts +1 -1
- package/src/plugins/marginfi/helpers.js +41 -31
- package/src/plugins/marginfi/helpers.js.map +1 -1
- package/src/plugins/marginfi/structs/Bank.d.ts +19 -12
- package/src/plugins/marginfi/structs/Bank.js +19 -12
- package/src/plugins/marginfi/structs/Bank.js.map +1 -1
- package/src/plugins/marginfi/types.d.ts +7 -3
- package/src/plugins/rain/helpers.d.ts +1 -1
- package/src/plugins/rain/helpers.js +1 -1
- package/src/plugins/rain/helpers.js.map +1 -1
- package/src/plugins/rain/poolsFetcher.js +1 -3
- package/src/plugins/rain/poolsFetcher.js.map +1 -1
- package/src/plugins/solend/marketsJob.js +1 -1
- package/src/plugins/solend/marketsJob.js.map +1 -1
- package/src/plugins/solend/reservesJob.js +24 -14
- package/src/plugins/solend/reservesJob.js.map +1 -1
- package/src/plugins/suilend/marketsJob.js +1 -1
- package/src/plugins/suilend/marketsJob.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -19,20 +19,37 @@ const clients_1 = require("../../utils/clients");
|
|
19
19
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
20
|
const connection = (0, clients_1.getClientSolana)();
|
21
21
|
const banksRawData = yield (0, solana_1.getParsedProgramAccounts)(connection, Bank_1.bankStruct, constants_1.MarginfiProgram, (0, filters_1.banksFilters)());
|
22
|
+
const banks = [];
|
23
|
+
const rateItems = [];
|
22
24
|
for (let index = 0; index < banksRawData.length; index += 1) {
|
23
25
|
const bank = banksRawData[index];
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
const { lendingApr, borrowingApr } = (0, helpers_1.computeInterestRates)(bank);
|
27
|
+
banks.push(Object.assign(Object.assign({}, bank), { dividedAssetShareValue: (0, helpers_1.wrappedI80F48toBigNumber)(bank.assetShareValue)
|
28
|
+
.div(Math.pow(10, bank.mintDecimals))
|
29
|
+
.toString(), dividedLiabilityShareValue: (0, helpers_1.wrappedI80F48toBigNumber)(bank.liabilityShareValue)
|
30
|
+
.div(Math.pow(10, bank.mintDecimals))
|
31
|
+
.toString(), suppliedLtv: (0, helpers_1.wrappedI80F48toBigNumber)(bank.config.assetWeightMaint)
|
32
|
+
.decimalPlaces(2)
|
33
|
+
.toNumber(), suppliedYields: [
|
34
|
+
{
|
35
|
+
apy: (0, portfolio_core_1.aprToApy)(lendingApr),
|
36
|
+
apr: lendingApr,
|
37
|
+
},
|
38
|
+
], borrowedWeight: (0, helpers_1.wrappedI80F48toBigNumber)(bank.config.liabilityWeightMaint)
|
39
|
+
.decimalPlaces(2)
|
40
|
+
.toNumber(), borrowedYields: [
|
41
|
+
{
|
42
|
+
apy: -(0, portfolio_core_1.aprToApy)(borrowingApr),
|
43
|
+
apr: -borrowingApr,
|
44
|
+
},
|
45
|
+
] }));
|
29
46
|
const depositedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(bank.liabilityShareValue)
|
30
47
|
.times((0, helpers_1.wrappedI80F48toBigNumber)(bank.totalLiabilityShares))
|
31
48
|
.toNumber();
|
32
49
|
const borrowedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(bank.assetShareValue)
|
33
50
|
.times((0, helpers_1.wrappedI80F48toBigNumber)(bank.totalAssetShares))
|
34
51
|
.toNumber();
|
35
|
-
if (borrowedAmount <=
|
52
|
+
if (borrowedAmount <= 1 && depositedAmount <= 1)
|
36
53
|
continue;
|
37
54
|
const tokenAddress = bank.mint.toString();
|
38
55
|
const poolName = bank.config.riskTier === 0 ? 'Global Pool' : 'Isolated Pool';
|
@@ -51,11 +68,19 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
68
|
platformId: constants_1.platformId,
|
52
69
|
poolName,
|
53
70
|
};
|
54
|
-
|
55
|
-
|
56
|
-
|
71
|
+
rateItems.push({
|
72
|
+
key: `${bank.pubkey.toString()}-${tokenAddress}`,
|
73
|
+
value: rate,
|
57
74
|
});
|
58
75
|
}
|
76
|
+
yield cache.setItem(constants_1.banksKey, banks, {
|
77
|
+
prefix: constants_1.platformId,
|
78
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
79
|
+
});
|
80
|
+
yield cache.setItems(rateItems, {
|
81
|
+
prefix: portfolio_core_1.borrowLendRatesPrefix,
|
82
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
83
|
+
});
|
59
84
|
});
|
60
85
|
const job = {
|
61
86
|
id: `${constants_1.platformId}-banks`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"banksJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/banksJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AACpC,
|
1
|
+
{"version":3,"file":"banksJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/banksJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AACpC,2CAAoE;AACpE,yCAA4C;AAC5C,uCAAyC;AACzC,uCAA2E;AAC3E,+CAA8D;AAC9D,iDAAsD;AAKtD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,YAAY,GAAG,MAAM,IAAA,iCAAwB,EACjD,UAAU,EACV,iBAAU,EACV,2BAAe,EACf,IAAA,sBAAY,GAAE,CACf,CAAC;IAEF,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,IAAA,8BAAoB,EAAC,IAAI,CAAC,CAAC;QAEhE,KA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|
-
export declare const
|
4
|
+
export declare const banksKey = "banks";
|
5
5
|
export declare const platformId = "marginfi";
|
6
6
|
export declare const marginfiPlatform: Platform;
|
7
7
|
export declare const MarginfiProgram: PublicKey;
|
@@ -3,11 +3,11 @@ 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.solFactor = exports.MarginfiAccountAddress = exports.MarginfiProgram = exports.marginfiPlatform = exports.platformId = exports.
|
6
|
+
exports.solFactor = exports.MarginfiAccountAddress = exports.MarginfiProgram = exports.marginfiPlatform = exports.platformId = exports.banksKey = void 0;
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
8
8
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
9
9
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
10
|
-
exports.
|
10
|
+
exports.banksKey = 'banks';
|
11
11
|
exports.platformId = 'marginfi';
|
12
12
|
exports.marginfiPlatform = {
|
13
13
|
id: exports.platformId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/constants.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,+DAAqE;AACrE,gEAAqC;AAExB,QAAA,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/constants.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,+DAAqE;AACrE,gEAAqC;AAExB,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QAAA,UAAU,GAAG,UAAU,CAAC;AACxB,QAAA,gBAAgB,GAAa;IACxC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,gDAAgD;IACvD,WAAW,EAAE,iBAAiB;IAC9B,OAAO,EAAE,2BAA2B;CACrC,CAAC;AACW,QAAA,eAAe,GAAG,IAAI,mBAAS,CAC1C,6CAA6C,CAC9C,CAAC;AAEW,QAAA,sBAAsB,GACjC,8CAA8C,CAAC;AAEpC,QAAA,SAAS,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,8BAAa,CAAC,MAAM,CAAC,QAAQ,CAAA,CAAC,CAAC"}
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
17
16
|
const constants_1 = require("./constants");
|
18
17
|
const MarginfiAccount_1 = require("./structs/MarginfiAccount");
|
19
18
|
const helpers_1 = require("./helpers");
|
@@ -21,19 +20,16 @@ const filters_1 = require("./filters");
|
|
21
20
|
const solana_1 = require("../../utils/solana");
|
22
21
|
const clients_1 = require("../../utils/clients");
|
23
22
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
24
|
-
const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
|
25
|
-
const helpers_2 = require("../../utils/solana/pyth/helpers");
|
26
|
-
const Bank_1 = require("./structs/Bank");
|
27
23
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
28
24
|
const client = (0, clients_1.getClientSolana)();
|
29
25
|
const accounts = yield (0, solana_1.getParsedProgramAccounts)(client, MarginfiAccount_1.marginfiAccountStruct, constants_1.MarginfiProgram, (0, filters_1.accountsFilter)(owner));
|
30
26
|
if (accounts.length === 0)
|
31
27
|
return [];
|
32
|
-
const banksInfo = yield cache.
|
33
|
-
prefix: constants_1.
|
28
|
+
const banksInfo = yield cache.getItem(constants_1.banksKey, {
|
29
|
+
prefix: constants_1.platformId,
|
34
30
|
networkId: portfolio_core_1.NetworkId.solana,
|
35
31
|
});
|
36
|
-
if (banksInfo.length === 0)
|
32
|
+
if (!banksInfo || banksInfo.length === 0)
|
37
33
|
return [];
|
38
34
|
const banksInfoByAddress = new Map();
|
39
35
|
const tokensAddresses = new Set();
|
@@ -43,7 +39,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
43
39
|
banksInfoByAddress.set(bankInfo.pubkey.toString(), bankInfo);
|
44
40
|
tokensAddresses.add(bankInfo.mint.toString());
|
45
41
|
});
|
46
|
-
const tokenPriceById = yield
|
42
|
+
const tokenPriceById = yield cache.getTokenPricesAsMap(Array.from(tokensAddresses), portfolio_core_1.NetworkId.solana);
|
47
43
|
const elements = [];
|
48
44
|
for (const account of accounts) {
|
49
45
|
const { balances } = account.lendingAccount;
|
@@ -63,47 +59,22 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
63
59
|
const bankInfo = banksInfoByAddress.get(balance.bankPk.toString());
|
64
60
|
if (!bankInfo)
|
65
61
|
continue;
|
66
|
-
const { lendingApr, borrowingApr } = (0, helpers_1.getInterestRates)(bankInfo);
|
67
62
|
const tokenPrice = tokenPriceById.get(bankInfo.mint.toString());
|
68
|
-
let price;
|
69
|
-
if (!tokenPrice && bankInfo.config.oracleSetup === Bank_1.OracleSetup.PythEma) {
|
70
|
-
const pythOracle = new web3_js_1.PublicKey(bankInfo.config.oracleKeys[0]);
|
71
|
-
const pythAccount = yield client.getAccountInfo(pythOracle);
|
72
|
-
const pythPrice = pythAccount ? (0, helpers_2.parsePriceData)(pythAccount.data) : null;
|
73
|
-
if (pythPrice)
|
74
|
-
price = pythPrice.price;
|
75
|
-
}
|
76
63
|
if (!balance.assetShares.value.isZero()) {
|
77
|
-
suppliedLtvs.push(
|
78
|
-
|
79
|
-
.toNumber());
|
80
|
-
const suppliedQuantity = (0, helpers_1.wrappedI80F48toBigNumber)(balance.assetShares)
|
64
|
+
suppliedLtvs.push(bankInfo.suppliedLtv);
|
65
|
+
const suppliedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.assetShares)
|
81
66
|
.times(bankInfo.dividedAssetShareValue)
|
82
67
|
.toNumber();
|
83
|
-
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(),
|
84
|
-
|
85
|
-
{
|
86
|
-
apr: lendingApr,
|
87
|
-
apy: (0, portfolio_core_1.aprToApy)(lendingApr),
|
88
|
-
},
|
89
|
-
];
|
90
|
-
suppliedYields.push(bankLendingYields);
|
68
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), suppliedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
69
|
+
suppliedYields.push(bankInfo.suppliedYields);
|
91
70
|
}
|
92
71
|
if (!balance.liabilityShares.value.isZero()) {
|
93
|
-
borrowedWeights.push(
|
94
|
-
|
95
|
-
.toNumber());
|
96
|
-
const borrowedQuantity = (0, helpers_1.wrappedI80F48toBigNumber)(balance.liabilityShares)
|
72
|
+
borrowedWeights.push(bankInfo.borrowedWeight);
|
73
|
+
const borrowedAmount = (0, helpers_1.wrappedI80F48toBigNumber)(balance.liabilityShares)
|
97
74
|
.times(bankInfo.dividedLiabilityShareValue)
|
98
75
|
.toNumber();
|
99
|
-
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(),
|
100
|
-
|
101
|
-
{
|
102
|
-
apr: -borrowingApr,
|
103
|
-
apy: -(0, portfolio_core_1.aprToApy)(borrowingApr),
|
104
|
-
},
|
105
|
-
];
|
106
|
-
borrowedYields.push(bankBorrowedYields);
|
76
|
+
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(bankInfo.mint.toString(), borrowedAmount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
77
|
+
borrowedYields.push(bankInfo.borrowedYields);
|
107
78
|
}
|
108
79
|
}
|
109
80
|
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,2CAAoE;AACpE,+DAAkE;AAClE,uCAAqD;AACrD,uCAA2C;AAE3C,+CAA6E;AAC7E,iDAAsD;AACtD,qGAA6E;AAI7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAwB,EAC7C,MAAM,EACN,uCAAqB,EACrB,2BAAe,EACf,IAAA,wBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,OAAO,CAA4B,oBAAQ,EAAE;QACzE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpD,MAAM,kBAAkB,GAA0B,IAAI,GAAG,EAAE,CAAC;IAC5D,MAAM,eAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC/C,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAoB,CAAC,CAAC;QACzE,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,QA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qB;YAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,eAAe,EAAE,IAAI;gBACrB,WAAW;gBACX,YAAY;gBACZ,WAAW;gBACX,KAAK;aACN;SACF,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.banksFilters = exports.accountsFilter = void 0;
|
4
4
|
const constants_1 = require("./constants");
|
5
|
+
const Bank_1 = require("./structs/Bank");
|
5
6
|
const accountsFilter = (owner) => [
|
6
7
|
{
|
7
8
|
memcmp: {
|
@@ -36,6 +37,9 @@ const banksFilters = () => [
|
|
36
37
|
offset: 41,
|
37
38
|
},
|
38
39
|
},
|
40
|
+
{
|
41
|
+
dataSize: Bank_1.bankStruct.byteSize,
|
42
|
+
},
|
39
43
|
];
|
40
44
|
exports.banksFilters = banksFilters;
|
41
45
|
//# sourceMappingURL=filters.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/filters.ts"],"names":[],"mappings":";;;AACA,2CAAqD;
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/filters.ts"],"names":[],"mappings":";;;AACA,2CAAqD;AACrD,yCAA4C;AAErC,MAAM,cAAc,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IAC3E;QACE,MAAM,EAAE;YACN,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,CAAC;SACV;KACF;IACD;QACE,MAAM,EAAE;YACN,KAAK,EAAE,kCAAsB;YAC7B,MAAM,EAAE,CAAC;SACV;KACF;IACD;QACE,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,EAAE;SACX;KACF;CACF,CAAC;AAnBW,QAAA,cAAc,kBAmBzB;AAEK,MAAM,YAAY,GAAG,GAA+B,EAAE,CAAC;IAC5D;QACE,MAAM,EAAE;YACN,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,CAAC;SACV;KACF;IACD;QACE,MAAM,EAAE;YACN,KAAK,EAAE,kCAAsB;YAC7B,MAAM,EAAE,EAAE;SACX;KACF;IACD;QACE,QAAQ,EAAE,iBAAU,CAAC,QAAQ;KAC9B;CACF,CAAC;AAhBW,QAAA,YAAY,gBAgBvB"}
|
@@ -3,7 +3,7 @@ import { Bank } from './structs/Bank';
|
|
3
3
|
export declare function wrappedI80F48toBigNumber({ value }: {
|
4
4
|
value: BigNumber;
|
5
5
|
}, scaleDecimal?: number): BigNumber;
|
6
|
-
export declare function
|
6
|
+
export declare function computeInterestRates(bank: Bank): {
|
7
7
|
lendingApr: number;
|
8
8
|
borrowingApr: number;
|
9
9
|
};
|
@@ -3,49 +3,59 @@ 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.
|
6
|
+
exports.computeInterestRates = exports.wrappedI80F48toBigNumber = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
9
9
|
function wrappedI80F48toBigNumber({ value }, scaleDecimal = 0) {
|
10
10
|
if (!value)
|
11
11
|
return new bignumber_js_1.default(0);
|
12
|
-
const
|
13
|
-
const numbers = new decimal_js_1.default(`${newValue.isNegative() ? '-' : ''}0b${newValue.abs().toString(2)}p-48`).dividedBy(Math.pow(10, scaleDecimal));
|
12
|
+
const numbers = new decimal_js_1.default(`${value.isNegative() ? '-' : ''}0b${value.abs().toString(2)}p-48`).dividedBy(Math.pow(10, scaleDecimal));
|
14
13
|
return new bignumber_js_1.default(numbers.toString());
|
15
14
|
}
|
16
15
|
exports.wrappedI80F48toBigNumber = wrappedI80F48toBigNumber;
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.times(new bignumber_js_1.default(1).plus(rateFee))
|
30
|
-
.plus(fixedFee)
|
31
|
-
.toNumber();
|
32
|
-
return { lendingApr: lendingApy, borrowingApr: borrowingApy };
|
16
|
+
function getTotalLiabilityQuantity(bank) {
|
17
|
+
return wrappedI80F48toBigNumber(bank.totalLiabilityShares).times(wrappedI80F48toBigNumber(bank.liabilityShareValue));
|
18
|
+
}
|
19
|
+
function getTotalAssetQuantity(bank) {
|
20
|
+
return wrappedI80F48toBigNumber(bank.totalAssetShares).times(wrappedI80F48toBigNumber(bank.assetShareValue));
|
21
|
+
}
|
22
|
+
function computeUtilizationRate(bank) {
|
23
|
+
const assets = getTotalAssetQuantity(bank);
|
24
|
+
const liabilities = getTotalLiabilityQuantity(bank);
|
25
|
+
if (assets.isZero())
|
26
|
+
return new bignumber_js_1.default(0);
|
27
|
+
return liabilities.div(assets);
|
33
28
|
}
|
34
|
-
|
35
|
-
function interestRateCurve(bank) {
|
29
|
+
function computeBaseInterestRate(bank) {
|
36
30
|
const { optimalUtilizationRate, plateauInterestRate, maxInterestRate } = bank.config.interestRateConfig;
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
const fOptimalUtilizationRate = wrappedI80F48toBigNumber(optimalUtilizationRate);
|
32
|
+
const fPlateauInterestRate = wrappedI80F48toBigNumber(plateauInterestRate);
|
33
|
+
const fMaxInterestRate = wrappedI80F48toBigNumber(maxInterestRate);
|
34
|
+
const utilizationRate = computeUtilizationRate(bank);
|
35
|
+
if (utilizationRate.lte(fOptimalUtilizationRate)) {
|
41
36
|
return utilizationRate
|
42
|
-
.times(
|
43
|
-
.div(
|
37
|
+
.times(fPlateauInterestRate)
|
38
|
+
.div(fOptimalUtilizationRate);
|
44
39
|
}
|
45
40
|
return utilizationRate
|
46
|
-
.minus(
|
47
|
-
.div(new bignumber_js_1.default(1).minus(
|
48
|
-
.times(
|
49
|
-
.plus(
|
41
|
+
.minus(fOptimalUtilizationRate)
|
42
|
+
.div(new bignumber_js_1.default(1).minus(fOptimalUtilizationRate))
|
43
|
+
.times(fMaxInterestRate.minus(fPlateauInterestRate))
|
44
|
+
.plus(fPlateauInterestRate);
|
45
|
+
}
|
46
|
+
function computeInterestRates(bank) {
|
47
|
+
const { insuranceFeeFixedApr, insuranceIrFee, protocolFixedFeeApr, protocolIrFee, } = bank.config.interestRateConfig;
|
48
|
+
const fixedFee = wrappedI80F48toBigNumber(insuranceFeeFixedApr).plus(wrappedI80F48toBigNumber(protocolFixedFeeApr));
|
49
|
+
const rateFee = wrappedI80F48toBigNumber(insuranceIrFee).plus(wrappedI80F48toBigNumber(protocolIrFee));
|
50
|
+
const baseInterestRate = computeBaseInterestRate(bank);
|
51
|
+
const utilizationRate = computeUtilizationRate(bank);
|
52
|
+
const lendingRate = baseInterestRate.times(utilizationRate);
|
53
|
+
const borrowingRate = baseInterestRate
|
54
|
+
.times(new bignumber_js_1.default(1).plus(rateFee))
|
55
|
+
.plus(fixedFee);
|
56
|
+
const lendingApr = lendingRate.toNumber();
|
57
|
+
const borrowingApr = borrowingRate.toNumber();
|
58
|
+
return { lendingApr, borrowingApr };
|
50
59
|
}
|
60
|
+
exports.computeInterestRates = computeInterestRates;
|
51
61
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,4DAAiC;AAGjC,SAAgB,wBAAwB,CACtC,EAAE,KAAK,EAAwB,EAC/B,YAAY,GAAG,CAAC;IAEhB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/marginfi/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,4DAAiC;AAGjC,SAAgB,wBAAwB,CACtC,EAAE,KAAK,EAAwB,EAC/B,YAAY,GAAG,CAAC;IAEhB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IAEpC,MAAM,OAAO,GAAG,IAAI,oBAAO,CACzB,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CACnE,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,YAAY,CAAA,CAAC,CAAC;IAChC,OAAO,IAAI,sBAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC3C,CAAC;AAVD,4DAUC;AAED,SAAS,yBAAyB,CAAC,IAAU;IAC3C,OAAO,wBAAwB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAC9D,wBAAwB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CACnD,CAAC;AACJ,CAAC;AACD,SAAS,qBAAqB,CAAC,IAAU;IACvC,OAAO,wBAAwB,CAAC,IAAI,CAAC,gBAAgB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oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,aAAa,GACd,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;IAEnC,MAAM,QAAQ,GAAG,wBAAwB,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAClE,wBAAwB,CAAC,mBAAmB,CAAC,CAC9C,CAAC;IACF,MAAM,OAAO,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAAC,IAAI,CAC3D,wBAAwB,CAAC,aAAa,CAAC,CACxC,CAAC;IAEF,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,gBAAgB;SACnC,KAAK,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACrC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAElB,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;IAE9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACtC,CAAC;AA9BD,oDA8BC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import {
|
2
|
+
import { BeetStruct, bignum } from '@metaplex-foundation/beet';
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
4
4
|
import BigNumber from 'bignumber.js';
|
5
5
|
import { WrappedI80F48 } from './common';
|
@@ -25,9 +25,9 @@ export type InterestRateConfig = {
|
|
25
25
|
insuranceIrFee: WrappedI80F48;
|
26
26
|
protocolFixedFeeApr: WrappedI80F48;
|
27
27
|
protocolIrFee: WrappedI80F48;
|
28
|
-
padding:
|
28
|
+
padding: bignum[];
|
29
29
|
};
|
30
|
-
export declare const interestRateConfigStruct:
|
30
|
+
export declare const interestRateConfigStruct: BeetStruct<InterestRateConfig, Partial<InterestRateConfig>>;
|
31
31
|
export type BankConfig = {
|
32
32
|
assetWeightInit: WrappedI80F48;
|
33
33
|
assetWeightMaint: WrappedI80F48;
|
@@ -37,32 +37,39 @@ export type BankConfig = {
|
|
37
37
|
interestRateConfig: InterestRateConfig;
|
38
38
|
operationalState: BankOperationalState;
|
39
39
|
oracleSetup: OracleSetup;
|
40
|
-
|
41
|
-
|
40
|
+
oracleKeys_1: PublicKey;
|
41
|
+
oracleKeys_2: PublicKey;
|
42
|
+
oracleKeys_3: PublicKey;
|
43
|
+
oracleKeys_4: PublicKey;
|
44
|
+
oracleKeys_5: PublicKey;
|
45
|
+
auto_padding_0: number[];
|
42
46
|
borrowLimit: BigNumber;
|
43
47
|
riskTier: RiskTier;
|
48
|
+
auto_padding_1: BigNumber[];
|
49
|
+
totalAssetValueInitLimit: BigNumber;
|
44
50
|
padding: BigNumber[];
|
45
51
|
};
|
46
|
-
export declare const bankConfigStruct:
|
52
|
+
export declare const bankConfigStruct: BeetStruct<BankConfig, Partial<BankConfig>>;
|
47
53
|
export type Bank = {
|
48
54
|
padding: Buffer;
|
49
55
|
mint: PublicKey;
|
50
56
|
mintDecimals: number;
|
51
57
|
group: PublicKey;
|
52
|
-
|
58
|
+
auto_padding_0: number[];
|
53
59
|
assetShareValue: WrappedI80F48;
|
54
60
|
liabilityShareValue: WrappedI80F48;
|
55
61
|
liquidityVault: PublicKey;
|
56
|
-
|
62
|
+
liquidityVaultBump: number;
|
63
|
+
liquidityVaultAuthorityBump: number;
|
57
64
|
insuranceVault: PublicKey;
|
58
65
|
insuranceVaultBump: number;
|
59
|
-
insuranceVaultAuthorityBump:
|
60
|
-
|
66
|
+
insuranceVaultAuthorityBump: number;
|
67
|
+
auto_padding_1: PublicKey;
|
61
68
|
collectedInsuranceFeesOutstanding: WrappedI80F48;
|
62
69
|
feeVault: PublicKey;
|
63
70
|
feeVaultBump: number;
|
64
71
|
feeVaultAuthorityBump: number;
|
65
|
-
|
72
|
+
auto_padding_2: number[];
|
66
73
|
collectedGroupFeesOutstanding: WrappedI80F48;
|
67
74
|
totalLiabilityShares: WrappedI80F48;
|
68
75
|
totalAssetShares: WrappedI80F48;
|
@@ -75,4 +82,4 @@ export type Bank = {
|
|
75
82
|
padding0: BigNumber[];
|
76
83
|
padding1: BigNumber[];
|
77
84
|
};
|
78
|
-
export declare const bankStruct:
|
85
|
+
export declare const bankStruct: BeetStruct<Bank, Partial<Bank>>;
|
@@ -23,7 +23,7 @@ var RiskTier;
|
|
23
23
|
RiskTier[RiskTier["Collateral"] = 0] = "Collateral";
|
24
24
|
RiskTier[RiskTier["Isolated"] = 1] = "Isolated";
|
25
25
|
})(RiskTier || (exports.RiskTier = RiskTier = {}));
|
26
|
-
exports.interestRateConfigStruct = new beet_1.
|
26
|
+
exports.interestRateConfigStruct = new beet_1.BeetStruct([
|
27
27
|
['optimalUtilizationRate', common_1.wrappedI80F48Struct],
|
28
28
|
['plateauInterestRate', common_1.wrappedI80F48Struct],
|
29
29
|
['maxInterestRate', common_1.wrappedI80F48Struct],
|
@@ -31,9 +31,9 @@ exports.interestRateConfigStruct = new beet_1.FixableBeetStruct([
|
|
31
31
|
['insuranceIrFee', common_1.wrappedI80F48Struct],
|
32
32
|
['protocolFixedFeeApr', common_1.wrappedI80F48Struct],
|
33
33
|
['protocolIrFee', common_1.wrappedI80F48Struct],
|
34
|
-
['padding', (0, beet_1.uniformFixedSizeArray)(
|
34
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u32, 32)],
|
35
35
|
], (args) => args);
|
36
|
-
exports.bankConfigStruct = new beet_1.
|
36
|
+
exports.bankConfigStruct = new beet_1.BeetStruct([
|
37
37
|
['assetWeightInit', common_1.wrappedI80F48Struct],
|
38
38
|
['assetWeightMaint', common_1.wrappedI80F48Struct],
|
39
39
|
['liabilityWeightInit', common_1.wrappedI80F48Struct],
|
@@ -42,31 +42,38 @@ exports.bankConfigStruct = new beet_1.FixableBeetStruct([
|
|
42
42
|
['interestRateConfig', exports.interestRateConfigStruct],
|
43
43
|
['operationalState', beet_1.u8],
|
44
44
|
['oracleSetup', beet_1.u8],
|
45
|
-
['
|
46
|
-
['
|
45
|
+
['oracleKeys_1', beet_solana_1.publicKey],
|
46
|
+
['oracleKeys_2', beet_solana_1.publicKey],
|
47
|
+
['oracleKeys_3', beet_solana_1.publicKey],
|
48
|
+
['oracleKeys_4', beet_solana_1.publicKey],
|
49
|
+
['oracleKeys_5', beet_solana_1.publicKey],
|
50
|
+
['auto_padding_0', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 6)],
|
47
51
|
['borrowLimit', solana_1.u64],
|
48
52
|
['riskTier', beet_1.u8],
|
49
|
-
['
|
53
|
+
['auto_padding_1', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 7)],
|
54
|
+
['totalAssetValueInitLimit', solana_1.u64],
|
55
|
+
['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 5)],
|
50
56
|
], (args) => args);
|
51
|
-
exports.bankStruct = new beet_1.
|
57
|
+
exports.bankStruct = new beet_1.BeetStruct([
|
52
58
|
['padding', (0, solana_1.blob)(8)],
|
53
59
|
['mint', beet_solana_1.publicKey],
|
54
60
|
['mintDecimals', beet_1.u8],
|
55
61
|
['group', beet_solana_1.publicKey],
|
56
|
-
['
|
62
|
+
['auto_padding_0', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 7)],
|
57
63
|
['assetShareValue', common_1.wrappedI80F48Struct],
|
58
64
|
['liabilityShareValue', common_1.wrappedI80F48Struct],
|
59
65
|
['liquidityVault', beet_solana_1.publicKey],
|
60
|
-
['
|
66
|
+
['liquidityVaultBump', beet_1.u8],
|
67
|
+
['liquidityVaultAuthorityBump', beet_1.u8],
|
61
68
|
['insuranceVault', beet_solana_1.publicKey],
|
62
69
|
['insuranceVaultBump', beet_1.u8],
|
63
70
|
['insuranceVaultAuthorityBump', beet_1.u8],
|
64
|
-
['
|
71
|
+
['auto_padding_1', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 4)],
|
65
72
|
['collectedInsuranceFeesOutstanding', common_1.wrappedI80F48Struct],
|
66
73
|
['feeVault', beet_solana_1.publicKey],
|
67
74
|
['feeVaultBump', beet_1.u8],
|
68
75
|
['feeVaultAuthorityBump', beet_1.u8],
|
69
|
-
['
|
76
|
+
['auto_padding_2', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 6)],
|
70
77
|
['collectedGroupFeesOutstanding', common_1.wrappedI80F48Struct],
|
71
78
|
['totalLiabilityShares', common_1.wrappedI80F48Struct],
|
72
79
|
['totalAssetShares', common_1.wrappedI80F48Struct],
|
@@ -74,8 +81,8 @@ exports.bankStruct = new beet_1.FixableBeetStruct([
|
|
74
81
|
['config', exports.bankConfigStruct],
|
75
82
|
['emissionsFlags', solana_1.u64],
|
76
83
|
['emissionsRate', solana_1.u64],
|
77
|
-
['emissionsMint', beet_solana_1.publicKey],
|
78
84
|
['emissionsRemaining', common_1.wrappedI80F48Struct],
|
85
|
+
['emissionsMint', beet_solana_1.publicKey],
|
79
86
|
['padding0', (0, beet_1.uniformFixedSizeArray)(solana_1.u128, 28)],
|
80
87
|
['padding1', (0, beet_1.uniformFixedSizeArray)(solana_1.u128, 32)],
|
81
88
|
], (args) => args);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Bank.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/marginfi/structs/Bank.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"Bank.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/marginfi/structs/Bank.ts"],"names":[],"mappings":";;;AAAA,oDAMmC;AACnC,kEAA6D;AAG7D,qCAA8D;AAC9D,kDAA6D;AAE7D,sIAAsI;AAEtI,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,6CAAI,CAAA;IACJ,mDAAO,CAA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,EAAE,4BAAmB,CAAC;IAC1D,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,cAAc,EAAE,SAAE,CAAC;IACpB,CAAC,uBAAuB,EAAE,SAAE,CAAC;IAC7B,CAAC,gBAAgB,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC,+BAA+B,EAAE,4BAAmB,CAAC;IACtD,CAAC,sBAAsB,EAAE,4BAAmB,CAAC;IAC7C,CAAC,kBAAkB,EAAE,4BAAmB,CAAC;IACzC,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,QAAQ,EAAE,wBAAgB,CAAC;IAC5B,CAAC,gBAAgB,EAAE,YAAG,CAAC;IACvB,CAAC,eAAe,EAAE,YAAG,CAAC;IACtB,CAAC,oBAAoB,EAAE,4BAAmB,CAAC;IAC3C,CAAC,eAAe,EAAE,uBAAS,CAAC;IAC5B,CAAC,UAAU,EAAE,IAAA,4BAAqB,EAAC,aAAI,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC,UAAU,EAAE,IAAA,4BAAqB,EAAC,aAAI,EAAE,EAAE,CAAC,CAAC;CAC9C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAY,CACvB,CAAC"}
|
@@ -1,6 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import { Yield } from '@sonarwatch/portfolio-core';
|
2
2
|
import { Bank } from './structs/Bank';
|
3
3
|
export type BankInfo = Bank & {
|
4
|
-
dividedAssetShareValue:
|
5
|
-
dividedLiabilityShareValue:
|
4
|
+
dividedAssetShareValue: string;
|
5
|
+
dividedLiabilityShareValue: string;
|
6
|
+
suppliedYields: Yield[];
|
7
|
+
borrowedYields: Yield[];
|
8
|
+
suppliedLtv: number;
|
9
|
+
borrowedWeight: number;
|
6
10
|
};
|
@@ -2,6 +2,6 @@ import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { Collection, Pool } from './types';
|
3
3
|
export declare function getPool(pool: string): Promise<Pool | undefined>;
|
4
4
|
export declare function getCollections(): Promise<Collection[]>;
|
5
|
-
export declare function getPoolPda(owner:
|
5
|
+
export declare function getPoolPda(owner: string): PublicKey;
|
6
6
|
export declare function getLoans(owner: string): Promise<import("./types").Loan[]>;
|
7
7
|
export declare function daysBetweenDates(start: Date, end: Date): number;
|
@@ -39,7 +39,7 @@ function getCollections() {
|
|
39
39
|
}
|
40
40
|
exports.getCollections = getCollections;
|
41
41
|
function getPoolPda(owner) {
|
42
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('poolv2', 'utf-8'), owner.toBuffer()], constants_1.programId)[0];
|
42
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('poolv2', 'utf-8'), new web3_js_1.PublicKey(owner).toBuffer()], constants_1.programId)[0];
|
43
43
|
}
|
44
44
|
exports.getPoolPda = getPoolPda;
|
45
45
|
function getLoans(owner) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,6CAA4C;AAC5C,gEAAqC;AACrC,2CAAiD;AASjD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEnC,SAAsB,OAAO,CAAC,IAAY;;QACxC,MAAM,WAAW,GAAuC,MAAM,eAAK;aAChE,GAAG,CAAC,GAAG,mBAAO,sBAAsB,IAAI,EAAE,CAAC;aAC3C,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QACxD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/B,CAAC;CAAA;AAND,0BAMC;AAED,SAAsB,cAAc;;QAClC,MAAM,iBAAiB,GACrB,MAAM,eAAK,CAAC,GAAG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