carbon-js-sdk 0.11.22 → 0.11.23-beta.2
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.d.ts +2 -1
- package/lib/CarbonSDK.js +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +1 -0
- package/lib/modules/otc.d.ts +17 -0
- package/lib/modules/otc.js +63 -0
- package/lib/provider/amino/AminoTypesMap.js +1 -1
- package/lib/provider/amino/types/index.d.ts +1 -0
- package/lib/provider/amino/types/index.js +3 -1
- package/lib/provider/amino/types/otc.d.ts +4 -0
- package/lib/provider/amino/types/otc.js +48 -0
- package/lib/websocket/channel.js +17 -0
- package/lib/websocket/types.d.ts +10 -2
- package/lib/websocket/types.js +2 -0
- package/package.json +1 -1
package/lib/CarbonSDK.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { CarbonQueryClient, AxelarBridgeClient, ETHClient, HydrogenClient, Insig
|
|
|
6
6
|
import GasFee from "./clients/GasFee";
|
|
7
7
|
import GrpcQueryClient from "./clients/GrpcQueryClient";
|
|
8
8
|
import N3Client from "./clients/N3Client";
|
|
9
|
-
import { AdminModule, AllianceModule, BankModule, BridgeModule, BrokerModule, CDPModule, CoinModule, ERC20Module, EvmMergeModule, EvmModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PerpspoolModule, PositionModule, ProfileModule, SubAccountModule, XChainModule } from "./modules";
|
|
9
|
+
import { AdminModule, AllianceModule, BankModule, BridgeModule, BrokerModule, CDPModule, CoinModule, ERC20Module, EvmMergeModule, EvmModule, FeeModule, GovModule, IBCModule, LeverageModule, LiquidityPoolModule, MarketModule, OracleModule, OrderModule, PerpspoolModule, PositionModule, ProfileModule, SubAccountModule, XChainModule, OTCModule } from "./modules";
|
|
10
10
|
import { GrantModule } from "./modules/grant";
|
|
11
11
|
import { StakingModule } from "./modules/staking";
|
|
12
12
|
import { CosmosLedger, Keplr, LeapExtended } from "./provider";
|
|
@@ -96,6 +96,7 @@ declare class CarbonSDK {
|
|
|
96
96
|
evm: EvmModule;
|
|
97
97
|
evmmerge: EvmMergeModule;
|
|
98
98
|
bridge: BridgeModule;
|
|
99
|
+
otc: OTCModule;
|
|
99
100
|
neo: NEOClient;
|
|
100
101
|
eth: ETHClient;
|
|
101
102
|
bsc: ETHClient;
|
package/lib/CarbonSDK.js
CHANGED
|
@@ -117,6 +117,7 @@ class CarbonSDK {
|
|
|
117
117
|
this.evm = new modules_1.EvmModule(this);
|
|
118
118
|
this.evmmerge = new modules_1.EvmMergeModule(this);
|
|
119
119
|
this.bridge = new modules_1.BridgeModule(this);
|
|
120
|
+
this.otc = new modules_1.OTCModule(this);
|
|
120
121
|
this.neo = clients_1.NEOClient.instance({
|
|
121
122
|
configProvider: this,
|
|
122
123
|
blockchain: blockchain_1.Blockchain.Neo,
|
package/lib/modules/index.d.ts
CHANGED
package/lib/modules/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CarbonTx } from "../util";
|
|
2
|
+
import BaseModule from "./base";
|
|
3
|
+
export declare class OTCModule extends BaseModule {
|
|
4
|
+
createRfq(params: OTCModule.CreateRfqParams, opts?: CarbonTx.SignTxOpts): Promise<import("..").CarbonWallet.SendTxResponse>;
|
|
5
|
+
cancelRfq(rfqId: string, opts?: CarbonTx.SignTxOpts): Promise<import("..").CarbonWallet.SendTxResponse>;
|
|
6
|
+
acceptQuote(quoteId: string, opts?: CarbonTx.SignTxOpts): Promise<import("..").CarbonWallet.SendTxResponse>;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace OTCModule {
|
|
9
|
+
interface CreateRfqParams {
|
|
10
|
+
denoms: {
|
|
11
|
+
denom: string;
|
|
12
|
+
amount: string;
|
|
13
|
+
}[];
|
|
14
|
+
buyDenom: string;
|
|
15
|
+
expiryTime: Date;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OTCModule = void 0;
|
|
16
|
+
const tx_1 = require("../codec/Switcheo/carbon/otc/tx");
|
|
17
|
+
const util_1 = require("../util");
|
|
18
|
+
const base_1 = __importDefault(require("./base"));
|
|
19
|
+
class OTCModule extends base_1.default {
|
|
20
|
+
createRfq(params, opts) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const wallet = this.getWallet();
|
|
23
|
+
const { denoms: sellCoins, buyDenom, expiryTime } = params;
|
|
24
|
+
const value = tx_1.MsgCreateRfq.fromPartial({
|
|
25
|
+
requester: wallet.bech32Address,
|
|
26
|
+
sellCoins,
|
|
27
|
+
buyDenom: buyDenom,
|
|
28
|
+
expiryTime: expiryTime,
|
|
29
|
+
});
|
|
30
|
+
return yield wallet.sendTx({
|
|
31
|
+
typeUrl: util_1.CarbonTx.Types.MsgCreateRfq,
|
|
32
|
+
value,
|
|
33
|
+
}, opts);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
cancelRfq(rfqId, opts) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const wallet = this.getWallet();
|
|
39
|
+
const value = tx_1.MsgCancelRfq.fromPartial({
|
|
40
|
+
requester: wallet.bech32Address,
|
|
41
|
+
id: rfqId,
|
|
42
|
+
});
|
|
43
|
+
return yield wallet.sendTx({
|
|
44
|
+
typeUrl: util_1.CarbonTx.Types.MsgCancelRfq,
|
|
45
|
+
value,
|
|
46
|
+
}, opts);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
acceptQuote(quoteId, opts) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const wallet = this.getWallet();
|
|
52
|
+
const value = tx_1.MsgAcceptQuote.fromPartial({
|
|
53
|
+
requester: wallet.bech32Address,
|
|
54
|
+
id: quoteId,
|
|
55
|
+
});
|
|
56
|
+
return yield wallet.sendTx({
|
|
57
|
+
typeUrl: util_1.CarbonTx.Types.MsgAcceptQuote,
|
|
58
|
+
value,
|
|
59
|
+
}, opts);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.OTCModule = OTCModule;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const stargate_1 = require("@cosmjs/stargate");
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
-
const AminoTypesMap = new stargate_1.AminoTypes(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, types_1.AdminAmino), types_1.BankAmino), types_1.BrokerAmino), types_1.CdpAmino), types_1.CoinAmino), types_1.GovAmino), types_1.IbcAmino), types_1.LeverageAmino), types_1.LiquidityPoolAmino), types_1.MarketAmino), types_1.OracleAmino), types_1.OrderAmino), types_1.PositionAmino), types_1.ProfileAmino), types_1.StakingAmino), types_1.SubAccountAmino), types_1.EvmAmino), types_1.EvmMergeAmino), types_1.FeeMarketAmino), types_1.PerpspoolAmino), types_1.ERC20Amino), types_1.GrantAmino), types_1.BridgeAmino));
|
|
5
|
+
const AminoTypesMap = new stargate_1.AminoTypes(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, types_1.AdminAmino), types_1.BankAmino), types_1.BrokerAmino), types_1.CdpAmino), types_1.CoinAmino), types_1.GovAmino), types_1.IbcAmino), types_1.LeverageAmino), types_1.LiquidityPoolAmino), types_1.MarketAmino), types_1.OracleAmino), types_1.OrderAmino), types_1.PositionAmino), types_1.ProfileAmino), types_1.StakingAmino), types_1.SubAccountAmino), types_1.EvmAmino), types_1.EvmMergeAmino), types_1.FeeMarketAmino), types_1.PerpspoolAmino), types_1.ERC20Amino), types_1.GrantAmino), types_1.BridgeAmino), types_1.OtcAmino));
|
|
6
6
|
exports.default = AminoTypesMap;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BridgeAmino = exports.GrantAmino = exports.ERC20Amino = exports.PerpspoolAmino = exports.FeeMarketAmino = exports.EvmAmino = exports.EvmMergeAmino = exports.SubAccountAmino = exports.StakingAmino = exports.ProfileAmino = exports.PositionAmino = exports.OrderAmino = exports.OracleAmino = exports.MarketAmino = exports.LiquidityPoolAmino = exports.LeverageAmino = exports.IbcAmino = exports.GovAmino = exports.CoinAmino = exports.CdpAmino = exports.BrokerAmino = exports.BankAmino = exports.AdminAmino = void 0;
|
|
6
|
+
exports.OtcAmino = exports.BridgeAmino = exports.GrantAmino = exports.ERC20Amino = exports.PerpspoolAmino = exports.FeeMarketAmino = exports.EvmAmino = exports.EvmMergeAmino = exports.SubAccountAmino = exports.StakingAmino = exports.ProfileAmino = exports.PositionAmino = exports.OrderAmino = exports.OracleAmino = exports.MarketAmino = exports.LiquidityPoolAmino = exports.LeverageAmino = exports.IbcAmino = exports.GovAmino = exports.CoinAmino = exports.CdpAmino = exports.BrokerAmino = exports.BankAmino = exports.AdminAmino = void 0;
|
|
7
7
|
var admin_1 = require("./admin");
|
|
8
8
|
Object.defineProperty(exports, "AdminAmino", { enumerable: true, get: function () { return __importDefault(admin_1).default; } });
|
|
9
9
|
var bank_1 = require("./bank");
|
|
@@ -50,3 +50,5 @@ var grant_1 = require("./grant");
|
|
|
50
50
|
Object.defineProperty(exports, "GrantAmino", { enumerable: true, get: function () { return __importDefault(grant_1).default; } });
|
|
51
51
|
var bridge_1 = require("./bridge");
|
|
52
52
|
Object.defineProperty(exports, "BridgeAmino", { enumerable: true, get: function () { return __importDefault(bridge_1).default; } });
|
|
53
|
+
var otc_1 = require("./otc");
|
|
54
|
+
Object.defineProperty(exports, "OtcAmino", { enumerable: true, get: function () { return __importDefault(otc_1).default; } });
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const CarbonTx = __importStar(require("../../../util/tx"));
|
|
23
|
+
const utils_1 = require("../utils");
|
|
24
|
+
const TxTypes = {
|
|
25
|
+
MsgCreateRfq: "otc/CreateRfq",
|
|
26
|
+
MsgCancelRfq: "otc/CancelRfq",
|
|
27
|
+
MsgAcceptQuote: "otc/AcceptQuote",
|
|
28
|
+
};
|
|
29
|
+
const MsgCreateRfq = {
|
|
30
|
+
aminoType: TxTypes.MsgCreateRfq,
|
|
31
|
+
valueMap: {
|
|
32
|
+
expiryTime: utils_1.ConvertEncType.Date,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const MsgCancelRfq = {
|
|
36
|
+
aminoType: TxTypes.MsgCancelRfq,
|
|
37
|
+
valueMap: {},
|
|
38
|
+
};
|
|
39
|
+
const MsgAcceptQuote = {
|
|
40
|
+
aminoType: TxTypes.MsgAcceptQuote,
|
|
41
|
+
valueMap: {},
|
|
42
|
+
};
|
|
43
|
+
const OtcAmino = {
|
|
44
|
+
[CarbonTx.Types.MsgCreateRfq]: utils_1.generateAminoType(MsgCreateRfq),
|
|
45
|
+
[CarbonTx.Types.MsgCancelRfq]: utils_1.generateAminoType(MsgCancelRfq),
|
|
46
|
+
[CarbonTx.Types.MsgAcceptQuote]: utils_1.generateAminoType(MsgAcceptQuote),
|
|
47
|
+
};
|
|
48
|
+
exports.default = OtcAmino;
|
package/lib/websocket/channel.js
CHANGED
|
@@ -124,6 +124,14 @@ const generateChannelId = (params) => {
|
|
|
124
124
|
const { channel } = params;
|
|
125
125
|
return [channel].join(":");
|
|
126
126
|
}
|
|
127
|
+
case types_1.WSChannel.otc_rfqs_by_address: {
|
|
128
|
+
const { channel, address } = params;
|
|
129
|
+
return [channel, address].join(":");
|
|
130
|
+
}
|
|
131
|
+
case types_1.WSChannel.otc_quotes_for_rfq: {
|
|
132
|
+
const { channel, rfq_id } = params;
|
|
133
|
+
return [channel, rfq_id].join(":");
|
|
134
|
+
}
|
|
127
135
|
default:
|
|
128
136
|
throw new Error(`invalid subscription channel: ${params.channel}`);
|
|
129
137
|
}
|
|
@@ -279,6 +287,15 @@ const parseChannelId = (rawChannelId) => {
|
|
|
279
287
|
return {
|
|
280
288
|
channel,
|
|
281
289
|
};
|
|
290
|
+
case types_1.WSChannel.otc_rfqs_by_address:
|
|
291
|
+
return {
|
|
292
|
+
channel,
|
|
293
|
+
};
|
|
294
|
+
case types_1.WSChannel.otc_quotes_for_rfq:
|
|
295
|
+
return {
|
|
296
|
+
channel,
|
|
297
|
+
rfq_id: param0,
|
|
298
|
+
};
|
|
282
299
|
default:
|
|
283
300
|
throw new Error("Error parsing channelId");
|
|
284
301
|
}
|
package/lib/websocket/types.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ export declare enum WSChannel {
|
|
|
28
28
|
cdp_token_supply = "cdp_token_supply",
|
|
29
29
|
cdp_token_supply_by_denom = "cdp_token_supply_by_denom",
|
|
30
30
|
token_supply_by_denom = "token_supply_by_denom",
|
|
31
|
-
market_liquidity_usage_multiplier = "market_liquidity_usage_multiplier"
|
|
31
|
+
market_liquidity_usage_multiplier = "market_liquidity_usage_multiplier",
|
|
32
|
+
otc_rfqs_by_address = "otc_rfqs_by_address",
|
|
33
|
+
otc_quotes_for_rfq = "otc_quotes_for_rfq"
|
|
32
34
|
}
|
|
33
35
|
export declare enum WSRequest {
|
|
34
36
|
MarketStats = "get_market_stats",
|
|
@@ -230,4 +232,10 @@ export interface WsSubscribeTokenSupplyByDenom extends WsSubscribeParams {
|
|
|
230
232
|
}
|
|
231
233
|
export interface WsSubscribeMarketLiquidityUsageMultiplier extends WsSubscribeParams {
|
|
232
234
|
}
|
|
233
|
-
export
|
|
235
|
+
export interface WsSubscribeOTCRFQsByAddress extends WsSubscribeParams {
|
|
236
|
+
address: string;
|
|
237
|
+
}
|
|
238
|
+
export interface WsSubscribeOTCQuotesForRfq extends WsSubscribeParams {
|
|
239
|
+
rfq_id: string;
|
|
240
|
+
}
|
|
241
|
+
export declare type WsSubscriptionParams = WsSubscribeCandlesticksParams | WsSubscribeBooksParams | WsSubscribeRecentTradesParams | WsSubscribeOrdersAllParams | WsSubscribeOrdersByMarketParams | WsSubscribeWalletBalanceParams | WsSubscribeAccountTradesAllParams | WsSubscribeAccountTradesByMarketParams | WsSubscribeMarketStatsAllParams | WsSubscribeMarketStatsByMarketParams | WsSubscribeLeveragesAllParams | WsSubscribeLeveragesByMarketParams | WsSubscribePositionsAllParams | WsSubscribePositionsByMarketParams | WsSubscribePoolsAllParams | WsSubscribePoolsByIdParams | WsSubscribeTokenPrices | WsSubscribeAllTokenPrices | WsSubscribeCommitmentParams | WsUnsubscribeCandlesticksParams | WsSubscribeCDPBorrows | WsSubscribeCDPCollaterals | WsSubscribeCDPLiquidateCollaterals | WsSubscribeTokenDebts | WsSubscribeTokenDebtByDenom | WsSubscribeRewardSchemes | WsSubscribeRewardDebts | WsSubscribeCDPTokenSupply | WsSubscribeCDPTokenSupplyByDenom | WsSubscribeTokenSupplyByDenom | WsSubscribeMarketLiquidityUsageMultiplier | WsSubscribeOTCRFQsByAddress | WsSubscribeOTCQuotesForRfq;
|
package/lib/websocket/types.js
CHANGED
|
@@ -33,6 +33,8 @@ var WSChannel;
|
|
|
33
33
|
WSChannel["cdp_token_supply_by_denom"] = "cdp_token_supply_by_denom";
|
|
34
34
|
WSChannel["token_supply_by_denom"] = "token_supply_by_denom";
|
|
35
35
|
WSChannel["market_liquidity_usage_multiplier"] = "market_liquidity_usage_multiplier";
|
|
36
|
+
WSChannel["otc_rfqs_by_address"] = "otc_rfqs_by_address";
|
|
37
|
+
WSChannel["otc_quotes_for_rfq"] = "otc_quotes_for_rfq";
|
|
36
38
|
})(WSChannel = exports.WSChannel || (exports.WSChannel = {}));
|
|
37
39
|
var WSRequest;
|
|
38
40
|
(function (WSRequest) {
|