@glowlabs-org/utils 0.2.129 → 0.2.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +1 -1
- package/dist/cjs/{farms-router-BJHzbi9K.js → farms-router-DXTR8f4V.js} +17 -1
- package/dist/cjs/farms-router-DXTR8f4V.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/control-api/farms-router.d.ts +6 -1
- package/dist/cjs/lib/types/index.d.ts +43 -1
- package/dist/esm/browser.js +2 -2
- package/dist/esm/{farms-router-CXLLMwfG.js → farms-router-DqPqj03h.js} +17 -1
- package/dist/esm/farms-router-DqPqj03h.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/control-api/farms-router.d.ts +6 -1
- package/dist/esm/lib/types/index.d.ts +43 -1
- package/package.json +1 -1
- package/src/lib/control-api/farms-router.ts +28 -0
- package/src/lib/types/index.ts +53 -1
- package/dist/cjs/farms-router-BJHzbi9K.js.map +0 -1
- package/dist/esm/farms-router-CXLLMwfG.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var viem = require('viem');
|
|
|
15
15
|
var merkletreejs = require('merkletreejs');
|
|
16
16
|
var ethers = require('ethers');
|
|
17
17
|
var Decimal = require('decimal.js');
|
|
18
|
-
var farmsRouter = require('./farms-router-
|
|
18
|
+
var farmsRouter = require('./farms-router-DXTR8f4V.js');
|
|
19
19
|
|
|
20
20
|
const GENESIS_TIMESTAMP = 1700352000;
|
|
21
21
|
|
|
@@ -23,12 +23,17 @@
|
|
|
23
23
|
* ### POST `/farms/estimate-reward-scores-batch`
|
|
24
24
|
* Calculates reward scores for multiple potential marketplace farms.
|
|
25
25
|
* Each farm is calculated independently as if joining the protocol by itself.
|
|
26
|
+
*
|
|
27
|
+
* ### POST `/farms/mining-scores-batch`
|
|
28
|
+
* Calculates mining scores for existing farms that are already live on the protocol.
|
|
29
|
+
* The mining score represents the return on investment for a miner based on the farm's total GLW rewards.
|
|
26
30
|
*/
|
|
27
|
-
import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse, FarmWithRewards, FarmRewardSplit } from "../types";
|
|
31
|
+
import type { SponsoredFarm, EstimateRewardScoreParams, RewardScoreResponse, EstimateRewardScoresBatchParams, EstimateRewardScoresBatchResponse, FarmWithRewards, FarmRewardSplit, MiningScoresBatchParams, MiningScoresBatchResponse } from "../types";
|
|
28
32
|
export declare function FarmsRouter(baseUrl: string): {
|
|
29
33
|
readonly fetchFarmRewardSplits: (farmId: string) => Promise<FarmRewardSplit[]>;
|
|
30
34
|
readonly fetchSponsoredFarms: (sponsorWallet?: string) => Promise<SponsoredFarm[]>;
|
|
31
35
|
readonly fetchWalletFarmsWithRewards: (walletAddress: string) => Promise<FarmWithRewards[]>;
|
|
32
36
|
readonly estimateRewardScore: (params: EstimateRewardScoreParams) => Promise<RewardScoreResponse>;
|
|
33
37
|
readonly estimateRewardScoresBatch: (params: EstimateRewardScoresBatchParams) => Promise<EstimateRewardScoresBatchResponse>;
|
|
38
|
+
readonly calculateMiningScoresBatch: (params: MiningScoresBatchParams) => Promise<MiningScoresBatchResponse>;
|
|
34
39
|
};
|
|
@@ -422,7 +422,6 @@ export interface EstimateRewardScoreParams {
|
|
|
422
422
|
paymentCurrency: PaymentCurrency;
|
|
423
423
|
adjustedWeeklyCarbonCredits: number;
|
|
424
424
|
regionId: number;
|
|
425
|
-
sponsorDepositSplit?: number;
|
|
426
425
|
}
|
|
427
426
|
export interface RewardScoreResponse {
|
|
428
427
|
rewardScore: number;
|
|
@@ -471,6 +470,49 @@ export type BatchRewardScoreResult = BatchRewardScoreSuccessResult | BatchReward
|
|
|
471
470
|
export interface EstimateRewardScoresBatchResponse {
|
|
472
471
|
results: BatchRewardScoreResult[];
|
|
473
472
|
}
|
|
473
|
+
export interface MiningScoreParams {
|
|
474
|
+
farmId: string;
|
|
475
|
+
userId: string;
|
|
476
|
+
dollarCostOfMiner: string;
|
|
477
|
+
}
|
|
478
|
+
export interface MiningScoresBatchParams {
|
|
479
|
+
farms: MiningScoreParams[];
|
|
480
|
+
}
|
|
481
|
+
export interface MiningScoreResponse {
|
|
482
|
+
miningScore: number;
|
|
483
|
+
userWeeklyGlwRewards: string;
|
|
484
|
+
glwPriceUsd6: string;
|
|
485
|
+
dollarCostOfMiner: string;
|
|
486
|
+
weeksOfMinerLifeRemaining: number;
|
|
487
|
+
regionInfo: {
|
|
488
|
+
regionId: number;
|
|
489
|
+
existingFarmCount: number;
|
|
490
|
+
existingTotalDepositsUsd: string;
|
|
491
|
+
currencyBreakdown: {
|
|
492
|
+
currency: string;
|
|
493
|
+
protocolDepositSum: string;
|
|
494
|
+
carbonCreditProductionSum: string;
|
|
495
|
+
}[];
|
|
496
|
+
regionGctlStaked: string;
|
|
497
|
+
totalGctlStakedAllRegions: string;
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
export interface BatchMiningScoreSuccessResult {
|
|
501
|
+
success: true;
|
|
502
|
+
data: MiningScoreResponse;
|
|
503
|
+
}
|
|
504
|
+
export interface BatchMiningScoreFailureResult {
|
|
505
|
+
success: false;
|
|
506
|
+
error: string;
|
|
507
|
+
farmData: {
|
|
508
|
+
farmId: string;
|
|
509
|
+
userId: string;
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
export type BatchMiningScoreResult = BatchMiningScoreSuccessResult | BatchMiningScoreFailureResult;
|
|
513
|
+
export interface MiningScoresBatchResponse {
|
|
514
|
+
results: BatchMiningScoreResult[];
|
|
515
|
+
}
|
|
474
516
|
export interface UserWeeklyRewards {
|
|
475
517
|
protocolDepositAsset: PaymentCurrency;
|
|
476
518
|
protocolDepositRewards: string;
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TRANSFER_TYPES } from './farms-router-
|
|
2
|
-
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, i as FORWARDER_ABI, F as FarmsRouter, d as ForwarderError, l as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, c as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, j as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, e as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, f as allRegions, h as countries, k as getAddresses, r as regionMetadata, g as usStates, u as useForwarder, a as useOffchainFractions } from './farms-router-
|
|
1
|
+
import { T as TRANSFER_TYPES } from './farms-router-DqPqj03h.js';
|
|
2
|
+
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, i as FORWARDER_ABI, F as FarmsRouter, d as ForwarderError, l as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, c as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, j as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, e as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, f as allRegions, h as countries, k as getAddresses, r as regionMetadata, g as usStates, u as useForwarder, a as useOffchainFractions } from './farms-router-DqPqj03h.js';
|
|
3
3
|
import { verifyTypedData, getAddress } from 'viem';
|
|
4
4
|
import 'ethers';
|
|
5
5
|
|
|
@@ -3638,14 +3638,30 @@ function FarmsRouter(baseUrl) {
|
|
|
3638
3638
|
throw new Error(parseApiError(error));
|
|
3639
3639
|
}
|
|
3640
3640
|
};
|
|
3641
|
+
const calculateMiningScoresBatch = async (params) => {
|
|
3642
|
+
try {
|
|
3643
|
+
const data = await request("/farms/mining-scores-batch", {
|
|
3644
|
+
method: "POST",
|
|
3645
|
+
headers: {
|
|
3646
|
+
"Content-Type": "application/json",
|
|
3647
|
+
},
|
|
3648
|
+
body: JSON.stringify(params),
|
|
3649
|
+
});
|
|
3650
|
+
return data;
|
|
3651
|
+
}
|
|
3652
|
+
catch (error) {
|
|
3653
|
+
throw new Error(parseApiError(error));
|
|
3654
|
+
}
|
|
3655
|
+
};
|
|
3641
3656
|
return {
|
|
3642
3657
|
fetchFarmRewardSplits,
|
|
3643
3658
|
fetchSponsoredFarms,
|
|
3644
3659
|
fetchWalletFarmsWithRewards,
|
|
3645
3660
|
estimateRewardScore,
|
|
3646
3661
|
estimateRewardScoresBatch,
|
|
3662
|
+
calculateMiningScoresBatch,
|
|
3647
3663
|
};
|
|
3648
3664
|
}
|
|
3649
3665
|
|
|
3650
3666
|
export { ControlRouter as C, DECIMALS_BY_TOKEN as D, FarmsRouter as F, GLOW_WEIGHT_DECIMAL_PRECISION as G, HUB_URL as H, KickstarterRouter as K, MAX_WEIGHT as M, OFF_CHAIN_PAYMENT_CURRENCIES as O, PAYMENT_CURRENCIES as P, RegionRouter as R, STAKING_DIRECTIONS as S, TRANSFER_TYPES as T, USDG_WEIGHT_DECIMAL_PRECISION as U, WalletsRouter as W, useOffchainFractions as a, REGIONS as b, KICKSTARTER_STATUS as c, ForwarderError as d, OffchainFractionsError as e, allRegions as f, usStates as g, countries as h, FORWARDER_ABI as i, OFFCHAIN_FRACTIONS_ABI as j, getAddresses as k, GCA_URLS as l, regionMetadata as r, useForwarder as u };
|
|
3651
|
-
//# sourceMappingURL=farms-router-
|
|
3667
|
+
//# sourceMappingURL=farms-router-DqPqj03h.js.map
|