Skip to content
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

token-swap: Add constraint to swap instruction to prevent too much slippage #87

Closed
jstarry opened this issue Jul 7, 2020 · 0 comments · Fixed by #560
Closed

token-swap: Add constraint to swap instruction to prevent too much slippage #87

jstarry opened this issue Jul 7, 2020 · 0 comments · Fixed by #560

Comments

@jstarry
Copy link
Member

jstarry commented Jul 7, 2020

Problem

Users don't have any guarantee that the token ratio they submit a swap at will be the same as what is executed on-chain

Proposed Changes

  • Add a min output to swap instruction
@joncinque joncinque changed the title Add constraint to swap instruction to prevent too much slippage token-swap: Add constraint to swap instruction to prevent too much slippage Aug 25, 2020
codewithgun pushed a commit to MeteoraAg/solana-program-library that referenced this issue Apr 11, 2023
Issue: As in description `WithdrawObligationCollateralAndRedeemReserveCollateral` combines `WithdrawObligationCollateral` and `RedeemReserveCollateral`. While `obligation_owner` in `WithdrawObligationCollateral` is readonly, it is writable in `WithdrawObligationCollateralAndRedeemReserveCollateral` is writable. 

Solution: Update `obligation_owner` readonly in `WithdrawObligationCollateralAndRedeemReserveCollateral`
codewithgun added a commit to MeteoraAg/solana-program-library that referenced this issue Apr 11, 2023
* allow loan_to_value_ratio == liquidation_threshold (solana-labs#85)

* high rate map (solana-labs#86)

* high rate map

* prop test exception

* adding more high rate cases

* fix to support higher exponent for switchboard v2 (solana-labs#90)

* trying take rate other way (solana-labs#89)

* started take rate

cleaning up all the boilerplate adding reserve config take rate

claim fees

config check + fixing/adding tests

fix comment in instruction.rs

fixed tests for native token and added pr feedback

properly keeping track of availible amount when redeeming fees

add in fees when compounding

try other method

* change to accumulating and redeem when can also added staleness checks

* fixed tests

* cleanup

* sliding down borrow limit and 1 percent close factor (solana-labs#91)

* sliding down borrow limit and 1 percent close factor

* fix tests

* final dates set

* only redeem as much collateral as liquidity allows during liquidate (solana-labs#88)

* only redeem as much collateral as liquidity allows

* added test for where not enough liquidity to fully redeem and liquidation

* ignore redeem if no collateral to withdraw

* rebase and fix tests

* undo borrow limit and close factor change and cap liquidation amount (solana-labs#92)

* undo borrow limit and close factor change, but keep caps on borrow limits

* fml changed the wrong variable

* add new liquidation value cap

* test coverage github action (solana-labs#94)

* test coverage github action

* move actions to another job

* moving stuff around

* grr

* artifact error

* try cobertura format with codecov

* add decimal test

* formatting

* tests for decimal

* rate tests

* format

* tests for calculate liquidation

* enable github actions on commits to upcoming branch (solana-labs#96)

* turn on liquidation fees and deprecate old liquidation instruction (solana-labs#100)

* turn on liquidation fees and deprecate old liquidation instruction

* fix tests

* clippy

* bump solana to 1.9.18 (solana-labs#97)

* bump t o 1.9.18

* Solve clippy warnings after bump update

* bump solana version in script

* fixing various warnings

* fix all clippy warnings in the tests

* fmt

Co-authored-by: Andrei Hrs <andrei_hristescu@yahoo.com>

* flash loans (solana-labs#95)

* copying kiplet's code

* make flash loans more conservative

* happy case test

* adding more tests, fixed a bug

* moar tests

* clippy lints

* fix assert

* remove clock

* remove old flash loan instruction, but keep the instruction packing code

* saner flash loan fee calculation

* add flash borrow ix arg to flash repay

* cargo fmt

* add cpi repay test

* bump compute units, no idea why github actions is failing

* test for malicious use case

* remove unused variable

* fix coverage, check reserve borrow limit in flash borrow

* mark reserves as stale in flash borrow and repay

* revert back to old nightly version, install grcov with stable

* fix for [repay, borrow, repay]

* refactor CPI

* recheck stuff in flash repay

* explicitly check for out of bounds in flash borrow loop

* 0xripleys remove clock (solana-labs#99)

* make clock sysvar optional

* remove clock from instructions

* add stack height check

* fmt

* bump cargo version (solana-labs#103)

* make cli update only update if actually changing something and add an… (solana-labs#101)

* make cli update only update if actually changing something and add anchor.toml

* fix clippy

* allow 0 ltv assets to be deposited + minor cleanup (solana-labs#104)

* Obligation_owner should be readonly (solana-labs#87)

Issue: As in description `WithdrawObligationCollateralAndRedeemReserveCollateral` combines `WithdrawObligationCollateral` and `RedeemReserveCollateral`. While `obligation_owner` in `WithdrawObligationCollateral` is readonly, it is writable in `WithdrawObligationCollateralAndRedeemReserveCollateral` is writable. 

Solution: Update `obligation_owner` readonly in `WithdrawObligationCollateralAndRedeemReserveCollateral`

* allow passing just pyth to save bytes (solana-labs#105)

* oallow passing just pyth to save bytes

* fixing to check that there is a next account and 1 other check

* use option instead

* added a test

* update debt limit (solana-labs#107)

* 0xripleys manual liquidate (solana-labs#112)

* kinda working cli liquidation

* dynamically create atas if they don't exist

* adding compute budget request

* fix clippy

* liquidate scripts

* withdraw ctokens command

* add redeem reserve collateral function

* fix cli for updating oracle (solana-labs#114)

* Use pyth sdk + tests (solana-labs#113)

* Create a crate, relax solana dependencies in crate (solana-labs#118)

* bump solana version to 1.14 (solana-labs#116)

* (rfc) bump solana version to 1.14

* fix build

* remove flag

* update solana version

* fix clippy

* fix clippy

* pin serde version

* Refactor and improve tests (solana-labs#121)

- use Reserve, LendingMarket, Obligation types directly instead of TestReserve, TestLendingMarket, TestObligation
- more helper functions
- check account state after every successful program call
- check _all_ token accounts and mint accounts after every successful program call

* changing util rate calc to exclude non-claimed fees (solana-labs#132)

* Solend v2.0.1 (solana-labs#131)

* 0xripleys outflow limits (solana-labs#125)

Use a sliding window rate limiter to limit borrows and withdraws at the lending pool owner's discretion.

* 0xripleys borrow coefficient (solana-labs#127)

Add a borrow weight to the Reserve

* Two Prices PR (solana-labs#129)

- Add a smoothed_market_price to Reserve that is used to limit borrows and withdraws in cases where smoothed price and spot price diverge.
- allowed_borrow_value now uses the min(smoothed_market_price, current spot price)
- new field on obligation called borrowed_value_upper_bound that uses max(smoothed_market_price, current spot price)

* audit nits

* audit fixes pt 2

* disable rate limiter if window duration == 0

* cli changes for v2.0.1 (solana-labs#133)

* div by zero fix (solana-labs#138)

* div by zero fix

* fmt

* use cur slot instead of 0

* fix for withdraw case (solana-labs#140)

---------

Co-authored-by: nope <83512286+nope-finance@users.noreply.github.com>
Co-authored-by: Nope X <nope@solend.fi>
Co-authored-by: 0xripleys <105607696+0xripleys@users.noreply.github.com>
Co-authored-by: Andrei Hrs <andrei_hristescu@yahoo.com>
Co-authored-by: andrewsource147 <31321699+andrewsource147@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant