Skip to content

Commit

Permalink
Add a base of the tezos atomex protocol;
Browse files Browse the repository at this point in the history
Add the kUSD config
  • Loading branch information
skubarenko committed Aug 12, 2022
1 parent faa9f3c commit a95f710
Show file tree
Hide file tree
Showing 15 changed files with 464 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export { Web3BlockchainWallet } from './evm/index';
export { ExchangeManager, InMemoryExchangeSymbolsProvider } from './exchange/index';
export { EthereumWeb3AtomexProtocolV1, ERC20EthereumWeb3AtomexProtocolV1 } from './ethereum/index';
export { InMemoryAuthorizationManagerStore } from './stores/index';
export { TaquitoBlockchainWallet } from './tezos/index';
export {
TaquitoBlockchainWallet,
TezosTaquitoAtomexProtocolV1, FA12TezosTaquitoAtomexProtocolV1, FA2TezosTaquitoAtomexProtocolV1
} from './tezos/index';
export * from './utils';

export type { AtomexOptions, NewSwapRequest } from './atomex/index';
Expand Down
52 changes: 52 additions & 0 deletions src/tezos/atomexProtocol/fa12TezosTaquitoAtomexProtocolV1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type BigNumber from 'bignumber.js';

import type {
AtomexProtocolV1, AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Transaction
} from '../../blockchain/index';
import type { AtomexNetwork, CurrenciesProvider } from '../../common/index';
import type { DeepReadonly } from '../../core';
import type { FA12TezosTaquitoAtomexProtocolV1Options } from '../models/atomexProtocolOptions';

