import { Timestamp } from "../../../../google/protobuf/timestamp"; import { Duration, DurationSDKType } from "../../../../google/protobuf/duration"; import { Coin, CoinSDKType } from "../../../../cosmos/base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; import { toTimestamp, fromTimestamp, DeepPartial, Long } from "../../../../helpers"; /** * Parameters for changing the weights in a balancer pool smoothly from * a start weight and end weight over a period of time. * Currently, the only smooth change supported is linear changing between * the two weights, but more types may be added in the future. * When these parameters are set, the weight w(t) for pool time `t` is the * following: * t <= start_time: w(t) = initial_pool_weights * start_time < t <= start_time + duration: * w(t) = initial_pool_weights + (t - start_time) * * (target_pool_weights - initial_pool_weights) / (duration) * t > start_time + duration: w(t) = target_pool_weights */ export interface SmoothWeightChangeParams { /** * The start time for beginning the weight change. * If a parameter change / pool instantiation leaves this blank, * it should be generated by the state_machine as the current time. */ startTime?: Date; /** Duration for the weights to change over */ duration?: Duration; /** * The initial pool weights. These are copied from the pool's settings * at the time of weight change instantiation. * The amount PoolAsset.token.amount field is ignored if present, * future type refactorings should just have a type with the denom & weight * here. */ initialPoolWeights: PoolAsset[]; /** * The target pool weights. The pool weights will change linearly with respect * to time between start_time, and start_time + duration. The amount * PoolAsset.token.amount field is ignored if present, future type * refactorings should just have a type with the denom & weight here. */ targetPoolWeights: PoolAsset[]; } /** * Parameters for changing the weights in a balancer pool smoothly from * a start weight and end weight over a period of time. * Currently, the only smooth change supported is linear changing between * the two weights, but more types may be added in the future. * When these parameters are set, the weight w(t) for pool time `t` is the * following: * t <= start_time: w(t) = initial_pool_weights * start_time < t <= start_time + duration: * w(t) = initial_pool_weights + (t - start_time) * * (target_pool_weights - initial_pool_weights) / (duration) * t > start_time + duration: w(t) = target_pool_weights */ export interface SmoothWeightChangeParamsSDKType { /** * The start time for beginning the weight change. * If a parameter change / pool instantiation leaves this blank, * it should be generated by the state_machine as the current time. */ start_time?: Date; /** Duration for the weights to change over */ duration?: DurationSDKType; /** * The initial pool weights. These are copied from the pool's settings * at the time of weight change instantiation. * The amount PoolAsset.token.amount field is ignored if present, * future type refactorings should just have a type with the denom & weight * here. */ initial_pool_weights: PoolAssetSDKType[]; /** * The target pool weights. The pool weights will change linearly with respect * to time between start_time, and start_time + duration. The amount * PoolAsset.token.amount field is ignored if present, future type * refactorings should just have a type with the denom & weight here. */ target_pool_weights: PoolAssetSDKType[]; } /** * PoolParams defined the parameters that will be managed by the pool * governance in the future. This params are not managed by the chain * governance. Instead they will be managed by the token holders of the pool. * The pool's token holders are specified in future_pool_governor. */ export interface PoolParams { swapFee: string; exitFee: string; smoothWeightChangeParams?: SmoothWeightChangeParams; } /** * PoolParams defined the parameters that will be managed by the pool * governance in the future. This params are not managed by the chain * governance. Instead they will be managed by the token holders of the pool. * The pool's token holders are specified in future_pool_governor. */ export interface PoolParamsSDKType { swap_fee: string; exit_fee: string; smooth_weight_change_params?: SmoothWeightChangeParamsSDKType; } /** * Pool asset is an internal struct that combines the amount of the * token in the pool, and its balancer weight. * This is an awkward packaging of data, * and should be revisited in a future state migration. */ export interface PoolAsset { /** * Coins we are talking about, * the denomination must be unique amongst all PoolAssets for this pool. */ token?: Coin; /** Weight that is not normalized. This weight must be less than 2^50 */ weight: string; } /** * Pool asset is an internal struct that combines the amount of the * token in the pool, and its balancer weight. * This is an awkward packaging of data, * and should be revisited in a future state migration. */ export interface PoolAssetSDKType { /** * Coins we are talking about, * the denomination must be unique amongst all PoolAssets for this pool. */ token?: CoinSDKType; /** Weight that is not normalized. This weight must be less than 2^50 */ weight: string; } export interface Pool { address: string; id: Long; poolParams?: PoolParams; /** * This string specifies who will govern the pool in the future. * Valid forms of this are: * {token name},{duration} * {duration} * where {token name} if specified is the token which determines the * governor, and if not specified is the LP token for this pool.duration is * a time specified as 0w,1w,2w, etc. which specifies how long the token * would need to be locked up to count in governance. 0w means no lockup. * TODO: Further improve these docs */ futurePoolGovernor: string; /** sum of all LP tokens sent out */ totalShares?: Coin; /** * These are assumed to be sorted by denomiation. * They contain the pool asset and the information about the weight */ poolAssets: PoolAsset[]; /** sum of all non-normalized pool weights */ totalWeight: string; } export interface PoolSDKType { address: string; id: Long; pool_params?: PoolParamsSDKType; /** * This string specifies who will govern the pool in the future. * Valid forms of this are: * {token name},{duration} * {duration} * where {token name} if specified is the token which determines the * governor, and if not specified is the LP token for this pool.duration is * a time specified as 0w,1w,2w, etc. which specifies how long the token * would need to be locked up to count in governance. 0w means no lockup. * TODO: Further improve these docs */ future_pool_governor: string; /** sum of all LP tokens sent out */ total_shares?: CoinSDKType; /** * These are assumed to be sorted by denomiation. * They contain the pool asset and the information about the weight */ pool_assets: PoolAssetSDKType[]; /** sum of all non-normalized pool weights */ total_weight: string; } function createBaseSmoothWeightChangeParams(): SmoothWeightChangeParams { return { startTime: undefined, duration: undefined, initialPoolWeights: [], targetPoolWeights: [] }; } export const SmoothWeightChangeParams = { encode(message: SmoothWeightChangeParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.startTime !== undefined) { Timestamp.encode(toTimestamp(message.startTime), writer.uint32(10).fork()).ldelim(); } if (message.duration !== undefined) { Duration.encode(message.duration, writer.uint32(18).fork()).ldelim(); } for (const v of message.initialPoolWeights) { PoolAsset.encode(v!, writer.uint32(26).fork()).ldelim(); } for (const v of message.targetPoolWeights) { PoolAsset.encode(v!, writer.uint32(34).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): SmoothWeightChangeParams { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSmoothWeightChangeParams(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); break; case 2: message.duration = Duration.decode(reader, reader.uint32()); break; case 3: message.initialPoolWeights.push(PoolAsset.decode(reader, reader.uint32())); break; case 4: message.targetPoolWeights.push(PoolAsset.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: DeepPartial): SmoothWeightChangeParams { const message = createBaseSmoothWeightChangeParams(); message.startTime = object.startTime ?? undefined; message.duration = object.duration !== undefined && object.duration !== null ? Duration.fromPartial(object.duration) : undefined; message.initialPoolWeights = object.initialPoolWeights?.map(e => PoolAsset.fromPartial(e)) || []; message.targetPoolWeights = object.targetPoolWeights?.map(e => PoolAsset.fromPartial(e)) || []; return message; } }; function createBasePoolParams(): PoolParams { return { swapFee: "", exitFee: "", smoothWeightChangeParams: undefined }; } export const PoolParams = { encode(message: PoolParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.swapFee !== "") { writer.uint32(10).string(message.swapFee); } if (message.exitFee !== "") { writer.uint32(18).string(message.exitFee); } if (message.smoothWeightChangeParams !== undefined) { SmoothWeightChangeParams.encode(message.smoothWeightChangeParams, writer.uint32(26).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): PoolParams { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePoolParams(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.swapFee = reader.string(); break; case 2: message.exitFee = reader.string(); break; case 3: message.smoothWeightChangeParams = SmoothWeightChangeParams.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: DeepPartial): PoolParams { const message = createBasePoolParams(); message.swapFee = object.swapFee ?? ""; message.exitFee = object.exitFee ?? ""; message.smoothWeightChangeParams = object.smoothWeightChangeParams !== undefined && object.smoothWeightChangeParams !== null ? SmoothWeightChangeParams.fromPartial(object.smoothWeightChangeParams) : undefined; return message; } }; function createBasePoolAsset(): PoolAsset { return { token: undefined, weight: "" }; } export const PoolAsset = { encode(message: PoolAsset, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.token !== undefined) { Coin.encode(message.token, writer.uint32(10).fork()).ldelim(); } if (message.weight !== "") { writer.uint32(18).string(message.weight); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): PoolAsset { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePoolAsset(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.token = Coin.decode(reader, reader.uint32()); break; case 2: message.weight = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: DeepPartial): PoolAsset { const message = createBasePoolAsset(); message.token = object.token !== undefined && object.token !== null ? Coin.fromPartial(object.token) : undefined; message.weight = object.weight ?? ""; return message; } }; function createBasePool(): Pool { return { address: "", id: Long.UZERO, poolParams: undefined, futurePoolGovernor: "", totalShares: undefined, poolAssets: [], totalWeight: "" }; } export const Pool = { encode(message: Pool, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.address !== "") { writer.uint32(10).string(message.address); } if (!message.id.isZero()) { writer.uint32(16).uint64(message.id); } if (message.poolParams !== undefined) { PoolParams.encode(message.poolParams, writer.uint32(26).fork()).ldelim(); } if (message.futurePoolGovernor !== "") { writer.uint32(34).string(message.futurePoolGovernor); } if (message.totalShares !== undefined) { Coin.encode(message.totalShares, writer.uint32(42).fork()).ldelim(); } for (const v of message.poolAssets) { PoolAsset.encode(v!, writer.uint32(50).fork()).ldelim(); } if (message.totalWeight !== "") { writer.uint32(58).string(message.totalWeight); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Pool { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePool(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.address = reader.string(); break; case 2: message.id = (reader.uint64() as Long); break; case 3: message.poolParams = PoolParams.decode(reader, reader.uint32()); break; case 4: message.futurePoolGovernor = reader.string(); break; case 5: message.totalShares = Coin.decode(reader, reader.uint32()); break; case 6: message.poolAssets.push(PoolAsset.decode(reader, reader.uint32())); break; case 7: message.totalWeight = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromPartial(object: DeepPartial): Pool { const message = createBasePool(); message.address = object.address ?? ""; message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; message.poolParams = object.poolParams !== undefined && object.poolParams !== null ? PoolParams.fromPartial(object.poolParams) : undefined; message.futurePoolGovernor = object.futurePoolGovernor ?? ""; message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? Coin.fromPartial(object.totalShares) : undefined; message.poolAssets = object.poolAssets?.map(e => PoolAsset.fromPartial(e)) || []; message.totalWeight = object.totalWeight ?? ""; return message; } };