Skip to content

Commit

Permalink
Merge pull request #889 from osmosis-labs/JP69/move-axl-transfer-fee
Browse files Browse the repository at this point in the history
Move axl Transfer Fee Definition
  • Loading branch information
jonator authored Oct 19, 2022
2 parents 262d701 + ead2fae commit bdde4b4
Show file tree
Hide file tree
Showing 14 changed files with 327 additions and 90 deletions.
11 changes: 11 additions & 0 deletions packages/stores/src/bridge-history/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "mobx";
import { computedFn } from "mobx-utils";
import { KVStore } from "@keplr-wallet/common";
import { IQueriesStore, CosmosQueries } from "@keplr-wallet/stores";
import { TxStatus } from "./types";
import { ITxStatusReceiver, ITxStatusSource } from "./types";

Expand Down Expand Up @@ -37,6 +38,8 @@ export class NonIbcBridgeHistoryStore implements ITxStatusReceiver {
private isRestoredFromLocalStorage = false;

constructor(
protected readonly queriesStore: IQueriesStore<CosmosQueries>,
protected readonly chainId: string,
protected readonly kvStore: KVStore,
protected readonly txStatusSources: ITxStatusSource[] = [],
protected readonly historyExpireDays = 3
Expand Down Expand Up @@ -143,6 +146,14 @@ export class NonIbcBridgeHistoryStore implements ITxStatusReceiver {
return;
}

// update balances if successful
if (status === "success") {
this.queriesStore
.get(this.chainId)
.queryBalances.getQueryBech32Address(snapshot.accountAddress)
.fetch();
}

snapshot.status = status;
snapshot.reason = reason;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/stores/types/bridge-history/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { KVStore } from "@keplr-wallet/common";
import { IQueriesStore, CosmosQueries } from "@keplr-wallet/stores";
import { TxStatus } from "./types";
import { ITxStatusReceiver, ITxStatusSource } from "./types";
/** Persistable data enough to identify a tx. */
Expand All @@ -17,13 +18,15 @@ declare type TxSnapshot = {
* NOTE: source keyPrefix values must be unique.
*/
export declare class NonIbcBridgeHistoryStore implements ITxStatusReceiver {
protected readonly queriesStore: IQueriesStore<CosmosQueries>;
protected readonly chainId: string;
protected readonly kvStore: KVStore;
protected readonly txStatusSources: ITxStatusSource[];
protected readonly historyExpireDays: number;
/** Volatile store of tx statuses. `prefixedKey => TxSnapshot` */
protected snapshots: TxSnapshot[];
private isRestoredFromLocalStorage;
constructor(kvStore: KVStore, txStatusSources?: ITxStatusSource[], historyExpireDays?: number);
constructor(queriesStore: IQueriesStore<CosmosQueries>, chainId: string, kvStore: KVStore, txStatusSources?: ITxStatusSource[], historyExpireDays?: number);
addStatusSource(source: ITxStatusSource): void;
getHistoriesByAccount: (accountAddress: string) => {
key: string;
Expand Down
30 changes: 29 additions & 1 deletion packages/web/config/chain-infos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ const chainInfos = (
coinDenom: "stJUNO",
coinMinimalDenom: "stujuno",
coinDecimals: 6,
// coinGeckoId: "juno-network",
coinGeckoId: "pool:stujuno",
coinImageUrl: "/tokens/stjuno.svg",
},
{
Expand Down Expand Up @@ -2016,6 +2016,34 @@ const chainInfos = (
features: ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go"],
explorerUrlToTx: "https://rebus.explorers.guru/transaction/{txHash}",
},
{
rpc: "https://rpc.mainnet.teritori.com/",
rest: "https://rest.mainnet.teritori.com/",
chainId: "teritori-1",
chainName: "Teritori",
bip44: {
coinType: 118,
},
bech32Config: Bech32Address.defaultBech32Config("tori"),
currencies: [
{
coinDenom: "TORI",
coinMinimalDenom: "utori",
coinDecimals: 6,
coinGeckoId: "pool:utori",
coinImageUrl: "/tokens/utori.png",
isStakeCurrency: true,
isFeeCurrency: true,
},
],
gasPriceStep: {
low: 0.0,
average: 0.25,
high: 0.5,
},
features: ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go"],
explorerUrlToTx: "https://explorer.teritori.com/teritori/tx/{txHash}",
},
] as SimplifiedChainInfo[]
).map(createKeplrChainInfos);

Expand Down
19 changes: 13 additions & 6 deletions packages/web/config/feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,19 @@ export const ExternalIncentiveGaugeAllowList: {
],
"602": [
{
gaugeId: "21788",
gaugeId: "29713",
denom:
"ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA",
},
{
gaugeId: "21790",
gaugeId: "29715",
denom:
"ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA",
},
],
"604": [
{
gaugeId: "2912",
gaugeId: "29704",
denom:
"ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4",
},
Expand Down Expand Up @@ -547,7 +547,7 @@ export const ExternalIncentiveGaugeAllowList: {
],
"611": [
{
gaugeId: "2913",
gaugeId: "29705",
denom:
"ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4",
},
Expand All @@ -573,12 +573,12 @@ export const ExternalIncentiveGaugeAllowList: {
],
"617": [
{
gaugeId: "21792",
gaugeId: "29716",
denom:
"ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA",
},
{
gaugeId: "21793",
gaugeId: "29717",
denom:
"ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA",
},
Expand Down Expand Up @@ -1098,4 +1098,11 @@ export const ExternalIncentiveGaugeAllowList: {
denom: "uosmo",
},
],
"817": [
{
gaugeId: "29724",
denom:
"ibc/A8CA5EE328FA10C9519DF6057DA1F69682D28F7D0F5CCC7ECB72E3DCA2D157A4",
},
],
};
34 changes: 24 additions & 10 deletions packages/web/config/ibc-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,23 @@ export const IBCAssetInfos: (IBCAsset & {
wallets: ["metamask" as const, "walletconnect" as const],
method: "deposit-address" as const,
sourceChains: [AxelarSourceChainConfigs.usdc.ethereum],
tokenMinDenom: IS_TESTNET ? "uausdc" : "uusdc", // test: "uausdc"
transferFeeMinAmount: IS_TESTNET ? "150000" : "10500000", // From https://docs.axelar.dev/resources/mainnet#cross-chain-relayer-gas-fee
},
},
{
counterpartyChainId: "axelar-dojo-1",
sourceChannelId: "channel-208",
destChannelId: "channel-3",
counterpartyChainId: IS_TESTNET
? "axelar-testnet-lisbon-3"
: "axelar-dojo-1",
sourceChannelId: IS_TESTNET ? "channel-312" : "channel-208",
destChannelId: IS_TESTNET ? "channel-22" : "channel-3",
coinMinimalDenom: "weth-wei",
depositUrlOverride:
"https://satellite.money/?source=ethereum&destination=osmosis&asset_denom=weth-wei",
withdrawUrlOverride:
"https://satellite.money/?source=osmosis&destination=ethereum&asset_denom=weth-wei",
sourceChainNameOverride: "Ethereum",
sourceChainNameOverride: IS_TESTNET ? "Ropsten Ethereum" : "Ethereum",
isVerified: true,
originBridgeInfo: {
bridge: "axelar" as const,
wallets: ["metamask" as const, "walletconnect" as const],
method: "deposit-address" as const,
sourceChains: [AxelarSourceChainConfigs.weth.ethereum],
},
},
{
counterpartyChainId: "axelar-dojo-1",
Expand Down Expand Up @@ -906,6 +908,18 @@ export const IBCAssetInfos: (IBCAsset & {
destChannelId: "channel-0",
coinMinimalDenom: "arebus",
},
{
counterpartyChainId: "teritori-1",
sourceChannelId: "channel-362",
destChannelId: "channel-0",
coinMinimalDenom: "utori",
},
{
counterpartyChainId: "stride-1",
sourceChannelId: "channel-326",
destChannelId: "channel-5",
coinMinimalDenom: "stujuno",
},
].filter((ibcAsset) => {
// validate IBC asset config
if (
Expand Down
23 changes: 23 additions & 0 deletions packages/web/config/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,27 @@ export const PoolPriceRoutes: IntermediateRoute[] = [
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
},
{
alternativeCoinId: "pool:utori",
poolId: "816",
spotPriceSourceDenom: DenomHelper.ibcDenom(
[{ portId: "transfer", channelId: "channel-362" }],
"utori"
),
spotPriceDestDenom: "uosmo",
destCoinId: "osmosis",
},
{
alternativeCoinId: "pool:stujuno",
poolId: "817",
spotPriceSourceDenom: DenomHelper.ibcDenom(
[{ portId: "transfer", channelId: "channel-326" }],
"stujuno"
),
spotPriceDestDenom: DenomHelper.ibcDenom(
[{ portId: "transfer", channelId: "channel-42" }],
"ujuno"
),
destCoinId: "juno-network",
},
];
6 changes: 3 additions & 3 deletions packages/web/integrations/axelar/hooks/use-deposit-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function useDepositAddress(
sourceChain: string,
destChain: string,
address: string | undefined,
tokenMinDenom: string,
coinMinimalDenom: string,
generateOnMount = true,
environment = Environment.MAINNET
): {
Expand All @@ -20,7 +20,7 @@ export function useDepositAddress(
if (address && depositAddress === null) {
setIsLoading(true);
new AxelarAssetTransfer({ environment })
.getDepositAddress(sourceChain, destChain, address, tokenMinDenom)
.getDepositAddress(sourceChain, destChain, address, coinMinimalDenom)
.then((generatedAddress) => {
setDepositAddress(generatedAddress);
})
Expand All @@ -36,7 +36,7 @@ export function useDepositAddress(
address,
sourceChain,
destChain,
tokenMinDenom,
coinMinimalDenom,
setIsLoading,
]);

Expand Down
1 change: 1 addition & 0 deletions packages/web/integrations/axelar/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./queries";
export * from "./source-chain-config";
export * from "./transfer-status-source";
export * from "./types";
export * from "./utils";
65 changes: 65 additions & 0 deletions packages/web/integrations/axelar/source-chain-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { SourceChainConfig } from "./types";

const IS_TESTNET = process.env.NEXT_PUBLIC_IS_TESTNET === "true";

/** https://axelarscan.io/assets
* Ensure that users bridge sufficient amounts from EthMainnet=>NonEthEvm via Axelar before enabling.
*/
export const SourceChainConfigs: {
[asset: string]: { [chain: string]: SourceChainConfig };
} = {
usdc: {
ethereum: {
id: IS_TESTNET
? ("Ropsten Test Network" as const)
: ("Ethereum" as const),
erc20ContractAddress: IS_TESTNET
? "0x526f0A95EDC3DF4CBDB7bb37d4F7Ed451dB8e369"
: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // test: 'aUSDC' on metamask/etherscan
logoUrl: "/networks/ethereum.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "10500000", // From https://docs.axelar.dev/resources/mainnet#cross-chain-relayer-gas-fee
},
bnbChain: {
id: "Binance" as const,
erc20ContractAddress: "0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3",
logoUrl: "/networks/binance.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000",
},
avalanche: {
id: "Avalanche" as const,
erc20ContractAddress: "0xfaB550568C688d5D8A52C7d794cb93Edc26eC0eC",
logoUrl: "/networks/avalanche.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000",
},
polygon: {
id: "Polygon" as const,
erc20ContractAddress: "0x750e4C4984a9e0f12978eA6742Bc1c5D248f40ed",
logoUrl: "/networks/polygon.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000",
},
fantom: {
id: "Fantom" as const,
erc20ContractAddress: "0x1B6382DBDEa11d97f24495C9A90b7c88469134a4",
logoUrl: "/networks/fantom.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000",
},
moonbeam: {
id: "Moonbeam" as const,
erc20ContractAddress: "0xCa01a1D0993565291051daFF390892518ACfAD3A",
logoUrl: "/networks/moonbeam.svg",
transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000",
},
},
weth: {
ethereum: {
id: IS_TESTNET
? ("Ropsten Test Network" as const)
: ("Ethereum" as const),
erc20ContractAddress: IS_TESTNET
? "0xc778417E063141139Fce010982780140Aa0cD5Ab"
: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
logoUrl: "/networks/ethereum.svg",
transferFeeMinAmount: IS_TESTNET ? "60000000000000" : "6300000000000000",
},
},
};
Loading

0 comments on commit bdde4b4

Please sign in to comment.