Skip to content

Commit

Permalink
cleanup: cleanup: example programs
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Nov 8, 2023
1 parent 6ae2b44 commit faf317d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
6 changes: 3 additions & 3 deletions token-lending/program/tests/modify_reserve_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ async fn correct_owner_providing_wrong_lending_market_fails() {
new_config,
sol_test_reserve.pubkey,
other_lending_market.pubkey,
lending_market.owner.pubkey(), /* lending_market.owner ==
* other_lending_market.owner, defined by
* `add_lending_market` */
// lending_market.owner == other_lending_market.owner, defined by
// `add_lending_market`
lending_market.owner.pubkey(),
)],
Some(&payer.pubkey()),
);
Expand Down
35 changes: 20 additions & 15 deletions token-swap/program/src/curve/constant_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,21 +390,26 @@ mod tests {
.is_none()); // spot: 10 * 4m / 70b = 0

let tests: &[(u128, u128, u128, u128, u128)] = &[
(10, 4_000_000, 70_000_000_000, 10, 174_999), // spot: 10 * 70b / ~4m = 174,999.99
(20, 30_000 - 20, 10_000, 18, 6), /* spot: 20 * 1 / 3.000 = 6.6667
* (source can be 18
* to get 6 dest.) */
(19, 30_000 - 20, 10_000, 18, 6), /* spot: 19 * 1 / 2.999 = 6.3334 (source can be 18
* to get 6 dest.) */
(18, 30_000 - 20, 10_000, 18, 6), // spot: 18 * 1 / 2.999 = 6.0001
(10, 20_000, 30_000, 10, 14), // spot: 10 * 3 / 2.0010 = 14.99
(10, 20_000 - 9, 30_000, 10, 14), // spot: 10 * 3 / 2.0001 = 14.999
(10, 20_000 - 10, 30_000, 10, 15), // spot: 10 * 3 / 2.0000 = 15
(100, 60_000, 30_000, 99, 49), /* spot: 100 * 3 / 6.001 = 49.99 (source can be 99
* to get 49 dest.) */
(99, 60_000, 30_000, 99, 49), // spot: 99 * 3 / 6.001 = 49.49
(98, 60_000, 30_000, 97, 48), /* spot: 98 * 3 / 6.001 = 48.99 (source can be 97 to
* get 48 dest.) */
// spot: 10 * 70b / ~4m = 174,999.99
(10, 4_000_000, 70_000_000_000, 10, 174_999),
// spot: 20 * 1 / 3.000 = 6.6667 (source can be 18 to get 6 dest.)
(20, 30_000 - 20, 10_000, 18, 6),
// spot: 19 * 1 / 2.999 = 6.3334 (source can be 18 to get 6 dest.)
(19, 30_000 - 20, 10_000, 18, 6),
// spot: 18 * 1 / 2.999 = 6.0001
(18, 30_000 - 20, 10_000, 18, 6),
// spot: 10 * 3 / 2.0010 = 14.99
(10, 20_000, 30_000, 10, 14),
// spot: 10 * 3 / 2.0001 = 14.999
(10, 20_000 - 9, 30_000, 10, 14),
// spot: 10 * 3 / 2.0000 = 15
(10, 20_000 - 10, 30_000, 10, 15),
// spot: 100 * 3 / 6.001 = 49.99 (source can be 99 to get 49 dest.)
(100, 60_000, 30_000, 99, 49),
// spot: 99 * 3 / 6.001 = 49.49
(99, 60_000, 30_000, 99, 49),
// spot: 98 * 3 / 6.001 = 48.99 (source can be 97 to get 48 dest.)
(98, 60_000, 30_000, 97, 48),
];
for (
source_amount,
Expand Down
10 changes: 5 additions & 5 deletions token-swap/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ pub enum SwapInstruction {
DepositAllTokenTypes(DepositAllTokenTypes),

/// Withdraw both types of tokens from the pool at the current ratio,
/// given pool tokens. The pool tokens are burned in exchange for an
/// equivalent amount of token A and B.
/// given pool tokens. The pool tokens are burned in exchange for an
/// equivalent amount of token A and B.
///
/// 0. `[]` Token-swap
/// 1. `[]` swap authority
Expand All @@ -181,9 +181,9 @@ pub enum SwapInstruction {
/// 14. `[]` Token B program id
WithdrawAllTokenTypes(WithdrawAllTokenTypes),

/// Deposit one type of tokens into the pool. The output is a "pool"
/// token representing ownership into the pool. Input token is
/// converted as if a swap and deposit all token types were performed.
/// Deposit one type of tokens into the pool. The output is a "pool"
/// token representing ownership into the pool. Input token is
/// converted as if a swap and deposit all token types were performed.
///
/// 0. `[]` Token-swap
/// 1. `[]` swap authority
Expand Down

0 comments on commit faf317d

Please sign in to comment.