@sonarwatch/portfolio-plugins 0.11.159 → 0.11.161
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1371 -1363
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/index.js +8 -0
- package/src/index.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/banx/constants.d.ts +8 -0
- package/src/plugins/banx/constants.js +18 -0
- package/src/plugins/banx/constants.js.map +1 -0
- package/src/plugins/banx/filters.d.ts +2 -0
- package/src/plugins/banx/filters.js +14 -0
- package/src/plugins/banx/filters.js.map +1 -0
- package/src/plugins/banx/index.d.ts +6 -0
- package/src/plugins/banx/index.js +12 -0
- package/src/plugins/banx/index.js.map +1 -0
- package/src/plugins/banx/stakingFetcher.js +65 -0
- package/src/plugins/banx/stakingFetcher.js.map +1 -0
- package/src/plugins/banx/structs.d.ts +26 -0
- package/src/plugins/banx/structs.js +29 -0
- package/src/plugins/banx/structs.js.map +1 -0
- package/src/plugins/banx/types.d.ts +65 -0
- package/src/plugins/banx/types.js +3 -0
- package/src/plugins/banx/types.js.map +1 -0
- package/src/plugins/flash/custodiesJob.js +1 -1
- package/src/plugins/flash/custodiesJob.js.map +1 -1
- package/src/plugins/flash/perpetualFetcher.js +3 -3
- package/src/plugins/flash/perpetualFetcher.js.map +1 -1
- package/src/plugins/flash/structs.d.ts +1 -1
- package/src/plugins/flash/structs.js +3 -3
- package/src/plugins/flash/types.d.ts +1 -1
- package/src/plugins/jupiter/exchange/constants.d.ts +11 -0
- package/src/plugins/jupiter/exchange/constants.js +21 -0
- package/src/plugins/jupiter/exchange/constants.js.map +1 -0
- package/src/plugins/jupiter/{custodiesJob.d.ts → exchange/custodiesJob.d.ts} +1 -1
- package/src/plugins/jupiter/{custodiesJob.js → exchange/custodiesJob.js} +5 -5
- package/src/plugins/jupiter/exchange/custodiesJob.js.map +1 -0
- package/src/plugins/{orders/jupiter → jupiter/exchange}/dcaFetcher.js +7 -10
- package/src/plugins/jupiter/exchange/dcaFetcher.js.map +1 -0
- package/src/plugins/jupiter/exchange/filters.d.ts +4 -0
- package/src/plugins/jupiter/exchange/filters.js +46 -0
- package/src/plugins/jupiter/exchange/filters.js.map +1 -0
- package/src/plugins/{orders/jupiter → jupiter/exchange}/limitFetcher.js +10 -20
- package/src/plugins/jupiter/exchange/limitFetcher.js.map +1 -0
- package/src/plugins/jupiter/{perpetualFetcher.d.ts → exchange/perpetualFetcher.d.ts} +1 -1
- package/src/plugins/jupiter/{perpetualFetcher.js → exchange/perpetualFetcher.js} +16 -16
- package/src/plugins/jupiter/exchange/perpetualFetcher.js.map +1 -0
- package/src/plugins/jupiter/{poolJob.d.ts → exchange/poolJob.d.ts} +1 -1
- package/src/plugins/jupiter/{poolJob.js → exchange/poolJob.js} +5 -5
- package/src/plugins/jupiter/exchange/poolJob.js.map +1 -0
- package/src/plugins/jupiter/{structs/perpetuals.d.ts → exchange/structs.d.ts} +71 -1
- package/src/plugins/jupiter/{structs/perpetuals.js → exchange/structs.js} +69 -2
- package/src/plugins/jupiter/exchange/structs.js.map +1 -0
- package/src/plugins/jupiter/{valueAverageFetcher.d.ts → exchange/valueAverageFetcher.d.ts} +1 -1
- package/src/plugins/jupiter/{valueAverageFetcher.js → exchange/valueAverageFetcher.js} +8 -8
- package/src/plugins/jupiter/exchange/valueAverageFetcher.js.map +1 -0
- package/src/plugins/jupiter/filters.d.ts +0 -1
- package/src/plugins/jupiter/filters.js +1 -11
- package/src/plugins/jupiter/filters.js.map +1 -1
- package/src/plugins/jupiter/governance/constants.d.ts +3 -0
- package/src/plugins/jupiter/governance/constants.js +12 -0
- package/src/plugins/jupiter/governance/constants.js.map +1 -0
- package/src/plugins/jupiter/{voteFetcher.d.ts → governance/voteFetcher.d.ts} +1 -1
- package/src/plugins/jupiter/{voteFetcher.js → governance/voteFetcher.js} +10 -9
- package/src/plugins/jupiter/governance/voteFetcher.js.map +1 -0
- package/src/plugins/jupiter/helpers.js +1 -1
- package/src/plugins/jupiter/helpers.js.map +1 -1
- package/src/plugins/jupiter/index.js +12 -8
- package/src/plugins/jupiter/index.js.map +1 -1
- package/src/plugins/jupiter/launchpad/allocationsFetcher.d.ts +3 -0
- package/src/plugins/jupiter/launchpad/allocationsFetcher.js +79 -0
- package/src/plugins/jupiter/launchpad/allocationsFetcher.js.map +1 -0
- package/src/plugins/jupiter/{constants.d.ts → launchpad/constants.d.ts} +10 -9
- package/src/plugins/jupiter/launchpad/constants.js +31 -0
- package/src/plugins/jupiter/launchpad/constants.js.map +1 -0
- package/src/plugins/jupiter/{structs/vote.d.ts → launchpad/structs.d.ts} +10 -0
- package/src/plugins/jupiter/{structs/vote.js → launchpad/structs.js} +11 -2
- package/src/plugins/jupiter/launchpad/structs.js.map +1 -0
- package/src/plugins/jupiter/pricingJob.js +1 -1
- package/src/plugins/jupiter/pricingJob.js.map +1 -1
- package/src/plugins/meteora/dlmmHelper.d.ts +6 -5
- package/src/plugins/meteora/dlmmHelper.js +107 -83
- package/src/plugins/meteora/dlmmHelper.js.map +1 -1
- package/src/plugins/meteora/types.d.ts +8 -0
- package/src/plugins/orders/index.js +16 -23
- package/src/plugins/orders/index.js.map +1 -1
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/plugins/wormhole/airdropFetcher.d.ts +3 -0
- package/src/plugins/wormhole/airdropFetcher.js +52 -0
- package/src/plugins/wormhole/airdropFetcher.js.map +1 -0
- package/src/plugins/wormhole/constants.d.ts +6 -0
- package/src/plugins/wormhole/constants.js +15 -0
- package/src/plugins/wormhole/constants.js.map +1 -0
- package/src/plugins/wormhole/helpers.d.ts +4 -0
- package/src/plugins/wormhole/helpers.js +45 -0
- package/src/plugins/wormhole/helpers.js.map +1 -0
- package/src/plugins/wormhole/index.d.ts +6 -0
- package/src/plugins/wormhole/index.js +8 -0
- package/src/plugins/wormhole/index.js.map +1 -0
- package/src/plugins/wormhole/types.d.ts +9 -0
- package/src/plugins/wormhole/types.js +3 -0
- package/src/plugins/wormhole/types.js.map +1 -0
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
- package/src/plugins/jupiter/airdropFetcher.js +0 -63
- package/src/plugins/jupiter/airdropFetcher.js.map +0 -1
- package/src/plugins/jupiter/constants.js +0 -25
- package/src/plugins/jupiter/constants.js.map +0 -1
- package/src/plugins/jupiter/custodiesJob.js.map +0 -1
- package/src/plugins/jupiter/perpetualFetcher.js.map +0 -1
- package/src/plugins/jupiter/poolJob.js.map +0 -1
- package/src/plugins/jupiter/structs/aidrop.d.ts +0 -14
- package/src/plugins/jupiter/structs/aidrop.js +0 -16
- package/src/plugins/jupiter/structs/aidrop.js.map +0 -1
- package/src/plugins/jupiter/structs/perpetuals.js.map +0 -1
- package/src/plugins/jupiter/structs/valueAverage.d.ts +0 -31
- package/src/plugins/jupiter/structs/valueAverage.js +0 -33
- package/src/plugins/jupiter/structs/valueAverage.js.map +0 -1
- package/src/plugins/jupiter/structs/vote.js.map +0 -1
- package/src/plugins/jupiter/valueAverageFetcher.js.map +0 -1
- package/src/plugins/jupiter/voteFetcher.js.map +0 -1
- package/src/plugins/orders/jupiter/constants.d.ts +0 -3
- package/src/plugins/orders/jupiter/constants.js +0 -7
- package/src/plugins/orders/jupiter/constants.js.map +0 -1
- package/src/plugins/orders/jupiter/dcaFetcher.js.map +0 -1
- package/src/plugins/orders/jupiter/filters.d.ts +0 -3
- package/src/plugins/orders/jupiter/filters.js +0 -36
- package/src/plugins/orders/jupiter/filters.js.map +0 -1
- package/src/plugins/orders/jupiter/limitFetcher.js.map +0 -1
- package/src/plugins/orders/jupiter/struct.d.ts +0 -47
- package/src/plugins/orders/jupiter/struct.js +0 -48
- package/src/plugins/orders/jupiter/struct.js.map +0 -1
- /package/src/plugins/{jupiter/airdropFetcher.d.ts → banx/stakingFetcher.d.ts} +0 -0
- /package/src/plugins/{orders/jupiter → jupiter/exchange}/dcaFetcher.d.ts +0 -0
- /package/src/plugins/{orders/jupiter → jupiter/exchange}/limitFetcher.d.ts +0 -0
@@ -13,16 +13,17 @@ 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
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
16
|
+
const clients_1 = require("../../../utils/clients");
|
17
|
+
const getParsedAccountInfo_1 = require("../../../utils/solana/getParsedAccountInfo");
|
18
|
+
const helpers_1 = require("../helpers");
|
19
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../../utils/misc/tokenPriceToAssetToken"));
|
20
|
+
const structs_1 = require("../launchpad/structs");
|
21
|
+
const constants_1 = require("../launchpad/constants");
|
22
|
+
const constants_2 = require("./constants");
|
22
23
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
24
|
const client = (0, clients_1.getClientSolana)();
|
24
25
|
const escrowPubkey = (0, helpers_1.getVotePda)(owner);
|
25
|
-
const escrowAccount = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(client,
|
26
|
+
const escrowAccount = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, structs_1.escrowStruct, escrowPubkey);
|
26
27
|
if (!escrowAccount)
|
27
28
|
return [];
|
28
29
|
const jupTokenPrice = yield cache.getTokenPrice(constants_1.jupMint, portfolio_core_1.NetworkId.solana);
|
@@ -42,14 +43,14 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
42
43
|
label: 'Staked',
|
43
44
|
name: 'Vote',
|
44
45
|
networkId: portfolio_core_1.NetworkId.solana,
|
45
|
-
platformId:
|
46
|
+
platformId: constants_2.jupGovernancePlatformId,
|
46
47
|
data: { assets: [asset] },
|
47
48
|
value: asset.value,
|
48
49
|
},
|
49
50
|
];
|
50
51
|
});
|
51
52
|
const fetcher = {
|
52
|
-
id: `${
|
53
|
+
id: `${constants_2.jupGovernancePlatformId}-vote`,
|
53
54
|
networkId: portfolio_core_1.NetworkId.solana,
|
54
55
|
executor,
|
55
56
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"voteFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/governance/voteFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AAGpC,oDAAyD;AACzD,qFAAkF;AAClF,wCAAwC;AACxC,wGAAgF;AAChF,kDAAoD;AACpD,sDAAiD;AACjD,2CAAsD;AAEtD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,YAAY,GAAG,IAAA,oBAAU,EAAC,KAAK,CAAC,CAAC;IACvC,MAAM,aAAa,GAAG,MAAM,IAAA,2CAAoB,EAC9C,MAAM,EACN,sBAAY,EACZ,YAAY,CACb,CAAC;IAEF,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAE9B,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,mBAAO,EAAE,0BAAS,CAAC,MAAM,CAAC,CAAC;IAC3E,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;IAEnC,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAE7C,MAAM,KAAK,GAAmB,IAAA,gCAAsB,EAClD,mBAAO,EACP,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,QAAQ,CAAA,CAAC,CAAC,QAAQ,EAAE,EACzD,0BAAS,CAAC,MAAM,EAChB,aAAa,CACd,CAAC;IACF,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,IAAI,CAC1B,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAClD,CAAC;QACF,KAAK,CAAC,UAAU,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO;QACL;YACE,IAAI,EAAE,qCAAoB,CAAC,QAAQ;YACnC,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAE,mCAAuB;YACnC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,mCAAuB,OAAO;IACrC,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -16,7 +16,7 @@ exports.getMergedAssets = exports.getJupiterPrices = exports.getVotePda = export
|
|
16
16
|
const web3_js_1 = require("@solana/web3.js");
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
18
18
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
19
|
-
const constants_1 = require("./constants");
|
19
|
+
const constants_1 = require("./launchpad/constants");
|
20
20
|
function deriveClaimStatus(claimant, distributor, programId) {
|
21
21
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('ClaimStatus'), claimant.toBytes(), distributor.toBytes()], programId);
|
22
22
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,kDAA6C;AAC7C,+DAA4E;
|
1
|
+
{"version":3,"file":"help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E,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAfD,4CAeC;AAED,SAAgB,eAAe,CAAC,MAAwB;IACtD,MAAM,WAAW,GAAgC,IAAI,GAAG,EAAE,CAAC;IAC3D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,SAAS;QAErC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAC/B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QACtC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC/B,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,aAAa,CAAC,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC;YACzC,aAAa,CAAC,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACxE,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1C,CAAC;AAnBD,0CAmBC"}
|
@@ -4,19 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
|
-
const perpetualFetcher_1 = __importDefault(require("./perpetualFetcher"));
|
8
|
-
const
|
7
|
+
const perpetualFetcher_1 = __importDefault(require("./exchange/perpetualFetcher"));
|
8
|
+
const valueAverageFetcher_1 = __importDefault(require("./exchange/valueAverageFetcher"));
|
9
|
+
const limitFetcher_1 = __importDefault(require("./exchange/limitFetcher"));
|
10
|
+
const dcaFetcher_1 = __importDefault(require("./exchange/dcaFetcher"));
|
11
|
+
const custodiesJob_1 = __importDefault(require("./exchange/custodiesJob"));
|
12
|
+
const allocationsFetcher_1 = __importDefault(require("./launchpad/allocationsFetcher"));
|
13
|
+
const voteFetcher_1 = __importDefault(require("./governance/voteFetcher"));
|
9
14
|
const pricingJob_1 = __importDefault(require("./pricingJob"));
|
10
|
-
const
|
11
|
-
const voteFetcher_1 = __importDefault(require("./voteFetcher"));
|
12
|
-
const constants_1 = require("./constants");
|
13
|
-
const valueAverageFetcher_1 = __importDefault(require("./valueAverageFetcher"));
|
15
|
+
const constants_1 = require("./exchange/constants");
|
14
16
|
exports.platforms = [constants_1.jupiterPlatform];
|
15
17
|
exports.jobs = [custodiesJob_1.default, pricingJob_1.default];
|
16
18
|
exports.fetchers = [
|
17
19
|
perpetualFetcher_1.default,
|
18
|
-
airdropFetcher_1.default,
|
19
|
-
voteFetcher_1.default,
|
20
20
|
valueAverageFetcher_1.default,
|
21
|
+
limitFetcher_1.default,
|
22
|
+
dcaFetcher_1.default,
|
23
|
+
allocationsFetcher_1.default,
|
24
|
+
voteFetcher_1.default,
|
21
25
|
];
|
22
26
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/index.ts"],"names":[],"mappings":";;;;;;AAGA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/index.ts"],"names":[],"mappings":";;;;;;AAGA,mFAA2D;AAC3D,yFAAiE;AACjE,2EAAmD;AACnD,uEAA+C;AAC/C,2EAAmD;AAEnD,wFAA+D;AAE/D,2EAAmD;AAEnD,8DAAsC;AACtC,oDAAuD;AAE1C,QAAA,SAAS,GAAe,CAAC,2BAAe,CAAC,CAAC;AAC1C,QAAA,IAAI,GAAU,CAAC,sBAAY,EAAE,oBAAU,CAAC,CAAC;AACzC,QAAA,QAAQ,GAAc;IACjC,0BAAgB;IAChB,6BAAmB;IACnB,sBAAY;IACZ,oBAAU;IACV,4BAAiB;IACjB,qBAAW;CACZ,CAAC"}
|
@@ -0,0 +1,79 @@
|
|
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
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
17
|
+
const web3_js_1 = require("@solana/web3.js");
|
18
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
19
|
+
const clients_1 = require("../../../utils/clients");
|
20
|
+
const helpers_1 = require("../helpers");
|
21
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../../utils/misc/tokenPriceToAssetToken"));
|
22
|
+
const structs_1 = require("./structs");
|
23
|
+
const constants_1 = require("./constants");
|
24
|
+
const solana_1 = require("../../../utils/solana");
|
25
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
26
|
+
const client = (0, clients_1.getClientSolana)();
|
27
|
+
const claimsProof = yield Promise.all(constants_1.airdropsInfo.map((info) => axios_1.default.get(`${constants_1.merkleApi}/${info.mint}/${owner}`).catch(() => null)));
|
28
|
+
const eligibleAirdrops = [];
|
29
|
+
const proofs = [];
|
30
|
+
for (let i = 0; i < claimsProof.length; i++) {
|
31
|
+
const proof = claimsProof[i];
|
32
|
+
if (!proof)
|
33
|
+
continue;
|
34
|
+
eligibleAirdrops.push(constants_1.airdropsInfo[i]);
|
35
|
+
proofs.push(proof.data);
|
36
|
+
}
|
37
|
+
if (proofs.length === 0)
|
38
|
+
return [];
|
39
|
+
const claimStatusAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, structs_1.claimStatusStruct, proofs.map((proof) => (0, helpers_1.deriveClaimStatus)(new web3_js_1.PublicKey(owner), new web3_js_1.PublicKey(proof.merkle_tree), constants_1.merkleDistributorPid)[0]));
|
40
|
+
const tokenPriceById = yield cache.getTokenPricesAsMap(eligibleAirdrops.map((info) => info.mint), portfolio_core_1.NetworkId.solana);
|
41
|
+
const assets = [];
|
42
|
+
for (let j = 0; j < claimStatusAccounts.length; j++) {
|
43
|
+
const claimStatus = claimStatusAccounts[j];
|
44
|
+
if (claimStatus)
|
45
|
+
continue;
|
46
|
+
const proof = proofs[j];
|
47
|
+
const { claimUntilTs, decimals, mint } = eligibleAirdrops[j];
|
48
|
+
if (claimUntilTs < Date.now())
|
49
|
+
continue;
|
50
|
+
const tokenPrice = tokenPriceById.get(mint);
|
51
|
+
const amount = new bignumber_js_1.default(proof.amount)
|
52
|
+
.dividedBy(Math.pow(10, decimals))
|
53
|
+
.toNumber();
|
54
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(mint, amount, portfolio_core_1.NetworkId.solana, tokenPrice, undefined, { isClaimable: true });
|
55
|
+
assets.push(asset);
|
56
|
+
}
|
57
|
+
if (assets.length === 0)
|
58
|
+
return [];
|
59
|
+
return [
|
60
|
+
{
|
61
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
62
|
+
label: 'Rewards',
|
63
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
64
|
+
platformId: constants_1.jupLaunchpadPlatformId,
|
65
|
+
name: 'Allocation',
|
66
|
+
data: {
|
67
|
+
assets,
|
68
|
+
},
|
69
|
+
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
|
70
|
+
},
|
71
|
+
];
|
72
|
+
});
|
73
|
+
const fetcher = {
|
74
|
+
id: `${constants_1.jupLaunchpadPlatformId}-allocation`,
|
75
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
76
|
+
executor,
|
77
|
+
};
|
78
|
+
exports.default = fetcher;
|
79
|
+
//# sourceMappingURL=allocationsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"allocationsFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/launchpad/allocationsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AACpC,kDAA6C;AAC7C,6CAA4C;AAC5C,gEAAqC;AAGrC,oDAAyD;AAEzD,wCAA+C;AAC/C,wGAAgF;AAChF,uCAA8C;AAC9C,2CAMqB;AACrB,kDAAsE;AAEtE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,WAAW,GACf,MAAM,OAAO,CAAC,GAAG,CACf,wBAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACxB,eAAK,CAAC,GAAG,CAAC,GAAG,qBAAS,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAClE,CACF,CAAC;IAEJ,MAAM,gBAAgB,GAAkB,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAyB,EAAE,CAA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,CAAC,CAAC;QAC7D,IAAI,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE;YAAE,SAAS;QAExC,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,KAAK,CAAC,MAAM,CAAC;aACvC,SAAS,CAAC,SAAA,EAAE,EAAI,QAAQ,CAAA,CAAC;aACzB,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,IAAA,gCAAsB,EAClC,IAAI,EACJ,MAAM,EACN,0BAAS,CAAC,MAAM,EAChB,UAAU,EACV,SAAS,EACT,EAAE,WAAW,EAAE,IAAI,EAAE,CACtB,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEnC,OAAO;QACL;YACE,IAAI,EAAE,qCAAoB,CAAC,QAAQ;YACnC,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAE,kCAAsB;YAClC,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE;gBACJ,MAAM;aACP;YACD,KAAK,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1D;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,kCAAsB,aAAa;IAC1C,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
2
|
import { Platform } from '@sonarwatch/portfolio-core';
|
3
|
-
export declare const
|
4
|
-
export declare const
|
5
|
-
export declare const jlpPool: PublicKey;
|
6
|
-
export declare const jlpToken: PublicKey;
|
7
|
-
export declare const perpsProgramId: PublicKey;
|
8
|
-
export declare const valueAverageProgramId: PublicKey;
|
3
|
+
export declare const jupLaunchpadPlatformId = "jupiter-launchpad";
|
4
|
+
export declare const jupLaunchpadPlatform: Platform;
|
9
5
|
export declare const voteProgramId: PublicKey;
|
10
6
|
export declare const lockerPubkey: PublicKey;
|
11
|
-
export declare const merkleDistributorPid: PublicKey;
|
12
7
|
export declare const jupMint = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
|
13
8
|
export declare const jupDecimals = 6;
|
14
|
-
export declare const
|
15
|
-
export declare const
|
9
|
+
export declare const merkleDistributorPid: PublicKey;
|
10
|
+
export declare const merkleApi = "https://worker.jup.ag/jup-claim-proof";
|
11
|
+
export type AirdropInfo = {
|
12
|
+
mint: string;
|
13
|
+
decimals: number;
|
14
|
+
claimUntilTs: number;
|
15
|
+
};
|
16
|
+
export declare const airdropsInfo: AirdropInfo[];
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.airdropsInfo = exports.merkleApi = exports.merkleDistributorPid = exports.jupDecimals = exports.jupMint = exports.lockerPubkey = exports.voteProgramId = exports.jupLaunchpadPlatform = exports.jupLaunchpadPlatformId = void 0;
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
5
|
+
exports.jupLaunchpadPlatformId = 'jupiter-launchpad';
|
6
|
+
exports.jupLaunchpadPlatform = {
|
7
|
+
id: exports.jupLaunchpadPlatformId,
|
8
|
+
name: 'Jupiter Launchpad',
|
9
|
+
image: 'https://sonar.watch/img/platforms/jupiter.png',
|
10
|
+
website: 'https://lfg.jup.ag/',
|
11
|
+
twitter: 'https://twitter.com/JupiterExchange',
|
12
|
+
};
|
13
|
+
exports.voteProgramId = new web3_js_1.PublicKey('voTpe3tHQ7AjQHMapgSue2HJFAh2cGsdokqN3XqmVSj');
|
14
|
+
exports.lockerPubkey = new web3_js_1.PublicKey('CVMdMd79no569tjc5Sq7kzz8isbfCcFyBS5TLGsrZ5dN');
|
15
|
+
exports.jupMint = 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN';
|
16
|
+
exports.jupDecimals = 6;
|
17
|
+
exports.merkleDistributorPid = new web3_js_1.PublicKey('meRjbQXFNf5En86FXT2YPz1dQzLj4Yb3xK8u1MVgqpb');
|
18
|
+
exports.merkleApi = 'https://worker.jup.ag/jup-claim-proof';
|
19
|
+
exports.airdropsInfo = [
|
20
|
+
{
|
21
|
+
mint: 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN',
|
22
|
+
decimals: 6,
|
23
|
+
claimUntilTs: 1722430800000,
|
24
|
+
},
|
25
|
+
{
|
26
|
+
mint: 'ZEUS1aR7aX8DFFJf5QjWj2ftDDdNTroMNGo8YoQm3Gq',
|
27
|
+
decimals: 6,
|
28
|
+
claimUntilTs: 1713445200000,
|
29
|
+
},
|
30
|
+
];
|
31
|
+
//# sourceMappingURL=constants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/launchpad/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,sBAAsB,GAAG,mBAAmB,CAAC;AAC7C,QAAA,oBAAoB,GAAa;IAC5C,EAAE,EAAE,8BAAsB;IAC1B,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,+CAA+C;IACtD,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,qCAAqC;CAC/C,CAAC;AAEW,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,6CAA6C,CAC9C,CAAC;AACW,QAAA,YAAY,GAAG,IAAI,mBAAS,CACvC,8CAA8C,CAC/C,CAAC;AACW,QAAA,OAAO,GAAG,6CAA6C,CAAC;AACxD,QAAA,WAAW,GAAG,CAAC,CAAC;AAEhB,QAAA,oBAAoB,GAAG,IAAI,mBAAS,CAC/C,6CAA6C,CAC9C,CAAC;AACW,QAAA,SAAS,GAAG,uCAAuC,CAAC;AAOpD,QAAA,YAAY,GAAkB;IACzC;QACE,IAAI,EAAE,6CAA6C;QACnD,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,aAAa;KAC5B;IACD;QACE,IAAI,EAAE,6CAA6C;QACnD,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC"}
|
@@ -16,3 +16,13 @@ export type Escrow = {
|
|
16
16
|
buffers: BigNumber[];
|
17
17
|
};
|
18
18
|
export declare const escrowStruct: BeetStruct<Escrow, Partial<Escrow>>;
|
19
|
+
export type ClaimStatus = {
|
20
|
+
buffer: Buffer;
|
21
|
+
claimant: PublicKey;
|
22
|
+
lockedAmount: BigNumber;
|
23
|
+
lockedAmountWithdrawn: BigNumber;
|
24
|
+
unlockedAmount: BigNumber;
|
25
|
+
closable: Buffer;
|
26
|
+
admin: PublicKey;
|
27
|
+
};
|
28
|
+
export declare const claimStatusStruct: BeetStruct<ClaimStatus, Partial<ClaimStatus>>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.escrowStruct = void 0;
|
3
|
+
exports.claimStatusStruct = exports.escrowStruct = void 0;
|
4
4
|
const beet_1 = require("@metaplex-foundation/beet");
|
5
5
|
const beet_solana_1 = require("@metaplex-foundation/beet-solana");
|
6
6
|
const solana_1 = require("../../../utils/solana");
|
@@ -17,4 +17,13 @@ exports.escrowStruct = new beet_1.BeetStruct([
|
|
17
17
|
['isMaxLock', beet_1.bool],
|
18
18
|
['buffers', (0, beet_1.uniformFixedSizeArray)(solana_1.u128, 10)],
|
19
19
|
], (args) => args);
|
20
|
-
|
20
|
+
exports.claimStatusStruct = new beet_1.BeetStruct([
|
21
|
+
['buffer', (0, solana_1.blob)(8)],
|
22
|
+
['claimant', beet_solana_1.publicKey],
|
23
|
+
['lockedAmount', solana_1.u64],
|
24
|
+
['lockedAmountWithdrawn', solana_1.u64],
|
25
|
+
['unlockedAmount', solana_1.u64],
|
26
|
+
['closable', (0, solana_1.blob)(1)],
|
27
|
+
['admin', beet_solana_1.publicKey],
|
28
|
+
], (args) => args);
|
29
|
+
//# sourceMappingURL=structs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/launchpad/structs.ts"],"names":[],"mappings":";;;AAAA,oDAKmC;AACnC,kEAA6D;AAG7D,kDAA6D;AAgBhD,QAAA,YAAY,GAAG,IAAI,iBAAU,CACxC;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,QAAQ,EAAE,uBAAS,CAAC;IACrB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,QAAQ,EAAE,uBAAS,CAAC;IACrB,CAAC,QAAQ,EAAE,YAAG,CAAC;IACf,CAAC,iBAAiB,EAAE,YAAG,CAAC;IACxB,CAAC,cAAc,EAAE,YAAG,CAAC;IACrB,CAAC,cAAc,EAAE,uBAAS,CAAC;IAC3B,CAAC,WAAW,EAAE,WAAI,CAAC;IACnB,CAAC,SAAS,EAAE,IAAA,4BAAqB,EAAC,aAAI,EAAE,EAAE,CAAC,CAAC;CAC7C,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAc,CACzB,CAAC;AAYW,QAAA,iBAAiB,GAAG,IAAI,iBAAU,CAC7C;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,UAAU,EAAE,uBAAS,CAAC;IACvB,CAAC,cAAc,EAAE,YAAG,CAAC;IACrB,CAAC,uBAAuB,EAAE,YAAG,CAAC;IAC9B,CAAC,gBAAgB,EAAE,YAAG,CAAC;IACvB,CAAC,UAAU,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACrB,CAAC,OAAO,EAAE,uBAAS,CAAC;CACrB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAmB,CAC9B,CAAC"}
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
14
|
-
const constants_1 = require("./constants");
|
14
|
+
const constants_1 = require("./exchange/constants");
|
15
15
|
const helpers_1 = require("./helpers");
|
16
16
|
const constants_2 = require("../tokens/constants");
|
17
17
|
const getMultipleDecimalsAsMap_1 = require("../../utils/solana/getMultipleDecimalsAsMap");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pricingJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/pricingJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAG5C,
|
1
|
+
{"version":3,"file":"pricingJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/pricingJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAG5C,oDAAkD;AAClD,uCAA6C;AAC7C,mDAA2D;AAC3D,0FAAuF;AACvF,iDAAsD;AAEtD,MAAM,KAAK,GAAG;IACZ,8CAA8C,EAAE,uBAAuB;IACvE,6CAA6C,EAAE,YAAY;IAC3D,8CAA8C,EAAE,OAAO;CACxD,CAAC;AACF,MAAM,OAAO,GAAG,2CAA0B,CAAC;AAE3C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAAM,aAAa,G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|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
2
|
import BN from 'bn.js';
|
3
3
|
import BigNumber from 'bignumber.js';
|
4
|
-
import { BinLiquidity, LMRewards, PositionData, PositionVersion } from './types';
|
4
|
+
import { BinLiquidity, LMRewards, PositionData, PositionVersion, SwapFee } from './types';
|
5
5
|
import { Bin, BinArray, DLMMPosition, LbPair } from './struct';
|
6
6
|
export declare const MAX_BIN_ARRAY_SIZE: BN;
|
7
7
|
export declare const SCALE_OFFSET = 64;
|
@@ -11,16 +11,17 @@ export declare function deriveBinArrayBitmapExtension(lbPair: PublicKey, program
|
|
11
11
|
export declare function deriveBinArray(lbPair: PublicKey, index: BN, programId: PublicKey): [PublicKey, number];
|
12
12
|
export declare function processPosition(program: PublicKey, version: PositionVersion, lbPair: LbPair, position: DLMMPosition, baseTokenDecimal: number, quoteTokenDecimal: number, lowerBinArray: BinArray, upperBinArray: BinArray): PositionData | null;
|
13
13
|
export declare function getBinsBetweenLowerAndUpperBound(lbPair: LbPair, lowerBinId: number, upperBinId: number, baseTokenDecimal: number, quoteTokenDecimal: number, lowerBinArrays: BinArray, upperBinArrays: BinArray): BinLiquidity[];
|
14
|
-
export declare function getClaimableLMReward(program: PublicKey, positionVersion: PositionVersion, lbPair: LbPair, onChainTimestamp: number, position: DLMMPosition, lowerBinArray
|
14
|
+
export declare function getClaimableLMReward(program: PublicKey, positionVersion: PositionVersion, lbPair: LbPair, onChainTimestamp: number, position: DLMMPosition, lowerBinArray: BinArray, upperBinArray: BinArray): LMRewards;
|
15
|
+
export declare function getClaimableSwapFee(program: PublicKey, positionVersion: PositionVersion, position: DLMMPosition, lowerBinArray: BinArray, upperBinArray: BinArray): SwapFee;
|
15
16
|
export declare function getBinFromBinArray(binId: number, binArray: BinArray): Bin;
|
16
17
|
export declare function getBinArrayLowerUpperBinId(binArrayIndex: BigNumber): BigNumber[];
|
17
18
|
export declare enum Rounding {
|
18
19
|
Up = 0,
|
19
20
|
Down = 1
|
20
21
|
}
|
21
|
-
export declare function mulShr(x:
|
22
|
-
export declare function shlDiv(x:
|
23
|
-
export declare function mulDiv(x:
|
22
|
+
export declare function mulShr(x: BN, y: BN, offset: number, rounding: Rounding): BigNumber;
|
23
|
+
export declare function shlDiv(x: BN, y: BN, offset: number, rounding: Rounding): BigNumber;
|
24
|
+
export declare function mulDiv(x: BN, y: BN, denominator: BN, rounding: Rounding): BigNumber;
|
24
25
|
export declare function getPriceOfBinByBinId(binStep: number, binId: number): string;
|
25
26
|
export declare function getTokensAmountsFromLiquidity(position: DLMMPosition, pool: LbPair, lowerBinArray: BinArray, upperBinArray: BinArray, baseTokenDecimal: number, quoteTokenDecimal: number): {
|
26
27
|
tokenAmountA: BigNumber;
|
@@ -1,27 +1,15 @@
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.getTokensAmountsFromLiquidity = exports.getPriceOfBinByBinId = exports.mulDiv = exports.shlDiv = exports.mulShr = exports.Rounding = exports.getBinArrayLowerUpperBinId = exports.getBinFromBinArray = exports.getClaimableLMReward = exports.getBinsBetweenLowerAndUpperBound = exports.processPosition = exports.deriveBinArray = exports.deriveBinArrayBitmapExtension = exports.binIdToBinArrayIndex = exports.BASIS_POINT_MAX = exports.SCALE_OFFSET = exports.MAX_BIN_ARRAY_SIZE = void 0;
|
6
|
+
exports.getTokensAmountsFromLiquidity = exports.getPriceOfBinByBinId = exports.mulDiv = exports.shlDiv = exports.mulShr = exports.Rounding = exports.getBinArrayLowerUpperBinId = exports.getBinFromBinArray = exports.getClaimableSwapFee = exports.getClaimableLMReward = exports.getBinsBetweenLowerAndUpperBound = exports.processPosition = exports.deriveBinArray = exports.deriveBinArrayBitmapExtension = exports.binIdToBinArrayIndex = exports.BASIS_POINT_MAX = exports.SCALE_OFFSET = exports.MAX_BIN_ARRAY_SIZE = void 0;
|
16
7
|
/* eslint-disable eqeqeq */
|
17
8
|
const web3_js_1 = require("@solana/web3.js");
|
18
9
|
const bn_js_1 = __importDefault(require("bn.js"));
|
19
10
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
20
11
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
21
|
-
const solana_1 = require("../../utils/solana");
|
22
|
-
const clients_1 = require("../../utils/clients");
|
23
12
|
const types_1 = require("./types");
|
24
|
-
const struct_1 = require("./struct");
|
25
13
|
const constants_1 = require("./constants");
|
26
14
|
exports.MAX_BIN_ARRAY_SIZE = new bn_js_1.default(70);
|
27
15
|
exports.SCALE_OFFSET = 64;
|
@@ -87,12 +75,33 @@ function processPosition(program, version, lbPair, position, baseTokenDecimal, q
|
|
87
75
|
positionYAmount: positionYAmount.toString(),
|
88
76
|
});
|
89
77
|
});
|
78
|
+
// Not getting the right results
|
79
|
+
// const { feeX, feeY } = getClaimableSwapFee(
|
80
|
+
// program,
|
81
|
+
// version,
|
82
|
+
// position,
|
83
|
+
// lowerBinArray,
|
84
|
+
// upperBinArray
|
85
|
+
// );
|
86
|
+
// const { rewardOne, rewardTwo } = getClaimableLMReward(
|
87
|
+
// program,
|
88
|
+
// version,
|
89
|
+
// lbPair,
|
90
|
+
// new Date(Date.now()).getTime(),
|
91
|
+
// position,
|
92
|
+
// lowerBinArray,
|
93
|
+
// upperBinArray
|
94
|
+
// );
|
90
95
|
return {
|
91
96
|
totalXAmount: new bignumber_js_1.default(totalXAmount.toString()),
|
92
97
|
totalYAmount: new bignumber_js_1.default(totalYAmount.toString()),
|
93
98
|
positionBinData: positionData,
|
94
99
|
lowerBinId,
|
95
100
|
upperBinId,
|
101
|
+
feeX: new bignumber_js_1.default(0),
|
102
|
+
feeY: new bignumber_js_1.default(0),
|
103
|
+
rewardOne: new bignumber_js_1.default(0),
|
104
|
+
rewardTwo: new bignumber_js_1.default(0),
|
96
105
|
};
|
97
106
|
}
|
98
107
|
exports.processPosition = processPosition;
|
@@ -148,73 +157,90 @@ function getBinsBetweenLowerAndUpperBound(lbPair, lowerBinId, upperBinId, baseTo
|
|
148
157
|
}
|
149
158
|
exports.getBinsBetweenLowerAndUpperBound = getBinsBetweenLowerAndUpperBound;
|
150
159
|
function getClaimableLMReward(program, positionVersion, lbPair, onChainTimestamp, position, lowerBinArray, upperBinArray) {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
if (!pairRewardInfo.mint.equals(web3_js_1.PublicKey.default)) {
|
184
|
-
let rewardPerTokenStored = j === 0
|
185
|
-
? binState.rewardPerTokenXStored
|
186
|
-
: binState.rewardPerTokenYStored;
|
187
|
-
if (i == lbPair.activeId && !binState.liquiditySupply.isZero()) {
|
188
|
-
const currentTime = new bignumber_js_1.default(Math.min(onChainTimestamp, pairRewardInfo.rewardDurationEnd.toNumber()));
|
189
|
-
const delta = currentTime.minus(pairRewardInfo.lastUpdateTime);
|
190
|
-
const liquiditySupply = binArray.version === 0
|
191
|
-
? binState.liquiditySupply
|
192
|
-
: binState.liquiditySupply.shiftedBy(64);
|
193
|
-
const rewardPerTokenStoredDelta = pairRewardInfo.rewardRate
|
194
|
-
.times(delta.toString())
|
195
|
-
.div(new bignumber_js_1.default(15))
|
196
|
-
.div(liquiditySupply);
|
197
|
-
rewardPerTokenStored = rewardPerTokenStored.plus(rewardPerTokenStoredDelta);
|
198
|
-
}
|
199
|
-
const delta = rewardPerTokenStored.minus(j === 0
|
200
|
-
? positionRewardInfo.rewardPerTokenCompletesX
|
201
|
-
: positionRewardInfo.rewardPerTokenCompletesY);
|
202
|
-
const newReward = mulShr(delta, liquidityShare, exports.SCALE_OFFSET, Rounding.Down);
|
203
|
-
rewards[j] = rewards[j]
|
204
|
-
.plus(newReward)
|
205
|
-
.plus(j === 0
|
206
|
-
? positionRewardInfo.rewardPendingsX
|
207
|
-
: positionRewardInfo.rewardPendingsY);
|
160
|
+
const lowerBinArrayIdx = binIdToBinArrayIndex(new bignumber_js_1.default(position.lowerBinId));
|
161
|
+
const rewards = [new bignumber_js_1.default(0), new bignumber_js_1.default(0)];
|
162
|
+
if (!lowerBinArray || !upperBinArray)
|
163
|
+
throw new Error('BinArray not found');
|
164
|
+
for (let i = position.lowerBinId; i <= position.upperBinId; i++) {
|
165
|
+
const binArrayIdx = binIdToBinArrayIndex(new bignumber_js_1.default(i));
|
166
|
+
const binArray = binArrayIdx.eq(lowerBinArrayIdx)
|
167
|
+
? lowerBinArray
|
168
|
+
: upperBinArray;
|
169
|
+
const binState = getBinFromBinArray(i, binArray);
|
170
|
+
const binIdxInPosition = i - position.lowerBinId;
|
171
|
+
const positionRewardInfo = position.rewardInfos[binIdxInPosition];
|
172
|
+
const liquidityShare = positionVersion === types_1.PositionVersion.V1
|
173
|
+
? new bn_js_1.default(position.liquidityShares[binIdxInPosition].toString())
|
174
|
+
: new bn_js_1.default(position.liquidityShares[binIdxInPosition].toString()).shrn(64);
|
175
|
+
for (let j = 0; j < 2; j++) {
|
176
|
+
const pairRewardInfo = lbPair.rewardInfos[j];
|
177
|
+
if (!pairRewardInfo.mint.equals(web3_js_1.PublicKey.default)) {
|
178
|
+
let rewardPerTokenStored = j === 0
|
179
|
+
? binState.rewardPerTokenXStored
|
180
|
+
: binState.rewardPerTokenYStored;
|
181
|
+
if (i == lbPair.activeId && !binState.liquiditySupply.isZero()) {
|
182
|
+
const currentTime = new bignumber_js_1.default(Math.min(onChainTimestamp, pairRewardInfo.rewardDurationEnd.toNumber()));
|
183
|
+
const delta = currentTime.minus(pairRewardInfo.lastUpdateTime);
|
184
|
+
const liquiditySupply = binArray.version === 0
|
185
|
+
? binState.liquiditySupply
|
186
|
+
: binState.liquiditySupply.shiftedBy(64);
|
187
|
+
const rewardPerTokenStoredDelta = pairRewardInfo.rewardRate
|
188
|
+
.times(delta.toString())
|
189
|
+
.div(new bignumber_js_1.default(15))
|
190
|
+
.div(liquiditySupply);
|
191
|
+
rewardPerTokenStored = rewardPerTokenStored.plus(rewardPerTokenStoredDelta);
|
208
192
|
}
|
193
|
+
const delta = rewardPerTokenStored.minus(j === 0
|
194
|
+
? positionRewardInfo.rewardPerTokenCompletesX
|
195
|
+
: positionRewardInfo.rewardPerTokenCompletesY);
|
196
|
+
const newReward = mulShr(new bn_js_1.default(delta.toString()), liquidityShare, exports.SCALE_OFFSET, Rounding.Down);
|
197
|
+
rewards[j] = rewards[j]
|
198
|
+
.plus(newReward)
|
199
|
+
.plus(j === 0
|
200
|
+
? positionRewardInfo.rewardPendingsX
|
201
|
+
: positionRewardInfo.rewardPendingsY);
|
209
202
|
}
|
210
203
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
}
|
204
|
+
}
|
205
|
+
return {
|
206
|
+
rewardOne: rewards[0],
|
207
|
+
rewardTwo: rewards[1],
|
208
|
+
};
|
216
209
|
}
|
217
210
|
exports.getClaimableLMReward = getClaimableLMReward;
|
211
|
+
function getClaimableSwapFee(program, positionVersion, position, lowerBinArray, upperBinArray) {
|
212
|
+
const lowerBinArrayIdx = binIdToBinArrayIndex(new bignumber_js_1.default(position.lowerBinId));
|
213
|
+
let feeX = new bignumber_js_1.default(0);
|
214
|
+
let feeY = new bignumber_js_1.default(0);
|
215
|
+
if (!lowerBinArray || !upperBinArray)
|
216
|
+
throw new Error('BinArray not found');
|
217
|
+
for (let i = position.lowerBinId; i <= position.upperBinId; i++) {
|
218
|
+
const binArrayIdx = binIdToBinArrayIndex(new bignumber_js_1.default(i));
|
219
|
+
const binArray = binArrayIdx.eq(lowerBinArrayIdx)
|
220
|
+
? lowerBinArray
|
221
|
+
: upperBinArray;
|
222
|
+
const binState = getBinFromBinArray(i, binArray);
|
223
|
+
const binIdxInPosition = i - position.lowerBinId;
|
224
|
+
const feeInfos = position.feeInfos[binIdxInPosition];
|
225
|
+
const liquidityShare = positionVersion === types_1.PositionVersion.V1
|
226
|
+
? new bn_js_1.default(position.liquidityShares[binIdxInPosition].toString())
|
227
|
+
: new bn_js_1.default(position.liquidityShares[binIdxInPosition].toString()).shrn(64);
|
228
|
+
if (liquidityShare.isZero())
|
229
|
+
continue;
|
230
|
+
const feeXPerToken = binState.feeAmountXPerTokenStored.minus(feeInfos.feeXPerTokenComplete);
|
231
|
+
if (!feeXPerToken.isZero()) {
|
232
|
+
const newFeeX = mulShr(liquidityShare, new bn_js_1.default(feeXPerToken.toString()), exports.SCALE_OFFSET, Rounding.Down);
|
233
|
+
feeX = feeX.plus(newFeeX).plus(feeInfos.feeXPending);
|
234
|
+
}
|
235
|
+
const feeYPerToken = binState.feeAmountXPerTokenStored.minus(feeInfos.feeXPerTokenComplete);
|
236
|
+
if (!feeYPerToken.isZero()) {
|
237
|
+
const newFeeY = mulShr(liquidityShare, new bn_js_1.default(feeYPerToken.toString()), exports.SCALE_OFFSET, Rounding.Down);
|
238
|
+
feeY = feeY.plus(newFeeY).plus(feeInfos.feeYPending);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
return { feeX, feeY };
|
242
|
+
}
|
243
|
+
exports.getClaimableSwapFee = getClaimableSwapFee;
|
218
244
|
function getBinFromBinArray(binId, binArray) {
|
219
245
|
const [lowerBinId, upperBinId] = getBinArrayLowerUpperBinId(binArray.index);
|
220
246
|
let index = 0;
|
@@ -242,23 +268,21 @@ var Rounding;
|
|
242
268
|
Rounding[Rounding["Down"] = 1] = "Down";
|
243
269
|
})(Rounding || (exports.Rounding = Rounding = {}));
|
244
270
|
function mulShr(x, y, offset, rounding) {
|
245
|
-
const denominator = new
|
271
|
+
const denominator = new bn_js_1.default(1).shln(offset);
|
246
272
|
return mulDiv(x, y, denominator, rounding);
|
247
273
|
}
|
248
274
|
exports.mulShr = mulShr;
|
249
275
|
function shlDiv(x, y, offset, rounding) {
|
250
|
-
const scale = new
|
276
|
+
const scale = new bn_js_1.default(1).shln(-offset);
|
251
277
|
return mulDiv(x, scale, y, rounding);
|
252
278
|
}
|
253
279
|
exports.shlDiv = shlDiv;
|
254
280
|
function mulDiv(x, y, denominator, rounding) {
|
255
|
-
const { div, mod } =
|
256
|
-
|
257
|
-
.
|
258
|
-
if (rounding == Rounding.Up && !mod.isZero()) {
|
259
|
-
return new bignumber_js_1.default(div.add(new bn_js_1.default(1)).toString());
|
281
|
+
const { div: resultat, mod: reste } = x.mul(y).divmod(denominator);
|
282
|
+
if (rounding == Rounding.Up && !reste.isZero()) {
|
283
|
+
return new bignumber_js_1.default(resultat.add(new bn_js_1.default(1)).toString());
|
260
284
|
}
|
261
|
-
return new bignumber_js_1.default(
|
285
|
+
return new bignumber_js_1.default(resultat.toString());
|
262
286
|
}
|
263
287
|
exports.mulDiv = mulDiv;
|
264
288
|
function getPriceOfBinByBinId(binStep, binId) {
|