Multiple Collateral Types & Cross-Asset Operations Testing#165
Multiple Collateral Types & Cross-Asset Operations Testing#165UlyanaAndrukhiv merged 23 commits intomainfrom
Conversation
Co-authored-by: Jordan Schalm <jordan.schalm@gmail.com>
|
@Kay-Zee, could you please review this PR when you have a chance? Thank you! |
Kay-Zee
left a comment
There was a problem hiding this comment.
This is great! pretty much exactly what i was hoping for.
The later scenarios do get quite complicated, wonder if those might belong more as integration tests. But i think it's fine to keep here for now.
| transferFungibleTokens(tokenIdentifier: MAINNET_USDF_TOKEN_ID, from: MAINNET_USDF_HOLDER, to: usdfLp, amount: 1000.0) | ||
| createPosition(admin: MAINNET_PROTOCOL_ACCOUNT, signer: usdfLp, amount: 1000.0, vaultStoragePath: MAINNET_USDF_STORAGE_PATH, pushToDrawDownSink: false) | ||
|
|
||
| // WETH LP (0.05 WETH available) |
There was a problem hiding this comment.
i guess we're just using such small values since this is forked mainnet and we don't have that much sitting around in the test accounts? This probably isn't a big deal but yeah, if we did want to increase this i feel like there's probably ways for "add liquidity" to these tests. Anyway, maybe for another time, but if we do want to resolve this, let me know, just ping me the addresses and desired tokens/amounts.
There was a problem hiding this comment.
@Kay-Zee, yes, exactly - I am using small values because this is a forked mainnet, and the accounts are limited by what the largest holders have at that time. I aligned the amounts with the biggest available balances there. If needed, we can later extend this test and recalculate expected values (max borrow and position health) with bigger liquidity.
Would it be okay to merge this PR as is for now?
Closes: #148
Description
Adds comprehensive test coverage for positions using multiple collateral types and cross-asset borrowing.
Tests added (
fork_multi_collateral_position_test.cdc)test_multi_collateral_position—FLOW+USDF+WETHcollateral; weighted health calculation and max borrow capacitytest_cross_asset_flow_to_usdf_borrowing— depositFLOW, borrowUSDFtest_cross_asset_flow_usdf_weth_borrowing—FLOW→USDF→WETHchain; netting when borrowing same token held as collateraltest_cross_asset_chain— four-asset pathFLOW→USDF→WETH→WBTC, intermediate assets net to zerotest_multi_asset_uncorrelated_price_movements—FLOWprice +10%,USDFprice -5%,WETHprice +20% simultaneouslytest_multi_asset_partial_withdrawal— partial withdrawal from multi-asset position; verifies remaining balancestest_cross_collateral_borrowing_capacity— borrowing same token as collateral caps at credit amount; different token uses health-based formulatest_multi_asset_liquidation_collateral_selection— 3 collateral types + 2 debt types; liquidator selects which collateral to seizetest_multi_asset_complex_workflow— full lifecycle with price change and auto-rebalance; verifies exact MOET pushed to drawDownSink and health restored to target healthRefactoring
manualLiquidation,setupGenericVault,transferFungibleTokensand updatedcreatePosition,borrowFromPositiontest helperscreate_and_store_pool.cdctotests/transactions/folder cause pool setup depends on both mocks