carbon-js-sdk 0.3.43-dev.3 → 0.3.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CarbonSDK.js +2 -2
- package/lib/codec/broker/amm.d.ts +1 -1
- package/lib/codec/broker/amm.js +18 -16
- package/lib/codec/index.d.ts +12 -15
- package/lib/codec/index.js +37 -56
- package/lib/codec/liquiditypool/event.d.ts +0 -14
- package/lib/codec/liquiditypool/event.js +1 -107
- package/lib/codec/liquiditypool/genesis.d.ts +1 -2
- package/lib/codec/liquiditypool/genesis.js +2 -17
- package/lib/codec/liquiditypool/liquiditypool.d.ts +0 -40
- package/lib/codec/liquiditypool/liquiditypool.js +2 -320
- package/lib/codec/liquiditypool/proposal.d.ts +25 -37
- package/lib/codec/liquiditypool/proposal.js +61 -139
- package/lib/codec/liquiditypool/query.d.ts +24 -85
- package/lib/codec/liquiditypool/query.js +23 -338
- package/lib/codec/liquiditypool/tx.d.ts +67 -101
- package/lib/codec/liquiditypool/tx.js +597 -817
- package/lib/codec/order/order.d.ts +0 -1
- package/lib/codec/order/order.js +1 -45
- package/lib/modules/admin.d.ts +2 -0
- package/lib/modules/admin.js +26 -0
- package/lib/modules/coin.d.ts +0 -19
- package/lib/modules/coin.js +0 -39
- package/lib/modules/gov.js +14 -0
- package/lib/modules/liquiditypool.d.ts +2 -11
- package/lib/modules/liquiditypool.js +2 -33
- package/lib/modules/market.d.ts +0 -11
- package/lib/modules/market.js +0 -19
- package/lib/provider/amino/types/admin.js +4 -0
- package/lib/provider/amino/types/coin.js +2 -2
- package/lib/provider/amino/types/gov.js +36 -0
- package/lib/provider/amino/types/liquidityPool.js +2 -0
- package/lib/provider/keplr/KeplrAccount.d.ts +2 -0
- package/lib/provider/keplr/KeplrAccount.js +37 -8
- package/lib/util/blockchain.js +10 -0
- package/lib/util/gov.d.ts +2 -0
- package/lib/util/gov.js +6 -0
- package/lib/util/tx.d.ts +6 -9
- package/lib/wallet/CarbonWallet.js +2 -2
- package/lib/websocket/models.d.ts +2 -7
- package/package.json +1 -1
package/lib/codec/order/order.js
CHANGED
|
@@ -163,16 +163,12 @@ exports.Order = {
|
|
|
163
163
|
if (message.referralKickback !== 0) {
|
|
164
164
|
writer.uint32(208).uint32(message.referralKickback);
|
|
165
165
|
}
|
|
166
|
-
if (message.poolRoute.length !== 0) {
|
|
167
|
-
writer.uint32(218).bytes(message.poolRoute);
|
|
168
|
-
}
|
|
169
166
|
return writer;
|
|
170
167
|
},
|
|
171
168
|
decode(input, length) {
|
|
172
169
|
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
173
170
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
174
171
|
const message = Object.assign({}, baseOrder);
|
|
175
|
-
message.poolRoute = new Uint8Array();
|
|
176
172
|
while (reader.pos < end) {
|
|
177
173
|
const tag = reader.uint32();
|
|
178
174
|
switch (tag >>> 3) {
|
|
@@ -254,9 +250,6 @@ exports.Order = {
|
|
|
254
250
|
case 26:
|
|
255
251
|
message.referralKickback = reader.uint32();
|
|
256
252
|
break;
|
|
257
|
-
case 27:
|
|
258
|
-
message.poolRoute = reader.bytes();
|
|
259
|
-
break;
|
|
260
253
|
default:
|
|
261
254
|
reader.skipType(tag & 7);
|
|
262
255
|
break;
|
|
@@ -370,10 +363,6 @@ exports.Order = {
|
|
|
370
363
|
object.referralKickback !== undefined && object.referralKickback !== null
|
|
371
364
|
? Number(object.referralKickback)
|
|
372
365
|
: 0;
|
|
373
|
-
message.poolRoute =
|
|
374
|
-
object.poolRoute !== undefined && object.poolRoute !== null
|
|
375
|
-
? bytesFromBase64(object.poolRoute)
|
|
376
|
-
: new Uint8Array();
|
|
377
366
|
return message;
|
|
378
367
|
},
|
|
379
368
|
toJSON(message) {
|
|
@@ -419,12 +408,10 @@ exports.Order = {
|
|
|
419
408
|
(obj.referralCommission = message.referralCommission);
|
|
420
409
|
message.referralKickback !== undefined &&
|
|
421
410
|
(obj.referralKickback = message.referralKickback);
|
|
422
|
-
message.poolRoute !== undefined &&
|
|
423
|
-
(obj.poolRoute = base64FromBytes(message.poolRoute !== undefined ? message.poolRoute : new Uint8Array()));
|
|
424
411
|
return obj;
|
|
425
412
|
},
|
|
426
413
|
fromPartial(object) {
|
|
427
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
414
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
428
415
|
const message = Object.assign({}, baseOrder);
|
|
429
416
|
message.id = (_a = object.id) !== null && _a !== void 0 ? _a : "";
|
|
430
417
|
message.blockHeight =
|
|
@@ -465,7 +452,6 @@ exports.Order = {
|
|
|
465
452
|
message.referralAddress = (_v = object.referralAddress) !== null && _v !== void 0 ? _v : "";
|
|
466
453
|
message.referralCommission = (_w = object.referralCommission) !== null && _w !== void 0 ? _w : 0;
|
|
467
454
|
message.referralKickback = (_x = object.referralKickback) !== null && _x !== void 0 ? _x : 0;
|
|
468
|
-
message.poolRoute = (_y = object.poolRoute) !== null && _y !== void 0 ? _y : new Uint8Array();
|
|
469
455
|
return message;
|
|
470
456
|
},
|
|
471
457
|
};
|
|
@@ -801,36 +787,6 @@ exports.Orders = {
|
|
|
801
787
|
return message;
|
|
802
788
|
},
|
|
803
789
|
};
|
|
804
|
-
var globalThis = (() => {
|
|
805
|
-
if (typeof globalThis !== "undefined")
|
|
806
|
-
return globalThis;
|
|
807
|
-
if (typeof self !== "undefined")
|
|
808
|
-
return self;
|
|
809
|
-
if (typeof window !== "undefined")
|
|
810
|
-
return window;
|
|
811
|
-
if (typeof global !== "undefined")
|
|
812
|
-
return global;
|
|
813
|
-
throw "Unable to locate global object";
|
|
814
|
-
})();
|
|
815
|
-
const atob = globalThis.atob ||
|
|
816
|
-
((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
|
|
817
|
-
function bytesFromBase64(b64) {
|
|
818
|
-
const bin = atob(b64);
|
|
819
|
-
const arr = new Uint8Array(bin.length);
|
|
820
|
-
for (let i = 0; i < bin.length; ++i) {
|
|
821
|
-
arr[i] = bin.charCodeAt(i);
|
|
822
|
-
}
|
|
823
|
-
return arr;
|
|
824
|
-
}
|
|
825
|
-
const btoa = globalThis.btoa ||
|
|
826
|
-
((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
|
|
827
|
-
function base64FromBytes(arr) {
|
|
828
|
-
const bin = [];
|
|
829
|
-
for (const byte of arr) {
|
|
830
|
-
bin.push(String.fromCharCode(byte));
|
|
831
|
-
}
|
|
832
|
-
return btoa(bin.join(""));
|
|
833
|
-
}
|
|
834
790
|
function toTimestamp(date) {
|
|
835
791
|
const seconds = numberToLong(date.getTime() / 1000);
|
|
836
792
|
const nanos = (date.getTime() % 1000) * 1000000;
|
package/lib/modules/admin.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export declare class AdminModule extends BaseModule {
|
|
|
16
16
|
linkToken(params: AdminModule.LinkTokenParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
17
17
|
createMarket(params: AdminModule.CreateMarketParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
18
18
|
createMarkets(params: AdminModule.CreateMarketParams[], opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
19
|
+
linkPool(params: AdminModule.LinkPoolParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
20
|
+
unlinkPool(params: AdminModule.UnlinkPoolParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
19
21
|
setRewardsWeights(params: AdminModule.SetRewardsWeightsParams[], opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
20
22
|
setRewardCurve(params: AdminModule.SetRewardCurveParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
21
23
|
setCommitmentCurve(params: AdminModule.SetCommitmentCurveParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
package/lib/modules/admin.js
CHANGED
|
@@ -172,6 +172,32 @@ class AdminModule extends base_1.default {
|
|
|
172
172
|
return yield wallet.sendTxs(msgs, opts);
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
+
linkPool(params, opts) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
const wallet = this.getWallet();
|
|
178
|
+
const value = tx_4.MsgLinkPool.fromPartial({
|
|
179
|
+
creator: wallet.bech32Address,
|
|
180
|
+
linkPoolParams: transfromLinkPoolParams(params),
|
|
181
|
+
});
|
|
182
|
+
return yield wallet.sendTx({
|
|
183
|
+
typeUrl: util_1.CarbonTx.Types.MsgLinkPool,
|
|
184
|
+
value,
|
|
185
|
+
}, opts);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
unlinkPool(params, opts) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const wallet = this.getWallet();
|
|
191
|
+
const value = tx_4.MsgUnlinkPool.fromPartial({
|
|
192
|
+
creator: wallet.bech32Address,
|
|
193
|
+
unlinkPoolParams: transfromUnlinkPoolParams(params),
|
|
194
|
+
});
|
|
195
|
+
return yield wallet.sendTx({
|
|
196
|
+
typeUrl: util_1.CarbonTx.Types.MsgUnlinkPool,
|
|
197
|
+
value,
|
|
198
|
+
}, opts);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
175
201
|
setRewardsWeights(params, opts) {
|
|
176
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
203
|
const wallet = this.getWallet();
|
package/lib/modules/coin.d.ts
CHANGED
|
@@ -2,15 +2,12 @@ import { Coin } from "../codec/cosmos/base/v1beta1/coin";
|
|
|
2
2
|
import { CarbonTx } from "../util";
|
|
3
3
|
import BigNumber from "bignumber.js";
|
|
4
4
|
import BaseModule from "./base";
|
|
5
|
-
import Long from "long";
|
|
6
5
|
export declare class CoinModule extends BaseModule {
|
|
7
6
|
createWithdrawal(params: CoinModule.CreateWithdrawalParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
8
7
|
mintToken(params: CoinModule.MintTokenParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
9
8
|
depositToGroup(params: CoinModule.DepositToGroupParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
10
9
|
convertToGroup(params: CoinModule.DepositToGroupParams[], opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
11
10
|
withdrawFromGroup(params: CoinModule.WithdrawFromGroupParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
12
|
-
addBridgeAddress(params: CoinModule.AddBridgeAddressParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
13
|
-
createToken(params: CoinModule.CreateTokenParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
14
11
|
}
|
|
15
12
|
export declare namespace CoinModule {
|
|
16
13
|
interface CreateWithdrawalParams {
|
|
@@ -34,20 +31,4 @@ export declare namespace CoinModule {
|
|
|
34
31
|
creator?: string;
|
|
35
32
|
sourceCoin: Coin;
|
|
36
33
|
}
|
|
37
|
-
interface AddBridgeAddressParams {
|
|
38
|
-
creator?: string;
|
|
39
|
-
chainId: Long;
|
|
40
|
-
bridgeId: Long;
|
|
41
|
-
bridgeAddress: string;
|
|
42
|
-
}
|
|
43
|
-
interface CreateTokenParams {
|
|
44
|
-
creator?: string;
|
|
45
|
-
name: string;
|
|
46
|
-
symbol: string;
|
|
47
|
-
decimals: Long;
|
|
48
|
-
chainId: Long;
|
|
49
|
-
bridgeId: Long;
|
|
50
|
-
bridgeAddress: string;
|
|
51
|
-
tokenAddress: string;
|
|
52
|
-
}
|
|
53
34
|
}
|
package/lib/modules/coin.js
CHANGED
|
@@ -94,44 +94,5 @@ class CoinModule extends base_1.default {
|
|
|
94
94
|
}, opts);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
-
addBridgeAddress(params, opts) {
|
|
98
|
-
var _a;
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const wallet = this.getWallet();
|
|
101
|
-
const value = tx_1.MsgAddBridgeAddress.fromPartial({
|
|
102
|
-
creator: (_a = params.creator) !== null && _a !== void 0 ? _a : wallet.bech32Address,
|
|
103
|
-
chainId: params.chainId,
|
|
104
|
-
bridgeId: params.bridgeId,
|
|
105
|
-
bridgeAddress: params.bridgeAddress,
|
|
106
|
-
});
|
|
107
|
-
return yield wallet.sendTx({
|
|
108
|
-
typeUrl: util_1.CarbonTx.Types.MsgAddBridgeAddress,
|
|
109
|
-
value,
|
|
110
|
-
}, opts);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
createToken(params, opts) {
|
|
114
|
-
var _a, _b;
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const wallet = this.getWallet();
|
|
117
|
-
const value = tx_1.MsgCreateToken.fromPartial({
|
|
118
|
-
creator: (_a = params.creator) !== null && _a !== void 0 ? _a : wallet.bech32Address,
|
|
119
|
-
createTokenParams: {
|
|
120
|
-
creator: (_b = params.creator) !== null && _b !== void 0 ? _b : wallet.bech32Address,
|
|
121
|
-
name: params.name,
|
|
122
|
-
symbol: params.symbol,
|
|
123
|
-
decimals: params.decimals,
|
|
124
|
-
chainId: params.chainId,
|
|
125
|
-
bridgeId: params.bridgeId,
|
|
126
|
-
bridgeAddress: params.bridgeAddress,
|
|
127
|
-
tokenAddress: params.tokenAddress,
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return yield wallet.sendTx({
|
|
131
|
-
typeUrl: util_1.CarbonTx.Types.MsgCreateToken,
|
|
132
|
-
value,
|
|
133
|
-
}, opts);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
97
|
}
|
|
137
98
|
exports.CoinModule = CoinModule;
|
package/lib/modules/gov.js
CHANGED
|
@@ -109,6 +109,20 @@ class GovModule extends base_1.default {
|
|
|
109
109
|
denom: proposalMsg.denom,
|
|
110
110
|
};
|
|
111
111
|
return proposal_2.RemoveMinGasPriceProposal.encode(removeMinGasPriceMsg).finish();
|
|
112
|
+
case "LinkPoolProposal":
|
|
113
|
+
const linkPoolMsg = {
|
|
114
|
+
title: title,
|
|
115
|
+
description: description,
|
|
116
|
+
msg: admin_1.transfromLinkPoolParams(msg),
|
|
117
|
+
};
|
|
118
|
+
return proposal_3.LinkPoolProposal.encode(linkPoolMsg).finish();
|
|
119
|
+
case "UnlinkPoolProposal":
|
|
120
|
+
const unlinkPoolMsg = {
|
|
121
|
+
title: title,
|
|
122
|
+
description: description,
|
|
123
|
+
msg: admin_1.transfromUnlinkPoolParams(msg),
|
|
124
|
+
};
|
|
125
|
+
return proposal_3.UnlinkPoolProposal.encode(unlinkPoolMsg).finish();
|
|
112
126
|
case "SetRewardCurveProposal":
|
|
113
127
|
const setRewardCurveMsg = {
|
|
114
128
|
title: title,
|
|
@@ -18,8 +18,6 @@ export declare class LiquidityPoolModule extends BaseModule {
|
|
|
18
18
|
*/
|
|
19
19
|
getWeeklyRewards(): Promise<BigNumber>;
|
|
20
20
|
claimMultiPoolRewards(params: LiquidityPoolModule.ClaimMultiPoolRewards, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
21
|
-
createPoolRoute(params: LiquidityPoolModule.CreatePoolRouteParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
22
|
-
removePoolRoute(params: LiquidityPoolModule.RemovePoolRouteParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
23
21
|
}
|
|
24
22
|
export declare namespace LiquidityPoolModule {
|
|
25
23
|
interface CreatePoolParams {
|
|
@@ -29,6 +27,7 @@ export declare namespace LiquidityPoolModule {
|
|
|
29
27
|
tokenBWeight: BigNumber;
|
|
30
28
|
swapFee: BigNumber;
|
|
31
29
|
ampBps: Long;
|
|
30
|
+
numQuotes: number;
|
|
32
31
|
}
|
|
33
32
|
interface CreatePoolWithLiquidityParams {
|
|
34
33
|
tokenADenom: string;
|
|
@@ -39,6 +38,7 @@ export declare namespace LiquidityPoolModule {
|
|
|
39
38
|
amountB: BigNumber;
|
|
40
39
|
swapFee: BigNumber;
|
|
41
40
|
ampBps: Long;
|
|
41
|
+
numQuotes: number;
|
|
42
42
|
}
|
|
43
43
|
interface AddLiquidityParams {
|
|
44
44
|
poolId: number;
|
|
@@ -73,13 +73,4 @@ export declare namespace LiquidityPoolModule {
|
|
|
73
73
|
poolId: string;
|
|
74
74
|
address: string;
|
|
75
75
|
}
|
|
76
|
-
interface CreatePoolRouteParams {
|
|
77
|
-
marketName: string;
|
|
78
|
-
poolIds: Long[];
|
|
79
|
-
numQuotes: Long;
|
|
80
|
-
}
|
|
81
|
-
interface RemovePoolRouteParams {
|
|
82
|
-
marketName: string;
|
|
83
|
-
poolIds: Long[];
|
|
84
|
-
}
|
|
85
76
|
}
|
|
@@ -31,6 +31,7 @@ class LiquidityPoolModule extends base_1.default {
|
|
|
31
31
|
tokenBWeight: params.tokenBWeight.shiftedBy(18).toString(10),
|
|
32
32
|
swapFee: params.swapFee.shiftedBy(18).toString(10),
|
|
33
33
|
ampBps: params.ampBps,
|
|
34
|
+
numQuotes: new long_1.default(params.numQuotes),
|
|
34
35
|
});
|
|
35
36
|
return yield wallet.sendTx({
|
|
36
37
|
typeUrl: util_1.CarbonTx.Types.MsgCreatePool,
|
|
@@ -51,6 +52,7 @@ class LiquidityPoolModule extends base_1.default {
|
|
|
51
52
|
amountB: params.amountB.toString(10),
|
|
52
53
|
swapFee: params.swapFee.shiftedBy(18).toString(10),
|
|
53
54
|
ampBps: params.ampBps,
|
|
55
|
+
numQuotes: new long_1.default(params.numQuotes),
|
|
54
56
|
});
|
|
55
57
|
return yield wallet.sendTx({
|
|
56
58
|
typeUrl: util_1.CarbonTx.Types.MsgCreatePoolWithLiquidity,
|
|
@@ -175,38 +177,5 @@ class LiquidityPoolModule extends base_1.default {
|
|
|
175
177
|
})), opts);
|
|
176
178
|
});
|
|
177
179
|
}
|
|
178
|
-
createPoolRoute(params, opts) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const wallet = this.getWallet();
|
|
181
|
-
const value = index_1.Models.MsgCreatePoolRoute.fromPartial({
|
|
182
|
-
creator: wallet.bech32Address,
|
|
183
|
-
createPoolRouteParams: {
|
|
184
|
-
marketName: params.marketName,
|
|
185
|
-
poolIds: params.poolIds,
|
|
186
|
-
numQuotes: params.numQuotes,
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return yield wallet.sendTx({
|
|
190
|
-
typeUrl: util_1.CarbonTx.Types.MsgCreatePoolRoute,
|
|
191
|
-
value,
|
|
192
|
-
}, opts);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
removePoolRoute(params, opts) {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
const wallet = this.getWallet();
|
|
198
|
-
const value = index_1.Models.MsgRemovePoolRoute.fromPartial({
|
|
199
|
-
creator: wallet.bech32Address,
|
|
200
|
-
removePoolRouteParams: {
|
|
201
|
-
marketName: params.marketName,
|
|
202
|
-
poolIds: params.poolIds,
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
return yield wallet.sendTx({
|
|
206
|
-
typeUrl: util_1.CarbonTx.Types.MsgRemovePoolRoute,
|
|
207
|
-
value,
|
|
208
|
-
}, opts);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
180
|
}
|
|
212
181
|
exports.LiquidityPoolModule = LiquidityPoolModule;
|
package/lib/modules/market.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { BigNumber } from "bignumber.js";
|
|
|
4
4
|
import { Duration } from "../codec/google/protobuf/duration";
|
|
5
5
|
export declare class MarketModule extends BaseModule {
|
|
6
6
|
update(params: MarketModule.UpdateMarketParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
7
|
-
createMarket(params: MarketModule.CreateMarketParams, opts?: CarbonTx.SignTxOpts): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
8
7
|
}
|
|
9
8
|
export declare namespace MarketModule {
|
|
10
9
|
interface UpdateMarketParams {
|
|
@@ -28,16 +27,6 @@ export declare namespace MarketModule {
|
|
|
28
27
|
lastPriceProtectedBand?: number;
|
|
29
28
|
isActive?: boolean;
|
|
30
29
|
}
|
|
31
|
-
interface CreateMarketParams {
|
|
32
|
-
creator: string;
|
|
33
|
-
marketType: string;
|
|
34
|
-
base: string;
|
|
35
|
-
quote: string;
|
|
36
|
-
currentBasePriceUsd: string;
|
|
37
|
-
currentQuotePriceUsd: string;
|
|
38
|
-
indexOracleId: string;
|
|
39
|
-
expiryTime?: Date;
|
|
40
|
-
}
|
|
41
30
|
}
|
|
42
31
|
export declare function transfromUpdateMarketParams(msg: MarketModule.UpdateMarketParams): {
|
|
43
32
|
name: string;
|
package/lib/modules/market.js
CHANGED
|
@@ -30,25 +30,6 @@ class MarketModule extends base_1.default {
|
|
|
30
30
|
}, opts);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
createMarket(params, opts) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const wallet = this.getWallet();
|
|
36
|
-
const value = tx_1.MsgCreateMarket.fromPartial({
|
|
37
|
-
creator: params.creator,
|
|
38
|
-
marketType: params.marketType,
|
|
39
|
-
base: params.base,
|
|
40
|
-
quote: params.quote,
|
|
41
|
-
currentBasePriceUsd: params.currentBasePriceUsd,
|
|
42
|
-
currentQuotePriceUsd: params.currentQuotePriceUsd,
|
|
43
|
-
indexOracleId: params.indexOracleId,
|
|
44
|
-
expiryTime: params.expiryTime,
|
|
45
|
-
});
|
|
46
|
-
return yield wallet.sendTx({
|
|
47
|
-
typeUrl: util_1.CarbonTx.Types.MsgCreateMarket,
|
|
48
|
-
value,
|
|
49
|
-
}, opts);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
33
|
}
|
|
53
34
|
exports.MarketModule = MarketModule;
|
|
54
35
|
function transfromUpdateMarketParams(msg) {
|
|
@@ -29,6 +29,8 @@ const TxTypes = {
|
|
|
29
29
|
SyncToken: "carbon/MsgSyncToken",
|
|
30
30
|
CreateMarket: "market/CreateMarket",
|
|
31
31
|
CreateVaultType: "cdp/CreateVaultType",
|
|
32
|
+
LinkPool: "liquiditypool/LinkPool",
|
|
33
|
+
UnlinkPool: "liquiditypool/UnlinkPool",
|
|
32
34
|
ChangeSwapFee: "liquiditypool/ChangeSwapFee",
|
|
33
35
|
SetRewardsWeights: "liquiditypool/SetRewardsWeights",
|
|
34
36
|
SetRewardCurve: "liquiditypool/SetRewardCurve",
|
|
@@ -237,6 +239,8 @@ const AdminAmino = {
|
|
|
237
239
|
[CarbonTx.Types.MsgLinkToken]: utils_1.generateAminoType(MsgLinkToken),
|
|
238
240
|
[CarbonTx.Types.MsgSyncToken]: utils_1.generateAminoType(MsgSyncToken),
|
|
239
241
|
[CarbonTx.Types.MsgCreateMarket]: utils_1.generateAminoType(MsgCreateMarket),
|
|
242
|
+
[CarbonTx.Types.MsgLinkPool]: utils_1.generateAminoType(MsgLinkPool),
|
|
243
|
+
[CarbonTx.Types.MsgUnlinkPool]: utils_1.generateAminoType(MsgUnlinkPool),
|
|
240
244
|
[CarbonTx.Types.MsgUpdatePool]: utils_1.generateAminoType(MsgUpdatePool),
|
|
241
245
|
[CarbonTx.Types.MsgSetRewardsWeights]: utils_1.generateAminoType(MsgSetRewardsWeights),
|
|
242
246
|
[CarbonTx.Types.MsgSetRewardCurve]: utils_1.generateAminoType(MsgSetRewardCurve),
|
|
@@ -24,8 +24,8 @@ const utils_1 = require("../utils");
|
|
|
24
24
|
const TxTypes = {
|
|
25
25
|
MintToken: "carbon/MsgMintToken",
|
|
26
26
|
Withdraw: "carbon/MsgWithdraw",
|
|
27
|
-
DepositToGroup: "
|
|
28
|
-
WithdrawFromGroup: "
|
|
27
|
+
DepositToGroup: "coin/DepositToGroup",
|
|
28
|
+
WithdrawFromGroup: "coin/WithdrawFromGroup",
|
|
29
29
|
};
|
|
30
30
|
const MsgWithdraw = {
|
|
31
31
|
aminoType: TxTypes.Withdraw,
|
|
@@ -38,6 +38,8 @@ const ContentTypes = {
|
|
|
38
38
|
[util_1.GovUtils.ProposalTypes.SetRewardCurve]: "liquiditypool/SetRewardCurveProposal",
|
|
39
39
|
[util_1.GovUtils.ProposalTypes.SetRewardsWeights]: "liquiditypool/SetRewardsWeightsProposal",
|
|
40
40
|
[util_1.GovUtils.ProposalTypes.UpdatePool]: "liquiditypool/UpdatePoolProposal",
|
|
41
|
+
[util_1.GovUtils.ProposalTypes.LinkPool]: "liquiditypool/LinkPoolProposal",
|
|
42
|
+
[util_1.GovUtils.ProposalTypes.UnlinkPool]: "liquiditypool/UnlinkPoolProposal",
|
|
41
43
|
[util_1.GovUtils.ProposalTypes.UpdateMarket]: "market/UpdateMarketProposal",
|
|
42
44
|
[util_1.GovUtils.ProposalTypes.CreateOracle]: "oracle/CreateOracleProposal",
|
|
43
45
|
[util_1.GovUtils.ProposalTypes.SettlementPrice]: "pricing/SettlementPriceProposal",
|
|
@@ -142,6 +144,14 @@ const UpdateGroupConfig = {
|
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
};
|
|
147
|
+
const ChangeNumQuotes = {
|
|
148
|
+
value: {
|
|
149
|
+
msg: {
|
|
150
|
+
poolId: utils_1.ConvertEncType.Long,
|
|
151
|
+
numQuotes: utils_1.ConvertEncType.Long,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
145
155
|
const UpdatePool = {
|
|
146
156
|
value: {
|
|
147
157
|
msg: {
|
|
@@ -275,6 +285,12 @@ const checkDecodeProposal = (content, amino) => {
|
|
|
275
285
|
case util_1.GovUtils.ProposalTypes.CreateOracle:
|
|
276
286
|
newAmino.content = Object.assign({}, CreateOracle);
|
|
277
287
|
break;
|
|
288
|
+
case util_1.GovUtils.ProposalTypes.LinkPool:
|
|
289
|
+
newAmino.content = Object.assign({}, LinkPool);
|
|
290
|
+
break;
|
|
291
|
+
case util_1.GovUtils.ProposalTypes.UnlinkPool:
|
|
292
|
+
newAmino.content = Object.assign({}, UnlinkPool);
|
|
293
|
+
break;
|
|
278
294
|
case util_1.GovUtils.ProposalTypes.UpdateMarket:
|
|
279
295
|
newAmino.content = Object.assign({}, UpdateMarket);
|
|
280
296
|
break;
|
|
@@ -398,6 +414,26 @@ const checkEncodeProposal = (content, amino) => {
|
|
|
398
414
|
},
|
|
399
415
|
newAmino: Object.assign({}, amino),
|
|
400
416
|
};
|
|
417
|
+
case ContentTypes[util_1.GovUtils.ProposalTypes.LinkPool]:
|
|
418
|
+
const linkPoolMsg = preProcessAmino(content.value.msg, LinkPool.value.msg);
|
|
419
|
+
const linkPoolProp = codec_1.LinkPoolProposal.fromPartial(Object.assign(Object.assign({}, content.value), { msg: linkPoolMsg }));
|
|
420
|
+
return {
|
|
421
|
+
newContent: {
|
|
422
|
+
typeUrl: util_1.GovUtils.ProposalTypes.LinkPool,
|
|
423
|
+
value: codec_1.LinkPoolProposal.encode(linkPoolProp).finish(),
|
|
424
|
+
},
|
|
425
|
+
newAmino: Object.assign({}, amino),
|
|
426
|
+
};
|
|
427
|
+
case ContentTypes[util_1.GovUtils.ProposalTypes.UnlinkPool]:
|
|
428
|
+
const unlinkPoolMsg = preProcessAmino(content.value.msg, UnlinkPool.value.msg);
|
|
429
|
+
const unlinkPoolProp = codec_1.LinkPoolProposal.fromPartial(Object.assign(Object.assign({}, content.value), { msg: unlinkPoolMsg }));
|
|
430
|
+
return {
|
|
431
|
+
newContent: {
|
|
432
|
+
typeUrl: util_1.GovUtils.ProposalTypes.UnlinkPool,
|
|
433
|
+
value: codec_1.UnlinkPoolProposal.encode(unlinkPoolProp).finish(),
|
|
434
|
+
},
|
|
435
|
+
newAmino: Object.assign({}, amino),
|
|
436
|
+
};
|
|
401
437
|
case ContentTypes[util_1.GovUtils.ProposalTypes.UpdateMarket]:
|
|
402
438
|
const updateMarketMsg = preProcessAmino(content.value.msg, UpdateMarket.value.msg);
|
|
403
439
|
const updateMarketProp = codec_1.UpdateMarketProposal.fromPartial(Object.assign(Object.assign({}, content.value), { msg: updateMarketMsg }));
|
|
@@ -33,6 +33,7 @@ const TxTypes = {
|
|
|
33
33
|
const MsgCreatePool = {
|
|
34
34
|
aminoType: TxTypes.CreatePool,
|
|
35
35
|
valueMap: {
|
|
36
|
+
numQuotes: utils_1.ConvertEncType.Long,
|
|
36
37
|
swapFee: utils_1.ConvertEncType.Dec,
|
|
37
38
|
tokenAWeight: utils_1.ConvertEncType.Dec,
|
|
38
39
|
tokenBWeight: utils_1.ConvertEncType.Dec,
|
|
@@ -45,6 +46,7 @@ const MsgCreatePoolWithLiquidity = {
|
|
|
45
46
|
tokenAWeight: utils_1.ConvertEncType.Dec,
|
|
46
47
|
tokenBWeight: utils_1.ConvertEncType.Dec,
|
|
47
48
|
swapFee: utils_1.ConvertEncType.Dec,
|
|
49
|
+
numQuotes: utils_1.ConvertEncType.Long,
|
|
48
50
|
ampBps: utils_1.ConvertEncType.Long,
|
|
49
51
|
},
|
|
50
52
|
};
|
|
@@ -16,6 +16,8 @@ declare class KeplrAccount {
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
};
|
|
18
18
|
static createKeplrSigner(keplr: Keplr, chainInfo: ChainInfo, account: Key): CarbonSigner;
|
|
19
|
+
static queryFeeCurrencies(configProvider: SDKProvider): Promise<FeeCurrency[]>;
|
|
20
|
+
static processCurrencies(feeCurrencies: FeeCurrency[]): AppCurrency[];
|
|
19
21
|
static getChainInfo(configProvider: SDKProvider): Promise<ChainInfo>;
|
|
20
22
|
}
|
|
21
23
|
declare namespace KeplrAccount { }
|
|
@@ -45,14 +45,12 @@ class KeplrAccount {
|
|
|
45
45
|
getAccounts,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
static
|
|
48
|
+
static queryFeeCurrencies(configProvider) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const config = configProvider.getConfig();
|
|
51
|
-
const bech32Prefix = config.Bech32Prefix;
|
|
52
|
-
const chainId = yield configProvider.query.chain.getChainId();
|
|
53
|
-
const gasPricesResult = yield configProvider.query.fee.MinGasPriceAll({});
|
|
54
50
|
const tokenClient = configProvider.getTokenClient();
|
|
55
51
|
const coingeckoIdMap = tokenClient.geckoTokenNames;
|
|
52
|
+
// Query minGasPrices from on-chain (for testnet/devnet/localhost)
|
|
53
|
+
const gasPricesResult = yield configProvider.query.fee.MinGasPriceAll({});
|
|
56
54
|
const feeCurrencies = gasPricesResult.minGasPrices.reduce((result, price) => {
|
|
57
55
|
var _a, _b, _c;
|
|
58
56
|
const token = tokenClient.tokenForDenom(price.denom);
|
|
@@ -76,14 +74,45 @@ class KeplrAccount {
|
|
|
76
74
|
});
|
|
77
75
|
return result;
|
|
78
76
|
}, []);
|
|
77
|
+
return feeCurrencies;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
static processCurrencies(feeCurrencies) {
|
|
81
|
+
return feeCurrencies.reduce((prevCurrencies, feeCurrency) => {
|
|
82
|
+
const currentFeeCurrency = {
|
|
83
|
+
coinDenom: feeCurrency.coinDenom,
|
|
84
|
+
coinMinimalDenom: feeCurrency.coinMinimalDenom,
|
|
85
|
+
coinDecimals: feeCurrency.coinDecimals,
|
|
86
|
+
coinGeckoId: feeCurrency.coinGeckoId,
|
|
87
|
+
};
|
|
88
|
+
prevCurrencies.push(currentFeeCurrency);
|
|
89
|
+
return prevCurrencies;
|
|
90
|
+
}, []);
|
|
91
|
+
}
|
|
92
|
+
static getChainInfo(configProvider) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const config = configProvider.getConfig();
|
|
95
|
+
const bech32Prefix = config.Bech32Prefix;
|
|
96
|
+
const chainId = yield configProvider.query.chain.getChainId();
|
|
97
|
+
// Query fee currencies from keplr-chain-registry
|
|
98
|
+
const keplrChainInfo = yield (yield util_1.FetchUtils.fetch("https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/master/cosmos/carbon.json")).json();
|
|
99
|
+
if (config.network === constant_1.Network.MainNet) {
|
|
100
|
+
if (keplrChainInfo.nodeProvider) {
|
|
101
|
+
delete keplrChainInfo.nodeProvider;
|
|
102
|
+
}
|
|
103
|
+
return keplrChainInfo;
|
|
104
|
+
}
|
|
105
|
+
const feeCurrencies = yield this.queryFeeCurrencies(configProvider);
|
|
106
|
+
const networkFees = [KeplrAccount.SWTH_CURRENCY, ...feeCurrencies];
|
|
107
|
+
const currencies = this.processCurrencies(networkFees);
|
|
79
108
|
return {
|
|
80
|
-
feeCurrencies:
|
|
109
|
+
feeCurrencies: networkFees,
|
|
81
110
|
bip44: KeplrAccount.BASE_CHAIN_INFO.bip44,
|
|
82
|
-
currencies:
|
|
111
|
+
currencies: currencies,
|
|
83
112
|
stakeCurrency: KeplrAccount.SWTH_CURRENCY,
|
|
84
113
|
rest: config.restUrl,
|
|
85
114
|
rpc: config.tmRpcUrl,
|
|
86
|
-
chainName:
|
|
115
|
+
chainName: `Carbon (${config.network})`,
|
|
87
116
|
chainId: chainId,
|
|
88
117
|
bech32Config: {
|
|
89
118
|
bech32PrefixAccAddr: `${bech32Prefix}`,
|
package/lib/util/blockchain.js
CHANGED
|
@@ -199,6 +199,7 @@ const blockchainForChainId = (chainId, network = network_1.Network.MainNet) => {
|
|
|
199
199
|
switch (chainId) {
|
|
200
200
|
case 1:
|
|
201
201
|
return Blockchain.Btc;
|
|
202
|
+
case 0:
|
|
202
203
|
case 5:
|
|
203
204
|
return Blockchain.Carbon;
|
|
204
205
|
case 79:
|
|
@@ -215,12 +216,21 @@ const blockchainForChainId = (chainId, network = network_1.Network.MainNet) => {
|
|
|
215
216
|
}
|
|
216
217
|
case network_1.Network.DevNet:
|
|
217
218
|
switch (chainId) {
|
|
219
|
+
case 0:
|
|
220
|
+
return Blockchain.Carbon;
|
|
221
|
+
case 1:
|
|
222
|
+
return Blockchain.Btc;
|
|
223
|
+
case 2:
|
|
218
224
|
case 350:
|
|
219
225
|
return Blockchain.Ethereum;
|
|
220
226
|
case 5:
|
|
221
227
|
return Blockchain.Neo;
|
|
222
228
|
case 79:
|
|
223
229
|
return Blockchain.BinanceSmartChain;
|
|
230
|
+
case 111:
|
|
231
|
+
return Blockchain.Zilliqa;
|
|
232
|
+
default:
|
|
233
|
+
return undefined;
|
|
224
234
|
}
|
|
225
235
|
case network_1.Network.LocalHost:
|
|
226
236
|
return undefined;
|
package/lib/util/gov.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare enum ProposalTypes {
|
|
|
11
11
|
RemoveMinGasPrice = "/Switcheo.carbon.fee.RemoveMinGasPriceProposal",
|
|
12
12
|
CreateToken = "/Switcheo.carbon.coin.CreateTokenProposal",
|
|
13
13
|
CreateOracle = "/Switcheo.carbon.oracle.CreateOracleProposal",
|
|
14
|
+
LinkPool = "/Switcheo.carbon.liquiditypool.LinkPoolProposal",
|
|
15
|
+
UnlinkPool = "/Switcheo.carbon.liquiditypool.UnlinkPoolProposal",
|
|
14
16
|
UpdatePool = "/Switcheo.carbon.liquiditypool.UpdatePoolProposal",
|
|
15
17
|
SetRewardCurve = "/Switcheo.carbon.liquiditypool.SetRewardCurveProposal",
|
|
16
18
|
SetRewardsWeights = "/Switcheo.carbon.liquiditypool.SetRewardsWeightsProposal",
|
package/lib/util/gov.js
CHANGED
|
@@ -19,6 +19,8 @@ var ProposalTypes;
|
|
|
19
19
|
ProposalTypes["RemoveMinGasPrice"] = "/Switcheo.carbon.fee.RemoveMinGasPriceProposal";
|
|
20
20
|
ProposalTypes["CreateToken"] = "/Switcheo.carbon.coin.CreateTokenProposal";
|
|
21
21
|
ProposalTypes["CreateOracle"] = "/Switcheo.carbon.oracle.CreateOracleProposal";
|
|
22
|
+
ProposalTypes["LinkPool"] = "/Switcheo.carbon.liquiditypool.LinkPoolProposal";
|
|
23
|
+
ProposalTypes["UnlinkPool"] = "/Switcheo.carbon.liquiditypool.UnlinkPoolProposal";
|
|
22
24
|
ProposalTypes["UpdatePool"] = "/Switcheo.carbon.liquiditypool.UpdatePoolProposal";
|
|
23
25
|
ProposalTypes["SetRewardCurve"] = "/Switcheo.carbon.liquiditypool.SetRewardCurveProposal";
|
|
24
26
|
ProposalTypes["SetRewardsWeights"] = "/Switcheo.carbon.liquiditypool.SetRewardsWeightsProposal";
|
|
@@ -58,6 +60,8 @@ const decodeContent = (content) => {
|
|
|
58
60
|
return Object.assign(Object.assign({}, content), { value: codec_1.CreateOracleProposal.decode(content.value) });
|
|
59
61
|
case ProposalTypes.CreateToken:
|
|
60
62
|
return Object.assign(Object.assign({}, content), { value: codec_1.CreateTokenProposal.decode(content.value) });
|
|
63
|
+
case ProposalTypes.LinkPool:
|
|
64
|
+
return Object.assign(Object.assign({}, content), { value: codec_1.LinkPoolProposal.decode(content.value) });
|
|
61
65
|
case ProposalTypes.SetCommitmentCurve:
|
|
62
66
|
return Object.assign(Object.assign({}, content), { value: codec_1.SetCommitmentCurveProposal.decode(content.value) });
|
|
63
67
|
case ProposalTypes.SetMsgGasCost:
|
|
@@ -74,6 +78,8 @@ const decodeContent = (content) => {
|
|
|
74
78
|
return Object.assign(Object.assign({}, content), { value: codec_1.SetRewardsWeightsProposal.decode(content.value) });
|
|
75
79
|
case ProposalTypes.SettlementPrice:
|
|
76
80
|
return Object.assign(Object.assign({}, content), { value: codec_1.SettlementPriceProposal.decode(content.value) });
|
|
81
|
+
case ProposalTypes.UnlinkPool:
|
|
82
|
+
return Object.assign(Object.assign({}, content), { value: codec_1.UnlinkPoolProposal.decode(content.value) });
|
|
77
83
|
case ProposalTypes.UpdateMarket:
|
|
78
84
|
return Object.assign(Object.assign({}, content), { value: codec_1.UpdateMarketProposal.decode(content.value) });
|
|
79
85
|
default:
|