Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions integrationtest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion integrationtest/output/tc1.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"liquidity_provider_units": "1000000000000000000000",
"liquidity_provider_address": "sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd"
}
}
},
"Positions": null
}
55 changes: 36 additions & 19 deletions integrationtest/output/tc2.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd": [
{
"denom": "atom",
"amount": "998999999500000000"
"amount": "999000084894963897"
},
{
"denom": "cusdc",
"amount": "1000000000000000000"
},
{
"denom": "rowan",
"amount": "999000014013414589440803461377"
"amount": "998996042186543065302680149569"
}
]
},
Expand All @@ -34,32 +34,49 @@
"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": {
"\u0001atom_sif1syavy2npfyt9tcncdtsdzf7kny9lh777yqc2nd": {
"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
}
]
}
49 changes: 48 additions & 1 deletion integrationtest/output/tc3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}