{"id":30913002,"url":"https://github.com/tgntr/swapchain","last_synced_at":"2025-09-09T22:18:15.546Z","repository":{"id":186276908,"uuid":"614823076","full_name":"tgntr/swapchain","owner":"tgntr","description":"Demo IBC Appchain","archived":false,"fork":false,"pushed_at":"2023-04-06T00:29:53.000Z","size":339,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-01T13:25:53.774Z","etag":null,"topics":["cosmos-sdk","golang","ibc","osmosis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgntr.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-16T11:51:55.000Z","updated_at":"2023-04-22T04:27:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"bfbb6add-2615-45a8-86d5-b19287d7059f","html_url":"https://github.com/tgntr/swapchain","commit_stats":null,"previous_names":["tgntr/swapchain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tgntr/swapchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgntr%2Fswapchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgntr%2Fswapchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgntr%2Fswapchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgntr%2Fswapchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgntr","download_url":"https://codeload.github.com/tgntr/swapchain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgntr%2Fswapchain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274370148,"owners_count":25272755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cosmos-sdk","golang","ibc","osmosis"],"created_at":"2025-09-09T22:18:10.008Z","updated_at":"2025-09-09T22:18:15.519Z","avatar_url":"https://github.com/tgntr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview \n\nThe following repository contains a basic example of a module that interacts with Osmosis through IBC.\n\n\u003cbr\u003e\n\n### Prerequisites\n\n- Go 1.19+\nhttps://go.dev/doc/install\n\n- Linux users need to make sure they have GCC installed\n\n\u003cbr\u003e\n\n### Developer Documentation\n\n- IBC docs\nhttps://ibc.cosmos.network/\n\n- Osmosis docs\nhttps://docs.osmosis.zone/\n\n- ICQ docs\nhttps://github.com/strangelove-ventures/async-icq#readme\n\n\u003cbr\u003e\n\n# Demo\n\n### Prerequisites\n\n\n- Ignite CLI v0.26+\nhttps://docs.ignite.com/welcome/install\n\n\u003cbr\u003e\n\n### 1. Start local swapchain network\n\n```bash \nmake start-swapchain\n```\n\n\u003cbr\u003e\n\n### 2. Start local osmosis network\n\n```bash \nmake start-osmosis\n```\n\n\u003cbr\u003e\n\n### 3. Wait until osmosis node starts producing blocks (~15 secs)\n\n\u003cbr\u003e\n\n### 4. Start relayer\n\n```bash\nmake start-relayer\n```\n\n\u003cbr\u003e\n\n### 5. Wait until relayer makes connection between the networks (~30 secs)\n\n\u003cbr\u003e\n\n### 6. Create osmosis liquidity pool\n\n```bash\n# create liquidity pool for stake-uosmo with equal amounts\nosmosisd tx gamm create-pool --pool-file=contrib/osmosis-pool.json --from validator --home=contrib/osmosis/.osmosis --node=tcp://localhost:26662 --chain-id=osmosis --fees=875stake -y\n```\n\n\u003cbr\u003e\n\n### 7. Query osmosis pool spot price through ICQ\n\n```bash\n# query spot price for stake\nswapchaind tx interchainswap send-query-osmosis-spot-price channel-0 1 stake uosmo --from=validator --home=.swapchain --node=tcp://localhost:26660 -y\n```\n\n\u003cbr\u003e\n\n### 8. Wait until relayer relays packet (~10sec)\n\n\u003cbr\u003e\n\n### 9. Query the result of the ICQ query\n\n```bash\n# price should be 1.00 since the pool has equal amounts for both tokens\nswapchaind q interchainswap query-state 1 --home=.swapchain --node=tcp://localhost:26660\n```\n\n\u003cbr\u003e\n\n### 10. Create osmosis account through ICA\n\n```bash\nswapchaind tx interchainswap register-interchain-account connection-0 --from=validator --home=.swapchain --node=tcp://localhost:26660 -y\n```\n\n\u003cbr\u003e\n\n### 11. Wait until relayer relays packet (~10sec)\n\n\u003cbr\u003e\n\n### 12. Query the created ICA account address \n\n```bash\nswapchaind q interchain-accounts controller interchain-account cosmos14y0kdvznkssdtal2r60a8us266n0mm97r2xju8 connection-0 --home=.swapchain --node=tcp://localhost:26660\n```\n\n\u003cbr\u003e\n\n### 13. Fund the ICA address in osmosis\n- Replace $INTERCHAIN_ADDRESS with the address queried in step 12\n\n```bash\n# fund address with 10000uosmo\nosmosisd tx bank send faucet $INTERCHAIN_ADDRESS 10000uosmo --home=contrib/osmosis/.osmosis --node=tcp://localhost:26662 --chain-id=osmosis --fees=875stake -y\n```\n\n\u003cbr\u003e\n\n### 14. Swap tokens through ICA\n- Replace $INTERCHAIN_ADDRESS with the address queried in step 12\n\n```bash\n# swap 10uosmo for stake\nswapchaind tx interchainswap send-msg-osmosis-swap '{\"@type\":\"/osmosis.gamm.v1beta1.MsgSwapExactAmountIn\",\"sender\":\"$INTERCHAIN_ADDRESS\",\"routes\":[{\"poolId\":\"1\",\"tokenOutDenom\":\"stake\"}],\"tokenIn\":{\"denom\":\"uosmo\",\"amount\":\"10\"},\"tokenOutMinAmount\":\"1\"}' connection-0 --from=validator --home=.swapchain --node=tcp://localhost:26660 -y\n```\n\n\u003cbr\u003e\n\n### 15. Wait until relayer relays packet (~10sec)\n\n\u003cbr\u003e\n\n### 16. Verify swap was successful\n- Replace $INTERCHAIN_ADDRESS with the address queried in step 12\n\n```bash\n# interchain account should have 9990uosmo and some stake in their balance\nosmosisd q bank balances $INTERCHAIN_ADDRESS --home=contrib/osmosis/.osmosis --node=tcp://localhost:26662 --chain-id=osmosis\n\n# pool should have more uosmo than stake, therefore the spot price for uosmo should be less than 1.00 stake\nosmosisd q gamm spot-price 1 stake uosmo --home=contrib/osmosis/.osmosis --node=tcp://localhost:26662 --chain-id=osmosis\n```\n\n\u003cbr\u003e\n\n# Tests\n\n[./interchaintest](./interchaintest/) contains example end-to-end IBC test using [`interchaintest`](https://github.com/strangelove-ventures/interchaintest) - a package that provides test suite for complete interchain simulation\n\n\u003cbr\u003e\n\n### Prerequisites\n\n- Docker\nhttps://docs.docker.com/get-docker/\n\n\u003cbr\u003e\n\n### 1. Build binary image\n\n```bash\nmake build-docker\n```\n\n\u003cbr\u003e\n\n### 2. Run tests\n\n```bash\nmake interchaintest\n```\n\n\u003cbr\u003e\n\n# Working with Docker\n\n### 1. Build binary image\n\n```bash\n# create image named 'swapchaind'\nmake build-docker\n```\n\n\u003cbr\u003e\n\n### 2. Example interaction\n\n```bash\n# init config and persist config folder (/swapchain/.swapchain) to volume 'my-vol'\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind init testmoniker --chain-id=testchainid\n\n# add account key named 'test'\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind keys add test --keyring-backend=test\n\n# fund account and add to genesis\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind add-genesis-account test 999999999999999stake --keyring-backend=test\n\n# generate genesis tx that sets 'test' as validator\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind gentx test 2222222222stake --keyring-backend=test --chain-id=testchainid\n\n# collect the genesis tx and add to genesis\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind collect-gentxs\n\n# start node\ndocker run --rm -it -v=my-vol:/swapchain/.swapchain swapchaind start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgntr%2Fswapchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgntr%2Fswapchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgntr%2Fswapchain/lists"}