forked from solana-labs/solana-program-library
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Oracleless ctoken mint and redeem #69
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ async fn test_success() { | |
|
||
const SOL_DEPOSIT_AMOUNT_LAMPORTS: u64 = 10 * LAMPORTS_TO_SOL * INITIAL_COLLATERAL_RATIO; | ||
const SOL_RESERVE_COLLATERAL_LAMPORTS: u64 = 2 * SOL_DEPOSIT_AMOUNT_LAMPORTS; | ||
const SOL_BORROWED_AMOUNT_LAMPORTS: u64 = SOL_DEPOSIT_AMOUNT_LAMPORTS; | ||
|
||
let user_accounts_owner = Keypair::new(); | ||
let user_transfer_authority = Keypair::new(); | ||
|
@@ -45,6 +46,7 @@ async fn test_success() { | |
liquidity_amount: SOL_RESERVE_COLLATERAL_LAMPORTS, | ||
liquidity_mint_decimals: 9, | ||
liquidity_mint_pubkey: spl_token::native_mint::id(), | ||
borrow_amount: SOL_BORROWED_AMOUNT_LAMPORTS, | ||
config: test_reserve_config(), | ||
mark_fresh: true, | ||
..AddReserveArgs::default() | ||
|
@@ -58,14 +60,24 @@ async fn test_success() { | |
AddObligationArgs::default(), | ||
); | ||
|
||
let (mut banks_client, payer, recent_blockhash) = test.start().await; | ||
let mut test_context = test.start_with_context().await; | ||
test_context.warp_to_slot(300).unwrap(); // clock.slot = 300 | ||
|
||
let ProgramTestContext { | ||
mut banks_client, | ||
payer, | ||
last_blockhash: recent_blockhash, | ||
.. | ||
} = test_context; | ||
|
||
test_obligation.validate_state(&mut banks_client).await; | ||
|
||
let initial_collateral_supply_balance = | ||
get_token_balance(&mut banks_client, sol_test_reserve.collateral_supply_pubkey).await; | ||
let initial_user_collateral_balance = | ||
get_token_balance(&mut banks_client, sol_test_reserve.user_collateral_pubkey).await; | ||
let pre_sol_reserve = sol_test_reserve.get_state(&mut banks_client).await; | ||
let old_borrow_rate = pre_sol_reserve.liquidity.cumulative_borrow_rate_wads; | ||
|
||
let mut transaction = Transaction::new_with_payer( | ||
&[ | ||
|
@@ -99,6 +111,9 @@ async fn test_success() { | |
); | ||
assert!(banks_client.process_transaction(transaction).await.is_ok()); | ||
|
||
let sol_reserve = sol_test_reserve.get_state(&mut banks_client).await; | ||
assert_eq!(sol_reserve.last_update.stale, true); | ||
|
||
// check that collateral tokens were transferred | ||
let collateral_supply_balance = | ||
get_token_balance(&mut banks_client, sol_test_reserve.collateral_supply_pubkey).await; | ||
|
@@ -112,4 +127,6 @@ async fn test_success() { | |
user_collateral_balance, | ||
initial_user_collateral_balance - SOL_DEPOSIT_AMOUNT_LAMPORTS | ||
); | ||
|
||
assert!(sol_reserve.liquidity.cumulative_borrow_rate_wads > old_borrow_rate); | ||
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. 👍 |
||
} |
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
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
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.
Nit: Do we need to make the same comment change for
RedeemReserveCollateral
given it no longer needs to be refreshed?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.
ah yeh prob should change comment (the reserve over there was alright writable so just removing the "refreshed"