Skip to content

Commit

Permalink
Merge branch 'master' into omnipool-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav authored Dec 3, 2024
2 parents 6090286 + e0d869f commit 0b2b435
Show file tree
Hide file tree
Showing 61 changed files with 1,710 additions and 985 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

- [Node.js](https://nodejs.org/) (**version 18 or higher**)
- [Node.js](https://nodejs.org/) (**version 20 or higher**)

## Local development

Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ Collection of SDK(s) crafted to ease Hydration & Basilisk chains integration.

## Project Structure

| Package | Version | Changelog | Description |
|:----------------------|:--------------------|:-----------------------|:-----------------------|
| [`@galacticcouncil/sdk`](./packages/sdk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk) | [changelog](./packages/sdk/CHANGELOG.md) | Trade router & pool utilities
| [`@galacticcouncil/xcm-core`](./packages/xcm-core) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-core.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-core) | [changelog](./packages/xcm-core/CHANGELOG.md) | Cross-chain definitions & types
| [`@galacticcouncil/xcm-cfg`](./packages/xcm-cfg) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-cfg.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-cfg) | [changelog](./packages/xcm-cfg/CHANGELOG.md) | Cross-chain routes & configs
| [`@galacticcouncil/xcm-sdk`](./packages/xcm-sdk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-sdk) | [changelog](./packages/xcm-sdk/CHANGELOG.md) | Cross-chain transfer sdk
| [`@galacticcouncil/math-ema`](./packages/math-ema) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-ema.svg)](https://www.npmjs.com/package/@galacticcouncil/math-ema) | [changelog](./packages/math-ema/CHANGELOG.md) | EMA math
| [`@galacticcouncil/math-lbp`](./packages/math-lbp) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-lbp.svg)](https://www.npmjs.com/package/@galacticcouncil/math-lbp) | [changelog](./packages/math-lbp/CHANGELOG.md) | LBP math
| [`@galacticcouncil/math-liquidity-mining`](./packages/math-liquidity-mining) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-liquidity-mining.svg)](https://www.npmjs.com/package/@galacticcouncil/math-liquidity-mining) | [changelog](./packages/math-liquidity-mining/CHANGELOG.md) | Liquidity mining math
| [`@galacticcouncil/math-omnipool`](./packages/math-omnipool) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-omnipool.svg)](https://www.npmjs.com/package/@galacticcouncil/math-omnipool) | [changelog](./packages/math-omnipool/CHANGELOG.md) | Omnipool math
| [`@galacticcouncil/math-stableswap`](./packages/math-stableswap) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-stableswap.svg)](https://www.npmjs.com/package/@galacticcouncil/math-stableswap) | [changelog](./packages/math-stableswap/CHANGELOG.md) | Stableswap math
| [`@galacticcouncil/math-staking`](./packages/math-staking) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-staking.svg)](https://www.npmjs.com/package/@galacticcouncil/math-staking) | [changelog](./packages/math-staking/CHANGELOG.md) | Staking math
| [`@galacticcouncil/math-xyk`](./packages/math-xyk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-xyk.svg)](https://www.npmjs.com/package/@galacticcouncil/math-xyk) | [changelog](./packages/math-xyk/CHANGELOG.md) | XYK math
| Package | Version | Changelog | Description |
| :--------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------- | :------------------------------ |
| [`@galacticcouncil/sdk`](./packages/sdk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk) | [changelog](./packages/sdk/CHANGELOG.md) | Trade router & pool utilities |
| [`@galacticcouncil/xcm-core`](./packages/xcm-core) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-core.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-core) | [changelog](./packages/xcm-core/CHANGELOG.md) | Cross-chain definitions & types |
| [`@galacticcouncil/xcm-cfg`](./packages/xcm-cfg) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-cfg.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-cfg) | [changelog](./packages/xcm-cfg/CHANGELOG.md) | Cross-chain route configs |
| [`@galacticcouncil/xcm-sdk`](./packages/xcm-sdk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/xcm-sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-sdk) | [changelog](./packages/xcm-sdk/CHANGELOG.md) | Cross-chain transfer sdk |
| [`@galacticcouncil/math-ema`](./packages/math-ema) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-ema.svg)](https://www.npmjs.com/package/@galacticcouncil/math-ema) | [changelog](./packages/math-ema/CHANGELOG.md) | EMA math |
| [`@galacticcouncil/math-lbp`](./packages/math-lbp) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-lbp.svg)](https://www.npmjs.com/package/@galacticcouncil/math-lbp) | [changelog](./packages/math-lbp/CHANGELOG.md) | LBP math |
| [`@galacticcouncil/math-liquidity-mining`](./packages/math-liquidity-mining) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-liquidity-mining.svg)](https://www.npmjs.com/package/@galacticcouncil/math-liquidity-mining) | [changelog](./packages/math-liquidity-mining/CHANGELOG.md) | Liquidity mining math |
| [`@galacticcouncil/math-omnipool`](./packages/math-omnipool) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-omnipool.svg)](https://www.npmjs.com/package/@galacticcouncil/math-omnipool) | [changelog](./packages/math-omnipool/CHANGELOG.md) | Omnipool math |
| [`@galacticcouncil/math-stableswap`](./packages/math-stableswap) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-stableswap.svg)](https://www.npmjs.com/package/@galacticcouncil/math-stableswap) | [changelog](./packages/math-stableswap/CHANGELOG.md) | Stableswap math |
| [`@galacticcouncil/math-staking`](./packages/math-staking) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-staking.svg)](https://www.npmjs.com/package/@galacticcouncil/math-staking) | [changelog](./packages/math-staking/CHANGELOG.md) | Staking math |
| [`@galacticcouncil/math-xyk`](./packages/math-xyk) | [![version](https://img.shields.io/npm/v/@galacticcouncil/math-xyk.svg)](https://www.npmjs.com/package/@galacticcouncil/math-xyk) | [changelog](./packages/math-xyk/CHANGELOG.md) | XYK math |

## Contributing

Expand All @@ -29,6 +29,7 @@ Everything about building, setting up development environment & releasing can be
In case of unexpected sdk behaviour, please create well-written issue [here](https://github.com/galacticcouncil/sdk/issues/new). It makes it easier to find & fix the problem accordingly.

## Legal

<pre>
This file is part of https://github.com/galacticcouncil/*

Expand Down Expand Up @@ -58,4 +59,5 @@ This file is part of https://github.com/galacticcouncil/*
$$ $$$$$ $$$$$ $$ $$$$
$$$
</pre>

For more details read [LICENSE.md](LICENSE.md)
6 changes: 3 additions & 3 deletions examples/sdk-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"node": "^21.6.0"
},
"dependencies": {
"@galacticcouncil/sdk": "^4.6.1",
"@galacticcouncil/xcm-sdk": "^6.3.3",
"@galacticcouncil/xcm-cfg": "^5.5.0"
"@galacticcouncil/sdk": "^5.0.1",
"@galacticcouncil/xcm-sdk": "^7.0.0",
"@galacticcouncil/xcm-cfg": "^5.6.0"
}
}
2 changes: 1 addition & 1 deletion examples/sdk-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"esbuild": "^0.17.11"
},
"dependencies": {
"@galacticcouncil/sdk": "^4.6.1"
"@galacticcouncil/sdk": "^5.0.1"
}
}
6 changes: 3 additions & 3 deletions examples/xcm-transfer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"esbuild-plugin-wasm": "^1.0.0"
},
"dependencies": {
"@galacticcouncil/sdk": "^4.6.1",
"@galacticcouncil/xcm-cfg": "^5.5.0",
"@galacticcouncil/xcm-sdk": "^6.3.3",
"@galacticcouncil/sdk": "^5.0.1",
"@galacticcouncil/xcm-cfg": "^5.6.0",
"@galacticcouncil/xcm-sdk": "^7.0.0",
"@talismn/connect-wallets": "^1.2.5"
}
}
10 changes: 5 additions & 5 deletions examples/xcm-transfer/src/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ export function configureExternal(
) {
external.forEach((ext) => {
if (ext.origin === 1000 && !defaultExternals.includes(ext.id)) {
const assetData = toAssetData(ext, '_ah_');
console.log('Registering ' + assetData.asset.key);
const assetData = toAssetData(ext);
console.log('💀 Registering ' + assetData.asset.key);
configService.addExternalHubRoute(assetData);
}
});
}

