Skip to content

Commit

Permalink
added osmo twap price
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Nov 22, 2023
1 parent 458d966 commit d6efd34
Show file tree
Hide file tree
Showing 2 changed files with 656 additions and 114 deletions.
66 changes: 57 additions & 9 deletions proto/osmosis/gamm/v1beta1/osmosis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ package osmosis.gamm.v1beta1;
import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/Stride-Labs/stride/v16/x/stakeibc/types";

// MsgSwapExactAmountIn stores the tx Msg type to swap tokens in the trade ICA
message MsgSwapExactAmountIn {
option (amino.name) = "osmosis/gamm/swap-exact-amount-in";

Expand All @@ -24,17 +26,63 @@ message MsgSwapExactAmountIn {
];
}

message MsgSwapExactAmountInResponse {
string token_out_amount = 1 [

(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"token_out_amount\"",
(gogoproto.nullable) = false
];
}

message SwapAmountInRoute {
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
string token_out_denom = 2
[ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ];
}

// A TwapRecord stores the most recent price of a pair of denom's
message OsmosisTwapRecord {
uint64 pool_id = 1;
// Lexicographically smaller denom of the pair
string asset0_denom = 2;
// Lexicographically larger denom of the pair
string asset1_denom = 3;
// height this record corresponds to, for debugging purposes
int64 height = 4 [
(gogoproto.moretags) = "yaml:\"record_height\"",
(gogoproto.jsontag) = "record_height"
];
// This field should only exist until we have a global registry in the state
// machine, mapping prior block heights within {TIME RANGE} to times.
google.protobuf.Timestamp time = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"record_time\""
];

// We store the last spot prices in the struct, so that we can interpolate
// accumulator values for times between when accumulator records are stored.
string p0_last_spot_price = 6 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string p1_last_spot_price = 7 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

string p0_arithmetic_twap_accumulator = 8 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string p1_arithmetic_twap_accumulator = 9 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

string geometric_twap_accumulator = 10 [
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// This field contains the time in which the last spot price error occured.
// It is used to alert the caller if they are getting a potentially erroneous
// TWAP, due to an unforeseen underlying error.
google.protobuf.Timestamp last_error_time = 11 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"last_error_time\""
];
}
Loading

0 comments on commit d6efd34

Please sign in to comment.