Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0cf7ef8
[DEV-622] scaffolded strategies for bitcoin and erc-20 tokens
TonySemikin Sep 28, 2022
21c611a
[DEV-622] restructured dex strategies
TonySemikin Sep 29, 2022
6f7f433
[DEV-622] added new strategies to facades
TonySemikin Sep 29, 2022
f8a9195
Merge remote-tracking branch 'origin/develop' into feature/DEV-622-bu…
TonySemikin Sep 30, 2022
ebd77b7
[DEV-622] adapted DexEvmService to token purchase
TonySemikin Oct 3, 2022
a6bbeab
[DEV-622] restructured payout strategies
TonySemikin Oct 3, 2022
e11bbb0
[DEV-622] added payout strategies placeholders
TonySemikin Oct 3, 2022
f5e64c3
[DEV-622] private methds naming cleanup in dex module
TonySemikin Oct 3, 2022
57a3ef9
[DEV-622] refactored payout service to group orders by strategies
TonySemikin Oct 3, 2022
a466663
[DEV-622] implemented dex strategies for bitcoin and eth tokens
TonySemikin Oct 4, 2022
48abcc1
[DEV-622] implemented prepare strategy for bitcoin
TonySemikin Oct 4, 2022
d30f9d6
[DEV-622] added erc20 contract integration
TonySemikin Oct 5, 2022
9ed096c
[DEV-622] basic test swap for evm
TonySemikin Oct 6, 2022
d06636f
[DEV-622] fixed abi import and denomination of erc20 tokens
TonySemikin Oct 6, 2022
481ef15
[DEV-622] implemented new reference asset rules
TonySemikin Oct 6, 2022
c1b9960
[DEV-622] implemented btc to dfi pricing path
TonySemikin Oct 6, 2022
074a0bc
[DEV-622] refactored bitcoin payout strategy to use shared jellyfish …
TonySemikin Oct 6, 2022
c8c3eec
[DEV-622] remove redundant method binding
TonySemikin Oct 6, 2022
815166c
[DEV-622] implemented reference assets rules for evm liquidity strate…
TonySemikin Oct 6, 2022
a9649c2
[DEV-622] fixed abi import path
TonySemikin Oct 7, 2022
3cfcc1b
[DEV-622] changed naming in dfi payout strategy
TonySemikin Oct 7, 2022
f0eed20
[DEV-622] several adjustments during testing
TonySemikin Oct 10, 2022
c7159ff
[DEV-622] fix payout completion check error
TonySemikin Oct 10, 2022
b57e8df
[DEV-622] made swap contract and token configurable
TonySemikin Oct 10, 2022
e2b8118
[DEV-622] fixed evm client construction
TonySemikin Oct 10, 2022
5624a94
[DEV-622] extended env example file
TonySemikin Oct 10, 2022
a72c280
Merge remote-tracking branch 'origin/develop' into feature/DEV-622-bu…
TonySemikin Oct 10, 2022
1793df6
[DEV-622] created migration
TonySemikin Oct 10, 2022
71d847e
[DEV-622] implemented fallback to currency logic in pricing module
TonySemikin Oct 10, 2022
f4309fc
[DEV-622] Switched to ALTER COLUMN
davidleomay Oct 11, 2022
0737fc1
[DEV-622] added env configuration
TonySemikin Oct 11, 2022
7028fb7
[DEV-622] addressed PR comments
TonySemikin Oct 12, 2022
8279ffa
Merge remote-tracking branch 'origin/develop' into feature/DEV-622-bu…
TonySemikin Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ ETH_WALLET_ADDRESS=
ETH_WALLET_PRIVATE_KEY=
ETH_GATEWAY_URL=
ETH_API_KEY=
ETH_SWAP_CONTRACT_ADDRESS=
ETH_SWAP_TOKEN_ADDRESS=
BSC_WALLET_ADDRESS=
BSC_WALLET_PRIVATE_KEY=
BSC_GATEWAY_URL=
BSC_SWAP_CONTRACT_ADDRESS=
BSC_SWAP_TOKEN_ADDRESS=
LETTER_USER=
LETTER_AUTH=
LETTER_URL=
Expand Down
43 changes: 28 additions & 15 deletions infrastructure/bicep/dfx-api.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ param ethWalletPrivateKey string
param ethGatewayUrl string
@secure()
param ethApiKey string
param ethSwapContractAddress string
param ethSwapTokenAddress string

param bscWalletAddress string
@secure()
param bscWalletPrivateKey string
param bscGatewayUrl string
param bscSwapContractAddress string
param bscSwapTokenAddress string

param nodeServicePlanSkuName string
param nodeServicePlanSkuTier string
Expand Down Expand Up @@ -113,7 +117,6 @@ param paymentUrl string
@secure()
param lockApiKey string


