-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3c4b7f
commit 5578430
Showing
98 changed files
with
4,018 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/src/models/networks/osmosis/osmosis_accum_v1beta1/messages/accumulator_content.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:cosmos_sdk/src/models/networks/osmosis/osmosis_accum_v1beta1/types/types.dart'; | ||
import 'package:cosmos_sdk/src/models/sdk_v1beta1/cosmos_base_v1beta1/messages/dec_coin.dart'; | ||
import 'package:cosmos_sdk/src/protobuf/protobuf.dart'; | ||
import 'package:cosmos_sdk/src/utils/quick_extensions.dart'; | ||
|
||
/// AccumulatorContent is the state-entry for the global accumulator. | ||
/// It contains the name of the global accumulator and the total value of shares belonging to it from all positions. | ||
class OsmosisAccumAccumulatorContent extends CosmosMessage { | ||
final List<DecCoin> accumValue; | ||
final String totalShares; | ||
OsmosisAccumAccumulatorContent( | ||
{required List<DecCoin> accumValue, required this.totalShares}) | ||
: accumValue = accumValue.mutable; | ||
factory OsmosisAccumAccumulatorContent.deserialize(List<int> bytes) { | ||
final decode = CosmosProtocolBuffer.decode(bytes); | ||
return OsmosisAccumAccumulatorContent( | ||
accumValue: | ||
decode.getFields(1).map((e) => DecCoin.deserialize(e)).toList(), | ||
totalShares: decode.getField(2), | ||
); | ||
} | ||
factory OsmosisAccumAccumulatorContent.fromRpc(Map<String, dynamic> json) { | ||
return OsmosisAccumAccumulatorContent( | ||
accumValue: (json["accum_value"] as List?) | ||
?.map((e) => DecCoin.fromRpc(e)) | ||
.toList() ?? | ||
<DecCoin>[], | ||
totalShares: json["total_shares"], | ||
); | ||
} | ||
|
||
@override | ||
List<int> get fieldIds => [1, 2]; | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return { | ||
"accum_value": accumValue.map((e) => e.toJson()).toList(), | ||
"total_shares": totalShares, | ||
}; | ||
} | ||
|
||
@override | ||
String get typeUrl => OsmosisAccumV1beta1Types.accumulatorContent.typeUrl; | ||
|
||
@override | ||
List get values => [accumValue, totalShares]; | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/src/models/networks/osmosis/osmosis_accum_v1beta1/messages/options.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:cosmos_sdk/src/models/networks/osmosis/osmosis_accum_v1beta1/types/types.dart'; | ||
import 'package:cosmos_sdk/src/protobuf/protobuf.dart'; | ||
|
||
class OsmosisAccumOptions extends CosmosMessage { | ||
OsmosisAccumOptions(); | ||
factory OsmosisAccumOptions.deserialize(List<int> bytes) { | ||
return OsmosisAccumOptions(); | ||
} | ||
|
||
@override | ||
List<int> get fieldIds => []; | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return {}; | ||
} | ||
|
||
@override | ||
String get typeUrl => OsmosisAccumV1beta1Types.options.typeUrl; | ||
|
||
@override | ||
List get values => []; | ||
} |
85 changes: 85 additions & 0 deletions
85
lib/src/models/networks/osmosis/osmosis_accum_v1beta1/messages/record_msg.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'package:cosmos_sdk/src/models/networks/osmosis/osmosis_accum_v1beta1/types/types.dart'; | ||
import 'package:cosmos_sdk/src/models/sdk_v1beta1/cosmos_base_v1beta1/messages/dec_coin.dart'; | ||
import 'package:cosmos_sdk/src/protobuf/protobuf.dart'; | ||
import 'package:cosmos_sdk/src/utils/quick_extensions.dart'; | ||
|
||
/// Record corresponds to an individual position value belonging to the global accumulator. | ||
class OsmosisAccumRecord extends CosmosMessage { | ||
/// num_shares is the number of shares belonging to the position associated | ||
/// with this record. | ||
final String numShares; | ||
|
||
/// accum_value_per_share is the subset of coins per shar of the global | ||
/// accumulator value that allows to infer how much a position is entitled to | ||
/// per share that it owns. | ||
/// | ||
/// In the default case with no intervals, this value equals to the global | ||
/// accumulator value at the time of the position creation, the last update or | ||
/// reward claim. | ||
/// | ||
/// In the interval case such as concentrated liquidity, this value equals to | ||
/// the global growth of rewards inside the interval during one of: the time of | ||
/// the position creation, the last update or reward claim. Note, that | ||
// immediately prior to claiming or updating rewards, this value must be | ||
/// updated to "the growth inside at the time of last update + the growth | ||
/// outside at the time of the current block". This is so that the claiming | ||
/// logic can subtract this updated value from the global accumulator value to | ||
/// get the growth inside the interval from the time of last update up until | ||
/// the current block time. | ||
final List<DecCoin> accumValuePerShare; | ||
|
||
/// unclaimed_rewards_total is the total amount of unclaimed rewards that the | ||
/// position is entitled to. This value is updated whenever shares are added or | ||
/// removed from an existing position. We also expose API for manually updating | ||
/// this value for some custom use cases such as merging pre-existing positions | ||
/// into a single one.s | ||
final List<DecCoin> unclaimedRewardsTotal; | ||
OsmosisAccumRecord({ | ||
required this.numShares, | ||
required List<DecCoin> accumValuePerShare, | ||
required List<DecCoin> unclaimedRewardsTotal, | ||
}) : accumValuePerShare = accumValuePerShare.mutable, | ||
unclaimedRewardsTotal = unclaimedRewardsTotal.mutable; | ||
factory OsmosisAccumRecord.deserialize(List<int> bytes) { | ||
final decode = CosmosProtocolBuffer.decode(bytes); | ||
return OsmosisAccumRecord( | ||
numShares: decode.getField(1), | ||
accumValuePerShare: | ||
decode.getFields(2).map((e) => DecCoin.deserialize(e)).toList(), | ||
unclaimedRewardsTotal: | ||
decode.getFields(3).map((e) => DecCoin.deserialize(e)).toList(), | ||
); | ||
} | ||
factory OsmosisAccumRecord.fromRpc(Map<String, dynamic> json) { | ||
return OsmosisAccumRecord( | ||
numShares: json["num_shares"], | ||
accumValuePerShare: (json["accum_value_per_share"] as List?) | ||
?.map((e) => DecCoin.deserialize(e)) | ||
.toList() ?? | ||
<DecCoin>[], | ||
unclaimedRewardsTotal: (json["unclaimed_rewards_total"] as List?) | ||
?.map((e) => DecCoin.deserialize(e)) | ||
.toList() ?? | ||
<DecCoin>[]); | ||
} | ||
|
||
@override | ||
List<int> get fieldIds => [1, 2, 3]; | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return { | ||
"num_shares": numShares, | ||
"accum_value_per_share": | ||
accumValuePerShare.map((e) => e.toJson()).toList(), | ||
"unclaimed_rewards_total": | ||
unclaimedRewardsTotal.map((e) => e.toJson()).toList() | ||
}; | ||
} | ||
|
||
@override | ||
String get typeUrl => OsmosisAccumV1beta1Types.record.typeUrl; | ||
|
||
@override | ||
List get values => [numShares, accumValuePerShare, unclaimedRewardsTotal]; | ||
} |
3 changes: 3 additions & 0 deletions
3
lib/src/models/networks/osmosis/osmosis_accum_v1beta1/osmosis_accum_v1beta1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'messages/accumulator_content.dart'; | ||
export 'messages/options.dart'; | ||
export 'messages/record_msg.dart'; |
15 changes: 15 additions & 0 deletions
15
lib/src/models/networks/osmosis/osmosis_accum_v1beta1/types/types.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:cosmos_sdk/src/models/core/type_url/type_url.dart'; | ||
|
||
class OsmosisAccumV1beta1Types extends TypeUrl { | ||
@override | ||
final String typeUrl; | ||
@override | ||
final String? rpc = null; | ||
const OsmosisAccumV1beta1Types._(this.typeUrl); | ||
static const OsmosisAccumV1beta1Types accumulatorContent = | ||
OsmosisAccumV1beta1Types._("/osmosis.accum.v1beta1.AccumulatorContent"); | ||
static const OsmosisAccumV1beta1Types options = | ||
OsmosisAccumV1beta1Types._("/osmosis.accum.v1beta1.Options"); | ||
static const OsmosisAccumV1beta1Types record = | ||
OsmosisAccumV1beta1Types._("/osmosis.accum.v1beta1.Record"); | ||
} |
Binary file added
BIN
+6 KB
lib/src/models/networks/osmosis/osmosis_concentrated_liquidity_v1beta1/.DS_Store
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
...models/networks/osmosis/osmosis_concentrated_liquidity_v1beta1/messages/accum_object.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:cosmos_sdk/src/models/networks/osmosis/osmosis_accum_v1beta1/osmosis_accum_v1beta1.dart'; | ||
import 'package:cosmos_sdk/src/models/networks/osmosis/osmosis_concentrated_liquidity_v1beta1/types/types.dart'; | ||
import 'package:cosmos_sdk/src/protobuf/protobuf.dart'; | ||
|
||
class OsmosisConcentratedLiquidityAccumObject extends CosmosMessage { | ||
/// Accumulator's name (pulled from AccumulatorContent) | ||
final String? name; | ||
final OsmosisAccumAccumulatorContent? accumContent; | ||
OsmosisConcentratedLiquidityAccumObject({this.name, this.accumContent}); | ||
factory OsmosisConcentratedLiquidityAccumObject.deserialize(List<int> bytes) { | ||
final decode = CosmosProtocolBuffer.decode(bytes); | ||
return OsmosisConcentratedLiquidityAccumObject( | ||
name: decode.getField(1), | ||
accumContent: decode | ||
.getResult(2) | ||
?.to<OsmosisAccumAccumulatorContent, List<int>>( | ||
(e) => OsmosisAccumAccumulatorContent.deserialize(e))); | ||
} | ||
factory OsmosisConcentratedLiquidityAccumObject.fromRpc( | ||
Map<String, dynamic> json) { | ||
return OsmosisConcentratedLiquidityAccumObject( | ||
name: json["name"], | ||
accumContent: json["accum_content"] == null | ||
? null | ||
: OsmosisAccumAccumulatorContent.fromRpc(json["accum_content"])); | ||
} | ||
|
||
@override | ||
List<int> get fieldIds => [1, 2]; | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return {"name": name, "accum_content": accumContent?.toJson()}; | ||
} | ||
|
||
@override | ||
List get values => [name, accumContent]; | ||
|
||
@override | ||
String get typeUrl => | ||
OsmosisConcentratedLiquidityV1beta1Types.accumObject.typeUrl; | ||
} |
Oops, something went wrong.