diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml new file mode 100644 index 0000000000..a0eca20530 --- /dev/null +++ b/.github/workflows/deploy-production.yaml @@ -0,0 +1,67 @@ +name: 'Deploy Production' +concurrency: prod +on: + push: + branches: + - main +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout +jobs: + deploy: + name: Build & Deploy production using SST + environment: production + runs-on: ubuntu-latest + env: + ONE_INCH_API_KEY: ${{ secrets.ONE_INCH_API_KEY }} + ONE_INCH_API_VERSION: ${{ secrets.ONE_INCH_API_VERSION }} + ONE_INCH_API_URL: ${{ secrets.ONE_INCH_API_URL }} + ONE_INCH_ALLOWED_SWAP_PROTOCOLS: ${{ secrets.ONE_INCH_ALLOWED_SWAP_PROTOCOLS }} + ONE_INCH_SWAP_CHAIN_IDS: ${{ secrets.ONE_INCH_SWAP_CHAIN_IDS }} + MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} + SUBGRAPH_BASE: ${{ secrets.SUBGRAPH_BASE }} + RPC_GATEWAY: ${{ secrets.RPC_GATEWAY }} + DEBANK_API_KEY: ${{ secrets.DEBANK_API_KEY }} + DEBANK_API_URL: ${{ secrets.DEBANK_API_URL }} + POWERTOOLS_LOG_LEVEL: ${{ vars.POWERTOOLS_LOG_LEVEL }} + + steps: + - name: Git clone the repository + uses: actions/checkout@v3 + + - name: Cache turbo build setup + uses: actions/cache@v3 + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo- + + - uses: pnpm/action-setup@v2.0.1 + with: + version: 8.14.1 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: 'pnpm' + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Install dependencies + run: pnpm install + + - name: Prebuild + run: pnpm prebuild + + - name: Build + run: pnpm build + + - name: Deploy app + run: | + pnpm run sst:deploy:prod diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 28a31ea68b..bd01a19f4c 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -57,6 +57,12 @@ jobs: - name: Install dependencies run: pnpm install + - name: Prebuild + run: pnpm prebuild + + - name: Build + run: pnpm build + - name: Deploy app run: | pnpm run sst:deploy:staging diff --git a/.github/workflows/merge-main.yaml b/.github/workflows/merge-main.yaml deleted file mode 100644 index bbcc8ffc83..0000000000 --- a/.github/workflows/merge-main.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# This is a basic workflow that is manually triggered - -name: Merge DEV -> Main - -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. -on: - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "greet" - release: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 20 - - name: git config - run: | - git config user.name ${{ github.actor }} - - - name: Merge dev -> main - run: | - git status - git pull - git fetch - git checkout main - git rebase dev - git push origin main - git status diff --git a/sdk/sdk-common/src/common/utils/TokenUtils.ts b/sdk/sdk-common/src/common/utils/TokenUtils.ts new file mode 100644 index 0000000000..bafd4d8e20 --- /dev/null +++ b/sdk/sdk-common/src/common/utils/TokenUtils.ts @@ -0,0 +1,5 @@ +import { IToken } from '../interfaces/IToken' + +export function isSameTokens(a: IToken, b: IToken): boolean { + return a.address === b.address && a.chainInfo.chainId === b.chainInfo.chainId +} diff --git a/sdk/sdk-common/src/common/utils/index.ts b/sdk/sdk-common/src/common/utils/index.ts index b3b8441d0b..c89f3ce010 100644 --- a/sdk/sdk-common/src/common/utils/index.ts +++ b/sdk/sdk-common/src/common/utils/index.ts @@ -1,2 +1,3 @@ export * from './PositionUtils' export * from './PercentageUtils' +export * from './TokenUtils' diff --git a/sdk/sdk-server/src/handlers/getRefinanceSimulation.ts b/sdk/sdk-server/src/handlers/getRefinanceSimulation.ts index 2d4724c4ed..bd21be09a3 100644 --- a/sdk/sdk-server/src/handlers/getRefinanceSimulation.ts +++ b/sdk/sdk-server/src/handlers/getRefinanceSimulation.ts @@ -3,12 +3,27 @@ import type { ISimulation, SimulationType } from '@summerfi/sdk-common/simulatio import { refinanceLendingToLendingSamePair, type IRefinanceDependencies, + refinanceLendingToLendingAnyPair, } from '@summerfi/simulator-service/strategies' import type { IRefinanceParameters } from '@summerfi/sdk-common/orders' import { publicProcedure } from '../TRPC' +import { isSameTokens } from '@summerfi/sdk-common/common' const inputSchema = z.custom((parameters) => parameters !== undefined) +function isToSamePair(parameters: IRefinanceParameters): boolean { + return ( + isSameTokens( + parameters.sourcePosition.debtAmount.token, + parameters.targetPosition.debtAmount.token, + ) && + isSameTokens( + parameters.sourcePosition.collateralAmount.token, + parameters.targetPosition.collateralAmount.token, + ) + ) +} + export const getRefinanceSimulation = publicProcedure .input(inputSchema) .query(async (opts): Promise> => { @@ -19,5 +34,10 @@ export const getRefinanceSimulation = publicProcedure protocolManager: opts.ctx.protocolManager, } - return await refinanceLendingToLendingSamePair(args, dependencies) + // TODO: in the end we should use just any pair + if (isToSamePair(opts.input)) { + return refinanceLendingToLendingSamePair(args, dependencies) + } + + return refinanceLendingToLendingAnyPair(args, dependencies) })