Skip to content

Commit

Permalink
Make execute_retry function permissionless and adjust tests according…
Browse files Browse the repository at this point in the history
…ly (#429)

Co-authored-by: nahem <[email protected]>
  • Loading branch information
magiodev and nseguias authored Sep 4, 2023
1 parent 2d493a9 commit 0c93807
Show file tree
Hide file tree
Showing 36 changed files with 1,272 additions and 212 deletions.
201 changes: 201 additions & 0 deletions smart-contracts/contracts/cl-vault/src/test_tube/cl_proptests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#[cfg(test)]
mod tests {
use cosmwasm_std::{Coin, Decimal, Uint128};
use cw_vault_multi_standard::VaultInfoResponse;
use osmosis_std::types::osmosis::{
concentratedliquidity::v1beta1::{Pool, PoolsRequest},
tokenfactory::v1beta1::QueryDenomsFromCreatorRequest,
};
use osmosis_test_tube::{
cosmrs::proto::traits::Message, Account, ConcentratedLiquidity, Module, TokenFactory, Wasm,
};

use crate::{
msg::{ClQueryMsg, ExecuteMsg, ExtensionQueryMsg, ModifyRangeMsg, QueryMsg},
query::{PoolResponse, UserBalanceResponse},
test_tube::default_init,
};

#[test]
#[ignore]
fn multiple_deposit_withdraw_works() {
let (app, contract_address, _cl_pool_id, _admin) = default_init();
let alice = app
.init_account(&[
Coin::new(1_000_000_000_000, "uatom"),
Coin::new(1_000_000_000_000, "uosmo"),
])
.unwrap();

let wasm = Wasm::new(&app);

let _ = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::ExactDeposit { recipient: None },
&[Coin::new(5_000, "uatom"), Coin::new(5_000, "uosmo")],
&alice,
)
.unwrap();

let _ = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::ExactDeposit { recipient: None },
&[Coin::new(5_000, "uatom"), Coin::new(5_000, "uosmo")],
&alice,
)
.unwrap();

let _ = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::ExactDeposit { recipient: None },
&[Coin::new(5_000, "uatom"), Coin::new(5_000, "uosmo")],
&alice,
)
.unwrap();

let shares: UserBalanceResponse = wasm
.query(
contract_address.as_str(),
&QueryMsg::VaultExtension(ExtensionQueryMsg::Balances(
crate::msg::UserBalanceQueryMsg::UserLockedBalance {
user: alice.address(),
},
)),
)
.unwrap();
assert!(!shares.balance.is_zero());

let _withdraw = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::Redeem {
recipient: None,
amount: shares.balance,
},
&[],
&alice,
)
.unwrap();
// verify the correct execution
}

#[test]
#[ignore]
fn single_deposit_withdraw_works() {
let (app, contract_address, _cl_pool_id, _admin) = default_init();
let alice = app
.init_account(&[
Coin::new(1_000_000_000_000, "uatom"),
Coin::new(1_000_000_000_000, "uosmo"),
])
.unwrap();

let wasm = Wasm::new(&app);

let deposit = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::ExactDeposit { recipient: None },
&[Coin::new(5_000, "uatom"), Coin::new(5_000, "uosmo")],
&alice,
)
.unwrap();

let _mint = deposit.events.iter().find(|e| e.ty == "tf_mint").unwrap();

let shares: UserBalanceResponse = wasm
.query(
contract_address.as_str(),
&QueryMsg::VaultExtension(ExtensionQueryMsg::Balances(
crate::msg::UserBalanceQueryMsg::UserLockedBalance {
user: alice.address(),
},
)),
)
.unwrap();
assert!(!shares.balance.is_zero());

let _withdraw = wasm
.execute(
contract_address.as_str(),
&ExecuteMsg::Redeem {
recipient: None,
amount: shares.balance,
},
&[],
&alice,
)
.unwrap();
// verify the correct execution
}

// #[test]
// #[ignore]
fn move_range_works() {
let (app, contract, _cl_pool_id, admin) = default_init();
let _alice = app
.init_account(&[
Coin::new(1_000_000_000_000, "uatom"),
Coin::new(1_000_000_000_000, "uosmo"),
])
.unwrap();

let wasm = Wasm::new(&app);
let _result = wasm
.execute(
contract.as_str(),
&ExecuteMsg::VaultExtension(crate::msg::ExtensionExecuteMsg::ModifyRange(
ModifyRangeMsg {
lower_price: Uint128::new(2),
upper_price: Uint128::new(200),
max_slippage: Decimal::permille(5),
},
)),
&[],
&admin,
)
.unwrap();
}