export class FA12TezosTaquitoAtomexProtocolV1 implements AtomexProtocolV1 {
readonly version = 1;

constructor(
readonly atomexNetwork: AtomexNetwork,
protected readonly currenciesProvider: CurrenciesProvider,
protected readonly atomexProtocolOptions: DeepReadonly<FA12TezosTaquitoAtomexProtocolV1Options>
) {
}

get currencyId() {
return this.atomexProtocolOptions.currencyId;
}

initiate(_params: AtomexProtocolV1InitiateParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedInitiateFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

redeem(_params: AtomexProtocolV1RedeemParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getRedeemReward(_nativeTokenPriceInUsd: number, _nativeTokenPriceInCurrency: number): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

getEstimatedRedeemFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

refund(_params: AtomexProtocolV1RefundParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedRefundFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}
}
52 changes: 52 additions & 0 deletions src/tezos/atomexProtocol/fa2TezosTaquitoAtomexProtocolV1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type BigNumber from 'bignumber.js';

import type {
AtomexProtocolV1, AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Transaction
} from '../../blockchain/index';
import type { AtomexNetwork, CurrenciesProvider } from '../../common/index';
import type { DeepReadonly } from '../../core';
import type { FA2TezosTaquitoAtomexProtocolV1Options } from '../models/atomexProtocolOptions';

export class FA2TezosTaquitoAtomexProtocolV1 implements AtomexProtocolV1 {
readonly version = 1;

constructor(
readonly atomexNetwork: AtomexNetwork,
protected readonly currenciesProvider: CurrenciesProvider,
protected readonly atomexProtocolOptions: DeepReadonly<FA2TezosTaquitoAtomexProtocolV1Options>
) {
}

get currencyId() {
return this.atomexProtocolOptions.currencyId;
}

initiate(_params: AtomexProtocolV1InitiateParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedInitiateFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

redeem(_params: AtomexProtocolV1RedeemParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getRedeemReward(_nativeTokenPriceInUsd: number, _nativeTokenPriceInCurrency: number): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

getEstimatedRedeemFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

refund(_params: AtomexProtocolV1RefundParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedRefundFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}
}
3 changes: 3 additions & 0 deletions src/tezos/atomexProtocol/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { TezosTaquitoAtomexProtocolV1 } from './tezosTaquitoAtomexProtocolV1';
export { FA12TezosTaquitoAtomexProtocolV1 } from './fa12TezosTaquitoAtomexProtocolV1';
export { FA2TezosTaquitoAtomexProtocolV1 } from './fa2TezosTaquitoAtomexProtocolV1';
52 changes: 52 additions & 0 deletions src/tezos/atomexProtocol/tezosTaquitoAtomexProtocolV1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type BigNumber from 'bignumber.js';

import type {
AtomexProtocolV1, AtomexProtocolV1InitiateParameters, AtomexProtocolV1RedeemParameters, AtomexProtocolV1RefundParameters,
Transaction
} from '../../blockchain/index';
import type { AtomexNetwork, CurrenciesProvider } from '../../common/index';
import type { DeepReadonly } from '../../core';
import type { TezosTaquitoAtomexProtocolV1Options } from '../models/atomexProtocolOptions';

export class TezosTaquitoAtomexProtocolV1 implements AtomexProtocolV1 {
readonly version = 1;

constructor(
readonly atomexNetwork: AtomexNetwork,
protected readonly currenciesProvider: CurrenciesProvider,
protected readonly atomexProtocolOptions: DeepReadonly<TezosTaquitoAtomexProtocolV1Options>
) {
}

get currencyId() {
return this.atomexProtocolOptions.currencyId;
}

initiate(_params: AtomexProtocolV1InitiateParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedInitiateFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

redeem(_params: AtomexProtocolV1RedeemParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getRedeemReward(_nativeTokenPriceInUsd: number, _nativeTokenPriceInCurrency: number): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

getEstimatedRedeemFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}

refund(_params: AtomexProtocolV1RefundParameters): Promise<Transaction> {
throw new Error('Method not implemented.');
}

getEstimatedRefundFees(_params: Partial<AtomexProtocolV1InitiateParameters>): Promise<BigNumber> {
throw new Error('Method not implemented.');
}
}
90 changes: 90 additions & 0 deletions src/tezos/config/atomexProtocol/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

import type { FA12TezosTaquitoAtomexProtocolV1Options, FA2TezosTaquitoAtomexProtocolV1Options } from '../../models/index';

export const mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase: Omit<
FA12TezosTaquitoAtomexProtocolV1Options,
'currencyId' | 'swapContractAddress' | 'swapContractBlockId'
> = {
atomexProtocolVersion: 1,
initiateOperation: {
fee: 11000,
gasLimit: 110000,
storageLimit: 350,
},
redeemOperation: {
fee: 11000,
gasLimit: 15000,
storageLimit: 257
},
refundOperation: {
fee: 11000,
gasLimit: 110000,
storageLimit: 257,
}
};

export const mainnetFA2TezosTaquitoAtomexProtocolV1OptionsBase: Omit<
FA2TezosTaquitoAtomexProtocolV1Options,
'currencyId' | 'swapContractAddress' | 'swapContractBlockId'
> = {
atomexProtocolVersion: 1,
initiateOperation: {
fee: 350000,
gasLimit: 400000,
storageLimit: 250,
},
redeemOperation: {
fee: 120000,
gasLimit: 400000,
storageLimit: 257
},
refundOperation: {
fee: 120000,
gasLimit: 400000,
storageLimit: 257,
}
};

export const testnetFA12TezosTaquitoAtomexProtocolV1OptionsBase: Omit<
FA12TezosTaquitoAtomexProtocolV1Options,
'currencyId' | 'swapContractAddress' | 'swapContractBlockId'
> = {
atomexProtocolVersion: 1,
initiateOperation: {
fee: 2000,
gasLimit: 15000,
storageLimit: 350,
},
redeemOperation: {
fee: 2500,
gasLimit: 20000,
storageLimit: 257
},
refundOperation: {
fee: 2500,
gasLimit: 15000,
storageLimit: 257,
}
};

export const testnetFA2TezosTaquitoAtomexProtocolV1OptionsBase: Omit<
FA2TezosTaquitoAtomexProtocolV1Options,
'currencyId' | 'swapContractAddress' | 'swapContractBlockId'
> = {
atomexProtocolVersion: 1,
initiateOperation: {
fee: 350000,
gasLimit: 400000,
storageLimit: 250,
},
redeemOperation: {
fee: 120000,
gasLimit: 400000,
storageLimit: 257
},
refundOperation: {
fee: 120000,
gasLimit: 400000,
storageLimit: 257,
}
};
2 changes: 2 additions & 0 deletions src/tezos/config/atomexProtocol/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { mainnetTezosTaquitoAtomexProtocolV1Options } from './mainnetV1Options';
export { testnetTezosTaquitoAtomexProtocolV1Options } from './testnetV1Options';
61 changes: 61 additions & 0 deletions src/tezos/config/atomexProtocol/mainnetV1Options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type { FA12TezosTaquitoAtomexProtocolV1Options, FA2TezosTaquitoAtomexProtocolV1Options, TezosTaquitoAtomexProtocolV1Options } from '../../models/index';
import { mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase, mainnetFA2TezosTaquitoAtomexProtocolV1OptionsBase } from './base';

const mainnetNativeTezosTaquitoAtomexProtocolV1Options: TezosTaquitoAtomexProtocolV1Options = {
atomexProtocolVersion: 1,
currencyId: 'XTZ',
swapContractAddress: 'KT1VG2WtYdSWz5E7chTeAdDPZNy2MpP8pTfL',
swapContractBlockId: '513046',
initiateOperation: {
fee: 2000,
gasLimit: 11000,
storageLimit: 257
},
redeemOperation: {
fee: 2000,
gasLimit: 15000,
storageLimit: 257
},
refundOperation: {
fee: 1600,
gasLimit: 13000,
storageLimit: 257,
}
};

const mainnetTZBTCTezosTaquitoAtomexProtocolV1Options: FA12TezosTaquitoAtomexProtocolV1Options = {
...mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase,
currencyId: 'TZBTC',
swapContractAddress: 'KT1Ap287P1NzsnToSJdA4aqSNjPomRaHBZSr',
swapContractBlockId: '900350',
redeemOperation: {
...mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase.redeemOperation,
gasLimit: 180000
}
};

const mainnetKUSDTezosTaquitoAtomexProtocolV1Options: FA12TezosTaquitoAtomexProtocolV1Options = {
...mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase,
currencyId: 'KUSD',
swapContractAddress: 'KT1EpQVwqLGSH7vMCWKJnq6Uxi851sEDbhWL',
swapContractBlockId: '1358868',
redeemOperation: {
...mainnetFA12TezosTaquitoAtomexProtocolV1OptionsBase.redeemOperation,
gasLimit: 110000
}
};


const mainnetUSDtTezosTaquitoAtomexProtocolV1Options: FA2TezosTaquitoAtomexProtocolV1Options = {
...mainnetFA2TezosTaquitoAtomexProtocolV1OptionsBase,
currencyId: 'USDT_XTZ',
swapContractAddress: 'KT1Ays1Chwx3ArnHGoQXchUgDsvKe9JboUjj',
swapContractBlockId: '2496680'
};

export const mainnetTezosTaquitoAtomexProtocolV1Options = {
XTZ: mainnetNativeTezosTaquitoAtomexProtocolV1Options,
TZBTC: mainnetTZBTCTezosTaquitoAtomexProtocolV1Options,
KUSD: mainnetKUSDTezosTaquitoAtomexProtocolV1Options,
USDT_XTZ: mainnetUSDtTezosTaquitoAtomexProtocolV1Options
} as const;
37 changes: 37 additions & 0 deletions src/tezos/config/atomexProtocol/testnetV1Options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { FA2TezosTaquitoAtomexProtocolV1Options, TezosTaquitoAtomexProtocolV1Options } from '../../models/index';
import { testnetFA2TezosTaquitoAtomexProtocolV1OptionsBase } from './base';

const testnetNativeTezosTaquitoAtomexProtocolV1Options: TezosTaquitoAtomexProtocolV1Options = {
atomexProtocolVersion: 1,
currencyId: 'XTZ',
swapContractAddress: 'KT1VG2WtYdSWz5E7chTeAdDPZNy2MpP8pTfL',
swapContractBlockId: '513046',
initiateOperation: {
fee: 2000,
gasLimit: 11000,
storageLimit: 257
},
redeemOperation: {
fee: 2000,
gasLimit: 15000,
storageLimit: 257
},
refundOperation: {
fee: 1600,
gasLimit: 13000,
storageLimit: 257,
}
};


const testnetUSDtTezosTaquitoAtomexProtocolV1Options: FA2TezosTaquitoAtomexProtocolV1Options = {
...testnetFA2TezosTaquitoAtomexProtocolV1OptionsBase,
currencyId: 'USDT_XTZ',
swapContractAddress: 'KT1BWvRQnVVowZZLGkct9A7sdj5YEe8CdUhR',
swapContractBlockId: '665321'
};

export const testnetTezosTaquitoAtomexProtocolV1Options = {
XTZ: testnetNativeTezosTaquitoAtomexProtocolV1Options,
USDT_XTZ: testnetUSDtTezosTaquitoAtomexProtocolV1Options
} as const;
11 changes: 11 additions & 0 deletions src/tezos/config/currencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ const tzBtcCurrency: FA12TezosCurrency = {
decimals: 8,
};

const kusdCurrency: FA12TezosCurrency = {
id: 'KUSD',
name: 'Kolibri USD',
symbol: 'kUSD',
blockchain: 'tezos',
type: 'fa1.2',
contractAddress: 'KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV',
decimals: 18
};

const usdtCurrency: FA2TezosCurrency = {
id: 'USDT_XTZ',
name: 'Tether USD',
Expand All @@ -33,6 +43,7 @@ const usdtCurrency: FA2TezosCurrency = {
export const tezosMainnetCurrencies: TezosCurrency[] = [
nativeTezosCurrency,
tzBtcCurrency,
kusdCurrency,
usdtCurrency
];

Expand Down
Loading

0 comments on commit a95f710

Please sign in to comment.