Skip to content

Commit

Permalink
Fix/oracle dto types (GalaChain#423)
Browse files Browse the repository at this point in the history
* finalize Oracle Cross-rate price assertions

support bridge out, destination chain fee transaction
calculations in tokens that aren't directly priced in
GALA, using a common cross-rate exchange rate denominated
in a widely used token.

* fix oracle dtos and types for cross rate price assertions
  • Loading branch information
sentientforest authored Nov 6, 2024
1 parent 91ce958 commit 0ed8758
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chain-api/src/types/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,20 @@ export class OracleBridgeFeeAssertionDto extends ChainCallDTO {
@JSONSchema({
description: "Exchange Rate Price Assertion used to calculate Gas Fee"
})
@IsOptional()
@ValidateIf((assertion) => !!assertion.galaExchangeCrossRate)
@ValidateNested()
@Type(() => OraclePriceAssertionDto)
public galaExchangeRate: OraclePriceAssertionDto;
public galaExchangeRate?: OraclePriceAssertionDto;

@JSONSchema({
description: "Cross-Rate Exchange Rate used to calculate Gas Fee"
})
@IsOptional()
@ValidateIf((assertion) => !!assertion.galaExchangeRate)
@ValidateNested()
@Type(() => OraclePriceCrossRateAssertion)
public galaExchangeCrossRate?: OraclePriceCrossRateAssertion;
@Type(() => OraclePriceCrossRateAssertionDto)
public galaExchangeCrossRate?: OraclePriceCrossRateAssertionDto;

@JSONSchema({
description:
Expand Down
12 changes: 12 additions & 0 deletions chaincode/src/fees/feeGateImplementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,22 @@ export async function requestTokenBridgeOutFeeGate(ctx: GalaChainContext, dto: R
txid
});
} else if (galaExchangeCrossRate !== undefined) {
const baseTokenCrossRate: OraclePriceAssertion = await createValidChainObject(OraclePriceAssertion, {
...galaExchangeCrossRate.baseTokenCrossRate,
txid
});

const quoteTokenCrossRate: OraclePriceAssertion = await createValidChainObject(OraclePriceAssertion, {
...galaExchangeCrossRate.quoteTokenCrossRate,
txid
});

bridgeFeeAssertionRecord.galaExchangeCrossRate = await createValidChainObject(
OraclePriceCrossRateAssertion,
{
...galaExchangeCrossRate,
baseTokenCrossRate,
quoteTokenCrossRate,
txid
}
);
Expand Down

0 comments on commit 0ed8758

Please sign in to comment.