// --- VARIABLES --- //
var compName = 'dfx'
var apiName = 'api'
Expand All @@ -134,7 +137,6 @@ var apiServicePlanName = 'plan-${compName}-${apiName}-${env}'
var apiAppName = 'app-${compName}-${apiName}-${env}'
var appInsightsName = 'appi-${compName}-${apiName}-${env}'


var nodeProps = [
{
name: 'nodes-input-${env}'
Expand Down Expand Up @@ -246,7 +248,6 @@ resource virtualNet 'Microsoft.Network/virtualNetworks@2020-11-01' = {
}
}


// Storage Account
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: storageAccountName
Expand All @@ -267,7 +268,6 @@ resource dbBackupContainer 'Microsoft.Storage/storageAccounts/blobServices/conta
name: '${storageAccount.name}/default/${dbBackupContainerName}'
}


// SQL Database
resource sqlServer 'Microsoft.Sql/servers@2021-02-01-preview' = {
name: sqlServerName
Expand All @@ -279,11 +279,11 @@ resource sqlServer 'Microsoft.Sql/servers@2021-02-01-preview' = {
}

resource sqlVNetRule 'Microsoft.Sql/servers/virtualNetworkRules@2021-02-01-preview' = {
parent: sqlServer
name: 'apiVNetRule'
properties: {
virtualNetworkSubnetId: virtualNet.properties.subnets[0].id
}
parent: sqlServer
name: 'apiVNetRule'
properties: {
virtualNetworkSubnetId: virtualNet.properties.subnets[0].id
}
}

resource sqlAllRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-preview' = if (dbAllowAllIps) {
Expand Down Expand Up @@ -326,14 +326,13 @@ resource sqlDbLtrPolicy 'Microsoft.Sql/servers/databases/backupLongTermRetention
}
}