function toAssetData(external: ExternalAsset, suffix: string): ChainAssetData {
const { decimals, id, symbol, internalId } = external;
function toAssetData(external: ExternalAsset): ChainAssetData {
const { decimals, id, internalId, origin, symbol } = external;
const key = symbol.toLowerCase();
const asset = new Asset({
key: key + suffix + id,
key: [key, origin, id].join('_'),
originSymbol: symbol,
});

Expand Down
14 changes: 7 additions & 7 deletions examples/xcm-transfer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const wallet = new Wallet({
configureExternal(externals, configService);

// Define transfer
const srcChain = configService.getChain('ethereum');
const destChain = configService.getChain('hydration');
const asset = configService.getAsset('eth');
const srcChain = configService.getChain('hydration');
const destChain = configService.getChain('ethereum');
const asset = configService.getAsset('aave');

const configBuilder = ConfigBuilder(configService);
const { sourceChains } = configBuilder.assets().asset(asset);
Expand All @@ -71,8 +71,8 @@ logDestChains(asset.key, destinationChains);
logSrcChains(asset.key, sourceChains);

// Define source & dest accounts
const srcAddr = 'INSERT_ADDRESS';
const destAddr = 'INSERT_ADDRESS';
const srcAddr = '5HbftW2XCP77ypjeBEkL2iXHKw5rnRJoqKd3ySZCgxvxbxYj';
const destAddr = '0x26f5C2370e563e9f4dDA435f03A63D7C109D8D04';

// Subscribe source chain token balance
const balanceObserver = (balances: AssetAmount[]) => console.log(balances);
Expand All @@ -95,13 +95,13 @@ const xTransfer = await wallet.transfer(
const status = await xTransfer.validate();

// Construct calldata with transfer amount
const fee: AssetAmount = await xTransfer.estimateFee('0.0001');
const fee: AssetAmount = await xTransfer.estimateFee('0.1');
const feeInfo = [
'Estimated fee:',
fee.toDecimal(fee.decimals),
fee.originSymbol,
].join(' ');
const call: XCall = await xTransfer.buildCall('0.0001');
const call: XCall = await xTransfer.buildCall('0.1');

// Dump transfer info
console.log(xTransfer);
Expand Down
16 changes: 16 additions & 0 deletions integration-tests/xcm-test/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import { config } from '../../jest.config.mjs';

/**
* Chopsticks log level, "fatal" | "error" | "warn" | "info" | "debug" | "trace".
* Default is "info".
*/
process.env.LOG_LEVEL = 'info';

/**
* Don't log objects. Default is `false`.
*/
process.env.LOG_COMPACT = 'false';

/**
* Don't truncate log messages, show full log output. Default is `false`.
*/
process.env.VERBOSE_LOG = 'false';

export default config;
8 changes: 4 additions & 4 deletions integration-tests/xcm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
],
"scripts": {
"test:call": "jest call.spec.ts",
"test:call:update": "jest --updateSnapshot call.spec.ts",
"test:e2e": "jest e2e.spec.ts"
"test:e2e": "jest --forceExit e2e.spec.ts",
"test:exec": "jest --forceExit exec.spec.ts"
},
"devDependencies": {
"@acala-network/chopsticks-testing": "1.0.1"
},
"dependencies": {
"@galacticcouncil/xcm-cfg": "^5.5.0",
"@galacticcouncil/xcm-sdk": "^6.3.3"
"@galacticcouncil/xcm-cfg": "^5.6.0",
"@galacticcouncil/xcm-sdk": "^7.0.0"
}
}
Loading

0 comments on commit 0b2b435

Please sign in to comment.