@sonarwatch/portfolio-plugins 0.11.90 → 0.11.92
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1091 -1083
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/Cache.d.ts +1 -0
- package/src/Cache.js +12 -0
- package/src/Cache.js.map +1 -1
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/bskt/constants.d.ts +7 -0
- package/src/plugins/bskt/constants.js +17 -0
- package/src/plugins/bskt/constants.js.map +1 -0
- package/src/plugins/bskt/filters.d.ts +2 -0
- package/src/plugins/bskt/filters.js +14 -0
- package/src/plugins/bskt/filters.js.map +1 -0
- package/src/plugins/bskt/index.d.ts +6 -0
- package/src/plugins/bskt/index.js +12 -0
- package/src/plugins/bskt/index.js.map +1 -0
- package/src/plugins/bskt/structs.d.ts +13 -0
- package/src/plugins/bskt/structs.js +15 -0
- package/src/plugins/bskt/structs.js.map +1 -0
- package/src/plugins/bskt/types.d.ts +4 -0
- package/src/plugins/bskt/types.js +3 -0
- package/src/plugins/bskt/types.js.map +1 -0
- package/src/plugins/bskt/vestingFetcher.d.ts +3 -0
- package/src/plugins/bskt/vestingFetcher.js +114 -0
- package/src/plugins/bskt/vestingFetcher.js.map +1 -0
- package/src/plugins/circuit/constants.d.ts +1 -3
- package/src/plugins/circuit/constants.js +2 -17
- package/src/plugins/circuit/constants.js.map +1 -1
- package/src/plugins/circuit/depositsFetcher.js +10 -4
- package/src/plugins/circuit/depositsFetcher.js.map +1 -1
- package/src/plugins/circuit/filters.d.ts +1 -0
- package/src/plugins/circuit/filters.js +4 -1
- package/src/plugins/circuit/filters.js.map +1 -1
- package/src/plugins/circuit/index.js +2 -1
- package/src/plugins/circuit/index.js.map +1 -1
- package/src/plugins/circuit/types.d.ts +1 -47
- package/src/plugins/circuit/vaultsJob.d.ts +3 -0
- package/src/plugins/circuit/vaultsJob.js +42 -0
- package/src/plugins/circuit/vaultsJob.js.map +1 -0
- package/src/plugins/drift/deposits.js +1 -1
- package/src/plugins/drift/deposits.js.map +1 -1
- package/src/plugins/drift/helpers.d.ts +0 -1
- package/src/plugins/drift/helpers.js +1 -6
- package/src/plugins/drift/helpers.js.map +1 -1
- package/src/plugins/flash/poolJob.js +1 -2
- package/src/plugins/flash/poolJob.js.map +1 -1
- package/src/plugins/kamino/farmsFetcher.js +14 -5
- package/src/plugins/kamino/farmsFetcher.js.map +1 -1
- package/src/plugins/kamino/farmsJob.js +3 -5
- package/src/plugins/kamino/farmsJob.js.map +1 -1
- package/src/plugins/mango/collateralFetcher.js +1 -2
- package/src/plugins/mango/collateralFetcher.js.map +1 -1
- package/src/plugins/mango/helpers.d.ts +0 -1
- package/src/plugins/mango/helpers.js +1 -7
- package/src/plugins/mango/helpers.js.map +1 -1
- package/src/plugins/navi/collateralFetcher.js +20 -24
- package/src/plugins/navi/collateralFetcher.js.map +1 -1
- package/src/plugins/navi/constants.d.ts +0 -1
- package/src/plugins/navi/constants.js +10 -2
- package/src/plugins/navi/constants.js.map +1 -1
- package/src/plugins/navi/reservesJob.js +12 -50
- package/src/plugins/navi/reservesJob.js.map +1 -1
- package/src/plugins/navi/types.d.ts +42 -44
- 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
- package/src/utils/solana/index.d.ts +1 -0
- package/src/utils/solana/index.js +1 -0
- package/src/utils/solana/index.js.map +1 -1
- package/src/utils/solana/u8ArrayToString.d.ts +1 -0
- package/src/utils/solana/u8ArrayToString.js +11 -0
- package/src/utils/solana/u8ArrayToString.js.map +1 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/circuit/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,wEAAgD;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/circuit/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,wEAAgD;AAChD,4DAAoC;AAEvB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,mBAAS,CAAC,CAAC;AAC1B,QAAA,QAAQ,GAAc,CAAC,yBAAe,CAAC,CAAC"}
|
@@ -1,52 +1,6 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
type WithdrawRequest = {
|
3
|
-
shares: string;
|
4
|
-
value: string;
|
5
|
-
ts: string;
|
6
|
-
};
|
7
|
-
type Vault = {
|
8
|
-
buffer: Buffer;
|
9
|
-
name: number[];
|
10
|
-
pubkey: string;
|
11
|
-
manager: string;
|
12
|
-
tokenAccount: string;
|
13
|
-
userStats: string;
|
14
|
-
user: string;
|
15
|
-
delegate: string;
|
16
|
-
liquidationDelegate: string;
|
17
|
-
userShares: string;
|
18
|
-
totalShares: string;
|
19
|
-
lastFeeUpdateTs: string;
|
20
|
-
liquidationStartTs: string;
|
21
|
-
redeemPeriod: string;
|
22
|
-
totalWithdrawRequested: string;
|
23
|
-
maxTokens: string;
|
24
|
-
managementFee: string;
|
25
|
-
initTs: string;
|
26
|
-
netDeposits: string;
|
27
|
-
managerNetDeposits: string;
|
28
|
-
totalDeposits: string;
|
29
|
-
totalWithdraws: string;
|
30
|
-
managerTotalDeposits: string;
|
31
|
-
managerTotalWithdraws: string;
|
32
|
-
managerTotalFee: string;
|
33
|
-
managerTotalProfitShare: string;
|
34
|
-
minDepositAmount: string;
|
35
|
-
lastManagerWithdrawRequest: WithdrawRequest;
|
36
|
-
sharesBase: number;
|
37
|
-
profitShare: number;
|
38
|
-
hurdleRate: number;
|
39
|
-
spotMarketIndex: number;
|
40
|
-
bump: number;
|
41
|
-
permissioned: boolean;
|
42
|
-
padding: string[];
|
43
|
-
};
|
44
|
-
export type VaultEnhanced = Vault & {
|
45
|
-
publicKey: string;
|
46
|
-
};
|
47
1
|
export type VaultInfo = {
|
2
|
+
pubkey: string;
|
48
3
|
mint: string;
|
49
4
|
decimals: number;
|
50
5
|
name: string;
|
51
6
|
};
|
52
|
-
export {};
|
@@ -0,0 +1,42 @@
|
|
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 clients_1 = require("../../utils/clients");
|
14
|
+
const solana_1 = require("../../utils/solana");
|
15
|
+
const constants_1 = require("../drift/constants");
|
16
|
+
const constants_2 = require("./constants");
|
17
|
+
const filters_1 = require("./filters");
|
18
|
+
const structs_1 = require("./structs");
|
19
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
|
+
const client = (0, clients_1.getClientSolana)();
|
21
|
+
const vaults = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.vaultStruct, constants_2.circuitPid, filters_1.vaultFilter);
|
22
|
+
for (const vault of vaults) {
|
23
|
+
const name = (0, solana_1.u8ArrayToString)(vault.name);
|
24
|
+
const spotMarket = yield cache.getItem(vault.spotMarketIndex.toString(), {
|
25
|
+
prefix: constants_1.prefixSpotMarkets,
|
26
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
27
|
+
});
|
28
|
+
if (!spotMarket)
|
29
|
+
continue;
|
30
|
+
const mint = spotMarket.mint.toString();
|
31
|
+
const { decimals } = spotMarket;
|
32
|
+
const pubkey = vault.pubkey.toString();
|
33
|
+
yield cache.setItem(pubkey, { pubkey, name, mint, decimals }, { prefix: constants_2.prefixVaults, networkId: portfolio_core_1.NetworkId.solana });
|
34
|
+
}
|
35
|
+
});
|
36
|
+
const job = {
|
37
|
+
id: `${constants_2.platformId}-vaults`,
|
38
|
+
executor,
|
39
|
+
label: 'normal',
|
40
|
+
};
|
41
|
+
exports.default = job;
|
42
|
+
//# sourceMappingURL=vaultsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/circuit/vaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAsD;AACtD,+CAA+E;AAC/E,kDAAuD;AACvD,2CAAmE;AACnE,uCAAwC;AACxC,uCAAwC;AAIxC,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAwB,EAC3C,MAAM,EACN,qBAAW,EACX,sBAAU,EACV,qBAAW,CACZ,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAA,wBAAe,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,OAAO,CACpC,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,EAChC;YACE,MAAM,EAAE,6BAAiB;YACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;SAC5B,CACF,CAAC;QACF,IAAI,CAAC,UAAU;YAAE,SAAS;QAE1B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,KAAK,CAAC,OAAO,CACjB,MAAM,EACN,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAChC,EAAE,MAAM,EAAE,wBAAY,EAAE,SAAS,EAAE,0BAAS,CAAC,MAAM,EAAE,CACtD,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -160,7 +160,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
160
160
|
healthRatio,
|
161
161
|
value,
|
162
162
|
},
|
163
|
-
name: (0,
|
163
|
+
name: (0, solana_1.u8ArrayToString)(userAccount.name),
|
164
164
|
});
|
165
165
|
}
|
166
166
|
return elements;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift/deposits.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAUoC;AACpC,gEAAqC;AACrC,6CAA4C;AAG5C,2CAA0E;AAC1E,qCAIkB;AAClB,
|
1
|
+
{"version":3,"file":"deposits.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift/deposits.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAUoC;AACpC,gEAAqC;AACrC,6CAA4C;AAG5C,2CAA0E;AAC1E,qCAIkB;AAClB,uCAMmB;AAEnB,+CAG4B;AAC5B,iDAAsD;AACtD,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,g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,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -20,7 +20,6 @@ export declare function calculateBorrowRate(bank: SpotMarket): BigNumber;
|
|
20
20
|
export declare function calculateDepositRate(bank: SpotMarket): BigNumber;
|
21
21
|
export declare function calculateInterestRate(bank: SpotMarket, delta?: BigNumber): BigNumber;
|
22
22
|
export declare function isSpotPositionAvailable(position: SpotPosition): boolean;
|
23
|
-
export declare function decodeName(bytes: number[]): string;
|
24
23
|
export declare function getUserAccountPublicKey(programId: PublicKey, owner: PublicKey, subAccountId: number): PublicKey;
|
25
24
|
export declare function getUserMainAccountPublicKey(programId: PublicKey, owner: PublicKey): PublicKey;
|
26
25
|
export declare function getUserAccountsPublicKeys(programId: PublicKey, owner: PublicKey, startId: number, endId: number): PublicKey[];
|
@@ -3,7 +3,7 @@ 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.getUserInsuranceFundStakeAccountPublicKey = exports.getUserAccountsPublicKeys = exports.getUserMainAccountPublicKey = exports.getUserAccountPublicKey = exports.
|
6
|
+
exports.getUserInsuranceFundStakeAccountPublicKey = exports.getUserAccountsPublicKeys = exports.getUserMainAccountPublicKey = exports.getUserAccountPublicKey = exports.isSpotPositionAvailable = exports.calculateInterestRate = exports.calculateDepositRate = exports.calculateBorrowRate = exports.calculateUtilization = exports.getSignedTokenAmount = exports.getTokenAmount = exports.divCeil = exports.CONCENTRATION_PRECISION = exports.PERCENTAGE_PRECISION = exports.PERCENTAGE_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION_EXP = exports.QUOTE_SPOT_MARKET_INDEX = exports.TEN = exports.ONE = exports.ZERO = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
8
|
const web3_js_1 = require("@solana/web3.js");
|
9
9
|
const bn_js_1 = require("bn.js");
|
@@ -111,11 +111,6 @@ function isSpotPositionAvailable(position) {
|
|
111
111
|
return position.scaledBalance.eq(exports.ZERO) && position.openOrders === 0;
|
112
112
|
}
|
113
113
|
exports.isSpotPositionAvailable = isSpotPositionAvailable;
|
114
|
-
function decodeName(bytes) {
|
115
|
-
const buffer = Buffer.from(bytes);
|
116
|
-
return buffer.toString('utf8').trim();
|
117
|
-
}
|
118
|
-
exports.decodeName = decodeName;
|
119
114
|
function getUserAccountPublicKey(programId, owner, subAccountId) {
|
120
115
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
121
116
|
Buffer.from('user', 'utf8'),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,6CAA4C;AAC5C,iCAA2B;AAC3B,qCAAqE;AAExD,QAAA,IAAI,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;AACxB,QAAA,GAAG,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;AACvB,QAAA,GAAG,GAAG,IAAI,sBAAS,CAAC,EAAE,CAAC,CAAC;AACxB,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAC5B,QAAA,qCAAqC,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;AACzD,QAAA,iCAAiC,GAAG,IAAI,sBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CACpE,6CAAqC,CACtC,CAAC;AACW,QAAA,8BAA8B,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;AAClD,QAAA,0BAA0B,GAAG,IAAI,sBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAC7D,sCAA8B,CAC/B,CAAC;AACW,QAAA,wBAAwB,GAAG,IAAI,sBAAS,C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C,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YAC3B,KAAK,CAAC,QAAQ,EAAE;YAChB,IAAI,UAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;SACvC,EACD,SAAS,CACV,CAAC,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AApBD,8DAoBC;AAED,SAAgB,yCAAyC,CACvD,SAAoB,EACpB,KAAgB,EAChB,WAAmB;IAEnB,OAAO,mBAAS,CAAC,sBAAsB,CACrC;QACE,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC;QAC3C,KAAK,CAAC,QAAQ,EAAE;QAChB,IAAI,UAAE,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;KACjD,EACD,SAAS,CACV,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAbD,8FAaC"}
|
@@ -19,7 +19,6 @@ const getLpTokenSource_1 = __importDefault(require("../../utils/misc/getLpTokenS
|
|
19
19
|
const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
|
20
20
|
const constants_1 = require("./constants");
|
21
21
|
const structs_1 = require("./structs");
|
22
|
-
const helpers_1 = require("../mango/helpers");
|
23
22
|
const fetchTokenSupplyAndDecimals_1 = require("../../utils/solana/fetchTokenSupplyAndDecimals");
|
24
23
|
const solana_1 = require("../../utils/solana");
|
25
24
|
const constants_2 = require("../jupiter/constants");
|
@@ -97,7 +96,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
96
|
});
|
98
97
|
}
|
99
98
|
// eslint-disable-next-line prefer-const
|
100
|
-
let source = (0, getLpTokenSource_1.default)(portfolio_core_1.NetworkId.solana, constants_1.poolsPkeys[i].toString(), constants_1.platformId, (0,
|
99
|
+
let source = (0, getLpTokenSource_1.default)(portfolio_core_1.NetworkId.solana, constants_1.poolsPkeys[i].toString(), constants_1.platformId, (0, solana_1.u8ArrayToString)(pool.name), { address: mint, decimals, supply }, assets);
|
101
100
|
source.price = pool.aumUsd
|
102
101
|
.dividedBy(Math.pow(10, decimals))
|
103
102
|
.dividedBy(supply)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/poolJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAmE;AACnE,6CAA4C;AAG5C,iDAAsD;AACtD,yFAAiE;AACjE,gGAA6F;AAC7F,2CAAqD;AACrD,uCAAqD;AACrD,
|
1
|
+
{"version":3,"file":"poolJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/poolJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAmE;AACnE,6CAA4C;AAG5C,iDAAsD;AACtD,yFAAiE;AACjE,gGAA6F;AAC7F,2CAAqD;AACrD,uCAAqD;AACrD,gGAA6F;AAE7F,+CAK4B;AAC5B,oDAAoD;AAEpD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,MAAM,IAAA,yDAA2B,EAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAEpE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,OAAO;IAEnC,MAAM,aAAa,GAAG;QACpB,qBAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzC,qBAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC1C,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,wB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AAE,GAAG,sBAAU,OAAO;IACxB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -18,7 +18,7 @@ const clients_1 = require("../../utils/clients");
|
|
18
18
|
const solana_1 = require("../../utils/solana");
|
19
19
|
const vaults_1 = require("./structs/vaults");
|
20
20
|
const filters_1 = require("./filters");
|
21
|
-
const
|
21
|
+
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
22
22
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
23
|
const client = (0, clients_1.getClientSolana)();
|
24
24
|
const userStates = yield (0, solana_1.getParsedProgramAccounts)(client, vaults_1.userStateStruct, constants_1.farmProgramId, (0, filters_1.userStateFilter)(owner));
|
@@ -32,21 +32,30 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
32
32
|
return [];
|
33
33
|
const farmById = new Map();
|
34
34
|
farmsInfo.forEach((farmInfo) => farmById.set(farmInfo.pubkey, farmInfo));
|
35
|
+
const mints = new Set();
|
36
|
+
farmsInfo.forEach((farm) => {
|
37
|
+
mints.add(farm.mint);
|
38
|
+
farm.rewardsMints.forEach((reward) => mints.add(reward));
|
39
|
+
});
|
40
|
+
const tokenPrices = yield cache.getTokenPrices(Array.from(mints), portfolio_core_1.NetworkId.solana);
|
41
|
+
const tokenPriceById = new Map();
|
42
|
+
tokenPrices.forEach((tP) => tP ? tokenPriceById.set(tP.address, tP) : undefined);
|
35
43
|
const liquidities = [];
|
36
44
|
for (const userState of userStates) {
|
37
45
|
const rewardAssets = [];
|
38
46
|
const assets = [];
|
47
|
+
if (userState.activeStakeScaled.isZero())
|
48
|
+
continue;
|
39
49
|
const farm = farmById.get(userState.farmState.toString());
|
40
50
|
if (!farm)
|
41
51
|
continue;
|
42
|
-
|
43
|
-
|
44
|
-
const { price, decimals } = farm;
|
52
|
+
const tokenPrice = tokenPriceById.get(farm.mint);
|
53
|
+
const { decimals } = farm;
|
45
54
|
const amount = userState.activeStakeScaled
|
46
55
|
.dividedBy(Math.pow(10, 18))
|
47
56
|
.dividedBy(Math.pow(10, decimals))
|
48
57
|
.toNumber();
|
49
|
-
assets.push((0,
|
58
|
+
assets.push(...(0, tokenPriceToAssetTokens_1.default)(farm.mint, amount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
50
59
|
// for (let i = 0; i < farm.rewardsMints.length; i++) {
|
51
60
|
// const rewardMint = farm.rewardsMints[i];
|
52
61
|
// if (rewardMint === '11111111111111111111111111111111') continue;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AAGpC,2CAAkE;AAClE,iDAAsD;AACtD,+CAA8D;AAC9D,6CAAmD;AACnD,uCAA4C;AAE5C,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,UAAU,GAAG,MAAM,IAAA,iCAAwB,EAC/C,MAAM,EACN,wBAAe,EACf,yBAAa,EACb,IAAA,yBAAe,EAAC,KAAK,CAAC,CACvB,CAAC;IACF,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,OAAO,CAAa,oBAAQ,EAAE;QAC1D,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAE1B,M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AAC,CAAC;IAC9B,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,OAAO;QACL;YACE,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACtD,IAAI,EAAE;gBACJ,WAAW;aACZ;SACF;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -8,9 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
13
|
const clients_1 = require("../../utils/clients");
|
@@ -18,11 +15,12 @@ const solana_1 = require("../../utils/solana");
|
|
18
15
|
const filters_1 = require("../../utils/solana/filters");
|
19
16
|
const constants_1 = require("./constants");
|
20
17
|
const vaults_1 = require("./structs/vaults");
|
21
|
-
const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
|
22
18
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
19
|
const client = (0, clients_1.getClientSolana)();
|
24
20
|
const farms = yield (0, solana_1.getParsedProgramAccounts)(client, vaults_1.farmStateStruct, constants_1.farmProgramId, (0, filters_1.dataSizeFilter)(8336));
|
25
|
-
const
|
21
|
+
const tokenPrices = yield cache.getTokenPrices(farms.map((farm) => farm.token.mint.toString()), portfolio_core_1.NetworkId.solana);
|
22
|
+
const tokenPriceById = new Map();
|
23
|
+
tokenPrices.forEach((tP) => tP ? tokenPriceById.set(tP.address, tP) : undefined);
|
26
24
|
const farmsInfo = [];
|
27
25
|
farms.forEach((farm) => {
|
28
26
|
if (farm.token.mint.toString() === '11111111111111111111111111111111')
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"farmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/farmsJob.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"farmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kamino/farmsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAmE;AAGnE,iDAAsD;AACtD,+CAA8D;AAC9D,wDAA4D;AAC5D,2CAAkE;AAClE,6CAAmD;AAGnD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,MAAM,IAAA,iCAAwB,EAC1C,MAAM,EACN,wBAAe,EACf,yBAAa,EACb,IAAA,wBAAc,EAAC,IAAI,CAAC,CACrB,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,cAAc,CAC5C,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAC/C,0BAAS,CAAC,MAAM,CACjB,CAAC;IACF,MAAM,cAAc,GAA4B,IAAI,GAAG,EAAE,CAAC;IAC1D,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CACzB,EAAE,CAAC,CAA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AAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -20,7 +20,6 @@ const struct_1 = require("./struct");
|
|
20
20
|
const filters_1 = require("./filters");
|
21
21
|
const solana_1 = require("../../utils/solana");
|
22
22
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
23
|
-
const helpers_1 = require("./helpers");
|
24
23
|
const runInBatch_1 = __importDefault(require("../../utils/misc/runInBatch"));
|
25
24
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
26
25
|
const client = (0, clients_1.getClientSolana)();
|
@@ -137,7 +136,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
137
136
|
rewardAssets,
|
138
137
|
value,
|
139
138
|
},
|
140
|
-
name: (0,
|
139
|
+
name: (0, solana_1.u8ArrayToString)(userAccount.name),
|
141
140
|
});
|
142
141
|
}
|
143
142
|
return elements;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mango/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAAkE;AAClE,iDAAsD;AACtD,qCAA8C;AAC9C,uCAA2C;AAC3C,+
|
1
|
+
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mango/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAAkE;AAClE,iDAAsD;AACtD,qCAA8C;AAC9C,uCAA2C;AAC3C,+CAA+E;AAC/E,qGAA6E;AAC7E,6EAAqD;AAGrD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,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Name(bytes: number[]): string;
|
4
3
|
export declare function getBorrowRateWithoutUpkeepRate(bank: Bank): BigNumber;
|
5
4
|
export declare function zeroI80F48(): BigNumber;
|
6
5
|
/**
|
@@ -3,16 +3,10 @@ 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.getDepositRate = exports.getBorrowRate = exports.zeroI80F48 = exports.getBorrowRateWithoutUpkeepRate =
|
6
|
+
exports.getDepositRate = exports.getBorrowRate = exports.zeroI80F48 = exports.getBorrowRateWithoutUpkeepRate = void 0;
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
8
8
|
const FRACTIONS = 48;
|
9
9
|
const MULTIPLIER_NUMBER = Math.pow(2, FRACTIONS);
|
10
|
-
function decodeName(bytes) {
|
11
|
-
return new TextDecoder('utf-8')
|
12
|
-
.decode(new Uint8Array(bytes))
|
13
|
-
.split('\x00')[0];
|
14
|
-
}
|
15
|
-
exports.decodeName = decodeName;
|
16
10
|
function getBorrowRateWithoutUpkeepRate(bank) {
|
17
11
|
const totalBorrows = bank.indexedBorrows.multipliedBy(bank.borrowIndex);
|
18
12
|
const totalDeposits = bank.indexedDeposits.multipliedBy(bank.depositIndex);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mango/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,iBAAiB,GAAG,SAAA,CAAC,EAAI,SAAS,CAAA,CAAC;AAEzC,SAAgB,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mango/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGrC,MAAM,SAAS,GAAG,EAAE,CAAC;A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,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;AACzD,CAAC;AAdD,wCAcC"}
|
@@ -18,6 +18,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
18
18
|
const constants_1 = require("./constants");
|
19
19
|
const clients_1 = require("../../utils/clients");
|
20
20
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
21
|
+
const amountFactor = new bignumber_js_1.default(Math.pow(10, 36));
|
21
22
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
22
23
|
const client = (0, clients_1.getClientSui)();
|
23
24
|
const borrowedAssets = [];
|
@@ -31,34 +32,29 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
31
32
|
});
|
32
33
|
if (!reservesData)
|
33
34
|
return [];
|
34
|
-
const
|
35
|
-
for (const
|
36
|
-
|
37
|
-
|
38
|
-
for (const pool of constants_1.poolsInfos) {
|
39
|
-
const reserve = reserveById.get(pool.reserveData);
|
40
|
-
if (!reserve)
|
41
|
-
continue;
|
42
|
-
const reserveData = reserve.value.fields;
|
43
|
-
const borrowBalance = yield client.getDynamicFieldObject({
|
44
|
-
parentId: pool.borrowBalanceParentId,
|
35
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(reservesData.map((r) => r.value.fields.coin_type), portfolio_core_1.NetworkId.sui);
|
36
|
+
for (const rData of reservesData) {
|
37
|
+
const borrowBalancePromise = client.getDynamicFieldObject({
|
38
|
+
parentId: rData.value.fields.borrow_balance.fields.user_state.fields.id.id,
|
45
39
|
name: { type: 'address', value: owner },
|
46
40
|
});
|
47
|
-
const
|
48
|
-
parentId:
|
41
|
+
const supplyBalancePromise = client.getDynamicFieldObject({
|
42
|
+
parentId: rData.value.fields.supply_balance.fields.user_state.fields.id.id,
|
49
43
|
name: { type: 'address', value: owner },
|
50
44
|
});
|
51
|
-
const
|
52
|
-
|
53
|
-
|
45
|
+
const [borrowBalance, supplyBalance] = yield Promise.all([
|
46
|
+
borrowBalancePromise,
|
47
|
+
supplyBalancePromise,
|
48
|
+
]);
|
49
|
+
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(rData.value.fields.coin_type, portfolio_core_1.NetworkId.sui));
|
54
50
|
if (!borrowBalance.error && borrowBalance.data) {
|
55
51
|
const borrowInfo = (0, sui_js_1.getObjectFields)(borrowBalance.data);
|
56
52
|
if (borrowInfo.value) {
|
57
|
-
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(
|
58
|
-
.
|
59
|
-
.
|
53
|
+
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(rData.value.fields.coin_type, new bignumber_js_1.default(borrowInfo.value)
|
54
|
+
.times(rData.value.fields.current_borrow_index)
|
55
|
+
.dividedBy(amountFactor)
|
60
56
|
.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
61
|
-
const apy = new bignumber_js_1.default(
|
57
|
+
const apy = new bignumber_js_1.default(rData.value.fields.current_borrow_rate)
|
62
58
|
.dividedBy(Math.pow(10, constants_1.rateFactor))
|
63
59
|
.toNumber();
|
64
60
|
borrowedYields.push([
|
@@ -72,11 +68,11 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
72
68
|
if (!supplyBalance.error && supplyBalance.data) {
|
73
69
|
const supplyInfo = (0, sui_js_1.getObjectFields)(supplyBalance.data);
|
74
70
|
if (supplyInfo.value) {
|
75
|
-
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(
|
76
|
-
.
|
77
|
-
.
|
71
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(rData.value.fields.coin_type, new bignumber_js_1.default(supplyInfo.value)
|
72
|
+
.times(rData.value.fields.current_supply_index)
|
73
|
+
.dividedBy(amountFactor)
|
78
74
|
.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
79
|
-
const apy = new bignumber_js_1.default(
|
75
|
+
const apy = new bignumber_js_1.default(rData.value.fields.current_supply_rate)
|
80
76
|
.dividedBy(Math.pow(10, constants_1.rateFactor))
|
81
77
|
.toNumber();
|
82
78
|
suppliedYields.push([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,2CAAiD;AACjD,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qGAA6E;AAG7E,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAE1C,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,uBAAW,EAAE;QACnE,MAAM,EAAE,0BAAc;QACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IACH,IAAI,CAAC,YAA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,IAAI,sBAAS,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC;qBAC9D,SAAS,CAAC,SAAA,EAAE,EAAI,sBAAU,CAAA,CAAC;qBAC3B,QAAQ,EAAE,CAAC;gBACd,cAAc,CAAC,IAAI,CAAC;oBAClB;wBACE,GAAG,EAAE,IAAA,yBAAQ,EAAC,GAAG,CAAC;wBAClB,GAAG;qBACJ;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE1E,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,GACxD,IAAA,wCAAuB,EAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IACxE,MAAM,OAAO,GAAqB;QAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;QACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,IAAI,EAAE;YACJ,cAAc;YACd,aAAa;YACb,cAAc;YACd,cAAc;YACd,aAAa;YACb,cAAc;YACd,eAAe,EAAE,IAAI;YAErB,WAAW;YACX,YAAY;YACZ,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -4,7 +4,6 @@ export declare const naviPlatform: Platform;
|
|
4
4
|
export declare const reservesPrefix = "navi";
|
5
5
|
export declare const reservesKey = "reserves";
|
6
6
|
export declare const reserveParentId = "0xe6d4c6610b86ce7735ea754596d71d72d10c7980b5052fc3c8cdf8d09fea9b4b";
|
7
|
-
export declare const indexFactor = 18;
|
8
7
|
export declare const rateFactor = 27;
|
9
8
|
export declare const poolsInfos: {
|
10
9
|
id: number;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.poolsInfos = exports.rateFactor = exports.
|
3
|
+
exports.poolsInfos = exports.rateFactor = exports.reserveParentId = exports.reservesKey = exports.reservesPrefix = exports.naviPlatform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'navi';
|
5
5
|
exports.naviPlatform = {
|
6
6
|
id: exports.platformId,
|
@@ -12,7 +12,6 @@ exports.naviPlatform = {
|
|
12
12
|
exports.reservesPrefix = exports.platformId;
|
13
13
|
exports.reservesKey = 'reserves';
|
14
14
|
exports.reserveParentId = '0xe6d4c6610b86ce7735ea754596d71d72d10c7980b5052fc3c8cdf8d09fea9b4b';
|
15
|
-
exports.indexFactor = 18;
|
16
15
|
exports.rateFactor = 27;
|
17
16
|
exports.poolsInfos = [
|
18
17
|
{
|
@@ -51,5 +50,14 @@ exports.poolsInfos = [
|
|
51
50
|
borrowBalanceParentId: '0x7568d06a1b6ffc416a36c82791e3daf0e621cf19d4a2724fc6f74842661b6323',
|
52
51
|
supplyBalanceParentId: '0xa668905b1ad445a3159b4d29b1181c4a62d864861b463dd9106cc0d97ffe8f7f',
|
53
52
|
},
|
53
|
+
{
|
54
|
+
id: 4,
|
55
|
+
name: 'cetus',
|
56
|
+
type: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS',
|
57
|
+
pool: '0x71b9f6e822c48ce827bceadce82201d6a7559f7b0350ed1daa1dc2ba3ac41b56',
|
58
|
+
reserveData: '0x66a807c06212537fe46aa6719a00e4fa1e85a932d0b53ce7c4b1041983645133',
|
59
|
+
borrowBalanceParentId: '0x4c3da45ffff6432b4592a39cdb3ce12f4a28034cbcb804bb071facc81fdd923d',
|
60
|
+
supplyBalanceParentId: '0x6adc72faf2a9a15a583c9fb04f457c6a5f0b456bc9b4832413a131dfd4faddae',
|
61
|
+
},
|
54
62
|
];
|
55
63
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,qCAAqC,kBAAU,MAAM;IAC5D,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,8BAA8B;CACxC,CAAC;AAEW,QAAA,cAAc,GAAG,kBAAU,CAAC;AAC5B,QAAA,WAAW,GAAG,UAAU,CAAC;AAEzB,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAE1D,QAAA,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,YAAY,GAAa;IACpC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,qCAAqC,kBAAU,MAAM;IAC5D,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,8BAA8B;CACxC,CAAC;AAEW,QAAA,cAAc,GAAG,kBAAU,CAAC;AAC5B,QAAA,WAAW,GAAG,UAAU,CAAC;AAEzB,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAE1D,QAAA,UAAU,GAAG,EAAE,CAAC;AAEhB,QAAA,UAAU,GAAG;IACxB;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,8EAA8E;QACpF,WAAW,EACT,oEAAoE;QACtE,IAAI,EAAE,oEAAoE;QAC1E,qBAAqB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