-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support recurring swaps in QuarkBuilder #65
Conversation
24d4434
to
e94f6ae
Compare
return balanceOnChain; | ||
} | ||
|
||
function getAmountNeededOnChain( | ||
string memory assetSymbol, | ||
uint256 amount, | ||
uint256 chainId, | ||
PaymentInfo.Payment memory payment | ||
) internal pure returns (uint256) { | ||
// If action is paid for with tokens and the payment token is the transfer token, then add the payment max cost for the target chain to the amount needed | ||
uint256 amountNeededOnChain = amount; | ||
if (payment.isToken && Strings.stringEqIgnoreCase(payment.currency, assetSymbol)) { | ||
amountNeededOnChain += PaymentInfo.findMaxCost(payment, chainId); | ||
} | ||
|
||
return amountNeededOnChain; | ||
} | ||
|
||
function needsBridgedFunds( | ||
string memory assetSymbol, | ||
uint256 amount, | ||
uint256 chainId, | ||
Accounts.ChainAccounts[] memory chainAccountsList, | ||
PaymentInfo.Payment memory payment | ||
) internal pure returns (bool) { | ||
uint256 balanceOnChain = getBalanceOnChain(assetSymbol, chainId, chainAccountsList, payment); | ||
uint256 amountNeededOnChain = getAmountNeededOnChain(assetSymbol, amount, chainId, payment); | ||
|
||
return balanceOnChain < amountNeededOnChain; |
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.
These diffs are just pulling out the logic in needsBridgedFunds
into two separate helper functions.
e94f6ae
to
dba1bcd
Compare
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.
Looks good ✅
|
||
// Mainnet | ||
function knownPriceFeeds_1() internal pure returns (PriceFeed[] memory) { | ||
PriceFeed[] memory priceFeeds = new PriceFeed[](4); |
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.
Do we plan to add every price feed for all supported tokens here?
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.
Yeah, we'll have to hardcode all the price feeds for tokens we care about. 🧇 is working on a crawler that will output a Solidity config file that will replace this file.
dba1bcd
to
9d7c5e1
Compare
b0d0e0f
to
d073399
Compare
This implements the QuarkBuilder logic to construct Quark Operations for recurring swaps. We introduce a few new libraries that hardcode some addresses:
PriceFeeds.sol
andUniswapRouter.sol
.