@devprotocol/dev-kit
Advanced tools
Comparing version 7.2.0 to 7.3.0
@@ -92,2 +92,13 @@ import { BaseProvider } from '@ethersproject/providers'; | ||
type Asset = { | ||
readonly market: string; | ||
readonly marketSlug?: string; | ||
readonly id: string; | ||
}; | ||
type PropertiesAssets = (options: { | ||
readonly provider: BaseProvider; | ||
readonly destination: string; | ||
}) => Promise<UndefinedOr<readonly Asset[]>>; | ||
declare const propertiesAssets: PropertiesAssets; | ||
type DevContract$1 = { | ||
@@ -409,2 +420,2 @@ readonly totalSupply: () => Promise<string>; | ||
export { clientsDev, clientsLockup, clientsMarketFactory, clientsMetricsFactory, clientsPolicy, clientsProperty, clientsPropertyFactory, clientsRegistry, clientsSTokens, clientsUtilsSwapForStake, estimationsAPY, positionsCreate, positionsCreateWithEth$1 as positionsCreateWithEth, positionsCreateWithEth as positionsCreateWithEthForPolygon }; | ||
export { clientsDev, clientsLockup, clientsMarketFactory, clientsMetricsFactory, clientsPolicy, clientsProperty, clientsPropertyFactory, clientsRegistry, clientsSTokens, clientsUtilsSwapForStake, estimationsAPY, positionsCreate, positionsCreateWithEth$1 as positionsCreateWithEth, positionsCreateWithEth as positionsCreateWithEthForPolygon, propertiesAssets }; |
@@ -1140,2 +1140,13 @@ import { BaseProvider } from '@ethersproject/providers'; | ||
type Asset = { | ||
readonly market: string; | ||
readonly marketSlug?: string; | ||
readonly id: string; | ||
}; | ||
type PropertiesAssets = (options: { | ||
readonly provider: BaseProvider; | ||
readonly destination: string; | ||
}) => Promise<UndefinedOr<readonly Asset[]>>; | ||
declare const propertiesAssets: PropertiesAssets; | ||
type Erc20Contract = { | ||
@@ -1320,2 +1331,2 @@ readonly totalSupply: () => Promise<string>; | ||
export { ContractFactory, CreateAllocatorContract, CreateDevkitContract, CreateMarketBehaviorContract, CreateMarketContract, CreateMetricsContract, CreateMetricsGroupContract, CreatePolicyFactoryContract, CreatePolicyGroupContract, CreatePropertyContract, CreateRegistryContract, DevContract$1 as DevContract, DevkitClient, DevkitContract, DevkitUtils, Erc20Contract, LockupContract$1 as LockupContract, MarketFactoryContract$1 as MarketFactoryContract, PolicyContract$1 as PolicyContract, PolicyFactoryContract, PolicyGroupContract, Positions, PropertyContract$1 as PropertyContract, PropertyFactoryContract$1 as PropertyFactoryContract, RegistryContract$1 as RegistryContract, STokensContract, SwapContract, WithdrawContract, addressConfigAbi, addresses, allocatorAbi, client, clientsDev, clientsLockup, clientsMarketFactory, clientsMetricsFactory, clientsPolicy, clientsProperty, clientsPropertyFactory, clientsRegistry, clientsSTokens, clientsUtilsSwapForStake, contractFactory, createAllocatorContract, createDevContract, createDevkitContract, createErc20Contract, createLockupContract, createMarketBehaviorContract, createMarketContract, createMarketFactoryContract, createMetricsContract, createMetricsGroupContract, createPolicyContract, createPolicyFactoryContract, createPolicyGroupContract, createPropertyContract, createPropertyFactoryContract, createRegistryContract, createSTokensContract, createSwapContract, createWithdrawContract, devAbi, estimationsAPY, lockupAbi, marketAbi, marketAddresses, marketBehaviorAbi, marketFactoryAbi, metricsAbi, metricsFactoryAbi, metricsGroupAbi, policyAbi, policyFactoryAbi, policyGroupAbi, positionsCreate, positionsCreateWithEth$1 as positionsCreateWithEth, positionsCreateWithEth as positionsCreateWithEthForPolygon, propertyAbi, propertyFactoryAbi, sTokensAbi, utils, withdrawAbi }; | ||
export { ContractFactory, CreateAllocatorContract, CreateDevkitContract, CreateMarketBehaviorContract, CreateMarketContract, CreateMetricsContract, CreateMetricsGroupContract, CreatePolicyFactoryContract, CreatePolicyGroupContract, CreatePropertyContract, CreateRegistryContract, DevContract$1 as DevContract, DevkitClient, DevkitContract, DevkitUtils, Erc20Contract, LockupContract$1 as LockupContract, MarketFactoryContract$1 as MarketFactoryContract, PolicyContract$1 as PolicyContract, PolicyFactoryContract, PolicyGroupContract, Positions, PropertyContract$1 as PropertyContract, PropertyFactoryContract$1 as PropertyFactoryContract, RegistryContract$1 as RegistryContract, STokensContract, SwapContract, WithdrawContract, addressConfigAbi, addresses, allocatorAbi, client, clientsDev, clientsLockup, clientsMarketFactory, clientsMetricsFactory, clientsPolicy, clientsProperty, clientsPropertyFactory, clientsRegistry, clientsSTokens, clientsUtilsSwapForStake, contractFactory, createAllocatorContract, createDevContract, createDevkitContract, createErc20Contract, createLockupContract, createMarketBehaviorContract, createMarketContract, createMarketFactoryContract, createMetricsContract, createMetricsGroupContract, createPolicyContract, createPolicyFactoryContract, createPolicyGroupContract, createPropertyContract, createPropertyFactoryContract, createRegistryContract, createSTokensContract, createSwapContract, createWithdrawContract, devAbi, estimationsAPY, lockupAbi, marketAbi, marketAddresses, marketBehaviorAbi, marketFactoryAbi, metricsAbi, metricsFactoryAbi, metricsGroupAbi, policyAbi, policyFactoryAbi, policyGroupAbi, positionsCreate, positionsCreateWithEth$1 as positionsCreateWithEth, positionsCreateWithEth as positionsCreateWithEthForPolygon, propertiesAssets, propertyAbi, propertyFactoryAbi, sTokensAbi, utils, withdrawAbi }; |
@@ -5,2 +5,3 @@ export { positionsCreate } from './positionsCreate' | ||
export { estimationsAPY } from './estimationsAPY' | ||
export { propertiesAssets } from './propertiesAssets' | ||
@@ -7,0 +8,0 @@ export { clientsDev } from './common/clients/clientsDev' |
import type { BaseProvider } from '@ethersproject/providers' | ||
import { UndefinedOr } from '@devprotocol/util-ts' | ||
import { UndefinedOr, whenDefined } from '@devprotocol/util-ts' | ||
import { clientsMetricsFactory } from './common/clients/clientsMetricsFactory' | ||
import { createMetricsContract } from '../ethereum/metrics' | ||
import { createMarketContract } from '../ethereum/market' | ||
import { createMarketBehaviorContract } from '../ethereum/market-behavior' | ||
import { flatten, toPairs, unnest, values } from 'ramda' | ||
import { marketAddresses } from '../marketAddresses' | ||
@@ -14,1 +20,50 @@ type Asset = { | ||
}) => Promise<UndefinedOr<readonly Asset[]>> | ||
export const propertiesAssets: PropertiesAssets = async (options) => { | ||
const marketSet = unnest( | ||
flatten(values(marketAddresses).map(values)).map(toPairs) | ||
) as ReadonlyArray<readonly [string, string]> | ||
const [, metricsFactory] = await clientsMetricsFactory(options.provider) | ||
const metricsContract = createMetricsContract(options.provider) | ||
const marketContract = createMarketContract(options.provider) | ||
const marketBehaviorContract = createMarketBehaviorContract(options.provider) | ||
const listOfMetrics = await whenDefined(metricsFactory, (c) => | ||
c.metricsOfProperty(options.destination) | ||
) | ||
const listOfMetricsContract = await whenDefined(listOfMetrics, (x) => | ||
Promise.all(x.map(metricsContract)) | ||
) | ||
const listOfMarketContract = await whenDefined(listOfMetricsContract, (m) => | ||
Promise.all( | ||
m.map(async (metrics) => ({ | ||
metrics, | ||
market: marketContract(await metrics.market()), | ||
})) | ||
) | ||
) | ||
const marketBehaviors = await whenDefined(listOfMarketContract, (m) => | ||
Promise.all( | ||
m.map(async (cont) => ({ | ||
marketBehavior: marketBehaviorContract(await cont.market.behavior()), | ||
...cont, | ||
})) | ||
) | ||
) | ||
const results = await whenDefined(marketBehaviors, (mb) => | ||
Promise.all( | ||
mb.map(async (cont) => { | ||
const metrics = cont.metrics.contract().address | ||
const market = cont.market.contract().address | ||
const marketSlug = marketSet.find(([, addr]) => addr === market)?.[0] | ||
return { | ||
id: await cont.marketBehavior.getId(metrics), | ||
market, | ||
marketSlug, | ||
} | ||
}) | ||
) | ||
) | ||
return results | ||
} |
{ | ||
"name": "@devprotocol/dev-kit", | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"description": "Dev Kit for JavaScript", | ||
@@ -52,4 +52,4 @@ "author": "abyssparanoia", | ||
"@types/ramda": "0.28.22", | ||
"@typescript-eslint/eslint-plugin": "5.50.0", | ||
"@typescript-eslint/parser": "5.50.0", | ||
"@typescript-eslint/eslint-plugin": "5.51.0", | ||
"@typescript-eslint/parser": "5.51.0", | ||
"eslint": "8.33.0", | ||
@@ -61,7 +61,7 @@ "eslint-config-prettier": "8.6.0", | ||
"husky": "8.0.3", | ||
"jest": "29.4.1", | ||
"lint-staged": "13.1.0", | ||
"jest": "29.4.2", | ||
"lint-staged": "13.1.1", | ||
"npm-run-all": "4.1.5", | ||
"pre-commit": "1.2.2", | ||
"prettier": "2.8.3", | ||
"prettier": "2.8.4", | ||
"rimraf": "4.1.2", | ||
@@ -68,0 +68,0 @@ "rollup": "2.79.1", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2122953
79272