@bancor/carbon-sdk
Advanced tools
Comparing version 0.0.79-DEV to 0.0.80-DEV
@@ -14,3 +14,2 @@ import { BigNumber } from '../utils/numerics'; | ||
pairs(): Promise<TokenPair[]>; | ||
private _strategiesByPairWithMulticall; | ||
strategiesByPair(token0: string, token1: string): Promise<EncodedStrategy[]>; | ||
@@ -17,0 +16,0 @@ tokensByOwner(owner: string): Promise<BigNumber[]>; |
@@ -336,2 +336,37 @@ import { D as Decimal, t as tenPow, k as formatUnits, p as parseUnits, B as BigNumber, m as mulDiv } from './numerics.js'; | ||
/** | ||
* Gets all the strategies that belong to the given pair | ||
* | ||
* If the cache is synced, it will return the strategies from the cache. | ||
* Otherwise, it will fetch the strategies from the chain. | ||
* | ||
* @param {string} token0 - Address of one of the tokens in the pair - the order is not important. | ||
* @param {string} token1 - Address of one of the tokens in the pair - the order is not important. | ||
*/ | ||
async getStrategiesByPair(token0, token1) { | ||
logger.debug('getStrategiesByPair called', arguments); | ||
let encodedStrategies; | ||
if (this._cache) { | ||
encodedStrategies = await this._cache.getStrategiesByPair(token0, token1); | ||
} | ||
if (encodedStrategies) { | ||
logger.debug('getStrategiesByPair fetched from cache'); | ||
} | ||
else { | ||
logger.debug('getStrategiesByPair fetching from chain'); | ||
encodedStrategies = await this._api.reader.strategiesByPair(token0, token1); | ||
} | ||
const decodedStrategies = encodedStrategies.map(decodeStrategy); | ||
const strategies = await Promise.all(decodedStrategies.map(async (strategy) => { | ||
return await parseStrategy(strategy, this._decimals); | ||
})); | ||
logger.debug('getStrategiesByPair info:', { | ||
token0, | ||
token1, | ||
encodedStrategies, | ||
decodedStrategies, | ||
strategies, | ||
}); | ||
return strategies; | ||
} | ||
/** | ||
* Gets the strategies that are owned by the user. | ||
@@ -338,0 +373,0 @@ * It does so by reading the voucher token and |
@@ -62,2 +62,12 @@ import { PopulatedTransaction } from '@ethersproject/contracts'; | ||
/** | ||
* Gets all the strategies that belong to the given pair | ||
* | ||
* If the cache is synced, it will return the strategies from the cache. | ||
* Otherwise, it will fetch the strategies from the chain. | ||
* | ||
* @param {string} token0 - Address of one of the tokens in the pair - the order is not important. | ||
* @param {string} token1 - Address of one of the tokens in the pair - the order is not important. | ||
*/ | ||
getStrategiesByPair(token0: string, token1: string): Promise<Strategy[]>; | ||
/** | ||
* Gets the strategies that are owned by the user. | ||
@@ -64,0 +74,0 @@ * It does so by reading the voucher token and |
@@ -5,3 +5,3 @@ { | ||
"source": "src/index.ts", | ||
"version": "0.0.79-DEV", | ||
"version": "0.0.80-DEV", | ||
"description": "The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfill trades", | ||
@@ -73,12 +73,12 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"@rollup/plugin-commonjs": "^25.0.3", | ||
"@rollup/plugin-node-resolve": "^15.0.2", | ||
"@typechain/ethers-v5": "^10.2.0", | ||
"@typechain/ethers-v5": "^10.2.1", | ||
"@types/chai": "^4.3.5", | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.16.3", | ||
"@types/sinon": "^10.0.14", | ||
"@types/sinon": "^10.0.15", | ||
"chai": "^4.3.7", | ||
"mocha": "^10.1.0", | ||
"rollup": "^3.21.4", | ||
"rollup": "^3.27.0", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
@@ -85,0 +85,0 @@ "sinon": "^15.0.4", |
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
1055208
24052