#[test]
#[ignore]
fn default_init_works() {
let (app, contract_address, _cl_pool_id, _admin) = default_init();
let wasm = Wasm::new(&app);
let cl = ConcentratedLiquidity::new(&app);
let tf = TokenFactory::new(&app);

let pools = cl.query_pools(&PoolsRequest { pagination: None }).unwrap();
let pool = Pool::decode(pools.pools[0].value.as_slice()).unwrap();

let resp = wasm
.query::<QueryMsg, PoolResponse>(
contract_address.as_str(),
&QueryMsg::VaultExtension(ExtensionQueryMsg::ConcentratedLiquidity(
ClQueryMsg::Pool {},
)),
)
.unwrap();

assert_eq!(resp.pool_config.pool_id, pool.id);
assert_eq!(resp.pool_config.token0, pool.token0);
assert_eq!(resp.pool_config.token1, pool.token1);

let resp = wasm
.query::<QueryMsg, VaultInfoResponse>(contract_address.as_str(), &QueryMsg::Info {})
.unwrap();

assert_eq!(resp.tokens, vec![pool.token0, pool.token1]);
assert_eq!(
resp.vault_token,
tf.query_denoms_from_creator(&QueryDenomsFromCreatorRequest {
creator: contract_address.to_string()
})
.unwrap()
.denoms[0]
);
}
}
4 changes: 2 additions & 2 deletions smart-contracts/contracts/lp-strategy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

### Features

- Added retry entry point to handle exit pool errors
- Added retry entry point to handle join pool errors
- Added permission-less retry entrypoint to handle exit pool errors
- Added permission-less retry entrypoint to handle join pool errors

### Bugfixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
cc 18cce7ef7418ba2e32c0dc974cce3839ed3afdd23c44eeff10c7cd502b664e52 # shrinks to (claim_amount, raw_amount, owner, bond_id) = ([0, 0, 0, 0, 0, 0, 0, 0, 11673845048084930547460394097995684, 38681151403059791997234025049684207626, 275054852874891480362198002940302056891, 248004106615233309637537480600637151515, 12165567352195846609387282639635621409, 260605945814629129877776296832005137162, 332498733738228587954824791897661214933, 220466759761543005181347682445321394851, 276955038478825658651724087112112977189, 327002931333860120384022494611419106764, 147064090442518249001596779703329850197, 39564122707571826747255339378284677948, 17245431880610274106465508916866826111, 26339003119474933218657724991629946399, 82276117695411068556044142010840638542, 295008677415348915376590468404000416830, 151554982649645368787246484795119526682, 180975261261844223519603233989024384027, 168751969190378588139721758050330892898, 131638036830868649013316482547580628713, 220442041130371752953825283455113893493, 65440179817723704813041205675233168717, 302341085874258666373729283438827979429, 59484899708101852479526669734567026566, 167625816230803446734600484639624676839, 223247288265999841840523557165498328548, 271205220985832846755417320083279796734, 188428825985446459356920011698020643141, 55914548276615285259550848482812446934, 102195989075020376935386609445353607918, 121781350805295556121749379931595727418, 49381516483748229739304062049605408686, 329483797478926557991409582759842888536, 25050877269533561643188662513251020289, 184084971816401394199792095345498654512, 314553285012672846226294513049818847532, 118214012495816784551227736304553654376, 331325951165181232595902138691158403353, 229895801368881505703484862144444531032, 217114635620378362608851676834552215349, 159876936511935302157126642045367287856, 135181955021589654255626347995453150573], [227365969172255363624507819951096565724, 301233924106392053527349799565535715008, 215189084033479621725931318636708931919, 269766051904425953113532064070452847870, 61626890029710227563630958944174916236, 121643162891773300986476522338839386555, 157890849575919296860121842741320755656, 318428887894696259998226374343390699537, 150429733389995246829353939053231673536, 1309984178131570546375402682674361514, 288596204117498775793769566300644324747, 221239221463166352388729594400491553656, 148978909380753273521137273830591697007, 275538702349313158916849577919121729747, 163713187093681229043970290243259360890, 151924563830510961661700273092653868361, 148155351515033332222116696976228855043, 23040063650194206500661391710955447418, 13976091836981510172184743689715944696, 185666796634122241421163204703768333325, 31949197993783774617668624979640684182, 44236163852815662641567703574148698704, 47478877286618988935887578375249136659, 70426128900427005954075445206391113470, 140906409014291614293719794814848067102, 107269575146883060322539137018471008849, 296995157204714311405805419068824989229, 161750435276928235606415971917746751228, 130756986618466217781348998859419151606, 105073686713080197476347255702114582082, 129373854793859197217362919487938017347, 285793942650403489640653646346783262704, 176448516216785083528112658599394780511, 200568359946301769234774760267636045793, 27117563929292709236084290248168245624, 132398191031838449046483348706831060869, 57516945481821405412092628600363321519, 197427381802548279413420705792351222501, 222846337535771089032432325957371072165, 79516707543765823940780266761219013517, 332746313329984099982163571762137691017, 297346398595796224323092462643166162137, 337071417935433974216532431467712569575, 41085095792457838701721359791557450918, 702470706316076453758134797401550118, 100190323026370930887276274578630211218, 54132925651950671821377657598243746105, 160055808294617960457289618967505797919, 112719553546396289399469348203275740183, 242448663799866037822921626508547285315], ["pelxgcgce", "eypufagrnmxaahmtwbz", "cksckqcgu", "johwpajdhxxdilpdqrskizhddv", "ecdyivkeowdhfpw", "ueuajshhjamecwhwunb", "ytwfxzlqv", "hbbmwqnofuhemyeziytmbdf", "ygqznvztityjg", "ntflh", "mivqrepqpwb", "gdvidjpuxwlrrqbr", "xjarmvwsgdwvwbblsooirfpcc", "zepkhzdkhvuakrhxsevrtdmbethihul", "ifrbn", "mersihvlcbvl", "ofyoghkarnxgpkorimi", "drdnbwlazpjrnmjpsksn", "mlppcbqtffsanomjokhth", "rxvlxdmxxlhckfklgd", "abf", "xltocqunoj", "ivsethz", "nzxsbgopozgqdxdmjmahmlglzwppoqg", "tkfsavgckbbzenoy", "sszuzdirsyfcwqogzhcnoaku", "rqnynflkonzpf", "kxlbd", "sylpzasamyg", "arbxqxavnptpewgb", "zovsuusznqywcnmqjppgzhwlcl", "pvjqbwupe", "xlnxdjtvxpd", "", "xbdygipeqfbazl", "j", "mdxudvywbvbfxkhnq", "ijrbpwsmvhzksyztnbqctyfqoiwkcy", "dqthiwptekttiplbhttgiuj", "twqkimydeuvacaelnklsxsbavmobuiqk", "qixstkpwyugrfwxsgohjpvtaa", "rvsiw", "ghwgcnggijoyapcaadxjk", "vkjv", "icpqzohhbpiywrdonllmzadjmffin", "ridgzcfb", "xbeunufvpqzytneqr", "cgoazeqiogbsv", "pprfeonetfysfbylr", "w"], [245156543980833747090242765144329311038, 194567896024102730141520967076722737253, 78321590831082444086273322095061857666, 46234274478596011116062623468273869668, 263465158450098859717724367516067905975, 100752541069266103352244815706779144613, 246329798443977159630785364311541203165, 89071066193382807867647247777458784703, 89680324833787488426590379191240982648, 326751368326903363754619742229709084471, 81949509939543357493869595004811069397, 320435057684033242953952509794605645127, 133212895719388354112667050350502201843, 262256541475020683812327300478510544022, 68423813730476634270402958635073934367, 156738226689669755944851331748791005616, 165800725532545879609977936210035055040, 172018455739485735148072644379216290447, 230951541362177602359868002660805912181, 152287027695533706215823402052033189960, 185057933550094735087283806786823061589, 122688000701961209416344853008164886381, 134958802702793640081845590040343954920, 234580960409424622564273814575333116288, 183739892098724792237695657764961499807, 39015994699012683337617007960068058843, 324137172833870104374658339409853260398, 156871594659100780158350555737480367369, 76549132260116470292478935610594931831, 206367556367473756044436720233354369995, 242121355820534272849028361122887112128, 188631998326034004600861498586852938791, 216069174770114465624174207718872444354, 307944890529036529511929496919799050224, 316346783727245703493409702940347462603, 232794123719215275741536507199048918940, 230699271415462493000400243339292494907, 215746109799468672448745109724428767505, 10735964370838476891653111627115651590, 177546680977013945994944742461442930075, 48188853863336799882618830643360361251, 123072710083781474823580256603344815581, 53696605966638634884824007767847163895, 244813750508221881267886759962353770844, 138389416756738828485107907845869178387, 28787808414027521881066099129863372506, 208960876676490369283588392054850944689, 291922470923877549823217120675909351267, 115223001020919711020256788413332787629, 309151305555635829791059270121082705015])
cc ed5adefd853fbe7386e63b9d852d81fcfb66fd30eb1ee0ac95f4915dc32af26d # shrinks to (claim_amount, raw_amount, owner, bond_id) = ([0, 0], [5567553736818050811761864155695314435, 334714813184120412651612743276072882021], ["", ""], [0, 0])
cc bb29a873ab429224989abbadbb61fd8492c0c147fcbfdd7c03eb64d853c254db # shrinks to (claim_amount, raw_amount, owner, bond_id) = ([], [], [], []), (amount_pd, owner_pd, bond_id_pd) = ([], [], []), raw_balalance_rq = 0, quote_balance_rq = 0, lp_balance_rq = 0, join_pool_rq = 0, exit_pool_base_rq = 0, exit_pool_quote_rq = 0, spot_price_rq = 0
cc 34775cc5f6b44bd958d663493908f0e5546434ed9156d1ebe18a1503b4166df0 # shrinks to (claim_amount, raw_amount, owner, bond_id) = ([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 83553156567498, 11808849592816811342, 8130787376546610459, 14980519244902503230, 14234410997718520343, 10225549382265082313, 14258484066235613374, 16132509078925444533, 12496179773926113447, 5163701959177179557, 6115732151642180644, 16014557328226574517, 17910735935150482215, 15905882731006320604, 6938858134545344839, 311364060211843560, 8464979079766962920, 8688102988532725869, 6950140404087665517, 61793720827537470, 15697647606715928957, 6549806696217709345, 6362990510017777241, 10957519013857898322, 12513697704065533392, 10682377085392477145, 11467648984684906402, 6914635055688605728, 6355149797117565939, 3759358825474970803, 1512101291444601349, 12542255319701031943, 7005223357316672524, 11709985910294196329, 16431675148878993558, 18088527547444258371, 18128405577901023348, 533460672940784407, 6547510708312023640, 12866793111322861531, 8672995590736397231, 14424622615502074446, 2307613407971382985, 17441942398532076118], [15826457340195732357, 3704826055518850654, 7534652765877672533, 17446234302595466983, 6161974760894201947, 14625587653503619871, 6368026972723040756, 9429109580945985830, 2272938497016214323, 3904354027872436016, 11765354634249073970, 5206622489089162589, 6352158132024455001, 10360948853066292607, 16091076371184297087, 10686302784989918058, 522004517581656444, 4357444334841157825, 8752957838480279932, 1966713813215548561, 16954393754388505823, 984025542946232675, 13665913500959464705, 4955554490241156322, 7294307173539117479, 938763324680373732, 492520615853963630, 14849790482556102869, 13517356408982302285, 12639950288329634165, 13393035703502329928, 16572484674960023979, 6573211058722160462, 14412302373624951367, 6188123385003315881, 11715869108671089008, 5648724300247408734, 5413705664772579881, 5998831249611394040, 1220625596522501898, 1377604803059093507, 141220414108167420, 120942024884388456, 15465952658707590747, 14335606127926440686, 16175674822280915491, 8695491072012231849, 1853068128626976492, 11227189535675615227, 4960793297193568795, 7850650787850785584, 2911908877680041078, 9878681945393343004, 7725132537583460349, 5630970625065211239, 15588629860098892381, 9561298833016379036, 17094307055106940528, 6013650033902031667, 8259839850861701315], ["dgrqiyjcovaookyblrg", "ztmagivlipvydahetyhpdwayykzjj", "tfdbxmfojhsbmzgumapeoz", "gxezjehqzrkzutmghdlqaxfduyvdtmmd", "fhsdpym", "wudbifslwjvruodwlokezlrkouqarvt", "zpnihv", "e", "vkyycuyhdzzdeemvpigsb", "plvetqyxmjjhsgtuysxqqymj", "inwzsdwpbdoerg", "zfwpkflklyt", "mnbfxebcyiailqsrfqowr", "mupbksylxtjtgqalnitlqjitlnzks", "qpjyoai", "bzskbtibcesvxnfgbvuzhzgtycy", "opjjotortcawlyttck", "mgftscgljwawrffmgsffsxleujngatbi", "atofntcuqdxmzqyaykhwyuwzy", "bkehgtfwnxphyxfaryescclprn", "moaianym", "hufolvhlfdjbeogauquuv", "dpkoobsneuuktmrxabwhk", "fxkeasrmkldatftoxaxtrow", "ynqjoxyleuoo", "dmjobjvtdxvfaiiicbjjpmhrke", "rpqahmnaflpqteyeyzfbhuab", "qgxytkazzaowoahejafngnnmoyuwq", "mctubnxzqodnwqxlhfhcrmtnoqaav", "nhjqjrktvc", "ysyqcjioyrfhutkaueaoocfxnctqazeq", "clxcviqulqfkm", "rtnwqgagvt", "jmqaltldcjcvfmdj", "nnlnpocqf", "pptjwiqwjbxfetnztectxrainddacm", "onxfua", "jngvifuoigb", "scmknna", "splnseom", "onqlrofyfmycjjdz", "fifjawebeqjtnbvoeioyimxvjjl", "ovqeftnbpqwp", "sk", "zidmgenlzppemiofhewmlsefjzdo", "rweenuisuhqk", "hop", "hpnyurozekfedbxhzidxbfihcypeljuf", "x", "ttpwuzzlnw", "defee", "pszdtgzfkzdxldlcrbr", "hqqnyylxmm", "ytwhdpgbqqluofeimednsepsvkxhaae", "uwlzmmgbadlymz", "ilpfthwgblxrlcwt", "trxqrxeii", "nklgitkbqdgbuiykweimoxxbus", "wsnxygctcnomzgjywfvtu", "bfcglnnizuhprogakd"], [17564701645947559694, 10684717952737285943, 10219761788279915146, 2109710357599859391, 10487310863879864593, 15822884041780719907, 11848105584455790133, 17931449780282279864, 8909590184269171323, 2959034442329770038, 16596193355103071593, 15485371830524286297, 15155403646891693209, 16618642512816226160, 11042324674626444498, 11974407949461512535, 1763186450440707960, 18290373659633014915, 15628661186771988252, 16836233893596365339, 16156643523011845388, 6812953976141217730, 3685585248911984394, 810033298279336584, 9998175313336111059, 8687288352342553603, 3098556134784640099, 3864774701428716149, 15051486419399376922, 2190077543700623599, 16012320347463077713, 16833307165034632153, 2395940186996495483, 4130047742181157138, 398807872624232724, 5593681726988201550, 17694081960095301824, 15985889760645175226, 16376128475035724969, 4026056742303909744, 15014143413475248664, 3995771739911710916, 1941983340358743336, 13206881376468297167, 14576866369417099042, 11358921675486065870, 2026942581626530092, 3182543356739401115, 13832536031591260330, 10929954346159679353, 17226923001376597991, 14359302255407025404, 15604591261117489966, 4652729393292511177, 14178413536313939160, 8962255765512619945, 11954228840537278358, 7081160827464255778, 12740476215904686133, 901276637696619765]), (amount_pd, owner_pd, bond_id_pd) = ([], [], []), raw_balalance_rq = 3906736672086151414, quote_balance_rq = 5260586167652135091, lp_balance_rq = 47453939318407458, join_pool_rq = 17437550474192041343, exit_pool_base_rq = 12672570040552928040, exit_pool_quote_rq = 261663182347622709, spot_price_rq = 10002155156807470437
Loading

0 comments on commit 0c93807

Please sign in to comment.