// API App Service
resource appServicePlan 'Microsoft.Web/serverfarms@2018-02-01' = {
name: apiServicePlanName
location: location
kind: 'linux'
properties: {
reserved: true
reserved: true
}
sku: {
name: 'P1v2'
Expand All @@ -350,7 +349,7 @@ resource apiAppService 'Microsoft.Web/sites@2018-11-01' = {
serverFarmId: appServicePlan.id
httpsOnly: true
virtualNetworkSubnetId: virtualNet.properties.subnets[0].id

siteConfig: {
alwaysOn: true
linuxFxVersion: 'NODE|14-lts'
Expand All @@ -359,7 +358,7 @@ resource apiAppService 'Microsoft.Web/sites@2018-11-01' = {
logsDirectorySizeLimit: 100
vnetRouteAllEnabled: true
scmIpSecurityRestrictionsUseMain: true

appSettings: [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
Expand Down Expand Up @@ -534,6 +533,14 @@ resource apiAppService 'Microsoft.Web/sites@2018-11-01' = {
name: 'ETH_API_KEY'
value: ethApiKey
}
{
name: 'ETH_SWAP_CONTRACT_ADDRESS'
value: ethSwapContractAddress
}
{
name: 'ETH_SWAP_TOKEN_ADDRESS'
value: ethSwapTokenAddress
}
{
name: 'BSC_WALLET_ADDRESS'
value: bscWalletAddress
Expand All @@ -546,6 +553,14 @@ resource apiAppService 'Microsoft.Web/sites@2018-11-01' = {
name: 'BSC_GATEWAY_URL'
value: bscGatewayUrl
}
{
name: 'BSC_SWAP_CONTRACT_ADDRESS'
value: bscSwapContractAddress
}
{
name: 'BSC_SWAP_TOKEN_ADDRESS'
value: bscSwapTokenAddress
}
{
name: 'BTC_COLLECTOR_ADDRESS'
value: btcCollectorAddress
Expand Down Expand Up @@ -679,7 +694,6 @@ resource appInsights 'microsoft.insights/components@2020-02-02-preview' = {
}
}


// DeFi Nodes
module nodes 'defi-node.bicep' = [for node in nodeProps: {
name: node.name
Expand All @@ -699,7 +713,6 @@ module nodes 'defi-node.bicep' = [for node in nodeProps: {
}
}]


// BTC Node
resource vmNsg 'Microsoft.Network/networkSecurityGroups@2020-11-01' = {
name: vmNsgName
Expand Down
12 changes: 12 additions & 0 deletions infrastructure/bicep/parameters/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
"ethApiKey": {
"value": "xxx"
},
"ethSwapContractAddress": {
"value": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
},
"ethSwapTokenAddress": {
"value": "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6"
},
"bscWalletAddress": {
"value": "xxx"
},
Expand All @@ -95,6 +101,12 @@
"bscGatewayUrl": {
"value": "https://data-seed-prebsc-1-s1.binance.org:8545"
},
"bscSwapContractAddress": {
"value": "0xD99D1c33F9fC3444f8101754aBC46c52416550D1"
},
"bscSwapTokenAddress": {
"value": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"
},
"btcCollectorAddress": {
"value": "xxx"
},
Expand Down
12 changes: 12 additions & 0 deletions infrastructure/bicep/parameters/loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
"ethApiKey": {
"value": "xxx"
},
"ethSwapContractAddress": {
"value": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
},
"ethSwapTokenAddress": {
"value": "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6"
},
"bscWalletAddress": {
"value": "xxx"
},
Expand All @@ -95,6 +101,12 @@
"bscGatewayUrl": {
"value": "https://data-seed-prebsc-1-s1.binance.org:8545"
},
"bscSwapContractAddress": {
"value": "0xD99D1c33F9fC3444f8101754aBC46c52416550D1"
},
"bscSwapTokenAddress": {
"value": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd"
},
"btcCollectorAddress": {
"value": "xxx"
},
Expand Down
12 changes: 12 additions & 0 deletions infrastructure/bicep/parameters/prd.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
"ethApiKey": {
"value": "xxx"
},
"ethSwapContractAddress": {
"value": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
},
"ethSwapTokenAddress": {
"value": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
},
"bscWalletAddress": {
"value": "xxx"
},
Expand All @@ -95,6 +101,12 @@
"bscGatewayUrl": {
"value": "https://bsc-dataseed.binance.org"
},
"bscSwapContractAddress": {
"value": "0x10ED43C718714eb63d5aA57B78B54704E256024E"
},
"bscSwapTokenAddress": {
"value": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
},
"btcCollectorAddress": {
"value": "xxx"
},
Expand Down
13 changes: 13 additions & 0 deletions migration/1665408086368-assetChainId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { MigrationInterface, QueryRunner } = require("typeorm");

module.exports = class assetChainId1665408086368 {
name = 'assetChainId1665408086368'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "asset" ALTER COLUMN "chainId" nvarchar(255)`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "asset" ALTER COLUMN "chainId" int`);
}
}
10 changes: 8 additions & 2 deletions src/blockchain/bsc/bsc-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { EvmClient } from '../shared/evm/evm-client';

export class BscClient extends EvmClient {
constructor(gatewayUrl: string, privateKey: string, address: string) {
super(gatewayUrl, privateKey, address);
constructor(
gatewayUrl: string,
privateKey: string,
dfxAddress: string,
swapContractAddress: string,
swapTokenAddress: string,
) {
super(gatewayUrl, privateKey, dfxAddress, swapContractAddress, swapTokenAddress);
}
}
5 changes: 3 additions & 2 deletions src/blockchain/bsc/bsc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { EvmService } from '../shared/evm/evm.service';
@Injectable()
export class BscService extends EvmService {
constructor() {
const { bscGatewayUrl, bscWalletAddress, bscWalletPrivateKey } = GetConfig().blockchain.bsc;
const { bscGatewayUrl, bscWalletAddress, bscWalletPrivateKey, pancakeRouterAddress, swapTokenAddress } =
GetConfig().blockchain.bsc;

super(bscGatewayUrl, '', bscWalletAddress, bscWalletPrivateKey, BscClient);
super(bscGatewayUrl, '', bscWalletAddress, bscWalletPrivateKey, pancakeRouterAddress, swapTokenAddress, BscClient);
}
}
10 changes: 8 additions & 2 deletions src/blockchain/ethereum/ethereum-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { EvmClient } from '../shared/evm/evm-client';

export class EthereumClient extends EvmClient {
constructor(gatewayUrl: string, privateKey: string, address: string) {
super(gatewayUrl, privateKey, address);
constructor(
gatewayUrl: string,
privateKey: string,
dfxAddress: string,
swapContractAddress: string,
swapTokenAddress: string,
) {
super(gatewayUrl, privateKey, dfxAddress, swapContractAddress, swapTokenAddress);
}
}
19 changes: 17 additions & 2 deletions src/blockchain/ethereum/ethereum.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@ import { EvmService } from '../shared/evm/evm.service';
@Injectable()
export class EthereumService extends EvmService {
constructor() {
const { ethGatewayUrl, ethApiKey, ethWalletAddress, ethWalletPrivateKey } = GetConfig().blockchain.ethereum;
const {
ethGatewayUrl,
ethApiKey,
ethWalletAddress,
ethWalletPrivateKey,
uniswapV2Router02Address,
swapTokenAddress,
} = GetConfig().blockchain.ethereum;

super(ethGatewayUrl, ethApiKey, ethWalletAddress, ethWalletPrivateKey, EthereumClient);
super(
ethGatewayUrl,
ethApiKey,
ethWalletAddress,
ethWalletPrivateKey,
uniswapV2Router02Address,
swapTokenAddress,
EthereumClient,
);
}
}
Loading