-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch pair config #67
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
752e747
Merge pull request #66 from securesecrets/develop
AustinWoetzel 6792ca9
feat: batch pair config
DrPresident 915f904
feat: added function heading comments
DrPresident 9b246b0
feat: changeset
DrPresident 3cead3a
fix: dao fee parse bug, add docs and tests
AustinWoetzel acb3cff
terminology change
AustinWoetzel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@shadeprotocol/shadejs": patch | ||
--- | ||
|
||
Batch Pair Config Queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import { | |
} from '~/types/contracts/swap/response'; | ||
import { | ||
BatchPairsInfo, | ||
BatchPairsConfig, | ||
BatchStakingInfo, | ||
FactoryConfig, | ||
FactoryPairs, | ||
|
@@ -148,7 +149,7 @@ function parsePairConfig(response: PairConfigResponse): PairConfig { | |
isStable: pair[2], | ||
fee: customFee ? { | ||
lpFee: customFee.lp_fee.nom / customFee.lp_fee.denom, | ||
daoFee: customFee.lp_fee.nom / customFee.lp_fee.denom, | ||
daoFee: customFee.shade_dao_fee.nom / customFee.shade_dao_fee.denom, | ||
} : null, | ||
}; | ||
} | ||
|
@@ -233,6 +234,16 @@ const parseBatchQueryPairInfoResponse = ( | |
pairInfo: parsePairInfo(item.response), | ||
})); | ||
|
||
/** | ||
* parses the pair config response from a batch query of | ||
* multiple pair contracts | ||
*/ | ||
const parseBatchQueryPairConfigResponse = ( | ||
response: BatchQueryParsedResponse, | ||
): BatchPairsConfig => response.map((item) => ({ | ||
pairContractAddress: item.id as string, | ||
pairConfig: parsePairConfig(item.response), | ||
})); | ||
/** | ||
* parses the single staking info response | ||
*/ | ||
|
@@ -487,7 +498,7 @@ async function queryPairConfig({ | |
} | ||
|
||
/** | ||
* query the pair info for multiple pools at one time | ||
* query the info for multiple pairs at one time | ||
*/ | ||
function batchQueryPairsInfo$({ | ||
queryRouterContractAddress, | ||
|
@@ -523,7 +534,7 @@ function batchQueryPairsInfo$({ | |
} | ||
|
||
/** | ||
* query the pair info for multiple pools at one time | ||
* query the info for multiple pairs at one time | ||
*/ | ||
async function batchQueryPairsInfo({ | ||
queryRouterContractAddress, | ||
|
@@ -547,6 +558,67 @@ async function batchQueryPairsInfo({ | |
})); | ||
} | ||
|
||
/** | ||
* query the config for multiple pairs at one time | ||
*/ | ||
function batchQueryPairsConfig$({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment |
||
queryRouterContractAddress, | ||
queryRouterCodeHash, | ||
lcdEndpoint, | ||
chainId, | ||
pairsContracts, | ||
}:{ | ||
queryRouterContractAddress: string, | ||
queryRouterCodeHash?: string, | ||
lcdEndpoint?: string, | ||
chainId?: string, | ||
pairsContracts: Contract[] | ||
}) { | ||
const queries:BatchQuery[] = pairsContracts.map((contract) => ({ | ||
id: contract.address, | ||
contract: { | ||
address: contract.address, | ||
codeHash: contract.codeHash, | ||
}, | ||
queryMsg: msgQueryPairConfig(), | ||
})); | ||
return batchQuery$({ | ||
contractAddress: queryRouterContractAddress, | ||
codeHash: queryRouterCodeHash, | ||
lcdEndpoint, | ||
chainId, | ||
queries, | ||
}).pipe( | ||
map(parseBatchQueryPairConfigResponse), | ||
first(), | ||
); | ||
} | ||
|
||
/** | ||
* query the config for multiple pairs at one time | ||
*/ | ||
async function batchQueryPairsConfig({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment |
||
queryRouterContractAddress, | ||
queryRouterCodeHash, | ||
lcdEndpoint, | ||
chainId, | ||
pairsContracts, | ||
}:{ | ||
queryRouterContractAddress: string, | ||
queryRouterCodeHash?: string, | ||
lcdEndpoint?: string, | ||
chainId?: string, | ||
pairsContracts: Contract[] | ||
}) { | ||
return lastValueFrom(batchQueryPairsConfig$({ | ||
queryRouterContractAddress, | ||
queryRouterCodeHash, | ||
lcdEndpoint, | ||
chainId, | ||
pairsContracts, | ||
})); | ||
} | ||
|
||
/** | ||
* query the staking info for multiple staking contracts at one time | ||
*/ | ||
|
@@ -622,9 +694,12 @@ export { | |
queryPairConfig, | ||
batchQueryPairsInfo$, | ||
batchQueryPairsInfo, | ||
batchQueryPairsConfig$, | ||
batchQueryPairsConfig, | ||
batchQueryStakingInfo$, | ||
batchQueryStakingInfo, | ||
parseSwapResponse, | ||
parseBatchQueryPairInfoResponse, | ||
parseBatchQueryStakingInfoResponse, | ||
parseBatchQueryPairConfigResponse, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment above the function explaining what it does