diff --git a/integrationtest/integration_test.go b/integrationtest/integration_test.go index 1c325cf20a..f09522e328 100644 --- a/integrationtest/integration_test.go +++ b/integrationtest/integration_test.go @@ -203,13 +203,31 @@ func TC2(t *testing.T) TestCase { BorrowAsset: "atom", Position: margintypes.Position_LONG, Leverage: sdk.NewDec(5), - }, /* - &clptypes.MsgAddLiquidity{ - Signer: address, - ExternalAsset: &clptypes.Asset{Symbol: externalAsset}, - NativeAssetAmount: sdk.NewUintFromString("1000000000000000000000"), // 1000rowan - ExternalAssetAmount: sdk.NewUintFromString("1000000000"), - },*/ + }, + &clptypes.MsgAddLiquidity{ + Signer: address, + ExternalAsset: &clptypes.Asset{Symbol: "atom"}, + NativeAssetAmount: sdk.NewUintFromString("1000000000000000000000000"), // 1000,000rowan + ExternalAssetAmount: sdk.NewUintFromString("0"), + }, + &clptypes.MsgAddLiquidity{ + Signer: address, + ExternalAsset: &clptypes.Asset{Symbol: "atom"}, + NativeAssetAmount: sdk.NewUintFromString("0"), + ExternalAssetAmount: sdk.NewUintFromString("1000000000"), //1000atom + }, + &clptypes.MsgAddLiquidity{ + Signer: address, + ExternalAsset: &clptypes.Asset{Symbol: "atom"}, + NativeAssetAmount: sdk.NewUintFromString("3000000000000000000000000"), // 3000,000rowan + ExternalAssetAmount: sdk.NewUintFromString("0"), + }, + &clptypes.MsgAddLiquidity{ + Signer: address, + ExternalAsset: &clptypes.Asset{Symbol: "atom"}, + NativeAssetAmount: sdk.NewUintFromString("0"), + ExternalAssetAmount: sdk.NewUintFromString("3000000000"), //3000atom + }, }, } @@ -448,9 +466,10 @@ func endBlock(t *testing.T, app *sifapp.SifchainApp, ctx sdk.Context, height int } type TestResults struct { - Accounts map[string]sdk.Coins `json:"accounts"` - Pools map[string]clptypes.Pool - LPs map[string]clptypes.LiquidityProvider + Accounts map[string]sdk.Coins `json:"accounts"` + Pools map[string]clptypes.Pool + LPs map[string]clptypes.LiquidityProvider + Positions []margintypes.MTP } func getResults(t *testing.T, app *sifapp.SifchainApp, ctx sdk.Context, tc TestCase) TestResults { @@ -481,6 +500,8 @@ func getResults(t *testing.T, app *sifapp.SifchainApp, ctx sdk.Context, tc TestC results.LPs[string(clptypes.GetLiquidityProviderKey(lp.Asset.Symbol, lp.LiquidityProviderAddress))] = *lp } + results.Positions = app.MarginKeeper.GetAllMTPS(ctx) + return results } diff --git a/integrationtest/output/tc1.json b/integrationtest/output/tc1.json index eb2a85c155..941bf9f169 100644 --- a/integrationtest/output/tc1.json +++ b/integrationtest/output/tc1.json @@ -43,5 +43,6 @@ "liquidity_provider_units": "1000000000000000000000", "liquidity_provider_address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd" } - } + }, + "Positions": null } \ No newline at end of file diff --git a/integrationtest/output/tc2.json b/integrationtest/output/tc2.json index ba1d7beb9f..4a237c4a86 100644 --- a/integrationtest/output/tc2.json +++ b/integrationtest/output/tc2.json @@ -17,7 +17,7 @@ "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd": [ { "denom": "atom", - "amount": "998999999500000000" + "amount": "999000084894963897" }, { "denom": "cusdc", @@ -25,7 +25,7 @@ }, { "denom": "rowan", - "amount": "999000014013414589440803461377" + "amount": "998996042186543065302680149569" } ] }, @@ -34,23 +34,23 @@ "external_asset": { "symbol": "atom" }, - "native_asset_balance": "1000487089285600288982742163", - "external_asset_balance": "999004488135149", - "pool_units": "1000000000000000000000000000", - "swap_price_native": "1.000007907317368468", - "swap_price_external": "0.999992092745156704", - "reward_period_native_distributed": "2000000000000000000000", + "native_asset_balance": "1004463813456934697319850431", + "external_asset_balance": "999915105036103", + "pool_units": "1001995050772412052038420983", + "swap_price_native": "0.995463039797976218", + "swap_price_external": "1.004557638024355512", + "reward_period_native_distributed": "6000000000000000000000", "external_liabilities": "500000000", - "external_custody": "996011864851", - "native_liabilities": "500000000000000000000000", - "native_custody": "897299810270213796460", - "health": "0.999499996303992980", - "interest_rate": "0.200000000000000000", - "last_height_interest_rate_computed": 2, + "external_custody": "0", + "native_liabilities": "0", + "native_custody": "0", + "health": "0.999501972521346298", + "interest_rate": "0.600000000000000000", + "last_height_interest_rate_computed": 6, "unsettled_external_liabilities": "0", - "unsettled_native_liabilities": "0", - "block_interest_native": "89729273457704882289", - "block_interest_external": "0" + "unsettled_native_liabilities": "397739776251561669623497", + "block_interest_native": "267916876912448068138", + "block_interest_external": "267656513004" } }, "LPs": { @@ -58,8 +58,25 @@ "asset": { "symbol": "atom" }, - "liquidity_provider_units": "1000000000000000000000000000", + "liquidity_provider_units": "1001995050772412052038420983", "liquidity_provider_address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd" } - } + }, + "Positions": [ + { + "address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", + "collateral_asset": "atom", + "collateral_amount": "500000000", + "liabilities": "500000000", + "interest_paid_collateral": "995445818", + "interest_paid_custody": "996999003000996999003", + "interest_unpaid_collateral": "4554180", + "custody_asset": "rowan", + "custody_amount": "0", + "leverage": "2.000000000000000000", + "mtp_health": "0.590891638000000000", + "position": 1, + "id": 1 + } + ] } \ No newline at end of file diff --git a/integrationtest/output/tc3.json b/integrationtest/output/tc3.json index 76dfd28272..b125792e17 100644 --- a/integrationtest/output/tc3.json +++ b/integrationtest/output/tc3.json @@ -104,5 +104,52 @@ "liquidity_provider_units": "1000000000000000000000000000", "liquidity_provider_address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd" } - } + }, + "Positions": [ + { + "address": "sif15ky9du8a2wlstz6fpx3p4mqpjyrm5cgp29yyze", + "collateral_asset": "rowan", + "collateral_amount": "500000000000000000000000", + "liabilities": "500000000000000000000000", + "interest_paid_collateral": "250000000000000000000000", + "interest_paid_custody": "248696839957", + "interest_unpaid_collateral": "0", + "custody_asset": "atom", + "custody_amount": "747325066399", + "leverage": "2.000000000000000000", + "mtp_health": "1.988006077400219765", + "position": 1, + "id": 3 + }, + { + "address": "sif15ky9du8a2wlstz6fpx3p4mqpjyrm5cgqhns3lt", + "collateral_asset": "cusdc", + "collateral_amount": "5000000000", + "liabilities": "5000000000", + "interest_paid_collateral": "3499999999", + "interest_paid_custody": "3489339220850824052524", + "interest_unpaid_collateral": "0", + "custody_asset": "rowan", + "custody_amount": "6480403411951809127957", + "leverage": "2.000000000000000000", + "mtp_health": "1.689840585800000000", + "position": 1, + "id": 2 + }, + { + "address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd", + "collateral_asset": "cusdc", + "collateral_amount": "1000000000", + "liabilities": "1000000000", + "interest_paid_collateral": "899999999", + "interest_paid_custody": "897266729446045141572", + "interest_unpaid_collateral": "0", + "custody_asset": "rowan", + "custody_amount": "1096717318585858794620", + "leverage": "2.000000000000000000", + "mtp_health": "1.491076900000000000", + "position": 1, + "id": 1 + } + ] } \ No newline at end of file