@shapeshiftoss/swapper 5.3.0 → 5.6.0
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/dist/api.d.ts +12 -1
- package/dist/api.js +2 -0
- package/dist/swappercli.js +7 -0
- package/dist/swappers/cow/CowSwapper.d.ts +18 -0
- package/dist/swappers/cow/CowSwapper.js +52 -0
- package/dist/swappers/thorchain/ThorchainSwapper.d.ts +9 -3
- package/dist/swappers/thorchain/ThorchainSwapper.js +32 -6
- package/dist/swappers/thorchain/types.d.ts +14 -0
- package/dist/swappers/thorchain/types.js +2 -0
- package/dist/swappers/thorchain/utils/ethereum/routerAbi.d.ts +2 -0
- package/dist/swappers/thorchain/utils/ethereum/routerAbi.js +153 -0
- package/dist/swappers/thorchain/utils/ethereum/routerCalldata.d.ts +1 -0
- package/dist/swappers/thorchain/utils/ethereum/routerCalldata.js +15 -0
- package/dist/swappers/thorchain/utils/test-data/midgardResponse.d.ts +14 -0
- package/dist/swappers/thorchain/utils/test-data/midgardResponse.js +47 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
-
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
2
|
+
import { BTCSignTx, ETHSignTx, HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
3
3
|
import { Asset, ChainSpecific, SupportedChainIds } from '@shapeshiftoss/types';
|
|
4
4
|
export declare const SwapError: {
|
|
5
5
|
new <V extends {
|
|
@@ -85,6 +85,15 @@ export interface ZrxTrade<C extends SupportedChainIds> extends Trade<C> {
|
|
|
85
85
|
txData: string;
|
|
86
86
|
depositAddress: string;
|
|
87
87
|
}
|
|
88
|
+
export interface BtcThorTrade<C extends SupportedChainIds> extends Trade<C> {
|
|
89
|
+
chainId: 'bip122:000000000019d6689c085ae165831e93';
|
|
90
|
+
txData: BTCSignTx;
|
|
91
|
+
}
|
|
92
|
+
export interface EthThorTrade<C extends SupportedChainIds> extends Trade<C> {
|
|
93
|
+
chainId: 'eip155:1';
|
|
94
|
+
txData: ETHSignTx;
|
|
95
|
+
}
|
|
96
|
+
export declare type ThorTrade<C extends SupportedChainIds> = BtcThorTrade<C> | EthThorTrade<C>;
|
|
88
97
|
export declare type ExecuteTradeInput<C extends SupportedChainIds> = {
|
|
89
98
|
trade: Trade<C>;
|
|
90
99
|
wallet: HDWallet;
|
|
@@ -120,6 +129,7 @@ export declare type ApprovalNeededOutput = {
|
|
|
120
129
|
export declare enum SwapperType {
|
|
121
130
|
Zrx = "0x",
|
|
122
131
|
Thorchain = "Thorchain",
|
|
132
|
+
CowSwap = "CowSwap",
|
|
123
133
|
Test = "Test"
|
|
124
134
|
}
|
|
125
135
|
export declare type TradeTxs = {
|
|
@@ -133,6 +143,7 @@ export declare enum SwapErrorTypes {
|
|
|
133
143
|
CHECK_APPROVAL_FAILED = "CHECK_APPROVAL_FAILED",
|
|
134
144
|
EXECUTE_TRADE_FAILED = "EXECUTE_TRADE_FAILED",
|
|
135
145
|
GRANT_ALLOWANCE_FAILED = "GRANT_ALLOWANCE_FAILED",
|
|
146
|
+
INITIALIZE_FAILED = "INITIALIZE_FAILED",
|
|
136
147
|
MANAGER_ERROR = "MANAGER_ERROR",
|
|
137
148
|
MIN_MAX_FAILED = "MIN_MAX_FAILED",
|
|
138
149
|
RESPONSE_ERROR = "RESPONSE_ERROR",
|
package/dist/api.js
CHANGED
|
@@ -7,6 +7,7 @@ var SwapperType;
|
|
|
7
7
|
(function (SwapperType) {
|
|
8
8
|
SwapperType["Zrx"] = "0x";
|
|
9
9
|
SwapperType["Thorchain"] = "Thorchain";
|
|
10
|
+
SwapperType["CowSwap"] = "CowSwap";
|
|
10
11
|
SwapperType["Test"] = "Test";
|
|
11
12
|
})(SwapperType = exports.SwapperType || (exports.SwapperType = {}));
|
|
12
13
|
// Swap Errors
|
|
@@ -18,6 +19,7 @@ var SwapErrorTypes;
|
|
|
18
19
|
SwapErrorTypes["CHECK_APPROVAL_FAILED"] = "CHECK_APPROVAL_FAILED";
|
|
19
20
|
SwapErrorTypes["EXECUTE_TRADE_FAILED"] = "EXECUTE_TRADE_FAILED";
|
|
20
21
|
SwapErrorTypes["GRANT_ALLOWANCE_FAILED"] = "GRANT_ALLOWANCE_FAILED";
|
|
22
|
+
SwapErrorTypes["INITIALIZE_FAILED"] = "INITIALIZE_FAILED";
|
|
21
23
|
SwapErrorTypes["MANAGER_ERROR"] = "MANAGER_ERROR";
|
|
22
24
|
SwapErrorTypes["MIN_MAX_FAILED"] = "MIN_MAX_FAILED";
|
|
23
25
|
SwapErrorTypes["RESPONSE_ERROR"] = "RESPONSE_ERROR";
|
package/dist/swappercli.js
CHANGED
|
@@ -13,6 +13,7 @@ const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
|
13
13
|
const web3_1 = __importDefault(require("web3"));
|
|
14
14
|
const api_1 = require("./api");
|
|
15
15
|
const SwapperManager_1 = require("./manager/SwapperManager");
|
|
16
|
+
const ThorchainSwapper_1 = require("./swappers/thorchain/ThorchainSwapper");
|
|
16
17
|
const ZrxSwapper_1 = require("./swappers/zrx/ZrxSwapper");
|
|
17
18
|
dotenv_1.default.config();
|
|
18
19
|
const { UNCHAINED_HTTP_API = 'http://localhost:31300', UNCHAINED_WS_API = 'wss://localhost:31300', ETH_NODE_URL = 'http://localhost:3000', DEVICE_ID = 'device123', MNEMONIC = 'all all all all all all all all all all all all' } = process.env;
|
|
@@ -82,9 +83,15 @@ const main = async () => {
|
|
|
82
83
|
const web3Provider = new web3_1.default.providers.HttpProvider(ETH_NODE_URL);
|
|
83
84
|
const web3 = new web3_1.default(web3Provider);
|
|
84
85
|
const zrxSwapperDeps = { wallet, adapterManager, web3 };
|
|
86
|
+
const thorchainSwapperDeps = {
|
|
87
|
+
midgardUrl: 'https://midgard.thorchain.info/v2/pools'
|
|
88
|
+
};
|
|
85
89
|
const manager = new SwapperManager_1.SwapperManager();
|
|
86
90
|
const zrxSwapper = new ZrxSwapper_1.ZrxSwapper(zrxSwapperDeps);
|
|
91
|
+
const thorchainSwapper = new ThorchainSwapper_1.ThorchainSwapper(thorchainSwapperDeps);
|
|
92
|
+
await thorchainSwapper.initialize();
|
|
87
93
|
manager.addSwapper(api_1.SwapperType.Zrx, zrxSwapper);
|
|
94
|
+
manager.addSwapper(api_1.SwapperType.Thorchain, thorchainSwapper);
|
|
88
95
|
const swapper = await manager.getBestSwapper({
|
|
89
96
|
sellAssetId: 'eip155:1/slip44:60',
|
|
90
97
|
buyAssetId: 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
|
+
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
+
import { ApprovalNeededInput, ApprovalNeededOutput, ApproveInfiniteInput, BuildTradeInput, BuyAssetBySellIdInput, ExecuteTradeInput, GetMinMaxInput, GetTradeQuoteInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
|
+
export declare class CowSwapper implements Swapper {
|
|
5
|
+
static swapperName: string;
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
getType(): SwapperType;
|
|
8
|
+
buildTrade(args: BuildTradeInput): Promise<Trade<SupportedChainIds>>;
|
|
9
|
+
getTradeQuote(input: GetTradeQuoteInput): Promise<TradeQuote<SupportedChainIds>>;
|
|
10
|
+
getUsdRate(input: Pick<Asset, 'symbol' | 'assetId'>): Promise<string>;
|
|
11
|
+
getMinMax(input: GetMinMaxInput): Promise<MinMaxOutput>;
|
|
12
|
+
executeTrade(args: ExecuteTradeInput<SupportedChainIds>): Promise<TradeResult>;
|
|
13
|
+
approvalNeeded(args: ApprovalNeededInput<SupportedChainIds>): Promise<ApprovalNeededOutput>;
|
|
14
|
+
approveInfinite(args: ApproveInfiniteInput<SupportedChainIds>): Promise<string>;
|
|
15
|
+
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
16
|
+
filterAssetIdsBySellable(assetIds: AssetId[]): AssetId[];
|
|
17
|
+
getTradeTxs(): Promise<TradeTxs>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CowSwapper = void 0;
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
class CowSwapper {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
|
+
async initialize() { }
|
|
8
|
+
getType() {
|
|
9
|
+
return api_1.SwapperType.CowSwap;
|
|
10
|
+
}
|
|
11
|
+
async buildTrade(args) {
|
|
12
|
+
console.info(args);
|
|
13
|
+
throw new Error('CowSwapper: buildTrade unimplemented');
|
|
14
|
+
}
|
|
15
|
+
async getTradeQuote(input) {
|
|
16
|
+
console.info(input);
|
|
17
|
+
throw new Error('CowSwapper: getTradeQuote unimplemented');
|
|
18
|
+
}
|
|
19
|
+
getUsdRate(input) {
|
|
20
|
+
console.info(input);
|
|
21
|
+
throw new Error('CowSwapper: getUsdRate unimplemented');
|
|
22
|
+
}
|
|
23
|
+
getMinMax(input) {
|
|
24
|
+
console.info(input);
|
|
25
|
+
throw new Error('CowSwapper: getMinMax unimplemented');
|
|
26
|
+
}
|
|
27
|
+
async executeTrade(args) {
|
|
28
|
+
console.info(args);
|
|
29
|
+
throw new Error('CowSwapper: executeTrade unimplemented');
|
|
30
|
+
}
|
|
31
|
+
async approvalNeeded(args) {
|
|
32
|
+
console.info(args);
|
|
33
|
+
throw new Error('CowSwapper: approvalNeeded unimplemented');
|
|
34
|
+
}
|
|
35
|
+
async approveInfinite(args) {
|
|
36
|
+
console.info(args);
|
|
37
|
+
throw new Error('CowSwapper: approveInfinite unimplemented');
|
|
38
|
+
}
|
|
39
|
+
filterBuyAssetsBySellAssetId(args) {
|
|
40
|
+
console.info(args);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
filterAssetIdsBySellable(assetIds) {
|
|
44
|
+
console.info(assetIds);
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
async getTradeTxs() {
|
|
48
|
+
throw new Error('CowSwapper: executeTrade unimplemented');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.CowSwapper = CowSwapper;
|
|
52
|
+
CowSwapper.swapperName = 'CowSwapper';
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { AssetId } from '@shapeshiftoss/caip';
|
|
2
2
|
import { Asset, SupportedChainIds } from '@shapeshiftoss/types';
|
|
3
|
-
import { ApprovalNeededOutput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
3
|
+
import { ApprovalNeededOutput, BuyAssetBySellIdInput, GetMinMaxInput, MinMaxOutput, Swapper, SwapperType, Trade, TradeQuote, TradeResult, TradeTxs } from '../../api';
|
|
4
|
+
export declare type ThorchainSwapperDeps = {
|
|
5
|
+
midgardUrl: string;
|
|
6
|
+
};
|
|
4
7
|
export declare class ThorchainSwapper implements Swapper {
|
|
5
|
-
|
|
8
|
+
private supportedAssetIds;
|
|
9
|
+
deps: ThorchainSwapperDeps;
|
|
10
|
+
constructor(deps: ThorchainSwapperDeps);
|
|
6
11
|
initialize(): Promise<void>;
|
|
12
|
+
getType(): SwapperType;
|
|
7
13
|
getUsdRate(input: Pick<Asset, 'symbol' | 'assetId'>): Promise<string>;
|
|
8
14
|
getMinMax(input: GetMinMaxInput): Promise<MinMaxOutput>;
|
|
9
15
|
approvalNeeded(): Promise<ApprovalNeededOutput>;
|
|
10
16
|
approveInfinite(): Promise<string>;
|
|
11
|
-
filterBuyAssetsBySellAssetId(): AssetId[];
|
|
17
|
+
filterBuyAssetsBySellAssetId(args: BuyAssetBySellIdInput): AssetId[];
|
|
12
18
|
filterAssetIdsBySellable(): AssetId[];
|
|
13
19
|
buildTrade(): Promise<Trade<SupportedChainIds>>;
|
|
14
20
|
getTradeQuote(): Promise<TradeQuote<SupportedChainIds>>;
|
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ThorchainSwapper = void 0;
|
|
7
|
+
const caip_1 = require("@shapeshiftoss/caip");
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
4
9
|
const api_1 = require("../../api");
|
|
5
10
|
class ThorchainSwapper {
|
|
11
|
+
constructor(deps) {
|
|
12
|
+
this.supportedAssetIds = [];
|
|
13
|
+
this.deps = deps;
|
|
14
|
+
}
|
|
15
|
+
async initialize() {
|
|
16
|
+
try {
|
|
17
|
+
const { data: responseData } = await axios_1.default.get(this.deps.midgardUrl);
|
|
18
|
+
const supportedAssetIds = responseData.reduce((acc, midgardPool) => {
|
|
19
|
+
const assetId = caip_1.adapters.poolAssetIdToAssetId(midgardPool.asset);
|
|
20
|
+
if (!assetId)
|
|
21
|
+
return acc;
|
|
22
|
+
acc.push(assetId);
|
|
23
|
+
return acc;
|
|
24
|
+
}, []);
|
|
25
|
+
this.supportedAssetIds = supportedAssetIds;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new api_1.SwapError('[thorchainInitialize]: initialize failed to set supportedAssetIds', {
|
|
29
|
+
code: api_1.SwapErrorTypes.INITIALIZE_FAILED,
|
|
30
|
+
cause: e
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
6
34
|
getType() {
|
|
7
35
|
return api_1.SwapperType.Thorchain;
|
|
8
36
|
}
|
|
9
|
-
// TODO populate supported assets from midgard
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
11
|
-
async initialize() { }
|
|
12
37
|
getUsdRate(input) {
|
|
13
38
|
console.info(input);
|
|
14
39
|
throw new Error('ThorchainSwapper: getUsdRate unimplemented');
|
|
@@ -23,11 +48,12 @@ class ThorchainSwapper {
|
|
|
23
48
|
async approveInfinite() {
|
|
24
49
|
throw new Error('ThorchainSwapper: approveInfinite unimplemented');
|
|
25
50
|
}
|
|
26
|
-
filterBuyAssetsBySellAssetId() {
|
|
27
|
-
|
|
51
|
+
filterBuyAssetsBySellAssetId(args) {
|
|
52
|
+
const { assetIds = [], sellAssetId } = args;
|
|
53
|
+
return assetIds.filter((assetId) => this.supportedAssetIds.includes(assetId) && assetId !== sellAssetId);
|
|
28
54
|
}
|
|
29
55
|
filterAssetIdsBySellable() {
|
|
30
|
-
return
|
|
56
|
+
return this.supportedAssetIds;
|
|
31
57
|
}
|
|
32
58
|
async buildTrade() {
|
|
33
59
|
throw new Error('ThorchainSwapper: buildTrade unimplemented');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type MidgardResponse = {
|
|
2
|
+
asset: string;
|
|
3
|
+
assetDepth: string;
|
|
4
|
+
assetPrice: string;
|
|
5
|
+
assetPriceUSD: string;
|
|
6
|
+
liquidityUnits: string;
|
|
7
|
+
poolAPY: string;
|
|
8
|
+
runeDepth: string;
|
|
9
|
+
status: string;
|
|
10
|
+
synthSupply: string;
|
|
11
|
+
synthUnits: string;
|
|
12
|
+
units: string;
|
|
13
|
+
volume24h: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.routerAbi = void 0;
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
exports.routerAbi = [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [{ "internalType": "address", "name": "rune", "type": "address" }],
|
|
8
|
+
"stateMutability": "nonpayable",
|
|
9
|
+
"type": "constructor"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"anonymous": false,
|
|
13
|
+
"inputs": [
|
|
14
|
+
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" },
|
|
15
|
+
{ "indexed": true, "internalType": "address", "name": "asset", "type": "address" },
|
|
16
|
+
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
17
|
+
{ "indexed": false, "internalType": "string", "name": "memo", "type": "string" }
|
|
18
|
+
],
|
|
19
|
+
"name": "Deposit",
|
|
20
|
+
"type": "event"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"anonymous": false,
|
|
24
|
+
"inputs": [
|
|
25
|
+
{ "indexed": true, "internalType": "address", "name": "oldVault", "type": "address" },
|
|
26
|
+
{ "indexed": true, "internalType": "address", "name": "newVault", "type": "address" },
|
|
27
|
+
{ "indexed": false, "internalType": "address", "name": "asset", "type": "address" },
|
|
28
|
+
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
29
|
+
{ "indexed": false, "internalType": "string", "name": "memo", "type": "string" }
|
|
30
|
+
],
|
|
31
|
+
"name": "TransferAllowance",
|
|
32
|
+
"type": "event"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"anonymous": false,
|
|
36
|
+
"inputs": [
|
|
37
|
+
{ "indexed": true, "internalType": "address", "name": "vault", "type": "address" },
|
|
38
|
+
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" },
|
|
39
|
+
{ "indexed": false, "internalType": "address", "name": "asset", "type": "address" },
|
|
40
|
+
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
41
|
+
{ "indexed": false, "internalType": "string", "name": "memo", "type": "string" }
|
|
42
|
+
],
|
|
43
|
+
"name": "TransferOut",
|
|
44
|
+
"type": "event"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"anonymous": false,
|
|
48
|
+
"inputs": [
|
|
49
|
+
{ "indexed": true, "internalType": "address", "name": "oldVault", "type": "address" },
|
|
50
|
+
{ "indexed": true, "internalType": "address", "name": "newVault", "type": "address" },
|
|
51
|
+
{
|
|
52
|
+
"components": [
|
|
53
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
54
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
55
|
+
],
|
|
56
|
+
"indexed": false,
|
|
57
|
+
"internalType": "struct THORChain_Router.Coin[]",
|
|
58
|
+
"name": "coins",
|
|
59
|
+
"type": "tuple[]"
|
|
60
|
+
},
|
|
61
|
+
{ "indexed": false, "internalType": "string", "name": "memo", "type": "string" }
|
|
62
|
+
],
|
|
63
|
+
"name": "VaultTransfer",
|
|
64
|
+
"type": "event"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"inputs": [],
|
|
68
|
+
"name": "RUNE",
|
|
69
|
+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
70
|
+
"stateMutability": "view",
|
|
71
|
+
"type": "function"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"inputs": [
|
|
75
|
+
{ "internalType": "address payable", "name": "vault", "type": "address" },
|
|
76
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
77
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
78
|
+
{ "internalType": "string", "name": "memo", "type": "string" }
|
|
79
|
+
],
|
|
80
|
+
"name": "deposit",
|
|
81
|
+
"outputs": [],
|
|
82
|
+
"stateMutability": "payable",
|
|
83
|
+
"type": "function"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"inputs": [
|
|
87
|
+
{ "internalType": "address payable", "name": "vault", "type": "address" },
|
|
88
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
89
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
90
|
+
{ "internalType": "string", "name": "memo", "type": "string" },
|
|
91
|
+
{ "internalType": "uint256", "name": "expiration", "type": "uint256" }
|
|
92
|
+
],
|
|
93
|
+
"name": "depositWithExpiry",
|
|
94
|
+
"outputs": [],
|
|
95
|
+
"stateMutability": "payable",
|
|
96
|
+
"type": "function"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"inputs": [
|
|
100
|
+
{ "internalType": "address", "name": "router", "type": "address" },
|
|
101
|
+
{ "internalType": "address payable", "name": "asgard", "type": "address" },
|
|
102
|
+
{
|
|
103
|
+
"components": [
|
|
104
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
105
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
106
|
+
],
|
|
107
|
+
"internalType": "struct THORChain_Router.Coin[]",
|
|
108
|
+
"name": "coins",
|
|
109
|
+
"type": "tuple[]"
|
|
110
|
+
},
|
|
111
|
+
{ "internalType": "string", "name": "memo", "type": "string" }
|
|
112
|
+
],
|
|
113
|
+
"name": "returnVaultAssets",
|
|
114
|
+
"outputs": [],
|
|
115
|
+
"stateMutability": "payable",
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"inputs": [
|
|
120
|
+
{ "internalType": "address", "name": "router", "type": "address" },
|
|
121
|
+
{ "internalType": "address", "name": "newVault", "type": "address" },
|
|
122
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
123
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
124
|
+
{ "internalType": "string", "name": "memo", "type": "string" }
|
|
125
|
+
],
|
|
126
|
+
"name": "transferAllowance",
|
|
127
|
+
"outputs": [],
|
|
128
|
+
"stateMutability": "nonpayable",
|
|
129
|
+
"type": "function"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"inputs": [
|
|
133
|
+
{ "internalType": "address payable", "name": "to", "type": "address" },
|
|
134
|
+
{ "internalType": "address", "name": "asset", "type": "address" },
|
|
135
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" },
|
|
136
|
+
{ "internalType": "string", "name": "memo", "type": "string" }
|
|
137
|
+
],
|
|
138
|
+
"name": "transferOut",
|
|
139
|
+
"outputs": [],
|
|
140
|
+
"stateMutability": "payable",
|
|
141
|
+
"type": "function"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"inputs": [
|
|
145
|
+
{ "internalType": "address", "name": "vault", "type": "address" },
|
|
146
|
+
{ "internalType": "address", "name": "token", "type": "address" }
|
|
147
|
+
],
|
|
148
|
+
"name": "vaultAllowance",
|
|
149
|
+
"outputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
|
|
150
|
+
"stateMutability": "view",
|
|
151
|
+
"type": "function"
|
|
152
|
+
}
|
|
153
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deposit: (contractAddress: string, vault: string, asset: string, amount: string, memo: string) => Promise<any>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deposit = void 0;
|
|
7
|
+
const web3_1 = __importDefault(require("web3"));
|
|
8
|
+
const routerAbi_1 = require("./routerAbi");
|
|
9
|
+
const deposit = async (contractAddress, vault, asset, amount, memo) => {
|
|
10
|
+
const web3 = new web3_1.default();
|
|
11
|
+
const routerContract = new web3.eth.Contract(routerAbi_1.routerAbi, contractAddress);
|
|
12
|
+
const data = routerContract.methods.deposit(vault, asset, amount, memo).encodeABI();
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
exports.deposit = deposit;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const midgardResponse: {
|
|
2
|
+
asset: string;
|
|
3
|
+
assetDepth: string;
|
|
4
|
+
assetPrice: string;
|
|
5
|
+
assetPriceUSD: string;
|
|
6
|
+
liquidityUnits: string;
|
|
7
|
+
poolAPY: string;
|
|
8
|
+
runeDepth: string;
|
|
9
|
+
status: string;
|
|
10
|
+
synthSupply: string;
|
|
11
|
+
synthUnits: string;
|
|
12
|
+
units: string;
|
|
13
|
+
volume24h: string;
|
|
14
|
+
}[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.midgardResponse = void 0;
|
|
4
|
+
exports.midgardResponse = [
|
|
5
|
+
{
|
|
6
|
+
asset: 'BTC.BTC',
|
|
7
|
+
assetDepth: '91027798705',
|
|
8
|
+
assetPrice: '10280.68095465986',
|
|
9
|
+
assetPriceUSD: '29850.505131750208',
|
|
10
|
+
liquidityUnits: '536055974608843',
|
|
11
|
+
poolAPY: '0.09305294391574037',
|
|
12
|
+
runeDepth: '935827756491105',
|
|
13
|
+
status: 'available',
|
|
14
|
+
synthSupply: '3281284823',
|
|
15
|
+
synthUnits: '9838954536080',
|
|
16
|
+
units: '545894929144923',
|
|
17
|
+
volume24h: '15031085906495'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
asset: 'ETH.ETH',
|
|
21
|
+
assetDepth: '915018987646',
|
|
22
|
+
assetPrice: '676.2118757936507',
|
|
23
|
+
assetPriceUSD: '1963.4172247490626',
|
|
24
|
+
liquidityUnits: '273709963437801',
|
|
25
|
+
poolAPY: '0.10532151323548256',
|
|
26
|
+
runeDepth: '618746706022909',
|
|
27
|
+
status: 'available',
|
|
28
|
+
synthSupply: '3572065751',
|
|
29
|
+
synthUnits: '535301524652',
|
|
30
|
+
units: '274245264962453',
|
|
31
|
+
volume24h: '9890096673763'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
asset: 'ETH.FOX-0XC770EEFAD204B5180DF6A14EE197D99D808EE52D',
|
|
35
|
+
assetDepth: '166650912393467',
|
|
36
|
+
assetPrice: '0.05303710198887871',
|
|
37
|
+
assetPriceUSD: '0.15399605260336216',
|
|
38
|
+
liquidityUnits: '10015457121887',
|
|
39
|
+
poolAPY: '0.2597568967423438',
|
|
40
|
+
runeDepth: '8838681437152',
|
|
41
|
+
status: 'available',
|
|
42
|
+
synthSupply: '17428372569375',
|
|
43
|
+
synthUnits: '552604585625',
|
|
44
|
+
units: '10568061707512',
|
|
45
|
+
volume24h: '251596933033'
|
|
46
|
+
}
|
|
47
|
+
];
|